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
+42 -2
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();