[Core, Creature] Implement Creature/Pet Interrupts
This commit is contained in:
@@ -110,6 +110,10 @@ void CombatAI::UpdateAI(const uint32 diff)
|
||||
else
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs)
|
||||
{
|
||||
events.RescheduleEvent(spellId, msTime);
|
||||
}
|
||||
|
||||
/////////////////
|
||||
//CasterAI
|
||||
|
||||
@@ -46,6 +46,7 @@ class CombatAI : public CreatureAI
|
||||
void EnterCombat(Unit* who);
|
||||
void JustDied(Unit* killer);
|
||||
void UpdateAI(const uint32 diff);
|
||||
void SpellInterrupted(uint32 spellId, uint32 unTimeMs);
|
||||
static int Permissible(const Creature*);
|
||||
protected:
|
||||
EventMap events;
|
||||
|
||||
@@ -241,6 +241,10 @@ class UnitAI
|
||||
|
||||
// Called when the unit heals
|
||||
virtual void HealDone(Unit* /*done_to*/, uint32& /*addhealth*/) {}
|
||||
|
||||
// Called when a spell is interrupted by Spell::EffectInterruptCast
|
||||
// Use to reschedule next planned cast of spell.
|
||||
virtual void SpellInterrupted(uint32 /*spellId*/, uint32 /*unTimeMs*/) {}
|
||||
|
||||
void AttackStartCaster(Unit* victim, float dist);
|
||||
|
||||
|
||||
@@ -1308,7 +1308,7 @@ bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool trigger
|
||||
//Silenced so we can't cast
|
||||
if (!triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
|
||||
return false;
|
||||
|
||||
|
||||
//Check for power
|
||||
if (!triggered && me->GetPower((Powers)spell->PowerType) < spell->CalcPowerCost(me, spell->GetSchoolMask()))
|
||||
return false;
|
||||
@@ -1316,6 +1316,10 @@ bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool trigger
|
||||
//Unit is out of range of this spell
|
||||
if (!me->IsInRange(target, spell->GetMinRange(false), spell->GetMaxRange(false)))
|
||||
return false;
|
||||
|
||||
//Spell is on cooldown
|
||||
if (me->HasSpellCooldown(spell->Id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user