From 73f479034605ef4f1270bbfd03864c8a1e196155 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 19 Jan 2021 13:32:21 -0500 Subject: [PATCH] Core/SAI: Add distance option for SMART_ACTION_SOUND & SMART_ACTION_RANDOM_SOUND Port From (https://github.com/TrinityCore/TrinityCore/commit/097335f2c4db5ce8ff773ec73b179a1f26b504fe) --- Source/Game/AI/SmartScripts/SmartAIManager.cs | 7 ++----- Source/Game/AI/SmartScripts/SmartScript.cs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 97374b588..4b5bc8aa8 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -941,8 +941,6 @@ namespace Game.AI return false; if (e.Action.randomSound.sound4 != 0 && !IsSoundValid(e, e.Action.randomSound.sound4)) return false; - if (e.Action.randomSound.sound5 != 0 && !IsSoundValid(e, e.Action.randomSound.sound5)) - return false; break; case SmartActions.Cast: { @@ -2416,7 +2414,7 @@ namespace Game.AI { public uint soundId; public uint onlySelf; - public uint distance; // NYI: awaiting cherry-pick + public uint distance; public uint keyBroadcastTextId; } public struct Emote @@ -2700,7 +2698,6 @@ namespace Game.AI { public uint entry; } - public struct Equip { public uint entry; @@ -2843,8 +2840,8 @@ namespace Game.AI public uint sound2; public uint sound3; public uint sound4; - public uint sound5; public uint onlySelf; + public uint distance; } public struct CorpseDelay { diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 1955b1161..415c5b7d4 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -178,7 +178,11 @@ namespace Game.AI { if (IsUnit(target)) { - target.PlayDirectSound(e.Action.sound.soundId, e.Action.sound.onlySelf != 0 ? target.ToPlayer() : null, e.Action.sound.keyBroadcastTextId); + if (e.Action.sound.distance == 1) + target.PlayDistanceSound(e.Action.sound.soundId, e.Action.sound.onlySelf != 0 ? target.ToPlayer() : null); + else + target.PlayDirectSound(e.Action.sound.soundId, e.Action.sound.onlySelf != 0 ? target.ToPlayer() : null, e.Action.sound.keyBroadcastTextId); + Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SOUND: target: {0} (GuidLow: {1}), sound: {2}, onlyself: {3}", target.GetName(), target.GetGUID().ToString(), e.Action.sound.soundId, e.Action.sound.onlySelf); } @@ -2038,7 +2042,11 @@ namespace Game.AI if (IsUnit(target)) { uint sound = sounds.SelectRandom(); - target.PlayDirectSound(sound, onlySelf ? target.ToPlayer() : null); + if (e.Action.randomSound.distance == 1) + target.PlayDistanceSound(sound, onlySelf ? target.ToPlayer() : null); + else + target.PlayDirectSound(sound, onlySelf ? target.ToPlayer() : null); + Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: {0} ({1}), sound: {2}, onlyself: {3}", target.GetName(), target.GetGUID().ToString(), sound, onlySelf); }