diff options
| author | Krudor <erikstrandberg93@hotmail.com> | 2017-03-18 11:31:31 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2017-03-18 11:31:31 +0100 |
| commit | 5a36a2eb17aeec937b4375f341239fdb9dce5fda (patch) | |
| tree | eac8a498a243fa145877636402f8bf86528a7cfb /src/server/game/Entities | |
| parent | 0a35c473c8df41ec5e0699873e0746700eeb6b41 (diff) | |
Core/Scripts: Add support for spawn specific C++ scripts
Closes #19247
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 5 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 1 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 8 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 3 |
4 files changed, 15 insertions, 2 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 68c0065095b..3d6c0a25740 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -936,7 +936,7 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 /*phaseMask* SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, minfo->gender); } - LastUsedScriptID = GetCreatureTemplate()->ScriptID; + LastUsedScriptID = GetScriptId(); /// @todo Replace with spell, handle from DB if (IsSpiritHealer() || IsSpiritGuide()) @@ -2500,6 +2500,9 @@ std::string Creature::GetScriptName() const uint32 Creature::GetScriptId() const { + if (CreatureData const* creatureData = GetCreatureData()) + return creatureData->ScriptId; + return sObjectMgr->GetCreatureTemplate(GetEntry())->ScriptID; } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 8bcebd60bf7..d5cebc6bd06 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -543,6 +543,7 @@ struct CreatureData uint32 dynamicflags; uint32 phaseid; uint32 phaseGroup; + uint32 ScriptId; bool dbData; }; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index d5931dc1718..e2dfed4fb8c 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1988,6 +1988,14 @@ void GameObject::EventInform(uint32 eventId, WorldObject* invoker /*= nullptr*/) bgMap->GetBG()->ProcessEvent(this, eventId, invoker); } +uint32 GameObject::GetScriptId() const +{ + if (GameObjectData const* gameObjectData = GetGOData()) + return gameObjectData->ScriptId; + + return GetGOInfo()->ScriptId; +} + // overwrite WorldObject function for proper name localization std::string const & GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) const { diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 0e22c841022..7e265ebf2cd 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -913,6 +913,7 @@ struct GameObjectData uint8 artKit; uint32 phaseid; uint32 phaseGroup; + uint32 ScriptId; bool dbData; }; @@ -1124,7 +1125,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> void EventInform(uint32 eventId, WorldObject* invoker = NULL); - virtual uint32 GetScriptId() const { return GetGOInfo()->ScriptId; } + virtual uint32 GetScriptId() const; GameObjectAI* AI() const { return m_AI; } std::string GetAIName() const; |
