Core/SAI: Add distance option for SMART_ACTION_SOUND & SMART_ACTION_RANDOM_SOUND

This commit is contained in:
Aokromes
2017-10-26 12:33:57 +02:00
parent 42c488399e
commit 0a71d36af5
2 changed files with 15 additions and 3 deletions

View File

@@ -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");
}

View File

@@ -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