Beispiel #1
0
    def serialize(self, stream):
        stream.write(c_bit(True))
        stream.write(c_uint32(0))

        stream.write(c_bit(True))
        stream.write(c_uint32(self.state))
        stream.write(c_bit(self.success))
        stream.write(c_bit(self.enabled))
        stream.write(c_float(self.start))
        stream.write(c_float(self.paused))
Beispiel #2
0
    def write_construction(self, stream):
        self.serialize(stream)

        stream.write(c_bit(False))

        stream.write(c_float(self.activator_pos.x))
        stream.write(c_float(self.activator_pos.y))
        stream.write(c_float(self.activator_pos.z))

        stream.write(c_bit(True))
Beispiel #3
0
    def serialize(self, stream):
        """
        Serializes the packet
        """
        super().serialize(stream)

        stream.write(c_uint16(self.zone_id))
        stream.write(c_uint16(self.map_instance))
        stream.write(c_uint32(self.map_clone))
        stream.write(c_uint32(self.map_checksum))
        stream.write(c_uint16(self.unknown1))
        stream.write(c_float(self.pos.x))
        stream.write(c_float(self.pos.y))
        stream.write(c_float(self.pos.z))
        stream.write(c_uint32(self.is_activity))
Beispiel #4
0
 def serialize(self, stream: bitstream.WriteStream) -> None:
     key_num = len(self._keys)
     stream.write(bitstream.c_uint(key_num))
     for key in self._keys:
         name = key[0]
         value = key[1]
         value_type = key[2]
         stream.write(bitstream.c_uint8(len(name) * 2))
         for char in name:
             stream.write(char.encode('latin1'))
             stream.write(b'\0')
         stream.write(bitstream.c_ubyte(value_type))
         if value_type == 0:
             stream.write(value, length_type=bitstream.c_uint)
         elif value_type == 1:
             stream.write(bitstream.c_int(value))
         elif value_type == 3:
             stream.write(bitstream.c_float(value))
         elif value_type == 5:
             stream.write(bitstream.c_uint(value))
         elif value_type == 7:
             stream.write(bitstream.c_bool(value))
         elif value_type == 8 or value_type == 9:
             stream.write(bitstream.c_int64(value))
         elif value_type == 13:
             xml_str = bytes(ElementTree.tostring(value))
             xml_str = b'<?xml version="1.0">' + xml_str
             stream.write(bitstream.c_ulong(xml_str.__len__()))
             stream.write(xml_str)
Beispiel #5
0
    def write_construction(self, stream):
        """
        Writes construction data to a stream
        """
        stream.write(c_bit(False))  # NOTE: unknown
        stream.write(c_float(0))  # NOTE: unknown

        self.serialize(stream)
Beispiel #6
0
    def write_data(self, stream):
        stream.write(c_bit(self.stats))

        if self.stats:
            stream.write(c_uint32(self.health))
            stream.write(c_float(self.max_health))

            stream.write(c_uint32(self.armor))
            stream.write(c_float(self.max_armor))

            stream.write(c_uint32(self.imagination))
            stream.write(c_float(self.max_imagination))

            stream.write(c_uint32(0))  # NOTE: unknown
            stream.write(c_bit(True))
            stream.write(c_bit(False))
            stream.write(c_bit(False))

            stream.write(c_float(self.max_health))
            stream.write(c_float(self.max_armor))
            stream.write(c_float(self.max_imagination))

            stream.write(c_uint32(len(self.factions)))

            for faction_id in self.factions:
                stream.write(c_int32(faction_id))

            stream.write(c_bit(self.smashable))
Beispiel #7
0
    def collected(self, packet, conn: Connection, stream: ReadStream):
        """
        Handles the has been collected game message
        """

        objid = stream.read(c_int64)

        print(f'Collected object')
        print(f'ID: {packet.objid}')
        print(f'Player: {objid}')

        session = self.server.handle_until_return('session:get_session',
                                                  conn.get_address())
        char = self.server.handle_until_return(
            'char:characters',
            session.account.user.id)[session.account.front_character]
        clone = self.server.handle_until_return('world:get_clone',
                                                session.clone)
        char_missions = self.server.handle_until_return(
            'char:get_missions', char.pk)

        objs = [x for x in clone.objects if x.objid == packet.objid]

        if objs:
            obj = objs[0]

            for char_mission in [x for x in char_missions if x.state == 2]:
                tasks = self.server.handle_until_return(
                    'world:get_mission_tasks', char_mission.mission)

                for task in tasks:
                    if task[3] == obj.lot and task[2] == 3:
                        char_mission.progress += 1
                        char_mission.save()

                        wstr = WriteStream()

                        wstr.write(c_int(char_mission.mission))
                        wstr.write(c_int(1 << (tasks.index(task) + 1)))
                        wstr.write(c_uint8(1))
                        wstr.write(
                            c_float(char_mission.progress + (clone.zone << 8)))

                        msg = ServerGameMessage(
                            objid, GameMessageID.NOTIFY_MISSION_TASK, wstr)

                        conn.send(msg)

                        return
Beispiel #8
0
    def serialize(self, stream):
        """
        Serializes the component
        """
        stream.write(c_bit(False))  # NOTE: unknown
        stream.write(c_bit(False))  # NOTE: unknown

        stream.write(c_bit(True))
        stream.write(c_float(self.pos.x))
        stream.write(c_float(self.pos.y))
        stream.write(c_float(self.pos.z))
        stream.write(c_float(self.rot.x))
        stream.write(c_float(self.rot.y))
        stream.write(c_float(self.rot.z))
        stream.write(c_float(self.rot.w))
    def write_data(self, stream):
        """
        Writes object data
        """
        stream.write(c_bit(False))  # NOTE: flag is unknown

        stream.write(c_bit(True))  # NOTE: same as above
        stream.write(c_float(0))
        stream.write(c_bit(False))

        stream.write(c_bit(True))  # NOTE: same here
        stream.write(c_bit(False))

        stream.write(c_bit(self.player))

        if self.player:
            stream.write(c_float(self.player_pos.x))
            stream.write(c_float(self.player_pos.y))
            stream.write(c_float(self.player_pos.z))

            stream.write(c_float(self.player_rot.x))
            stream.write(c_float(self.player_rot.y))
            stream.write(c_float(self.player_rot.z))
            stream.write(c_float(self.player_rot.w))

            stream.write(c_bit(self.player_ground))
            stream.write(c_bit(self.player_rail))

            stream.write(c_bit(self.player_velocity))

            if self.player_velocity:
                stream.write(c_float(self.player_velocity_vec.x))
                stream.write(c_float(self.player_velocity_vec.y))
                stream.write(c_float(self.player_velocity_vec.z))

            stream.write(c_bit(self.player_angular_velocity))

            if self.player_angular_velocity:
                stream.write(c_float(self.player_angular_velocity_vec.x))
                stream.write(c_float(self.player_angular_velocity_vec.y))
                stream.write(c_float(self.player.angular_velocity_vec.z))

            stream.write(c_bit(False))  # NOTE: unknown flag
Beispiel #10
0
 def serialize(self, stream):
     stream.write(c_float(self.x))
     stream.write(c_float(self.y))
     stream.write(c_float(self.z))
     stream.write(c_float(self.w))
Beispiel #11
0
    def serialize(self, stream):
        """
        Serializes the component
        """
        stream.write(c_bit(True))
        stream.write(c_float(self.pos.x))
        stream.write(c_float(self.pos.y))
        stream.write(c_float(self.pos.z))
        stream.write(c_float(self.rot.x))
        stream.write(c_float(self.rot.y))
        stream.write(c_float(self.rot.z))
        stream.write(c_float(self.rot.w))

        stream.write(c_bit(True))
        stream.write(c_bit(self.effect))
        if self.effect:
            stream.write(c_uint32(self.effect_type))
            stream.write(c_float(self.effect_amount))
            stream.write(c_bit(False))
            stream.write(c_bit(True))
            stream.write(c_float(self.effect_direction.x))
            stream.write(c_float(self.effect_direction.y))
            stream.write(c_float(self.effect_direction.z))