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

Public Member Functions

 guard_genericAI (Creature *creature)
 
void Initialize ()
 
void Reset () override
 
void EnterCombat (Unit *who) override
 
void UpdateAI (uint32 diff) override
 
void DoReplyToTextEmote (uint32 emote)
 
void ReceiveEmote (Player *player, uint32 textEmote) override
 
- Public Member Functions inherited from GuardAI
 GuardAI (Creature *creature)
 
bool CanSeeAlways (WorldObject const *obj) override
 
void EnterEvadeMode (EvadeReason) override
 
void JustDied (Unit *killer) override
 
- Public Member Functions inherited from ScriptedAI
 ScriptedAI (Creature *creature)
 
virtual ~ScriptedAI ()
 
void AttackStartNoMove (Unit *target)
 
void DamageTaken (Unit *, uint32 &) override
 
void JustDied (Unit *) override
 
void KilledUnit (Unit *) override
 
void JustSummoned (Creature *) override
 
void SummonedCreatureDespawn (Creature *) override
 
void SpellHit (Unit *, SpellInfo const *) override
 
void SpellHitTarget (Unit *, SpellInfo const *) override
 
void OnPossess (bool)
 
void AttackStart (Unit *) override
 
void DoStartMovement (Unit *target, float distance=0.0f, float angle=0.0f)
 
void DoStartNoMovement (Unit *target)
 
void DoStopAttack ()
 
void DoCastSpell (Unit *target, SpellInfo const *spellInfo, bool triggered=false)
 
void DoPlaySoundToSet (WorldObject *source, uint32 soundId)
 
void DoResetThreat ()
 
float DoGetThreat (Unit *unit)
 
void DoModifyThreatPercent (Unit *unit, int32 pct)
 
void DoTeleportTo (float x, float y, float z, uint32 time=0)
 
void DoTeleportTo (float const pos[4])
 
void DoTeleportPlayer (Unit *unit, float x, float y, float z, float o)
 
void DoTeleportAll (float x, float y, float z, float o)
 
UnitDoSelectLowestHpFriendly (float range, uint32 minHPDiff=1)
 
std::list< Creature * > DoFindFriendlyCC (float range)
 
std::list< Creature * > DoFindFriendlyMissingBuff (float range, uint32 spellId)
 
PlayerGetPlayerAtMinimumRange (float minRange)
 
