Core/Spells: fixed Army of the Dead ghoul behaivior and damage reduction calculation
This commit is contained in:
1 parent
108dea25a0
commit
56b918da17
4 files changed
+193
-107
No files matched your search
@@ -0,0 +1,5 @@
|
||||
UPDATE `creature_template` SET `ScriptName`= 'npc_pet_dk_army_of_the_dead_ghoul' WHERE `entry`= 24207;
|
||||
|
||||
DELETE FROM `spell_script_names` WHERE `ScriptName`= 'spell_dk_army_of_the_dead';
|
||||
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
|
||||
(42650, 'spell_dk_army_of_the_dead');
|
||||
@@ -162,75 +162,152 @@ enum GhoulSpells
|
||||
SPELL_PET_PUTRID_BULWARK = 91837,
|
||||
};
|
||||
|
||||
class spell_pet_ghoul_dummy_ability : public SpellScriptLoader
|
||||
class spell_pet_ghoul_dummy_ability : public SpellScript
|
||||
{
|
||||
public:
|
||||
spell_pet_ghoul_dummy_ability() : SpellScriptLoader("spell_pet_ghoul_dummy_ability") { }
|
||||
PrepareSpellScript(spell_pet_ghoul_dummy_ability);
|
||||
|
||||
class spell_pet_ghoul_dummy_ability_SpellScript : public SpellScript
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
PrepareSpellScript(spell_pet_ghoul_dummy_ability_SpellScript);
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
return ValidateSpellInfo(
|
||||
{
|
||||
SPELL_PET_DARK_TRANSFORMATION,
|
||||
SPELL_PET_GNAW_DUMMY,
|
||||
SPELL_PET_GNAW_DAMAGE,
|
||||
SPELL_PET_MONSTROUS_BLOW,
|
||||
SPELL_PET_LEAP_DUMMY,
|
||||
SPELL_PET_LEAP_EFFECT,
|
||||
SPELL_PET_SHAMBLING_RUSH,
|
||||
SPELL_PET_CLAW_DUMMY,
|
||||
SPELL_PET_CLAW_DAMAGE,
|
||||
SPELL_PET_SWEEPING_CLAWS,
|
||||
SPELL_PET_HUDDLE_DUMMY,
|
||||
SPELL_PET_HUDDLE_EFFECT,
|
||||
SPELL_PET_PUTRID_BULWARK
|
||||
});
|
||||
}
|
||||
|
||||
void HandleHit(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* caster = GetCaster())
|
||||
return ValidateSpellInfo(
|
||||
{
|
||||
bool isTransformed = caster->HasAura(SPELL_PET_DARK_TRANSFORMATION);
|
||||
switch (GetSpellInfo()->Id)
|
||||
{
|
||||
case SPELL_PET_GNAW_DUMMY:
|
||||
caster->CastSpell(GetHitUnit(), isTransformed ? SPELL_PET_MONSTROUS_BLOW : SPELL_PET_GNAW_DAMAGE, true);
|
||||
break;
|
||||
case SPELL_PET_LEAP_DUMMY:
|
||||
caster->CastSpell(GetHitUnit(), isTransformed ? SPELL_PET_SHAMBLING_RUSH : SPELL_PET_LEAP_EFFECT, true);
|
||||
break;
|
||||
case SPELL_PET_CLAW_DUMMY:
|
||||
caster->CastSpell(GetHitUnit(), isTransformed ? SPELL_PET_SWEEPING_CLAWS : SPELL_PET_CLAW_DAMAGE, true);
|
||||
break;
|
||||
case SPELL_PET_HUDDLE_DUMMY:
|
||||
caster->CastSpell(GetHitUnit(), isTransformed ? SPELL_PET_PUTRID_BULWARK : SPELL_PET_HUDDLE_EFFECT, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SPELL_PET_DARK_TRANSFORMATION,
|
||||
SPELL_PET_GNAW_DUMMY,
|
||||
SPELL_PET_GNAW_DAMAGE,
|
||||
SPELL_PET_MONSTROUS_BLOW,
|
||||
SPELL_PET_LEAP_DUMMY,
|
||||
SPELL_PET_LEAP_EFFECT,
|
||||
SPELL_PET_SHAMBLING_RUSH,
|
||||
SPELL_PET_CLAW_DUMMY,
|
||||
SPELL_PET_CLAW_DAMAGE,
|
||||
SPELL_PET_SWEEPING_CLAWS,
|
||||
SPELL_PET_HUDDLE_DUMMY,
|
||||
SPELL_PET_HUDDLE_EFFECT,
|
||||
SPELL_PET_PUTRID_BULWARK
|
||||
});
|
||||
}
|
||||
|
||||
void HandleHit(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* caster = GetCaster())
|
||||
{
|
||||
bool isTransformed = caster->HasAura(SPELL_PET_DARK_TRANSFORMATION);
|
||||
switch (GetSpellInfo()->Id)
|
||||
{
|
||||
case SPELL_PET_GNAW_DUMMY:
|
||||
caster->CastSpell(GetHitUnit(), isTransformed ? SPELL_PET_MONSTROUS_BLOW : SPELL_PET_GNAW_DAMAGE, true);
|
||||
break;
|
||||
case SPELL_PET_LEAP_DUMMY:
|
||||
caster->CastSpell(GetHitUnit(), isTransformed ? SPELL_PET_SHAMBLING_RUSH : SPELL_PET_LEAP_EFFECT, true);
|
||||
break;
|
||||
case SPELL_PET_CLAW_DUMMY:
|
||||
caster->CastSpell(GetHitUnit(), isTransformed ? SPELL_PET_SWEEPING_CLAWS : SPELL_PET_CLAW_DAMAGE, true);
|
||||
break;
|
||||
case SPELL_PET_HUDDLE_DUMMY:
|
||||
caster->CastSpell(GetHitUnit(), isTransformed ? SPELL_PET_PUTRID_BULWARK : SPELL_PET_HUDDLE_EFFECT, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_pet_ghoul_dummy_ability::HandleHit, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
enum ArmyOfTheDead
|
||||
{
|
||||
SPELL_BIRTH = 7398,
|
||||
SPELL_PERIODIC_TAUNT = 43264,
|
||||
SPELL_DEATH_KNIGHT_PET_SCALING_2 = 51996,
|
||||
SPELL_DEATH_KNIGHT_PET_SCALING_3 = 61697,
|
||||
SPELL_DEATH_KNIGHT_PET_SCALING_5 = 110474,
|
||||
|
||||
EVENT_ALLOW_ATTACKS = 1,
|
||||
EVENT_LEAP,
|
||||
EVENT_CLAW
|
||||
};
|
||||
|
||||
struct npc_pet_dk_army_of_the_dead_ghoul : public AggressorAI
|
||||
{
|
||||
npc_pet_dk_army_of_the_dead_ghoul(Creature* creature) : AggressorAI(creature)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
_readyToAttack = false;
|
||||
}
|
||||
|
||||
void JustAppeared() override
|
||||
{
|
||||
DoCastSelf(SPELL_DEATH_KNIGHT_PET_SCALING_2);
|
||||
DoCastSelf(SPELL_DEATH_KNIGHT_PET_SCALING_3);
|
||||
DoCastSelf(SPELL_DEATH_KNIGHT_PET_SCALING_5);
|
||||
DoCastSelf(SPELL_BIRTH);
|
||||
me->AddUnitState(UNIT_STATE_ROOT);
|
||||
_events.ScheduleEvent(EVENT_ALLOW_ATTACKS, 4s);
|
||||
}
|
||||
|
||||
bool CanAIAttack(Unit const* target) const override
|
||||
{
|
||||
if (!target)
|
||||
return false;
|
||||
|
||||
if (!_readyToAttack)
|
||||
return false;
|
||||
|
||||
Unit* owner = me->GetOwner();
|
||||
if (owner && !target->IsInCombatWith(owner))
|
||||
return false;
|
||||
|
||||
return AggressorAI::CanAIAttack(target);
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim() && _readyToAttack)
|
||||
return;
|
||||
|
||||
_events.Update(diff);
|
||||
|
||||
while (uint32 eventId = _events.ExecuteEvent())
|
||||
{
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_ALLOW_ATTACKS:
|
||||
_readyToAttack = true;
|
||||
me->ClearUnitState(UNIT_STATE_ROOT);
|
||||
DoCastSelf(SPELL_PERIODIC_TAUNT);
|
||||
_events.ScheduleEvent(EVENT_LEAP, 1ms);
|
||||
_events.ScheduleEvent(EVENT_CLAW, 2s + 500ms);
|
||||
break;
|
||||
case EVENT_LEAP:
|
||||
DoCastVictim(SPELL_PET_LEAP_DUMMY, true);
|
||||
break;
|
||||
case EVENT_CLAW:
|
||||
DoCastVictim(SPELL_PET_CLAW_DUMMY, true);
|
||||
_events.Repeat(7s, 8s);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_pet_ghoul_dummy_ability_SpellScript::HandleHit, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const override
|
||||
{
|
||||
return new spell_pet_ghoul_dummy_ability_SpellScript();
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
private:
|
||||
EventMap _events;
|
||||
bool _readyToAttack;
|
||||
};
|
||||
|
||||
void AddSC_deathknight_pet_scripts()
|
||||
{
|
||||
new npc_pet_dk_ebon_gargoyle();
|
||||
new npc_pet_dk_guardian();
|
||||
new spell_pet_ghoul_dummy_ability();
|
||||
RegisterCreatureAI(npc_pet_dk_army_of_the_dead_ghoul);
|
||||
RegisterSpellScript(spell_pet_ghoul_dummy_ability);
|
||||
}
|
||||
@@ -1622,11 +1622,35 @@ class spell_dk_crimson_scourge : public AuraScript
|
||||
}
|
||||
};
|
||||
|
||||
class spell_dk_army_of_the_dead : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_dk_army_of_the_dead);
|
||||
|
||||
void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
|
||||
{
|
||||
amount = 0;
|
||||
if (Player* player = GetUnitOwner()->ToPlayer())
|
||||
{
|
||||
float dodgeChance = player->GetFloatValue(PLAYER_DODGE_PERCENTAGE);
|
||||
float parryChance = player->GetFloatValue(PLAYER_PARRY_PERCENTAGE);
|
||||
amount -= int32(dodgeChance + parryChance);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dk_army_of_the_dead::CalculateAmount, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN);
|
||||
}
|
||||
private:
|
||||
uint32 absorbPct;
|
||||
};
|
||||
|
||||
void AddSC_deathknight_spell_scripts()
|
||||
{
|
||||
RegisterAuraScript(spell_dk_anti_magic_shell_raid);
|
||||
RegisterAuraScript(spell_dk_anti_magic_shell_self);
|
||||
RegisterAuraScript(spell_dk_anti_magic_zone);
|
||||
RegisterAuraScript(spell_dk_army_of_the_dead);
|
||||
RegisterSpellScript(spell_dk_blood_boil);
|
||||
RegisterAuraScript(spell_dk_blood_gorged);
|
||||
RegisterAuraScript(spell_dk_blood_rites);
|
||||
|
||||
@@ -823,49 +823,40 @@ class spell_dk_pet_scaling_01 : public AuraScript
|
||||
void CalculateStaminaAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated)
|
||||
{
|
||||
canBeRecalculated = true;
|
||||
if (Pet* pet = GetUnitOwner()->ToPet())
|
||||
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
|
||||
{
|
||||
if (Player* owner = pet->GetOwner())
|
||||
{
|
||||
uint8 percentage = 45;
|
||||
uint8 percentage = 45;
|
||||
|
||||
// Glyph of Raise Dead
|
||||
if (AuraEffect const* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, DEATH_KNIGHT_ICON_ID_GLYPH_OF_RAISE_DEAD, EFFECT_0))
|
||||
percentage += aurEff->GetAmount();
|
||||
// Glyph of Raise Dead
|
||||
if (AuraEffect const* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, DEATH_KNIGHT_ICON_ID_GLYPH_OF_RAISE_DEAD, EFFECT_0))
|
||||
percentage += aurEff->GetAmount();
|
||||
|
||||
amount = int32(CalculatePct(owner->GetStat(STAT_STAMINA), percentage));
|
||||
}
|
||||
amount = int32(CalculatePct(owner->GetStat(STAT_STAMINA), percentage));
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateStrengthAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated)
|
||||
{
|
||||
canBeRecalculated = true;
|
||||
if (Pet* pet = GetUnitOwner()->ToPet())
|
||||
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
|
||||
{
|
||||
if (Player* owner = pet->GetOwner())
|
||||
{
|
||||
uint8 percentage = 70;
|
||||
uint8 percentage = 70;
|
||||
|
||||
// Glyph of Raise Dead
|
||||
if (AuraEffect const* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, DEATH_KNIGHT_ICON_ID_GLYPH_OF_RAISE_DEAD, EFFECT_0))
|
||||
percentage += aurEff->GetAmount();
|
||||
// Glyph of Raise Dead
|
||||
if (AuraEffect const* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, DEATH_KNIGHT_ICON_ID_GLYPH_OF_RAISE_DEAD, EFFECT_0))
|
||||
percentage += aurEff->GetAmount();
|
||||
|
||||
amount = int32(CalculatePct(owner->GetStat(STAT_STAMINA), percentage));
|
||||
}
|
||||
amount = int32(CalculatePct(owner->GetStat(STAT_STAMINA), percentage));
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated)
|
||||
{
|
||||
canBeRecalculated = true;
|
||||
if (Pet* pet = GetUnitOwner()->ToPet())
|
||||
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
|
||||
{
|
||||
if (Player* owner = pet->GetOwner())
|
||||
{
|
||||
float bonusDamage = owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.11f;
|
||||
amount += bonusDamage;
|
||||
}
|
||||
float bonusDamage = owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.11f;
|
||||
amount += bonusDamage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,17 +882,14 @@ class spell_dk_pet_scaling_02 : public AuraScript
|
||||
void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated)
|
||||
{
|
||||
canBeRecalculated = true;
|
||||
if (Pet* pet = GetUnitOwner()->ToPet())
|
||||
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
|
||||
{
|
||||
if (Player* owner = pet->GetOwner())
|
||||
{
|
||||
// For others recalculate it from:
|
||||
float HasteMelee = 0.0f;
|
||||
// Increase hit from SPELL_AURA_MOD_HIT_CHANCE
|
||||
HasteMelee += (1 - owner->m_modAttackSpeedPct[BASE_ATTACK]) * 100;
|
||||
// For others recalculate it from:
|
||||
float HasteMelee = 0.0f;
|
||||
// Increase hit from SPELL_AURA_MOD_HIT_CHANCE
|
||||
HasteMelee += (1 - owner->m_modAttackSpeedPct[BASE_ATTACK]) * 100;
|
||||
|
||||
amount += int32(HasteMelee);
|
||||
}
|
||||
amount += int32(HasteMelee);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,8 +913,6 @@ class spell_dk_pet_scaling_03 : public AuraScript
|
||||
void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated)
|
||||
{
|
||||
canBeRecalculated = true;
|
||||
if (!GetCaster() || !GetCaster()->GetOwner())
|
||||
return;
|
||||
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
|
||||
{
|
||||
// For others recalculate it from:
|
||||
@@ -943,8 +929,6 @@ class spell_dk_pet_scaling_03 : public AuraScript
|
||||
void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated)
|
||||
{
|
||||
canBeRecalculated = true;
|
||||
if (!GetCaster() || !GetCaster()->GetOwner())
|
||||
return;
|
||||
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
|
||||
{
|
||||
// For others recalculate it from:
|
||||
@@ -969,7 +953,7 @@ class spell_dk_pet_scaling_05 : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_dk_pet_scaling_05);
|
||||
|
||||
bool Load()
|
||||
bool Load() override
|
||||
{
|
||||
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
|
||||
return false;
|
||||
@@ -978,24 +962,20 @@ class spell_dk_pet_scaling_05 : public AuraScript
|
||||
|
||||
void CalculateAmountCritPct(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
|
||||
{
|
||||
if (Pet* pet = GetUnitOwner()->ToPet())
|
||||
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
|
||||
{
|
||||
if (Player* owner = pet->GetOwner())
|
||||
{
|
||||
float CritSpell = owner->GetMeleeCritFromAgility();
|
||||
CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE);
|
||||
CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT);
|
||||
CritSpell += owner->GetRatingBonusValue(CR_CRIT_MELEE);
|
||||
amount += int32(CritSpell);
|
||||
}
|
||||
float CritSpell = owner->GetMeleeCritFromAgility();
|
||||
CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE);
|
||||
CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT);
|
||||
CritSpell += owner->GetRatingBonusValue(CR_CRIT_MELEE);
|
||||
amount += int32(CritSpell);
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateAmountResistance(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
|
||||
{
|
||||
if (Pet* pet = GetUnitOwner()->ToPet())
|
||||
if (Player* owner = pet->GetOwner())
|
||||
amount += owner->GetInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE);
|
||||
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
|
||||
amount += owner->GetInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE);
|
||||
}
|
||||
|
||||
void Register()
|
||||
|
||||
Reference in new issue
Block a user