From 99793cab8b5550cc711e3137fc494669d789da11 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Fri, 11 Feb 2022 16:25:59 -0500 Subject: [PATCH] [Spells] Fix for AA recast timers not resetting properly (#1989) * revert completed Too many issues popping up that are difficult to track down. This was probably not best way to solve the problem. * fixed for real * Update aa.cpp * Update aa.cpp * Update aa.cpp * should work * remove spaces * [Spells] Fix for AA recast timers not resetting properly --- zone/aa.cpp | 17 +++++++---------- zone/mob.h | 2 +- zone/spells.cpp | 33 ++++++++++++++++++++++----------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/zone/aa.cpp b/zone/aa.cpp index df46bbb8f..3607385d2 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -1278,10 +1278,9 @@ void Client::ActivateAlternateAdvancementAbility(int rank_id, int target_id) { return; } - //calculate cooldown - int cooldown = rank->recast_time - GetAlternateAdvancementCooldownReduction(rank); - if (cooldown < 0) { - cooldown = 0; + int timer_duration = rank->recast_time - GetAlternateAdvancementCooldownReduction(rank); + if (timer_duration < 0) { + timer_duration = 0; } if (!IsCastWhileInvis(rank->spell)) @@ -1316,20 +1315,18 @@ void Client::ActivateAlternateAdvancementAbility(int rank_id, int target_id) { if (!DoCastingChecksOnCaster(rank->spell)) { return; } - if (!SpellFinished(rank->spell, entity_list.GetMob(target_id), EQ::spells::CastingSlot::AltAbility, spells[rank->spell].mana, -1, spells[rank->spell].resist_difficulty, false)) { + + if (!SpellFinished(rank->spell, entity_list.GetMob(target_id), EQ::spells::CastingSlot::AltAbility, spells[rank->spell].mana, -1, spells[rank->spell].resist_difficulty, false, -1, + rank->spell_type + pTimerAAStart, timer_duration, false, rank->id)) { return; } - ExpendAlternateAdvancementCharge(ability->id); } else { - if (!CastSpell(rank->spell, target_id, EQ::spells::CastingSlot::AltAbility, -1, -1, 0, -1, rank->spell_type + pTimerAAStart, cooldown, nullptr, rank->id)) { + if (!CastSpell(rank->spell, target_id, EQ::spells::CastingSlot::AltAbility, -1, -1, 0, -1, rank->spell_type + pTimerAAStart, timer_duration, nullptr, rank->id)) { return; } } } - - CastToClient()->GetPTimers().Start(rank->spell_type + pTimerAAStart, cooldown); - SendAlternateAdvancementTimer(rank->spell_type, 0, 0); } int Mob::GetAlternateAdvancementCooldownReduction(AA::Rank *rank_in) { diff --git a/zone/mob.h b/zone/mob.h index d0b3988ea..ca38653fa 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -326,7 +326,7 @@ public: void CastedSpellFinished(uint16 spell_id, uint32 target_id, EQ::spells::CastingSlot slot, uint16 mana_used, uint32 inventory_slot = 0xFFFFFFFF, int16 resist_adjust = 0); bool SpellFinished(uint16 spell_id, Mob *target, EQ::spells::CastingSlot slot = EQ::spells::CastingSlot::Item, uint16 mana_used = 0, - uint32 inventory_slot = 0xFFFFFFFF, int16 resist_adjust = 0, bool isproc = false, int level_override = -1, uint32 timer = 0xFFFFFFFF, uint32 timer_duration = 0, bool from_casted_spell = false); + uint32 inventory_slot = 0xFFFFFFFF, int16 resist_adjust = 0, bool isproc = false, int level_override = -1, uint32 timer = 0xFFFFFFFF, uint32 timer_duration = 0, bool from_casted_spell = false, uint32 aa_id = 0); void SendBeginCast(uint16 spell_id, uint32 casttime); virtual bool SpellOnTarget(uint16 spell_id, Mob* spelltar, int reflect_effectiveness = 0, bool use_resist_adjust = false, int16 resist_adjust = 0, bool isproc = false, int level_override = -1, int32 duration_override = 0); diff --git a/zone/spells.cpp b/zone/spells.cpp index 226670cf4..ee73add8c 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -2221,7 +2221,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce // if you need to abort the casting, return false bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, uint16 mana_used, uint32 inventory_slot, int16 resist_adjust, bool isproc, int level_override, - uint32 timer, uint32 timer_duration, bool from_casted_spell) + uint32 timer, uint32 timer_duration, bool from_casted_spell, uint32 aa_id) { Mob *ae_center = nullptr; @@ -2600,22 +2600,33 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui */ if(IsClient() && !isproc) { - //Support for bards to get disc recast timers while singing + if (slot == CastingSlot::AltAbility) { + if (!aa_id) { + aa_id = casting_spell_aa_id; + } + if (aa_id) { + AA::Rank *rank = zone->GetAlternateAdvancementRank(aa_id); + //handle expendable AA's + if (rank && rank->base_ability) { + ExpendAlternateAdvancementCharge(rank->base_ability->id); + } + //set AA recast timer + CastToClient()->SendAlternateAdvancementTimer(rank->spell_type, 0, 0); + } + } + //handle bard AA and Discipline recast timers when singing if (GetClass() == BARD && spell_id != casting_spell_id && timer != 0xFFFFFFFF) { CastToClient()->GetPTimers().Start(timer, timer_duration); - LogSpells("Spell [{}]: Setting bard disciple reuse timer from spell finished [{}] to [{}]", spell_id, timer, timer_duration); + LogSpells("Spell [{}]: Setting BARD custom reuse timer [{}] to [{}]", spell_id, casting_spell_timer, casting_spell_timer_duration); } - - if(casting_spell_aa_id) { - AA::Rank *rank = zone->GetAlternateAdvancementRank(casting_spell_aa_id); - - if(rank && rank->base_ability) { - ExpendAlternateAdvancementCharge(rank->base_ability->id); - } + //handles AA and Discipline recast timers + else if (spell_id == casting_spell_id && casting_spell_timer != 0xFFFFFFFF) + { + CastToClient()->GetPTimers().Start(casting_spell_timer, casting_spell_timer_duration); + LogSpells("Spell [{}]: Setting custom reuse timer [{}] to [{}]", spell_id, casting_spell_timer, casting_spell_timer_duration); } else if(spell_id == casting_spell_id && casting_spell_timer != 0xFFFFFFFF) { - //aa new todo: aa expendable charges here CastToClient()->GetPTimers().Start(casting_spell_timer, casting_spell_timer_duration); LogSpells("Spell [{}]: Setting custom reuse timer [{}] to [{}]", spell_id, casting_spell_timer, casting_spell_timer_duration); }