mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
[Spells] Fix for AA and Discipline recast timers being set on spell casting failure. (#1971)
* recast timer updates * reworked * removed unneeded param * fix expendible AA * fixed * Update spells.cpp * [Spells] Fix for AA and Discipline recast timers being set on spell casting failure. don't check recasts from triggered spells.
This commit is contained in:
+46
-32
@@ -1227,65 +1227,65 @@ void Client::IncrementAlternateAdvancementRank(int rank_id) {
|
||||
void Client::ActivateAlternateAdvancementAbility(int rank_id, int target_id) {
|
||||
AA::Rank *rank = zone->GetAlternateAdvancementRank(rank_id);
|
||||
|
||||
if(!rank) {
|
||||
if (!rank) {
|
||||
return;
|
||||
}
|
||||
|
||||
AA::Ability *ability = rank->base_ability;
|
||||
if(!ability) {
|
||||
if (!ability) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!IsValidSpell(rank->spell)) {
|
||||
if (!IsValidSpell(rank->spell)) {
|
||||
return;
|
||||
}
|
||||
//do not allow AA to cast if your actively casting another AA.
|
||||
if (rank->spell == casting_spell_id && rank->id == casting_spell_aa_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CanUseAlternateAdvancementRank(rank)) {
|
||||
if (!CanUseAlternateAdvancementRank(rank)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool use_toggle_passive_hotkey = UseTogglePassiveHotkey(*rank);
|
||||
|
||||
//make sure it is not a passive
|
||||
if(!rank->effects.empty() && !use_toggle_passive_hotkey) {
|
||||
if (!rank->effects.empty() && !use_toggle_passive_hotkey) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 charges = 0;
|
||||
// We don't have the AA
|
||||
if (!GetAA(rank_id, &charges))
|
||||
if (!GetAA(rank_id, &charges)) {
|
||||
return;
|
||||
}
|
||||
//if expendable make sure we have charges
|
||||
if(ability->charges > 0 && charges < 1)
|
||||
if (ability->charges > 0 && charges < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
//check cooldown
|
||||
if(!p_timers.Expired(&database, rank->spell_type + pTimerAAStart, false)) {
|
||||
if (!p_timers.Expired(&database, rank->spell_type + pTimerAAStart, false)) {
|
||||
uint32 aaremain = p_timers.GetRemainingTime(rank->spell_type + pTimerAAStart);
|
||||
uint32 aaremain_hr = aaremain / (60 * 60);
|
||||
uint32 aaremain_min = (aaremain / 60) % 60;
|
||||
uint32 aaremain_sec = aaremain % 60;
|
||||
|
||||
if(aaremain_hr >= 1) {
|
||||
if (aaremain_hr >= 1) {
|
||||
Message(Chat::Red, "You can use this ability again in %u hour(s) %u minute(s) %u seconds",
|
||||
aaremain_hr, aaremain_min, aaremain_sec);
|
||||
aaremain_hr, aaremain_min, aaremain_sec);
|
||||
}
|
||||
else {
|
||||
Message(Chat::Red, "You can use this ability again in %u minute(s) %u seconds",
|
||||
aaremain_min, aaremain_sec);
|
||||
aaremain_min, aaremain_sec);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//calculate cooldown
|
||||
int cooldown = rank->recast_time - GetAlternateAdvancementCooldownReduction(rank);
|
||||
if(cooldown < 0) {
|
||||
cooldown = 0;
|
||||
}
|
||||
|
||||
if (!IsCastWhileInvis(rank->spell))
|
||||
if (!IsCastWhileInvis(rank->spell)) {
|
||||
CommonBreakInvisible();
|
||||
}
|
||||
|
||||
if (spells[rank->spell].sneak && (!hidden || (hidden && (Timer::GetCurrentTime() - tmHidden) < 4000))) {
|
||||
MessageString(Chat::SpellFailure, SNEAK_RESTRICT);
|
||||
@@ -1293,13 +1293,15 @@ void Client::ActivateAlternateAdvancementAbility(int rank_id, int target_id) {
|
||||
}
|
||||
//
|
||||
// Modern clients don't require pet targeted for AA casts that are ST_Pet
|
||||
if (spells[rank->spell].target_type == ST_Pet || spells[rank->spell].target_type == ST_SummonedPet)
|
||||
if (spells[rank->spell].target_type == ST_Pet || spells[rank->spell].target_type == ST_SummonedPet) {
|
||||
target_id = GetPetID();
|
||||
}
|
||||
|
||||
// extra handling for cast_not_standing spells
|
||||
if (!IgnoreCastingRestriction(rank->spell)) {
|
||||
if (GetAppearance() == eaSitting) // we need to stand!
|
||||
if (GetAppearance() == eaSitting) { // we need to stand!
|
||||
SetAppearance(eaStanding, false);
|
||||
}
|
||||
|
||||
if (GetAppearance() != eaStanding) {
|
||||
MessageString(Chat::SpellFailure, STAND_TO_CAST);
|
||||
@@ -1312,24 +1314,35 @@ void Client::ActivateAlternateAdvancementAbility(int rank_id, int target_id) {
|
||||
}
|
||||
else {
|
||||
// Bards can cast instant cast AAs while they are casting or channeling item cast.
|
||||
if (GetClass() == BARD && IsCasting() && spells[rank->spell].cast_time == 0) {
|
||||
if (GetClass() == BARD && IsCasting() && spells[rank->spell].cast_time == 0) {
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
ExpendAlternateAdvancementCharge(ability->id);
|
||||
SpellFinished(rank->spell, entity_list.GetMob(target_id), EQ::spells::CastingSlot::AltAbility, spells[rank->spell].mana, -1, spells[rank->spell].resist_difficulty, false, -1, false, rank->id);
|
||||
}
|
||||
//Known issue: If you attempt to give a Bard an AA with a cast time, the cast timer will not display on the client (no live bard AA have cast time).
|
||||
else {
|
||||
if (!CastSpell(rank->spell, target_id, EQ::spells::CastingSlot::AltAbility, -1, -1, 0, -1, rank->spell_type + pTimerAAStart, cooldown, nullptr, rank->id)) {
|
||||
return;
|
||||
}
|
||||
CastSpell(rank->spell, target_id, EQ::spells::CastingSlot::AltAbility, -1, -1, 0, -1, 0xFFFFFFFF, 0, nullptr, rank->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CastToClient()->GetPTimers().Start(rank->spell_type + pTimerAAStart, cooldown);
|
||||
SendAlternateAdvancementTimer(rank->spell_type, 0, 0);
|
||||
void Client::SetAARecastTimer(AA::Rank *rank_in, int32 spell_id) {
|
||||
|
||||
if (!rank_in) {
|
||||
return;
|
||||
}
|
||||
|
||||
//calculate AA cooldown
|
||||
int timer_duration = rank_in->recast_time - GetAlternateAdvancementCooldownReduction(rank_in);
|
||||
|
||||
if (timer_duration <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CastToClient()->GetPTimers().Start(rank_in->spell_type + pTimerAAStart, timer_duration);
|
||||
CastToClient()->SendAlternateAdvancementTimer(rank_in->spell_type, 0, 0);
|
||||
LogSpells("Spell [{}]: Setting AA reuse timer [{}] to [{}]", spell_id, rank_in->spell_type + pTimerAAStart, timer_duration);
|
||||
}
|
||||
|
||||
int Mob::GetAlternateAdvancementCooldownReduction(AA::Rank *rank_in) {
|
||||
@@ -1363,6 +1376,7 @@ int Mob::GetAlternateAdvancementCooldownReduction(AA::Rank *rank_in) {
|
||||
}
|
||||
|
||||
void Mob::ExpendAlternateAdvancementCharge(uint32 aa_id) {
|
||||
|
||||
for (auto &iter : aa_ranks) {
|
||||
AA::Ability *ability = zone->GetAlternateAdvancementAbility(iter.first);
|
||||
if (ability && aa_id == ability->id) {
|
||||
|
||||
Reference in New Issue
Block a user