diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-06-19 23:20:06 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-06-19 23:20:06 -0300 |
| commit | 85a7d5ce9ac68b30da2277cc91d4b70358f1880d (patch) | |
| tree | df3d2084ee2e35008903c03178039b9c986e2d08 /src/server/game/Entities/Creature | |
| parent | 052fc24315ace866ea1cf610e85df119b68100c9 (diff) | |
Core: ported headers cleanup from master branch
Diffstat (limited to 'src/server/game/Entities/Creature')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 82 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 417 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/CreatureData.h | 370 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/CreatureGroups.cpp | 15 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/CreatureGroups.h | 7 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/GossipDef.cpp | 18 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/GossipDef.h | 7 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/TemporarySummon.cpp | 14 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/TemporarySummon.h | 18 |
9 files changed, 465 insertions, 483 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index ed98f7d70be..ef17eaa07bd 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -28,29 +28,30 @@ #include "GameEventMgr.h" #include "GameTime.h" #include "GossipDef.h" -#include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "Group.h" #include "GroupMgr.h" #include "InstanceScript.h" #include "Log.h" #include "LootMgr.h" +#include "MotionMaster.h" #include "MoveSpline.h" +#include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" #include "PoolMgr.h" +#include "QueryPackets.h" #include "QuestDef.h" +#include "ScriptedGossip.h" #include "SpellAuraEffects.h" #include "SpellMgr.h" #include "TemporarySummon.h" +#include "Transport.h" #include "Util.h" #include "Vehicle.h" #include "World.h" #include "WorldPacket.h" -#include "Transport.h" -#include "ScriptedGossip.h" - -#include "Packets/QueryPackets.h" +#include <G3D/g3dmath.h> TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const { @@ -61,27 +62,28 @@ TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const return nullptr; } +bool VendorItem::IsGoldRequired(ItemTemplate const* pProto) const +{ + return (pProto->Flags2 & ITEM_FLAG2_DONT_IGNORE_BUY_PRICE) || !ExtendedCost; +} + bool VendorItemData::RemoveItem(uint32 item_id) { - bool found = false; - for (VendorItemList::iterator i = m_items.begin(); i != m_items.end();) + auto newEnd = std::remove_if(m_items.begin(), m_items.end(), [=](VendorItem const& vendorItem) { - if ((*i)->item == item_id) - { - i = m_items.erase(i++); - found = true; - } - else - ++i; - } + return vendorItem.item == item_id; + }); + + bool found = (newEnd != m_items.end()); + m_items.erase(newEnd, m_items.end()); return found; } VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extendedCost) const { - for (VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i) - if ((*i)->item == item_id && (*i)->ExtendedCost == extendedCost) - return *i; + for (VendorItem const& vendorItem : m_items) + if (vendorItem.item == item_id && vendorItem.ExtendedCost == extendedCost) + return &vendorItem; return nullptr; } @@ -192,7 +194,7 @@ WorldPacket CreatureTemplate::BuildQueryData(LocaleConstant loc) const for (uint32 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i) queryTemp.Stats.QuestItems[i] = 0; - if (CreatureQuestItemList const* items = sObjectMgr->GetCreatureQuestItemList(Entry)) + if (std::vector<uint32> const* items = sObjectMgr->GetCreatureQuestItemList(Entry)) for (uint32 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i) if (i < items->size()) queryTemp.Stats.QuestItems[i] = (*items)[i]; @@ -333,7 +335,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool destroyForNearbyPlayers) if (getDeathState() != CORPSE) return; - m_corpseRemoveTime = time(NULL); + m_corpseRemoveTime = time(nullptr); setDeathState(DEAD); RemoveAllAuras(); loot.clear(); @@ -346,7 +348,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool destroyForNearbyPlayers) // Should get removed later, just keep "compatibility" with scripts if (setSpawnTime) - m_respawnTime = std::max<time_t>(time(NULL) + respawnDelay, m_respawnTime); + m_respawnTime = std::max<time_t>(time(nullptr) + respawnDelay, m_respawnTime); // if corpse was removed during falling, the falling will continue and override relocation to respawn position if (IsFalling()) @@ -583,7 +585,7 @@ void Creature::Update(uint32 diff) break; case DEAD: { - time_t now = time(NULL); + time_t now = time(nullptr); if (m_respawnTime <= now) { // First check if there are any scripts that object to us respawning @@ -636,7 +638,7 @@ void Creature::Update(uint32 diff) } else m_groupLootTimer -= diff; } - else if (m_corpseRemoveTime <= time(NULL)) + else if (m_corpseRemoveTime <= time(nullptr)) { RemoveCorpse(false); TC_LOG_DEBUG("entities.unit", "Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY)); @@ -700,7 +702,7 @@ void Creature::Update(uint32 diff) if (m_combatPulseTime == 0) { - Map::PlayerList const &players = GetMap()->GetPlayers(); + Map::PlayerList const& players = GetMap()->GetPlayers(); if (!players.isEmpty()) for (Map::PlayerList::const_iterator it = players.begin(); it != players.end(); ++it) { @@ -709,11 +711,11 @@ void Creature::Update(uint32 diff) if (player->IsGameMaster()) continue; - if (player->IsAlive() && this->IsHostileTo(player)) + if (player->IsAlive() && IsHostileTo(player)) { if (CanHaveThreatList()) AddThreat(player, 0.0f); - this->SetInCombatWith(player); + SetInCombatWith(player); player->SetInCombatWith(this); } } @@ -1486,7 +1488,7 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad // Is the creature script objecting to us spawning? If yes, delay by one second (then re-check in ::Update) if (!m_respawnTime && !sScriptMgr->CanSpawn(spawnId, GetEntry(), GetCreatureTemplate(), GetCreatureData(), map)) - m_respawnTime = time(NULL)+1; + m_respawnTime = time(nullptr)+1; if (m_respawnTime) // respawn on Update { @@ -1620,7 +1622,7 @@ bool Creature::IsInvisibleDueToDespawn() const if (Unit::IsInvisibleDueToDespawn()) return true; - if (IsAlive() || isDying() || m_corpseRemoveTime > time(NULL)) + if (IsAlive() || isDying() || m_corpseRemoveTime > time(nullptr)) return false; return true; @@ -1739,11 +1741,11 @@ void Creature::setDeathState(DeathState s) if (s == JUST_DIED) { - m_corpseRemoveTime = time(NULL) + m_corpseDelay; + m_corpseRemoveTime = time(nullptr) + m_corpseDelay; if (IsDungeonBoss() && !m_respawnDelay) m_respawnTime = std::numeric_limits<time_t>::max(); // never respawn in this instance else - m_respawnTime = time(NULL) + m_respawnDelay + m_corpseDelay; + m_respawnTime = time(nullptr) + m_respawnDelay + m_corpseDelay; // always save boss respawn time at death to prevent crash cheating if (sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY) || isWorldBoss()) @@ -1910,7 +1912,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds const& forceRespawn void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds const& forceRespawnTimer /*= 0*/) { - if (TempSummon* summon = this->ToTempSummon()) + if (TempSummon* summon = ToTempSummon()) summon->UnSummon(msTimeToDespawn); else ForcedDespawn(msTimeToDespawn, forceRespawnTimer); @@ -2162,7 +2164,7 @@ void Creature::CallForHelp(float radius) Cell::VisitGridObjects(this, worker, radius); } -bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const +bool Creature::CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction /*= true*/) const { if (IsInEvadeMode()) return false; @@ -2426,7 +2428,7 @@ void Creature::SetInCombatWithZone() return; } - Map::PlayerList const &PlList = map->GetPlayers(); + Map::PlayerList const& PlList = map->GetPlayers(); if (PlList.isEmpty()) return; @@ -2440,7 +2442,7 @@ void Creature::SetInCombatWithZone() if (player->IsAlive()) { - this->SetInCombatWith(player); + SetInCombatWith(player); player->SetInCombatWith(this); AddThreat(player, 0.0f); } @@ -2464,7 +2466,7 @@ bool Creature::HasSpell(uint32 spellID) const time_t Creature::GetRespawnTimeEx() const { - time_t now = time(NULL); + time_t now = time(nullptr); if (m_respawnTime > now) return m_respawnTime; else @@ -2508,7 +2510,7 @@ void Creature::AllLootRemovedFromCorpse() if (LootTemplates_Skinning.HaveLootFor(GetCreatureTemplate()->SkinLootId)) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - time_t now = time(NULL); + time_t now = time(nullptr); // Do not reset corpse remove time if corpse is already removed if (m_corpseRemoveTime <= now) return; @@ -2576,7 +2578,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) VendorItemCount* vCount = &*itr; - time_t ptime = time(NULL); + time_t ptime = time(nullptr); if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item)) @@ -2614,7 +2616,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us VendorItemCount* vCount = &*itr; - time_t ptime = time(NULL); + time_t ptime = time(nullptr); if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item)) @@ -2792,7 +2794,7 @@ float Creature::GetAggroRange(Unit const* target) const // Determines the aggro range for creatures (usually pets), used mainly for aggressive pet target selection. // Based on data from wowwiki due to lack of 3.3.5a data - if (target && this->IsPet()) + if (target && IsPet()) { uint32 targetLevel = 0; @@ -2841,7 +2843,7 @@ Unit* Creature::SelectNearestHostileUnitInAggroRange(bool useLOS) const // Selects nearest hostile target within creature's aggro range. Used primarily by // pets set to aggressive. Will not return neutral or friendly targets. - Unit* target = NULL; + Unit* target = nullptr; Trinity::NearestHostileUnitInAggroRangeCheck u_check(this, useLOS); Trinity::UnitSearcher<Trinity::NearestHostileUnitInAggroRangeCheck> searcher(this, target, u_check); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 2e398dcb223..77f383dcfd2 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -19,15 +19,13 @@ #ifndef TRINITYCORE_CREATURE_H #define TRINITYCORE_CREATURE_H -#include "Common.h" #include "Unit.h" -#include "UpdateMask.h" -#include "ItemTemplate.h" -#include "LootMgr.h" -#include "DatabaseEnv.h" -#include "Cell.h" -#include "WorldPacket.h" - +#include "Common.h" +#include "CreatureData.h" +#include "DatabaseEnvFwd.h" +#include "Duration.h" +#include "Loot.h" +#include "MapObject.h" #include <list> class CreatureAI; @@ -37,364 +35,12 @@ class Quest; class Player; class SpellInfo; class WorldSession; - -enum CreatureFlagsExtra : uint32 -{ - CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group - CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility) - CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry - CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry - CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block - CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks - CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP - CREATURE_FLAG_EXTRA_TRIGGER = 0x00000080, // trigger creature - CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00000100, // creature is immune to taunt auras and effect attack me - CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE = 0x00000200, // creature won't update movement flags - CREATURE_FLAG_EXTRA_GHOST_VISIBILITY = 0x00000400, // creature will be only visible for dead players - CREATURE_FLAG_EXTRA_UNUSED_11 = 0x00000800, - CREATURE_FLAG_EXTRA_UNUSED_12 = 0x00001000, - CREATURE_FLAG_EXTRA_UNUSED_13 = 0x00002000, - CREATURE_FLAG_EXTRA_WORLDEVENT = 0x00004000, // custom flag for world event creatures (left room for merging) - CREATURE_FLAG_EXTRA_GUARD = 0x00008000, // Creature is guard - CREATURE_FLAG_EXTRA_UNUSED_16 = 0x00010000, - CREATURE_FLAG_EXTRA_NO_CRIT = 0x00020000, // creature can't do critical strikes - CREATURE_FLAG_EXTRA_NO_SKILLGAIN = 0x00040000, // creature won't increase weapon skills - CREATURE_FLAG_EXTRA_TAUNT_DIMINISH = 0x00080000, // Taunt is a subject to diminishing returns on this creautre - CREATURE_FLAG_EXTRA_ALL_DIMINISH = 0x00100000, // creature is subject to all diminishing returns as player are - CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ = 0x00200000, // creature does not need to take player damage for kill credit - CREATURE_FLAG_EXTRA_UNUSED_22 = 0x00400000, - CREATURE_FLAG_EXTRA_UNUSED_23 = 0x00800000, - CREATURE_FLAG_EXTRA_UNUSED_24 = 0x01000000, - CREATURE_FLAG_EXTRA_UNUSED_25 = 0x02000000, - CREATURE_FLAG_EXTRA_UNUSED_26 = 0x04000000, - CREATURE_FLAG_EXTRA_UNUSED_27 = 0x08000000, - CREATURE_FLAG_EXTRA_DUNGEON_BOSS = 0x10000000, // creature is a dungeon boss (SET DYNAMICALLY, DO NOT ADD IN DB) - CREATURE_FLAG_EXTRA_IGNORE_PATHFINDING = 0x20000000, // creature ignore pathfinding - CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK = 0x40000000, // creature is immune to knockback effects - CREATURE_FLAG_EXTRA_UNUSED_31 = 0x80000000, - - // Masks - CREATURE_FLAG_EXTRA_UNUSED = (CREATURE_FLAG_EXTRA_UNUSED_11 | CREATURE_FLAG_EXTRA_UNUSED_12 | CREATURE_FLAG_EXTRA_UNUSED_13 | - CREATURE_FLAG_EXTRA_UNUSED_16 | CREATURE_FLAG_EXTRA_UNUSED_22 | CREATURE_FLAG_EXTRA_UNUSED_23 | - CREATURE_FLAG_EXTRA_UNUSED_24 | CREATURE_FLAG_EXTRA_UNUSED_25 | CREATURE_FLAG_EXTRA_UNUSED_26 | - CREATURE_FLAG_EXTRA_UNUSED_27 | CREATURE_FLAG_EXTRA_UNUSED_31), - - CREATURE_FLAG_EXTRA_DB_ALLOWED = (0xFFFFFFFF & ~(CREATURE_FLAG_EXTRA_UNUSED | CREATURE_FLAG_EXTRA_DUNGEON_BOSS)) -}; - -static const uint32 CREATURE_REGEN_INTERVAL = 2 * IN_MILLISECONDS; -static const uint32 PET_FOCUS_REGEN_INTERVAL = 4 * IN_MILLISECONDS; -static const uint32 CREATURE_NOPATH_EVADE_TIME = 5 * IN_MILLISECONDS; - -static const uint8 MAX_KILL_CREDIT = 2; -static const uint32 MAX_CREATURE_MODELS = 4; -static const uint32 MAX_CREATURE_QUEST_ITEMS = 6; -static const uint32 MAX_CREATURE_SPELLS = 8; - -// from `creature_template` table -struct TC_GAME_API CreatureTemplate -{ - uint32 Entry; - uint32 DifficultyEntry[MAX_DIFFICULTY - 1]; - uint32 KillCredit[MAX_KILL_CREDIT]; - uint32 Modelid1; - uint32 Modelid2; - uint32 Modelid3; - uint32 Modelid4; - std::string Name; - std::string Title; - std::string IconName; - uint32 GossipMenuId; - uint8 minlevel; - uint8 maxlevel; - uint32 expansion; - uint32 faction; - uint32 npcflag; - float speed_walk; - float speed_run; - float scale; - uint32 rank; - uint32 dmgschool; - uint32 BaseAttackTime; - uint32 RangeAttackTime; - float BaseVariance; - float RangeVariance; - uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures. - uint32 unit_flags; // enum UnitFlags mask values - uint32 unit_flags2; // enum UnitFlags2 mask values - uint32 dynamicflags; - CreatureFamily family; // enum CreatureFamily values (optional) - uint32 trainer_type; - uint32 trainer_spell; - uint32 trainer_class; - uint32 trainer_race; - uint32 type; // enum CreatureType values - uint32 type_flags; // enum CreatureTypeFlags mask values - uint32 lootid; - uint32 pickpocketLootId; - uint32 SkinLootId; - int32 resistance[MAX_SPELL_SCHOOL]; - uint32 spells[MAX_CREATURE_SPELLS]; - uint32 PetSpellDataId; - uint32 VehicleId; - uint32 mingold; - uint32 maxgold; - std::string AIName; - uint32 MovementType; - uint32 InhabitType; - float HoverHeight; - float ModHealth; - float ModMana; - float ModArmor; - float ModDamage; - float ModExperience; - bool RacialLeader; - uint32 movementId; - bool RegenHealth; - uint32 MechanicImmuneMask; - uint32 flags_extra; - uint32 ScriptID; - WorldPacket QueryData[TOTAL_LOCALES]; - uint32 GetRandomValidModelId() const; - uint32 GetFirstValidModelId() const; - uint32 GetFirstInvisibleModel() const; - uint32 GetFirstVisibleModel() const; - - // helpers - SkillType GetRequiredLootSkill() const - { - if (type_flags & CREATURE_TYPE_FLAG_HERB_SKINNING_SKILL) - return SKILL_HERBALISM; - else if (type_flags & CREATURE_TYPE_FLAG_MINING_SKINNING_SKILL) - return SKILL_MINING; - else if (type_flags & CREATURE_TYPE_FLAG_ENGINEERING_SKINNING_SKILL) - return SKILL_ENGINEERING; - else - return SKILL_SKINNING; // normal case - } - - bool IsExotic() const - { - return (type_flags & CREATURE_TYPE_FLAG_EXOTIC_PET) != 0; - } - - bool IsTameable(bool canTameExotic) const - { - if (type != CREATURE_TYPE_BEAST || family == CREATURE_FAMILY_NONE || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_PET) == 0) - return false; - - // if can tame exotic then can tame any tameable - return canTameExotic || !IsExotic(); - } - - void InitializeQueryData(); - WorldPacket BuildQueryData(LocaleConstant loc) const; -}; - -typedef std::vector<uint32> CreatureQuestItemList; -typedef std::unordered_map<uint32, CreatureQuestItemList> CreatureQuestItemMap; - -// Benchmarked: Faster than std::map (insert/find) -typedef std::unordered_map<uint32, CreatureTemplate> CreatureTemplateContainer; - -#pragma pack(push, 1) - -// Defines base stats for creatures (used to calculate HP/mana/armor/attackpower/rangedattackpower/all damage). -struct TC_GAME_API CreatureBaseStats -{ - uint32 BaseHealth[MAX_EXPANSIONS]; - uint32 BaseMana; - uint32 BaseArmor; - uint32 AttackPower; - uint32 RangedAttackPower; - float BaseDamage[MAX_EXPANSIONS]; - - // Helpers - - uint32 GenerateHealth(CreatureTemplate const* info) const - { - return uint32(ceil(BaseHealth[info->expansion] * info->ModHealth)); - } - - uint32 GenerateMana(CreatureTemplate const* info) const - { - // Mana can be 0. - if (!BaseMana) - return 0; - - return uint32(ceil(BaseMana * info->ModMana)); - } - - uint32 GenerateArmor(CreatureTemplate const* info) const - { - return uint32(ceil(BaseArmor * info->ModArmor)); - } - - float GenerateBaseDamage(CreatureTemplate const* info) const - { - return BaseDamage[info->expansion]; - } - - static CreatureBaseStats const* GetBaseStats(uint8 level, uint8 unitClass); -}; - -typedef std::unordered_map<uint16, CreatureBaseStats> CreatureBaseStatsContainer; - -struct CreatureLocale -{ - StringVector Name; - StringVector Title; -}; - -struct GossipMenuItemsLocale -{ - StringVector OptionText; - StringVector BoxText; -}; - -struct PointOfInterestLocale -{ - StringVector Name; -}; - -#define MAX_EQUIPMENT_ITEMS 3 - -struct EquipmentInfo -{ - uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]; -}; - -// Benchmarked: Faster than std::map (insert/find) -typedef std::unordered_map<uint8, EquipmentInfo> EquipmentInfoContainerInternal; -typedef std::unordered_map<uint32, EquipmentInfoContainerInternal> EquipmentInfoContainer; - -// from `creature` table -struct CreatureData -{ - CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0), - posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0), - spawndist(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0), - spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), ScriptId(0), dbData(true) { } - uint32 id; // entry in creature_template - uint16 mapid; - uint32 phaseMask; - uint32 displayid; - int8 equipmentId; - float posX; - float posY; - float posZ; - float orientation; - uint32 spawntimesecs; - float spawndist; - uint32 currentwaypoint; - uint32 curhealth; - uint32 curmana; - uint8 movementType; - uint8 spawnMask; - uint32 npcflag; - uint32 unit_flags; // enum UnitFlags mask values - uint32 dynamicflags; - uint32 ScriptId; - bool dbData; -}; - -struct CreatureModelInfo -{ - float bounding_radius; - float combat_reach; - uint8 gender; - uint32 modelid_other_gender; - bool is_trigger; -}; - -// Benchmarked: Faster than std::map (insert/find) -typedef std::unordered_map<uint16, CreatureModelInfo> CreatureModelContainer; - -enum InhabitTypeValues -{ - INHABIT_GROUND = 1, - INHABIT_WATER = 2, - INHABIT_AIR = 4, - INHABIT_ROOT = 8, - INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR | INHABIT_ROOT -}; - -// Enums used by StringTextData::Type (CreatureEventAI) -enum ChatType -{ - CHAT_TYPE_SAY = 0, - CHAT_TYPE_YELL = 1, - CHAT_TYPE_TEXT_EMOTE = 2, - CHAT_TYPE_BOSS_EMOTE = 3, - CHAT_TYPE_WHISPER = 4, - CHAT_TYPE_BOSS_WHISPER = 5, - CHAT_TYPE_ZONE_YELL = 6, - CHAT_TYPE_END = 255 -}; - -#pragma pack(pop) - -// `creature_addon` table -struct CreatureAddon -{ - uint32 path_id; - uint32 mount; - uint32 bytes1; - uint32 bytes2; - uint32 emote; - std::vector<uint32> auras; -}; - -typedef std::unordered_map<ObjectGuid::LowType, CreatureAddon> CreatureAddonContainer; -typedef std::unordered_map<uint32, CreatureAddon> CreatureAddonTemplateContainer; - -// Vendors -struct VendorItem -{ - VendorItem(uint32 _item, int32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost) - : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) { } - - uint32 item; - uint32 maxcount; // 0 for infinity item amount - uint32 incrtime; // time for restore items amount if maxcount != 0 - uint32 ExtendedCost; - - //helpers - bool IsGoldRequired(ItemTemplate const* pProto) const { return (pProto->Flags2 & ITEM_FLAG2_DONT_IGNORE_BUY_PRICE) || !ExtendedCost; } -}; -typedef std::vector<VendorItem*> VendorItemList; - -struct VendorItemData -{ - VendorItemList m_items; - - VendorItem* GetItem(uint32 slot) const - { - if (slot >= m_items.size()) - return NULL; - - return m_items[slot]; - } - bool Empty() const { return m_items.empty(); } - uint8 GetItemCount() const { return m_items.size(); } - void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost) - { - m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost)); - } - bool RemoveItem(uint32 item_id); - VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const; - void Clear() - { - for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr) - delete (*itr); - m_items.clear(); - } -}; +enum MovementGeneratorType : uint8; struct VendorItemCount { - explicit VendorItemCount(uint32 _item, uint32 _count) - : itemId(_item), count(_count), lastIncrementTime(time(NULL)) { } + VendorItemCount(uint32 _item, uint32 _count) + : itemId(_item), count(_count), lastIncrementTime(time(nullptr)) { } uint32 itemId; uint32 count; @@ -403,38 +49,6 @@ struct VendorItemCount typedef std::list<VendorItemCount> VendorItemCounts; -struct TrainerSpell -{ - TrainerSpell() : SpellID(0), MoneyCost(0), ReqSkillLine(0), ReqSkillRank(0), ReqLevel(0) - { - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - ReqAbility[i] = 0; - } - - uint32 SpellID; - uint32 MoneyCost; - uint32 ReqSkillLine; - uint32 ReqSkillRank; - uint32 ReqLevel; - uint32 ReqAbility[3]; - - // helpers - bool IsCastable() const { return ReqAbility[0] != SpellID; } -}; - -typedef std::unordered_map<uint32 /*spellid*/, TrainerSpell> TrainerSpellMap; - -struct TC_GAME_API TrainerSpellData -{ - TrainerSpellData() : trainerType(0) { } - ~TrainerSpellData() { spellList.clear(); } - - TrainerSpellMap spellList; - uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value. - // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2. - TrainerSpell const* Find(uint32 spell_id) const; -}; - // max different by z coordinate for creature aggro reaction #define CREATURE_Z_ATTACK_RANGE 3 @@ -447,7 +61,6 @@ typedef std::unordered_map<uint8, CreatureTextRepeatIds> CreatureTextRepeatGroup class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public MapObject { public: - explicit Creature(bool isWorldObject = false); virtual ~Creature(); @@ -504,7 +117,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma bool IsEvadingAttacks() const { return IsInEvadeMode() || CanNotReachTarget(); } bool AIM_Destroy(); - bool AIM_Initialize(CreatureAI* ai = NULL); + bool AIM_Initialize(CreatureAI* ai = nullptr); void Motion_Initialize(); CreatureAI* AI() const { return reinterpret_cast<CreatureAI*>(i_AI); } @@ -611,8 +224,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; } void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; } bool HasSearchedAssistance() const { return m_AlreadySearchedAssistance; } - bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const; - bool _IsTargetAcceptable(const Unit* target) const; + bool CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction = true) const; + bool _IsTargetAcceptable(Unit const* target) const; MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; } void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; } @@ -624,7 +237,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma time_t const& GetRespawnTime() const { return m_respawnTime; } time_t GetRespawnTimeEx() const; - void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } + void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(nullptr) + respawn : 0; } void Respawn(bool force = false); void SaveRespawnTime() override; @@ -669,12 +282,12 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma bool CanNotReachTarget() const { return m_cannotReachTarget; } void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); } - void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos); } + void SetHomePosition(Position const& pos) { m_homePosition.Relocate(pos); } void GetHomePosition(float& x, float& y, float& z, float& ori) const { m_homePosition.GetPosition(x, y, z, ori); } Position const& GetHomePosition() const { return m_homePosition; } void SetTransportHomePosition(float x, float y, float z, float o) { m_transportHomePosition.Relocate(x, y, z, o); } - void SetTransportHomePosition(const Position &pos) { m_transportHomePosition.Relocate(pos); } + void SetTransportHomePosition(Position const& pos) { m_transportHomePosition.Relocate(pos); } void GetTransportHomePosition(float& x, float& y, float& z, float& ori) const { m_transportHomePosition.GetPosition(x, y, z, ori); } Position const& GetTransportHomePosition() const { return m_transportHomePosition; } diff --git a/src/server/game/Entities/Creature/CreatureData.h b/src/server/game/Entities/Creature/CreatureData.h new file mode 100644 index 00000000000..754963f9812 --- /dev/null +++ b/src/server/game/Entities/Creature/CreatureData.h @@ -0,0 +1,370 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef CreatureData_h__ +#define CreatureData_h__ + +#include "DBCEnums.h" +#include "SharedDefines.h" +#include "UnitDefines.h" +#include "WorldPacket.h" +#include <string> +#include <unordered_map> +#include <vector> +#include <cmath> + +struct ItemTemplate; + +enum CreatureFlagsExtra : uint32 +{ + CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group + CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility) + CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry + CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry + CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block + CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks + CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP + CREATURE_FLAG_EXTRA_TRIGGER = 0x00000080, // trigger creature + CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00000100, // creature is immune to taunt auras and effect attack me + CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE = 0x00000200, // creature won't update movement flags + CREATURE_FLAG_EXTRA_GHOST_VISIBILITY = 0x00000400, // creature will be only visible for dead players + CREATURE_FLAG_EXTRA_UNUSED_11 = 0x00000800, + CREATURE_FLAG_EXTRA_UNUSED_12 = 0x00001000, + CREATURE_FLAG_EXTRA_UNUSED_13 = 0x00002000, + CREATURE_FLAG_EXTRA_WORLDEVENT = 0x00004000, // custom flag for world event creatures (left room for merging) + CREATURE_FLAG_EXTRA_GUARD = 0x00008000, // Creature is guard + CREATURE_FLAG_EXTRA_UNUSED_16 = 0x00010000, + CREATURE_FLAG_EXTRA_NO_CRIT = 0x00020000, // creature can't do critical strikes + CREATURE_FLAG_EXTRA_NO_SKILLGAIN = 0x00040000, // creature won't increase weapon skills + CREATURE_FLAG_EXTRA_TAUNT_DIMINISH = 0x00080000, // Taunt is a subject to diminishing returns on this creautre + CREATURE_FLAG_EXTRA_ALL_DIMINISH = 0x00100000, // creature is subject to all diminishing returns as player are + CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ = 0x00200000, // creature does not need to take player damage for kill credit + CREATURE_FLAG_EXTRA_UNUSED_22 = 0x00400000, + CREATURE_FLAG_EXTRA_UNUSED_23 = 0x00800000, + CREATURE_FLAG_EXTRA_UNUSED_24 = 0x01000000, + CREATURE_FLAG_EXTRA_UNUSED_25 = 0x02000000, + CREATURE_FLAG_EXTRA_UNUSED_26 = 0x04000000, + CREATURE_FLAG_EXTRA_UNUSED_27 = 0x08000000, + CREATURE_FLAG_EXTRA_DUNGEON_BOSS = 0x10000000, // creature is a dungeon boss (SET DYNAMICALLY, DO NOT ADD IN DB) + CREATURE_FLAG_EXTRA_IGNORE_PATHFINDING = 0x20000000, // creature ignore pathfinding + CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK = 0x40000000, // creature is immune to knockback effects + CREATURE_FLAG_EXTRA_UNUSED_31 = 0x80000000, + + // Masks + CREATURE_FLAG_EXTRA_UNUSED = (CREATURE_FLAG_EXTRA_UNUSED_11 | CREATURE_FLAG_EXTRA_UNUSED_12 | CREATURE_FLAG_EXTRA_UNUSED_13 | + CREATURE_FLAG_EXTRA_UNUSED_16 | CREATURE_FLAG_EXTRA_UNUSED_22 | CREATURE_FLAG_EXTRA_UNUSED_23 | + CREATURE_FLAG_EXTRA_UNUSED_24 | CREATURE_FLAG_EXTRA_UNUSED_25 | CREATURE_FLAG_EXTRA_UNUSED_26 | + CREATURE_FLAG_EXTRA_UNUSED_27 | CREATURE_FLAG_EXTRA_UNUSED_31), + + CREATURE_FLAG_EXTRA_DB_ALLOWED = (0xFFFFFFFF & ~(CREATURE_FLAG_EXTRA_UNUSED | CREATURE_FLAG_EXTRA_DUNGEON_BOSS)) +}; + +static const uint32 CREATURE_REGEN_INTERVAL = 2 * IN_MILLISECONDS; +static const uint32 PET_FOCUS_REGEN_INTERVAL = 4 * IN_MILLISECONDS; +static const uint32 CREATURE_NOPATH_EVADE_TIME = 5 * IN_MILLISECONDS; + +static const uint8 MAX_KILL_CREDIT = 2; +static const uint32 MAX_CREATURE_MODELS = 4; +static const uint32 MAX_CREATURE_QUEST_ITEMS = 6; +static const uint32 MAX_CREATURE_SPELLS = 8; + +// from `creature_template` table +struct TC_GAME_API CreatureTemplate +{ + uint32 Entry; + uint32 DifficultyEntry[MAX_DIFFICULTY - 1]; + uint32 KillCredit[MAX_KILL_CREDIT]; + uint32 Modelid1; + uint32 Modelid2; + uint32 Modelid3; + uint32 Modelid4; + std::string Name; + std::string Title; + std::string IconName; + uint32 GossipMenuId; + uint8 minlevel; + uint8 maxlevel; + uint32 expansion; + uint32 faction; + uint32 npcflag; + float speed_walk; + float speed_run; + float scale; + uint32 rank; + uint32 dmgschool; + uint32 BaseAttackTime; + uint32 RangeAttackTime; + float BaseVariance; + float RangeVariance; + uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures. + uint32 unit_flags; // enum UnitFlags mask values + uint32 unit_flags2; // enum UnitFlags2 mask values + uint32 dynamicflags; + CreatureFamily family; // enum CreatureFamily values (optional) + uint32 trainer_type; + uint32 trainer_spell; + uint32 trainer_class; + uint32 trainer_race; + uint32 type; // enum CreatureType values + uint32 type_flags; // enum CreatureTypeFlags mask values + uint32 lootid; + uint32 pickpocketLootId; + uint32 SkinLootId; + int32 resistance[MAX_SPELL_SCHOOL]; + uint32 spells[MAX_CREATURE_SPELLS]; + uint32 PetSpellDataId; + uint32 VehicleId; + uint32 mingold; + uint32 maxgold; + std::string AIName; + uint32 MovementType; + uint32 InhabitType; + float HoverHeight; + float ModHealth; + float ModMana; + float ModArmor; + float ModDamage; + float ModExperience; + bool RacialLeader; + uint32 movementId; + bool RegenHealth; + uint32 MechanicImmuneMask; + uint32 flags_extra; + uint32 ScriptID; + WorldPacket QueryData[TOTAL_LOCALES]; + uint32 GetRandomValidModelId() const; + uint32 GetFirstValidModelId() const; + uint32 GetFirstInvisibleModel() const; + uint32 GetFirstVisibleModel() const; + + // helpers + SkillType GetRequiredLootSkill() const + { + if (type_flags & CREATURE_TYPE_FLAG_HERB_SKINNING_SKILL) + return SKILL_HERBALISM; + else if (type_flags & CREATURE_TYPE_FLAG_MINING_SKINNING_SKILL) + return SKILL_MINING; + else if (type_flags & CREATURE_TYPE_FLAG_ENGINEERING_SKINNING_SKILL) + return SKILL_ENGINEERING; + else + return SKILL_SKINNING; // normal case + } + + bool IsExotic() const + { + return (type_flags & CREATURE_TYPE_FLAG_EXOTIC_PET) != 0; + } + + bool IsTameable(bool canTameExotic) const + { + if (type != CREATURE_TYPE_BEAST || family == CREATURE_FAMILY_NONE || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_PET) == 0) + return false; + + // if can tame exotic then can tame any tameable + return canTameExotic || !IsExotic(); + } + + void InitializeQueryData(); + WorldPacket BuildQueryData(LocaleConstant loc) const; +}; + +#pragma pack(push, 1) + +// Defines base stats for creatures (used to calculate HP/mana/armor/attackpower/rangedattackpower/all damage). +struct TC_GAME_API CreatureBaseStats +{ + uint32 BaseHealth[MAX_EXPANSIONS]; + uint32 BaseMana; + uint32 BaseArmor; + uint32 AttackPower; + uint32 RangedAttackPower; + float BaseDamage[MAX_EXPANSIONS]; + + // Helpers + + uint32 GenerateHealth(CreatureTemplate const* info) const + { + return uint32(ceil(BaseHealth[info->expansion] * info->ModHealth)); + } + + uint32 GenerateMana(CreatureTemplate const* info) const + { + // Mana can be 0. + if (!BaseMana) + return 0; + + return uint32(ceil(BaseMana * info->ModMana)); + } + + uint32 GenerateArmor(CreatureTemplate const* info) const + { + return uint32(ceil(BaseArmor * info->ModArmor)); + } + + float GenerateBaseDamage(CreatureTemplate const* info) const + { + return BaseDamage[info->expansion]; + } + + static CreatureBaseStats const* GetBaseStats(uint8 level, uint8 unitClass); +}; + +struct CreatureLocale +{ + std::vector<std::string> Name; + std::vector<std::string> Title; +}; + +struct EquipmentInfo +{ + uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]; +}; + +// from `creature` table +struct CreatureData +{ + CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0), + posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0), + spawndist(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0), + spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), ScriptId(0), dbData(true) { } + uint32 id; // entry in creature_template + uint16 mapid; + uint32 phaseMask; + uint32 displayid; + int8 equipmentId; + float posX; + float posY; + float posZ; + float orientation; + uint32 spawntimesecs; + float spawndist; + uint32 currentwaypoint; + uint32 curhealth; + uint32 curmana; + uint8 movementType; + uint8 spawnMask; + uint32 npcflag; + uint32 unit_flags; // enum UnitFlags mask values + uint32 dynamicflags; + uint32 ScriptId; + bool dbData; +}; + +struct CreatureModelInfo +{ + float bounding_radius; + float combat_reach; + uint8 gender; + uint32 modelid_other_gender; + bool is_trigger; +}; + +enum InhabitTypeValues +{ + INHABIT_GROUND = 1, + INHABIT_WATER = 2, + INHABIT_AIR = 4, + INHABIT_ROOT = 8, + INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR | INHABIT_ROOT +}; + +#pragma pack(pop) + +// `creature_addon` table +struct CreatureAddon +{ + uint32 path_id; + uint32 mount; + uint32 bytes1; + uint32 bytes2; + uint32 emote; + std::vector<uint32> auras; +}; + +// Vendors +struct VendorItem +{ + VendorItem(uint32 _item, int32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost) + : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) { } + + uint32 item; + uint32 maxcount; // 0 for infinity item amount + uint32 incrtime; // time for restore items amount if maxcount != 0 + uint32 ExtendedCost; + + //helpers + bool IsGoldRequired(ItemTemplate const* pProto) const; +}; + +struct VendorItemData +{ + std::vector<VendorItem> m_items; + + VendorItem const* GetItem(uint32 slot) const + { + if (slot >= m_items.size()) + return nullptr; + + return &m_items[slot]; + } + bool Empty() const { return m_items.empty(); } + uint8 GetItemCount() const { return m_items.size(); } + void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost) + { + m_items.emplace_back(item, maxcount, ptime, ExtendedCost); + } + bool RemoveItem(uint32 item_id); + VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const; + void Clear() + { + m_items.clear(); + } +}; + +struct TrainerSpell +{ + TrainerSpell() : SpellID(0), MoneyCost(0), ReqSkillLine(0), ReqSkillRank(0), ReqLevel(0) + { + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + ReqAbility[i] = 0; + } + + uint32 SpellID; + uint32 MoneyCost; + uint32 ReqSkillLine; + uint32 ReqSkillRank; + uint32 ReqLevel; + uint32 ReqAbility[3]; + + // helpers + bool IsCastable() const { return ReqAbility[0] != SpellID; } +}; + +typedef std::unordered_map<uint32 /*spellid*/, TrainerSpell> TrainerSpellMap; + +struct TC_GAME_API TrainerSpellData +{ + TrainerSpellData() : trainerType(0) { } + ~TrainerSpellData() { spellList.clear(); } + + TrainerSpellMap spellList; + uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value. + // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2. + TrainerSpell const* Find(uint32 spell_id) const; +}; + +#endif // CreatureData_h__ diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index c0bdaddb767..0c19bdb502d 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -16,11 +16,14 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Creature.h" #include "CreatureGroups.h" -#include "ObjectMgr.h" - +#include "Creature.h" #include "CreatureAI.h" +#include "DatabaseEnv.h" +#include "Log.h" +#include "Map.h" +#include "MotionMaster.h" +#include "ObjectMgr.h" #define MAX_DESYNC 5.0f @@ -164,10 +167,10 @@ void CreatureGroup::AddMember(Creature* member) void CreatureGroup::RemoveMember(Creature* member) { if (m_leader == member) - m_leader = NULL; + m_leader = nullptr; m_members.erase(member); - member->SetFormation(NULL); + member->SetFormation(nullptr); } void CreatureGroup::MemberAttackStart(Creature* member, Unit* target) @@ -217,7 +220,7 @@ void CreatureGroup::FormationReset(bool dismiss) m_Formed = !dismiss; } -void CreatureGroup::LeaderMoveTo(Position destination, uint32 id /*= 0*/, uint32 moveType /*= 0*/, bool orientation /*= false*/) +void CreatureGroup::LeaderMoveTo(Position const& destination, uint32 id /*= 0*/, uint32 moveType /*= 0*/, bool orientation /*= false*/) { //! To do: This should probably get its own movement generator or use WaypointMovementGenerator. //! If the leader's path is known, member's path can be plotted as well using formation offsets. diff --git a/src/server/game/Entities/Creature/CreatureGroups.h b/src/server/game/Entities/Creature/CreatureGroups.h index ae57d7b9152..ddb8b6876ec 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.h +++ b/src/server/game/Entities/Creature/CreatureGroups.h @@ -20,11 +20,14 @@ #define _FORMATIONS_H #include "Define.h" +#include "ObjectGuid.h" #include <unordered_map> #include <map> class Creature; class CreatureGroup; +class Unit; +struct Position; struct FormationInfo { @@ -65,7 +68,7 @@ class TC_GAME_API CreatureGroup public: //Group cannot be created empty - explicit CreatureGroup(uint32 id) : m_leader(NULL), m_groupID(id), m_Formed(false) { } + explicit CreatureGroup(uint32 id) : m_leader(nullptr), m_groupID(id), m_Formed(false) { } ~CreatureGroup() { } Creature* getLeader() const { return m_leader; } @@ -77,7 +80,7 @@ class TC_GAME_API CreatureGroup void RemoveMember(Creature* member); void FormationReset(bool dismiss); - void LeaderMoveTo(Position destination, uint32 id = 0, uint32 moveType = 0, bool orientation = false); + void LeaderMoveTo(Position const& destination, uint32 id = 0, uint32 moveType = 0, bool orientation = false); void MemberAttackStart(Creature* member, Unit* target); }; diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 0c395eb8cad..caa700f6672 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -16,11 +16,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "QuestDef.h" #include "GossipDef.h" +#include "Log.h" #include "ObjectMgr.h" +#include "Player.h" +#include "QuestDef.h" +#include "World.h" #include "WorldSession.h" -#include "Formulas.h" GossipMenu::GossipMenu() { @@ -229,7 +231,7 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) std::string title = quest->GetTitle(); LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); - if (localeConstant >= LOCALE_enUS) + if (localeConstant != LOCALE_enUS) if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) ObjectMgr::GetLocaleString(localeData->Title, localeConstant, title); @@ -263,7 +265,7 @@ void PlayerMenu::SendPointOfInterest(uint32 id) const std::string name = poi->Name; LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); - if (localeConstant >= LOCALE_enUS) + if (localeConstant != LOCALE_enUS) if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(id)) ObjectMgr::GetLocaleString(localeData->Name, localeConstant, name); @@ -348,7 +350,7 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string std::string title = quest->GetTitle(); LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); - if (localeConstant >= LOCALE_enUS) + if (localeConstant != LOCALE_enUS) if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) ObjectMgr::GetLocaleString(localeData->Title, localeConstant, title); @@ -387,7 +389,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU std::string questAreaDescription = quest->GetAreaDescription(); LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); - if (localeConstant >= LOCALE_enUS) + if (localeConstant != LOCALE_enUS) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) { @@ -506,7 +508,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUI std::string questOfferRewardText = quest->GetOfferRewardText(); LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); - if (localeConstant >= LOCALE_enUS) + if (localeConstant != LOCALE_enUS) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) { @@ -603,7 +605,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGU std::string requestItemsText = quest->GetRequestItemsText(); LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); - if (localeConstant >= LOCALE_enUS) + if (localeConstant != LOCALE_enUS) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) { diff --git a/src/server/game/Entities/Creature/GossipDef.h b/src/server/game/Entities/Creature/GossipDef.h index 9826057361d..cd9d529605f 100644 --- a/src/server/game/Entities/Creature/GossipDef.h +++ b/src/server/game/Entities/Creature/GossipDef.h @@ -21,9 +21,10 @@ #include "Common.h" #include "ObjectGuid.h" -#include "QuestDef.h" #include "NPCHandler.h" +#include <map> +class Quest; class WorldSession; #define GOSSIP_MAX_MENU_ITEMS 32 @@ -192,7 +193,7 @@ class TC_GAME_API GossipMenu if (itr != _menuItems.end()) return &itr->second; - return NULL; + return nullptr; } GossipMenuItemData const* GetItemData(uint32 indexId) const @@ -201,7 +202,7 @@ class TC_GAME_API GossipMenu if (itr != _menuItemData.end()) return &itr->second; - return NULL; + return nullptr; } uint32 GetMenuItemSender(uint32 menuItemId) const; diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index bc433ed2d69..7e9cf6bf7a3 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -16,10 +16,12 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "TemporarySummon.h" +#include "CreatureAI.h" +#include "DBCStructure.h" #include "Log.h" +#include "Map.h" #include "ObjectAccessor.h" -#include "CreatureAI.h" -#include "TemporarySummon.h" #include "Pet.h" #include "Player.h" @@ -35,12 +37,12 @@ m_timer(0), m_lifetime(0) Unit* TempSummon::GetSummoner() const { - return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : NULL; + return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : nullptr; } Creature* TempSummon::GetSummonerCreatureBase() const { - return m_summonerGUID ? ObjectAccessor::GetCreature(*this, m_summonerGUID) : NULL; + return m_summonerGUID ? ObjectAccessor::GetCreature(*this, m_summonerGUID) : nullptr; } void TempSummon::Update(uint32 diff) @@ -250,7 +252,7 @@ void TempSummon::UnSummon(uint32 msTime) //ASSERT(!IsPet()); if (IsPet()) { - ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT); + ToPet()->Remove(PET_SAVE_NOT_IN_SLOT); ASSERT(!IsInWorld()); return; } @@ -395,6 +397,6 @@ void Puppet::RemoveFromWorld() if (!IsInWorld()) return; - RemoveCharmedBy(NULL); + RemoveCharmedBy(nullptr); Minion::RemoveFromWorld(); } diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index 50f6c592b9e..50d7f9f712f 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -21,21 +21,7 @@ #include "Creature.h" -enum SummonerType -{ - SUMMONER_TYPE_CREATURE = 0, - SUMMONER_TYPE_GAMEOBJECT = 1, - SUMMONER_TYPE_MAP = 2 -}; - -/// Stores data for temp summons -struct TempSummonData -{ - uint32 entry; ///< Entry of summoned creature - Position pos; ///< Position, where should be creature spawned - TempSummonType type; ///< Summon type, see TempSummonType for available types - uint32 time; ///< Despawn time, usable only with certain temp summon types -}; +struct SummonPropertiesEntry; class TC_GAME_API TempSummon : public Creature { @@ -56,7 +42,7 @@ class TC_GAME_API TempSummon : public Creature TempSummonType const& GetSummonType() { return m_type; } uint32 GetTimer() const { return m_timer; } - const SummonPropertiesEntry* const m_Properties; + SummonPropertiesEntry const* const m_Properties; private: TempSummonType m_type; uint32 m_timer; |
