diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-05-01 18:19:36 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-05-01 18:19:36 -0300 |
| commit | f913f3bb8977c127d200d5d4a608ab434b21bbcd (patch) | |
| tree | bb2d18ad5c0c23667271ca98bd6754cc745256a8 /src/server/scripts/EasternKingdoms/Stratholme | |
| parent | e4481c016a86fe7db0b83a434ea08eb7ba50174f (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)
Diffstat (limited to 'src/server/scripts/EasternKingdoms/Stratholme')
| -rw-r--r-- | src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp | 62 |
1 files changed, 35 insertions, 27 deletions
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_gauntlet_gateAI>(go); + } }; /*###### |
