TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CasterAI Class Reference

#include <CombatAI.h>

Public Member Functions

 CasterAI (Creature *c)
 
void InitializeAI () override
 
void AttackStart (Unit *victim) override
 
void UpdateAI (uint32 diff) override
 
void EnterCombat (Unit *) override
 
- Public Member Functions inherited from CombatAI
 CombatAI (Creature *c)
 
void Reset () override
 
void JustDied (Unit *killer) override
 
void SpellInterrupted (uint32 spellId, uint32 unTimeMs) override
 
- Public Member Functions inherited from CreatureAI
void Talk (uint8 id, WorldObject const *whisperTarget=nullptr)
 
 CreatureAI (Creature *creature)
 
virtual ~CreatureAI ()
 
void MoveInLineOfSight_Safe (Unit *who)
 == Reactions At ================================= More...
 
void TriggerAlert (Unit const *who) const
 
virtual bool CanRespawn ()
 
virtual void EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
virtual void KilledUnit (Unit *)
 
virtual void JustSummoned (Creature *)
 
virtual void IsSummonedBy (Unit *)
 
virtual void SummonedCreatureDespawn (Creature *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
virtual void SpellHit (Unit *, SpellInfo const *)
 
virtual void SpellHitTarget (Unit *, SpellInfo const *)
 
virtual void AttackedBy (Unit *)
 
virtual bool IsEscorted () const
 
virtual void JustRespawned ()
 
virtual void MovementInform (uint32, uint32)
 
void OnCharmed (bool apply) override
 
virtual void JustReachedHome ()
 
void DoZoneInCombat (Creature *creature=NULL, float maxRangeToNearestTarget=50.0f)
 
virtual void ReceiveEmote (Player *, uint32)
 
virtual void OwnerAttackedBy (Unit *)
 
virtual void OwnerAttacked (Unit *)
 
virtual void CorpseRemoved (uint32 &)
 == Triggered Actions Requested ================== More...
 
virtual void PassengerBoarded (Unit *, int8, bool)
 == Fields ======================================= More...
 
virtual void OnSpellClick (Unit *, bool &)
 
virtual bool CanSeeAlways (WorldObject const *)
 
int32 VisualizeBoundary (uint32 duration, Unit *owner=nullptr, bool fill=false) const
 
virtual bool CheckInRoom ()
 
CreatureBoundary constGetBoundary () const
 
- Public Member Functions inherited from UnitAI
 UnitAI (Unit *unit)
 
virtual ~UnitAI ()
 
virtual bool CanAIAttack (Unit const *) const
 
virtual void DoAction (int32)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void SetGUID (ObjectGuid, int32=0)
 
virtual ObjectGuid GetGUID (int32=0) const
 
UnitSelectTarget (SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
 
template<class PREDICATE >
UnitSelectTarget (SelectAggroTarget targetType, uint32 position, PREDICATE const &predicate)
 
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectAggroTarget targetType, float dist=0.0f, bool playerOnly=false, int32 aura=0)
 
template<class PREDICATE >
void SelectTargetList (std::list< Unit * > &targetList, PREDICATE const &predicate, uint32 maxTargets, SelectAggroTarget targetType)
 
virtual void DamageDealt (Unit *, uint32 &, DamageEffectType)
 
virtual void DamageTaken (Unit *, uint32 &)
 
virtual void HealReceived (Unit *, uint32 &)
 
virtual void HealDone (Unit *, uint32 &)
 
void AttackStartCaster (Unit *victim, float dist)
 
void DoCast (uint32 spellId)
 
void DoCast (Unit *victim, uint32 spellId, bool triggered=false)
 
void DoCastVictim (uint32 spellId, bool triggered=false)
 
void DoCastAOE (uint32 spellId, bool triggered=false)
 
void DoMeleeAttackIfReady ()
 
bool DoSpellAttackIfReady (uint32 spellId)
 
virtual void sGossipHello (Player *)
 
virtual void sGossipSelect (Player *, uint32, uint32)
 
virtual void sGossipSelectCode (Player *, uint32, uint32, char const *)
 
virtual void sQuestAccept (Player *, Quest const *)
 
virtual void sQuestSelect (Player *, Quest const *)
 
virtual void sQuestReward (Player *, Quest const *, uint32)
 
virtual bool sOnDummyEffect (Unit *, uint32, SpellEffIndex)
 
virtual void sOnGameEvent (bool, uint16)
 

Private Attributes

float m_attackDist
 

Additional Inherited Members

- Public Types inherited from CreatureAI
enum  EvadeReason { EVADE_REASON_NO_HOSTILES, EVADE_REASON_BOUNDARY, EVADE_REASON_SEQUENCE_BREAK, EVADE_REASON_OTHER }
 
- Static Public Member Functions inherited from CombatAI
static int Permissible (Creature const *)
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 
- Static Public Attributes inherited from UnitAI
static AISpellInfoTypeAISpellInfo
 
- Protected Member Functions inherited from CreatureAI
bool UpdateVictim ()
 
bool UpdateVictimWithGaze ()
 
void SetGazeOn (Unit *target)
 
CreatureDoSummon (uint32 entry, Position const &pos, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummon (uint32 entry, WorldObject *obj, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummonFlyer (uint32 entry, WorldObject *obj, float flightZ, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
bool CheckBoundary (Position const *who=nullptr) const
 
void SetBoundary (CreatureBoundary const *boundary)
 
virtual void MoveInLineOfSight (Unit *)
 
bool _EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
- Protected Attributes inherited from CombatAI
EventMap events
 
SpellVct spells
 
- Protected Attributes inherited from CreatureAI
Creature *const me
 
CreatureBoundary const_boundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Constructor & Destructor Documentation

CasterAI::CasterAI ( Creature c)
inlineexplicit
CombatAI(Creature *c)
Definition: CombatAI.h:42
#define MELEE_RANGE
Definition: Object.h:48
float m_attackDist
Definition: CombatAI.h:67

Member Function Documentation

void CasterAI::AttackStart ( Unit victim)
inlineoverridevirtual

Reimplemented from UnitAI.

63 { AttackStartCaster(victim, m_attackDist); }
void AttackStartCaster(Unit *victim, float dist)
Definition: UnitAI.cpp:43
float m_attackDist
Definition: CombatAI.h:67

+ Here is the call graph for this function:

void CasterAI::EnterCombat ( Unit who)
overridevirtual

Reimplemented from CombatAI.

Reimplemented in npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI.

124 {
125  if (spells.empty())
126  return;
127 
128  uint32 spell = rand32() % spells.size();
129  uint32 count = 0;
130  for (SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr, ++count)
131  {
132  if (AISpellInfo[*itr].condition == AICOND_AGGRO)
133  me->CastSpell(who, *itr, false);
134  else if (AISpellInfo[*itr].condition == AICOND_COMBAT)
135  {
136  uint32 cooldown = GetAISpellInfo(*itr)->realCooldown;
137  if (count == spell)
138  {
139  DoCast(spells[spell]);
140  cooldown += me->GetCurrentSpellCastTime(*itr);
141  }
142  events.ScheduleEvent(*itr, cooldown);
143  }
144  }
145 }
static AISpellInfoType * AISpellInfo
Definition: UnitAI.h:250
SpellVct spells
Definition: CombatAI.h:55
uint32 realCooldown
Definition: CreatureAIImpl.h:62
EventMap events
Definition: CombatAI.h:54
Definition: CreatureAIImpl.h:48
Creature *const me
Definition: CreatureAI.h:71
uint32_t uint32
Definition: Define.h:150
void DoCast(uint32 spellId)
Definition: UnitAI.cpp:101
void ScheduleEvent(uint32 eventId, Milliseconds const &time, uint32 group=0, uint8 phase=0)
Definition: EventMap.h:123
Definition: CreatureAIImpl.h:49
uint32 rand32()
Definition: Random.cpp:64
AISpellInfoType * GetAISpellInfo(uint32 i)
Definition: CreatureAI.cpp:40
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
int32 GetCurrentSpellCastTime(uint32 spell_id) const
Definition: Unit.cpp:2939

+ Here is the call graph for this function:

void CasterAI::InitializeAI ( )
overridevirtual

Reimplemented from CombatAI.

Reimplemented in npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI, and npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI.

112 {
114 
115  m_attackDist = 30.0f;
116  for (SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr)
117  if (AISpellInfo[*itr].condition == AICOND_COMBAT && m_attackDist > GetAISpellInfo(*itr)->maxRange)
119  if (m_attackDist == 30.0f)
121 }
static AISpellInfoType * AISpellInfo
Definition: UnitAI.h:250
SpellVct spells
Definition: CombatAI.h:55
float maxRange
Definition: CreatureAIImpl.h:63
void InitializeAI() override
Definition: CombatAI.cpp:51
Definition: CreatureAIImpl.h:49
AISpellInfoType * GetAISpellInfo(uint32 i)
Definition: CreatureAI.cpp:40
#define MELEE_RANGE
Definition: Object.h:48
float m_attackDist
Definition: CombatAI.h:67

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CasterAI::UpdateAI ( uint32  diff)
overridevirtual

Reimplemented from CombatAI.

Reimplemented in npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI, and npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI.

148 {
149  if (!UpdateVictim())
150  return;
151 
152  events.Update(diff);
153 
155  {
156  me->InterruptNonMeleeSpells(false);
157  return;
158  }
159 
161  return;
162 
163  if (uint32 spellId = events.ExecuteEvent())
164  {
165  DoCast(spellId);
166  uint32 casttime = me->GetCurrentSpellCastTime(spellId);
167  events.ScheduleEvent(spellId, (casttime ? casttime : 500) + GetAISpellInfo(spellId)->realCooldown);
168  }
169 }
Unit * EnsureVictim() const
Definition: Unit.h:1381
bool UpdateVictim()
Definition: CreatureAI.cpp:233
EventMap events
Definition: CombatAI.h:54
Definition: Unit.h:565
Creature *const me
Definition: CreatureAI.h:71
Unit * GetVictim() const
Definition: Unit.h:1379
uint32_t uint32
Definition: Define.h:150
void DoCast(uint32 spellId)
Definition: UnitAI.cpp:101
bool HasBreakableByDamageCrowdControlAura(Unit *excludeCasterChannel=NULL) const
Definition: Unit.cpp:590
void ScheduleEvent(uint32 eventId, Milliseconds const &time, uint32 group=0, uint8 phase=0)
Definition: EventMap.h:123
void Update(uint32 time)
Definition: EventMap.h:54
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
uint32 ExecuteEvent()
Definition: EventMap.cpp:46
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
AISpellInfoType * GetAISpellInfo(uint32 i)
Definition: CreatureAI.cpp:40
int32 GetCurrentSpellCastTime(uint32 spell_id) const
Definition: Unit.cpp:2939

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

float CasterAI::m_attackDist
private

The documentation for this class was generated from the following files: