From 6604849716bc73d82a4cdbf8c66bb188086ceae4 Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 1 May 2017 18:19:36 -0300 Subject: 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) --- src/server/game/Scripting/ScriptMgr.cpp | 191 -------------------------------- 1 file changed, 191 deletions(-) (limited to 'src/server/game/Scripting/ScriptMgr.cpp') diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index fea767fa9a5..b70f38a8970 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1686,78 +1686,6 @@ bool ScriptMgr::OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo co return tmpscript->OnCastItemCombatSpell(player, victim, spellInfo, item); } -bool ScriptMgr::OnGossipHello(Player* player, Creature* creature) -{ - ASSERT(player); - ASSERT(creature); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnGossipHello(player, creature); -} - -bool ScriptMgr::OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) -{ - ASSERT(player); - ASSERT(creature); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - return tmpscript->OnGossipSelect(player, creature, sender, action); -} - -bool ScriptMgr::OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(code); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - return tmpscript->OnGossipSelectCode(player, creature, sender, action, code); -} - -bool ScriptMgr::OnQuestAccept(Player* player, Creature* creature, Quest const* quest) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(quest); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnQuestAccept(player, creature, quest); -} - -bool ScriptMgr::OnQuestSelect(Player* player, Creature* creature, Quest const* quest) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(quest); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnQuestSelect(player, creature, quest); -} - -bool ScriptMgr::OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(quest); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnQuestReward(player, creature, quest, opt); -} - -uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature) -{ - ASSERT(player); - ASSERT(creature); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->GetDialogStatus(player, creature); -} - bool ScriptMgr::CanSpawn(ObjectGuid::LowType spawnId, uint32 entry, CreatureTemplate const* actTemplate, CreatureData const* cData, Map const* map) { ASSERT(actTemplate); @@ -1793,115 +1721,6 @@ AreaTriggerAI* ScriptMgr::GetAreaTriggerAI(AreaTrigger* areatrigger) return tmpscript->GetAI(areatrigger); } -void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff) -{ - ASSERT(creature); - - GET_SCRIPT(CreatureScript, creature->GetScriptId(), tmpscript); - tmpscript->OnUpdate(creature, diff); -} - -bool ScriptMgr::OnGossipHello(Player* player, GameObject* go) -{ - ASSERT(player); - ASSERT(go); - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnGossipHello(player, go); -} - -bool ScriptMgr::OnGossipSelect(Player* player, GameObject* go, uint32 sender, uint32 action) -{ - ASSERT(player); - ASSERT(go); - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - return tmpscript->OnGossipSelect(player, go, sender, action); -} - -bool ScriptMgr::OnGossipSelectCode(Player* player, GameObject* go, uint32 sender, uint32 action, const char* code) -{ - ASSERT(player); - ASSERT(go); - ASSERT(code); - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - return tmpscript->OnGossipSelectCode(player, go, sender, action, code); -} - -bool ScriptMgr::OnQuestAccept(Player* player, GameObject* go, Quest const* quest) -{ - ASSERT(player); - ASSERT(go); - ASSERT(quest); - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnQuestAccept(player, go, quest); -} - -bool ScriptMgr::OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt) -{ - ASSERT(player); - ASSERT(go); - ASSERT(quest); - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->OnQuestReward(player, go, quest, opt); -} - -uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go) -{ - ASSERT(player); - ASSERT(go); - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS); - player->PlayerTalkClass->ClearMenus(); - return tmpscript->GetDialogStatus(player, go); -} - -void ScriptMgr::OnGameObjectDestroyed(GameObject* go, Player* player) -{ - ASSERT(go); - - GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript); - tmpscript->OnDestroyed(go, player); -} - -void ScriptMgr::OnGameObjectDamaged(GameObject* go, Player* player) -{ - ASSERT(go); - - GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript); - tmpscript->OnDamaged(go, player); -} - -void ScriptMgr::OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit) -{ - ASSERT(go); - - GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript); - tmpscript->OnLootStateChanged(go, state, unit); -} - -void ScriptMgr::OnGameObjectStateChanged(GameObject* go, uint32 state) -{ - ASSERT(go); - - GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript); - tmpscript->OnGameObjectStateChanged(go, state); -} - -void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff) -{ - ASSERT(go); - - GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript); - tmpscript->OnUpdate(go, diff); -} - bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger, bool entered) { ASSERT(player); @@ -2585,22 +2404,12 @@ CreatureScript::CreatureScript(const char* name) ScriptRegistry::Instance()->AddScript(this); } -uint32 CreatureScript::GetDialogStatus(Player* /*player*/, Creature* /*creature*/) -{ - return DIALOG_STATUS_SCRIPTED_NO_STATUS; -} - GameObjectScript::GameObjectScript(const char* name) : ScriptObject(name) { ScriptRegistry::Instance()->AddScript(this); } -uint32 GameObjectScript::GetDialogStatus(Player* /*player*/, GameObject* /*go*/) -{ - return DIALOG_STATUS_SCRIPTED_NO_STATUS; -} - AreaTriggerScript::AreaTriggerScript(const char* name) : ScriptObject(name) { -- cgit v1.2.3