aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/NPCHandler.cpp
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-05-01 18:19:36 -0300
committerfunjoker <funjoker109@gmail.com>2020-05-03 03:04:32 +0200
commit6604849716bc73d82a4cdbf8c66bb188086ceae4 (patch)
treebd293ee1fdac3baf8bef0a55aa854fe8bf793bc2 /src/server/game/Handlers/NPCHandler.cpp
parente3489c48ee6929018618322571adbb8dc59e11b1 (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/game/Handlers/NPCHandler.cpp')
-rw-r--r--src/server/game/Handlers/NPCHandler.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp
index 1cda9ba2f1c..7739f383e03 100644
--- a/src/server/game/Handlers/NPCHandler.cpp
+++ b/src/server/game/Handlers/NPCHandler.cpp
@@ -183,13 +183,13 @@ void WorldSession::HandleGossipHelloOpcode(WorldPackets::NPC::Hello& packet)
}
}
- if (!sScriptMgr->OnGossipHello(_player, unit))
+ _player->PlayerTalkClass->ClearMenus();
+ if (!unit->AI()->GossipHello(_player))
{
// _player->TalkedToCreature(unit->GetEntry(), unit->GetGUID());
_player->PrepareGossipMenu(unit, unit->GetCreatureTemplate()->GossipMenuId, true);
_player->SendPreparedGossip(unit);
}
- unit->AI()->sGossipHello(_player);
}
void WorldSession::HandleGossipSelectOptionOpcode(WorldPackets::NPC::GossipSelectOption& packet)
@@ -248,14 +248,12 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPackets::NPC::GossipSelec
{
if (unit)
{
- unit->AI()->sGossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode.c_str());
- if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex), packet.PromotionCode.c_str()))
+ if (!unit->AI()->GossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode.c_str()))
_player->OnGossipSelect(unit, packet.GossipIndex, packet.GossipID);
}
else
{
- go->AI()->GossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode.c_str());
- if (!sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex), packet.PromotionCode.c_str()))
+ if (!go->AI()->GossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode.c_str()))
_player->OnGossipSelect(go, packet.GossipIndex, packet.GossipID);
}
}
@@ -263,14 +261,12 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPackets::NPC::GossipSelec
{
if (unit)
{
- unit->AI()->sGossipSelect(_player, packet.GossipID, packet.GossipIndex);
- if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex)))
+ if (!unit->AI()->GossipSelect(_player, packet.GossipID, packet.GossipIndex))
_player->OnGossipSelect(unit, packet.GossipIndex, packet.GossipID);
}
else
{
- go->AI()->GossipSelect(_player, packet.GossipID, packet.GossipIndex);
- if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex)))
+ if (!go->AI()->GossipSelect(_player, packet.GossipID, packet.GossipIndex))
_player->OnGossipSelect(go, packet.GossipIndex, packet.GossipID);
}
}