diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-05-01 18:19:36 -0300 |
|---|---|---|
| committer | funjoker <funjoker109@gmail.com> | 2020-05-03 03:04:32 +0200 |
| commit | 6604849716bc73d82a4cdbf8c66bb188086ceae4 (patch) | |
| tree | bd293ee1fdac3baf8bef0a55aa854fe8bf793bc2 /src/server/scripts/EasternKingdoms/Stratholme | |
| parent | e3489c48ee6929018618322571adbb8dc59e11b1 (diff) | |
Core/Scripts: unified scripted gossip/quest api
- Changed self-accessor on GameObjectAI to "me", like UnitAI
- Moved all related functions to AI, now Unit and GameObject have the same function names with identical behaviour
- Remove "OnUpdate" from CreatureScript/GameObjectScript, was never used and we already have AI Update method
- Quest methods no longer return a bool, the return value was used to call the AI version if the ScriptMgr one returned false
- Implemented GameObjectAI::Destroyed hook (was never called), implemented Damaged method
- Rename OnStateChanged to OnLootStateChanged to reflect when it's really called, and created a new hook OnStateChanged that only gets called on GOState change
- Since the functions are now only getting called from AI, made GetAI methods full virtual. (CanSpawn method is anyways going to be used on creatures with AI)
(cherry picked from commit f913f3bb8977c127d200d5d4a608ab434b21bbcd)
Diffstat (limited to 'src/server/scripts/EasternKingdoms/Stratholme')
| -rw-r--r-- | src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp | 62 | ||||
| -rw-r--r-- | src/server/scripts/EasternKingdoms/Stratholme/stratholme.h | 6 |
2 files changed, 38 insertions, 30 deletions
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp index ec82afb6cab..5c0881958ce 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp @@ -30,6 +30,7 @@ npc_spectral_ghostly_citizen EndContentData */ #include "ScriptMgr.h" +#include "GameObjectAI.h" #include "GameObject.h" #include "Group.h" #include "InstanceScript.h" @@ -46,41 +47,48 @@ EndContentData */ class go_gauntlet_gate : public GameObjectScript { -public: - go_gauntlet_gate() : GameObjectScript("go_gauntlet_gate") { } - - bool OnGossipHello(Player* player, GameObject* go) override - { - InstanceScript* instance = go->GetInstanceScript(); + public: + go_gauntlet_gate() : GameObjectScript("go_gauntlet_gate") { } - if (!instance) - return false; + struct go_gauntlet_gateAI : public GameObjectAI + { + go_gauntlet_gateAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { } - if (instance->GetData(TYPE_BARON_RUN) != NOT_STARTED) - return false; + InstanceScript* instance; - if (Group* group = player->GetGroup()) - { - for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) + bool GossipHello(Player* player, bool /*reportUse*/) override { - Player* pGroupie = itr->GetSource(); - if (!pGroupie || !pGroupie->IsInMap(player)) - continue; - - if (pGroupie->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE && - !pGroupie->HasAura(SPELL_BARON_ULTIMATUM) && - pGroupie->GetMap() == go->GetMap()) - pGroupie->CastSpell(pGroupie, SPELL_BARON_ULTIMATUM, true); - } - } else if (player->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE && + if (instance->GetData(TYPE_BARON_RUN) != NOT_STARTED) + return false; + + if (Group* group = player->GetGroup()) + { + for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next()) + { + Player* pGroupie = itr->GetSource(); + if (!pGroupie || !pGroupie->IsInMap(player)) + continue; + + if (pGroupie->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE && + !pGroupie->HasAura(SPELL_BARON_ULTIMATUM) && + pGroupie->GetMap() == me->GetMap()) + pGroupie->CastSpell(pGroupie, SPELL_BARON_ULTIMATUM, true); + } + } + else if (player->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE && !player->HasAura(SPELL_BARON_ULTIMATUM) && - player->GetMap() == go->GetMap()) + player->GetMap() == me->GetMap()) player->CastSpell(player, SPELL_BARON_ULTIMATUM, true); - instance->SetData(TYPE_BARON_RUN, IN_PROGRESS); - return false; - } + instance->SetData(TYPE_BARON_RUN, IN_PROGRESS); + return false; + } + }; + GameObjectAI* GetAI(GameObject* go) const override + { + return GetStratholmeAI<go_gauntlet_gateAI>(go); + } }; /*###### diff --git a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.h b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.h index 8c3d50e0eef..f3f5121bb5a 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.h +++ b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.h @@ -83,10 +83,10 @@ enum STRSpellIds SPELL_BARON_ULTIMATUM = 27861 }; -template<typename AI> -inline AI* GetStratholmeAI(Creature* creature) +template <class AI, class T> +inline AI* GetStratholmeAI(T* obj) { - return GetInstanceAI<AI>(creature, StratholmeScriptName); + return GetInstanceAI<AI>(obj, StratholmeScriptName); } #endif |
