Core/Unit: Big cleanup in Unit::CalcAbsorbResist

Core/AuraScript:
	Fix compile time check for AuraScript functions
	Remove AuraApplication from hook functions parameter list, use GetTarget() and GetTargetApplication() instead
	Add OnEffectAbsorb hook
Scripts: move handlers of Spell Deflection, Savage Defense, Primal Tenacity, Nerves of Steel, Astral shift from core to scripts.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-12-27 20:14:54 +01:00
parent da8d794f4b
commit ef968f4b15
30 changed files with 791 additions and 438 deletions

View File

@@ -157,9 +157,49 @@ public:
}
};
// 49145 - Spell Deflection
class spell_dk_spell_deflection : public SpellScriptLoader
{
public:
spell_dk_spell_deflection() : SpellScriptLoader("spell_dk_spell_deflection") { }
class spell_dk_spell_deflection_AuraScript : public AuraScript
{
PrepareAuraScript(spell_dk_spell_deflection_AuraScript);
uint32 absorbPct;
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & canBeRecalculated)
{
absorbPct = amount;
// Set absorbtion amount to unlimited
amount = -1;
}
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
// You have a chance equal to your Parry chance
if ((dmgInfo.GetDamageType() == DIRECT_DAMAGE) && roll_chance_f(GetTarget()->GetUnitParryChance()))
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_spell_deflection_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_spell_deflection_AuraScript::Absorb, EFFECT_0);
}
};
AuraScript *GetAuraScript() const
{
return new spell_dk_spell_deflection_AuraScript();
}
};
void AddSC_deathknight_spell_scripts()
{
new spell_dk_corpse_explosion();
new spell_dk_runic_power_feed();
new spell_dk_scourge_strike();
new spell_dk_spell_deflection();
}

View File

@@ -83,7 +83,126 @@ public:
}
};
// 69366 - Moonkin Form passive
class spell_dru_moonkin_form_passive : public SpellScriptLoader
{
public:
spell_dru_moonkin_form_passive() : SpellScriptLoader("spell_dru_moonkin_form_passive") { }
class spell_dru_moonkin_form_passive_AuraScript : public AuraScript
{
PrepareAuraScript(spell_dru_moonkin_form_passive_AuraScript);
uint32 absorbPct;
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & canBeRecalculated)
{
absorbPct = amount;
// Set absorbtion amount to unlimited
amount = -1;
}
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
// reduces all damage taken while Stunned in Cat Form
if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED))
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_moonkin_form_passive_AuraScript::CalculateAmount, EFFECT_1, SPELL_AURA_SCHOOL_ABSORB);
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dru_moonkin_form_passive_AuraScript::Absorb, EFFECT_1);
}
};
AuraScript *GetAuraScript() const
{
return new spell_dru_moonkin_form_passive_AuraScript();
}
};
// 33851 - Primal Tenacity
class spell_dru_primal_tenacity : public SpellScriptLoader
{
public:
spell_dru_primal_tenacity() : SpellScriptLoader("spell_dru_primal_tenacity") { }
class spell_dru_primal_tenacity_AuraScript : public AuraScript
{
PrepareAuraScript(spell_dru_primal_tenacity_AuraScript);
uint32 absorbPct;
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & canBeRecalculated)
{
absorbPct = amount;
// Set absorbtion amount to unlimited
amount = -1;
}
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
// reduces all damage taken while Stunned in Cat Form
if ((GetTarget()->GetShapeshiftForm() == FORM_CAT) && (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED)))
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_primal_tenacity_AuraScript::CalculateAmount, EFFECT_1, SPELL_AURA_SCHOOL_ABSORB);
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dru_primal_tenacity_AuraScript::Absorb, EFFECT_1);
}
};
AuraScript *GetAuraScript() const
{
return new spell_dru_primal_tenacity_AuraScript();
}
};
// 62606 - Savage Defense
class spell_dru_savage_defense : public SpellScriptLoader
{
public:
spell_dru_savage_defense() : SpellScriptLoader("spell_dru_savage_defense") { }
class spell_dru_savage_defense_AuraScript : public AuraScript
{
PrepareAuraScript(spell_dru_savage_defense_AuraScript);
uint32 absorbPct;
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & canBeRecalculated)
{
absorbPct = amount;
// Set absorbtion amount to unlimited
amount = -1;
}
void Absorb(AuraEffect * aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
// don't waste charge when no dmg
if (!dmgInfo.GetDamage())
return;
absorbAmount = CalculatePctN(GetTarget()->GetTotalAttackPowerValue(BASE_ATTACK), absorbPct);
aurEff->SetAmount(0);
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_savage_defense_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dru_savage_defense_AuraScript::Absorb, EFFECT_0);
}
};
AuraScript *GetAuraScript() const
{
return new spell_dru_savage_defense_AuraScript();
}
};
void AddSC_druid_spell_scripts()
{
new spell_dru_glyph_of_starfire();
new spell_dru_moonkin_form_passive();
new spell_dru_primal_tenacity();
new spell_dru_savage_defense();
}

