aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/EasternKingdoms/ShadowfangKeep
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-05-01 18:19:36 -0300
committerariel- <ariel-@users.noreply.github.com>2017-05-01 18:19:36 -0300
commitf913f3bb8977c127d200d5d4a608ab434b21bbcd (patch)
treebb2d18ad5c0c23667271ca98bd6754cc745256a8 /src/server/scripts/EasternKingdoms/ShadowfangKeep
parente4481c016a86fe7db0b83a434ea08eb7ba50174f (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/ShadowfangKeep')
-rw-r--r--src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp17
-rw-r--r--src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp55
2 files changed, 33 insertions, 39 deletions
diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp
index 1ca23799f83..485c7b3d6a5 100644
--- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp
+++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp
@@ -99,7 +99,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)
{
@@ -107,6 +107,7 @@ class boss_apothecary_hummel : public CreatureScript
CloseGossipMenuFor(player);
DoAction(ACTION_START_EVENT);
}
+ return false;
}
void Reset() override
@@ -261,6 +262,12 @@ 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;
@@ -270,14 +277,6 @@ class boss_apothecary_hummel : public CreatureScript
{
return GetInstanceAI<boss_apothecary_hummelAI>(creature);
}
-
- bool OnQuestReward(Player* /*player*/, Creature* creature, Quest const* quest, uint32 /*opt*/) override
- {
- if (quest->GetQuestId() == QUEST_YOUVE_BEEN_SERVED)
- creature->AI()->DoAction(ACTION_START_EVENT);
-
- return true;
- }
};
struct npc_apothecary_genericAI : public ScriptedAI
diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
index f1cc7223d27..077a5664b93 100644
--- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
+++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
@@ -67,36 +67,6 @@ class npc_shadowfang_prisoner : public CreatureScript
public:
npc_shadowfang_prisoner() : CreatureScript("npc_shadowfang_prisoner") { }
- CreatureAI* GetAI(Creature* creature) const override
- {
- return GetInstanceAI<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)
@@ -143,8 +113,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 GetInstanceAI<npc_shadowfang_prisonerAI>(creature);
+ }
};
class npc_arugal_voidwalker : public CreatureScript