[svn] Add UNIT_STAT_CASTING, and use it to update attack timer as test.

--HG--
branch : trunk
This commit is contained in:
megamage
2008-11-14 17:42:00 -06:00
parent bfa9e75161
commit 053b671cb5
3 changed files with 19 additions and 11 deletions

View File

@@ -2142,6 +2142,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura)
m_caster->SetCurrentCastedSpell( this );
m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]);
SendSpellStart();
m_caster->addUnitState(UNIT_STAT_CASTING);
}
}
@@ -2666,14 +2667,17 @@ void Spell::finish(bool ok)
if(!m_caster)
return;
if(IsChanneledSpell(m_spellInfo))
m_caster->UpdateInterruptMask();
if(m_spellState == SPELL_STATE_FINISHED)
return;
m_spellState = SPELL_STATE_FINISHED;
if(IsChanneledSpell(m_spellInfo))
m_caster->UpdateInterruptMask();
if(!m_caster->IsNonMeleeSpellCasted(false, false, true))
m_caster->clearUnitState(UNIT_STAT_CASTING);
//remove spell mods
if (m_caster->GetTypeId() == TYPEID_PLAYER)
((Player*)m_caster)->RemoveSpellMods(this);
@@ -2707,12 +2711,12 @@ void Spell::finish(bool ok)
}
}
if (IsMeleeAttackResetSpell())
/*if (IsMeleeAttackResetSpell())
{
m_caster->resetAttackTimer(BASE_ATTACK);
if(m_caster->haveOffhandWeapon())
m_caster->resetAttackTimer(OFF_ATTACK);
}
}*/
/*if (IsRangedAttackResetSpell())
m_caster->resetAttackTimer(RANGED_ATTACK);*/

View File

@@ -283,12 +283,15 @@ void Unit::Update( uint32 p_time )
}
}
if(uint32 base_att = getAttackTimer(BASE_ATTACK))
setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time) );
if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
setAttackTimer(RANGED_ATTACK, (p_time >= ranged_att ? 0 : ranged_att - p_time) );
if(uint32 off_att = getAttackTimer(OFF_ATTACK))
setAttackTimer(OFF_ATTACK, (p_time >= off_att ? 0 : off_att - p_time) );
if(!hasUnitState(UNIT_STAT_CASTING))
{
if(uint32 base_att = getAttackTimer(BASE_ATTACK))
setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time) );
if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
setAttackTimer(RANGED_ATTACK, (p_time >= ranged_att ? 0 : ranged_att - p_time) );
if(uint32 off_att = getAttackTimer(OFF_ATTACK))
setAttackTimer(OFF_ATTACK, (p_time >= off_att ? 0 : off_att - p_time) );
}
// update abilities available only for fraction of time
UpdateReactives( p_time );

View File

@@ -363,6 +363,7 @@ enum UnitState
UNIT_STAT_DISTRACTED = 0x1000,
UNIT_STAT_ISOLATED = 0x2000, // area auras do not affect other players
UNIT_STAT_ATTACK_PLAYER = 0x4000,
UNIT_STAT_CASTING = 0x8000,
UNIT_STAT_ALL_STATE = 0xffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT)
};