Core/Auras: periodics refactor part 3: move more switch hacks to scripts

- Incidentally fixed some spells which were supposed to be removed by proc instead of healing to full

(cherry picked from commit 16e20711d2)
This commit is contained in:
ariel-
2017-12-14 13:39:05 -03:00
committed by funjoker
parent fd786c03a3
commit 97e869e8b3
5 changed files with 100 additions and 92 deletions

View File

@@ -0,0 +1,20 @@
DELETE FROM `spell_proc` WHERE `SpellId` IN (35321, 38363, 39215);
INSERT INTO `spell_proc` (`SpellId`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `SpellFamilyMask1`, `SpellFamilyMask2`, `ProcFlags`, `SpellTypeMask`, `SpellPhaseMask`, `HitMask`, `AttributesMask`, `ProcsPerMinute`, `Chance`, `Cooldown`, `Charges`) VALUES
(35321, 0x0, 0, 0x00000000, 0x00000000, 0x00000000, 0x0, 0x2, 0x0, 0x0, 0x0, 0, 0, 0, 0),
(38363, 0x0, 0, 0x00000000, 0x00000000, 0x00000000, 0x0, 0x2, 0x0, 0x0, 0x0, 0, 0, 0, 0),
(39215, 0x0, 0, 0x00000000, 0x00000000, 0x00000000, 0x0, 0x2, 0x0, 0x0, 0x0, 0, 0, 0, 0);
DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_gen_remove_on_health_pct','spell_gen_remove_on_full_health','spell_gen_remove_on_full_health_pct','spell_trash_npc_glacial_strike','spell_iron_ring_guard_impale');
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(38772, 'spell_gen_remove_on_health_pct'),
(43937, 'spell_gen_remove_on_health_pct'),
(62331, 'spell_gen_remove_on_health_pct'),
(62418, 'spell_gen_remove_on_health_pct'),
(31956, 'spell_gen_remove_on_full_health'),
(38801, 'spell_gen_remove_on_full_health'),
(43093, 'spell_gen_remove_on_full_health'),
(58517, 'spell_gen_remove_on_full_health'),
(59262, 'spell_gen_remove_on_full_health'),
(70292, 'spell_gen_remove_on_full_health_pct'),
(71316, 'spell_gen_remove_on_full_health_pct');
-- (71317, 'spell_gen_remove_on_full_health_pct');

View File

@@ -5497,35 +5497,6 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
caster->SpellHitResult(target, GetSpellInfo(), false) != SPELL_MISS_NONE)
return;
// some auras remove at specific health level or more
if (GetAuraType() == SPELL_AURA_PERIODIC_DAMAGE)
{
switch (GetSpellInfo()->Id)
{
case 43093: case 31956: case 38801: // Grievous Wound
case 35321: case 38363: case 39215: // Gushing Wound
if (target->IsFullHealth())
{
target->RemoveAurasDueToSpell(GetSpellInfo()->Id);
return;
}
break;
case 38772: // Grievous Wound
{
if (SpellEffectInfo const* effect = GetSpellInfo()->GetEffect(EFFECT_1))
{
uint32 percent = effect->CalcValue(caster);
if (!target->HealthBelowPct(percent))
{
target->RemoveAurasDueToSpell(GetSpellInfo()->Id);
return;
}
}
break;
}
}
}
CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
// AOE spells are not affected by the new periodic system.

View File

