fix(Core/Unit): ranged auto-attack sound issue if a player attacks target not in LOS (#3610)

This commit is contained in:
Goatform
2020-11-07 18:23:42 +01:00
committed by GitHub
parent 9da3939c2d
commit 5254aec645
+33 -14
View File
@@ -3213,36 +3213,55 @@ void Unit::_UpdateSpells(uint32 time)
void Unit::_UpdateAutoRepeatSpell() void Unit::_UpdateAutoRepeatSpell()
{ {
// check "realtime" interrupts SpellInfo const* spellProto = nullptr;
if ((GetTypeId() == TYPEID_PLAYER && ToPlayer()->isMoving()) || IsNonMeleeSpellCast(false, false, true, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == 75)) if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL])
{ {
// cancel wand shoot spellProto = m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo;
if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != 75) }
InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
if (!spellProto)
{
return;
}
static uint32 const HUNTER_AUTOSHOOT = 75;
// Check "realtime" interrupts
if ((GetTypeId() == TYPEID_PLAYER && ToPlayer()->isMoving() && spellProto->Id != HUNTER_AUTOSHOOT) ||
IsNonMeleeSpellCast(false, false, true, spellProto->Id == HUNTER_AUTOSHOOT))
{
InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
m_AutoRepeatFirstCast = true; m_AutoRepeatFirstCast = true;
return; return;
} }
// apply delay (Auto Shot (spellID 75) not affected) // Apply delay (Hunter's autoshoot not affected)
if (m_AutoRepeatFirstCast && getAttackTimer(RANGED_ATTACK) < 500 && m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != 75) if (m_AutoRepeatFirstCast && getAttackTimer(RANGED_ATTACK) < 500 && spellProto->Id != HUNTER_AUTOSHOOT)
{
setAttackTimer(RANGED_ATTACK, 500); setAttackTimer(RANGED_ATTACK, 500);
}
m_AutoRepeatFirstCast = false; m_AutoRepeatFirstCast = false;
// castroutine // Check for ranged attack timer
if (isAttackReady(RANGED_ATTACK)) if (isAttackReady(RANGED_ATTACK))
{ {
// Check if able to cast SpellCastResult result = m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true);
if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true) != SPELL_CAST_OK) if (result != SPELL_CAST_OK)
{ {
InterruptSpell(CURRENT_AUTOREPEAT_SPELL); if (spellProto->Id != HUNTER_AUTOSHOOT)
{
InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
}
return; return;
} }
// we want to shoot // We want to shoot
Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, TRIGGERED_FULL_MASK); Spell* spell = new Spell(this, spellProto, TRIGGERED_FULL_MASK);
spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets)); spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
// all went good, reset attack // Reset attack
resetAttackTimer(RANGED_ATTACK); resetAttackTimer(RANGED_ATTACK);
} }
} }