示例#1
0
    def help(world_session, args):
        total_number = 0

        def _split_command_text(commands, n=8):
            command_list = list(commands)
            for i in range(0, len(command_list), n):
                yield command_list[i:i + n]

        # If player is GM, send GM commands first.
        if world_session.player_mgr.is_gm:
            ChatManager.send_system_message(world_session, '[GM Commands]')
            for commands_chunk in _split_command_text(GM_COMMAND_DEFINITIONS.keys()):
                total_number += len(commands_chunk)
                gm_commands = ' | '.join([k for k in commands_chunk])
                ChatManager.send_system_message(world_session, gm_commands)
            ChatManager.send_system_message(world_session, '\n')

        # Send Player commands.
        ChatManager.send_system_message(world_session, '[Player Commands]')
        for commands_chunk in _split_command_text(PLAYER_COMMAND_DEFINITIONS.keys()):
            total_number += len(commands_chunk)
            player_commands = ' | '.join([k for k in commands_chunk])
            ChatManager.send_system_message(world_session, player_commands)

        return 0, f'{total_number} commands found.'
示例#2
0
 def gobject_info(world_session, args):
     try:
         if args:
             max_distance = int(args)
         else:
             max_distance = 10
         found_count = 0
         for guid, gobject in list(
                 GridManager.get_surrounding_gameobjects(
                     world_session.player_mgr).items()):
             distance = world_session.player_mgr.location.distance(
                 gobject.location)
             if distance <= max_distance:
                 found_count += 1
                 ChatManager.send_system_message(
                     world_session,
                     f'[{gobject.gobject_template.name}] - Guid: {gobject.guid & ~HighGuid.HIGHGUID_GAMEOBJECT}, '
                     f'Entry: {gobject.gobject_template.entry}, '
                     f'Display ID: {gobject.display_id}, '
                     f'X: {gobject.location.x}, '
                     f'Y: {gobject.location.y}, '
                     f'Z: {gobject.location.z}, '
                     f'O: {gobject.location.o}, '
                     f'Map: {gobject.map_}, '
                     f'Distance: {distance}')
         return 0, f'{found_count} game objects found within {max_distance} distance units.'
     except ValueError:
         return -1, 'please specify a valid distance.'
示例#3
0
    def ann(world_session, args):
        ann = str(args)

        for session in WorldSessionStateHandler.get_world_sessions():
            if session.player_mgr and session.player_mgr.online:
                ChatManager.send_system_message(session, f'[SERVER] {ann}')

        return 0, ''
示例#4
0
 def tickets(world_session, args):
     tickets = RealmDatabaseManager.ticket_get_all()
     for ticket in tickets:
         ticket_color = '|cFFFF0000' if ticket.is_bug else '|cFF00FFFF'
         ticket_title = 'Bug report' if ticket.is_bug else 'Suggestion'
         ticket_text = f'{ticket_color}[{ticket.id}]|r {ticket.submit_time}: {ticket_title} from {ticket.character_name}.'
         ChatManager.send_system_message(world_session, ticket_text)
     return 0, f'{len(tickets)} tickets shown.'
示例#5
0
    def sskill(world_session, args):
        skill_name = args.strip()
        if not skill_name:
            return -1, 'please specify a skill name to start searching.'
        skills = DbcDatabaseManager.skill_get_by_name(skill_name)

        for skill in skills:
            skill_name = skill.DisplayName_enUS.replace('\\', '')
            skill_text = f'{skill.ID} - |cFF00FFFF[{skill_name}]|r'
            ChatManager.send_system_message(world_session, skill_text)
        return 0, f'{len(skills)} skills found.'
示例#6
0
    def sitem(world_session, args):
        item_name = args.strip()
        if not item_name:
            return -1, 'please specify an item name to start searching.'
        items = WorldDatabaseManager.item_template_get_by_name(item_name, return_all=True)

        for item in items:
            item_link = GameTextFormatter.generate_item_link(item.entry, item.name, item.quality)
            item_text = f'{item.entry} - {item_link}'
            ChatManager.send_system_message(world_session, item_text)
        return 0, f'{len(items)} items found.'
示例#7
0
    def stel(world_session, args):
        try:
            tel_name = args.split()[0]
        except IndexError:
            return -1, 'please specify a location name to start searching.'
        locations = WorldDatabaseManager.worldport_get_by_name(tel_name, return_all=True)

        for location in locations:
            port_text = f'|cFF00FFFF[Map {location.map}]|r - {location.name}'
            ChatManager.send_system_message(world_session, port_text)
        return 0, f'{len(locations)} worldports found.'
