TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI Struct Reference

Public Member Functions

 npc_pet_mage_mirror_imageAI (Creature *creature)
 
void Init ()
 
bool IsInThreatList (Unit *target)
 
void InitializeAI () override
 
void EnterCombat (Unit *who) override
 
void Reset () override
 
void UpdateAI (uint32 diff) override
 
void EnterEvadeMode (EvadeReason) override
 
- Public Member Functions inherited from CasterAI
 CasterAI (Creature *c)
 
void AttackStart (Unit *victim) override
 
- Public Member Functions inherited from CombatAI
 CombatAI (Creature *c)
 
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 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)
 

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

npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI::npc_pet_mage_mirror_imageAI ( Creature creature)
inline
54 : CasterAI(creature) { }
CasterAI(Creature *c)
Definition: CombatAI.h:61

Member Function Documentation

void npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI::EnterCombat ( Unit who)
inlineoverridevirtual

Reimplemented from CasterAI.

161  {
163  {
164  me->CastSpell(who, SPELL_MAGE_FIRE_BLAST, false);
167  }
168  else
170  }
EventMap events
Definition: CombatAI.h:54
Definition: pet_mage.cpp:36
Definition: pet_mage.cpp:37
Definition: pet_mage.cpp:42
void EnterEvadeMode(EvadeReason) override
Definition: pet_mage.cpp:235
Creature *const me
Definition: CreatureAI.h:71
Definition: CreatureAI.h:90
Unit * GetVictim() const
Definition: Unit.h:1379
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 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
Definition: pet_mage.cpp:44

+ Here is the call graph for this function:

void npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI::EnterEvadeMode ( EvadeReason  )
inlineoverridevirtual

Reimplemented from CreatureAI.

236  {
237  if (me->IsInEvadeMode() || !me->IsAlive())
238  return;
239 
240  Unit* owner = me->GetCharmerOrOwner();
241 
242  me->CombatStop(true);
243  if (owner && !me->HasUnitState(UNIT_STATE_FOLLOW))
244  {
245  me->GetMotionMaster()->Clear(false);
247  }
248  Init();
249  }
void Clear(bool reset=true)
Definition: MotionMaster.h:138
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool IsInEvadeMode() const
Definition: Creature.h:520
Definition: MotionMaster.h:61
Creature *const me
Definition: CreatureAI.h:71
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
Definition: Unit.h:559
bool IsAlive() const
Definition: Unit.h:1692
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
Definition: Unit.h:1305
virtual float GetFollowAngle() const
Definition: Unit.h:2194
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:265

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI::Init ( )
inline
57  {
58  Unit* owner = me->GetCharmerOrOwner();
59 
60  std::list<Unit*> targets;
63  me->VisitNearbyObject(40.0f, searcher);
64 
65  Unit* highestThreatUnit = nullptr;
66  float highestThreat = 0.0f;
67  Unit* nearestPlayer = nullptr;
68  for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
69  {
70  // Consider only units without CC
71  if (!(*iter)->HasBreakableByDamageCrowdControlAura((*iter)))
72  {
73  // Take first found unit
74  if (!highestThreatUnit && (*iter)->GetTypeId() != TYPEID_PLAYER)
75  {
76  highestThreatUnit = (*iter);
77  continue;
78  }
79  if (!nearestPlayer && ((*iter)->GetTypeId() == TYPEID_PLAYER))
80  {
81  nearestPlayer = (*iter);
82  continue;
83  }
84  // else compare best fit unit with current unit
86  for (ThreatContainer::StorageType::const_iterator trig_citr = triggers.begin(); trig_citr != triggers.end(); ++trig_citr)
87  {
88  // Try to find threat referenced to owner
89  if ((*trig_citr)->getTarget() == owner)
90  {
91  // Check if best fit hostile unit hs lower threat than this current unit
92  if (highestThreat < (*trig_citr)->getThreat())
93  {
94  // If so, update best fit unit
95  highestThreat = (*trig_citr)->getThreat();
96  highestThreatUnit = (*iter);
97  break;
98  }
99  }
100  }
101  // In case no unit with threat was found so far, always check for nearest unit (only for players)
102  if ((*iter)->GetTypeId() == TYPEID_PLAYER)
103  {
104  // If this player is closer than the previous one, update it
105  if (me->GetDistance((*iter)->GetPosition()) < me->GetDistance(nearestPlayer->GetPosition()))
106  nearestPlayer = (*iter);
107  }
108  }
109  }
110  // Prioritize units with threat referenced to owner
111  if (highestThreat > 0.0f && highestThreatUnit)
112  me->Attack(highestThreatUnit, false);
113  // If there is no such target, try to attack nearest hostile unit if such exists
114  else if (nearestPlayer)
115  me->Attack(nearestPlayer, false);
116  }
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:7222
ThreatContainer::StorageType const & getThreatList() const
Definition: ThreatManager.h:263
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:587
Definition: GridNotifiers.h:410
Creature *const me
Definition: CreatureAI.h:71
TypeID GetTypeId() const
Definition: Object.h:113
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
void GetPosition(float &x, float &y) const
Definition: Position.h:109
Definition: ObjectGuid.h:33
std::list< HostileReference * > StorageType
Definition: ThreatManager.h:149
ThreatManager & getThreatManager()
Definition: Unit.h:1998
Definition: GridNotifiers.h:797
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI::InitializeAI ( )
inlineoverridevirtual

