示例#1
0
    def load_trainer_spells():
        trainer_spells = WorldDatabaseManager.trainer_spell_get_all()
        length = len(trainer_spells)
        count = 0

        for trainer_spell in trainer_spells:
            WorldDatabaseManager.TrainerSpellHolder.load_trainer_spell(
                trainer_spell)

            count += 1
            Logger.progress('Loading trainer spells...', count, length)

        return length
示例#2
0
    def load_fishing_loot_templates():
        fishing_loot_templates = WorldDatabaseManager.fishing_get_loot_template(
        )
        length = len(fishing_loot_templates)
        count = 0

        for loot_template in fishing_loot_templates:
            WorldDatabaseManager.FishingLootTemplateHolder.load_fishing_loot_template(
                loot_template)
            count += 1
            Logger.progress('Loading fishing loot templates...', count, length)

        return length
示例#3
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.'
示例#4
0
    def load_spell_chains():
        spell_chains: list[
            SpellChain] = WorldDatabaseManager.spell_chain_get_all()
        length = len(spell_chains)
        count = 0

        for spell_chain in spell_chains:
            WorldDatabaseManager.SpellChainHolder.load_spell_chain(spell_chain)

            count += 1
            Logger.progress('Loading spell chains...', count, length)

        return length
示例#5
0
    def load_quests():
        quest_templates = WorldDatabaseManager.quest_template_get_all()
        length = len(quest_templates)
        count = 0

        for quest_template in quest_templates:
            WorldDatabaseManager.QuestTemplateHolder.load_quest_template(
                quest_template)

            count += 1
            Logger.progress('Loading quest templates...', count, length)

        return length
示例#6
0
    def load_item_templates():
        item_templates = WorldDatabaseManager.item_template_get_all()
        length = len(item_templates)
        count = 0

        for item_template in item_templates:
            WorldDatabaseManager.ItemTemplateHolder.load_item_template(
                item_template)

            count += 1
            Logger.progress('Loading item templates...', count, length)

        return length
示例#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 = '|cFF00FFFF[Map %s]|r - %s' % (location.map,
                                                       location.name)
            ChatManager.send_system_message(world_session, port_text)
        return 0, '%u worldports found.' % len(locations)
示例#8
0
    def load_reference_loot_templates():
        reference_loot_templates = WorldDatabaseManager.reference_loot_template_get_all(
        )
        length = len(reference_loot_templates)
        count = 0

        for reference_loot_template in reference_loot_templates:
            WorldDatabaseManager.ReferenceLootTemplateHolder.load_reference_loot_template(
                reference_loot_template)
            count += 1
            Logger.progress('Loading reference loot templates...', count,
                            length)

        return length
示例#9
0
    def load_pickpocketing_loot_templates():
        pickpocketing_loot_templates = WorldDatabaseManager.pickpocketing_loot_template_get_all(
        )
        length = len(pickpocketing_loot_templates)
        count = 0

        for pickpocketing_loot_template in pickpocketing_loot_templates:
            WorldDatabaseManager.PickPocketingLootTemplateHolder.load_pickpocketing_loot_template(
                pickpocketing_loot_template)
            count += 1
            Logger.progress('Loading pickpocketing loot templates...', count,
                            length)

        return length
示例#10
0
    def load_creature_on_kill_reputation():
        creature_on_kill_reputations = WorldDatabaseManager.creature_on_kill_reputation_get_all(
        )
        length = len(creature_on_kill_reputations)
        count = 0

        for creature_on_kill_reputation in creature_on_kill_reputations:
            WorldDatabaseManager.CreatureOnKillReputationHolder.load_creature_on_kill_reputation(
                creature_on_kill_reputation)
            count += 1
            Logger.progress('Loading creature on kill reputations...', count,
                            length)

        return length
示例#11
0
    def load_creature_equip_templates():
        creature_equip_templates = WorldDatabaseManager.creature_equip_template_get_all(
        )
        length = len(creature_equip_templates)
        count = 0

        for creature_equip_template in creature_equip_templates:
            WorldDatabaseManager.CreatureEquipmentHolder.load_creature_equip_template(
                creature_equip_template)
            count += 1
            Logger.progress('Loading creature equipment templates...', count,
                            length)

        return length
示例#12
0
    def resolve_table_coordinates(casting_spell, target_effect):
        target_position = WorldDatabaseManager.spell_target_position_get_by_spell(
            casting_spell.spell_entry.ID)
        if not target_position:
            Logger.warning(
                f'Unimplemented target spell position for spell {casting_spell.spell_entry.ID}.'
            )
            return []

        return target_position.target_map, Vector(
            target_position.target_position_x,
            target_position.target_position_y,
            target_position.target_position_z,
            target_position.target_orientation)
示例#13
0
    def load_creature_quests():
        creature_quests = WorldDatabaseManager.creature_quest_get_all()
        length = len(creature_quests)
        count = 0

        for creature_quest in creature_quests:
            WorldDatabaseManager.QuestRelationHolder.load_creature_quest(
                creature_quest)

            count += 1
            Logger.progress('Loading creature quest relations...', count,
                            length)

        return length
示例#14
0
    def load_creature_loot_templates():
        creature_loot_templates = WorldDatabaseManager.creature_get_loot_template(
        )
        length = len(creature_loot_templates)
        count = 0

        for loot_template in creature_loot_templates:
            WorldDatabaseManager.CreatureLootTemplateHolder.load_creature_loot_template(
                loot_template)
            count += 1
            Logger.progress('Loading creature loot templates...', count,
                            length)

        return length
示例#15
0
 def generate_starting_item(owner, entry, last_bag_slot):
     item_template = WorldDatabaseManager.item_template_get_by_entry(entry)
     if item_template:
         slot = ItemManager.get_inv_slot_by_type(item_template.inventory_type)
         if slot >= InventorySlots.SLOT_INBACKPACK:
             slot = last_bag_slot
         bag = InventorySlots.SLOT_INBACKPACK.value
         count = 1
         if item_template.inventory_type == 0 and item_template.class_ == 0:
             count = 2 if item_template.spellid_1 == 430 else 4
         elif item_template.inventory_type == 24:
             count = 200
         return ItemManager.generate_item(item_template, owner, bag, slot, count=count)
     return None
示例#16
0
    def load_gameobject_loot_templates():
        gameobject_loot_templates = WorldDatabaseManager.gameobject_get_loot_template(
        )
        length = len(gameobject_loot_templates)
        count = 0

        for loot_template in gameobject_loot_templates:
            WorldDatabaseManager.GameObjectLootTemplateHolder.load_gameobject_loot_template(
                loot_template)
            count += 1
            Logger.progress('Loading gameobject loot templates...', count,
                            length)

        return length
示例#17
0
    def load_creature_model_info():
        creature_model_infos = WorldDatabaseManager.creature_model_info_get_all(
        )
        length = len(creature_model_infos)
        count = 0

        for creature_model_info in creature_model_infos:
            WorldDatabaseManager.CreatureModelInfoHolder.load_creature_model_info(
                creature_model_info)

            count += 1
            Logger.progress('Loading creature model info...', count, length)

        return length
示例#18
0
    def load_gameobject_quest_starters():
        gameobject_quest_starters = WorldDatabaseManager.gameobject_quest_starter_get_all(
        )
        length = len(gameobject_quest_starters)
        count = 0

        for gameobject_quest_starter in gameobject_quest_starters:
            WorldDatabaseManager.QuestRelationHolder.load_gameobject_starter_quest(
                gameobject_quest_starter)

            count += 1
            Logger.progress('Loading gameobject quest starters...', count,
                            length)

        return length
示例#19
0
    def load_creature_quest_finishers():
        creature_quest_finishers = WorldDatabaseManager.creature_quest_finisher_get_all(
        )
        length = len(creature_quest_finishers)
        count = 0

        for creature_quest_finisher in creature_quest_finishers:
            WorldDatabaseManager.QuestRelationHolder.load_creature_finisher_quest(
                creature_quest_finisher)

            count += 1
            Logger.progress('Loading creature quest finishers...', count,
                            length)

        return length
示例#20
0
    def load_area_trigger_quest_relations():
        area_trigger_quest_relations = WorldDatabaseManager.area_trigger_quest_relations_get_all(
        )
        length = len(area_trigger_quest_relations)
        count = 0

        for area_trigger_relation in area_trigger_quest_relations:
            WorldDatabaseManager.QuestRelationHolder.load_area_trigger_quest_relation(
                area_trigger_relation)

            count += 1
            Logger.progress('Loading area trigger quest relations...', count,
                            length)

        return length
示例#21
0
    def tel(world_session, args):
        try:
            tel_name = args.split()[0]
        except IndexError:
            return -1, 'please specify a location name.'
        location = WorldDatabaseManager.worldport_get_by_name(tel_name)

        if location:
            tel_location = Vector(location.x, location.y, location.z, location.o)
            success = world_session.player_mgr.teleport(location.map, tel_location)

            if success:
                return 0, f'Teleported to "{location.name}".'
            return -1, f'map not found ({location.map}).'
        return -1, f'"{tel_name}" not found.'
    def generate_loot(self):
        # TODO: Implement loot group handling
        money = randint(self.world_obj.creature_template.gold_min, self.world_obj.creature_template.gold_max)
        self.current_money = money

        for loot_item in self.loot_template:
            chance = float(round(uniform(0.0, 1.0), 2) * 100)
            item_template = WorldDatabaseManager.item_template_get_by_entry(loot_item.item)
            if item_template:
                item_chance = loot_item.ChanceOrQuestChance
                item_chance = item_chance if item_chance > 0 else item_chance * -1

                if item_chance >= 100 or chance - item_chance < 0:
                    item = ItemManager.generate_item_from_entry(item_template.entry)
                    if item:
                        self.current_loot.append(LootHolder(item, randint(loot_item.mincountOrRef, loot_item.maxcount)))
    def handle(world_session, socket, reader):
        if len(reader.data) >= 12:  # Avoid handling empty creature query packet.
            entry, guid = unpack('<IQ', reader.data[:12])
            if guid > 0:
                creature_mgr = MapManager.get_surrounding_unit_by_guid(world_session.player_mgr, guid)
                if not creature_mgr:
                    creature_spawn, session = WorldDatabaseManager.creature_spawn_get_by_guid(guid)
                    if creature_spawn and creature_spawn.creature_template.entry == entry:
                        creature_mgr = CreatureManager(
                            creature_template=creature_spawn.creature_template
                        )
                    session.close()
                if creature_mgr:
                    world_session.enqueue_packet(creature_mgr.query_details())

        return 0
示例#24
0
    def handle(world_session, socket, reader):
        if len(reader.data) >= 12:  # Avoid handling empty gameobject query packet.
            entry, guid = unpack('<IQ', reader.data[:12])
            if guid > 0:
                gobject_mgr = MapManager.get_surrounding_gameobject_by_guid(world_session.player_mgr, guid)
                if not gobject_mgr:
                    gobject_spawn, session = WorldDatabaseManager.gameobject_spawn_get_by_guid(guid)
                    if gobject_spawn and gobject_spawn.gameobject.entry == entry:
                        gobject_mgr = GameObjectManager(
                            gobject_template=gobject_spawn.gameobject
                        )
                    session.close()
                if gobject_mgr:
                    world_session.enqueue_packet(gobject_mgr.query_details())

        return 0
示例#25
0
    def handle(world_session, socket, reader):
        if len(reader.data) >= 22:  # Avoid handling empty buy item packet.
            vendor_guid, item, bag_guid, slot, count = unpack(
                '<QIQ2B', reader.data[:22])
            if vendor_guid > 0:
                if count <= 0:
                    count = 1

                vendor_npc = MapManager.get_surrounding_unit_by_guid(
                    world_session.player_mgr, vendor_guid)

                vendor_data, session = WorldDatabaseManager.creature_get_vendor_data_by_item(
                    vendor_npc.entry, item)

                if vendor_data:
                    item_template = vendor_data.item_template
                    session.close()

                    total_cost = item_template.buy_price * count
                    real_count = count if item_template.buy_count == 1 else item_template.buy_count

                    if world_session.player_mgr.coinage < total_cost:
                        world_session.player_mgr.inventory.send_buy_error(
                            BuyResults.BUY_ERR_NOT_ENOUGH_MONEY, item,
                            vendor_guid, real_count)
                        return 0

                    if 0 < vendor_data.maxcount < count:  # I should be checking here for current count too
                        world_session.player_mgr.inventory.send_buy_error(
                            BuyResults.BUY_ERR_ITEM_SOLD_OUT, item,
                            vendor_guid, real_count)
                        return 0

                    bag_slot = world_session.player_mgr.inventory.get_container_slot_by_guid(
                        bag_guid)
                    if world_session.player_mgr.inventory.add_item_to_slot(
                            dest_bag_slot=bag_slot,
                            dest_slot=slot,
                            item_template=item_template,
                            count=real_count):
                        world_session.player_mgr.mod_money(total_cost * -1)
                        # vendor_npc.send_inventory_list(world_session)
                else:
                    world_session.player_mgr.inventory.send_buy_error(
                        BuyResults.BUY_ERR_CANT_FIND_ITEM, item, vendor_guid)

        return 0