示例#8
0
    def sspell(world_session, args):
        spell_name = args.strip()
        if not spell_name:
            return -1, 'please specify a spell name to start searching.'
        spells = DbcDatabaseManager.spell_get_by_name(spell_name)

        for spell in spells:
            spell_name = spell.Name_enUS.replace('\\', '')
            spell_subtext = spell.NameSubtext_enUS if spell.NameSubtext_enUS else ''
            spell_text = f'{spell.ID} - |cFF00FFFF[{spell_name}]|r'
            spell_text += f' ({spell_subtext})'
            ChatManager.send_system_message(world_session, spell_text)
        return 0, f'{len(spells)} spells found.'
示例#9
0
    def handle(world_session, socket, reader):
        channel = PacketReader.read_string(reader.data, 0).strip().capitalize()
        offset = len(channel) + 1
        has_player = len(reader.data) == offset + 1
        player_name = '' if has_player else PacketReader.read_string(reader.data, offset, 0).strip()[:-1]

        target_player_mgr = WorldSessionStateHandler.find_player_by_name(player_name)
        if target_player_mgr:
            ChannelManager.kick_player(channel, world_session.player_mgr, target_player_mgr)
        else:
            ChatManager.send_system_message(world_session, f'No player named [{player_name}] is currently playing.')

        return 0
示例#10
0
    def handle(world_session, socket, reader):
        if len(reader.data) >= 4:  # Avoid handling empty area trigger packet.
            trigger_id = unpack('<I', reader.data[:4])[0]
            location = WorldDatabaseManager.area_trigger_teleport_get_by_id(
                trigger_id)
            if location:
                if world_session.player_mgr.level >= location.required_level or world_session.player_mgr.is_gm:
                    world_session.player_mgr.teleport(
                        location.target_map,
                        Vector(location.target_position_x,
                               location.target_position_y,
                               location.target_position_z,
                               location.target_orientation))
                else:
                    # SMSG_AREA_TRIGGER_MESSAGE in 1.x, but this OpCode seems to be missing in 0.5.3
                    ChatManager.send_system_message(
                        world_session,
                        f'You must be at least level {location.required_level} to enter.'
                    )

        return 0
示例#11
0
    def handle_command(world_session, command_msg):
        terminator_index = command_msg.find(' ') if ' ' in command_msg else len(command_msg)

        command = command_msg[1:terminator_index].strip()
        args = command_msg[terminator_index:].strip()

        if command in PLAYER_COMMAND_DEFINITIONS:
            command_func = PLAYER_COMMAND_DEFINITIONS.get(command)
        elif command in GM_COMMAND_DEFINITIONS and world_session.player_mgr.is_gm:
            command_func = GM_COMMAND_DEFINITIONS.get(command)
        else:
            ChatManager.send_system_message(world_session, 'Command not found, type .help for help.')
            return

        if command_func:
            code, res = command_func(world_session, args)
            if code != 0:
                ChatManager.send_system_message(world_session, f'Wrong arguments for <{command}> command: {res}')
            elif res:
                ChatManager.send_system_message(world_session, res)
示例#12
0
    def handle(world_session, socket, reader):
        chat_type, lang = unpack('<2I', reader.data[:8])
        message = ''
        guid = 0
        chat_flags = 0

        # Return if no player
        if not world_session.player_mgr:
            return 0

        # Override language to universal for GMs
        if world_session.player_mgr.is_gm:
            lang = Languages.LANG_UNIVERSAL

        # Channel
        if chat_type == ChatMsgs.CHAT_MSG_CHANNEL:
            channel = PacketReader.read_string(reader.data, 8).strip()
            message = PacketReader.read_string(reader.data,
                                               8 + len(channel) + 1)
            ChatManager.send_channel_message(world_session.player_mgr, channel,
                                             message, lang)

        # Say, Yell, Emote
        if chat_type == ChatMsgs.CHAT_MSG_SAY \
                or chat_type == ChatMsgs.CHAT_MSG_EMOTE \
                or chat_type == ChatMsgs.CHAT_MSG_YELL:
            message = PacketReader.read_string(reader.data, 8)
            guid = world_session.player_mgr.guid
            chat_flags = world_session.player_mgr.chat_flags

            # Only send message if it's not a command
            if not ChatHandler.check_if_command(world_session, message):
                ChatManager.send_chat_message(
                    world_session, guid, chat_flags, message, chat_type, lang,
                    ChatHandler.get_range_by_type(chat_type))
        # Whisper
        elif chat_type == ChatMsgs.CHAT_MSG_WHISPER:
            target_name = PacketReader.read_string(reader.data, 8).strip()
            target_player_mgr = WorldSessionStateHandler.find_player_by_name(
                target_name)
            if not target_player_mgr:
                ChatManager.send_system_message(
                    world_session,
                    f'No player named \'{target_name.capitalize()}\' is currently playing.'
                )
                return 0
            message = PacketReader.read_string(reader.data,
                                               8 + len(target_name) + 1)
            if not ChatHandler.check_if_command(world_session, message):
                # Always whisper in universal language when speaking with a GM
                if target_player_mgr.is_gm:
                    lang = Languages.LANG_UNIVERSAL

                ChatManager.send_whisper(world_session.player_mgr,
                                         target_player_mgr, message, lang)
            return 0
        # Party
        elif chat_type == ChatMsgs.CHAT_MSG_PARTY:
            if not ChatHandler.check_if_command(world_session, message):
                message = PacketReader.read_string(reader.data, 8)
                ChatManager.send_party(world_session.player_mgr, message, lang)
            return 0
        # Guild
        elif chat_type == ChatMsgs.CHAT_MSG_GUILD or chat_type == ChatMsgs.CHAT_MSG_OFFICER:
            if not ChatHandler.check_if_command(world_session, message):
                message = PacketReader.read_string(reader.data, 8)
                ChatManager.send_guild(world_session.player_mgr, message, lang,
                                       chat_type)
            return 0

        return 0
