From f913f3bb8977c127d200d5d4a608ab434b21bbcd Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 1 May 2017 18:19:36 -0300 Subject: 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) --- .../EasternKingdoms/Stratholme/stratholme.cpp | 62 ++++++++++++---------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'src/server/scripts/EasternKingdoms/Stratholme') diff --git a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp index 3ccf0e3dd19..c67a1c2b4bb 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp @@ -32,6 +32,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "GameObjectAI.h" #include "stratholme.h" #include "Group.h" #include "Player.h" @@ -43,41 +44,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 GetInstanceAI(go); + } }; /*###### -- cgit v1.2.3