@@ -232,36 +232,6 @@ class npc_geist_ambusher : public CreatureScript
}
};
class spell_trash_npc_glacial_strike : public SpellScriptLoader
{
public:
spell_trash_npc_glacial_strike() : SpellScriptLoader("spell_trash_npc_glacial_strike") { }
class spell_trash_npc_glacial_strike_AuraScript : public AuraScript
{
PrepareAuraScript(spell_trash_npc_glacial_strike_AuraScript);
void PeriodicTick(AuraEffect const* /*aurEff*/)
{
if (GetTarget()->IsFullHealth())
{
GetTarget()->RemoveAura(GetId(), ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL);
PreventDefaultAction();
}
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_trash_npc_glacial_strike_AuraScript::PeriodicTick, EFFECT_2, SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_trash_npc_glacial_strike_AuraScript();
}
};
class npc_pit_of_saron_icicle : public CreatureScript
{
public:
@@ -395,7 +365,6 @@ void AddSC_pit_of_saron()
new npc_iceborn_protodrake();
new npc_geist_ambusher();
new npc_pit_of_saron_icicle();
new spell_trash_npc_glacial_strike();
new spell_pos_ice_shards();
new at_pit_cavern_entrance();
new at_pit_cavern_end();

View File

@@ -2092,37 +2092,6 @@ class spell_thorim_activate_lightning_orb_periodic : public SpellScriptLoader
}
};
// 62331, 62418 - Impale
class spell_iron_ring_guard_impale : public SpellScriptLoader
{
public:
spell_iron_ring_guard_impale() : SpellScriptLoader("spell_iron_ring_guard_impale") { }
class spell_iron_ring_guard_impale_AuraScript : public AuraScript
{
PrepareAuraScript(spell_iron_ring_guard_impale_AuraScript);
void PeriodicTick(AuraEffect const* /*aurEff*/)
{
if (GetTarget()->HealthAbovePct(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()))
{
Remove(AURA_REMOVE_BY_ENEMY_SPELL);
PreventDefaultAction();
}
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_iron_ring_guard_impale_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_iron_ring_guard_impale_AuraScript();
}
};
class condition_thorim_arena_leap : public ConditionScript
{
public:
@@ -2161,6 +2130,5 @@ void AddSC_boss_thorim()
new spell_thorim_arena_leap();
new spell_thorim_runic_smash();
new spell_thorim_activate_lightning_orb_periodic();
new spell_iron_ring_guard_impale();
new condition_thorim_arena_leap();
}

View File

@@ -2264,6 +2264,83 @@ class spell_gen_remove_flight_auras : public SpellScript
}
};
// 38772 Grievous Wound
// 43937 Grievous Wound
// 62331 Impale
// 62418 Impale
class spell_gen_remove_on_health_pct : public AuraScript
{
PrepareAuraScript(spell_gen_remove_on_health_pct);
void PeriodicTick(AuraEffect const* /*aurEff*/)
{
// they apply damage so no need to check for ticks here
if (GetTarget()->HealthAbovePct(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()))
{
Remove(AURA_REMOVE_BY_ENEMY_SPELL);
PreventDefaultAction();
}
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_remove_on_health_pct::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
}
};
// 31956 Grievous Wound
// 38801 Grievous Wound
// 43093 Grievous Throw
// 58517 Grievous Wound
// 59262 Grievous Wound
class spell_gen_remove_on_full_health : public AuraScript
{
PrepareAuraScript(spell_gen_remove_on_full_health);
void PeriodicTick(AuraEffect const* aurEff)
{
// if it has only periodic effect, allow 1 tick
bool onlyEffect = (GetSpellInfo()->GetEffects().size() == 1);
if (onlyEffect && aurEff->GetTickNumber() <= 1)
return;
if (GetTarget()->IsFullHealth())
{
Remove(AURA_REMOVE_BY_ENEMY_SPELL);
PreventDefaultAction();
}
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_remove_on_full_health::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
}
};
// 70292 - Glacial Strike
// 71316 - Glacial Strike
class spell_gen_remove_on_full_health_pct : public AuraScript
{
PrepareAuraScript(spell_gen_remove_on_full_health_pct);
void PeriodicTick(AuraEffect const* /*aurEff*/)
{
// they apply damage so no need to check for ticks here
if (GetTarget()->IsFullHealth())
{
Remove(AURA_REMOVE_BY_ENEMY_SPELL);
PreventDefaultAction();
}
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_remove_on_full_health_pct::PeriodicTick, EFFECT_2, SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
}
};
enum Replenishment
{
SPELL_REPLENISHMENT = 57669,
@@ -3765,6 +3842,9 @@ void AddSC_generic_spell_scripts()
RegisterSpellScript(spell_gen_two_forms);
RegisterSpellScript(spell_gen_darkflight);
/* */
RegisterAuraScript(spell_gen_remove_on_health_pct);
RegisterAuraScript(spell_gen_remove_on_full_health);
RegisterAuraScript(spell_gen_remove_on_full_health_pct);
RegisterSpellScript(spell_gen_seaforium_blast);
RegisterSpellScript(spell_gen_spectator_cheer_trigger);
RegisterSpellScript(spell_gen_spirit_healer_res);