Scripts/Spells: Fix demon hunter talent "Darkglare Boon" (#30496)

This commit is contained in:
Aqua Deus
2024-12-08 20:27:07 +01:00
committed by GitHub
parent 752ea0f8e9
commit 794346bd42
2 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_dh_darkglare_boon';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(212084, 'spell_dh_darkglare_boon');

View File

@@ -65,6 +65,8 @@ enum DemonHunterSpells
SPELL_DH_CONSUME_SOUL_VENGEANCE = 208014,
SPELL_DH_CONSUME_SOUL_VENGEANCE_DEMON = 210050,
SPELL_DH_CONSUME_SOUL_VENGEANCE_SHATTERED = 210047,
SPELL_DH_DARKGLARE_BOON = 389708,
SPELL_DH_DARKGLARE_BOON_ENERGIZE = 391345,
SPELL_DH_DARKNESS_ABSORB = 209426,
SPELL_DH_DEMON_BLADES_DMG = 203796,
SPELL_DH_DEMON_SPIKES = 203819,
@@ -279,6 +281,55 @@ private:
uint32 _healAmount = 0;
};
// Called by 212084 - Fel Devastation
class spell_dh_darkglare_boon : public AuraScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!ValidateSpellInfo({ SPELL_DH_DARKGLARE_BOON_ENERGIZE, SPELL_DH_FEL_DEVASTATION })
|| !ValidateSpellEffect({ { SPELL_DH_DARKGLARE_BOON, EFFECT_3 } }))
return false;
SpellInfo const* darkglareBoon = sSpellMgr->GetSpellInfo(SPELL_DH_DARKGLARE_BOON, DIFFICULTY_NONE);
return darkglareBoon->GetEffect(EFFECT_0).CalcValue() < darkglareBoon->GetEffect(EFFECT_1).CalcValue()
&& darkglareBoon->GetEffect(EFFECT_2).CalcValue() < darkglareBoon->GetEffect(EFFECT_3).CalcValue();
}
bool Load() override
{
return GetUnitOwner()->HasAura(SPELL_DH_DARKGLARE_BOON);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) const
{
// Tooltip mentions "fully channelled" being a requirement but ingame it always reduces cooldown and energizes, even when manually cancelled
//if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
// return;
Unit* target = GetTarget();
Aura const* darkglareBoon = target->GetAura(SPELL_DH_DARKGLARE_BOON);
SpellHistory::Duration cooldown, categoryCooldown;
SpellHistory::GetCooldownDurations(GetSpellInfo(), 0, &cooldown, nullptr, &categoryCooldown);
int32 reductionPct = irand(darkglareBoon->GetEffect(EFFECT_0)->GetAmount(), darkglareBoon->GetEffect(EFFECT_1)->GetAmount());
SpellHistory::Duration cooldownReduction(CalculatePct(std::max(cooldown, categoryCooldown).count(), reductionPct));
int32 energizeValue = irand(darkglareBoon->GetEffect(EFFECT_2)->GetAmount(), darkglareBoon->GetEffect(EFFECT_3)->GetAmount());
target->GetSpellHistory()->ModifyCooldown(SPELL_DH_FEL_DEVASTATION, -cooldownReduction);
target->CastSpell(target, SPELL_DH_DARKGLARE_BOON_ENERGIZE, CastSpellExtraArgsInit{
.TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR,
.SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, energizeValue } }
});
}
void Register() override
{
OnEffectRemove += AuraEffectRemoveFn(spell_dh_darkglare_boon::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
};
// 209426 - Darkness
class spell_dh_darkness : public AuraScript
{
@@ -691,6 +742,7 @@ void AddSC_demon_hunter_spell_scripts()
RegisterSpellScript(spell_dh_chaos_strike);
RegisterSpellScript(spell_dh_chaotic_transformation);
RegisterSpellScript(spell_dh_charred_warblades);
RegisterSpellScript(spell_dh_darkglare_boon);
RegisterSpellScript(spell_dh_darkness);
RegisterSpellScript(spell_dh_eye_beam);
RegisterSpellScript(spell_dh_sigil_of_chains);