From 1cd8516e3830391b5c3f6c93796b03bc60ecbf4e Mon Sep 17 00:00:00 2001 From: sogladev Date: Tue, 5 May 2026 09:46:47 +0200 Subject: [PATCH] fix(Core/SmartAI): Mist escort and follow completion granting Credit (#25653) --- .../rev_1777475353267081450.sql | 13 +++++++ src/server/game/AI/SmartScripts/SmartAI.cpp | 34 +++++++++---------- 2 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1777475353267081450.sql diff --git a/data/sql/updates/pending_db_world/rev_1777475353267081450.sql b/data/sql/updates/pending_db_world/rev_1777475353267081450.sql new file mode 100644 index 000000000..9e01118e5 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1777475353267081450.sql @@ -0,0 +1,13 @@ +-- +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 3568); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(3568, 0, 1, 2, 19, 0, 100, 512, 938, 0, 0, 0, 0, 0, 29, 1, 1, 3519, 938, 1, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Quest \'Mist\' Taken - Start Follow Invoker'), +(3568, 0, 2, 3, 61, 0, 100, 512, 0, 0, 0, 0, 0, 0, 83, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Quest \'Mist\' Taken - Remove Npc Flags Questgiver'), +(3568, 0, 3, 4, 61, 0, 100, 512, 0, 0, 0, 0, 0, 0, 19, 512, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Quest \'Mist\' Taken - Remove Flags Immune To NPC\'s'), +(3568, 0, 4, 0, 61, 0, 100, 513, 0, 0, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Quest \'Mist\' Taken - Set Reactstate Defensive'), +(3568, 0, 5, 0, 6, 0, 100, 512, 0, 0, 0, 0, 0, 0, 70, 1000, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Just Died - Respawn Self'), +(3568, 0, 6, 7, 11, 0, 100, 512, 0, 0, 0, 0, 0, 0, 18, 512, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Respawn - Set Flags Immune To NPC\'s'), +(3568, 0, 7, 8, 61, 0, 100, 512, 0, 0, 0, 0, 0, 0, 81, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Respawn - Set Npc Flags Questgiver'), +(3568, 0, 8, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Respawn - Set Reactstate Passive'), +(3568, 0, 9, 10, 65, 0, 100, 512, 0, 0, 0, 0, 0, 0, 70, 2000, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Mist - On Follow Complete - Respawn Self'), +(3568, 0, 10, 0, 61, 0, 100, 512, 0, 0, 0, 0, 0, 0, 1, 0, 1000, 0, 0, 0, 0, 19, 3519, 10, 0, 0, 0, 0, 0, 0, 'Mist - On Follow Complete - Say Line 0'); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 8ce3641e8..f84e84c34 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -1241,6 +1241,23 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui void SmartAI::StopFollow(bool complete) { + if (complete) + { + Player* player = ObjectAccessor::GetPlayer(*me, mFollowGuid); + if (player && mFollowCredit > 0) + { + if (!mFollowCreditType) + player->RewardPlayerAndGroupAtEvent(mFollowCredit, me); + else + player->GroupEventHappens(mFollowCredit, me); + } + + SetDespawnTime(5000); + StartDespawn(); + + GetScript()->ProcessEventsFor(SMART_EVENT_FOLLOW_COMPLETED, player); + } + mFollowGuid.Clear(); mFollowDist = 0; mFollowAngle = 0; @@ -1252,23 +1269,6 @@ void SmartAI::StopFollow(bool complete) me->GetMotionMaster()->Clear(false); me->StopMoving(); me->GetMotionMaster()->MoveIdle(); - - if (!complete) - return; - - Player* player = ObjectAccessor::GetPlayer(*me, mFollowGuid); - if (player) - { - if (!mFollowCreditType) - player->RewardPlayerAndGroupAtEvent(mFollowCredit, me); - else - player->GroupEventHappens(mFollowCredit, me); - } - - SetDespawnTime(5000); - StartDespawn(); - - GetScript()->ProcessEventsFor(SMART_EVENT_FOLLOW_COMPLETED, player); } void SmartAI::SetScript9(SmartScriptHolder& e, uint32 entry, WorldObject* invoker)