mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
Core/SAI: Add distance option for SMART_ACTION_SOUND & SMART_ACTION_RANDOM_SOUND
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -622,6 +622,7 @@ struct SmartAction
|
||||
{
|
||||
uint32 sound;
|
||||
uint32 onlySelf;
|
||||
uint32 distance;
|
||||
} sound;
|
||||
|
||||
struct
|
||||
@@ -1109,8 +1110,9 @@ struct SmartAction
|
||||
|
||||
struct
|
||||
{
|
||||
std::array<uint32, SMART_ACTION_PARAM_COUNT - 1> sounds;
|
||||
std::array<uint32, SMART_ACTION_PARAM_COUNT - 2> sounds;
|
||||
uint32 onlySelf;
|
||||
uint32 distance;
|
||||
} randomSound;
|
||||
|
||||
struct
|
||||
|
||||
Reference in New Issue
Block a user