diff options
Diffstat (limited to 'src')
19 files changed, 382 insertions, 202 deletions
diff --git a/src/server/game/AI/CoreAI/ConversationAI.cpp b/src/server/game/AI/CoreAI/ConversationAI.cpp new file mode 100644 index 00000000000..19de90c6ad2 --- /dev/null +++ b/src/server/game/AI/CoreAI/ConversationAI.cpp @@ -0,0 +1,28 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "Conversation.h" +#include "ConversationAI.h" + +ConversationAI::ConversationAI(Conversation* c, uint32 scriptId) : _scriptId(scriptId ? scriptId : c->GetScriptId()), conversation(c) +{ + ASSERT(_scriptId, "A ConversationAI was initialized with an invalid scriptId!"); +} + +ConversationAI::~ConversationAI() +{ +} diff --git a/src/server/game/AI/CoreAI/ConversationAI.h b/src/server/game/AI/CoreAI/ConversationAI.h new file mode 100644 index 00000000000..25adc8bc68b --- /dev/null +++ b/src/server/game/AI/CoreAI/ConversationAI.h @@ -0,0 +1,73 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TRINITY_CONVERSATIONAI_H +#define TRINITY_CONVERSATIONAI_H + +#include "Define.h" +#include "ObjectGuid.h" + +class Conversation; +class Unit; +class Player; + +class TC_GAME_API ConversationAI +{ + uint32 _scriptId; + + protected: + Conversation* const conversation; + public: + explicit ConversationAI(Conversation* c, uint32 scriptId = {}); + virtual ~ConversationAI(); + + // Called when the Conversation has just been initialized, just before added to map + virtual void OnInitialize() {} + + // Called when Conversation is created but not added to Map yet. + virtual void OnCreate([[maybe_unused]] Unit* creator) { } + + // Called when Conversation is started + virtual void OnStart() { } + + // Called when player sends CMSG_CONVERSATION_LINE_STARTED with valid conversation guid + virtual void OnLineStarted([[maybe_unused]] uint32 lineId, [[maybe_unused]] Player* sender) { } + + // Called for each update tick + virtual void OnUpdate([[maybe_unused]] uint32 diff) { } + + // Called when the Conversation is removed + virtual void OnRemove() { } + + // Pass parameters between AI + virtual void DoAction([[maybe_unused]] int32 param) { } + virtual uint32 GetData([[maybe_unused]] uint32 id = 0) const { return 0; } + virtual void SetData([[maybe_unused]] uint32 id, [[maybe_unused]] uint32 value) { } + virtual void SetGUID([[maybe_unused]] ObjectGuid const& guid, [[maybe_unused]] int32 id = 0) { } + virtual ObjectGuid GetGUID([[maybe_unused]] int32 id = 0) const { return ObjectGuid::Empty; } + + // Gets the id of the AI (script id) + uint32 GetId() const { return _scriptId; } +}; + +class NullConversationAI final : public ConversationAI +{ + public: + using ConversationAI::ConversationAI; +}; + +#endif diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp index c6a8871a822..ec22e9e4eba 100644 --- a/src/server/game/AI/CreatureAISelector.cpp +++ b/src/server/game/AI/CreatureAISelector.cpp @@ -28,6 +28,9 @@ #include "AreaTriggerAI.h" +#include "Conversation.h" +#include "ConversationAI.h" + #include "ScriptMgr.h" namespace FactorySelector @@ -187,4 +190,28 @@ namespace FactorySelector return GetNullAreaTriggerAIScriptId(); } + + static uint32 GetNullConversationAIScriptId() + { + return sObjectMgr->GetScriptId("NullConversationAI", false); + } + + ConversationAI* SelectConversationAI(Conversation* conversation) + { + if (ConversationAI* ai = sScriptMgr->GetConversationAI(conversation)) + return ai; + + return new NullConversationAI(conversation, GetNullConversationAIScriptId()); + } + + uint32 GetSelectedAIId(Conversation const* conversation) + { + if (uint32 id = conversation->GetScriptId()) + { + if (sScriptMgr->CanCreateConversationAI(id)) + return id; + } + + return GetNullConversationAIScriptId(); + } } diff --git a/src/server/game/AI/CreatureAISelector.h b/src/server/game/AI/CreatureAISelector.h index 0cb6c9632b3..d2ee805706f 100644 --- a/src/server/game/AI/CreatureAISelector.h +++ b/src/server/game/AI/CreatureAISelector.h @@ -28,6 +28,8 @@ class GameObjectAI; class GameObject; class AreaTriggerAI; class AreaTrigger; +class Conversation; +class ConversationAI; namespace FactorySelector { @@ -35,10 +37,12 @@ namespace FactorySelector TC_GAME_API MovementGenerator* SelectMovementGenerator(Unit* unit); TC_GAME_API GameObjectAI* SelectGameObjectAI(GameObject* go); TC_GAME_API AreaTriggerAI* SelectAreaTriggerAI(AreaTrigger* at); + TC_GAME_API ConversationAI* SelectConversationAI(Conversation* conversation); TC_GAME_API uint32 GetSelectedAIId(Creature const* creature); TC_GAME_API uint32 GetSelectedAIId(GameObject const* go); TC_GAME_API uint32 GetSelectedAIId(AreaTrigger const* at); + TC_GAME_API uint32 GetSelectedAIId(Conversation const* conversation); } #endif diff --git a/src/server/game/Entities/Conversation/Conversation.cpp b/src/server/game/Entities/Conversation/Conversation.cpp index fa1d5204165..746f936a88c 100644 --- a/src/server/game/Entities/Conversation/Conversation.cpp +++ b/src/server/game/Entities/Conversation/Conversation.cpp @@ -18,8 +18,10 @@ #include "Conversation.h" #include "ConditionMgr.h" #include "Containers.h" +#include "ConversationAI.h" #include "ConversationDataStore.h" #include "Creature.h" +#include "CreatureAISelector.h" #include "DB2Stores.h" #include "IteratorPair.h" #include "Log.h" @@ -61,6 +63,8 @@ void Conversation::RemoveFromWorld() ///- Remove the Conversation from the accessor and from all lists of objects in world if (IsInWorld()) { + _ai->OnRemove(); + WorldObject::RemoveFromWorld(); GetMap()->GetObjectsStore().Remove<Conversation>(GetGUID()); } @@ -68,7 +72,7 @@ void Conversation::RemoveFromWorld() void Conversation::Update(uint32 diff) { - sScriptMgr->OnConversationUpdate(this, diff); + _ai->OnUpdate(diff); if (GetDuration() > Milliseconds(diff)) { @@ -183,6 +187,8 @@ void Conversation::Create(ObjectGuid::LowType lowGuid, uint32 conversationEntry, SetEntry(conversationEntry); SetObjectScale(1.0f); + AI_Initialize(); + _textureKitId = conversationTemplate->TextureKitId; for (ConversationActorTemplate const& actor : conversationTemplate->Actors) @@ -227,7 +233,7 @@ void Conversation::Create(ObjectGuid::LowType lowGuid, uint32 conversationEntry, // conversations are despawned 5-20s after LastLineEndTime _duration += 10s; - sScriptMgr->OnConversationCreate(this, creator); + _ai->OnCreate(creator); } bool Conversation::Start() @@ -255,7 +261,7 @@ bool Conversation::Start() if (!GetMap()->AddToMap(this)) return false; - sScriptMgr->OnConversationStart(this); + _ai->OnStart(); return true; } @@ -344,6 +350,18 @@ Creature* Conversation::GetActorCreature(uint32 actorIdx) const return actor->ToCreature(); } +void Conversation::AI_Initialize() +{ + AI_Destroy(); + _ai.reset(FactorySelector::SelectConversationAI(this)); + _ai->OnInitialize(); +} + +void Conversation::AI_Destroy() +{ + _ai.reset(); +} + uint32 Conversation::GetScriptId() const { return sConversationDataStore->GetConversationTemplate(GetEntry())->ScriptId; diff --git a/src/server/game/Entities/Conversation/Conversation.h b/src/server/game/Entities/Conversation/Conversation.h index f56c8e1d3c6..4f85809b5ba 100644 --- a/src/server/game/Entities/Conversation/Conversation.h +++ b/src/server/game/Entities/Conversation/Conversation.h @@ -22,6 +22,7 @@ #include "GridObject.h" #include "Hash.h" +class ConversationAI; class Unit; class SpellInfo; enum class ConversationActorType : uint32; @@ -85,6 +86,10 @@ class TC_GAME_API Conversation final : public WorldObject, public GridObject<Con Unit* GetActorUnit(uint32 actorIdx) const; Creature* GetActorCreature(uint32 actorIdx) const; + void AI_Initialize(); + void AI_Destroy(); + + ConversationAI* AI() { return _ai.get(); } uint32 GetScriptId() const; UF::UpdateField<UF::ConversationData, int32(WowCS::EntityFragment::CGObject), TYPEID_CONVERSATION> m_conversationData; @@ -97,6 +102,8 @@ class TC_GAME_API Conversation final : public WorldObject, public GridObject<Con std::unordered_map<std::pair<LocaleConstant /*locale*/, int32 /*lineId*/>, Milliseconds /*startTime*/> _lineStartTimes; std::array<Milliseconds /*endTime*/, TOTAL_LOCALES> _lastLineEndTimes; + + std::unique_ptr<ConversationAI> _ai; }; #endif // TRINITYCORE_CONVERSATION_H diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 451526e1cf8..189e40cdca8 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -27,6 +27,7 @@ #include "ClientConfigPackets.h" #include "Common.h" #include "Conversation.h" +#include "ConversationAI.h" #include "Corpse.h" #include "DatabaseEnv.h" #include "DB2Stores.h" @@ -1164,8 +1165,8 @@ void WorldSession::HandleCloseInteraction(WorldPackets::Misc::CloseInteraction& void WorldSession::HandleConversationLineStarted(WorldPackets::Misc::ConversationLineStarted& conversationLineStarted) { - if (Conversation* convo = ObjectAccessor::GetConversation(*_player, conversationLineStarted.ConversationGUID)) - sScriptMgr->OnConversationLineStarted(convo, conversationLineStarted.LineID, _player); + if (Conversation* conversation = ObjectAccessor::GetConversation(*_player, conversationLineStarted.ConversationGUID)) + conversation->AI()->OnLineStarted(conversationLineStarted.LineID, _player); } void WorldSession::HandleRequestLatestSplashScreen(WorldPackets::Misc::RequestLatestSplashScreen& /*requestLatestSplashScreen*/) diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index e69b64a73fa..99f25980a0d 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -21,6 +21,7 @@ #include "AreaTriggerAI.h" #include "ChatCommand.h" #include "Conversation.h" +#include "ConversationAI.h" #include "Creature.h" #include "CreatureAI.h" #include "CreatureAIImpl.h" @@ -382,7 +383,7 @@ public: /// This hook is responsible for swapping Creature, GameObject and AreaTrigger AI's template<typename ObjectType, typename ScriptType, typename Base> -class CreatureGameObjectAreaTriggerScriptRegistrySwapHooks +class CreatureGameObjectAreaTriggerConversationScriptRegistrySwapHooks : public ScriptRegistrySwapHookBase { template<typename W> @@ -484,6 +485,24 @@ class CreatureGameObjectAreaTriggerScriptRegistrySwapHooks "The AI should be null here!"); } + // Hook which is called before a conversation is swapped + static void UnloadResetScript(Conversation* conversation) + { + // Remove deletable events only, + // otherwise it causes crashes with non-deletable spell events. + conversation->m_Events.KillAllEvents(false); + + conversation->AI()->OnRemove(); + } + + static void UnloadDestroyScript(Conversation* conversation) + { + conversation->AI_Destroy(); + + ASSERT(!conversation->AI(), + "The AI should be null here!"); + } + // Hook which is called after a creature was swapped static void LoadInitializeScript(Creature* creature) { @@ -543,6 +562,20 @@ class CreatureGameObjectAreaTriggerScriptRegistrySwapHooks at->AI()->OnCreate(nullptr); } + // Hook which is called after a conversation was swapped + static void LoadInitializeScript(Conversation* conversation) + { + ASSERT(!conversation->AI(), + "The AI should be null here!"); + + conversation->AI_Initialize(); + } + + static void LoadResetScript(Conversation* conversation) + { + conversation->AI()->OnCreate(nullptr); + } + static Creature* GetEntityFromMap(std::common_type<Creature>, Map* map, ObjectGuid const& guid) { return map->GetCreature(guid); @@ -558,6 +591,11 @@ class CreatureGameObjectAreaTriggerScriptRegistrySwapHooks return map->GetAreaTrigger(guid); } + static Conversation* GetEntityFromMap(std::common_type<Conversation>, Map* map, ObjectGuid const& guid) + { + return map->GetConversation(guid); + } + static auto VisitObjectsToSwapOnMap(std::unordered_set<uint32> const& idsToRemove) { return [&idsToRemove](Map* map, auto&& visitor) @@ -731,24 +769,32 @@ private: // This hook is responsible for swapping CreatureAI's template<typename Base> class ScriptRegistrySwapHooks<CreatureScript, Base> - : public CreatureGameObjectAreaTriggerScriptRegistrySwapHooks< + : public CreatureGameObjectAreaTriggerConversationScriptRegistrySwapHooks< Creature, CreatureScript, Base > { }; // This hook is responsible for swapping GameObjectAI's template<typename Base> class ScriptRegistrySwapHooks<GameObjectScript, Base> - : public CreatureGameObjectAreaTriggerScriptRegistrySwapHooks< + : public CreatureGameObjectAreaTriggerConversationScriptRegistrySwapHooks< GameObject, GameObjectScript, Base > { }; // This hook is responsible for swapping AreaTriggerAI's template<typename Base> class ScriptRegistrySwapHooks<AreaTriggerEntityScript, Base> - : public CreatureGameObjectAreaTriggerScriptRegistrySwapHooks< + : public CreatureGameObjectAreaTriggerConversationScriptRegistrySwapHooks< AreaTrigger, AreaTriggerEntityScript, Base > { }; +// This hook is responsible for swapping ConversationAI's +template<typename Base> +class ScriptRegistrySwapHooks<ConversationScript, Base> + : public CreatureGameObjectAreaTriggerConversationScriptRegistrySwapHooks< + Conversation, ConversationScript, Base + > { +}; + /// This hook is responsible for swapping BattlefieldScripts template<typename Base> class ScriptRegistrySwapHooks<BattlefieldScript, Base> @@ -955,7 +1001,7 @@ class SpecializedScriptRegistry<ScriptType, true> friend class ScriptRegistrySwapHooks; template<typename, typename, typename> - friend class CreatureGameObjectAreaTriggerScriptRegistrySwapHooks; + friend class CreatureGameObjectAreaTriggerConversationScriptRegistrySwapHooks; public: SpecializedScriptRegistry() { } @@ -1752,6 +1798,19 @@ bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger, b return entered ? tmpscript->OnTrigger(player, trigger) : tmpscript->OnExit(player, trigger); } +bool ScriptMgr::CanCreateConversationAI(uint32 scriptId) const +{ + return !!ScriptRegistry<ConversationScript>::Instance()->GetScriptById(scriptId); +} + +ConversationAI* ScriptMgr::GetConversationAI(Conversation* conversation) +{ + ASSERT(conversation); + + GET_SCRIPT_RET(ConversationScript, conversation->GetScriptId(), tmpscript, nullptr); + return tmpscript->GetAI(conversation); +} + Battlefield* ScriptMgr::CreateBattlefield(uint32 scriptId, Map* map) { GET_SCRIPT_RET(BattlefieldScript, scriptId, tmpscript, nullptr); @@ -2279,40 +2338,6 @@ void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& dama FOREACH_SCRIPT(UnitScript)->ModifySpellDamageTaken(target, attacker, damage, spellInfo); } -// Conversation -void ScriptMgr::OnConversationCreate(Conversation* conversation, Unit* creator) -{ - ASSERT(conversation); - - GET_SCRIPT(ConversationScript, conversation->GetScriptId(), tmpscript); - tmpscript->OnConversationCreate(conversation, creator); -} - -void ScriptMgr::OnConversationStart(Conversation* conversation) -{ - ASSERT(conversation); - - GET_SCRIPT(ConversationScript, conversation->GetScriptId(), tmpscript); - tmpscript->OnConversationStart(conversation); -} - -void ScriptMgr::OnConversationLineStarted(Conversation* conversation, uint32 lineId, Player* sender) -{ - ASSERT(conversation); - ASSERT(sender); - - GET_SCRIPT(ConversationScript, conversation->GetScriptId(), tmpscript); - tmpscript->OnConversationLineStarted(conversation, lineId, sender); -} - -void ScriptMgr::OnConversationUpdate(Conversation* conversation, uint32 diff) -{ - ASSERT(conversation); - - GET_SCRIPT(ConversationScript, conversation->GetScriptId(), tmpscript); - tmpscript->OnConversationUpdate(conversation, diff); -} - // Scene void ScriptMgr::OnSceneStart(Player* player, uint32 sceneInstanceID, SceneTemplate const* sceneTemplate) { @@ -3172,20 +3197,9 @@ ConversationScript::ConversationScript(char const* name) ConversationScript::~ConversationScript() = default; -void ConversationScript::OnConversationCreate(Conversation* /*conversation*/, Unit* /*creator*/) -{ -} - -void ConversationScript::OnConversationStart(Conversation* /*conversation*/ ) -{ -} - -void ConversationScript::OnConversationLineStarted(Conversation* /*conversation*/, uint32 /*lineId*/, Player* /*sender*/) -{ -} - -void ConversationScript::OnConversationUpdate(Conversation* /*conversation*/, uint32 /*diff*/) +ConversationAI* ConversationScript::GetAI(Conversation* /*conversation*/) const { + return nullptr; } SceneScript::SceneScript(char const* name) diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 31a5842a383..d7746b01e04 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -38,6 +38,7 @@ class BattlegroundMap; class BattlegroundScript; class Channel; class Conversation; +class ConversationAI; class Creature; class CreatureAI; class DynamicObject; @@ -911,17 +912,8 @@ class TC_GAME_API ConversationScript : public ScriptObject ~ConversationScript(); - // Called when Conversation is created but not added to Map yet. - virtual void OnConversationCreate(Conversation* conversation, Unit* creator); - - // Called when Conversation is started - virtual void OnConversationStart(Conversation* conversation); - - // Called when player sends CMSG_CONVERSATION_LINE_STARTED with valid conversation guid - virtual void OnConversationLineStarted(Conversation* conversation, uint32 lineId, Player* sender); - - // Called for each update tick - virtual void OnConversationUpdate(Conversation* conversation, uint32 diff); + // Called when a ConversationAI object is needed for the conversation. + virtual ConversationAI* GetAI(Conversation* conversation) const; }; class TC_GAME_API SceneScript : public ScriptObject @@ -1279,10 +1271,8 @@ class TC_GAME_API ScriptMgr public: /* ConversationScript */ - void OnConversationCreate(Conversation* conversation, Unit* creator); - void OnConversationStart(Conversation* conversation); - void OnConversationLineStarted(Conversation* conversation, uint32 lineId, Player* sender); - void OnConversationUpdate(Conversation* conversation, uint32 diff); + bool CanCreateConversationAI(uint32 scriptId) const; + ConversationAI* GetConversationAI(Conversation* conversation); public: /* SceneScript */ @@ -1405,6 +1395,15 @@ class GenericAreaTriggerEntityScript : public AreaTriggerEntityScript }; #define RegisterAreaTriggerAI(ai_name) new GenericAreaTriggerEntityScript<ai_name>(#ai_name) +template <class AI> +class GenericConversationScript : public ConversationScript +{ +public: + GenericConversationScript(char const* name) : ConversationScript(name) {} + ConversationAI* GetAI(Conversation* conversation) const override { return new AI(conversation); } +}; +#define RegisterConversationAI(ai_name) new GenericConversationScript<ai_name>(#ai_name) + template<class Script> class GenericBattlegroundMapScript : public BattlegroundMapScript { diff --git a/src/server/scripts/BrokenIsles/zone_mardum.cpp b/src/server/scripts/BrokenIsles/zone_mardum.cpp index 34b604ab7af..b4ac35635ba 100644 --- a/src/server/scripts/BrokenIsles/zone_mardum.cpp +++ b/src/server/scripts/BrokenIsles/zone_mardum.cpp @@ -20,6 +20,7 @@ #include "CellImpl.h" #include "Containers.h" #include "Conversation.h" +#include "ConversationAI.h" #include "CreatureAIImpl.h" #include "EventProcessor.h" #include "GridNotifiersImpl.h" @@ -376,10 +377,10 @@ struct npc_cyana_nightglaive_invasion_begins : public ScriptedAI }; // 922 - The Invasion Begins -class conversation_the_invasion_begins : public ConversationScript +class conversation_the_invasion_begins : public ConversationAI { public: - conversation_the_invasion_begins() : ConversationScript("conversation_the_invasion_begins") { } + conversation_the_invasion_begins(Conversation* conversation) : ConversationAI(conversation) { } enum TheInvasionBeginsConversationData { @@ -396,7 +397,7 @@ public: EVENT_ILLIDARI_START_PATH }; - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* kaynObject = GetClosestCreatureWithOptions(creator, 10.0f, { .CreatureId = NPC_KAYN_SUNFURY_INVASION_BEGINS, .IgnorePhases = true }); Creature* jayceObject = GetClosestCreatureWithOptions(creator, 10.0f, { .CreatureId = NPC_JAYCE_DARKWEAVER_INVASION_BEGINS, .IgnorePhases = true }); @@ -428,7 +429,7 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale(); @@ -439,7 +440,7 @@ public: _events.ScheduleEvent(EVENT_ILLIDARI_START_PATH, *illidariStartPathLineStarted); } - static void StartCloneChannel(ObjectGuid guid, Conversation* conversation) + void StartCloneChannel(ObjectGuid guid) { Unit* privateObjectOwner = ObjectAccessor::GetUnit(*conversation, conversation->GetPrivateObjectOwner()); if (!privateObjectOwner) @@ -452,7 +453,7 @@ public: clone->CastSpell(privateObjectOwner, SPELL_TRACK_TARGET_IN_CHANNEL, false); } - static void StartCloneMovement(ObjectGuid cloneGUID, uint32 pathId, uint32 animKit, Conversation* conversation) + void StartCloneMovement(ObjectGuid cloneGUID, uint32 pathId, uint32 animKit) { Creature* clone = ObjectAccessor::GetCreature(*conversation, cloneGUID); if (!clone) @@ -464,7 +465,7 @@ public: clone->SetAIAnimKitId(animKit); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -472,12 +473,12 @@ public: { case EVENT_ILLIDARI_FACE_PLAYERS: { - StartCloneChannel(conversation->GetActorUnit(CONVO_ACTOR_IDX_KAYN)->GetGUID(), conversation); - StartCloneChannel(conversation->GetActorUnit(CONVO_ACTOR_IDX_KORVAS)->GetGUID(), conversation); - StartCloneChannel(_jayceGUID, conversation); - StartCloneChannel(_allariGUID, conversation); - StartCloneChannel(_cyanaGUID, conversation); - StartCloneChannel(_sevisGUID, conversation); + StartCloneChannel(conversation->GetActorUnit(CONVO_ACTOR_IDX_KAYN)->GetGUID()); + StartCloneChannel(conversation->GetActorUnit(CONVO_ACTOR_IDX_KORVAS)->GetGUID()); + StartCloneChannel(_jayceGUID); + StartCloneChannel(_allariGUID); + StartCloneChannel(_cyanaGUID); + StartCloneChannel(_sevisGUID); break; } case EVENT_ILLIDARI_START_PATH: @@ -501,11 +502,11 @@ public: kaynClone->SetSheath(SHEATH_STATE_MELEE); kaynClone->SetNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); - StartCloneMovement(conversation->GetActorUnit(CONVO_ACTOR_IDX_KORVAS)->GetGUID(), PATH_KORVAS_INVASION_BEGINS, ANIM_DH_RUN, conversation); - StartCloneMovement(_jayceGUID, PATH_JAYCE_INVASION_BEGINS, 0, conversation); - StartCloneMovement(_allariGUID, PATH_ALLARI_INVASION_BEGINS, ANIM_DH_RUN_ALLARI, conversation); - StartCloneMovement(_cyanaGUID, PATH_CYANA_INVASION_BEGINS, 0, conversation); - StartCloneMovement(_sevisGUID, PATH_SEVIS_INVASION_BEGINS, ANIM_DH_RUN, conversation); + StartCloneMovement(conversation->GetActorUnit(CONVO_ACTOR_IDX_KORVAS)->GetGUID(), PATH_KORVAS_INVASION_BEGINS, ANIM_DH_RUN); + StartCloneMovement(_jayceGUID, PATH_JAYCE_INVASION_BEGINS, 0); + StartCloneMovement(_allariGUID, PATH_ALLARI_INVASION_BEGINS, ANIM_DH_RUN_ALLARI); + StartCloneMovement(_cyanaGUID, PATH_CYANA_INVASION_BEGINS, 0); + StartCloneMovement(_sevisGUID, PATH_SEVIS_INVASION_BEGINS, ANIM_DH_RUN); break; } default: @@ -2002,7 +2003,7 @@ void AddSC_zone_mardum() new event_sevis_sacrifice_self(); // Conversation - new conversation_the_invasion_begins(); + RegisterConversationAI(conversation_the_invasion_begins); // Scene new scene_demonhunter_intro(); diff --git a/src/server/scripts/DragonIsles/AberrusTheShadowedCrucible/aberrus_the_shadowed_crucible.cpp b/src/server/scripts/DragonIsles/AberrusTheShadowedCrucible/aberrus_the_shadowed_crucible.cpp index 7527b516936..746b24a77ca 100644 --- a/src/server/scripts/DragonIsles/AberrusTheShadowedCrucible/aberrus_the_shadowed_crucible.cpp +++ b/src/server/scripts/DragonIsles/AberrusTheShadowedCrucible/aberrus_the_shadowed_crucible.cpp @@ -18,6 +18,7 @@ #include "AreaTrigger.h" #include "AreaTriggerAI.h" #include "Conversation.h" +#include "ConversationAI.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ScriptMgr.h" @@ -107,12 +108,12 @@ struct at_aberrus_sarkareth_conversation_intro : AreaTriggerAI }; // 20800 - Conversation -class conversation_aberrus_sabellian_intro : public ConversationScript +class conversation_aberrus_sabellian_intro : public ConversationAI { public: - conversation_aberrus_sabellian_intro() : ConversationScript("conversation_aberrus_sabellian_intro") { } + conversation_aberrus_sabellian_intro(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { if (Milliseconds const* sabellianMoveStartTime = conversation->GetLineStartTime(DEFAULT_LOCALE, CONVO_SABELLIAN_INTRO_LINE_01)) _events.ScheduleEvent(EVENT_SABELLIAN_MOVE, *sabellianMoveStartTime); @@ -121,7 +122,7 @@ public: _events.ScheduleEvent(EVENT_SABELLIAN_MOVE_HOME_POS, *sabellianHomeMoveStartTime + Seconds(2)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -157,17 +158,17 @@ private: }; // 20985 - Conversation -class conversation_aberrus_kazzara_intro : public ConversationScript +class conversation_aberrus_kazzara_intro : public ConversationAI { public: - conversation_aberrus_kazzara_intro() : ConversationScript("conversation_aberrus_kazzara_intro") { } + conversation_aberrus_kazzara_intro(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { _events.ScheduleEvent(EVENT_KAZZARA_INTRO, conversation->GetLineEndTime(DEFAULT_LOCALE, CONVO_SARKARETH_LAST_LINE)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -213,6 +214,6 @@ void AddSC_aberrus_the_shadowed_crucible() RegisterAreaTriggerAI(at_aberrus_sabellian_conversation_intro); RegisterAreaTriggerAI(at_aberrus_sarkareth_conversation_intro); - new conversation_aberrus_sabellian_intro(); - new conversation_aberrus_kazzara_intro(); + RegisterConversationAI(conversation_aberrus_sabellian_intro); + RegisterConversationAI(conversation_aberrus_kazzara_intro); } diff --git a/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp b/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp index caa7fb2dd97..22a8b5dedf2 100644 --- a/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp +++ b/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp @@ -19,6 +19,7 @@ #include "AreaTriggerAI.h" #include "Containers.h" #include "Conversation.h" +#include "ConversationAI.h" #include "CreatureAIImpl.h" #include "CreatureGroups.h" #include "MotionMaster.h" @@ -469,12 +470,12 @@ struct at_human_heritage_lions_pride_inn_basement_enter : AreaTriggerAI }; // 20342 - Conversation -class conversation_an_unlikely_informant : public ConversationScript +class conversation_an_unlikely_informant : public ConversationAI { public: - conversation_an_unlikely_informant() : ConversationScript("conversation_an_unlikely_informant") { } + conversation_an_unlikely_informant(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* mathiasObject = GetClosestCreatureWithOptions(creator, 15.0f, { .CreatureId = NPC_MATHIAS_SHAW, .IgnorePhases = true }); Creature* vanessaObject = GetClosestCreatureWithOptions(creator, 15.0f, { .CreatureId = NPC_VANESSA_VANCLEEF, .IgnorePhases = true }); @@ -495,7 +496,7 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale(); @@ -511,7 +512,7 @@ public: _events.ScheduleEvent(EVENT_MATHIAS_CLONE_DESPAWN, conversation->GetLastLineEndTime(privateOwnerLocale)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -582,12 +583,12 @@ private: }; // 20387 - Conversation -class conversation_the_new_classington_estate : public ConversationScript +class conversation_the_new_classington_estate : public ConversationAI { public: - conversation_the_new_classington_estate() : ConversationScript("conversation_the_new_classington_estate") { } + conversation_the_new_classington_estate(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* mathiasObject = GetClosestCreatureWithOptions(creator, 15.0f, { .CreatureId = NPC_MATHIAS_SHAW, .IgnorePhases = true }); Creature* vanessaObject = GetClosestCreatureWithOptions(creator, 15.0f, { .CreatureId = NPC_VANESSA_VANCLEEF, .IgnorePhases = true }); @@ -608,7 +609,7 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale(); @@ -622,7 +623,7 @@ public: _events.ScheduleEvent(EVENT_MATHIAS_CLONE_DESPAWN, conversation->GetLastLineEndTime(privateOwnerLocale)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -720,8 +721,8 @@ void AddSC_elwynn_forest() RegisterSpellScript(spell_stealth_vanessa_human_heritage); // Conversation - new conversation_an_unlikely_informant(); - new conversation_the_new_classington_estate(); + RegisterConversationAI(conversation_an_unlikely_informant); + RegisterConversationAI(conversation_the_new_classington_estate); // AreaTrigger RegisterAreaTriggerAI(at_human_heritage_lions_pride_inn_basement_enter); diff --git a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp index e071fdf1f19..902fb016da4 100644 --- a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp @@ -19,6 +19,7 @@ #include "AreaTriggerAI.h" #include "Containers.h" #include "Conversation.h" +#include "ConversationAI.h" #include "CreatureAIImpl.h" #include "MotionMaster.h" #include "ObjectAccessor.h" @@ -104,10 +105,10 @@ struct at_stormwind_keep_tides_of_war : AreaTriggerAI Position const VisionOfSailorsMemoryPosition = { -8384.131f, 324.383f, 148.443f, 1.559973f }; // 4857 - Conversation -class conversation_start_council_tides_of_war : public ConversationScript +class conversation_start_council_tides_of_war : public ConversationAI { public: - conversation_start_council_tides_of_war() : ConversationScript("conversation_start_council_tides_of_war") { } + conversation_start_council_tides_of_war(Conversation* conversation) : ConversationAI(conversation) { } enum Events { @@ -123,7 +124,7 @@ public: CONVO_LINE_JAINA_CREDIT = 19486, }; - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* jainaObject = GetClosestCreatureWithOptions(creator, 30.0f, { .CreatureId = NPC_JAINA_TIDES_OF_WAR, .IgnorePhases = true }); if (!jainaObject) @@ -137,7 +138,7 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale(); @@ -147,7 +148,7 @@ public: _events.ScheduleEvent(EVENT_KILL_CREDIT, conversation->GetLineEndTime(privateOwnerLocale, CONVO_LINE_JAINA_CREDIT)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -422,10 +423,10 @@ private: }; // 22025 - Conversation -class conversation_quest_ancient_curses_accept : public ConversationScript +class conversation_quest_ancient_curses_accept : public ConversationAI { public: - conversation_quest_ancient_curses_accept() : ConversationScript("conversation_quest_ancient_curses_accept") { } + conversation_quest_ancient_curses_accept(Conversation* conversation) : ConversationAI(conversation) { } enum AncientCursesConversationEvents { @@ -439,7 +440,7 @@ public: CONVO_LINE_LYSANDER_START_PATH = 60113, }; - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* arkonarinObject = GetClosestCreatureWithOptions(creator, 20.0f, { .CreatureId = NPC_ARKONARIN_STARSHADE, .IgnorePhases = true }); Creature* lysanderObject = GetClosestCreatureWithOptions(creator, 20.0f, { .CreatureId = NPC_LYSANDER_STARSHADE, .IgnorePhases = true }); @@ -461,7 +462,7 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale(); @@ -472,7 +473,7 @@ public: _events.ScheduleEvent(EVENT_LYSANDER_START_PATH, *lysanderPathStartTime); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -563,8 +564,8 @@ void AddSC_stormwind_city() RegisterCreatureAI(npc_lysande_starshade_ancient_curses); // Conversation - new conversation_start_council_tides_of_war(); - new conversation_quest_ancient_curses_accept(); + RegisterConversationAI(conversation_start_council_tides_of_war); + RegisterConversationAI(conversation_quest_ancient_curses_accept); // PlayerScript new player_conv_after_movie_tides_of_war(); diff --git a/src/server/scripts/KulTiras/WaycrestManor/waycrest_manor.cpp b/src/server/scripts/KulTiras/WaycrestManor/waycrest_manor.cpp index d8973eb29e7..21fb2e722fc 100644 --- a/src/server/scripts/KulTiras/WaycrestManor/waycrest_manor.cpp +++ b/src/server/scripts/KulTiras/WaycrestManor/waycrest_manor.cpp @@ -18,6 +18,7 @@ #include "AreaTrigger.h" #include "AreaTriggerAI.h" #include "Conversation.h" +#include "ConversationAI.h" #include "Creature.h" #include "InstanceScript.h" #include "Map.h" @@ -351,12 +352,12 @@ class spell_waycrest_manor_organ_missiles : public SpellScript // 267597 - Waycrest Manor - Waycrests Defeated (Alliance) // 7351 - Conversation // 7352 - Conversation -class conversation_waycrest_manor_waycrests_defeated : public ConversationScript +class conversation_waycrest_manor_waycrests_defeated : public ConversationAI { public: - conversation_waycrest_manor_waycrests_defeated() : ConversationScript("conversation_waycrest_manor_waycrests_defeated") { } + conversation_waycrest_manor_waycrests_defeated(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { if (Milliseconds const* gorakTulMoveStartTimeAlliance = conversation->GetLineStartTime(DEFAULT_LOCALE, CONVERSATION_LINE_LUCILLE_WAYCREST)) _events.ScheduleEvent(EVENT_GORAK_TUL_TRANSFORM, *gorakTulMoveStartTimeAlliance); @@ -364,7 +365,7 @@ public: _events.ScheduleEvent(EVENT_GORAK_TUL_TRANSFORM, *gorakTulMoveStartTimeHorde + 3s); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -442,5 +443,5 @@ void AddSC_waycrest_manor() // Lord and Lady Waycrest outro RegisterAreaTriggerAI(at_waycrest_manor_organ_missiles); RegisterSpellScript(spell_waycrest_manor_organ_missiles); - new conversation_waycrest_manor_waycrests_defeated(); + RegisterConversationAI(conversation_waycrest_manor_waycrests_defeated); } diff --git a/src/server/scripts/KulTiras/zone_boralus.cpp b/src/server/scripts/KulTiras/zone_boralus.cpp index 32dc6942110..854e8e0298f 100644 --- a/src/server/scripts/KulTiras/zone_boralus.cpp +++ b/src/server/scripts/KulTiras/zone_boralus.cpp @@ -19,6 +19,7 @@ #include "AreaTriggerAI.h" #include "Containers.h" #include "Conversation.h" +#include "ConversationAI.h" #include "CreatureAIImpl.h" #include "MotionMaster.h" #include "ObjectAccessor.h" @@ -138,12 +139,12 @@ struct npc_taelia_get_your_bearings : public ScriptedAI }; // 5360 - Conversation -class conversation_boralus_hub_tour_00 : public ConversationScript +class conversation_boralus_hub_tour_00 : public ConversationAI { public: - conversation_boralus_hub_tour_00() : ConversationScript("conversation_boralus_hub_tour_00") { } + conversation_boralus_hub_tour_00(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* kultiranGuard = creator->FindNearestCreatureWithOptions(20.0f, { .CreatureId = NPC_SUMMONED_KULTIRAN_GUARD, .IgnorePhases = true, .OwnerGuid = creator->GetGUID() }); if (!kultiranGuard) @@ -174,10 +175,10 @@ struct at_boralus_get_your_bearings : AreaTriggerAI }; // 5362 - Conversation - Get your Bearings (Ferry) -class conversation_boralus_hub_tour : public ConversationScript +class conversation_boralus_hub_tour : public ConversationAI { public: - conversation_boralus_hub_tour(char const* scriptName) : ConversationScript(scriptName) { } + conversation_boralus_hub_tour(Conversation* conversation) : ConversationAI(conversation) { } enum ConversationFerryData { @@ -187,7 +188,7 @@ public: virtual Position const& GetGuardMovePosition() = 0; virtual uint32 GetKillCreditId() = 0; - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* kultiranGuard = creator->FindNearestCreatureWithOptions(20.0f, { .CreatureId = NPC_SUMMONED_KULTIRAN_GUARD, .IgnorePhases = true, .OwnerGuid = creator->GetGUID() }); if (!kultiranGuard) @@ -200,14 +201,14 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale(); _events.ScheduleEvent(EVENT_TAELIA_CREDIT, conversation->GetLastLineEndTime(privateOwnerLocale)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -241,7 +242,7 @@ Position const TaeliaFerryPos = { 1039.5955f, -598.00653f, 1.458778f }; class conversation_boralus_hub_tour_ferry : public conversation_boralus_hub_tour { public: - conversation_boralus_hub_tour_ferry() : conversation_boralus_hub_tour("conversation_boralus_hub_tour_ferry") { } + conversation_boralus_hub_tour_ferry(Conversation* conversation) : conversation_boralus_hub_tour(conversation) { } Position const& GetGuardMovePosition() { @@ -260,7 +261,7 @@ Position const TaeliaBankPos = { 1118.7385f, -622.4115f, 17.76035f }; class conversation_boralus_hub_tour_counting_house : public conversation_boralus_hub_tour { public: - conversation_boralus_hub_tour_counting_house() : conversation_boralus_hub_tour("conversation_boralus_hub_tour_counting_house") { } + conversation_boralus_hub_tour_counting_house(Conversation* conversation) : conversation_boralus_hub_tour(conversation) { } Position const& GetGuardMovePosition() { @@ -279,7 +280,7 @@ Position const TaeliaInnPos = { 1177.39f, -587.682f, 31.557224f }; class conversation_boralus_hub_tour_harbor_inn : public conversation_boralus_hub_tour { public: - conversation_boralus_hub_tour_harbor_inn() : conversation_boralus_hub_tour("conversation_boralus_hub_tour_harbor_inn") { } + conversation_boralus_hub_tour_harbor_inn(Conversation* conversation) : conversation_boralus_hub_tour(conversation) { } Position const& GetGuardMovePosition() { @@ -298,7 +299,7 @@ Position const TaeliaFlightMasterPos = { 1149.82f, -471.071f, 30.503826f }; class conversation_boralus_hub_tour_flight_master : public conversation_boralus_hub_tour { public: - conversation_boralus_hub_tour_flight_master() : conversation_boralus_hub_tour("conversation_boralus_hub_tour_flight_master") { } + conversation_boralus_hub_tour_flight_master(Conversation* conversation) : conversation_boralus_hub_tour(conversation) {} Position const& GetGuardMovePosition() { @@ -312,12 +313,12 @@ public: }; // 9556 - Conversation The Old Knight (accept Quest) -class conversation_boralus_accept_old_knight : public ConversationScript +class conversation_boralus_accept_old_knight : public ConversationAI { public: - conversation_boralus_accept_old_knight() : ConversationScript("conversation_boralus_accept_old_knight") { } + conversation_boralus_accept_old_knight(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* kultiranGuard = creator->FindNearestCreatureWithOptions(20.0f, { .CreatureId = NPC_SUMMONED_KULTIRAN_GUARD, .IgnorePhases = true, .OwnerGuid = creator->GetGUID() }); if (!kultiranGuard) @@ -344,12 +345,12 @@ struct at_boralus_old_knight_enter_harbormasters_office : AreaTriggerAI }; // 7605 - Conversation The Old Knight (Enter the Harbormasters Office) -class conversation_boralus_enter_harbormaster_office : public ConversationScript +class conversation_boralus_enter_harbormaster_office : public ConversationAI { public: - conversation_boralus_enter_harbormaster_office() : ConversationScript("conversation_boralus_enter_harbormaster_office") { } + conversation_boralus_enter_harbormaster_office(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* kultiranGuard = creator->FindNearestCreatureWithOptions(20.0f, { .CreatureId = NPC_SUMMONED_KULTIRAN_GUARD, .IgnorePhases = true, .OwnerGuid = creator->GetGUID() }); if (!kultiranGuard) @@ -428,10 +429,10 @@ Position const GreyguardOneOfficePos = { 1044.979f, -468.523f, 8.386f, 6.03047f Position const GreyguardTwoOfficePos = { 1042.359f, -467.738f, 8.386f, 6.04665f }; // 8062 - Conversation -class conversation_boralus_cyrus_meets_genn : public ConversationScript +class conversation_boralus_cyrus_meets_genn : public ConversationAI { public: - conversation_boralus_cyrus_meets_genn() : ConversationScript("conversation_boralus_cyrus_meets_genn") { } + conversation_boralus_cyrus_meets_genn(Conversation* conversation) : ConversationAI(conversation) { } enum OldKnightsConversationData { @@ -440,7 +441,7 @@ public: EVENT_OLD_KNIGHTS_CLONE_DESPAWN = 1 }; - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* cyrusObject = GetClosestCreatureWithOptions(creator, 30.0f, { .CreatureId = NPC_CYRUS_CRESTFALL, .IgnorePhases = true }); Creature* gennObject = GetClosestCreatureWithOptions(creator, 30.0f, { .CreatureId = NPC_GENN_GREYMANE, .IgnorePhases = true }); @@ -470,14 +471,14 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale(); _events.ScheduleEvent(EVENT_OLD_KNIGHTS_CLONE_DESPAWN, conversation->GetLineEndTime(privateOwnerLocale, CONVO_LINE_CYRUS_AND_GENN_DESPAWN)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -532,10 +533,10 @@ Position const CyrusMoveToOfficeFirePos = { 1075.257f, -487.25696f, 9.812291f }; Position const CyrusStaticOfficePos = { 1071.428f, -486.312f, 9.783f, 3.4995f }; // 7653 - Conversation -class conversation_cyrus_crestfall_shaking_hands : public ConversationScript +class conversation_cyrus_crestfall_shaking_hands : public ConversationAI { public: - conversation_cyrus_crestfall_shaking_hands() : ConversationScript("conversation_cyrus_crestfall_shaking_hands") { } + conversation_cyrus_crestfall_shaking_hands(Conversation* conversation) : ConversationAI(conversation) { } enum ShakingHandsConversationData { @@ -553,7 +554,7 @@ public: POINT_CYRUS_MOVE_BACK_TO_GENN = 2 }; - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { Creature* cyrusObject = GetClosestCreatureWithOptions(creator, 10.0f, { .CreatureId = NPC_CYRUS_CRESTFALL, .IgnorePhases = true }); if (!cyrusObject) @@ -569,7 +570,7 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale(); @@ -579,7 +580,7 @@ public: _events.ScheduleEvent(EVENT_CYRUS_DESPAWN_CLONE_OFFICE, conversation->GetLineEndTime(privateOwnerLocale, CONVO_LINE_CYRUS_DESPAWN_CLONE_OFFICE)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -778,15 +779,15 @@ void AddSC_zone_boralus() RegisterCreatureAI(npc_7th_legion_magus_sanctum_of_the_sages); // Conversation - new conversation_boralus_hub_tour_00(); - new conversation_boralus_hub_tour_ferry(); - new conversation_boralus_hub_tour_counting_house(); - new conversation_boralus_hub_tour_harbor_inn(); - new conversation_boralus_hub_tour_flight_master(); - new conversation_boralus_accept_old_knight(); - new conversation_boralus_enter_harbormaster_office(); - new conversation_boralus_cyrus_meets_genn(); - new conversation_cyrus_crestfall_shaking_hands(); + RegisterConversationAI(conversation_boralus_hub_tour_00); + RegisterConversationAI(conversation_boralus_hub_tour_ferry); + RegisterConversationAI(conversation_boralus_hub_tour_counting_house); + RegisterConversationAI(conversation_boralus_hub_tour_harbor_inn); + RegisterConversationAI(conversation_boralus_hub_tour_flight_master); + RegisterConversationAI(conversation_boralus_accept_old_knight); + RegisterConversationAI(conversation_boralus_enter_harbormaster_office); + RegisterConversationAI(conversation_boralus_cyrus_meets_genn); + RegisterConversationAI(conversation_cyrus_crestfall_shaking_hands); // Scene new scene_boralus_client_scene_cyrus_and_genn(); diff --git a/src/server/scripts/Shadowlands/SanctumOfDomination/boss_sylvanas_windrunner.cpp b/src/server/scripts/Shadowlands/SanctumOfDomination/boss_sylvanas_windrunner.cpp index 4ed74a7b144..c54d4a7d8fa 100644 --- a/src/server/scripts/Shadowlands/SanctumOfDomination/boss_sylvanas_windrunner.cpp +++ b/src/server/scripts/Shadowlands/SanctumOfDomination/boss_sylvanas_windrunner.cpp @@ -18,6 +18,7 @@ #include "AreaTrigger.h" #include "AreaTriggerAI.h" #include "Conversation.h" +#include "ConversationAI.h" #include "CreatureAI.h" #include "CreatureAIImpl.h" #include "InstanceScript.h" @@ -262,12 +263,12 @@ struct at_sylvanas_windrunner_introduction : AreaTriggerAI }; // 17368 - Sylvanas Windrunner's Introduction (Conversation) -class conversation_sylvanas_windrunner_introduction : public ConversationScript +class conversation_sylvanas_windrunner_introduction : public ConversationAI { public: - conversation_sylvanas_windrunner_introduction() : ConversationScript("conversation_sylvanas_windrunner_introduction") { } + conversation_sylvanas_windrunner_introduction(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationCreate(Conversation* conversation, Unit* creator) override + void OnCreate(Unit* creator) override { InstanceScript* instance = creator->GetInstanceScript(); if (!instance) @@ -283,7 +284,7 @@ public: _events.ScheduleEvent(EVENT_INTRODUCTION, 5s + 500ms); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -485,5 +486,5 @@ void AddSC_boss_sylvanas_windrunner() RegisterAreaTriggerAI(at_sylvanas_windrunner_z_check); RegisterAreaTriggerAI(at_sylvanas_windrunner_introduction); - new conversation_sylvanas_windrunner_introduction(); + RegisterConversationAI(conversation_sylvanas_windrunner_introduction); } diff --git a/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp b/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp index 62f6ca3f78b..aba4b171ef4 100644 --- a/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp +++ b/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp @@ -776,14 +776,14 @@ struct boss_anduin_wrynn : public BossAI if (!jaina) return; - Conversation* convo = Conversation::CreateConversation(CONVERSATION_INTRO, me, me->GetPosition(), ObjectGuid::Empty, nullptr, false); - if (!convo) + Conversation* conversation = Conversation::CreateConversation(CONVERSATION_INTRO, me, me->GetPosition(), ObjectGuid::Empty, nullptr, false); + if (!conversation) return; - convo->AddActor(NPC_UTHER_THE_LIGHTBRINGER_ANDUIN, 1, uther->GetGUID()); - convo->AddActor(NPC_SYLVANAS_WINDRUNNER_ANDUIN, 2, sylvanas->GetGUID()); - convo->AddActor(NPC_LADY_JAINA_PROUDMOORE_ANDUIN, 3, jaina->GetGUID()); - convo->Start(); + conversation->AddActor(NPC_UTHER_THE_LIGHTBRINGER_ANDUIN, 1, uther->GetGUID()); + conversation->AddActor(NPC_SYLVANAS_WINDRUNNER_ANDUIN, 2, sylvanas->GetGUID()); + conversation->AddActor(NPC_LADY_JAINA_PROUDMOORE_ANDUIN, 3, jaina->GetGUID()); + conversation->Start(); }); scheduler.Schedule(35s, [this](TaskContext /*task*/) @@ -827,15 +827,15 @@ struct boss_anduin_wrynn : public BossAI firim->GetMotionMaster()->MovePath(PATH_OUTRODUCTION_FIRIM, false); - Conversation* convo = Conversation::CreateConversation(CONVERSATION_ANDUIN_OUTRODUCTION, me, me->GetPosition(), ObjectGuid::Empty, nullptr, false); - if (!convo) + Conversation* conversation = Conversation::CreateConversation(CONVERSATION_ANDUIN_OUTRODUCTION, me, me->GetPosition(), ObjectGuid::Empty, nullptr, false); + if (!conversation) break; - convo->AddActor(NPC_LADY_JAINA_PROUDMOORE_ANDUIN, 1, jaina->GetGUID()); - convo->AddActor(NPC_SYLVANAS_WINDRUNNER_ANDUIN, 2, sylvanas->GetGUID()); - convo->AddActor(NPC_UTHER_THE_LIGHTBRINGER_ANDUIN, 3, uther->GetGUID()); - convo->AddActor(NPC_FIRIM_ANDUIN, 4, firim->GetGUID()); - convo->Start(); + conversation->AddActor(NPC_LADY_JAINA_PROUDMOORE_ANDUIN, 1, jaina->GetGUID()); + conversation->AddActor(NPC_SYLVANAS_WINDRUNNER_ANDUIN, 2, sylvanas->GetGUID()); + conversation->AddActor(NPC_UTHER_THE_LIGHTBRINGER_ANDUIN, 3, uther->GetGUID()); + conversation->AddActor(NPC_FIRIM_ANDUIN, 4, firim->GetGUID()); + conversation->Start(); break; } case ACTION_ARTHAS_INTERMISSION_UTHER: @@ -843,10 +843,10 @@ struct boss_anduin_wrynn : public BossAI instance->DoUpdateWorldState(WORLD_STATE_ANDUIN_INTERMISSION, 1); if (Creature* uther = instance->GetCreature(DATA_UTHER_THE_LIGHTBRINGER_ANDUIN)) { - if (Conversation* convo = Conversation::CreateConversation(CONVERSATION_ARTHAS_UTHER, me, me->GetPosition(), ObjectGuid::Empty, nullptr, false)) + if (Conversation* conversation = Conversation::CreateConversation(CONVERSATION_ARTHAS_UTHER, me, me->GetPosition(), ObjectGuid::Empty, nullptr, false)) { - convo->AddActor(NPC_UTHER_THE_LIGHTBRINGER_ANDUIN, 1, uther->GetGUID()); - convo->Start(); + conversation->AddActor(NPC_UTHER_THE_LIGHTBRINGER_ANDUIN, 1, uther->GetGUID()); + conversation->Start(); } } break; @@ -856,10 +856,10 @@ struct boss_anduin_wrynn : public BossAI instance->DoUpdateWorldState(WORLD_STATE_ANDUIN_INTERMISSION, 2); if (Creature* sylvanas = instance->GetCreature(DATA_SYLVANAS_WINDRUNNER_ANDUIN)) { - if (Conversation* convo = Conversation::CreateConversation(CONVERSATION_ARTHAS_SYLVANAS, me, me->GetPosition(), ObjectGuid::Empty, nullptr, false)) + if (Conversation* conversation = Conversation::CreateConversation(CONVERSATION_ARTHAS_SYLVANAS, me, me->GetPosition(), ObjectGuid::Empty, nullptr, false)) { - convo->AddActor(NPC_SYLVANAS_WINDRUNNER_ANDUIN, 1, sylvanas->GetGUID()); - convo->Start(); + conversation->AddActor(NPC_SYLVANAS_WINDRUNNER_ANDUIN, 1, sylvanas->GetGUID()); + conversation->Start(); } } break; diff --git a/src/server/scripts/World/conversation_scripts.cpp b/src/server/scripts/World/conversation_scripts.cpp index 507da020e79..f1a442c40b7 100644 --- a/src/server/scripts/World/conversation_scripts.cpp +++ b/src/server/scripts/World/conversation_scripts.cpp @@ -17,9 +17,10 @@ #include "ScriptMgr.h" #include "Conversation.h" +#include "ConversationAI.h" #include "Player.h" -class conversation_allied_race_dk_defender_of_azeroth : public ConversationScript +class conversation_allied_race_dk_defender_of_azeroth : public ConversationAI { public: enum DefenderOfAzerothIds : uint32 @@ -30,15 +31,15 @@ public: CONVERSATION_LINE_PLAYER = 32926 }; - conversation_allied_race_dk_defender_of_azeroth() : ConversationScript("conversation_allied_race_dk_defender_of_azeroth") { } + conversation_allied_race_dk_defender_of_azeroth(Conversation* conversation) : ConversationAI(conversation) { } - void OnConversationCreate(Conversation* /*conversation*/, Unit* creator) override + void OnCreate(Unit* creator) override { if (Player* player = creator->ToPlayer()) player->KilledMonsterCredit(NPC_TALK_TO_YOUR_COMMANDER_CREDIT); } - void OnConversationLineStarted(Conversation* /*conversation*/, uint32 lineId, Player* sender) override + void OnLineStarted(uint32 lineId, Player* sender) override { if (lineId != CONVERSATION_LINE_PLAYER) return; @@ -49,5 +50,5 @@ public: void AddSC_conversation_scripts() { - new conversation_allied_race_dk_defender_of_azeroth(); + RegisterConversationAI(conversation_allied_race_dk_defender_of_azeroth); } diff --git a/src/server/scripts/Zandalar/KingsRest/kings_rest.cpp b/src/server/scripts/Zandalar/KingsRest/kings_rest.cpp index 00d545b3d3f..5ffa6554ebc 100644 --- a/src/server/scripts/Zandalar/KingsRest/kings_rest.cpp +++ b/src/server/scripts/Zandalar/KingsRest/kings_rest.cpp @@ -18,6 +18,7 @@ #include "AreaTrigger.h" #include "AreaTriggerAI.h" #include "Conversation.h" +#include "ConversationAI.h" #include "GameObject.h" #include "GameObjectAI.h" #include "InstanceScript.h" @@ -85,10 +86,10 @@ struct at_kings_rest_trigger_intro_event_with_zul : AreaTriggerAI }; // 7690 - Shadow of Zul - KingsRest Intro -class conversation_kings_rest_intro : public ConversationScript +class conversation_kings_rest_intro : public ConversationAI { public: - conversation_kings_rest_intro() : ConversationScript("conversation_kings_rest_intro") { } + conversation_kings_rest_intro(Conversation* conversation) : ConversationAI(conversation) { } enum KingsRestIntroConversationData { @@ -103,7 +104,7 @@ public: EVENT_ZUL_INTRO_DESPAWN, }; - void OnConversationCreate(Conversation* conversation, Unit* /*creator*/) override + void OnCreate(Unit* /*creator*/) override { TempSummon* shadowOfZul = conversation->SummonCreature(NPC_SHADOW_OF_ZUL, ShadowOfZulIntroSpawnPosition, TEMPSUMMON_MANUAL_DESPAWN); if (!shadowOfZul) @@ -113,12 +114,12 @@ public: conversation->Start(); } - void OnConversationStart(Conversation* conversation) override + void OnStart() override { _events.ScheduleEvent(EVENT_ZUL_OPEN_INTRO_DOOR, conversation->GetLineEndTime(DEFAULT_LOCALE, CONVO_LINE_INTRO_DOOR)); } - void OnConversationUpdate(Conversation* conversation, uint32 diff) override + void OnUpdate(uint32 diff) override { _events.Update(diff); @@ -595,7 +596,7 @@ void AddSC_kings_rest() RegisterAreaTriggerAI(at_kings_rest_gust_slash); // Conversation - new conversation_kings_rest_intro(); + RegisterConversationAI(conversation_kings_rest_intro); // Spells RegisterSpellScript(spell_kings_rest_suppression_slam); |