Featured Image

Ace of Spades 0.54 Protocol

Documenting the network protocol and packet types for Ace of Spades 0.54 using pyspades source code as a reference.
Published: — Last Modified:

About the protocol

Ace of Spades uses the ENET networking library with compression on top of UDP. There is no encryption involved. All packets begin with an identifier byte to indicate the packet type. Total size includes this byte.

Ace of Spades uses a client-server model:

  • server.py - receives packets as defined in clientloaders.pyx, sends packets as defined in serverloaders.pyx
  • client.exe - receives packets as defined in serverloaders.pyx, sends packets as defined in clientloaders.pyx

I am using the following pyspades server commit: d7de49161c9e355920c07fa1dd6fbeb572edd410

The source code for the original Ace of Spades 0.54 client is not known.

What needs to be done

Documentation of the remaining packets still needs to be finished. This version of the game also handles map downloads differently (no compression or chunks).


PositionData (0)

Update player position on the map.

Server to Client:

int player_id
float x
float y
float z

Client to Server:

float x
float y
float z

OrientationData (1)

Update player angles. These correspond to the direction the player camera is looking.

Server to Client:

int player_id
float x
float y
float z

Client to Server:

float x
float y
float z

MovementData (2)

Update player movement. These correspond to the movement keys the player is pressing.

Server to Client:

int player_id
bint up
bint down
bint left
bint right

Client to Server:

bint up
bint down
bint left
bint right

AnimationData (3)

Update player actions. These correspond to the action keys the player is pressing.

Server to Client:

int player_id
bint fire
bint jump
bint crouch
bint aim

Client to Server:

bint fire
bint jump
bint crouch
bint aim

HitPacket (4)

Register player damage.

Server to Client:

int hp
bint not_fall

Client to Server:

Servers should check this if this is a valid hit first.

int player_id
int value

GrenadePacket (5)

Spawn a grenade on the map.

Server to Client:

int player_id
float value

Client to Server:

float value

SetTool (6)

Update player held tool.

value Tool
0 Spade
1 ?
2 Block
3 Weapon

Server to Client:

int player_id
int value

Client to Server:

int value

SetColor (7)

Update player block color.

unsigned int player_id
unsigned int blue
unsigned int green
unsigned int red

ExistingPlayer (8)

Update player attributes.

Team:

value Team
0 Team 1 (Blue)
1 Team 2 (Green)

Weapon:

value Weapon
0 Semi-Auto Rifle
1 Sub-Machine Gun

Block Color:

Three bytes. Color format is in BGR (Blue, Green, Red).

Name:

String. Uses ASCII code page 437.

Server to Client:

Used when the server wants to respawn a player.

int player_id
int team
int weapon
int tool
int kills
int blue
int green
int red
object name

Note: Packet size varies by name length.

Client to Server:

Used when the client wants to change teams/weapon. When received by the server, kill the client.

int team
int weapon
object name

Note: Packet size varies by name length.


IntelAction (9)

Update the current gamestate.

Action Type:

The action that just happened.

value Action Type Description
0 Intel/tent move Updates Z coordinate of intel or tent being moved.

Used by Action 3 or when player digs/builds blocks below intel/tent.

1 Intel taken Updates which player_id is currently holding the intel.
2 Intel drop Updates which player_id dropped the intel and current intel XYZ coordinates.
3 Intel capture Updates which player_id captured the intel and new intel XY location.

If game_end, update both intel and tent XY locations.

4 Health/ammo refill  

Move Type:

Used for Action 0.

value Move Type
0 team_1_intel (Blue)
1 team_2_intel (Green)
2 team_1_base (Blue)
3 team_2_base (Green)

Server to Client:

int player_id
int action_type
int x
int y
int z
int move_type
int blue_flag_x
int blue_flag_y
int green_flag_x
int green_flag_y
int blue_base_x
int blue_base_y
int green_base_x
int green_base_y
bint game_end

CreatePlayer (10)

Create and spawn a newly joined player.

Server to Client:

int player_id
int x
int y
int weapon
object name

Note: Packet size varies by name length.


BlockAction (11)

Update block on the map.

Action Type:

value action
0 Build
1 Gun/Pickaxe Destroy (single block)
2 Spade Destroy (1x3 blocks)
3 Grenade Destroy (3x3 blocks)

Server to Client:

unsigned int player_id
unsigned int value
unsigned int x
unsigned int y
unsigned int z

Client to Server:

unsigned int value
unsigned int x
unsigned int y
unsigned int z

PlayerData (12)

"CTF State"

int player_left
int player_id
int blue_score
int green_score
int max_score
int green_flag_player
int blue_flag_player
int green_flag_x
int green_flag_y
int green_flag_z
int blue_flag_x
int blue_flag_y
int blue_flag_z
int blue_base_x
int blue_base_y
int blue_base_z
int green_base_x
int green_base_y
int green_base_z

KillAction (13)

Report player death.

bint not_fall
int player1
int player2

ChatMessage (14)

To be continued...

Tags: aos