CreatureDoSpawnCreature (uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
 
bool HealthBelowPct (uint32 pct) const
 
bool HealthAbovePct (uint32 pct) const
 
SpellInfo constSelectSpell (Unit *target, uint32 school, uint32 mechanic, SelectTargetType targets, float rangeMin, float rangeMax, SelectEffect effect)
 
void SetEquipmentSlots (bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
 
void SetCombatMovement (bool allowMovement)
 
bool IsCombatMovementAllowed () const
 
bool IsHeroic () const
 
Difficulty GetDifficulty () const
 
bool Is25ManRaid () const
 
template<class T >
const T & DUNGEON_MODE (const T &normal5, const T &heroic10) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25, const T &heroic10, const T &heroic25) const
 
- 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 IsSummonedBy (Unit *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
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 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 &)
 
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 InitializeAI ()
 
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 HealReceived (Unit *, uint32 &)
 
virtual void HealDone (Unit *, uint32 &)
 
virtual void SpellInterrupted (uint32, 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

uint32 globalCooldown
 
uint32 buffTimer
 

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 GuardAI
static int Permissible (Creature const *creature)
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 
- Public Attributes inherited from ScriptedAI
bool IsFleeing
 
- 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 CreatureAI
Creature *const me
 
CreatureBoundary const_boundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Constructor & Destructor Documentation

guard_generic::guard_genericAI::guard_genericAI ( Creature creature)
inline
57  : GuardAI(creature)
58  {
59  Initialize();
60  }
GuardAI(Creature *creature)
Definition: GuardAI.cpp:31
void Initialize()
Definition: guards.cpp:62

+ Here is the call graph for this function:

Member Function Documentation

void guard_generic::guard_genericAI::DoReplyToTextEmote ( uint32  emote)
inline
204  {
205  switch (emote)
206  {
207  case TEXT_EMOTE_KISS:
209  break;
210 
211  case TEXT_EMOTE_WAVE:
213  break;
214 
215  case TEXT_EMOTE_SALUTE:
217  break;
218 
219  case TEXT_EMOTE_SHY:
221  break;
222 
223  case TEXT_EMOTE_RUDE:
224  case TEXT_EMOTE_CHICKEN:
226  break;
227  }
228  }
Definition: SharedDefines.h:2433
Definition: SharedDefines.h:2414
Definition: SharedDefines.h:2435
Definition: SharedDefines.h:2460
Definition: SharedDefines.h:2253
Creature *const me
Definition: CreatureAI.h:71
Definition: SharedDefines.h:2236
Definition: SharedDefines.h:2210
Definition: SharedDefines.h:2230
void HandleEmoteCommand(uint32 anim_id)
Definition: Unit.cpp:1444
Definition: SharedDefines.h:2415
Definition: SharedDefines.h:2229
Definition: SharedDefines.h:2174

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void guard_generic::guard_genericAI::EnterCombat ( Unit who)
inlineoverridevirtual

Reimplemented from ScriptedAI.

74  {
77  if (SpellInfo const* spell = me->reachWithSpellAttack(who))
78  DoCast(who, spell->Id);
79  }
Definition: SpellInfo.h:326
Definition: guards.cpp:44
Creature *const me
Definition: CreatureAI.h:71
void DoCast(uint32 spellId)
Definition: UnitAI.cpp:101
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:42
Definition: guards.cpp:42
uint32 GetEntry() const
Definition: Object.h:107
SpellInfo const * reachWithSpellAttack(Unit *victim)
Definition: Creature.cpp:1841

+ Here is the call graph for this function:

void guard_generic::guard_genericAI::Initialize ( void  )
inline
63  {
64  globalCooldown = 0;
65  buffTimer = 0;
66  }
uint32 globalCooldown
Definition: guards.cpp:249
uint32 buffTimer
Definition: guards.cpp:250

+ Here is the caller graph for this function:

void guard_generic::guard_genericAI::ReceiveEmote ( Player player,
uint32  textEmote 
)
inlineoverridevirtual

Reimplemented from CreatureAI.

231  {
232  switch (me->GetEntry())
233  {
236  case NPC_ORGRIMMAR_GRUNT:
237  break;
238  default:
239  return;
240  }
241 
242  if (!me->IsFriendlyTo(player))
243  return;
244 
245  DoReplyToTextEmote(textEmote);
246  }
void DoReplyToTextEmote(uint32 emote)
Definition: guards.cpp:203
Creature *const me
Definition: CreatureAI.h:71
Definition: guards.cpp:46
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
Definition: guards.cpp:45
Definition: guards.cpp:47
uint32 GetEntry() const
Definition: Object.h:107

+ Here is the call graph for this function:

void guard_generic::guard_genericAI::Reset ( )
inlineoverridevirtual

Reimplemented from ScriptedAI.

69  {
70  Initialize();
71  }
void Initialize()
Definition: guards.cpp:62

+ Here is the call graph for this function:

void guard_generic::guard_genericAI::UpdateAI ( uint32  diff)
inlineoverridevirtual

Reimplemented from ScriptedAI.

82  {
83  //Always decrease our global cooldown first
84  if (globalCooldown > diff)
85  globalCooldown -= diff;
86  else
87  globalCooldown = 0;
88 
89  //Buff timer (only buff when we are alive and not in combat
90  if (me->IsAlive() && !me->IsInCombat())
91  {
92  if (buffTimer <= diff)
93  {
94  //Find a spell that targets friendly and applies an aura (these are generally buffs)
96 
97  if (info && !globalCooldown)
98  {
99  //Cast the buff spell
100  DoCast(me, info->Id);
101 
102  //Set our global cooldown
104 
105  //Set our timer to 10 minutes before rebuff
106  buffTimer = 600000;
107  } //Try again in 30 seconds
108  else buffTimer = 30000;
109  } else buffTimer -= diff;
110  }
111 
112  //Return since we have no target
113  if (!UpdateVictim())
114  return;
115 
116  // Make sure our attack is ready and we arn't currently casting
117  if (me->isAttackReady() && !me->IsNonMeleeSpellCast(false))
118  {
119  //If we are within range melee the target
121  {
122  bool healing = false;
123  SpellInfo const* info = NULL;
124 
125  //Select a healing spell if less than 30% hp
126  if (me->HealthBelowPct(30))
128 
129  //No healing spell available, select a hostile spell
130  if (info)
131  healing = true;
132  else
134 
135  //20% chance to replace our white hit with a spell
136  if (info && urand(0, 99) < 20 && !globalCooldown)
137  {
138  //Cast the spell
139  if (healing)
140  DoCast(me, info->Id);
141  else
142  DoCastVictim(info->Id);
143 
144  //Set our global cooldown
146  }
147  else
149 
150  me->resetAttackTimer();
151  }
152  }
153  else
154  {
155  //Only run this code if we arn't already casting
156  if (!me->IsNonMeleeSpellCast(false))
157  {
158  bool healing = false;
159  SpellInfo const* info = NULL;
160 
161  //Select a healing spell if less than 30% hp ONLY 33% of the time
162  if (me->HealthBelowPct(30) && 33 > urand(0, 99))
164 
165  //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE)
166  if (info)
167  healing = true;
168  else
170 
171  //Found a spell, check if we arn't on cooldown
172  if (info && !globalCooldown)
173  {
174  //If we are currently moving stop us and set the movement generator
176  {
177  me->GetMotionMaster()->Clear(false);
179  }
180 
181  //Cast spell
182  if (healing)
183  DoCast(me, info->Id);
184  else
185  DoCastVictim(info->Id);
186 
187  //Set our global cooldown
189  } //If no spells available and we arn't moving run to target
191  {
192  //Cancel our current spell and then mutate new movement generator
193  me->InterruptNonMeleeSpells(false);
194  me->GetMotionMaster()->Clear(false);
196  }
197  }
198  }
199 
201  }
Definition: MotionMaster.h:37
uint32 Id
Definition: SpellInfo.h:329
void MoveIdle()
Definition: MotionMaster.cpp:185
bool UpdateVictim()
Definition: CreatureAI.cpp:233
uint32 globalCooldown
Definition: guards.cpp:249
void AttackerStateUpdate(Unit *victim, WeaponAttackType attType=BASE_ATTACK, bool extra=false)
Definition: Unit.cpp:1874
void Clear(bool reset=true)
Definition: MotionMaster.h:138
Definition: SpellInfo.h:326
uint32 buffTimer
Definition: guards.cpp:250
SpellInfo const * SelectSpell(Unit *target, uint32 school, uint32 mechanic, SelectTargetType targets, float rangeMin, float rangeMax, SelectEffect effect)
Definition: ScriptedCreature.cpp:182
void MoveChase(Unit *target, float dist=0.0f, float angle=0.0f)
Definition: MotionMaster.cpp:241
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool IsInCombat() const
Definition: Unit.h:1584
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:663
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: CreatureAI.h:55
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Definition: CreatureAI.h:45
Definition: guards.cpp:40
Creature *const me
Definition: CreatureAI.h:71
bool IsAlive() const
Definition: Unit.h:1692
Unit * GetVictim() const
Definition: Unit.h:1379
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
Definition: CreatureAI.h:57
bool HealthBelowPct(int32 pct) const
Definition: Unit.h:1430
Definition: CreatureAI.h:49
bool IsWithinMeleeRange(const Unit *obj, float dist=MELEE_RANGE) const
Definition: Unit.cpp:508
void DoCast(uint32 spellId)
Definition: UnitAI.cpp:101
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:1357
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:481
#define NOMINAL_MELEE_RANGE
Definition: Object.h:47
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
Definition: CreatureAI.h:58
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:49
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition: UnitAI.cpp:159
Definition: MotionMaster.h:43

+ Here is the call graph for this function:

Member Data Documentation

uint32 guard_generic::guard_genericAI::buffTimer
private
uint32 guard_generic::guard_genericAI::globalCooldown
private

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