Example #1
0
    def use(self, player):
        if self.gobject_template.type == GameObjectTypes.TYPE_DOOR or \
                self.gobject_template.type == GameObjectTypes.TYPE_BUTTON:
            # TODO: Check locks for doors
            if self.state == GameObjectStates.GO_STATE_READY:
                self.state = GameObjectStates.GO_STATE_ACTIVE
                # TODO: Trigger sripts / events on cooldown restart
                self.send_update_surrounding()
        elif self.gobject_template.type == GameObjectTypes.TYPE_CAMERA:
            cinematic_id = self.gobject_template.data1
            if DbcDatabaseManager.cinematic_sequences_get_by_id(cinematic_id):
                data = pack('<I', cinematic_id)
                player.session.enqueue_packet(
                    PacketWriter.get_packet(OpCode.SMSG_TRIGGER_CINEMATIC,
                                            data))
        elif self.gobject_template.type == GameObjectTypes.TYPE_CHAIR:
            slots = self.gobject_template.data0
            height = self.gobject_template.data1

            lowest_distance = 90.0
            x_lowest = self.location.x
            y_lowest = self.location.y

            if slots > 0:
                orthogonal_orientation = self.location.o + pi * 0.5
                for x in range(0, slots):
                    relative_distance = (self.current_scale *
                                         x) - (self.current_scale *
                                               (slots - 1) / 2.0)
                    x_i = self.location.x + relative_distance * cos(
                        orthogonal_orientation)
                    y_i = self.location.y + relative_distance * sin(
                        orthogonal_orientation)

                    player_slot_distance = player.location.distance(
                        Vector(x_i, y_i, player.location.z))
                    if player_slot_distance <= lowest_distance:
                        lowest_distance = player_slot_distance
                        x_lowest = x_i
                        y_lowest = y_i
                player.teleport(
                    player.map_,
                    Vector(x_lowest, y_lowest, self.location.z,
                           self.location.o))
                player.set_stand_state(StandState.UNIT_SITTINGCHAIRLOW.value +
                                       height)
        elif self.gobject_template.type == GameObjectTypes.TYPE_CHEST:
            # Activate chest open animation, while active, it won't let any other player loot.
            if self.state == GameObjectStates.GO_STATE_READY:
                self.state = GameObjectStates.GO_STATE_ACTIVE
                self.send_update_surrounding()

            # Generate loot if it's empty.
            if not self.loot_manager.has_loot():
                self.loot_manager.generate_loot(player)

            player.send_loot(self)
    def handle(world_session, socket, reader: PacketReader) -> int:
        if len(reader.data) >= 4:  # Avoid handling empty trigger cinematic cheat packet.
            if not world_session.player_mgr.is_gm:
                return 0

            cinematic_id = unpack('<I', reader.data[:4])[0]
            if DbcDatabaseManager.cinematic_sequences_get_by_id(cinematic_id):
                data = pack('<I', cinematic_id)
                world_session.enqueue_packet(PacketWriter.get_packet(OpCode.SMSG_TRIGGER_CINEMATIC, data))

        return 0
    def use(self, player):
        if self.gobject_template.type == GameObjectTypes.TYPE_DOOR or \
                self.gobject_template.type == GameObjectTypes.TYPE_BUTTON:
            # TODO: Check locks for doors
            if self.state == GameObjectStates.GO_STATE_READY:
                self.state = GameObjectStates.GO_STATE_ACTIVE
                # TODO: Trigger sripts / events on cooldown restart
                self.send_update_surrounding()
        elif self.gobject_template.type == GameObjectTypes.TYPE_CAMERA:
            cinematic_id = self.gobject_template.data2
            if DbcDatabaseManager.cinematic_sequences_get_by_id(cinematic_id):
                data = pack('<I', cinematic_id)
                player.session.request.sendall(
                    PacketWriter.get_packet(OpCode.SMSG_TRIGGER_CINEMATIC,
                                            data))
        elif self.gobject_template.type == GameObjectTypes.TYPE_CHAIR:
            slots = self.gobject_template.data1
            height = self.gobject_template.data2

            lowest_distance = 90.0
            x_lowest = self.location.x
            y_lowest = self.location.y

            if slots > 0:
                orthogonal_orientation = self.location.o + pi * 0.5
                for x in range(0, slots):
                    relative_distance = (self.scale * x) - (self.scale *
                                                            (slots - 1) / 2.0)
                    x_i = self.location.x + relative_distance * cos(
                        orthogonal_orientation)
                    y_i = self.location.y + relative_distance * sin(
                        orthogonal_orientation)

                    player_slot_distance = player.location.distance(
                        Vector(x_i, y_i, player.location.z))
                    if player_slot_distance <= lowest_distance:
                        lowest_distance = player_slot_distance
                        x_lowest = x_i
                        y_lowest = y_i
                player.teleport(
                    player.map_,
                    Vector(x_lowest, y_lowest, self.location.z,
                           self.location.o))
                player.stand_state = StandState.UNIT_SITTINGCHAIRLOW.value + height
    def handle(world_session, socket, reader: PacketReader) -> int:
        player_mgr = world_session.player_mgr
        if not player_mgr:
            return 0

        if not player_mgr.is_gm:
            Logger.anticheat(
                f'Player {player_mgr.player.name} ({player_mgr.guid}) tried to force trigger a cinematic.'
            )
            return 0

        if len(reader.data
               ) >= 4:  # Avoid handling empty trigger cinematic cheat packet.
            cinematic_id = unpack('<I', reader.data[:4])[0]
            if DbcDatabaseManager.cinematic_sequences_get_by_id(cinematic_id):
                data = pack('<I', cinematic_id)
                world_session.enqueue_packet(
                    PacketWriter.get_packet(OpCode.SMSG_TRIGGER_CINEMATIC,
                                            data))

        return 0
Example #5
0
 def _handle_use_camera(self, player):
     cinematic_id = self.gobject_template.data1
     if DbcDatabaseManager.cinematic_sequences_get_by_id(cinematic_id):
         data = pack('<I', cinematic_id)
         player.enqueue_packet(PacketWriter.get_packet(OpCode.SMSG_TRIGGER_CINEMATIC, data))