mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[9503] Updated behavior of auto shot according to the client changes.
Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
parent
ab74b20006
commit
53623696cc
4 changed files with 28 additions and 19 deletions
|
|
@ -3310,20 +3310,31 @@ void Unit::_UpdateSpells( uint32 time )
|
|||
|
||||
void Unit::_UpdateAutoRepeatSpell()
|
||||
{
|
||||
//check "realtime" interrupts
|
||||
if ( (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isMoving()) || IsNonMeleeSpellCasted(false,false,true) )
|
||||
bool isAutoShot = m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == SPELL_ID_AUTOSHOT;
|
||||
|
||||
//check movement
|
||||
if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isMoving())
|
||||
{
|
||||
// cancel wand shoot
|
||||
if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != SPELL_ID_AUTOSHOT)
|
||||
if(!isAutoShot)
|
||||
InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
|
||||
m_AutoRepeatFirstCast = true;
|
||||
// auto shot just waits
|
||||
return;
|
||||
}
|
||||
|
||||
//apply delay
|
||||
if ( m_AutoRepeatFirstCast && getAttackTimer(RANGED_ATTACK) < 500 )
|
||||
setAttackTimer(RANGED_ATTACK,500);
|
||||
m_AutoRepeatFirstCast = false;
|
||||
// check spell casts
|
||||
if (IsNonMeleeSpellCasted(false, false, true))
|
||||
{
|
||||
// cancel wand shoot
|
||||
if(!isAutoShot)
|
||||
{
|
||||
InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
|
||||
return;
|
||||
}
|
||||
// auto shot is delayed by everythihng, except ranged(!) CURRENT_GENERIC_SPELL's -> recheck that
|
||||
else if (!(m_currentSpells[CURRENT_GENERIC_SPELL] && m_currentSpells[CURRENT_GENERIC_SPELL]->IsRangedSpell()))
|
||||
return;
|
||||
}
|
||||
|
||||
//castroutine
|
||||
if (isAttackReady(RANGED_ATTACK))
|
||||
|
|
@ -3369,7 +3380,6 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
|
|||
// break autorepeat if not Auto Shot
|
||||
if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != SPELL_ID_AUTOSHOT)
|
||||
InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
|
||||
m_AutoRepeatFirstCast = true;
|
||||
}
|
||||
} break;
|
||||
|
||||
|
|
@ -3393,9 +3403,10 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
|
|||
// generic autorepeats break generic non-delayed and channeled non-delayed spells
|
||||
InterruptSpell(CURRENT_GENERIC_SPELL,false);
|
||||
InterruptSpell(CURRENT_CHANNELED_SPELL,false);
|
||||
// special action: first cast delay
|
||||
if ( getAttackTimer(RANGED_ATTACK) < 500 )
|
||||
setAttackTimer(RANGED_ATTACK,500);
|
||||
}
|
||||
// special action: set first cast flag
|
||||
m_AutoRepeatFirstCast = true;
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
|
@ -3415,14 +3426,14 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
|
|||
pSpell->m_selfContainer = &(m_currentSpells[pSpell->GetCurrentContainer()]);
|
||||
}
|
||||
|
||||
void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed)
|
||||
void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool sendAutoRepeatCancelToClient)
|
||||
{
|
||||
assert(spellType < CURRENT_MAX_SPELL);
|
||||
|
||||
if (m_currentSpells[spellType] && (withDelayed || m_currentSpells[spellType]->getState() != SPELL_STATE_DELAYED) )
|
||||
{
|
||||
// send autorepeat cancel message for autorepeat spells
|
||||
if (spellType == CURRENT_AUTOREPEAT_SPELL)
|
||||
if (spellType == CURRENT_AUTOREPEAT_SPELL && sendAutoRepeatCancelToClient)
|
||||
{
|
||||
if(GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)this)->SendAutoRepeatCancel(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue