aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Scripting/ScriptMgr.h
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/game/Scripting/ScriptMgr.h
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/game/Scripting/ScriptMgr.h')
-rw-r--r--src/server/game/Scripting/ScriptMgr.h78
1 files changed, 4 insertions, 74 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index e053a8b4c63..1f553989253 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -404,7 +404,7 @@ class TC_GAME_API UnitScript : public ScriptObject
virtual void ModifySpellDamageTaken(Unit* /*target*/, Unit* /*attacker*/, int32& /*damage*/) { }
};
-class TC_GAME_API CreatureScript : public UnitScript, public UpdatableScript<Creature>
+class TC_GAME_API CreatureScript : public UnitScript
{
protected:
@@ -412,35 +412,14 @@ class TC_GAME_API CreatureScript : public UnitScript, public UpdatableScript<Cre
public:
- // Called when a player opens a gossip dialog with the creature.
- virtual bool OnGossipHello(Player* /*player*/, Creature* /*creature*/) { return false; }
-
- // Called when a player selects a gossip item in the creature's gossip menu.
- virtual bool OnGossipSelect(Player* /*player*/, Creature* /*creature*/, uint32 /*sender*/, uint32 /*action*/) { return false; }
-
- // Called when a player selects a gossip with a code in the creature's gossip menu.
- virtual bool OnGossipSelectCode(Player* /*player*/, Creature* /*creature*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { return false; }
-
- // Called when a player accepts a quest from the creature.
- virtual bool OnQuestAccept(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/) { return false; }
-
- // Called when a player selects a quest in the creature's quest menu.
- virtual bool OnQuestSelect(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/) { return false; }
-
- // Called when a player completes a quest and is rewarded, opt is the selected item's index or 0
- virtual bool OnQuestReward(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
-
- // Called when the dialog status between a player and the creature is requested.
- virtual uint32 GetDialogStatus(Player* /*player*/, Creature* /*creature*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; }
-
// Called when the creature tries to spawn. Return false to block spawn and re-evaluate on next tick.
virtual bool CanSpawn(ObjectGuid::LowType /*spawnId*/, uint32 /*entry*/, CreatureTemplate const* /*baseTemplate*/, CreatureTemplate const* /*actTemplate*/, CreatureData const* /*cData*/, Map const* /*map*/) const { return true; }
// Called when a CreatureAI object is needed for the creature.
- virtual CreatureAI* GetAI(Creature* /*creature*/) const { return NULL; }
+ virtual CreatureAI* GetAI(Creature* /*creature*/) const = 0;
};
-class TC_GAME_API GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
+class TC_GAME_API GameObjectScript : public ScriptObject
{
protected:
@@ -448,38 +427,8 @@ class TC_GAME_API GameObjectScript : public ScriptObject, public UpdatableScript
public:
- // Called when a player opens a gossip dialog with the gameobject.
- virtual bool OnGossipHello(Player* /*player*/, GameObject* /*go*/) { return false; }
-
- // Called when a player selects a gossip item in the gameobject's gossip menu.
- virtual bool OnGossipSelect(Player* /*player*/, GameObject* /*go*/, uint32 /*sender*/, uint32 /*action*/) { return false; }
-
- // Called when a player selects a gossip with a code in the gameobject's gossip menu.
- virtual bool OnGossipSelectCode(Player* /*player*/, GameObject* /*go*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { return false; }
-
- // Called when a player accepts a quest from the gameobject.
- virtual bool OnQuestAccept(Player* /*player*/, GameObject* /*go*/, Quest const* /*quest*/) { return false; }
-
- // Called when a player completes a quest and is rewarded, opt is the selected item's index or 0
- virtual bool OnQuestReward(Player* /*player*/, GameObject* /*go*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
-
- // Called when the dialog status between a player and the gameobject is requested.
- virtual uint32 GetDialogStatus(Player* /*player*/, GameObject* /*go*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; }
-
- // Called when the game object is destroyed (destructible buildings only).
- virtual void OnDestroyed(GameObject* /*go*/, Player* /*player*/) { }
-
- // Called when the game object is damaged (destructible buildings only).
- virtual void OnDamaged(GameObject* /*go*/, Player* /*player*/) { }
-
- // Called when the game object loot state is changed.
- virtual void OnLootStateChanged(GameObject* /*go*/, uint32 /*state*/, Unit* /*unit*/) { }
-
- // Called when the game object state is changed.
- virtual void OnGameObjectStateChanged(GameObject* /*go*/, uint32 /*state*/) { }
-
// Called when a GameObjectAI object is needed for the gameobject.
- virtual GameObjectAI* GetAI(GameObject* /*go*/) const { return NULL; }
+ virtual GameObjectAI* GetAI(GameObject* /*go*/) const = 0;
};
class TC_GAME_API AreaTriggerScript : public ScriptObject
@@ -953,30 +902,11 @@ class TC_GAME_API ScriptMgr
public: /* CreatureScript */
- bool OnGossipHello(Player* player, Creature* creature);
- bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action);
- bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code);
- bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest);
- bool OnQuestSelect(Player* player, Creature* creature, Quest const* quest);
- bool OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt);
- uint32 GetDialogStatus(Player* player, Creature* creature);
bool CanSpawn(ObjectGuid::LowType spawnId, uint32 entry, CreatureTemplate const* actTemplate, CreatureData const* cData, Map const* map);
CreatureAI* GetCreatureAI(Creature* creature);
- void OnCreatureUpdate(Creature* creature, uint32 diff);
public: /* GameObjectScript */
- bool OnGossipHello(Player* player, GameObject* go);
- bool OnGossipSelect(Player* player, GameObject* go, uint32 sender, uint32 action);
- bool OnGossipSelectCode(Player* player, GameObject* go, uint32 sender, uint32 action, const char* code);
- bool OnQuestAccept(Player* player, GameObject* go, Quest const* quest);
- bool OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt);
- uint32 GetDialogStatus(Player* player, GameObject* go);
- void OnGameObjectDestroyed(GameObject* go, Player* player);
- void OnGameObjectDamaged(GameObject* go, Player* player);
- void OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit);
- void OnGameObjectStateChanged(GameObject* go, uint32 state);
- void OnGameObjectUpdate(GameObject* go, uint32 diff);
GameObjectAI* GetGameObjectAI(GameObject* go);
public: /* AreaTriggerScript */