fix(Scripts/Spell): Volley should trigger pet attack in defensive mode (#7453)
- Closes #7340
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1629404470911887900');
|
||||||
|
|
||||||
|
DELETE FROM `spell_script_names` WHERE `spell_id`=-42243;
|
||||||
|
INSERT INTO `spell_script_names` VALUES
|
||||||
|
(-42243,'spell_hun_volley_trigger');
|
||||||
@@ -1295,6 +1295,67 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// -42243 - Volley (Trigger one)
|
||||||
|
class spell_hun_volley_trigger : public SpellScriptLoader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
spell_hun_volley_trigger() : SpellScriptLoader("spell_hun_volley_trigger") {}
|
||||||
|
|
||||||
|
class spell_hun_volley_trigger_SpellScript : public SpellScript
|
||||||
|
{
|
||||||
|
PrepareSpellScript(spell_hun_volley_trigger_SpellScript);
|
||||||
|
|
||||||
|
void SelectTarget(std::list<WorldObject*>& targets)
|
||||||
|
{
|
||||||
|
// It's here because Volley is an AOE spell so there is no specific target to be attacked
|
||||||
|
// Let's select one of our targets
|
||||||
|
if (!targets.empty())
|
||||||
|
{
|
||||||
|
_target = *(targets.begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleFinish()
|
||||||
|
{
|
||||||
|
if (!_target)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Unit* caster = GetCaster();
|
||||||
|
if (!caster || !caster->IsPlayer())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Unit::ControlSet::iterator itr = caster->m_Controlled.begin(); itr != caster->m_Controlled.end(); ++itr)
|
||||||
|
{
|
||||||
|
if (Unit* pet = *itr)
|
||||||
|
{
|
||||||
|
if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT)
|
||||||
|
{
|
||||||
|
pet->ToCreature()->AI()->OwnerAttacked(_target->ToUnit());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Register() override
|
||||||
|
{
|
||||||
|
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_hun_volley_trigger_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY);
|
||||||
|
AfterCast += SpellCastFn(spell_hun_volley_trigger_SpellScript::HandleFinish);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
WorldObject* _target = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
SpellScript* GetSpellScript() const override
|
||||||
|
{
|
||||||
|
return new spell_hun_volley_trigger_SpellScript();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void AddSC_hunter_spell_scripts()
|
void AddSC_hunter_spell_scripts()
|
||||||
{
|
{
|
||||||
// Ours
|
// Ours
|
||||||
@@ -1324,4 +1385,5 @@ void AddSC_hunter_spell_scripts()
|
|||||||
new spell_hun_sniper_training();
|
new spell_hun_sniper_training();
|
||||||
new spell_hun_tame_beast();
|
new spell_hun_tame_beast();
|
||||||
new spell_hun_viper_attack_speed();
|
new spell_hun_viper_attack_speed();
|
||||||
|
new spell_hun_volley_trigger();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user