View File

@@ -104,9 +104,9 @@ public:
return true;
}
void HandleEffectPeriodic(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp)
void HandleEffectPeriodic(AuraEffect const * /*aurEff*/)
{
Unit* pTarget = aurApp->GetTarget();
Unit* pTarget = GetTarget();
if (Player* pPlayerTarget = pTarget->ToPlayer())
if (pPlayerTarget->IsFalling())
{
@@ -244,9 +244,9 @@ public:
return true;
}
void HandleEffectPeriodic(AuraEffect const * aurEff, AuraApplication const * aurApp)
void HandleEffectPeriodic(AuraEffect const * aurEff)
{
Unit* pTarget = aurApp->GetTarget();
Unit* pTarget = GetTarget();
if (Unit* pCaster = GetCaster())
{
int32 lifeLeeched = pTarget->CountPctFromMaxHealth(aurEff->GetAmount());
@@ -405,9 +405,9 @@ class spell_creature_permanent_feign_death : public SpellScriptLoader
class spell_creature_permanent_feign_deathAuraScript : public AuraScript
{
PrepareAuraScript(spell_creature_permanent_feign_deathAuraScript)
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/)
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* pTarget = aurApp->GetTarget();
Unit* pTarget = GetTarget();
pTarget->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
pTarget->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
@@ -498,14 +498,14 @@ class spell_gen_animal_blood : public SpellScriptLoader
return true;
}
void OnApply(AuraEffect const* /*aurEff*/, AuraApplication const* /*aurApp*/, AuraEffectHandleModes /*mode*/)
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
// Remove all auras with spell id 46221, except the one currently being applied
while (Aura* aur = GetUnitOwner()->GetOwnedAura(SPELL_ANIMAL_BLOOD, 0, 0, 0, GetAura()))
GetUnitOwner()->RemoveOwnedAura(aur);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraApplication const* /*aurApp*/, AuraEffectHandleModes /*mode*/)
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetUnitOwner()->IsInWater())
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SPAWN_BLOOD_POOL, true);
@@ -533,16 +533,16 @@ class spell_gen_shroud_of_death : public SpellScriptLoader
{
PrepareAuraScript(spell_gen_shroud_of_deathAuraScript)
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/)
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = aurApp->GetTarget();
Unit* target = GetTarget();
target->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
target->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
}
void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/)
void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = aurApp->GetTarget();
Unit* target = GetTarget();
target->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
target->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
}

View File

@@ -357,14 +357,14 @@ public:
return true;
}
void HandlePeriodic(AuraEffect const * aurEff, AuraApplication const * aurApp)
void HandlePeriodic(AuraEffect const * aurEff)
{
PreventDefaultAction();
if (aurEff->GetAmount() > 0)
return;
uint32 spellId = SPELL_SNIPER_TRAINING_BUFF_R1 + GetId() - SPELL_SNIPER_TRAINING_R1;
Unit * pTarget = aurApp->GetTarget();
Unit * pTarget = GetTarget();
if (!pTarget->HasAura(spellId))
{
SpellEntry const * triggeredSpellInfo = sSpellStore.LookupEntry(spellId);

View File

@@ -698,9 +698,9 @@ public:
return true;
}
void OnStackChange(AuraEffect const* /*aurEff*/, AuraApplication const* aurApp, AuraEffectHandleModes /*mode*/)
void OnStackChange(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = aurApp->GetTarget();
Unit* target = GetTarget();
switch (GetStackAmount())
{
@@ -718,11 +718,11 @@ public:
}
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraApplication const* aurApp, AuraEffectHandleModes /*mode*/)
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = aurApp->GetTarget();
Unit* target = GetTarget();
if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_STACK)
if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_STACK)
return;
target->RemoveAurasDueToSpell(SPELL_SHADOWMOURNE_VISUAL_LOW);
target->RemoveAurasDueToSpell(SPELL_SHADOWMOURNE_VISUAL_HIGH);

View File

