mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
feat(Core/SmartScripts): Add distance option for SMART_ACTION_SOUND & SMART_ACTION_RANDOM_SOUND (#10255)
This commit is contained in:
committed by
GitHub
parent
5ee89ebfba
commit
915b6a2738
@@ -234,13 +234,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (targets)
|
||||
{
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
for (auto& target : *targets)
|
||||
{
|
||||
if (IsUnit(*itr))
|
||||
if (IsUnit(target))
|
||||
{
|
||||
(*itr)->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? (*itr)->ToPlayer() : nullptr);
|
||||
if (e.action.sound.distance == 1)
|
||||
target->PlayDistanceSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
|
||||
else
|
||||
target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
|
||||
LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: {} ({}), sound: {}, onlyself: {}",
|
||||
(*itr)->GetName(), (*itr)->GetGUID().ToString(), e.action.sound.sound, e.action.sound.onlySelf);
|
||||
target->GetName(), target->GetGUID().ToString(), e.action.sound.sound, e.action.sound.onlySelf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,14 +279,17 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
}
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
for (auto& target : *targets)
|
||||
{
|
||||
if (IsUnit(*itr))
|
||||
if (IsUnit(target))
|
||||
{
|
||||
uint32 sound = temp[urand(0, count - 1)];
|
||||
(*itr)->PlayDirectSound(sound, e.action.randomSound.onlySelf ? (*itr)->ToPlayer() : nullptr);
|
||||
if (e.action.randomSound.distance == 1)
|
||||
target->PlayDistanceSound(sound, e.action.randomSound.onlySelf ? target->ToPlayer() : nullptr);
|
||||
else
|
||||
target->PlayDirectSound(sound, e.action.randomSound.onlySelf ? target->ToPlayer() : nullptr);
|
||||
LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: {} ({}), sound: {}, onlyself: {}",
|
||||
(*itr)->GetName(), (*itr)->GetGUID().ToString(), sound, e.action.randomSound.onlySelf);
|
||||
target->GetName(), target->GetGUID().ToString(), sound, e.action.randomSound.onlySelf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -685,6 +685,7 @@ struct SmartAction
|
||||
{
|
||||
uint32 sound;
|
||||
SAIBool onlySelf;
|
||||
uint32 distance;
|
||||
} sound;
|
||||
|
||||
struct
|
||||
@@ -694,6 +695,7 @@ struct SmartAction
|
||||
uint32 sound3;
|
||||
uint32 sound4;
|
||||
SAIBool onlySelf;
|
||||
uint32 distance;
|
||||
} randomSound;
|
||||
|
||||
struct
|
||||
|
||||
Reference in New Issue
Block a user