From 0a71d36af5dc5d1d9df0d27f8559bc4976b3ddad Mon Sep 17 00:00:00 2001 From: Aokromes Date: Thu, 26 Oct 2017 12:33:57 +0200 Subject: [PATCH] Core/SAI: Add distance option for SMART_ACTION_SOUND & SMART_ACTION_RANDOM_SOUND --- src/server/game/AI/SmartScripts/SmartScript.cpp | 14 ++++++++++++-- src/server/game/AI/SmartScripts/SmartScriptMgr.h | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index b3d11d77481..acac491a010 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -208,7 +208,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (IsUnit(*itr)) { - (*itr)->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? (*itr)->ToPlayer() : nullptr); + if (e.action.sound.distance == 1) + (*itr)->PlayDistanceSound(e.action.sound.sound, e.action.sound.onlySelf ? (*itr)->ToPlayer() : nullptr); + else + (*itr)->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? (*itr)->ToPlayer() : nullptr); + TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u", (*itr)->GetName().c_str(), (*itr)->GetGUID().GetCounter(), e.action.sound.sound, e.action.sound.onlySelf); } @@ -2474,7 +2478,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsUnit(obj)) { uint32 sound = Trinity::Containers::SelectRandomContainerElement(sounds); - obj->PlayDirectSound(sound, onlySelf ? obj->ToPlayer() : nullptr); + + if (e.action.randomSound.distance == 1) + obj->PlayDistanceSound(sound, onlySelf ? obj->ToPlayer() : nullptr); + else + obj->PlayDirectSound(sound, onlySelf ? obj->ToPlayer() : nullptr); + + TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: %s (%s), sound: %u, onlyself: %s", obj->GetName().c_str(), obj->GetGUID().ToString().c_str(), sound, onlySelf ? "true" : "false"); } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 9f89067c089..590133fcc45 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -622,6 +622,7 @@ struct SmartAction { uint32 sound; uint32 onlySelf; + uint32 distance; } sound; struct @@ -1109,8 +1110,9 @@ struct SmartAction struct { - std::array sounds; + std::array sounds; uint32 onlySelf; + uint32 distance; } randomSound; struct