@@ -108,16 +108,16 @@ public:
return true;
}
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/)
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* pTarget = aurApp->GetTarget();
Unit* pTarget = GetTarget();
if (Unit* pCaster = GetCaster())
pCaster->CastSpell(pTarget, PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, true);
}
void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/)
void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* pTarget = aurApp->GetTarget();
Unit* pTarget = GetTarget();
pTarget->RemoveAura(PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, GetCasterGUID());
}

View File

@@ -219,16 +219,16 @@ public:
class spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript : public AuraScript
{
PrepareAuraScript(spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript)
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/)
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* pTarget = aurApp->GetTarget();
Unit* pTarget = GetTarget();
pTarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
pTarget->AddUnitState(UNIT_STAT_ROOT);
}
void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/)
void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
aurApp->GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
}
void Register()

View File

@@ -30,6 +30,44 @@ enum RogueSpells
ROGUE_SPELL_PREY_ON_THE_WEAK = 58670,
};
// 31130 - Nerves of Steel
class spell_rog_nerves_of_steel : public SpellScriptLoader
{
public:
spell_rog_nerves_of_steel() : SpellScriptLoader("spell_rog_nerves_of_steel") { }
class spell_rog_nerves_of_steel_AuraScript : public AuraScript
{
PrepareAuraScript(spell_rog_nerves_of_steel_AuraScript);
uint32 absorbPct;
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & canBeRecalculated)
{
absorbPct = amount;
// Set absorbtion amount to unlimited
amount = -1;
}
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
// reduces all damage taken while stun or fear
if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED | UNIT_FLAG_FLEEING))
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_rog_nerves_of_steel_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
OnEffectAbsorb += AuraEffectAbsorbFn(spell_rog_nerves_of_steel_AuraScript::Absorb, EFFECT_0);
}
};
AuraScript *GetAuraScript() const
{
return new spell_rog_nerves_of_steel_AuraScript();
}
};
class spell_rog_preparation : public SpellScriptLoader
{
public:
@@ -109,9 +147,9 @@ public:
return true;
}
void HandleEffectPeriodic(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp)
void HandleEffectPeriodic(AuraEffect const * /*aurEff*/)
{
Unit* pTarget = aurApp->GetTarget();
Unit* pTarget = GetTarget();
Unit* pVictim = pTarget->getVictim();
if (pVictim && (pTarget->GetHealthPct() > pVictim->GetHealthPct()))
{
@@ -178,6 +216,7 @@ class spell_rog_shiv : public SpellScriptLoader
void AddSC_rogue_spell_scripts()
{
new spell_rog_nerves_of_steel();
new spell_rog_preparation();
new spell_rog_prey_on_the_weak();
new spell_rog_shiv();

View File

@@ -36,6 +36,44 @@ enum ShamanSpells
SHAMAN_TOTEM_SPELL_EARTHEN_POWER = 59566,//Spell witch remove snare effect
};
// 51474 - Astral shift
class spell_sha_astral_shift : public SpellScriptLoader
{
public:
spell_sha_astral_shift() : SpellScriptLoader("spell_sha_astral_shift") { }
class spell_sha_astral_shift_AuraScript : public AuraScript
{
PrepareAuraScript(spell_sha_astral_shift_AuraScript);
uint32 absorbPct;
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & canBeRecalculated)
{
absorbPct = amount;
// Set absorbtion amount to unlimited
amount = -1;
}
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
// reduces all damage taken while stun, fear or silence
if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED | UNIT_FLAG_FLEEING | UNIT_FLAG_SILENCED))
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_sha_astral_shift_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
OnEffectAbsorb += AuraEffectAbsorbFn(spell_sha_astral_shift_AuraScript::Absorb, EFFECT_0);
}
};
AuraScript *GetAuraScript() const
{
return new spell_sha_astral_shift_AuraScript();
}
};
// 1535 Fire Nova
class spell_sha_fire_nova : public SpellScriptLoader
{
@@ -154,9 +192,9 @@ public:
return true;
}
void HandleEffectPeriodic(AuraEffect const * aurEff, AuraApplication const * aurApp)
void HandleEffectPeriodic(AuraEffect const * aurEff)
{
Unit* target = aurApp->GetTarget();
Unit* target = GetTarget();
if (Unit *caster = aurEff->GetBase()->GetCaster())
if (AuraEffect* aur = caster->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 2289, 0))
if (roll_chance_i(aur->GetBaseAmount()))
@@ -174,8 +212,10 @@ public:
return new spell_sha_earthbind_totem_AuraScript();
}
};
void AddSC_shaman_spell_scripts()
{
new spell_sha_astral_shift();
new spell_sha_fire_nova();
new spell_sha_mana_tide_totem();
new spell_sha_earthbind_totem();