Scripts/Spells: Moved all special target filtering cases to scripts
This commit is contained in:
@@ -26,407 +26,446 @@
|
||||
|
||||
enum DeathKnightSpells
|
||||
{
|
||||
DK_SPELL_SUMMON_GARGOYLE = 50514,
|
||||
DK_SPELL_CORPSE_EXPLOSION_TRIGGERED = 43999,
|
||||
DISPLAY_GHOUL_CORPSE = 25537,
|
||||
DK_SPELL_SCOURGE_STRIKE_TRIGGERED = 70890,
|
||||
DK_SPELL_RUNIC_POWER_ENERGIZE = 49088,
|
||||
DK_SPELL_ANTI_MAGIC_SHELL_TALENT = 51052,
|
||||
DK_SPELL_SUMMON_GARGOYLE = 50514,
|
||||
DK_SPELL_CORPSE_EXPLOSION_TRIGGERED = 43999,
|
||||
DISPLAY_GHOUL_CORPSE = 25537,
|
||||
DK_SPELL_SCOURGE_STRIKE_TRIGGERED = 70890,
|
||||
DK_SPELL_WILL_OF_THE_NECROPOLIS_TALENT_R1 = 49189,
|
||||
DK_SPELL_WILL_OF_THE_NECROPOLIS_AURA_R1 = 52284,
|
||||
};
|
||||
|
||||
// 50462 - Anti-Magic Shell (on raid member)
|
||||
class spell_dk_anti_magic_shell_raid : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_anti_magic_shell_raid() : SpellScriptLoader("spell_dk_anti_magic_shell_raid") { }
|
||||
public:
|
||||
spell_dk_anti_magic_shell_raid() : SpellScriptLoader("spell_dk_anti_magic_shell_raid") { }
|
||||
|
||||
class spell_dk_anti_magic_shell_raid_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_dk_anti_magic_shell_raid_AuraScript);
|
||||
|
||||
uint32 absorbPct;
|
||||
|
||||
bool Load()
|
||||
class spell_dk_anti_magic_shell_raid_AuraScript : public AuraScript
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
return true;
|
||||
}
|
||||
PrepareAuraScript(spell_dk_anti_magic_shell_raid_AuraScript);
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
uint32 absorbPct;
|
||||
|
||||
bool Load()
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
return true;
|
||||
}
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
// TODO: this should absorb limited amount of damage, but no info on calculation formula
|
||||
amount = -1;
|
||||
}
|
||||
|
||||
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_anti_magic_shell_raid_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
|
||||
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_anti_magic_shell_raid_AuraScript::Absorb, EFFECT_0);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript *GetAuraScript() const
|
||||
{
|
||||
// TODO: this should absorb limited amount of damage, but no info on calculation formula
|
||||
amount = -1;
|
||||
return new spell_dk_anti_magic_shell_raid_AuraScript();
|
||||
}
|
||||
|
||||
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_anti_magic_shell_raid_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
|
||||
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_anti_magic_shell_raid_AuraScript::Absorb, EFFECT_0);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript *GetAuraScript() const
|
||||
{
|
||||
return new spell_dk_anti_magic_shell_raid_AuraScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 48707 - Anti-Magic Shell (on self)
|
||||
class spell_dk_anti_magic_shell_self : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_anti_magic_shell_self() : SpellScriptLoader("spell_dk_anti_magic_shell_self") { }
|
||||
public:
|
||||
spell_dk_anti_magic_shell_self() : SpellScriptLoader("spell_dk_anti_magic_shell_self") { }
|
||||
|
||||
class spell_dk_anti_magic_shell_self_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_dk_anti_magic_shell_self_AuraScript);
|
||||
|
||||
enum Spells
|
||||
class spell_dk_anti_magic_shell_self_AuraScript : public AuraScript
|
||||
{
|
||||
DK_SPELL_RUNIC_POWER_ENERGIZE = 49088,
|
||||
PrepareAuraScript(spell_dk_anti_magic_shell_self_AuraScript);
|
||||
|
||||
uint32 absorbPct, hpPct;
|
||||
bool Load()
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
hpPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_1, GetCaster());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
{
|
||||
return sSpellStore.LookupEntry(DK_SPELL_RUNIC_POWER_ENERGIZE);
|
||||
}
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
// Set absorbtion amount to unlimited
|
||||
amount = -1;
|
||||
}
|
||||
|
||||
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
absorbAmount = std::min(CalculatePctN(dmgInfo.GetDamage(), absorbPct), GetTarget()->CountPctFromMaxHealth(hpPct));
|
||||
}
|
||||
|
||||
void Trigger(AuraEffect * aurEff, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount)
|
||||
{
|
||||
Unit * target = GetTarget();
|
||||
// damage absorbed by Anti-Magic Shell energizes the DK with additional runic power.
|
||||
// This, if I'm not mistaken, shows that we get back ~20% of the absorbed damage as runic power.
|
||||
int32 bp = absorbAmount * 2 / 10;
|
||||
target->CastCustomSpell(target, DK_SPELL_RUNIC_POWER_ENERGIZE, &bp, NULL, NULL, true, NULL, aurEff);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_anti_magic_shell_self_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
|
||||
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_anti_magic_shell_self_AuraScript::Absorb, EFFECT_0);
|
||||
AfterEffectAbsorb += AuraEffectAbsorbFn(spell_dk_anti_magic_shell_self_AuraScript::Trigger, EFFECT_0);
|
||||
}
|
||||
};
|
||||
|
||||
uint32 absorbPct, hpPct;
|
||||
bool Load()
|
||||
AuraScript *GetAuraScript() const
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
hpPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_1, GetCaster());
|
||||
return true;
|
||||
return new spell_dk_anti_magic_shell_self_AuraScript();
|
||||
}
|
||||
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
{
|
||||
return sSpellStore.LookupEntry(DK_SPELL_RUNIC_POWER_ENERGIZE);
|
||||
}
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
// Set absorbtion amount to unlimited
|
||||
amount = -1;
|
||||
}
|
||||
|
||||
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
absorbAmount = std::min(CalculatePctN(dmgInfo.GetDamage(), absorbPct), GetTarget()->CountPctFromMaxHealth(hpPct));
|
||||
}
|
||||
|
||||
void Trigger(AuraEffect * aurEff, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount)
|
||||
{
|
||||
Unit * target = GetTarget();
|
||||
// damage absorbed by Anti-Magic Shell energizes the DK with additional runic power.
|
||||
// This, if I'm not mistaken, shows that we get back ~20% of the absorbed damage as runic power.
|
||||
int32 bp = absorbAmount * 2 / 10;
|
||||
target->CastCustomSpell(target, DK_SPELL_RUNIC_POWER_ENERGIZE, &bp, NULL, NULL, true, NULL, aurEff);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_anti_magic_shell_self_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
|
||||
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_anti_magic_shell_self_AuraScript::Absorb, EFFECT_0);
|
||||
AfterEffectAbsorb += AuraEffectAbsorbFn(spell_dk_anti_magic_shell_self_AuraScript::Trigger, EFFECT_0);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript *GetAuraScript() const
|
||||
{
|
||||
return new spell_dk_anti_magic_shell_self_AuraScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 50461 - Anti-Magic Zone
|
||||
class spell_dk_anti_magic_zone : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_anti_magic_zone() : SpellScriptLoader("spell_dk_anti_magic_zone") { }
|
||||
public:
|
||||
spell_dk_anti_magic_zone() : SpellScriptLoader("spell_dk_anti_magic_zone") { }
|
||||
|
||||
class spell_dk_anti_magic_zone_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_dk_anti_magic_zone_AuraScript);
|
||||
|
||||
enum Spells
|
||||
class spell_dk_anti_magic_zone_AuraScript : public AuraScript
|
||||
{
|
||||
DK_SPELL_ANTI_MAGIC_SHELL_TALENT = 51052,
|
||||
PrepareAuraScript(spell_dk_anti_magic_zone_AuraScript);
|
||||
|
||||
uint32 absorbPct;
|
||||
|
||||
bool Load()
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
{
|
||||
return sSpellStore.LookupEntry(DK_SPELL_ANTI_MAGIC_SHELL_TALENT);
|
||||
}
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
SpellEntry const * talentSpell = sSpellStore.LookupEntry(DK_SPELL_ANTI_MAGIC_SHELL_TALENT);
|
||||
amount = SpellMgr::CalculateSpellEffectAmount(talentSpell, EFFECT_0, GetCaster());
|
||||
// assume caster is a player here
|
||||
if (Unit * caster = GetCaster())
|
||||
amount += int32(2 * caster->ToPlayer()->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||
}
|
||||
|
||||
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_anti_magic_zone_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
|
||||
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_anti_magic_zone_AuraScript::Absorb, EFFECT_0);
|
||||
}
|
||||
};
|
||||
|
||||
uint32 absorbPct;
|
||||
|
||||
bool Load()
|
||||
AuraScript *GetAuraScript() const
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
return true;
|
||||
return new spell_dk_anti_magic_zone_AuraScript();
|
||||
}
|
||||
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
{
|
||||
return sSpellStore.LookupEntry(DK_SPELL_ANTI_MAGIC_SHELL_TALENT);
|
||||
}
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
SpellEntry const * talentSpell = sSpellStore.LookupEntry(DK_SPELL_ANTI_MAGIC_SHELL_TALENT);
|
||||
amount = SpellMgr::CalculateSpellEffectAmount(talentSpell, EFFECT_0, GetCaster());
|
||||
// assume caster is a player here
|
||||
if (Unit * caster = GetCaster())
|
||||
amount += int32(2 * caster->ToPlayer()->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||
}
|
||||
|
||||
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_anti_magic_zone_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
|
||||
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_anti_magic_zone_AuraScript::Absorb, EFFECT_0);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript *GetAuraScript() const
|
||||
{
|
||||
return new spell_dk_anti_magic_zone_AuraScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 49158 Corpse Explosion (51325, 51326, 51327, 51328)
|
||||
class spell_dk_corpse_explosion : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_corpse_explosion() : SpellScriptLoader("spell_dk_corpse_explosion") { }
|
||||
public:
|
||||
spell_dk_corpse_explosion() : SpellScriptLoader("spell_dk_corpse_explosion") { }
|
||||
|
||||
class spell_dk_corpse_explosion_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_dk_corpse_explosion_SpellScript)
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
class spell_dk_corpse_explosion_SpellScript : public SpellScript
|
||||
{
|
||||
if (!sSpellStore.LookupEntry(DK_SPELL_CORPSE_EXPLOSION_TRIGGERED))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
PrepareSpellScript(spell_dk_corpse_explosion_SpellScript);
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* unitTarget = GetHitUnit())
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
{
|
||||
int32 bp = 0;
|
||||
// Living ghoul as a target
|
||||
if (unitTarget->isAlive())
|
||||
bp = int32(unitTarget->CountPctFromMaxHealth(25));
|
||||
// Some corpse
|
||||
else
|
||||
bp = GetEffectValue();
|
||||
GetCaster()->CastCustomSpell(unitTarget, SpellMgr::CalculateSpellEffectAmount(GetSpellInfo(), 1), &bp, NULL, NULL, true);
|
||||
// Corpse Explosion (Suicide)
|
||||
unitTarget->CastCustomSpell(unitTarget, DK_SPELL_CORPSE_EXPLOSION_TRIGGERED, &bp, NULL, NULL, true);
|
||||
// Set corpse look
|
||||
unitTarget->SetDisplayId(DISPLAY_GHOUL_CORPSE + urand(0, 3));
|
||||
if (!sSpellStore.LookupEntry(DK_SPELL_CORPSE_EXPLOSION_TRIGGERED))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* unitTarget = GetHitUnit())
|
||||
{
|
||||
int32 bp = 0;
|
||||
// Living ghoul as a target
|
||||
if (unitTarget->isAlive())
|
||||
bp = int32(unitTarget->CountPctFromMaxHealth(25));
|
||||
// Some corpse
|
||||
else
|
||||
bp = GetEffectValue();
|
||||
GetCaster()->CastCustomSpell(unitTarget, SpellMgr::CalculateSpellEffectAmount(GetSpellInfo(), 1), &bp, NULL, NULL, true);
|
||||
// Corpse Explosion (Suicide)
|
||||
unitTarget->CastCustomSpell(unitTarget, DK_SPELL_CORPSE_EXPLOSION_TRIGGERED, &bp, NULL, NULL, true);
|
||||
// Set corpse look
|
||||
unitTarget->SetDisplayId(DISPLAY_GHOUL_CORPSE + urand(0, 3));
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnEffect += SpellEffectFn(spell_dk_corpse_explosion_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
OnEffect += SpellEffectFn(spell_dk_corpse_explosion_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
return new spell_dk_corpse_explosion_SpellScript();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_dk_corpse_explosion_SpellScript();
|
||||
}
|
||||
class spell_dk_death_pact : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_death_pact() : SpellScriptLoader("spell_dk_death_pact") { }
|
||||
|
||||
class spell_dk_death_pact_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_dk_death_pact_SpellScript);
|
||||
|
||||
void FilterTargets(std::list<Unit*>& unitList)
|
||||
{
|
||||
Unit* unit_to_add = NULL;
|
||||
for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->GetTypeId() == TYPEID_UNIT
|
||||
&& (*itr)->GetOwnerGUID() == GetCaster()->GetGUID()
|
||||
&& (*itr)->ToCreature()->GetCreatureInfo()->type == CREATURE_TYPE_UNDEAD)
|
||||
{
|
||||
unit_to_add = (*itr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unitList.clear();
|
||||
if (unit_to_add)
|
||||
unitList.push_back(unit_to_add);
|
||||
else
|
||||
{
|
||||
// Pet not found - remove cooldown
|
||||
if (Player* modOwner = GetCaster()->GetSpellModOwner())
|
||||
modOwner->RemoveSpellCooldown(GetSpellInfo()->Id, true);
|
||||
FinishCast(SPELL_FAILED_NO_PET);
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnUnitTargetSelect += SpellUnitTargetFn(spell_dk_death_pact_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_AREA_ALLY_DST);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_dk_death_pact_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 50524 Runic Power Feed (keeping Gargoyle alive)
|
||||
class spell_dk_runic_power_feed : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_runic_power_feed() : SpellScriptLoader("spell_dk_runic_power_feed") { }
|
||||
public:
|
||||
spell_dk_runic_power_feed() : SpellScriptLoader("spell_dk_runic_power_feed") { }
|
||||
|
||||
class spell_dk_runic_power_feed_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_dk_runic_power_feed_SpellScript)
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
class spell_dk_runic_power_feed_SpellScript : public SpellScript
|
||||
{
|
||||
if (!sSpellStore.LookupEntry(DK_SPELL_SUMMON_GARGOYLE))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
PrepareSpellScript(spell_dk_runic_power_feed_SpellScript);
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* caster = GetCaster())
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
{
|
||||
// No power, dismiss Gargoyle
|
||||
if (caster->GetPower(POWER_RUNIC_POWER) < 30)
|
||||
caster->RemoveAurasDueToSpell(DK_SPELL_SUMMON_GARGOYLE, caster->GetGUID());
|
||||
else
|
||||
caster->ModifyPower(POWER_RUNIC_POWER, -30);
|
||||
if (!sSpellStore.LookupEntry(DK_SPELL_SUMMON_GARGOYLE))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* caster = GetCaster())
|
||||
{
|
||||
// No power, dismiss Gargoyle
|
||||
if (caster->GetPower(POWER_RUNIC_POWER) < 30)
|
||||
caster->RemoveAurasDueToSpell(DK_SPELL_SUMMON_GARGOYLE, caster->GetGUID());
|
||||
else
|
||||
caster->ModifyPower(POWER_RUNIC_POWER, -30);
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnEffect += SpellEffectFn(spell_dk_runic_power_feed_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
OnEffect += SpellEffectFn(spell_dk_runic_power_feed_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
return new spell_dk_runic_power_feed_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_dk_runic_power_feed_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 55090 Scourge Strike (55265, 55270, 55271)
|
||||
class spell_dk_scourge_strike : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_scourge_strike() : SpellScriptLoader("spell_dk_scourge_strike") { }
|
||||
public:
|
||||
spell_dk_scourge_strike() : SpellScriptLoader("spell_dk_scourge_strike") { }
|
||||
|
||||
class spell_dk_scourge_strike_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_dk_scourge_strike_SpellScript)
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
class spell_dk_scourge_strike_SpellScript : public SpellScript
|
||||
{
|
||||
if (!sSpellStore.LookupEntry(DK_SPELL_SCOURGE_STRIKE_TRIGGERED))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
PrepareSpellScript(spell_dk_scourge_strike_SpellScript);
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (Unit* unitTarget = GetHitUnit())
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
{
|
||||
int32 bp = CalculatePctN(GetHitDamage(), GetEffectValue() * unitTarget->GetDiseasesByCaster(caster->GetGUID()));
|
||||
caster->CastCustomSpell(unitTarget, DK_SPELL_SCOURGE_STRIKE_TRIGGERED, &bp, NULL, NULL, true);
|
||||
if (!sSpellStore.LookupEntry(DK_SPELL_SCOURGE_STRIKE_TRIGGERED))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (Unit* unitTarget = GetHitUnit())
|
||||
{
|
||||
int32 bp = CalculatePctN(GetHitDamage(), GetEffectValue() * unitTarget->GetDiseasesByCaster(caster->GetGUID()));
|
||||
caster->CastCustomSpell(unitTarget, DK_SPELL_SCOURGE_STRIKE_TRIGGERED, &bp, NULL, NULL, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnEffect += SpellEffectFn(spell_dk_scourge_strike_SpellScript::HandleDummy, EFFECT_2, SPELL_EFFECT_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
OnEffect += SpellEffectFn(spell_dk_scourge_strike_SpellScript::HandleDummy, EFFECT_2, SPELL_EFFECT_DUMMY);
|
||||
return new spell_dk_scourge_strike_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_dk_scourge_strike_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 49145 - Spell Deflection
|
||||
class spell_dk_spell_deflection : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_spell_deflection() : SpellScriptLoader("spell_dk_spell_deflection") { }
|
||||
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;
|
||||
|
||||
bool Load()
|
||||
class spell_dk_spell_deflection_AuraScript : public AuraScript
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
return true;
|
||||
}
|
||||
PrepareAuraScript(spell_dk_spell_deflection_AuraScript);
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
uint32 absorbPct;
|
||||
|
||||
bool Load()
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
return true;
|
||||
}
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
// Set absorbtion amount to unlimited
|
||||
amount = -1;
|
||||
return new spell_dk_spell_deflection_AuraScript();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
// 52284 - Will of the Necropolis
|
||||
class spell_dk_will_of_the_necropolis : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_dk_will_of_the_necropolis() : SpellScriptLoader("spell_dk_will_of_the_necropolis") { }
|
||||
public:
|
||||
spell_dk_will_of_the_necropolis() : SpellScriptLoader("spell_dk_will_of_the_necropolis") { }
|
||||
|
||||
class spell_dk_will_of_the_necropolis_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_dk_will_of_the_necropolis_AuraScript);
|
||||
|
||||
enum Spells
|
||||
class spell_dk_will_of_the_necropolis_AuraScript : public AuraScript
|
||||
{
|
||||
DK_SPELL_WILL_OF_THE_NECROPOLIS_TALENT_R1 = 49189,
|
||||
DK_SPELL_WILL_OF_THE_NECROPOLIS_AURA_R1 = 52284,
|
||||
};
|
||||
bool Validate(SpellEntry const *spellEntry)
|
||||
{
|
||||
// can't use other spell than will of the necropolis due to spell_ranks dependency
|
||||
if (sSpellMgr->GetFirstSpellInChain(DK_SPELL_WILL_OF_THE_NECROPOLIS_AURA_R1) != sSpellMgr->GetFirstSpellInChain(spellEntry->Id))
|
||||
return false;
|
||||
PrepareAuraScript(spell_dk_will_of_the_necropolis_AuraScript);
|
||||
|
||||
uint8 rank = sSpellMgr->GetSpellRank(spellEntry->Id);
|
||||
if (!sSpellMgr->GetSpellWithRank(DK_SPELL_WILL_OF_THE_NECROPOLIS_TALENT_R1, rank, true))
|
||||
return false;
|
||||
bool Validate(SpellEntry const *spellEntry)
|
||||
{
|
||||
// can't use other spell than will of the necropolis due to spell_ranks dependency
|
||||
if (sSpellMgr->GetFirstSpellInChain(DK_SPELL_WILL_OF_THE_NECROPOLIS_AURA_R1) != sSpellMgr->GetFirstSpellInChain(spellEntry->Id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
uint8 rank = sSpellMgr->GetSpellRank(spellEntry->Id);
|
||||
if (!sSpellMgr->GetSpellWithRank(DK_SPELL_WILL_OF_THE_NECROPOLIS_TALENT_R1, rank, true))
|
||||
return false;
|
||||
|
||||
uint32 absorbPct;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Load()
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
return true;
|
||||
}
|
||||
uint32 absorbPct;
|
||||
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
// Set absorbtion amount to unlimited
|
||||
amount = -1;
|
||||
}
|
||||
bool Load()
|
||||
{
|
||||
absorbPct = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), EFFECT_0, GetCaster());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
// min pct of hp is stored in effect 0 of talent spell
|
||||
uint32 rank = sSpellMgr->GetSpellRank(GetSpellProto()->Id);
|
||||
SpellEntry const * talentProto = sSpellStore.LookupEntry(sSpellMgr->GetSpellWithRank(DK_SPELL_WILL_OF_THE_NECROPOLIS_TALENT_R1, rank));
|
||||
void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
// Set absorbtion amount to unlimited
|
||||
amount = -1;
|
||||
}
|
||||
|
||||
int32 remainingHp = int32(GetTarget()->GetHealth() - dmgInfo.GetDamage());
|
||||
int32 minHp = int32(GetTarget()->CountPctFromMaxHealth(SpellMgr::CalculateSpellEffectAmount(talentProto, EFFECT_0, GetCaster())));
|
||||
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
// min pct of hp is stored in effect 0 of talent spell
|
||||
uint32 rank = sSpellMgr->GetSpellRank(GetSpellProto()->Id);
|
||||
SpellEntry const * talentProto = sSpellStore.LookupEntry(sSpellMgr->GetSpellWithRank(DK_SPELL_WILL_OF_THE_NECROPOLIS_TALENT_R1, rank));
|
||||
|
||||
int32 remainingHp = int32(GetTarget()->GetHealth() - dmgInfo.GetDamage());
|
||||
int32 minHp = int32(GetTarget()->CountPctFromMaxHealth(SpellMgr::CalculateSpellEffectAmount(talentProto, EFFECT_0, GetCaster())));
|
||||
|
||||
// Damage that would take you below [effect0] health or taken while you are at [effect0]
|
||||
if (remainingHp < minHp)
|
||||
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
|
||||
}
|
||||
// Damage that would take you below [effect0] health or taken while you are at [effect0]
|
||||
if (remainingHp < minHp)
|
||||
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
|
||||
}
|
||||
|
||||
void Register()
|
||||
void Register()
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_will_of_the_necropolis_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
|
||||
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_will_of_the_necropolis_AuraScript::Absorb, EFFECT_0);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript *GetAuraScript() const
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_will_of_the_necropolis_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
|
||||
OnEffectAbsorb += AuraEffectAbsorbFn(spell_dk_will_of_the_necropolis_AuraScript::Absorb, EFFECT_0);
|
||||
return new spell_dk_will_of_the_necropolis_AuraScript();
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript *GetAuraScript() const
|
||||
{
|
||||
return new spell_dk_will_of_the_necropolis_AuraScript();
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_deathknight_spell_scripts()
|
||||
@@ -435,6 +474,7 @@ void AddSC_deathknight_spell_scripts()
|
||||
new spell_dk_anti_magic_shell_self();
|
||||
new spell_dk_anti_magic_zone();
|
||||
new spell_dk_corpse_explosion();
|
||||
new spell_dk_death_pact();
|
||||
new spell_dk_runic_power_feed();
|
||||
new spell_dk_scourge_strike();
|
||||
new spell_dk_spell_deflection();
|
||||
|
||||
Reference in New Issue
Block a user