示例#13
0
    def handle(world_session, socket, reader):
        if len(reader.data) < 8:  # Avoid handling wrong player login packet.
            return -1

        guid = unpack('<Q', reader.data[:8])[0]

        world_session.player_mgr = PlayerManager(
            RealmDatabaseManager.character_get_by_guid(guid), world_session)
        world_session.player_mgr.session = world_session
        if not world_session.player_mgr.player:
            Logger.anticheat(
                f'Character with wrong guid ({guid}) tried to login.')
            return -1
        else:
            WorldSessionStateHandler.push_active_player_session(world_session)

        # Disabled race & class checks (only if not a GM)
        if not world_session.player_mgr.is_gm:
            disabled_race_mask = config.Server.General.disabled_race_mask
            disabled = disabled_race_mask & world_session.player_mgr.race_mask == world_session.player_mgr.race_mask

            if not disabled:
                disabled_class_mask = config.Server.General.disabled_class_mask
                disabled = disabled_class_mask & world_session.player_mgr.class_mask == world_session.player_mgr.class_mask

            if disabled:
                # Not 100% sure if CHAR_LOGIN_DISABLED matters here, but I don't know where else to send it
                data = pack('<B', CharLogin.CHAR_LOGIN_DISABLED)
                world_session.enqueue_packet(
                    PacketWriter.get_packet(OpCode.SMSG_CHARACTER_LOGIN_FAILED,
                                            data))
                return 0

        # Class & race allowed, continue with the login process

        world_session.enqueue_packet(
            PacketWriter.get_packet(OpCode.SMSG_LOGIN_SETTIMESPEED,
                                    PlayerLoginHandler._get_login_timespeed()))

        world_session.player_mgr.skill_manager.load_proficiencies()
        world_session.player_mgr.spell_manager.load_spells()

        world_session.player_mgr.deathbind = RealmDatabaseManager.character_get_deathbind(
            world_session.player_mgr.guid)
        world_session.player_mgr.friends_manager.load_from_db(
            RealmDatabaseManager.character_get_social(
                world_session.player_mgr.guid))

        world_session.enqueue_packet(
            world_session.player_mgr.get_deathbind_packet())
        # Tutorials aren't implemented in 0.5.3
        # world_session.enqueue_packet(world_session.player_mgr.get_tutorial_packet())
        world_session.player_mgr.skill_manager.init_proficiencies()
        world_session.enqueue_packet(
            world_session.player_mgr.spell_manager.get_initial_spells())
        world_session.enqueue_packet(
            world_session.player_mgr.get_action_buttons())

        # MotD
        ChatManager.send_system_message(world_session,
                                        config.Server.General.motd)

        world_session.player_mgr.inventory.load_items()
        world_session.player_mgr.stat_manager.init_stats()
        world_session.player_mgr.stat_manager.apply_bonuses()
        world_session.player_mgr.skill_manager.load_skills()
        world_session.player_mgr.quest_manager.load_quests()
        world_session.player_mgr.reputation_manager.load_reputations()
        GuildManager.set_character_guild(world_session.player_mgr)
        GroupManager.set_character_group(world_session.player_mgr)
        PetitionManager.load_petition(world_session.player_mgr)

        # First login
        if world_session.player_mgr.player.totaltime == 0:
            # Replenish health, and mana if needed.
            world_session.player_mgr.set_health(
                world_session.player_mgr.max_health)
            if world_session.player_mgr.power_type == PowerTypes.TYPE_MANA:
                world_session.player_mgr.set_mana(
                    world_session.player_mgr.max_power_1)

            # Load self before sending cinematic
            PlayerLoginHandler._load_self(world_session.player_mgr)

            # Send cinematic
            PlayerLoginHandler._send_cinematic(world_session,
                                               world_session.player_mgr.player,
                                               socket)
        else:
            PlayerLoginHandler._load_self(world_session.player_mgr)

        world_session.player_mgr.complete_login()

        return 0