aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/EasternKingdoms/ScarletMonastery
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/ScarletMonastery
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/ScarletMonastery')
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp48
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/scarlet_monastery.h6
2 files changed, 32 insertions, 22 deletions
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
index 3102b7461d5..c1b3bbd8aec 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
@@ -25,6 +25,7 @@ EndScriptData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
+#include "GameObjectAI.h"
#include "SpellMgr.h"
#include "scarlet_monastery.h"
#include "LFGMgr.h"
@@ -876,32 +877,41 @@ enum LooselyTurnedSoil
class go_loosely_turned_soil : public GameObjectScript
{
-public:
- go_loosely_turned_soil() : GameObjectScript("go_loosely_turned_soil") { }
+ public:
+ go_loosely_turned_soil() : GameObjectScript("go_loosely_turned_soil") { }
- bool OnGossipHello(Player* player, GameObject* /*go*/) override
- {
- if (InstanceScript* instance = player->GetInstanceScript())
- if (instance->GetBossState(DATA_HORSEMAN_EVENT) == IN_PROGRESS || player->GetQuestStatus(QUEST_CALL_THE_HEADLESS_HORSEMAN) != QUEST_STATUS_COMPLETE)
- return true;
+ struct go_loosely_turned_soilAI : public GameObjectAI
+ {
+ go_loosely_turned_soilAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { }
- return false;
- }
+ InstanceScript* instance;
+
+ bool GossipHello(Player* player, bool /*reportUse*/) override
+ {
+ if (instance->GetBossState(DATA_HORSEMAN_EVENT) == IN_PROGRESS || player->GetQuestStatus(QUEST_CALL_THE_HEADLESS_HORSEMAN) != QUEST_STATUS_COMPLETE)
+ return true;
- bool OnQuestReward(Player* player, GameObject* go, Quest const* /*quest*/, uint32 /*opt*/) override
- {
- if (InstanceScript* instance = go->GetInstanceScript())
- if (instance->GetBossState(DATA_HORSEMAN_EVENT) == IN_PROGRESS)
return false;
+ }
- player->AreaExploredOrEventHappens(11405);
- if (Creature* horseman = go->SummonCreature(HH_MOUNTED, FlightPoint[20].x, FlightPoint[20].y, FlightPoint[20].z, 0, TEMPSUMMON_MANUAL_DESPAWN, 0))
+ void QuestReward(Player* player, Quest const* /*quest*/, uint32 /*opt*/) override
+ {
+ if (instance->GetBossState(DATA_HORSEMAN_EVENT) == IN_PROGRESS)
+ return;
+
+ player->AreaExploredOrEventHappens(11405);
+ if (Creature* horseman = me->SummonCreature(HH_MOUNTED, FlightPoint[20].x, FlightPoint[20].y, FlightPoint[20].z, 0, TEMPSUMMON_MANUAL_DESPAWN, 0))
+ {
+ ENSURE_AI(boss_headless_horseman::boss_headless_horsemanAI, horseman->AI())->PlayerGUID = player->GetGUID();
+ ENSURE_AI(boss_headless_horseman::boss_headless_horsemanAI, horseman->AI())->FlyMode();
+ }
+ }
+ };
+
+ GameObjectAI* GetAI(GameObject* go) const override
{
- ENSURE_AI(boss_headless_horseman::boss_headless_horsemanAI, horseman->AI())->PlayerGUID = player->GetGUID();
- ENSURE_AI(boss_headless_horseman::boss_headless_horsemanAI, horseman->AI())->FlyMode();
+ return GetScarletMonasteryAI<go_loosely_turned_soilAI>(go);
}
- return true;
- }
};
void npc_head::npc_headAI::Disappear()
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/scarlet_monastery.h b/src/server/scripts/EasternKingdoms/ScarletMonastery/scarlet_monastery.h
index fede79df5d3..94db224f4ce 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/scarlet_monastery.h
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/scarlet_monastery.h
@@ -60,10 +60,10 @@ enum SMGameObjectIds
GO_PUMPKIN_SHRINE = 186267
};
-template<class AI>
-inline AI* GetScarletMonasteryAI(Creature* creature)
+template<class AI, class T>
+inline AI* GetScarletMonasteryAI(T* obj)
{
- return GetInstanceAI<AI>(creature, SMScriptName);
+ return GetInstanceAI<AI>(obj, SMScriptName);
}
#endif // SCARLET_M_