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/ShadowfangKeep | |
| 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/ShadowfangKeep')
| -rw-r--r-- | src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp | 26 | ||||
| -rw-r--r-- | src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp | 55 |
2 files changed, 45 insertions, 36 deletions
diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp index 6edda7824be..a1714085160 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp @@ -102,7 +102,7 @@ class boss_apothecary_hummel : public CreatureScript { boss_apothecary_hummelAI(Creature* creature) : BossAI(creature, DATA_APOTHECARY_HUMMEL), _deadCount(0), _isDead(false) { } - void sGossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override + bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override { if (menuId == GOSSIP_MENU_HUMMEL && gossipListId == GOSSIP_OPTION_START) { @@ -110,6 +110,7 @@ class boss_apothecary_hummel : public CreatureScript CloseGossipMenuFor(player); DoAction(ACTION_START_EVENT); } + return false; } void Reset() override @@ -267,17 +268,20 @@ class boss_apothecary_hummel : public CreatureScript DoMeleeAttackIfReady(); } + void QuestReward(Player* /*player*/, Quest const* quest, uint32 /*opt*/) override + { + if (quest->GetQuestId() == QUEST_YOUVE_BEEN_SERVED) + DoAction(ACTION_START_EVENT); + } + private: uint8 _deadCount; bool _isDead; }; - bool OnQuestReward(Player* /*player*/, Creature* creature, Quest const* quest, uint32 /*opt*/) override + CreatureAI* GetAI(Creature* creature) const override { - if (quest->GetQuestId() == QUEST_YOUVE_BEEN_SERVED) - creature->AI()->DoAction(ACTION_START_EVENT); - - return true; + return GetShadowfangKeepAI<boss_apothecary_hummelAI>(creature); } }; @@ -325,6 +329,11 @@ class npc_apothecary_frye : public CreatureScript Talk(SAY_FRYE_DEATH); } }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetShadowfangKeepAI<npc_apothecary_fryeAI>(creature); + } }; class npc_apothecary_baxter : public CreatureScript @@ -383,6 +392,11 @@ class npc_apothecary_baxter : public CreatureScript private: EventMap _events; }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetShadowfangKeepAI<npc_apothecary_baxterAI>(creature); + } }; // 68965 -[DND] Lingering Fumes Targetting (starter) diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp index c323d87f091..b1b641806a8 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp @@ -66,36 +66,6 @@ class npc_shadowfang_prisoner : public CreatureScript public: npc_shadowfang_prisoner() : CreatureScript("npc_shadowfang_prisoner") { } - CreatureAI* GetAI(Creature* creature) const override - { - return GetShadowfangKeepAI<npc_shadowfang_prisonerAI>(creature); - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override - { - ClearGossipMenuFor(player); - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - CloseGossipMenuFor(player); - - if (npc_escortAI* pEscortAI = CAST_AI(npc_shadowfang_prisoner::npc_shadowfang_prisonerAI, creature->AI())) - pEscortAI->Start(false, false); - } - return true; - } - - bool OnGossipHello(Player* player, Creature* creature) override - { - InstanceScript* instance = creature->GetInstanceScript(); - - if (instance && instance->GetData(TYPE_FREE_NPC) != DONE && instance->GetData(TYPE_RETHILGORE) == DONE) - AddGossipItemFor(player, Player::GetDefaultGossipMenuForSource(creature), 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID()); - - return true; - } - struct npc_shadowfang_prisonerAI : public npc_escortAI { npc_shadowfang_prisonerAI(Creature* creature) : npc_escortAI(creature) @@ -142,8 +112,33 @@ public: void Reset() override { } void EnterCombat(Unit* /*who*/) override { } + + bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override + { + uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId); + ClearGossipMenuFor(player); + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + CloseGossipMenuFor(player); + Start(false, false); + } + return true; + } + + bool GossipHello(Player* player) override + { + if (instance->GetData(TYPE_FREE_NPC) != DONE && instance->GetData(TYPE_RETHILGORE) == DONE) + AddGossipItemFor(player, Player::GetDefaultGossipMenuForSource(me), 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + SendGossipMenuFor(player, player->GetGossipTextId(me), me->GetGUID()); + return true; + } }; + CreatureAI* GetAI(Creature* creature) const override + { + return GetShadowfangKeepAI<npc_shadowfang_prisonerAI>(creature); + } }; class npc_arugal_voidwalker : public CreatureScript |
