OregonCore  revision 3611e8a-git
Your Favourite TBC server
ScriptedCreature.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "ScriptedCreature.h"
19 #include "Spell.h"
20 #include "GridNotifiers.h"
21 #include "GridNotifiersImpl.h"
22 #include "Cell.h"
23 #include "CellImpl.h"
24 #include "ObjectMgr.h"
25 #include "MoveSplineInit.h"
26 
27 // Spell summary for ScriptedAI::SelectSpell
29 {
30  uint8 Targets; // set of enum SelectTarget
31  uint8 Effects; // set of enum SelectEffect
32 }* SpellSummary;
33 
35 {
36  for (iterator i = begin(); i != end();)
37  {
38  Creature* summon = Unit::GetCreature(*me, *i);
39  ++i;
40  if (summon && summon->IsAIEnabled
41  && (!entry || summon->GetEntry() == entry))
42  summon->AI()->DoZoneInCombat();
43  }
44 }
45 
47 {
48  for (iterator i = begin(); i != end();)
49  {
50  Creature* summon = Unit::GetCreature(*me, *i);
51  ++i;
52  if (summon && summon->IsAIEnabled
53  && (!entry || summon->GetEntry() == entry))
54  summon->AI()->DoAction(info);
55  }
56 }
57 
59 {
60  for (iterator i = begin(); i != end();)
61  {
62  Creature* summon = Unit::GetCreature(*me, *i);
63  if (!summon)
64  erase(i++);
65  else if (summon->GetEntry() == entry)
66  {
67  erase(i++);
68  summon->setDeathState(JUST_DIED);
69  summon->RemoveCorpse();
70  }
71  else
72  ++i;
73  }
74 }
75 
77 {
78  if (empty())
79  return;
80 
81  while (!empty())
82  {
83  Creature* summon = Unit::GetCreature(*me, *begin());
84  if (!summon)
85  erase(begin());
86  else
87  {
88  erase(begin());
89  if (summon->IsSummon())
90  {
91  summon->DestroyForNearbyPlayers();
92  CAST_SUM(summon)->UnSummon();
93  }
94  else
95  summon->DisappearAndDie();
96  }
97  }
98 }
99 
100 ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature),
101  me(pCreature),
102  IsFleeing(false),
103  m_bCombatMovement(true),
104  m_uiEvadeCheckCooldown(2500)
105 {
106  HeroicMode = me->GetMap()->IsHeroic();
107 }
108 
110 {
111  if (!pWho)
112  return;
113 
114  if (me->Attack(pWho, false))
115  DoStartNoMovement(pWho);
116 }
117 
118 void ScriptedAI::UpdateAI(const uint32 /*uiDiff*/)
119 {
120  //Check if we have a current target
121  if (!UpdateVictim())
122  return;
123 
125 }
126 
127 void ScriptedAI::DoStartMovement(Unit* pVictim, float fDistance, float fAngle)
128 {
129  if (pVictim)
130  me->GetMotionMaster()->MoveChase(pVictim, fDistance, fAngle);
131 }
132 
134 {
135  if (!pVictim)
136  return;
137 
139 }
140 
142 {
143  if (me->GetVictim())
144  me->AttackStop();
145 }
146 
147 void ScriptedAI::DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered)
148 {
149  if (!pTarget || me->IsNonMeleeSpellCast(false))
150  return;
151 
152  me->StopMoving();
153  me->CastSpell(pTarget, pSpellInfo, bTriggered);
154 }
155 
157 {
158  if (!pSource)
159  return;
160 
161  if (!GetSoundEntriesStore()->LookupEntry(uiSoundId))
162  {
163  error_log("OSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", uiSoundId, pSource->GetTypeId(), pSource->GetGUIDLow());
164  return;
165  }
166 
167  pSource->PlayDirectSound(uiSoundId);
168 }
169 
170 Creature* ScriptedAI::DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime)
171 {
172  return me->SummonCreature(uiId, me->GetPositionX() + fX, me->GetPositionY() + fY, me->GetPositionZ() + fZ, fAngle, (TempSummonType)uiType, uiDespawntime);
173 }
174 
176 {
178  ThreatContainer::StorageType::const_iterator itr = threatList.begin();
179  ThreatContainer::StorageType::reverse_iterator ritr = threatList.rbegin();
180 
181  if (uiPosition >= threatList.size() || !threatList.size())
182  return NULL;
183 
184  switch (pTarget)
185  {
187  advance (itr , uiPosition + (rand() % (threatList.size() - uiPosition)));
188  return Unit::GetUnit((*me), (*itr)->getUnitGuid());
189  break;
190 
192  advance (itr , uiPosition);
193  return Unit::GetUnit((*me), (*itr)->getUnitGuid());
194  break;
195 
197  advance (ritr , uiPosition);
198  return Unit::GetUnit((*me), (*ritr)->getUnitGuid());
199  break;
200 
201  default:
202  return UnitAI::SelectTarget(pTarget, uiPosition);
203  }
204 }
205 
206 SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, uint32 uiSchool, uint32 uiMechanic, SelectTargetType selectTargets, uint32 uiPowerCostMin, uint32 uiPowerCostMax, float fRangeMin, float fRangeMax, SelectEffect selectEffects)
207 {
208  //No target so we can't cast
209  if (!pTarget)
210  return NULL;
211 
212  //Silenced so we can't cast
214  return NULL;
215 
216  //Using the extended script system we first create a list of viable spells
217  SpellEntry const* apSpell[CREATURE_MAX_SPELLS];
218  memset(apSpell, 0, sizeof(SpellEntry*)*CREATURE_MAX_SPELLS);
219 
220  uint32 uiSpellCount = 0;
221 
222  SpellEntry const* pTempSpell;
223  SpellRangeEntry const* pTempRange;
224 
225  //Check if each spell is viable(set it to null if not)
226  for (uint32 i = 0; i < CREATURE_MAX_SPELLS; i++)
227  {
228  pTempSpell = GetSpellStore()->LookupEntry(me->m_spells[i]);
229 
230  //This spell doesn't exist
231  if (!pTempSpell)
232  continue;
233 
234  // Targets and Effects checked first as most used restrictions
235  //Check the spell targets if specified
236  if (selectTargets && !(SpellSummary[me->m_spells[i]].Targets & (1 << (selectTargets - 1))))
237  continue;
238 
239  //Check the type of spell if we are looking for a specific spell type
240  if (selectEffects && !(SpellSummary[me->m_spells[i]].Effects & (1 << (selectEffects - 1))))
241  continue;
242 
243  //Check for school if specified
244  if (uiSchool && (pTempSpell->SchoolMask & uiSchool) == 0)
245  continue;
246 
247  //Check for spell mechanic if specified
248  if (uiMechanic && pTempSpell->Mechanic != uiMechanic)
249  continue;
250 
251  //Make sure that the spell uses the requested amount of power
252  if (uiPowerCostMin && pTempSpell->manaCost < uiPowerCostMin)
253  continue;
254 
255  if (uiPowerCostMax && pTempSpell->manaCost > uiPowerCostMax)
256  continue;
257 
258  //Continue if we don't have the mana to actually cast this spell
259  if (pTempSpell->manaCost > me->GetPower((Powers)pTempSpell->powerType))
260  continue;
261 
262  //Get the Range
263  pTempRange = GetSpellRangeStore()->LookupEntry(pTempSpell->rangeIndex);
264 
265  //Spell has invalid range store so we can't use it
266  if (!pTempRange)
267  continue;
268 
269  //Check if the spell meets our range requirements
270  if (fRangeMin && pTempRange->maxRange < fRangeMin)
271  continue;
272  if (fRangeMax && pTempRange->maxRange > fRangeMax)
273  continue;
274 
275  //Check if our target is in range
276  if (me->IsWithinDistInMap(pTarget, pTempRange->minRange) || !me->IsWithinDistInMap(pTarget, pTempRange->maxRange))
277  continue;
278 
279  //All good so lets add it to the spell list
280  apSpell[uiSpellCount] = pTempSpell;
281  ++uiSpellCount;
282  }
283 
284  //We got our usable spells so now lets randomly pick one
285  if (!uiSpellCount)
286  return NULL;
287 
288  return apSpell[rand() % uiSpellCount];
289 }
290 
291 bool ScriptedAI::CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered)
292 {
293  //No target so we can't cast
294  if (!pTarget || !pSpell)
295  return false;
296 
297  //Silenced so we can't cast
298  if (!bTriggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
299  return false;
300 
301  //Check for power
302  if (!bTriggered && me->GetPower((Powers)pSpell->powerType) < pSpell->manaCost)
303  return false;
304 
305  SpellRangeEntry const* pTempRange = GetSpellRangeStore()->LookupEntry(pSpell->rangeIndex);
306 
307  //Spell has invalid range store so we can't use it
308  if (!pTempRange)
309  return false;
310 
311  //Unit is out of range of this spell
312  if (me->IsInRange(pTarget, pTempRange->minRange, pTempRange->maxRange))
313  return false;
314 
315  return true;
316 }
317 
319 {
320  SpellSummary = new TSpellSummary[GetSpellStore()->GetNumRows()];
321 
322  SpellEntry const* pTempSpell;
323 
324  for (uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i)
325  {
326  SpellSummary[i].Effects = 0;
327  SpellSummary[i].Targets = 0;
328 
329  pTempSpell = GetSpellStore()->LookupEntry(i);
330  //This spell doesn't exist
331  if (!pTempSpell)
332  continue;
333 
334  for (uint32 j = 0; j < 3; ++j)
335  {
336  //Spell targets self
337  if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER)
338  SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF - 1);
339 
340  //Spell targets a single enemy
341  if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
344 
345  //Spell targets AoE at enemy
346  if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_SRC ||
348  pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER ||
351 
352  //Spell targets an enemy
353  if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
357  pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER ||
360 
361  //Spell targets a single friend(or self)
362  if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER ||
366 
367  //Spell targets aoe friends
368  if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_CASTER ||
370  pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER)
372 
373  //Spell targets any friend(or self)
374  if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER ||
379  pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER)
381 
382  //Make sure that this spell includes a damage effect
383  if (pTempSpell->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE ||
384  pTempSpell->Effect[j] == SPELL_EFFECT_INSTAKILL ||
385  pTempSpell->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
386  pTempSpell->Effect[j] == SPELL_EFFECT_HEALTH_LEECH)
387  SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE - 1);
388 
389  //Make sure that this spell includes a healing effect (or an apply aura with a periodic heal)
390  if (pTempSpell->Effect[j] == SPELL_EFFECT_HEAL ||
391  pTempSpell->Effect[j] == SPELL_EFFECT_HEAL_MAX_HEALTH ||
392  pTempSpell->Effect[j] == SPELL_EFFECT_HEAL_MECHANICAL ||
393  (pTempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA && pTempSpell->EffectApplyAuraName[j] == 8))
394  SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING - 1);
395 
396  //Make sure that this spell applies an aura
397  if (pTempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA)
398  SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA - 1);
399  }
400  }
401 }
402 
404 {
406  {
407  error_log("OSCR: DoResetThreat called for creature that either cannot have threat list or has empty threat list (me entry = %d)", me->GetEntry());
408  return;
409  }
410 
412 
413  for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
414  {
415  Unit* pUnit = Unit::GetUnit((*me), (*itr)->getUnitGuid());
416 
417  if (pUnit && DoGetThreat(pUnit))
418  DoModifyThreatPercent(pUnit, -100);
419  }
420 }
421 
423 {
424  if (!pUnit) return 0.0f;
425  return me->getThreatManager().getThreat(pUnit);
426 }
427 
429 {
430  if (!pUnit) return;
431  me->getThreatManager().modifyThreatPercent(pUnit, pct);
432 }
433 
434 void ScriptedAI::DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime)
435 {
436  me->Relocate(fX, fY, fZ);
438  init.MoveTo(fX, fY, fZ, true);
439  int32 duration = init.Launch();
440  if (duration != uiTime)
441  sLog.outError("Scripted Creature - DoTeleportTo : Travel time and duration from spline don't match (travel time : %u, duration : %i). Object (TypeId: %u, Entry: %u, GUID: %u)",
442  uiTime, duration,
443  me->GetTypeId(), me->GetEntry(), me->GetGUIDLow());
444 }
445 
446 void ScriptedAI::DoTeleportTo(const float fPos[4])
447 {
448  me->NearTeleportTo(fPos[0], fPos[1], fPos[2], fPos[3]);
449 }
450 
451 void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO)
452 {
453  if (!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER)
454  {
455  if (pUnit)
456  error_log("OSCR: Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), fX, fY, fZ, fO);
457  return;
458  }
459 
460  CAST_PLR(pUnit)->TeleportTo(pUnit->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT);
461 }
462 
463 void ScriptedAI::DoTeleportAll(float fX, float fY, float fZ, float fO)
464 {
465  Map* map = me->GetMap();
466  if (!map->IsDungeon())
467  return;
468 
469  Map::PlayerList const& PlayerList = map->GetPlayers();
470  for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
471  if (Player* i_pl = i->GetSource())
472  if (i_pl->IsAlive())
473  i_pl->TeleportTo(me->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT);
474 }
475 
477 {
478  Unit* pUnit = NULL;
479  Oregon::MostHPMissingInRange u_check(me, fRange, uiMinHPDiff);
481  me->VisitNearbyObject(fRange, searcher);
482 
483  return pUnit;
484 }
485 
486 std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float fRange)
487 {
488  std::list<Creature*> pList;
489  Oregon::FriendlyCCedInRange u_check(me, fRange);
491  me->VisitNearbyObject(fRange, searcher);
492  return pList;
493 }
494 
495 std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellid)
496 {
497  std::list<Creature*> pList;
498  Oregon::FriendlyMissingBuffInRange u_check(me, fRange, uiSpellid);
500  me->VisitNearbyObject(fRange, searcher);
501  return pList;
502 }
503 
505 {
506  Player* pPlayer = NULL;
507 
509  Cell cell(pair);
510  cell.SetNoCreate();
511 
512  Oregon::PlayerAtMinimumRangeAway check(me, minimumRange);
515 
516  cell.Visit(pair, visitor, *me->GetMap(), *me, minimumRange);
517 
518  return pPlayer;
519 }
520 
521 void ScriptedAI::SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand, int32 uiOffHand, int32 uiRanged)
522 {
523  if (bLoadDefault)
524  {
525  if (CreatureInfo const* pInfo = GetCreatureTemplateStore(me->GetEntry()))
526  me->LoadEquipment(pInfo->equipmentId, true);
527 
528  return;
529  }
530 
531  if (uiMainHand >= 0)
533 
534  if (uiOffHand >= 0)
536 
537  if (uiRanged >= 0)
539 }
540 
541 void ScriptedAI::SetCombatMovement(bool bCombatMove)
542 {
543  m_bCombatMovement = bCombatMove;
544 }
545 
546 enum eNPCs
547 {
548  NPC_BROODLORD = 12017,
550  NPC_JAN_ALAI = 23578,
552 };
553 
554 // Hacklike storage used for misc creatures that are expected to evade of outside of a certain area.
555 // It is assumed the information is found elswehere and can be handled by the core. So far no luck finding such information/way to extract it.
557 {
558  if (m_uiEvadeCheckCooldown <= uiDiff)
559  m_uiEvadeCheckCooldown = 2500;
560  else
561  {
562  m_uiEvadeCheckCooldown -= uiDiff;
563  return false;
564  }
565 
566  if (me->IsInEvadeMode() || !me->GetVictim())
567  return false;
568 
569  float fX = me->GetPositionX();
570  float fY = me->GetPositionY();
571  float fZ = me->GetPositionZ();
572 
573  switch (me->GetEntry())
574  {
575  case NPC_BROODLORD: // broodlord (not move down stairs)
576  if (fZ > 448.60f)
577  return false;
578  break;
579  case NPC_VOID_REAVER: // void reaver (calculate from center of room)
580  if (me->GetDistance2d(432.59f, 371.93f) < 105.0f)
581  return false;
582  break;
583  case NPC_JAN_ALAI: // jan'alai (calculate by Z)
584  if (fZ > 12.0f)
585  return false;
586  break;
587  case NPC_SARTHARION: // sartharion (calculate box)
588  if (fX > 3218.86f && fX < 3275.69f && fY < 572.40f && fY > 484.68f)
589  return false;
590  break;
591  default:
592  error_log("OSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition.", me->GetEntry());
593  return false;
594  }
595 
596  EnterEvadeMode();
597  return true;
598 }
599 
601 {
602  if (!pWho)
603  return;
604 
605  if (me->Attack(pWho, true))
606  DoStartNoMovement(pWho);
607 }
608 
610  , bossId(id), summons(me), instance(c->GetInstanceData())
611 {
612 }
613 
615 {
616  if (!me->IsAlive())
617  return;
618 
620  events.Reset();
622  if (instance)
624 }
625 
627 {
628  events.Reset();
630  if (instance)
631  {
633  instance->SaveToDB();
634  }
635 }
636 
638 {
640  me->setActive(true);
641  DoZoneInCombat();
642  if (instance)
644 }
645 
647 {
648  summons.Summon(summon);
649  if (me->IsInCombat())
650  DoZoneInCombat(summon);
651 }
652 
654 {
655  summons.Despawn(summon);
656 }
657 
658 #define GOBJECT(x) (const_cast<GameObjectInfo*>(GetGameObjectInfo(x)))
659 
661 {
662  GameObjectInfo* goInfo;
663 
664  // Sunwell Plateau : Kalecgos : Spectral Rift
665  goInfo = GOBJECT(187055);
666  if (goInfo)
667  if (goInfo->type == GAMEOBJECT_TYPE_GOOBER)
669 
670  // Naxxramas : Sapphiron Birth
671  goInfo = GOBJECT(181356);
672  if (goInfo)
673  if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
674  goInfo->trap.radius = 50;
675 }
676 
677 // SD2 grid searchers.
678 Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange, bool bAlive)
679 {
680  return pSource->FindNearestCreature(uiEntry, fMaxSearchRange, bAlive);
681 }
682 GameObject* GetClosestGameObjectWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
683 {
684  return pSource->FindNearestGameObject(uiEntry, fMaxSearchRange);
685 }
686 void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
687 {
688  return pSource->GetCreatureListWithEntryInGrid(lList, uiEntry, fMaxSearchRange);
689 }
690 void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
691 {
692  return pSource->GetGameObjectListWithEntryInGrid(lList, uiEntry, fMaxSearchRange);
693 }
694 
bool AttackStop()
Definition: Unit.cpp:7408
struct GameObjectInfo::@59::@66 trap
virtual void EnterEvadeMode()
Definition: CreatureAI.cpp:219
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:7315
DBCStorage< SpellEntry > const * GetSpellStore()
Definition: DBCStores.cpp:776
float DoGetThreat(Unit *u)
void MoveIdle(MovementSlot slot=MOTION_SLOT_ACTIVE)
virtual void DoAction(const int32 param=0)
Definition: UnitAI.h:69
bool UpdateVictim()
Definition: CreatureAI.cpp:276
DBCStorage< SpellRangeEntry > const * GetSpellRangeStore()
Definition: DBCStores.cpp:780
SpellEntry const * SelectSpell(Unit *Target, uint32 School, uint32 Mechanic, SelectTargetType Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effect)
void PlayDirectSound(uint32 sound_id, Player *target=NULL)
Definition: Object.cpp:2544
void modifyThreatPercent(Unit *victim, int32 percent)
Map * GetMap() const
Definition: Object.h:829
SummonList summons
InstanceData *const instance
void Reset()
void _JustDied()
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false) const
Definition: Unit.cpp:3493
void MoveChase(Unit *target, float dist=0.0f, float angle=0.0f)
void DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime=0)
void UpdateAI(const uint32)
void setActive(bool isActiveObject)
Definition: Object.cpp:1122
void DoZoneInCombat(Creature *creature=NULL, float maxRangeToNearestTarget=50.0f)
Definition: CreatureAI.cpp:78
MotionMaster * GetMotionMaster()
Definition: Unit.h:2001
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2088
bool IsInCombat() const
Definition: Unit.h:1318
void DespawnEntry(uint32 entry)
#define sLog
Log class singleton.
Definition: Log.h:187
const uint32 bossId
void GetCreatureListWithEntryInGrid(std::list< Creature * > &creatureList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
Definition: Object.cpp:2329
ThreatContainer::StorageType const & getThreatList() const
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
ACE_INT32 int32
Definition: Define.h:67
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
bool IsInEvadeMode() const
Definition: Creature.cpp:2284
uint32 powerType
Definition: DBCStructure.h:709
NULL Dbg ErrDB Arena Chat Char Map MMap false
Definition: Log.cpp:556
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &gameobjectList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
Definition: Object.cpp:2316
bool IsDungeon() const
Definition: Map.h:427
bool EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
void LoadOverridenSQLData()
virtual bool SetBossState(uint32 id, EncounterState state)
void SetNoCreate()
Definition: Cell.h:76
uint32 GetGUIDLow() const
Definition: Object.h:160
uint32 Effect[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:724
bool isThreatListEmpty() const
std::list< Creature * > DoFindFriendlyCC(float fRange)
iterator begin()
Definition: MapRefManager.h:48
void MoveTo(const Vector3 &destination, bool generatePath=false, bool forceDestination=false)
bool IsAIEnabled
Definition: Unit.h:2101
#define CAST_PLR(a)
uint32 EffectApplyAuraName[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:734
bool CanCast(Unit *pTarget, SpellEntry const *pSpell, bool bTriggered=false)
uint32 rangeIndex
Definition: DBCStructure.h:714
void DoModifyThreatPercent(Unit *pUnit, int32 pct)
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.h:762
void SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand=EQUIP_NO_CHANGE, int32 uiOffHand=EQUIP_NO_CHANGE, int32 uiRanged=EQUIP_NO_CHANGE)
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:909
uint32 GetPower(Powers power) const
Definition: Unit.h:1076
void DoStartNoMovement(Unit *pVictim)
float GetDistance2d(const WorldObject *obj) const
Definition: Object.h:721
ScriptedAI(Creature *pCreature)
uint8 GetTypeId() const
Definition: Object.h:204
Player * GetPlayerAtMinimumRange(float fMinimumRange)
uint32 m_spells[CREATURE_MAX_SPELLS]
Definition: Creature.h:679
ACE_UINT8 uint8
Definition: Define.h:73
Powers
void setDeathState(DeathState s) override
Definition: Creature.cpp:1558
DBCStorage< SoundEntriesEntry > const * GetSoundEntriesStore()
Definition: DBCStores.cpp:772
#define UI64FMTD
Definition: Common.h:149
void Relocate(float x, float y)
Definition: Position.h:65
void JustSummoned(Creature *summon)
bool IsHeroic() const
Definition: Map.h:435
uint32 m_uiEvadeCheckCooldown
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition: Unit.cpp:12503
void DoTeleportAll(float fX, float fY, float fZ, float fO)
bool IsAlive() const
Definition: Unit.h:1433
Unit * GetVictim() const
Definition: Unit.h:985
float GetPositionY() const
Definition: Position.h:98
SelectAggroTarget
Definition: UnitAI.h:31
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1174
GameObject * GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
CreatureAI * AI() const
Definition: Creature.h:548
void FillSpellSummary()
bool m_bCombatMovement
float GetPositionZ() const
Definition: Position.h:99
void DoZoneInCombat(uint32 entry=0)
BossAI(Creature *c, uint32 id)
TempSummonType
uint32 EffectImplicitTargetA[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:731
Creature * GetClosestCreatureWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange, bool bAlive)
uint32 GetMapId() const
Definition: Object.h:585
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
void AttackStartNoMove(Unit *pTarget)
uint32 SchoolMask
Definition: DBCStructure.h:772
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true)
Definition: Object.cpp:2289
Definition: Map.h:266
void DoTeleportPlayer(Unit *pUnit, float fX, float fY, float fZ, float fO)
void AttackStart(Unit *who)
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
void Summon(Creature *summon)
Unit * SelectUnit(SelectAggroTarget pTarget, uint32 uiPosition)
float getThreat(Unit *victim, bool alsoSearchOfflineList=false)
PlayerList const & GetPlayers() const
Definition: Map.h:491
void Despawn(Creature *summon)
Definition: Cell.h:46
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition: Object.cpp:1296
#define GOBJECT(x)
void SetCombatMovement(bool CombatMove)
#define error_log
Definition: Log.h:202
CreatureInfo const * GetCreatureTemplateStore(uint32 entry)
Definition: ObjectMgr.cpp:7620
std::list< Creature * > DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellId)
Unit * DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff=1)
#define CREATURE_MAX_SPELLS
Definition: Unit.h:249
std::list< HostileReference * > StorageType
void DoAction(uint32 entry, uint32 info)
ThreatManager & getThreatManager()
Definition: Unit.h:1830
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition: Unit.cpp:10602
SelectEffect
Definition: CreatureAI.h:51
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:45
uint32 Mechanic
Definition: DBCStructure.h:678
void RemoveCorpse(bool setSpawnTime=true)
Definition: Creature.cpp:234
GameObject * FindNearestGameObject(uint32 entry, float range)
Definition: Object.cpp:2298
void SetCombatPulseDelay(uint32 delay)
Definition: Creature.h:758
bool CanHaveThreatList() const
Definition: Unit.cpp:10090
static Unit * GetUnit(WorldObject &object, uint64 guid)
Definition: Unit.cpp:10592
void DestroyForNearbyPlayers()
Definition: Object.cpp:2554
Creature * me
uint32 GetEntry() const
Definition: Object.h:186
void LoadEquipment(uint32 equip_entry, bool force=false)
Definition: Creature.cpp:1358
Creature * DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime)
struct TSpellSummary * SpellSummary
void DoCastSpell(Unit *pTarget, SpellEntry const *pSpellInfo, bool bTriggered=false)
EventMap events
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:299
ACE_UINT32 uint32
Definition: Define.h:71
float GetPositionX() const
Definition: Position.h:97
void SummonedCreatureDespawn(Creature *summon)
void DoStartMovement(Unit *pVictim, float fDistance=0, float fAngle=0)
bool IsSummon() const
Definition: Unit.h:1018
true
Definition: Log.cpp:534
Definition: Unit.h:884
Unit * SelectTarget(SelectAggroTarget target, uint32 position=0, float dist=0, bool playerOnly=false, int32 aura=0)
Definition: UnitAI.cpp:126
void StopMoving()
Definition: Unit.cpp:11838
void DisappearAndDie()
Definition: Creature.cpp:212
Definition: Player.h:922
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
Definition: CellImpl.h:121
void _EnterCombat()
iterator end()
Definition: MapRefManager.h:52
void DoPlaySoundToSet(WorldObject *pSource, uint32 sound)
uint32 manaCost
Definition: DBCStructure.h:710
SelectTargetType
Definition: CreatureAI.h:35
#define CAST_SUM(a)
const uint64 & GetGUID() const
Definition: Object.h:156