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/Handlers/NPCHandler.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/server/game/Handlers/NPCHandler.cpp') 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); } } -- cgit v1.2.3