mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-17 21:50:50 -04:00
Core/Spells: Autorepeat casting fixes
* Fixed cast bars of ranged spells not disappearing when canceled while autoshooting * Replaced hacky 500ms delay on non auto shot autorepeat spells with native spell cast time (wands have 500ms cast time) * Update cooldowns before attempting to cast autorepeat spells (for cases when cooldown ends on the same server tick as cast attempt)
This commit is contained in:
@@ -299,7 +299,7 @@ SpellNonMeleeDamage::SpellNonMeleeDamage(Unit* _attacker, Unit* _target, SpellIn
|
||||
|
||||
Unit::Unit(bool isWorldObject) :
|
||||
WorldObject(isWorldObject), m_lastSanctuaryTime(0), LastCharmerGUID(), movespline(new Movement::MoveSpline()),
|
||||
m_ControlledByPlayer(false), m_AutoRepeatFirstCast(false), m_procDeep(0), m_transformSpell(0),
|
||||
m_ControlledByPlayer(false), m_procDeep(0), m_transformSpell(0),
|
||||
m_removedAurasCount(0), m_interruptMask(SpellAuraInterruptFlags::None), m_interruptMask2(SpellAuraInterruptFlags2::None),
|
||||
m_unitMovedByMe(nullptr), m_playerMovingMe(nullptr), m_charmer(nullptr), m_charmed(nullptr),
|
||||
i_motionMaster(new MotionMaster(this)), m_regenTimer(0), m_vehicle(nullptr),
|
||||
@@ -2721,6 +2721,8 @@ void Unit::_DeleteRemovedAuras()
|
||||
|
||||
void Unit::_UpdateSpells(uint32 time)
|
||||
{
|
||||
_spellHistory->Update();
|
||||
|
||||
if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL])
|
||||
_UpdateAutoRepeatSpell();
|
||||
|
||||
@@ -2774,8 +2776,6 @@ void Unit::_UpdateSpells(uint32 time)
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
_spellHistory->Update();
|
||||
}
|
||||
|
||||
void Unit::_UpdateAutoRepeatSpell()
|
||||
@@ -2789,17 +2789,11 @@ void Unit::_UpdateAutoRepeatSpell()
|
||||
// cancel wand shoot
|
||||
if (autoRepeatSpellInfo->Id != 75)
|
||||
InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
|
||||
m_AutoRepeatFirstCast = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// apply delay (Auto Shot (spellID 75) not affected)
|
||||
if (m_AutoRepeatFirstCast && getAttackTimer(RANGED_ATTACK) < 500 && autoRepeatSpellInfo->Id != 75)
|
||||
setAttackTimer(RANGED_ATTACK, 500);
|
||||
m_AutoRepeatFirstCast = false;
|
||||
|
||||
// castroutine
|
||||
if (isAttackReady(RANGED_ATTACK))
|
||||
if (isAttackReady(RANGED_ATTACK) && m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_PREPARING)
|
||||
{
|
||||
// Check if able to cast
|
||||
SpellCastResult result = m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true);
|
||||
@@ -2814,11 +2808,8 @@ void Unit::_UpdateAutoRepeatSpell()
|
||||
}
|
||||
|
||||
// we want to shoot
|
||||
Spell* spell = new Spell(this, autoRepeatSpellInfo, TRIGGERED_FULL_MASK);
|
||||
Spell* spell = new Spell(this, autoRepeatSpellInfo, TRIGGERED_IGNORE_GCD);
|
||||
spell->prepare(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets);
|
||||
|
||||
// all went good, reset attack
|
||||
resetAttackTimer(RANGED_ATTACK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2831,14 +2822,13 @@ void Unit::SetCurrentCastSpell(Spell* pSpell)
|
||||
if (pSpell == m_currentSpells[CSpellType]) // avoid breaking self
|
||||
return;
|
||||
|
||||
// break same type spell if it is not delayed
|
||||
InterruptSpell(CSpellType, false);
|
||||
|
||||
// special breakage effects:
|
||||
switch (CSpellType)
|
||||
{
|
||||
case CURRENT_GENERIC_SPELL:
|
||||
{
|
||||
InterruptSpell(CURRENT_GENERIC_SPELL, false);
|
||||
|
||||
// generic spells always break channeled not delayed spells
|
||||
if (m_currentSpells[CURRENT_CHANNELED_SPELL] && !m_currentSpells[CURRENT_CHANNELED_SPELL]->GetSpellInfo()->HasAttribute(SPELL_ATTR5_ALLOW_ACTIONS_DURING_CHANNEL))
|
||||
InterruptSpell(CURRENT_CHANNELED_SPELL, false);
|
||||
@@ -2849,7 +2839,6 @@ void Unit::SetCurrentCastSpell(Spell* pSpell)
|
||||
// break autorepeat if not Auto Shot
|
||||
if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellInfo()->Id != 75)
|
||||
InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
|
||||
m_AutoRepeatFirstCast = true;
|
||||
}
|
||||
if (pSpell->GetCastTime() > 0)
|
||||
AddUnitState(UNIT_STATE_CASTING);
|
||||
@@ -2872,6 +2861,9 @@ void Unit::SetCurrentCastSpell(Spell* pSpell)
|
||||
}
|
||||
case CURRENT_AUTOREPEAT_SPELL:
|
||||
{
|
||||
if (m_currentSpells[CSpellType] && m_currentSpells[CSpellType]->getState() == SPELL_STATE_IDLE)
|
||||
m_currentSpells[CSpellType]->setState(SPELL_STATE_FINISHED);
|
||||
|
||||
// only Auto Shoot does not break anything
|
||||
if (pSpell->GetSpellInfo()->Id != 75)
|
||||
{
|
||||
@@ -2879,8 +2871,6 @@ void Unit::SetCurrentCastSpell(Spell* pSpell)
|
||||
InterruptSpell(CURRENT_GENERIC_SPELL, false);
|
||||
InterruptSpell(CURRENT_CHANNELED_SPELL, false);
|
||||
}
|
||||
// special action: set first cast flag
|
||||
m_AutoRepeatFirstCast = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user