示例#26
0
    def handle(world_session, socket, reader):
        if len(reader.data) >= 13:  # Avoid handling empty buy item packet
            vendor_guid, item, count = unpack('<QIB', reader.data[:13])

            if 0 < vendor_guid == world_session.player_mgr.current_selection:
                if count <= 0:
                    count = 1

                vendor_npc = GridManager.get_surrounding_unit_by_guid(
                    world_session.player_mgr, vendor_guid)
                vendor_data, session = WorldDatabaseManager.creature_get_vendor_data_by_item(
                    vendor_npc.entry, item)

                if vendor_data:
                    item_template = vendor_data.item_template
                    session.close()

                    total_cost = item_template.buy_price * count

                    if world_session.player_mgr.coinage < total_cost:
                        world_session.player_mgr.inventory.send_buy_error(
                            BuyResults.BUY_ERR_NOT_ENOUGH_MONEY, item,
                            vendor_guid)
                        return 0

                    if 0 < vendor_data.maxcount < count:  # I should be checking here for current count too
                        world_session.player_mgr.inventory.send_buy_error(
                            BuyResults.BUY_ERR_ITEM_SOLD_OUT, item,
                            vendor_guid)
                        return 0

                    if world_session.player_mgr.inventory.add_item(
                            item_template=item_template,
                            count=count,
                            handle_error=False):
                        world_session.player_mgr.mod_money(total_cost * -1)
                        #vendor_npc.send_inventory_list(world_session)
                    else:
                        world_session.player_mgr.inventory.send_buy_error(
                            BuyResults.BUY_ERR_CANT_CARRY_MORE, item,
                            vendor_guid)
                else:
                    world_session.player_mgr.inventory.send_buy_error(
                        BuyResults.BUY_ERR_CANT_FIND_ITEM, item, vendor_guid)

        return 0
示例#27
0
    def load_creatures():
        creature_spawns, session = WorldDatabaseManager.creature_get_all_spawns(
        )
        length = len(creature_spawns)
        count = 0

        for creature in creature_spawns:
            if creature.creature_template:
                creature_mgr = CreatureManager(
                    creature_template=creature.creature_template,
                    creature_instance=creature)
                creature_mgr.load()
            count += 1
            Logger.progress('Spawning creatures...', count, length)

        session.close()
        return length
示例#28
0
    def load_gameobjects():
        gobject_spawns, session = WorldDatabaseManager.gameobject_get_all_spawns(
        )
        length = len(gobject_spawns)
        count = 0

        for gobject in gobject_spawns:
            if gobject.gameobject:
                gobject_mgr = GameObjectManager(
                    gobject_template=gobject.gameobject,
                    gobject_instance=gobject)
                gobject_mgr.load()
            count += 1
            Logger.progress('Spawning gameobjects...', count, length)

        session.close()
        return length
示例#29
0
    def handle_transform(aura, effect_target, remove):
        if not remove:
            creature_entry = aura.spell_effect.misc_value
            creature = WorldDatabaseManager.creature_get_by_entry(
                creature_entry)
            if not creature:
                Logger.error(
                    f'SPELL_AURA_TRANSFORM: Creature template ({creature_entry}) not found in database.'
                )
                return

            if not effect_target.set_display_id(creature.display_id1):
                Logger.error(
                    f'SPELL_AURA_TRANSFORM: Invalid display id ({creature.display_id1}) for creature ({creature_entry}).'
                )
        else:
            effect_target.reset_display_id()
示例#30
0
    def get_char_packet(world_session, character):
        name_bytes = PacketWriter.string_to_bytes(character.name)
        char_fmt = '<Q%usBBBBBBBBBIIfffIIII' % len(name_bytes)
        char_packet = pack(
            char_fmt,
            character.guid,
            name_bytes,
            character.race,
            character.class_,
            character.gender,
            character.skin,
            character.face,
            character.hairstyle,
            character.haircolour,
            character.facialhair,
            character.level,
            character.zone,
            character.map,
            character.position_x,
            character.position_y,
            character.position_z,
            0,  # TODO: Handle Guild GUID,
            0,  # TODO: Handle PetDisplayInfo
            0,  # TODO: Handle PetLevel
            0  # TODO: Handle PetFamily
        )

        for slot in range(0, 19):
            item = RealmDatabaseManager.character_get_item_by_slot(character.guid, slot)
            display_id = 0
            inventory_type = 0

            if item:
                item_template = WorldDatabaseManager.item_template_get_by_entry(item.item_template)
                if item_template:
                    display_id = item_template.display_id
                    inventory_type = item_template.inventory_type
                else:
                    display_id = 0
                    inventory_type = 0
            char_packet += pack('<IB', display_id, inventory_type)

        char_packet += pack('<IB', 0, 0)  # First bag data

        return char_packet