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

Public Member Functions

 npc_headAI (Creature *creature)
 
void Initialize ()
 
void Reset () override
 
void EnterCombat (Unit *) override
 
void SaySound (uint8 textEntry, Unit *target=0)
 
void DamageTaken (Unit *, uint32 &damage) override
 
void SpellHit (Unit *caster, const SpellInfo *spell) override
 
void Disappear ()
 
void UpdateAI (uint32 diff) override
 
- Public Member Functions inherited from ScriptedAI
 ScriptedAI (Creature *creature)
 
virtual ~ScriptedAI ()
 
void AttackStartNoMove (Unit *target)
 
void JustDied (Unit *) override
 
void KilledUnit (Unit *) override
 
void JustSummoned (Creature *) override
 
void SummonedCreatureDespawn (Creature *) 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 EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
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 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 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)
 

Public Attributes

ObjectGuid bodyGUID
 
uint32 Phase
 
uint32 laugh
 
uint32 wait
 
bool withbody
 
bool die
 
- Public Attributes inherited from ScriptedAI
bool IsFleeing
 

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 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 CreatureAI
Creature *const me
 
CreatureBoundary const_boundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Constructor & Destructor Documentation

npc_head::npc_headAI::npc_headAI ( Creature creature)
inline
230  : ScriptedAI(creature)
231  {
232  Initialize();
233  }
ScriptedAI(Creature *creature)
Definition: ScriptedCreature.cpp:100
void Initialize()
Definition: boss_headless_horseman.cpp:235

+ Here is the call graph for this function:

Member Function Documentation

void npc_head::npc_headAI::DamageTaken ( Unit ,
uint32 damage 
)
inlineoverridevirtual

Reimplemented from ScriptedAI.

272  {
273  if (withbody)
274  return;
275 
276  switch (Phase)
277  {
278  case 1:
279  if (me->HealthBelowPctDamaged(67, damage))
280  Disappear();
281  break;
282  case 2:
283  if (me->HealthBelowPctDamaged(34, damage))
284  Disappear();
285  break;
286  case 3:
287  if (damage >= me->GetHealth())
288  {
289  die = true;
290  withbody = true;
291  wait = 300;
292  damage = me->GetHealth() - me->CountPctFromMaxHealth(1);
294  me->StopMoving();
295  //me->GetMotionMaster()->MoveIdle();
297  }
298  break;
299  }
300  }
uint32 wait
Definition: boss_headless_horseman.cpp:249
Definition: Unit.h:674
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:1431
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
void Disappear()
Definition: boss_headless_horseman.cpp:911
Creature *const me
Definition: CreatureAI.h:71
bool withbody
Definition: boss_headless_horseman.cpp:251
void DoCast(uint32 spellId)
Definition: UnitAI.cpp:101
bool die
Definition: boss_headless_horseman.cpp:252
Definition: UpdateFields.h:109
Definition: boss_headless_horseman.cpp:75
uint32 GetHealth() const
Definition: Unit.h:1426
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743
Phase
Definition: boss_kiljaeden.cpp:153
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the call graph for this function:

void npc_head::npc_headAI::Disappear ( )
912 {
913  if (withbody)
914  return;
915 
916  if (!bodyGUID.IsEmpty())
917  {
919  if (body && body->IsAlive())
920  {
921  withbody = true;
922  me->RemoveAllAuras();
923  body->RemoveAurasDueToSpell(SPELL_IMMUNE);//hack, SpellHit doesn't calls if body has immune aura
924  DoCast(body, SPELL_FLYING_HEAD);
925  me->SetFullHealth();
930  }
931  }
932 }
Definition: boss_headless_horseman.cpp:382
void RemoveAllAuras()
Definition: Unit.cpp:3920
void MoveIdle()
Definition: MotionMaster.cpp:185
Definition: Unit.h:674
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
Definition: Creature.h:467
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
Definition: boss_headless_horseman.cpp:69
Creature *const me
Definition: CreatureAI.h:71
#define ENSURE_AI(a, b)
Definition: ScriptedCreature.h:29
bool IsAlive() const
Definition: Unit.h:1692
bool withbody
Definition: boss_headless_horseman.cpp:251
CreatureAI * AI() const
Definition: Creature.h:525
void DoCast(uint32 spellId)
Definition: UnitAI.cpp:101
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3586
ObjectGuid bodyGUID
Definition: boss_headless_horseman.cpp:245
Definition: UpdateFields.h:109
void SetFullHealth()
Definition: Unit.h:1440
Definition: boss_headless_horseman.cpp:73
Definition: Unit.h:698
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_head::npc_headAI::EnterCombat ( Unit )
inlineoverridevirtual

Reimplemented from ScriptedAI.

259 { }
void npc_head::npc_headAI::Initialize ( void  )
inline
236  {
237  Phase = 0;
238  bodyGUID.Clear();
239  die = false;
240  withbody = true;
241  wait = 1000;
242  laugh = urand(15000, 30000);
243  }
uint32 wait
Definition: boss_headless_horseman.cpp:249
uint32 laugh
Definition: boss_headless_horseman.cpp:248
bool withbody
Definition: boss_headless_horseman.cpp:251
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
void Clear()
Definition: ObjectGuid.h:215
bool die
Definition: boss_headless_horseman.cpp:252
ObjectGuid bodyGUID
Definition: boss_headless_horseman.cpp:245
Phase
Definition: boss_kiljaeden.cpp:153

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_head::npc_headAI::Reset ( )
inlineoverridevirtual

Reimplemented from ScriptedAI.

255  {
256  Initialize();
257  }
void Initialize()
Definition: boss_headless_horseman.cpp:235

