mirror of
https://gitcode.com/GitHub_Trending/az/azerothcore-wotlk.git
synced 2026-10-10 07:06:38 +08:00
fix(Scripts/Items): play the Toy Train Set sound (#27750)
Co-authored-by: treeston <[email protected]>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "AreaDefines.h"
|
||||
#include "Battleground.h"
|
||||
#include "DBCStores.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Pet.h"
|
||||
#include "Player.h"
|
||||
@@ -561,15 +562,31 @@ class spell_item_toy_train_set : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_item_toy_train_set)
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
targets.remove_if([](WorldObject const* target) { return !target->IsPlayer(); });
|
||||
}
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex effIndex)
|
||||
{
|
||||
PreventHitDefaultEffect(effIndex);
|
||||
if (Unit* target = GetHitUnit())
|
||||
target->HandleEmoteCommand(EMOTE_ONESHOT_TRAIN);
|
||||
Player* target = GetHitPlayer();
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
target->HandleEmoteCommand(EMOTE_ONESHOT_TRAIN);
|
||||
|
||||
// EmotesTextSound.dbc holds the per race/gender "choo choo" voice line. SMSG_EMOTE only carries
|
||||
// the animation, and EMOTE_ONESHOT_TRAIN is not enough for the client to pick the sound itself.
|
||||
uint8 const race = target->getRace();
|
||||
uint8 const gender = target->getGender();
|
||||
if (EmotesTextSoundEntry const* soundEntry = FindTextSoundEmoteFor(TEXT_EMOTE_TRAIN, race, gender))
|
||||
target->PlayDistanceSound(soundEntry->SoundId);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_item_toy_train_set::FilterTargets, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ALLY);
|
||||
OnEffectHitTarget += SpellEffectFn(spell_item_toy_train_set::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user