class MovePacket: def __init__(self): self.type = "MOVE" self.tickId = 0 self.time = 0 self.serverRealTimeMS = 0 self.newPos = WorldPosData() self.records = [] def write(self, writer): writer.writeInt32(self.tickId) writer.writeInt32(self.time) writer.writeUInt32(self.serverRealTimeMS) self.newPos.write(writer) writer.writeShort(len(self.records)) for record in self.records: record.write(writer) def read(self, reader): self.tickId = reader.readInt32() self.time = reader.readInt32() self.serverRealTimeMS = reader.readUInt32() self.newPos.read(reader) recordLen = reader.readShort() for i in range(recordLen): record = MoveRecord() record.read(reader) self.records.append(record)
class PlayerShootPacket: def __init__(self): self.type = "PLAYERSHOOT" self.time = 0 self.bulletId = 0 self.containerType = 0 self.pos = WorldPosData() self.angle = 0 self.speedMult = 0 self.lifeMult = 0 self.isBurst = False def write(self, writer): writer.writeInt32(self.time) writer.writeByte(self.bulletId) writer.writeShort(self.containerType) self.pos.write(writer) writer.writeFloat(self.angle) writer.writeShort(int(self.speedMult * 1000)) writer.writeShort(int(self.lifeMult * 1000)) writer.writeBool(self.isBurst) def read(self, reader): self.time = reader.readInt32() self.bulletId = reader.readByte() self.containerType = reader.readShort() self.pos.read(reader) self.angle = reader.readFloat() self.speedMult = int(reader.readShort() / 1000) self.lifeMult = int(reader.readShort() / 1000) self.isBurst = reader.readBool()
class GroundDamagePacket: def __init__(self): self.type = "GROUNDDAMAGE" self.time = 0 self.pos = WorldPosData() def write(self, writer): writer.writeInt32(self.time) self.pos.write(writer) def read(self, reader): self.time = reader.readInt32() self.pos.read(reader)
class InvSwapPacket: def __init__(self): self.type = "INVSWAP" self.time = 0 self.pos = WorldPosData() self.slotObject1 = SlotObjectData() self.slotObject2 = SlotObjectData() def write(self, writer): writer.writeInt32(self.time) self.pos.write(writer) self.slotObject1.write(writer) self.slotObject2.write(writer) def read(self, reader): self.time = reader.readInt32() self.pos.read(reader) self.slotObject1.read(reader) self.slotObject2.read(reader)
class UseItemPacket: def __init__(self): self.type = "USEITEM" self.time = 0 self.slotObject = SlotObjectData() self.pos = WorldPosData() self.useType = 0 def write(self, writer): writer.writeInt32(self.time) self.slotObject.write(writer) self.pos.write(writer) writer.writeByte(self.useType) def read(self, reader): self.time = reader.readInt32() self.slotObject.read(reader) self.pos.read(reader) self.useType = reader.readByte()