+ Here is the call graph for this function:

void npc_head::npc_headAI::SaySound ( uint8  textEntry,
Unit target = 0 
)
inline
262  {
263  Talk(textEntry, target);
264 
265  //DoCast(me, SPELL_HEAD_SPEAKS, true);
266  if (Creature* speaker = DoSpawnCreature(HELPER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 1000))
267  speaker->CastSpell(speaker, SPELL_HEAD_SPEAKS, false);
268  laugh += 3000;
269  }
Definition: boss_headless_horseman.cpp:86
uint32 laugh
Definition: boss_headless_horseman.cpp:248
Definition: Creature.h:467
Definition: Object.h:56
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:42
Creature * DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
Definition: ScriptedCreature.cpp:177
Definition: boss_headless_horseman.cpp:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_head::npc_headAI::SpellHit ( Unit caster,
const SpellInfo spell 
)
inlineoverridevirtual

Reimplemented from ScriptedAI.

303  {
304  if (!withbody)
305  return;
306 
307  if (spell->Id == SPELL_FLYING_HEAD)
308  {
309  if (Phase < 3)
310  ++Phase;
311  else
312  Phase = 3;
313 
314  withbody = false;
315  if (!bodyGUID)
316  bodyGUID = caster->GetGUID();
317  me->RemoveAllAuras();
319  DoCast(me, SPELL_HEAD_LANDS, true);
320  DoCast(me, SPELL_HEAD, false);
322  me->GetMotionMaster()->Clear(false);
323  me->GetMotionMaster()->MoveFleeing(caster->GetVictim());
324  }
325  }
void RemoveAllAuras()
Definition: Unit.cpp:3920
uint32 Id
Definition: SpellInfo.h:329
void Clear(bool reset=true)
Definition: MotionMaster.h:138
void MoveFleeing(Unit *enemy, uint32 time=0)
Definition: MotionMaster.cpp:526
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
Creature *const me
Definition: CreatureAI.h:71
Definition: boss_headless_horseman.cpp:38
Unit * GetVictim() const
Definition: Unit.h:1379
bool withbody
Definition: boss_headless_horseman.cpp:251
void DoCast(uint32 spellId)
Definition: UnitAI.cpp:101
uint32 Phase
Definition: boss_headless_horseman.cpp:247
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid bodyGUID
Definition: boss_headless_horseman.cpp:245
void SaySound(uint8 textEntry, Unit *target=0)
Definition: boss_headless_horseman.cpp:261
Definition: boss_headless_horseman.cpp:87
Definition: UpdateFields.h:109
Definition: boss_headless_horseman.cpp:74
Phase
Definition: boss_kiljaeden.cpp:153
Definition: boss_headless_horseman.cpp:73
Definition: Unit.h:698

+ Here is the call graph for this function:

void npc_head::npc_headAI::UpdateAI ( uint32  diff)
inlineoverridevirtual

Reimplemented from ScriptedAI.

329  {
330  if (!withbody)
331  {
332  if (wait <= diff)
333  {
334  wait = 1000;
335  if (!me->GetVictim())
336  return;
337  me->GetMotionMaster()->Clear(false);
339  }
340  else wait -= diff;
341 
342  if (laugh <= diff)
343  {
344  laugh = urand(15000, 30000);
346  //DoCast(me, SPELL_HEAD_SPEAKS, true); //this spell remove buff "head"
347  Creature* speaker = DoSpawnCreature(HELPER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 1000);
348  if (speaker)
349  speaker->CastSpell(speaker, SPELL_HEAD_SPEAKS, false);
351  }
352  else laugh -= diff;
353  }
354  else
355  {
356  if (die)
357  {
358  if (wait <= diff)
359  {
360  die = false;
361  if (Unit* body = ObjectAccessor::GetUnit(*me, bodyGUID))
362  body->KillSelf();
363  me->KillSelf();
364  }
365  else wait -= diff;
366  }
367  }
368  }
Definition: boss_headless_horseman.cpp:86
uint32 wait
Definition: boss_headless_horseman.cpp:249
void KillSelf(bool durabilityLoss=true)
Definition: Unit.h:1515
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
virtual void TextEmote(std::string const &text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition: Unit.cpp:16403
void Clear(bool reset=true)
Definition: MotionMaster.h:138
void MoveFleeing(Unit *enemy, uint32 time=0)
Definition: MotionMaster.cpp:526
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
uint32 laugh
Definition: boss_headless_horseman.cpp:248
Definition: Creature.h:467
void DoPlaySoundToSet(WorldObject *source, uint32 soundId)
Definition: ScriptedCreature.cpp:163
Creature *const me
Definition: CreatureAI.h:71
#define EMOTE_LAUGHS
Definition: boss_headless_horseman.cpp:137
Unit * GetVictim() const
Definition: Unit.h:1379
bool withbody
Definition: boss_headless_horseman.cpp:251
Definition: Object.h:56
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
Creature * DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
Definition: ScriptedCreature.cpp:177
bool die
Definition: boss_headless_horseman.cpp:252
ObjectGuid bodyGUID
Definition: boss_headless_horseman.cpp:245
uint32 RandomLaugh[]
Definition: boss_headless_horseman.cpp:48
Definition: boss_headless_horseman.cpp:57
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:

Member Data Documentation

ObjectGuid npc_head::npc_headAI::bodyGUID
bool npc_head::npc_headAI::die
uint32 npc_head::npc_headAI::laugh
uint32 npc_head::npc_headAI::Phase
uint32 npc_head::npc_headAI::wait
bool npc_head::npc_headAI::withbody

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