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

#include <CombatAI.h>

Public Member Functions

 CombatAI (Creature *c)
 
void InitializeAI () override
 
void Reset () override
 
void EnterCombat (Unit *who) override
 
void JustDied (Unit *killer) override
 
void UpdateAI (uint32 diff) 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 AttackStart (Unit *)
 
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)
 

Static Public Member Functions

static int Permissible (Creature const *)
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 

Protected Attributes

EventMap events
 
SpellVct spells
 
- Protected Attributes inherited from CreatureAI
Creature *const me
 
CreatureBoundary const_boundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

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 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)
 

Constructor & Destructor Documentation

CombatAI::CombatAI ( Creature c)
inlineexplicit
42 : CreatureAI(c) { }
CreatureAI(Creature *creature)
Definition: CreatureAI.h:95

Member Function Documentation

void CombatAI::EnterCombat ( Unit who)
overridevirtual

Reimplemented from CreatureAI.

Reimplemented in npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI, and CasterAI.

73 {
74  for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
75  {
76  if (AISpellInfo[*i].condition == AICOND_AGGRO)
77  me->CastSpell(who, *i, false);
78  else if (AISpellInfo[*i].condition == AICOND_COMBAT)
79  events.ScheduleEvent(*i, AISpellInfo[*i].cooldown + rand32() % AISpellInfo[*i].cooldown);
80  }
81 }
static AISpellInfoType * AISpellInfo
Definition: UnitAI.h:250
SpellVct spells
Definition: CombatAI.h:55
EventMap events
Definition: CombatAI.h:54
Definition: CreatureAIImpl.h:48
Creature *const me
Definition: CreatureAI.h:71
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
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

+ Here is the call graph for this function:

void CombatAI::InitializeAI ( )
overridevirtual

Reimplemented from UnitAI.

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

52 {
53  for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
54  if (me->m_spells[i] && sSpellMgr->GetSpellInfo(me->m_spells[i]))
55  spells.push_back(me->m_spells[i]);
56 
58 }
SpellVct spells
Definition: CombatAI.h:55
#define CREATURE_MAX_SPELLS
Definition: Creature.h:75
virtual void InitializeAI()
Definition: UnitAI.h:130
Creature *const me
Definition: CreatureAI.h:71
uint32 m_spells[CREATURE_MAX_SPELLS]
Definition: Creature.h:602
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CombatAI::JustDied ( Unit killer)
overridevirtual

Reimplemented from CreatureAI.

Reimplemented in npc_gothik_minion::npc_gothik_minionAI, and npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI.

66 {
67  for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
68  if (AISpellInfo[*i].condition == AICOND_DIE)
69  me->CastSpell(killer, *i, true);
70 }
static AISpellInfoType * AISpellInfo
Definition: UnitAI.h:250
SpellVct spells
Definition: CombatAI.h:55
Creature *const me
Definition: CreatureAI.h:71
Definition: CreatureAIImpl.h:50
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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int CombatAI::Permissible ( Creature const )
inlinestatic
51 { return PERMIT_BASE_NO; }
Definition: CreatureAI.h:207
void CombatAI::Reset ( )
overridevirtual

Reimplemented from UnitAI.

Reimplemented in npc_death_knight_initiate::npc_death_knight_initiateAI, and npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI.

61 {
62  events.Reset();
63 }
EventMap events
Definition: CombatAI.h:54
void Reset()
Definition: EventMap.cpp:20

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CombatAI::SpellInterrupted ( uint32  ,
uint32   
)
overridevirtual

Called when a spell is interrupted by Spell::EffectInterruptCast Use to reschedule next planned cast of spell.

Reimplemented from UnitAI.

103 {
104  events.RescheduleEvent(spellId, unTimeMs);
105 }
EventMap events
Definition: CombatAI.h:54
void RescheduleEvent(uint32 eventId, Milliseconds const &time, uint32 group=0, uint8 phase=0)
Definition: EventMap.h:146

+ Here is the call graph for this function:

void CombatAI::UpdateAI ( uint32  diff)
overridevirtual

Implements UnitAI.

Reimplemented in npc_death_knight_initiate::npc_death_knight_initiateAI, npc_gothik_minion::npc_gothik_minionAI, npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI, npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI, and CasterAI.

84 {
85  if (!UpdateVictim())
86  return;
87 
88  events.Update(diff);
89 
91  return;
92 
93  if (uint32 spellId = events.ExecuteEvent())
94  {
95  DoCast(spellId);
96  events.ScheduleEvent(spellId, AISpellInfo[spellId].cooldown + rand32() % AISpellInfo[spellId].cooldown);
97  }
98  else
100 }
static AISpellInfoType * AISpellInfo
Definition: UnitAI.h:250
bool UpdateVictim()
Definition: CreatureAI.cpp:233
EventMap events
Definition: CombatAI.h:54
Definition: Unit.h:565
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
void Update(uint32 time)
Definition: EventMap.h:54
uint32 ExecuteEvent()
Definition: EventMap.cpp:46
uint32 rand32()
Definition: Random.cpp:64
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:49
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

EventMap CombatAI::events
protected
SpellVct CombatAI::spells
protected

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