From 1f81c961f24337abdc8de25bd23d9834d0c7392b Mon Sep 17 00:00:00 2001 From: ModoX Date: Sat, 28 Dec 2024 23:25:10 +0100 Subject: Core/AI: Implemented conversation ai (#30538) (cherry picked from commit 309ba22a15e5e0b4321b99f7157ccb18e0adc8dd) # Conflicts: # src/server/scripts/BrokenIsles/zone_mardum.cpp # src/server/scripts/DragonIsles/AberrusTheShadowedCrucible/aberrus_the_shadowed_crucible.cpp # src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp # src/server/scripts/KulTiras/WaycrestManor/waycrest_manor.cpp # src/server/scripts/KulTiras/zone_boralus.cpp # src/server/scripts/Shadowlands/SanctumOfDomination/boss_sylvanas_windrunner.cpp # src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp # src/server/scripts/Zandalar/KingsRest/kings_rest.cpp --- src/server/game/Scripting/ScriptMgr.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/server/game/Scripting/ScriptMgr.h') 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) +template +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) + template class GenericBattlegroundMapScript : public BattlegroundMapScript { -- cgit v1.2.3