fix(Core/Spells): Improve Feign Death scripts (#15496)

init

Co-authored-by: offl <11556157+offl@users.noreply.github.com>
This commit is contained in:
Gultask
2023-03-20 02:49:01 -03:00
committed by GitHub
parent 0c2d2e0494
commit ce40ed6278
2 changed files with 155 additions and 11 deletions

View File

@@ -1785,19 +1785,29 @@ class spell_gen_elune_candle : public SpellScript
}
};
/* 29266, 57685, 58951, 70592, 70628, 74490 - Permanent Feign Death
31261 - Permanent Feign Death (Root)
35356, 35357 - Spawn Feign Death */
class spell_gen_creature_permanent_feign_death : public AuraScript
/*
There are only 3 possible flags Feign Death auras can apply: UNIT_DYNFLAG_DEAD, UNIT_FLAG2_FEIGN_DEATH
and UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT. Some auras can apply only 2 flags
spell_gen_feign_death_all_flags applies all 3 flags
spell_gen_feign_death_no_dyn_flag applies no UNIT_DYNFLAG_DEAD (does not make the creature appear dead)
spell_gen_feign_death_no_prevent_emotes applies no UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT
REACT_PASSIVE should be handled directly in scripts since not all creatures should be passive. Otherwise
creature will be not able to aggro or execute MoveInLineOfSight events. Removing may cause more issues
than already exists
*/
class spell_gen_feign_death_all_flags : public AuraScript
{
PrepareAuraScript(spell_gen_creature_permanent_feign_death);
PrepareAuraScript(spell_gen_feign_death_all_flags);
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->SetDynamicFlag(UNIT_DYNFLAG_DEAD);
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetImmuneToAll(true);
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->SetReactState(REACT_PASSIVE);
@@ -1808,16 +1818,83 @@ class spell_gen_creature_permanent_feign_death : public AuraScript
Unit* target = GetTarget();
target->RemoveDynamicFlag(UNIT_DYNFLAG_DEAD);
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetImmuneToAll(false);
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->SetReactState(REACT_AGGRESSIVE);
target->ToCreature()->InitializeReactState();
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_gen_creature_permanent_feign_death::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectApplyFn(spell_gen_creature_permanent_feign_death::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectApply += AuraEffectApplyFn(spell_gen_feign_death_all_flags::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectApplyFn(spell_gen_feign_death_all_flags::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
// 35357 - Spawn Feign Death
// 51329 - Feign Death
class spell_gen_feign_death_no_dyn_flag : public AuraScript
{
PrepareAuraScript(spell_gen_feign_death_no_dyn_flag);
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->SetReactState(REACT_PASSIVE);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->InitializeReactState();
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_gen_feign_death_no_dyn_flag::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectApplyFn(spell_gen_feign_death_no_dyn_flag::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
// 58951 - Permanent Feign Death
class spell_gen_feign_death_no_prevent_emotes : public AuraScript
{
PrepareAuraScript(spell_gen_feign_death_no_prevent_emotes);
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->SetReactState(REACT_PASSIVE);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->InitializeReactState();
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_gen_feign_death_no_prevent_emotes::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectApplyFn(spell_gen_feign_death_no_prevent_emotes::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
@@ -3689,6 +3766,29 @@ class spell_gen_paralytic_poison : public AuraScript
}
};
class spell_gen_prevent_emotes : public AuraScript
{
PrepareAuraScript(spell_gen_prevent_emotes);
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_gen_prevent_emotes::HandleEffectApply, EFFECT_FIRST_FOUND, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_gen_prevent_emotes::OnRemove, EFFECT_FIRST_FOUND, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
}
};
enum BladeWarding
{
SPELL_GEN_BLADE_WARDING_TRIGGERED = 64442
@@ -4753,7 +4853,9 @@ void AddSC_generic_spell_scripts()
RegisterSpellScript(spell_gen_parachute);
RegisterSpellScript(spell_gen_pet_summoned);
RegisterSpellScript(spell_gen_remove_flight_auras);
RegisterSpellScript(spell_gen_creature_permanent_feign_death);
RegisterSpellScript(spell_gen_feign_death_all_flags);
RegisterSpellScript(spell_gen_feign_death_no_dyn_flag);
RegisterSpellScript(spell_gen_feign_death_no_prevent_emotes);
RegisterSpellScript(spell_pvp_trinket_wotf_shared_cd);
RegisterSpellScript(spell_gen_animal_blood);
RegisterSpellScript(spell_gen_divine_storm_cd_reset);
@@ -4795,6 +4897,7 @@ void AddSC_generic_spell_scripts()
RegisterSpellScript(spell_gen_despawn_self);
RegisterSpellScript(spell_gen_bandage);
RegisterSpellScript(spell_gen_paralytic_poison);
RegisterSpellScript(spell_gen_prevent_emotes);
RegisterSpellScript(spell_gen_blade_warding);
RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_hexlord_lifebloom", SPELL_HEXLORD_MALACRASS_LIFEBLOOM_FINAL_HEAL);
RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_tur_ragepaw_lifebloom", SPELL_TUR_RAGEPAW_LIFEBLOOM_FINAL_HEAL);