Reimplemented from CasterAI.

148  {
150  Unit* owner = me->GetOwner();
151  if (!owner)
152  return;
153 
154  // here mirror image casts on summoner spell (not present in client dbc) 49866
155  // here should be auras (not present in client dbc): 35657, 35658, 35659, 35660 selfcast by mirror images (stats related?)
156  // Clone Me!
157  owner->CastSpell(me, SPELL_MAGE_CLONE_ME, false);
158  }
void InitializeAI() override
Definition: CombatAI.cpp:111
Definition: pet_mage.cpp:34
Creature *const me
Definition: CreatureAI.h:71
Unit * GetOwner() const
Definition: Unit.cpp:7542
Definition: Unit.h:1305
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:

bool npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI::IsInThreatList ( Unit target)
inline
119  {
120  Unit* owner = me->GetCharmerOrOwner();
121 
122  std::list<Unit*> targets;
125  me->VisitNearbyObject(40.0f, searcher);
126 
127  for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
128  {
129  if ((*iter) == target)
130  {
131  // Consider only units without CC
132  if (!(*iter)->HasBreakableByDamageCrowdControlAura((*iter)))
133  {
134  ThreatContainer::StorageType triggers = (*iter)->getThreatManager().getThreatList();
135  for (ThreatContainer::StorageType::const_iterator trig_citr = triggers.begin(); trig_citr != triggers.end(); ++trig_citr)
136  {
137  // Try to find threat referenced to owner
138  if ((*trig_citr)->getTarget() == owner)
139  return true;
140  }
141  }
142  }
143  }
144  return false;
145  }
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:587
Definition: GridNotifiers.h:410
Creature *const me
Definition: CreatureAI.h:71
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
std::list< HostileReference * > StorageType
Definition: ThreatManager.h:149
Definition: GridNotifiers.h:797
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI::Reset ( )
inlineoverridevirtual

Reimplemented from CombatAI.

173  {
174  events.Reset();
175  }
EventMap events
Definition: CombatAI.h:54
void Reset()
Definition: EventMap.cpp:20

+ Here is the call graph for this function:

void npc_pet_mage_mirror_image::npc_pet_mage_mirror_imageAI::UpdateAI ( uint32  diff)
inlineoverridevirtual

Reimplemented from CasterAI.

178  {
179  Unit* owner = me->GetCharmerOrOwner();
180  if (!owner)
181  return;
182 
183  Unit* target = owner->getAttackerForHelper();
184 
185  events.Update(diff);
186 
187  // prevent CC interrupts by images
189  {
190  me->InterruptNonMeleeSpells(false);
191  return;
192  }
193 
195  return;
196 
197  // assign target if image doesnt have any or the target is not actual
198  if (!target || me->GetVictim() != target)
199  {
200  Unit* ownerTarget = nullptr;
201  if (Player* owner = me->GetCharmerOrOwner()->ToPlayer())
202  ownerTarget = owner->GetSelectedUnit();
203 
204  // recognize which victim will be choosen
205  if (ownerTarget && ownerTarget->GetTypeId() == TYPEID_PLAYER)
206  {
207  if (!ownerTarget->HasBreakableByDamageCrowdControlAura(ownerTarget))
208  me->Attack(ownerTarget, false);
209  }
210  else if (ownerTarget && (ownerTarget->GetTypeId() != TYPEID_PLAYER) && IsInThreatList(ownerTarget))
211  {
212  if (!ownerTarget->HasBreakableByDamageCrowdControlAura(ownerTarget))
213  me->Attack(ownerTarget, false);
214  }
215  else
216  Init();
217  }
218 
219  if (uint32 spellId = events.ExecuteEvent())
220  {
221  if (spellId == SPELL_MAGE_FROST_BOLT)
222  {
224  DoCastVictim(spellId);
225  }
226  else if (spellId == SPELL_MAGE_FIRE_BLAST)
227  {
228  DoCastVictim(spellId);
230  }
231  }
232  }
Unit * EnsureVictim() const
Definition: Unit.h:1381
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:7222
EventMap events
Definition: CombatAI.h:54
Definition: pet_mage.cpp:36
Definition: Unit.h:565
Definition: pet_mage.cpp:37
Player * ToPlayer()
Definition: Object.h:191
Creature *const me
Definition: CreatureAI.h:71
TypeID GetTypeId() const
Definition: Object.h:113
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
Unit * GetVictim() const
Definition: Unit.h:1379
uint32_t uint32
Definition: Define.h:150
Definition: pet_mage.cpp:43
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
Definition: ObjectGuid.h:33
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
uint32 ExecuteEvent()
Definition: EventMap.cpp:46
Unit * getAttackerForHelper() const
Definition: Unit.cpp:7211
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition: UnitAI.cpp:159
Definition: Unit.h:1305
bool IsInThreatList(Unit *target)
Definition: pet_mage.cpp:118
Definition: pet_mage.cpp:44

+ Here is the call graph for this function:


The documentation for this struct was generated from the following file: