OregonCore  revision fb2a440-git
Your Favourite TBC server
Creature.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 "Common.h"
19 #include "Database/DatabaseEnv.h"
20 #include "WorldPacket.h"
21 #include "WorldSession.h"
22 #include "World.h"
23 #include "ObjectMgr.h"
24 #include "MapManager.h"
25 #include "SpellMgr.h"
26 #include "Creature.h"
27 #include "QuestDef.h"
28 #include "GossipDef.h"
29 #include "Player.h"
30 #include "PoolMgr.h"
31 #include "Opcodes.h"
32 #include "Log.h"
33 #include "LootMgr.h"
34 #include "CreatureAI.h"
35 #include "CreatureAISelector.h"
36 #include "Formulas.h"
37 #include "SpellAuras.h"
38 #include "InstanceData.h"
39 #include "Battleground.h"
40 #include "Utilities/Util.h"
41 #include "GridNotifiers.h"
42 #include "GridNotifiersImpl.h"
43 #include "CellImpl.h"
44 #include "GameEventMgr.h"
45 #include "CreatureGroups.h"
46 #include "MoveSpline.h"
47 
49 {
50  for (TrainerSpellList::iterator itr = spellList.begin(); itr != spellList.end(); ++itr)
51  delete (*itr);
52  spellList.clear();
53 }
54 
56 {
57  for (TrainerSpellList::const_iterator itr = spellList.begin(); itr != spellList.end(); ++itr)
58  if ((*itr)->spell == spell_id)
59  return *itr;
60 
61  return NULL;
62 }
63 
65 {
66  bool found = false;
67  for (VendorItemList::iterator i = m_items.begin(); i != m_items.end();)
68  {
69  if ((*i)->item == item_id)
70  {
71  i = m_items.erase(i++);
72  found = true;
73  }
74  else
75  ++i;
76  }
77  return found;
78 }
79 
80 size_t VendorItemData::FindItemSlot(uint32 item_id) const
81 {
82  for (size_t i = 0; i < m_items.size(); ++i)
83  if (m_items[i]->item == item_id)
84  return i;
85  return m_items.size();
86 }
87 
89 {
90  for (VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i)
91  if ((*i)->item == item_id)
92  return *i;
93  return NULL;
94 }
95 
97 {
98  uint32 c = 0;
99  uint32 modelIDs[4];
100 
101  if (modelid1) modelIDs[c++] = modelid1;
102  if (modelid2) modelIDs[c++] = modelid2;
103  if (modelid3) modelIDs[c++] = modelid3;
104  if (modelid4) modelIDs[c++] = modelid4;
105 
106  return ((c > 0) ? modelIDs[urand(0, c - 1)] : 0);
107 }
108 
110 {
111  if (modelid1) return modelid1;
112  if (modelid2) return modelid2;
113  if (modelid3) return modelid3;
114  if (modelid4) return modelid4;
115  return 0;
116 }
117 
118 bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
119 {
120  if (Unit* victim = Unit::GetUnit(m_owner, m_victim))
121  {
122  while (!m_assistants.empty())
123  {
124  Creature* assistant = Unit::GetCreature(m_owner, *m_assistants.begin());
125  m_assistants.pop_front();
126 
127  if (assistant && assistant->CanAssistTo(&m_owner, victim))
128  {
129  assistant->SetNoCallAssistance(true);
130  assistant->CombatStart(victim);
131  if (assistant->IsAIEnabled)
132  assistant->AI()->AttackStart(victim);
133  }
134  }
135  }
136  return true;
137 }
138 
139 bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
140 {
141  m_owner.DespawnOrUnsummon();
142  return true;
143 }
144 
145 Creature::Creature(bool isWorldObject): Unit(isWorldObject),
146  _pickpocketLootRestore(0),
147  _skinner(0),
148  m_GlobalCooldown(0),
149  hasPlayerDamaged(false), m_SightDistance(sWorld.getConfig(CONFIG_SIGHT_MONSTER)),
150  m_CombatDistance(MELEE_RANGE), m_lootMoney(0), m_lootRecipient(0), m_lootRecipientGroup(0), m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(25),
151  m_corpseDelay(60), m_respawnradius(0.0f), m_combatPulseTime(0), m_combatPulseDelay(0), m_emoteState(0), m_reactState(REACT_AGGRESSIVE), m_regenTimer(2000),
152  m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0),
153  m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false),
154  m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), DisableReputationGain(false), m_creatureData(NULL),
155  m_formation(NULL), m_creatureInfo(NULL)
156 {
159 
160  for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
161  m_spells[i] = 0;
162 
163  m_CreatureSpellCooldowns.clear();
165 
167  m_CombatDistance = 0; // MELEE_RANGE
168 
169  TriggerJustRespawned = false;
170  m_isTempWorldObject = false;
171 }
172 
174 {
175  m_vendorItemCounts.clear();
176 
177  delete i_AI;
178  i_AI = NULL;
179 }
180 
182 {
183  // Register the creature for guid lookup
184  if (!IsInWorld())
185  {
186  if (m_zoneScript)
187  m_zoneScript->OnCreatureCreate(this, true);
188 
191  SearchFormation();
192  AIM_Initialize();
193  }
194 }
195 
197 {
198  if (IsInWorld())
199  {
200  if (m_zoneScript)
201  m_zoneScript->OnCreatureCreate(this, false);
202 
203  if (m_formation)
204  sFormationMgr.RemoveCreatureFromGroup(m_formation, this);
205 
207 
209  }
210 }
211 
213 {
215  if (IsAlive())
217  RemoveCorpse(false);
218 }
219 
221 {
222  if (IsSummon())
223  return;
224 
225  uint32 lowguid = GetDBTableGUIDLow();
226  if (!lowguid)
227  return;
228 
229  CreatureGroupInfoType::iterator frmdata = sFormationMgr.CreatureGroupMap.find(lowguid);
230  if (frmdata != sFormationMgr.CreatureGroupMap.end())
231  sFormationMgr.AddCreatureToGroup(frmdata->second->leaderGUID, this);
232 }
233 
234 void Creature::RemoveCorpse(bool setSpawnTime)
235 {
236  if (getDeathState() != CORPSE)
237  return;
238 
239  m_corpseRemoveTime = time(NULL);
242  loot.clear();
243  uint32 respawnDelay = m_respawnDelay;
244  if (IsAIEnabled)
245  AI()->CorpseRemoved(respawnDelay);
246 
247  // Should get removed later, just keep "compatibility" with scripts
248  if (setSpawnTime)
249  m_respawnTime = time(NULL) + respawnDelay;
250 
251  float x, y, z, o;
252  GetRespawnPosition(x, y, z, &o);
253  SetHomePosition(x, y, z, o);
254  GetMap()->CreatureRelocation(this, x, y, z, o);
255 }
256 
260 bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData* data)
261 {
262  CreatureInfo const* normalInfo = sObjectMgr.GetCreatureTemplate(Entry);
263  if (!normalInfo)
264  {
265  sLog.outErrorDb("Creature::UpdateEntry creature entry %u does not exist.", Entry);
266  return false;
267  }
268 
269  // get heroic mode entry
270  uint32 actualEntry = Entry;
271  CreatureInfo const* cinfo = normalInfo;
272  if (normalInfo->HeroicEntry)
273  {
274  //we already have valid Map pointer for current creature!
275  if (GetMap()->IsHeroic())
276  {
277  cinfo = sObjectMgr.GetCreatureTemplate(normalInfo->HeroicEntry);
278  if (!cinfo)
279  {
280  sLog.outErrorDb("Creature::UpdateEntry creature heroic entry %u does not exist.", actualEntry);
281  return false;
282  }
283  }
284  }
285 
286  SetEntry(Entry); // normal entry always
287  m_creatureInfo = cinfo; // map mode related always
288 
289  // equal to player Race field, but creature does not have race
291 
292  // known valid are: CLASS_WARRIOR, CLASS_PALADIN, CLASS_ROGUE, CLASS_MAGE
294 
295  // Cancel load if no model defined
296  if (!(cinfo->GetFirstValidModelId()))
297  {
298  sLog.outErrorDb("Creature (Entry: %u) has no model defined in table creature_template, can't load. ", Entry);
299  return false;
300  }
301 
302  uint32 display_id = sObjectMgr.ChooseDisplayId(team, GetCreatureTemplate(), data);
303  CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
304  if (!minfo) // Cancel load if no model defined
305  {
306  sLog.outErrorDb("Creature (Entry: %u) has model %u not found in table creature_model_info, can't load. ", Entry, display_id);
307  return false;
308  }
309 
310  display_id = minfo->modelid; // it can be different (for another gender)
311 
312  SetDisplayId(display_id);
313  SetNativeDisplayId(display_id);
315 
316  // Load creature equipment
317  if (!data || data->equipmentId == 0)
318  {
319  // use default from the template
320  LoadEquipment(cinfo->equipmentId);
321  }
322  else if (data && data->equipmentId != -1)
323  {
324  // override, -1 means no equipment
325  LoadEquipment(data->equipmentId);
326  }
327 
328  SetName(normalInfo->Name); // at normal entry always
329 
332 
334 
335  SetSpeed(MOVE_WALK, cinfo->speed_walk);
336  SetSpeed(MOVE_RUN, cinfo->speed_run);
337  SetSpeed(MOVE_SWIM, 1.0f); // using 1.0 rate
338  SetSpeed(MOVE_FLIGHT, 1.0f); // using 1.0 rate
339 
340  SetObjectScale(cinfo->scale);
341 
342  // checked at loading
346 
347  for (int i = 0; i < CREATURE_MAX_SPELLS; ++i)
349 
350  return true;
351 }
352 
353 bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData* data)
354 {
355  if (!InitEntry(Entry, team, data))
356  return false;
357 
358  CreatureInfo const* cInfo = GetCreatureTemplate();
359 
360  m_regenHealth = cInfo->RegenHealth;
361 
362  // creatures always have melee weapon ready if any unless specified otherwise
363  if (!GetCreatureAddon())
365 
367 
368  SetFaction(cInfo->faction);
369 
370  uint32 npcflag, unit_flags, dynamicflags;
371  ObjectMgr::ChooseCreatureFlags(cInfo, npcflag, unit_flags, dynamicflags, data);
372 
374  SetUInt32Value(UNIT_NPC_FLAGS, npcflag | sGameEventMgr.GetNPCFlag(this));
375  else
376  SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
377 
378  SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags);
379  SetUInt32Value(UNIT_DYNAMIC_FLAGS, dynamicflags);
380 
382 
386 
387  SelectLevel();
388 
390  CreatureBaseStats const* cCLS = sObjectMgr.GetCreatureClassLvlStats(getLevel(), cInfo->unit_class, cInfo->exp);
391  float armor = cCLS->BaseArmor * cInfo->ModArmor;
393 
394  if (cInfo->resistance1 < 0)
395  {
398  }
399  else
401 
402  if (cInfo->resistance2 < 0)
403  {
406  }
407  else
409 
410  if (cInfo->resistance3 < 0)
411  {
414  }
415  else
417 
418  if (cInfo->resistance4 < 0)
419  {
422  }
423  else
425 
426  if (cInfo->resistance5 < 0)
427  {
430  }
431  else
433 
434  if (cInfo->resistance6 < 0)
435  {
438  }
439  else
441 
442 
443  SetCanModifyStats(true);
444  UpdateAllStats();
445 
446  // checked and error show at loading templates
447  if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction))
448  {
449  if (factionTemplate->factionFlags & FACTION_TEMPLATE_FLAG_PVP || IsPvP()) // PvP state may be set in UnitFlags.. Prevent overwrite
450  SetPvP(true);
451  else
452  SetPvP(false);
453  }
454 
455  // trigger creature is always not selectable and can not be attacked
456  if (IsTrigger())
458 
460 
462  {
465  }
466 
468  LoadCreaturesAddon(true);
469  return true;
470 }
471 
473 {
474  if (m_GlobalCooldown <= diff)
475  m_GlobalCooldown = 0;
476  else
477  m_GlobalCooldown -= diff;
478 
480  {
481  TriggerJustRespawned = false;
482  AI()->JustRespawned();
483  }
484 
486 
487  switch (m_deathState)
488  {
489  case JUST_RESPAWNED:
490  // Must not be called, see Creature::setDeathState JUST_RESPAWNED -> ALIVE promoting.
491  sLog.outError("Creature (GUIDLow: %u Entry: %u) in wrong state: JUST_RESPAWNED (4)", GetGUIDLow(), GetEntry());
492  break;
493  case JUST_DIED:
494  // Must not be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
495  sLog.outError("Creature (GUIDLow: %u Entry: %u) in wrong state: JUST_DEAD (1)", GetGUIDLow(), GetEntry());
496  break;
497  case DEAD:
498  {
499  time_t now = time(NULL);
500  if (m_respawnTime <= time(NULL))
501  {
502  time_t linkedRespawntime = GetLinkedCreatureRespawnTime();
503  if (!linkedRespawntime) // Can respawn
504  Respawn();
505  else // the master is dead
506  {
507  uint32 targetGuid = sObjectMgr.GetLinkedRespawnGuid(m_DBTableGuid);
508  if (targetGuid == m_DBTableGuid) // if linking self, never respawn (check delayed to next day)
510  else
511  m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
512  SaveRespawnTime(); // also save to DB immediately
513  }
514  }
515  break;
516  }
517  case CORPSE:
518  {
519  Unit::Update(diff);
520  // deathstate changed on spells update, prevent problems
521  if (m_deathState != CORPSE)
522  break;
523 
525  {
526  if (m_groupLootTimer <= diff)
527  {
528  Group* group = sObjectMgr.GetGroupByLeader(lootingGroupLeaderGUID);
529  if (group)
530  group->EndRoll();
531  m_groupLootTimer = 0;
533  }
534  else m_groupLootTimer -= diff;
535  }
536  else if (m_corpseRemoveTime <= time(NULL))
537  {
538  RemoveCorpse(false);
539  DEBUG_LOG("Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY));
540  }
541  break;
542  }
543  case ALIVE:
544  {
545  Unit::Update(diff);
546 
547  // creature can be dead after Unit::Update call
548  // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
549  if (!IsAlive())
550  break;
551 
552  // if creature is charmed, switch to charmed AI
553  if (NeedChangeAI)
554  {
555  UpdateCharmAI();
556  NeedChangeAI = false;
557  IsAIEnabled = true;
558  if (!IsInEvadeMode() && LastCharmerGUID)
559  if (Unit* charmer = ObjectAccessor::GetUnit(*this, LastCharmerGUID))
560  if (canStartAttack(charmer, true))
561  i_AI->AttackStart(charmer);
562 
563  LastCharmerGUID = 0;
564  }
565 
566  // if periodic combat pulse is enabled and we are both in combat and in a dungeon, do this now
567  if (m_combatPulseDelay > 0 && IsInCombat() && GetMap()->IsDungeon())
568  {
569  if (diff > m_combatPulseTime)
570  m_combatPulseTime = 0;
571  else
572  m_combatPulseTime -= diff;
573 
574  if (m_combatPulseTime == 0)
575  {
576  Map::PlayerList const &players = GetMap()->GetPlayers();
577  if (!players.isEmpty())
578  for (Map::PlayerList::const_iterator it = players.begin(); it != players.end(); ++it)
579  {
580  if (Player* player = it->GetSource())
581  {
582  if (player->IsGameMaster())
583  continue;
584 
585  if (player->IsAlive() && this->IsHostileTo(player))
586  {
587  if (CanHaveThreatList())
588  AddThreat(player, 0.0f);
589  this->SetInCombatWith(player);
590  player->SetInCombatWith(this);
591  }
592  }
593  }
594 
596  }
597  }
598 
599  if (!IsInEvadeMode() && IsAIEnabled)
600  {
601  // do not allow the AI to be changed during update
602  m_AI_locked = true;
603 
604  i_AI->UpdateAI(diff);
605  m_AI_locked = false;
606  }
607 
608  // creature can be dead after UpdateAI call
609  // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
610  if (!IsAlive())
611  break;
612 
613  if (m_regenTimer > 0)
614  {
615  if (diff >= m_regenTimer)
616  m_regenTimer = 0;
617  else
618  m_regenTimer -= diff;
619  }
620 
621  if (m_regenTimer != 0)
622  break;
623 
624  if (!IsInEvadeMode() && (!IsInCombat() || IsPolymorphed())) // regenerate health if not in combat or if polymorphed
626 
627  RegenerateMana();
628 
630  break;
631  }
632  case DEAD_FALLING:
634  break;
635  default:
636  break;
637  }
638 }
639 
641 {
642  uint32 curValue = GetPower(POWER_MANA);
643  uint32 maxValue = GetMaxPower(POWER_MANA);
644 
645  if (curValue >= maxValue)
646  return;
647 
648  uint32 addvalue = 0;
649 
650  // Combat and any controlled creature
652  {
654  {
655  float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA);
656  float Spirit = GetStat(STAT_SPIRIT);
657 
658  addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
659  }
660  }
661  else
662  addvalue = maxValue / 3;
663 
664  // Apply modifiers (if any).
665  AuraList const& ModPowerRegenPCTAuras = this->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
666  for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
667  if ((*i)->GetMiscValue() == POWER_MANA)
668  AddPct(addvalue, (*i)->GetAmount());
669 
671 
672  ModifyPower(POWER_MANA, addvalue);
673 }
674 
676 {
677  if (!isRegeneratingHealth())
678  return;
679 
680  uint32 curValue = GetHealth();
681  uint32 maxValue = GetMaxHealth();
682 
683  if (curValue >= maxValue)
684  return;
685 
686  uint32 addvalue = 0;
687 
688  // Not only pet, but any controlled creature
689  if (GetCharmerOrOwnerGUID())
690  {
691  float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH);
692  float Spirit = GetStat(STAT_SPIRIT);
693 
694  if (GetPower(POWER_MANA) > 0)
695  addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate);
696  else
697  addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate);
698  }
699  else
700  addvalue = maxValue / 3;
701 
702  // Apply modifiers (if any).
703  AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT);
704  for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
705  AddPct(addvalue, (*i)->GetAmount());
706 
708 
709  ModifyHealth(addvalue);
710 }
711 
713 {
714  if (!GetVictim())
715  return;
716 
718  return;
719 
720  float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS);
721  if (radius > 0)
722  {
723  Creature* creature = NULL;
724 
726  Cell cell(p);
727  cell.SetNoCreate();
730 
732 
733  cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
734 
735  SetNoSearchAssistance(true);
736  UpdateSpeed(MOVE_RUN, false);
737 
738  if (!creature)
740  else
741  GetMotionMaster()->MoveSeekAssistance(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ());
742  }
743 
744 }
745 
747 {
748  // make sure nothing can change the AI during AI update
749  if (m_AI_locked)
750  {
751  sLog.outDebug("AIM_Initialize: failed to init, locked.");
752  return false;
753  }
754 
755  UnitAI* oldAI = i_AI;
757  i_AI = ai ? ai : FactorySelector::selectAI(this);
758  delete oldAI;
759  IsAIEnabled = true;
760  i_AI->InitializeAI();
761  return true;
762 }
763 
764 bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry, uint32 team, float x, float y, float z, float ang, const CreatureData* data)
765 {
766  ASSERT(map);
767  SetMap(map);
768  SetPhaseMask(phaseMask, false);
769 
770  CreatureInfo const* cinfo = sObjectMgr.GetCreatureTemplate(entry);
771  if (!cinfo)
772  {
773  sLog.outError("Creature::Create(): creature template (guidlow: %u, entry: %u) does not exist.", guidlow, entry);
774  return false;
775  }
776 
779  Relocate(x, y, z, ang);
780 
781  if (!IsPositionValid())
782  {
783  sLog.outError("Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", guidlow, entry, x, y);
784  return false;
785  }
786 
787  // Allow players to see those units while dead, do it here (mayby altered by addon auras)
790 
791  if (!CreateFromProto(guidlow, entry, team, data))
792  return false;
793 
794  switch (GetCreatureTemplate()->rank)
795  {
796  case CREATURE_ELITE_RARE:
798  break;
801  break;
804  break;
807  break;
808  default:
810  break;
811  }
812 
814  if (IsSpiritHealer() || IsSpiritGuide())
815  {
818  }
819 
820  return true;
821 }
822 
824 {
825  if (IsTotem() || IsTrigger() || IsCritter() || IsSpiritService())
827  else
829 }
830 
831 bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
832 {
833  if (!IsTrainer())
834  return false;
835 
836  TrainerSpellData const* trainer_spells = GetTrainerSpells();
837 
838  if (!trainer_spells || trainer_spells->spellList.empty())
839  {
840  sLog.outErrorDb("Creature %u (Entry: %u) has UNIT_NPC_FLAG_TRAINER but trainer spell list is empty.",
841  GetGUIDLow(), GetEntry());
842  return false;
843  }
844 
845  switch (GetCreatureTemplate()->trainer_type)
846  {
847  case TRAINER_TYPE_CLASS:
848  if (pPlayer->getClass() != GetCreatureTemplate()->classNum)
849  {
850  if (msg)
851  {
852  pPlayer->PlayerTalkClass->ClearMenus();
853  switch (GetCreatureTemplate()->classNum)
854  {
855  case CLASS_DRUID:
856  pPlayer->PlayerTalkClass->SendGossipMenu(4913, GetGUID());
857  break;
858  case CLASS_HUNTER:
859  pPlayer->PlayerTalkClass->SendGossipMenu(10090, GetGUID());
860  break;
861  case CLASS_MAGE:
862  pPlayer->PlayerTalkClass->SendGossipMenu( 328, GetGUID());
863  break;
864  case CLASS_PALADIN:
865  pPlayer->PlayerTalkClass->SendGossipMenu(1635, GetGUID());
866  break;
867  case CLASS_PRIEST:
868  pPlayer->PlayerTalkClass->SendGossipMenu(4436, GetGUID());
869  break;
870  case CLASS_ROGUE:
871  pPlayer->PlayerTalkClass->SendGossipMenu(4797, GetGUID());
872  break;
873  case CLASS_SHAMAN:
874  pPlayer->PlayerTalkClass->SendGossipMenu(5003, GetGUID());
875  break;
876  case CLASS_WARLOCK:
877  pPlayer->PlayerTalkClass->SendGossipMenu(5836, GetGUID());
878  break;
879  case CLASS_WARRIOR:
880  pPlayer->PlayerTalkClass->SendGossipMenu(4985, GetGUID());
881  break;
882  }
883  }
884  return false;
885  }
886  break;
887  case TRAINER_TYPE_PETS:
888  if (pPlayer->getClass() != CLASS_HUNTER)
889  {
890  pPlayer->PlayerTalkClass->ClearMenus();
891  pPlayer->PlayerTalkClass->SendGossipMenu(3620, GetGUID());
892  return false;
893  }
894  break;
895  case TRAINER_TYPE_MOUNTS:
896  if (GetCreatureTemplate()->race && pPlayer->getRace() != GetCreatureTemplate()->race)
897  {
898  // Allowed to train if exalted
899  if (FactionTemplateEntry const* faction_template = GetFactionTemplateEntry())
900  {
901  if (pPlayer->GetReputationRank(faction_template->faction) == REP_EXALTED)
902  return true;
903  }
904 
905  if (msg)
906  {
907  pPlayer->PlayerTalkClass->ClearMenus();
908  switch (GetCreatureTemplate()->classNum)
909  {
910  case RACE_DWARF:
911  pPlayer->PlayerTalkClass->SendGossipMenu(5865, GetGUID());
912  break;
913  case RACE_GNOME:
914  pPlayer->PlayerTalkClass->SendGossipMenu(4881, GetGUID());
915  break;
916  case RACE_HUMAN:
917  pPlayer->PlayerTalkClass->SendGossipMenu(5861, GetGUID());
918  break;
919  case RACE_NIGHTELF:
920  pPlayer->PlayerTalkClass->SendGossipMenu(5862, GetGUID());
921  break;
922  case RACE_ORC:
923  pPlayer->PlayerTalkClass->SendGossipMenu(5863, GetGUID());
924  break;
925  case RACE_TAUREN:
926  pPlayer->PlayerTalkClass->SendGossipMenu(5864, GetGUID());
927  break;
928  case RACE_TROLL:
929  pPlayer->PlayerTalkClass->SendGossipMenu(5816, GetGUID());
930  break;
931  case RACE_UNDEAD_PLAYER:
932  pPlayer->PlayerTalkClass->SendGossipMenu(624, GetGUID());
933  break;
934  case RACE_BLOODELF:
935  pPlayer->PlayerTalkClass->SendGossipMenu(5862, GetGUID());
936  break;
937  case RACE_DRAENEI:
938  pPlayer->PlayerTalkClass->SendGossipMenu(5864, GetGUID());
939  break;
940  }
941  }
942  return false;
943  }
944  break;
946  if (GetCreatureTemplate()->trainer_spell && !pPlayer->HasSpell(GetCreatureTemplate()->trainer_spell))
947  {
948  if (msg)
949  {
950  pPlayer->PlayerTalkClass->ClearMenus();
951  pPlayer->PlayerTalkClass->SendGossipMenu(11031, GetGUID());
952  }
953  return false;
954  }
955  break;
956  default:
957  return false; // checked and error output at creature_template loading
958  }
959  return true;
960 }
961 
962 bool Creature::CanInteractWithBattleMaster(Player* player, bool msg) const
963 {
964  if (!IsBattleMaster())
965  return false;
966 
967  uint32 bgTypeId = sObjectMgr.GetBattleMasterBG(GetEntry());
968  if (!msg)
969  return player->GetBGAccessByLevel(bgTypeId);
970 
971  if (!player->GetBGAccessByLevel(bgTypeId))
972  {
973  player->PlayerTalkClass->ClearMenus();
974  switch (bgTypeId)
975  {
976  case BATTLEGROUND_AV: player->PlayerTalkClass->SendGossipMenu(7616, GetGUID()); break;
977  case BATTLEGROUND_WS: player->PlayerTalkClass->SendGossipMenu(7599, GetGUID()); break;
978  case BATTLEGROUND_AB: player->PlayerTalkClass->SendGossipMenu(7642, GetGUID()); break;
979  case BATTLEGROUND_EY:
980  case BATTLEGROUND_NA:
981  case BATTLEGROUND_BE:
982  case BATTLEGROUND_AA:
983  case BATTLEGROUND_RL: player->PlayerTalkClass->SendGossipMenu(10024, GetGUID()); break;
984  default: break;
985  }
986  return false;
987  }
988  return true;
989 }
990 
992 {
993  return player->getLevel() >= 10
995  && player->getClass() == GetCreatureTemplate()->classNum;
996 }
997 
999 {
1000  if (!m_lootRecipient)
1001  return NULL;
1003 }
1004 
1006 {
1007  if (!m_lootRecipientGroup)
1008  return NULL;
1009  return sObjectMgr.GetGroupByLeader(m_lootRecipientGroup);
1010 }
1011 
1013 {
1014  // set the player whose group should receive the right
1015  // to loot the creature after it dies
1016  // should be set to NULL after the loot disappears
1017 
1018  if (!unit)
1019  {
1020  m_lootRecipient = 0;
1023  return;
1024  }
1025 
1027  if (!player) // normal creature, no player involved
1028  return;
1029 
1030  m_lootRecipient = player->GetGUID();
1031  if (Group* group = player->GetGroup())
1032  m_lootRecipientGroup = group->GetLeaderGUID();
1033 
1035 }
1036 
1037 // return true if this creature is tapped by the player or by a member of his group.
1038 bool Creature::isTappedBy(Player const* player) const
1039 {
1040  if (player->GetGUID() == m_lootRecipient)
1041  return true;
1042 
1043  Group const* playerGroup = player->GetGroup();
1044  if (!playerGroup || playerGroup != GetLootRecipientGroup()) // if we dont have a group we arent the recipient
1045  return false; // if creature doesnt have group bound it means it was solo killed by someone else
1046 
1047  return true;
1048 }
1049 
1051 {
1052  // this should only be used when the creature has already been loaded
1053  // preferably after adding to map, because mapid may not be valid otherwise
1054  CreatureData const* data = sObjectMgr.GetCreatureData(m_DBTableGuid);
1055  if (!data)
1056  {
1057  sLog.outError("Creature::SaveToDB failed, cannot get creature data!");
1058  return;
1059  }
1060 
1061  SaveToDB(GetMapId(), data->spawnMask, GetPhaseMask());
1062 }
1063 
1064 void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
1065 {
1066  // update in loaded data
1067  if (!m_DBTableGuid)
1069 
1070  CreatureData& data = sObjectMgr.NewOrExistCreatureData(m_DBTableGuid);
1071 
1072  uint32 displayId = GetNativeDisplayId();
1074  uint32 unit_flags = GetUInt32Value(UNIT_FIELD_FLAGS);
1075  uint32 dynamicflags = GetUInt32Value(UNIT_DYNAMIC_FLAGS);
1076 
1077  // check if it's a custom model and if not, use 0 for displayId
1078  CreatureInfo const* cinfo = GetCreatureTemplate();
1079  if (cinfo)
1080  {
1081  if (displayId == cinfo->modelid1 || displayId == cinfo->modelid2 ||
1082  displayId == cinfo->modelid3 || displayId == cinfo->modelid4)
1083  displayId = 0;
1084  }
1085 
1086  if (npcflag == cinfo->npcflag)
1087  npcflag = 0;
1088 
1089  if (unit_flags == cinfo->unit_flags)
1090  unit_flags = 0;
1091 
1092  if (dynamicflags == cinfo->dynamicflags)
1093  dynamicflags = 0;
1094 
1095  // data->guid = guid must not be update at save
1096  data.id = GetEntry();
1097  data.mapid = mapid;
1098  data.phaseMask = phaseMask;
1099  data.displayid = displayId;
1101  data.posX = GetPositionX();
1102  data.posY = GetPositionY();
1103  data.posZ = GetPositionZ();
1104  data.orientation = GetOrientation();
1106  // prevent add data integrity problems
1108  data.currentwaypoint = 0;
1109  data.curhealth = GetHealth();
1110  data.curmana = GetPower(POWER_MANA);
1111  // prevent add data integrity problems
1114  data.spawnMask = spawnMask;
1115  data.npcflag = npcflag;
1116  data.unit_flags = unit_flags;
1117  data.dynamicflags = dynamicflags;
1118 
1119  // updated in DB
1121 
1122  WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid);
1123 
1124  std::ostringstream ss;
1125  ss << "INSERT INTO creature (guid, id , map, spawnMask, phaseMask, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES ("
1126  << m_DBTableGuid << ","
1127  << GetEntry() << ","
1128  << mapid << ","
1129  << (uint32)spawnMask << ","
1130  << (uint32)phaseMask << ","
1131  << displayId << ","
1132  << GetEquipmentId() << ","
1133  << GetPositionX() << ","
1134  << GetPositionY() << ","
1135  << GetPositionZ() << ","
1136  << GetOrientation() << ","
1137  << m_respawnDelay << "," //respawn time
1138  << (float) m_respawnradius << "," //spawn distance (float)
1139  << (uint32) (0) << "," //currentwaypoint
1140  << GetHealth() << "," //curhealth
1141  << GetPower(POWER_MANA) << "," //curmana
1142  << GetDefaultMovementType() << "," //default movement generator type
1143  << npcflag << ","
1144  << unit_flags << ","
1145  << dynamicflags << ")";
1146 
1147  WorldDatabase.PExecuteLog("%s", ss.str().c_str());
1148 
1150 }
1151 
1153 {
1154  CreatureInfo const* cInfo = GetCreatureTemplate();
1155 
1156  uint32 rank = IsPet() ? 0 : cInfo->rank;
1157 
1158  // level
1159  uint32 const minlevel = cInfo->minlevel;
1160  uint32 const maxlevel = cInfo->maxlevel;
1161  uint8 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel);
1162  SetLevel(level);
1163 
1164  uint32 health;
1165  uint32 mana;
1166 
1167  CreatureBaseStats const* cCLS = sObjectMgr.GetCreatureClassLvlStats(level, cInfo->unit_class, cInfo->exp);
1168 
1169  // health
1170  health = cCLS->BaseHealth * cInfo->ModHealth;
1171 
1172  health *= _GetHealthMod(rank); // Apply custom config settting
1173  if (health < 1)
1174  health = 1;
1175 
1176  SetCreateHealth(health);
1177  SetMaxHealth(health);
1178  SetHealth(health);
1179  SetPlayerDamaged(false);
1180 
1181  // mana
1182  mana = cCLS->BaseMana * cInfo->ModMana;
1183  SetCreateMana(mana);
1184  SetMaxPower(POWER_MANA, mana); //MAX Mana
1185  SetPower(POWER_MANA, mana);
1186 
1187  SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, (float)health);
1188  SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, (float)mana);
1189 
1190  // damage
1191  float basedamage = cCLS->BaseDamage;
1192 
1193  float weaponBaseMinDamage = basedamage;
1194  float weaponBaseMaxDamage = basedamage * 1.5;
1195 
1196  SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, weaponBaseMinDamage);
1197  SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, weaponBaseMaxDamage);
1198 
1199  SetBaseWeaponDamage(OFF_ATTACK, MINDAMAGE, weaponBaseMinDamage);
1200  SetBaseWeaponDamage(OFF_ATTACK, MAXDAMAGE, weaponBaseMaxDamage);
1201 
1202  SetBaseWeaponDamage(RANGED_ATTACK, MINDAMAGE, weaponBaseMinDamage);
1203  SetBaseWeaponDamage(RANGED_ATTACK, MAXDAMAGE, weaponBaseMaxDamage);
1204 
1207 
1208  UpdateAllStats();
1209 }
1210 
1212 {
1213  switch (Rank) // define rates for each elite rank
1214  {
1215  case CREATURE_ELITE_NORMAL:
1216  return sWorld.getRate(RATE_CREATURE_NORMAL_HP);
1217  case CREATURE_ELITE_ELITE:
1218  return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP);
1220  return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_HP);
1222  return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_HP);
1223  case CREATURE_ELITE_RARE:
1224  return sWorld.getRate(RATE_CREATURE_ELITE_RARE_HP);
1225  default:
1226  return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP);
1227  }
1228 }
1229 
1231 {
1232  hasPlayerDamaged = set;
1233 }
1234 
1236 {
1237  switch (Rank) // define rates for each elite rank
1238  {
1239  case CREATURE_ELITE_NORMAL:
1240  return sWorld.getRate(RATE_CREATURE_NORMAL_DAMAGE);
1241  case CREATURE_ELITE_ELITE:
1242  return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE);
1247  case CREATURE_ELITE_RARE:
1248  return sWorld.getRate(RATE_CREATURE_ELITE_RARE_DAMAGE);
1249  default:
1250  return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE);
1251  }
1252 }
1253 
1255 {
1256  switch (Rank) // define rates for each elite rank
1257  {
1258  case CREATURE_ELITE_NORMAL:
1259  return sWorld.getRate(RATE_CREATURE_NORMAL_SPELLDAMAGE);
1260  case CREATURE_ELITE_ELITE:
1266  case CREATURE_ELITE_RARE:
1268  default:
1270  }
1271 }
1272 
1273 bool Creature::CreateFromProto(uint32 guidlow, uint32 entry, uint32 team, const CreatureData* data)
1274 {
1275  SetZoneScript();
1276  if (m_zoneScript && data)
1277  {
1278  entry = m_zoneScript->GetCreatureEntry(guidlow, data);
1279  if (!entry)
1280  return false;
1281  }
1282 
1283  CreatureInfo const* cinfo = sObjectMgr.GetCreatureTemplate(entry);
1284  if (!cinfo)
1285  {
1286  sLog.outErrorDb("Creature::CreateFromProto(): creature template (guidlow: %u, entry: %u) does not exist.", guidlow, entry);
1287  return false;
1288  }
1289 
1290  SetOriginalEntry(entry);
1291 
1292  Object::_Create(guidlow, entry, HIGHGUID_UNIT);
1293 
1294  if (!UpdateEntry(entry, team, data))
1295  return false;
1296 
1297  return true;
1298 }
1299 
1300 bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap)
1301 {
1302  CreatureData const* data = sObjectMgr.GetCreatureData(guid);
1303 
1304  if (!data)
1305  {
1306  sLog.outErrorDb("Creature (GUID: %u) not found in table creature, can't load. ", guid);
1307  return false;
1308  }
1309 
1310  m_DBTableGuid = guid;
1311  if (map->GetInstanceId() != 0)
1312  guid = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT);
1313 
1314  uint16 team = 0;
1315  if (!Create(guid, map, data->phaseMask, data->id, team, data->posX, data->posY, data->posZ, data->orientation, data))
1316  return false;
1317 
1318  //We should set first home position, because then AI calls home movement
1319  SetHomePosition(data->posX, data->posY, data->posZ, data->orientation);
1320 
1321  m_respawnradius = data->spawndist;
1322 
1323  m_respawnDelay = data->spawntimesecs;
1324  m_deathState = ALIVE;
1325 
1326  m_respawnTime = sObjectMgr.GetCreatureRespawnTime(m_DBTableGuid, GetInstanceId());
1327  if (m_respawnTime) // respawn on Update
1328  {
1329  m_deathState = DEAD;
1330  if (CanFly())
1331  {
1332  float tz = GetMap()->GetHeight(data->posX, data->posY, data->posZ, false);
1333  if (data->posZ - tz > 0.1)
1334  Relocate(data->posX, data->posY, tz);
1335  }
1336  }
1337 
1338  uint32 curhealth;
1339 
1340  if (!m_regenHealth)
1341  {
1342  curhealth = data->curhealth;
1343  if (curhealth)
1344  {
1345  curhealth = uint32(curhealth * _GetHealthMod(GetCreatureTemplate()->rank));
1346  if (curhealth < 1)
1347  curhealth = 1;
1348  }
1349  SetPower(POWER_MANA, data->curmana);
1350  }
1351  else
1352  {
1353  curhealth = GetMaxHealth();
1355  }
1356 
1357  SetHealth(m_deathState == ALIVE ? curhealth : 0);
1358 
1359  // checked at creature_template loading
1361 
1362  m_creatureData = data;
1363 
1364  if (addToMap && !GetMap()->AddToMap(this))
1365  return false;
1366  return true;
1367 }
1368 
1370 {
1371  Unit::SetCanDualWield(value);
1373 }
1374 
1375 void Creature::LoadEquipment(uint32 equip_entry, bool force)
1376 {
1377  if (equip_entry == 0)
1378  {
1379  if (force)
1380  {
1381  for (uint8 i = 0; i < 3; ++i)
1382  {
1384  SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO + (i * 2), 0);
1385  SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO + (i * 2) + 1, 0);
1386  }
1387  m_equipmentId = 0;
1388  }
1389  return;
1390  }
1391 
1392  if (EquipmentInfo const* einfo = sObjectMgr.GetEquipmentInfo(equip_entry))
1393  {
1394  m_equipmentId = equip_entry;
1395  for (uint8 i = 0; i < MAX_VIRTUAL_ITEM_SLOT; ++i)
1396  SetVirtualItem(VirtualItemSlot(i), einfo->equipentry[i]);
1397  }
1398  else if (EquipmentInfoRaw const* einfo = sObjectMgr.GetEquipmentInfoRaw(equip_entry))
1399  {
1400  m_equipmentId = equip_entry;
1401  for (uint8 i = 0; i < MAX_VIRTUAL_ITEM_SLOT; ++i)
1402  SetVirtualItemRaw(VirtualItemSlot(i), einfo->equipmodel[i], einfo->equipinfo[i], einfo->equipslot[i]);
1403  }
1404 }
1405 
1407 {
1408  if (item_id == 0)
1409  {
1411  SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO + (slot * 2) + 0, 0);
1412  SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO + (slot * 2) + 1, 0);
1413  return;
1414  }
1415 
1416  ItemTemplate const* proto = ObjectMgr::GetItemTemplate(item_id);
1417  if (!proto)
1418  {
1419  sLog.outError("Not listed in 'item_template' item (ID:%u) used as virtual item for " UI64FMTD "", item_id, GetGUID());
1420  return;
1421  }
1422 
1430 }
1431 
1433 {
1434  SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + slot, display_id);
1435  SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO + (slot * 2) + 0, info0);
1436  SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO + (slot * 2) + 1, info1);
1437 }
1438 
1439 bool Creature::hasQuest(uint32 quest_id) const
1440 {
1441  QuestRelations qr = sObjectMgr.mCreatureQuestRelations;
1442  for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
1443  {
1444  if (itr->second == quest_id)
1445  return true;
1446  }
1447  return false;
1448 }
1449 
1451 {
1452  QuestRelations qir = sObjectMgr.mCreatureQuestInvolvedRelations;
1453  for (QuestRelations::const_iterator itr = qir.lower_bound(GetEntry()); itr != qir.upper_bound(GetEntry()); ++itr)
1454  {
1455  if (itr->second == quest_id)
1456  return true;
1457  }
1458  return false;
1459 }
1460 
1462 {
1463  if (!m_DBTableGuid)
1464  {
1465  sLog.outDebug("Trying to delete not saved creature!");
1466  return;
1467  }
1468 
1469  sObjectMgr.SaveCreatureRespawnTime(m_DBTableGuid, GetInstanceId(), 0);
1470  sObjectMgr.DeleteCreatureData(m_DBTableGuid);
1471 
1473  WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid);
1474  WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid = '%u'", m_DBTableGuid);
1475  WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid = '%u'", m_DBTableGuid);
1476  WorldDatabase.PExecuteLog("DELETE FROM game_event_model_equip WHERE guid = '%u'", m_DBTableGuid);
1478 }
1479 
1481 {
1483  return true;
1484 
1485  if (IsAlive() || isDying() || m_corpseRemoveTime > time(NULL))
1486  return false;
1487 
1488  return true;
1489 }
1490 
1491 bool Creature::CanAlwaysSee(WorldObject const* obj) const
1492 {
1493  if (IsAIEnabled && AI()->CanSeeAlways(obj))
1494  return true;
1495 
1496  return false;
1497 }
1498 
1499 bool Creature::canStartAttack(Unit const* who, bool force) const
1500 {
1501  if (IsCivilian())
1502  return false;
1503 
1504  // This set of checks is should be done only for creatures
1505  if ((HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC) && who->GetTypeId() != TYPEID_PLAYER) // flag is valid only for non player characters
1506  || (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && who->GetTypeId() == TYPEID_PLAYER) // immune to PC and target is a player, return false
1507  || (who->GetOwner() && who->GetOwner()->GetTypeId() == TYPEID_PLAYER && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))) // player pets are immune to pc as well
1508  return false;
1509 
1510  // Do not attack non-combat pets
1512  return false;
1513 
1515  return false;
1516 
1517  if (!force)
1518  {
1519  if (!_IsTargetAcceptable(who))
1520  return false;
1521 
1522  if (who->IsInCombat() && IsWithinDist(who, ATTACK_DISTANCE))
1523  if (Unit* victim = who->getAttackerForHelper())
1525  force = true;
1526 
1527  if (!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who) + m_CombatDistance)))
1528  return false;
1529  }
1530 
1531  if (!CanCreatureAttack(who, force))
1532  return false;
1533 
1534  return IsWithinLOSInMap(who);
1535 }
1536 
1537 float Creature::GetAttackDistance(Unit const* player) const
1538 {
1539  float aggroRate = sWorld.getRate(RATE_CREATURE_AGGRO);
1540  if (aggroRate == 0)
1541  return 0.0f;
1542 
1543  uint32 playerlevel = player->getLevelForTarget(this);
1544  uint32 creaturelevel = getLevelForTarget(player);
1545 
1546  int32 leveldif = int32(playerlevel) - int32(creaturelevel);
1547 
1548  // "The maximum Aggro Radius has a cap of 25 levels under. Example: A level 30 char has the same Aggro Radius of a level 5 char on a level 60 mob."
1549  if (leveldif < - 25)
1550  leveldif = -25;
1551 
1552  // "The aggro radius of a mob having the same level as the player is roughly 20 yards"
1553  float RetDistance = 20;
1554 
1555  // "Aggro Radius varies with level difference at a rate of roughly 1 yard/level"
1556  // radius grow if playlevel < creaturelevel
1557  RetDistance -= (float)leveldif;
1558 
1559  if (creaturelevel + 5 <= int32(sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)))
1560  {
1561  // detect range auras
1563 
1564  // detected range auras
1565  RetDistance += player->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE);
1566  }
1567 
1568  // "Minimum Aggro Radius for a mob seems to be combat range (5 yards)"
1569  if (RetDistance < 5)
1570  RetDistance = 5;
1571 
1572  return (RetDistance * aggroRate);
1573 }
1574 
1576 {
1578 
1579  if (s == JUST_DIED)
1580  {
1581  m_corpseRemoveTime = time(NULL) + m_corpseDelay;
1582  m_respawnTime = time(NULL) + m_respawnDelay + m_corpseDelay;
1583 
1584  // always save boss respawn time at death to prevent crash cheating
1586  SaveRespawnTime();
1587 
1588  SetTarget(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
1590 
1591  SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // if creature is mounted on a virtual mount, remove it at death
1592 
1593  setActive(false);
1594 
1595  if (HasSearchedAssistance())
1596  {
1597  SetNoSearchAssistance(false);
1598  UpdateSpeed(MOVE_RUN, false);
1599  }
1600 
1601  //Dismiss group if is leader
1602  if (m_formation && m_formation->getLeader() == this)
1603  m_formation->FormationReset(true);
1604 
1605  if ((CanFly() || IsFlying()))
1607 
1608  SetHealth(0);
1609  SetPower(getPowerType(), 0);
1610 
1611  if (m_zoneScript)
1613 
1615  }
1616  else if (s == JUST_RESPAWNED)
1617  {
1618  SetFullHealth();
1619  SetLootRecipient(nullptr);
1620  SetPlayerDamaged(false);
1621 
1623 
1625 
1626  if (!IsPet())
1627  {
1628  CreatureData const* creatureData = GetCreatureData();
1629  CreatureInfo const* cinfo = GetCreatureTemplate();
1630 
1632 
1634 
1636 
1637  if (creatureData && GetPhaseMask() != creatureData->phaseMask)
1638  SetPhaseMask(creatureData->phaseMask, false);
1639  }
1640 
1642  LoadCreaturesAddon(true);
1643 
1645 
1646  // Prevents the creature from re-spawning at the location of it's death
1648  }
1649 }
1650 
1651 void Creature::Respawn(bool force)
1652 {
1654 
1655  if (force)
1656  {
1657  if (IsAlive())
1659  else if (getDeathState() != CORPSE)
1661  }
1662 
1663  RemoveCorpse(false);
1664 
1665  if (getDeathState() == DEAD)
1666  {
1667  if (m_DBTableGuid)
1668  sObjectMgr.SaveCreatureRespawnTime(m_DBTableGuid, GetInstanceId(), 0);
1669 
1670  DEBUG_LOG("Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)", GetName(), GetGUIDLow(), GetGUID(), GetEntry());
1671  m_respawnTime = 0;
1673  loot.clear();
1674  if (m_originalEntry != GetEntry())
1676 
1677  SelectLevel();
1678 
1680 
1682 
1683  //Call AI respawn virtual function
1684  if (IsAIEnabled)
1685  {
1686  //reset the AI to be sure no dirty or uninitialized values will be used till next tick
1687  AI()->Reset();
1688  TriggerJustRespawned = true; //delay event to next tick so all creatures are created on the map before processing
1689  }
1690 
1691  uint32 poolid = sPoolMgr.IsPartOfAPool<Creature>(GetDBTableGUIDLow());
1692  if (poolid)
1693  sPoolMgr.UpdatePool<Creature>(poolid, GetDBTableGUIDLow());
1694 
1695  //Re-initialize reactstate that could be altered by movementgenerators
1697  }
1698 
1700 }
1701 
1702 void Creature::ForcedDespawn(uint32 timeMSToDespawn)
1703 {
1704  if (timeMSToDespawn)
1705  {
1706  ForcedDespawnDelayEvent* pEvent = new ForcedDespawnDelayEvent(*this);
1707 
1708  m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn));
1709  return;
1710  }
1711 
1712  if (IsAlive())
1714 
1715  RemoveCorpse(false);
1716 }
1717 
1718 void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/)
1719 {
1720  if (TempSummon* summon = this->ToTempSummon())
1721  summon->UnSummon(msTimeToDespawn);
1722  else
1723  ForcedDespawn(msTimeToDespawn);
1724 }
1725 
1726 bool Creature::IsImmuneToSpell(SpellEntry const* spellInfo, bool useCharges)
1727 {
1728  if (!spellInfo)
1729  return false;
1730 
1731  if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))
1732  return true;
1733 
1734  return Unit::IsImmuneToSpell(spellInfo, useCharges);
1735 }
1736 
1737 bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool castOnSelf) const
1738 {
1739  if (!castOnSelf && GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->EffectMechanic[index] - 1)))
1740  return true;
1741 
1742  if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effect[index] == SPELL_EFFECT_HEAL)
1743  return true;
1744 
1745  return Unit::IsImmuneToSpellEffect(spellInfo, index, castOnSelf);
1746 }
1747 
1748 bool Creature::isElite() const
1749 {
1750  if (IsPet())
1751  return false;
1752 
1753  uint32 rank = GetCreatureTemplate()->rank;
1754  return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
1755 }
1756 
1758 {
1759  if (IsPet())
1760  return false;
1761 
1762  return (GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_BOSS_MOB) != 0;
1763 }
1764 
1766 {
1767  if (!victim)
1768  return NULL;
1769 
1770  for (uint32 i = 0; i < CREATURE_MAX_SPELLS; i++)
1771  {
1772  if (!m_spells[i])
1773  continue;
1774  SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]);
1775  if (!spellInfo)
1776  {
1777  sLog.outError("WORLD: unknown spell id %i\n", m_spells[i]);
1778  continue;
1779  }
1780 
1781  bool bcontinue = true;
1782  for (uint32 j = 0; j < 3; j++)
1783  {
1784  if ((spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE) ||
1785  (spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) ||
1786  (spellInfo->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
1787  (spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH)
1788  )
1789  {
1790  bcontinue = false;
1791  break;
1792  }
1793  }
1794  if (bcontinue)
1795  continue;
1796 
1797  if (spellInfo->manaCost > GetPower(POWER_MANA))
1798  continue;
1799 
1800  SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
1801  float range = GetSpellMaxRange(srange);
1802  float minrange = GetSpellMinRange(srange);
1803  float dist = GetDistance(victim);
1804  if (dist > range || dist < minrange)
1805  continue;
1807  continue;
1809  continue;
1810  return spellInfo;
1811  }
1812  return NULL;
1813 }
1814 
1816 {
1817  if (!victim)
1818  return NULL;
1819 
1820  for (uint32 i = 0; i < CREATURE_MAX_SPELLS; i++)
1821  {
1822  if (!m_spells[i])
1823  continue;
1824  SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]);
1825  if (!spellInfo)
1826  {
1827  sLog.outError("WORLD: unknown spell id %i\n", m_spells[i]);
1828  continue;
1829  }
1830 
1831  bool bcontinue = true;
1832  for (uint32 j = 0; j < 3; j++)
1833  {
1834  if ((spellInfo->Effect[j] == SPELL_EFFECT_HEAL))
1835  {
1836  bcontinue = false;
1837  break;
1838  }
1839  }
1840  if (bcontinue)
1841  continue;
1842 
1843  if (spellInfo->manaCost > GetPower(POWER_MANA))
1844  continue;
1845 
1846  SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
1847  float range = GetSpellMaxRange(srange);
1848  float minrange = GetSpellMinRange(srange);
1849  float dist = GetDistance(victim);
1850  //if (!isInFront(victim, range) && spellInfo->AttributesEx)
1851  // continue;
1852  if (dist > range || dist < minrange)
1853  continue;
1855  continue;
1857  continue;
1858  return spellInfo;
1859  }
1860  return NULL;
1861 }
1862 
1863 // select nearest hostile unit within the given distance (regardless of threat list).
1864 Unit* Creature::SelectNearestTarget(float dist, bool playerOnly /* = false */) const
1865 {
1867  Cell cell(p);
1868  cell.SetNoCreate();
1869 
1870  Unit* target = NULL;
1871 
1872  {
1873  Oregon::NearestHostileUnitCheck u_check(this, dist, playerOnly);
1874  Oregon::UnitLastSearcher<Oregon::NearestHostileUnitCheck> searcher(this, target, u_check);
1875 
1878 
1879  cell.Visit(p, world_unit_searcher, *GetMap(), *this, dist);
1880  cell.Visit(p, grid_unit_searcher, *GetMap(), *this, dist);
1881  }
1882 
1883  return target;
1884 }
1885 
1886 // select nearest hostile unit within the given attack distance (i.e. distance is ignored if > than ATTACK_DISTANCE), regardless of threat list.
1888 {
1890  Cell cell(p);
1891  cell.SetNoCreate();
1892 
1893  Unit *target = nullptr;
1894 
1895  if (dist > MAX_VISIBILITY_DISTANCE)
1896  {
1897  sLog.outError("Creature (GUID: %u Entry: %u) SelectNearestTargetInAttackDistance called with dist > MAX_VISIBILITY_DISTANCE. Distance set to ATTACK_DISTANCE.", GetGUIDLow(), GetEntry());
1898  dist = ATTACK_DISTANCE;
1899  }
1900 
1903 
1906 
1907  cell.Visit(p, world_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE > dist ? ATTACK_DISTANCE : dist);
1908  cell.Visit(p, grid_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE > dist ? ATTACK_DISTANCE : dist);
1909 
1910  return target;
1911 }
1912 
1914 {
1915  WorldPacket data(SMSG_AI_REACTION, 12);
1916 
1917  data << uint64(GetGUID());
1918  data << uint32(reactionType);
1919 
1920  ((WorldObject*)this)->SendMessageToSet(&data, true);
1921 
1922  sLog.outDebug("WORLD: Sent SMSG_AI_REACTION, type %u.", reactionType);
1923 }
1924 
1926 {
1927  if (!m_AlreadyCallAssistance && GetVictim() && !IsPet() && !isCharmed())
1928  {
1929  SetNoCallAssistance(true);
1930 
1931  float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS);
1932 
1933  if (radius > 0)
1934  {
1935  std::list<Creature*> assistList;
1936 
1937  {
1939  Cell cell(p);
1940  cell.SetNoCreate();
1941 
1942  Oregon::AnyAssistCreatureInRangeCheck u_check(this, GetVictim(), radius);
1943  Oregon::CreatureListSearcher<Oregon::AnyAssistCreatureInRangeCheck> searcher(this, assistList, u_check);
1944 
1946 
1947  cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
1948  }
1949 
1950  if (!assistList.empty())
1951  {
1952  AssistDelayEvent* e = new AssistDelayEvent(GetVictim()->GetGUID(), *this);
1953  while (!assistList.empty())
1954  {
1955  // Pushing guids because in delay can happen some creature gets despawned => invalid pointer
1956  e->AddAssistant((*assistList.begin())->GetGUID());
1957  assistList.pop_front();
1958  }
1960  }
1961  }
1962  }
1963 }
1964 
1965 void Creature::CallForHelp(float radius)
1966 {
1967  if (radius <= 0.0f || !GetVictim() || IsPet() || isCharmed())
1968  return;
1969 
1971  Cell cell(p);
1972  cell.SetNoCreate();
1973 
1974  Oregon::CallOfHelpCreatureInRangeDo u_do(this, GetVictim(), radius);
1976 
1978 
1979  cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
1980 }
1981 
1982 bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
1983 {
1984  if (IsInEvadeMode())
1985  return false;
1986 
1987  // is it true?
1989  return false;
1990 
1991  // we don't need help from zombies :)
1992  if (!IsAlive())
1993  return false;
1994 
1995  // we don't need help from non-combatant ;)
1996  if (IsCivilian())
1997  return false;
1998 
2000  return false;
2001 
2002  // skip fighting creature
2003  if (IsInCombat())
2004  return false;
2005 
2006  // only free creature
2007  if (GetCharmerOrOwnerGUID())
2008  return false;
2009 
2010  // only from same creature faction
2011  if (checkfaction)
2012  {
2013  if (GetFaction() != u->GetFaction())
2014  return false;
2015  }
2016  else
2017  {
2018  if (!IsFriendlyTo(u))
2019  return false;
2020  }
2021 
2022  // skip non hostile to caster enemy creatures
2023  if (!IsHostileTo(enemy))
2024  return false;
2025 
2026  return true;
2027 }
2028 
2029 // use this function to avoid having hostile creatures attack
2030 // friendlies and other mobs they shouldn't attack
2031 bool Creature::_IsTargetAcceptable(Unit const* target) const
2032 {
2033  ASSERT(target);
2034 
2035  // if the target cannot be attacked, the target is not acceptable
2036  if (IsFriendlyTo(target)
2037  || !target->isTargetableForAttack(false))
2038  return false;
2039 
2040  if (target->HasUnitState(UNIT_STATE_DIED))
2041  {
2042  // guards can detect fake death
2044  return true;
2045  else
2046  return false;
2047  }
2048 
2049  Unit const* targetVictim = target->getAttackerForHelper();
2050 
2051  // if I'm already fighting target, or I'm hostile towards the target, the target is acceptable
2052  if (IsInCombatWith(target) || IsHostileTo(target))
2053  return true;
2054 
2055  // if the target's victim is friendly, and the target is neutral, the target is acceptable
2056  if (targetVictim && IsFriendlyTo(targetVictim))
2057  return true;
2058 
2059  // if the target's victim is not friendly, or the target is friendly, the target is not acceptable
2060  return false;
2061 }
2062 
2064 {
2066  return;
2067 
2068  sObjectMgr.SaveCreatureRespawnTime(m_DBTableGuid, GetInstanceId(), m_respawnTime);
2069 }
2070 
2071 bool Creature::CanCreatureAttack(Unit const* victim, bool /*force*/) const
2072 {
2073  if (!victim)
2074  return false;
2075 
2076  if (!victim->IsInMap(this))
2077  return false;
2078 
2079  if (!IsValidAttackTarget(victim))
2080  return false;
2081 
2082  if (!victim->isInAccessiblePlaceFor(this))
2083  return false;
2084 
2085  if (IsAIEnabled && !AI()->CanAIAttack(victim))
2086  return false;
2087 
2088  // we cannot attack in evade mode
2089  if (IsInEvadeMode())
2090  return false;
2091 
2092  // or if enemy is in evade mode
2093  if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode())
2094  return false;
2095 
2096  if (GetMap()->IsDungeon())
2097  return true;
2098 
2099  if (Unit* u = GetCharmerOrOwner())
2100  {
2101  if (u->GetTypeId() != TYPEID_PLAYER)
2102  {
2103  // don't check distance to home position if recently damaged, this should include taunt auras
2105  return true;
2106  }
2107  }
2108 
2109  // Get the correct threat range from the config.
2110  float dist = std::max<float>(GetAttackDistance(victim), sWorld.getConfig(CONFIG_THREAT_RADIUS) + m_CombatDistance);
2111 
2112  if (Unit* unit = GetCharmerOrOwner())
2113  return victim->IsWithinDist(unit, dist);
2114  else
2115  {
2116  // include sizes for huge npcs
2117  dist += GetObjectSize() + victim->GetObjectSize();
2118 
2119  // to prevent creatures in air ignore attacks because distance is already too high...
2120  if (GetCreatureTemplate()->InhabitType & INHABIT_AIR)
2121  return victim->IsInDist2d(&m_homePosition, dist);
2122  else
2123  return victim->IsInDist(&m_homePosition, dist);
2124  }
2125 }
2126 
2128 {
2129  if (m_DBTableGuid)
2130  {
2132  return addon;
2133  }
2134 
2135  // dependent from heroic mode entry
2137 }
2138 
2139 //creature_addon table
2141 {
2142  CreatureDataAddon const* cainfo = GetCreatureAddon();
2143  if (!cainfo)
2144  return false;
2145 
2146  if (cainfo->mount != 0)
2147  Mount(cainfo->mount);
2148 
2149  if (cainfo->bytes1 != 0)
2151 
2152  // Sheath State
2154 
2155  if (cainfo->emote != 0)
2157 
2158  //Load Path
2159  if (cainfo->path_id != 0)
2160  m_path_id = cainfo->path_id;
2161 
2162  if (cainfo->auras)
2163  {
2164  for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura)
2165  {
2166  SpellEntry const* AdditionalSpellInfo = sSpellStore.LookupEntry(cAura->spell_id);
2167  if (!AdditionalSpellInfo)
2168  {
2169  sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u) has wrong spell %u defined in auras field.", GetGUIDLow(), GetEntry(), cAura->spell_id);
2170  continue;
2171  }
2172 
2173  // skip already applied aura
2174  if (HasAura(cAura->spell_id, cAura->effect_idx))
2175  {
2176  if (!reload)
2177  sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u) has duplicate aura (spell %u effect %u) in auras field.", GetGUIDLow(), GetEntry(), cAura->spell_id, cAura->effect_idx);
2178 
2179  continue;
2180  }
2181 
2182  Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, cAura->effect_idx, NULL, this, this, 0);
2183  AddAura(AdditionalAura);
2184  sLog.outDebug("Spell: %u with Aura %u added to creature (GUIDLow: %u Entry: %u)", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[0], GetGUIDLow(), GetEntry());
2185  }
2186  }
2187  return true;
2188 }
2189 
2190 // Send a message to LocalDefense channel for players opposition team in the zone
2192 {
2193  uint32 enemy_team = attacker->GetTeam();
2194 
2196  data << (uint32)GetZoneId();
2197  sWorld.SendGlobalMessage(&data, NULL, (enemy_team == ALLIANCE ? HORDE : ALLIANCE));
2198 }
2199 
2201 {
2202  if (!CanHaveThreatList())
2203  {
2204  sLog.outError("Creature entry %u call SetInCombatWithZone but creature cannot have threat list.", GetEntry());
2205  return;
2206  }
2207 
2208  Map* pMap = GetMap();
2209 
2210  if (!pMap->IsDungeon())
2211  {
2212  sLog.outError("Creature entry %u call SetInCombatWithZone for map (id: %u) that isn't an instance.", GetEntry(), pMap->GetId());
2213  return;
2214  }
2215 
2216  Map::PlayerList const& PlList = pMap->GetPlayers();
2217 
2218  if (PlList.isEmpty())
2219  return;
2220 
2221  for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
2222  {
2223  if (Player* pPlayer = i->GetSource())
2224  {
2225  if (pPlayer->IsGameMaster())
2226  continue;
2227 
2228  if (pPlayer->IsAlive())
2229  {
2230  pPlayer->SetInCombatWith(this);
2231  AddThreat(pPlayer, 0.0f);
2232  }
2233  }
2234  }
2235 }
2236 
2237 void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
2238 {
2239  m_CreatureSpellCooldowns[spell_id] = end_time;
2240 }
2241 
2242 void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t end_time)
2243 {
2244  m_CreatureCategoryCooldowns[category] = end_time;
2245 }
2246 
2248 {
2249  SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid);
2250  if (!spellInfo)
2251  return;
2252 
2253  uint32 cooldown = GetSpellRecoveryTime(spellInfo);
2254  if (Player* modOwner = GetSpellModOwner())
2255  modOwner->ApplySpellMod(spellid, SPELLMOD_COOLDOWN, cooldown);
2256 
2257  if (cooldown)
2258  _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown / IN_MILLISECONDS);
2259 
2260  if (spellInfo->Category)
2261  _AddCreatureCategoryCooldown(spellInfo->Category, time(NULL));
2262 
2263  m_GlobalCooldown = spellInfo->StartRecoveryTime;
2264 
2265  if (Unit* owner = GetCharmerOrOwner())
2266  if (owner->GetTypeId() == TYPEID_PLAYER)
2267  {
2268  WorldPacket data(SMSG_SPELL_COOLDOWN, (4 + 8));
2269  data << uint64(GetGUID());
2270  data << uint8(0x0); // flags (0x1, 0x2)
2271  data << uint32(spellid);
2272  data << uint32(cooldown); // in m.secs
2273 
2274  owner->ToPlayer()->GetSession()->SendPacket(&data);
2275  }
2276 }
2277 
2279 {
2280  SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
2281  if (!spellInfo)
2282  return false;
2283 
2284  // check global cooldown if spell affected by it
2285  if (spellInfo->StartRecoveryCategory > 0 && m_GlobalCooldown > 0)
2286  return true;
2287 
2288  CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category);
2289  return (itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILLISECONDS)) > time(NULL));
2290 }
2291 
2293 {
2294  CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id);
2295  return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id);
2296 }
2297 
2299 {
2301 }
2302 
2303 bool Creature::HasSpell(uint32 spellID) const
2304 {
2305  uint8 i;
2306  for (i = 0; i < CREATURE_MAX_SPELLS; ++i)
2307  if (spellID == m_spells[i])
2308  break;
2309  return i < CREATURE_MAX_SPELLS; //broke before end of iteration of known spells
2310 }
2311 
2313 {
2314  time_t now = time(NULL);
2315  if (m_respawnTime > now)
2316  return m_respawnTime;
2317  else
2318  return now;
2319 }
2320 
2321 void Creature::GetRespawnPosition(float& x, float& y, float& z, float* ori, float* dist) const
2322 {
2323  if (m_DBTableGuid)
2324  {
2325  if (CreatureData const* data = sObjectMgr.GetCreatureData(GetDBTableGUIDLow()))
2326  {
2327  x = data->posX;
2328  y = data->posY;
2329  z = data->posZ;
2330  if (ori)
2331  *ori = data->orientation;
2332  if (dist)
2333  *dist = data->spawndist;
2334 
2335  return;
2336  }
2337  }
2338 
2339  x = GetPositionX();
2340  y = GetPositionY();
2341  z = GetPositionZ();
2342  if (ori)
2343  *ori = GetOrientation();
2344  if (dist)
2345  *dist = 0;
2346 }
2347 
2349 {
2350  if (loot.loot_type != LOOT_SKINNING && !IsPet() && GetCreatureTemplate()->SkinLootId && hasLootRecipient())
2353 
2354  time_t now = time(NULL);
2355  // Do not reset corpse remove time if corpse is already removed
2356  if (m_corpseRemoveTime <= now)
2357  return;
2358 
2359  float decayRate = sWorld.getRate(RATE_CORPSE_DECAY_LOOTED);
2360 
2361  // corpse skinnable, but without skinning flag, and then skinned, corpse will despawn next update
2362  if (loot.loot_type == LOOT_SKINNING)
2363  m_corpseRemoveTime = now;
2364  else
2365  m_corpseRemoveTime = now + uint32(m_corpseDelay * decayRate);
2366 
2368 }
2369 
2371 {
2372  if (!isWorldBoss() || !target->ToUnit())
2373  return Unit::getLevelForTarget(target);
2374 
2375  uint16 level = target->ToUnit()->getLevel() + sWorld.getConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF);
2376  if (level < 1)
2377  return 1;
2378  if (level > 255)
2379  return 255;
2380  return uint8(level);
2381 }
2382 
2383 std::string Creature::GetAIName() const
2384 {
2385  return sObjectMgr.GetCreatureTemplate(GetEntry())->AIName;
2386 }
2387 
2389 {
2390  return sObjectMgr.GetScriptName(GetScriptId());
2391 }
2392 
2394 {
2396 }
2397 
2399 {
2400  return sObjectMgr.GetNpcVendorItemList(GetEntry());
2401 }
2402 
2404 {
2405  if (!vItem->maxcount)
2406  return vItem->maxcount;
2407 
2408  VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
2409  for (; itr != m_vendorItemCounts.end(); ++itr)
2410  if (itr->itemId == vItem->item)
2411  break;
2412 
2413  if (itr == m_vendorItemCounts.end())
2414  return vItem->maxcount;
2415 
2416  VendorItemCount* vCount = &*itr;
2417 
2418  time_t ptime = time(NULL);
2419 
2420  if (vCount->lastIncrementTime + vItem->incrtime <= uint32(ptime))
2421  if (ItemTemplate const* pProto = sObjectMgr.GetItemTemplate(vItem->item))
2422  {
2423  uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime);
2424  if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount)
2425  {
2426  m_vendorItemCounts.erase(itr);
2427  return vItem->maxcount;
2428  }
2429 
2430  vCount->count += diff * pProto->BuyCount;
2431  vCount->lastIncrementTime = ptime;
2432  }
2433 
2434  return vCount->count;
2435 }
2436 
2438 {
2439  if (!vItem->maxcount)
2440  return 0;
2441 
2442  VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
2443  for (; itr != m_vendorItemCounts.end(); ++itr)
2444  if (itr->itemId == vItem->item)
2445  break;
2446 
2447  if (itr == m_vendorItemCounts.end())
2448  {
2449  uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount - used_count : 0;
2450  m_vendorItemCounts.push_back(VendorItemCount(vItem->item, new_count));
2451  return new_count;
2452  }
2453 
2454  VendorItemCount* vCount = &*itr;
2455 
2456  time_t ptime = time(NULL);
2457 
2458  if (vCount->lastIncrementTime + vItem->incrtime <= uint32(ptime))
2459  if (ItemTemplate const* pProto = sObjectMgr.GetItemTemplate(vItem->item))
2460  {
2461  uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime);
2462  if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount)
2463  vCount->count += diff * pProto->BuyCount;
2464  else
2465  vCount->count = vItem->maxcount;
2466  }
2467 
2468  vCount->count = vCount->count > used_count ? vCount->count - used_count : 0;
2469  vCount->lastIncrementTime = ptime;
2470  return vCount->count;
2471 }
2472 
2474 {
2475  return sObjectMgr.GetNpcTrainerSpells(GetEntry());
2476 }
2477 
2478 // overwrite WorldObject function for proper name localization
2479 const char* Creature::GetNameForLocaleIdx(int32 loc_idx) const
2480 {
2481  if (loc_idx >= 0)
2482  {
2483  CreatureLocale const* cl = sObjectMgr.GetCreatureLocale(GetEntry());
2484  if (cl)
2485  {
2486  if (cl->Name.size() > uint32(loc_idx) && !cl->Name[loc_idx].empty())
2487  return cl->Name[loc_idx].c_str();
2488  }
2489  }
2490 
2491  return GetName();
2492 }
2493 
2495 {
2496  if (!m_DBTableGuid) // only hard-spawned creatures from DB can have a linked master
2497  return NULL;
2498 
2499  if (uint32 targetGuid = sObjectMgr.GetLinkedRespawnGuid(m_DBTableGuid))
2500  return sObjectMgr.GetCreatureData(targetGuid);
2501 
2502  return NULL;
2503 }
2504 
2505 // returns master's remaining respawn time if any
2507 {
2508  if (!m_DBTableGuid) // only hard-spawned creatures from DB can have a linked master
2509  return 0;
2510 
2511  if (uint32 targetGuid = sObjectMgr.GetLinkedRespawnGuid(m_DBTableGuid))
2512  {
2513  Map* targetMap = NULL;
2514  if (const CreatureData* data = sObjectMgr.GetCreatureData(targetGuid))
2515  {
2516  if (data->mapid == GetMapId()) // look up on the same map
2517  targetMap = GetMap();
2518  else // it shouldn't be instanceable map here
2519  targetMap = MapManager::Instance().FindMap(data->mapid);
2520  }
2521  if (targetMap)
2522  return sObjectMgr.GetCreatureRespawnTime(targetGuid, targetMap->GetInstanceId());
2523  }
2524 
2525  return 0;
2526 }
2527 
2528 bool Creature::SetWalk(bool enable)
2529 {
2530  if (!Unit::SetWalk(enable))
2531  return false;
2532 
2534  data << GetPackGUID();
2535  SendMessageToSet(&data, false);
2536  return true;
2537 }
2538 
2539 bool Creature::SetSwim(bool enable)
2540 {
2541  if (!Unit::SetSwim(enable))
2542  return false;
2543 
2544  if (!movespline->Initialized())
2545  return true;
2546 
2548  data << GetPackGUID();
2549  SendMessageToSet(&data, true);
2550  return true;
2551 }
2552 
2553 bool Creature::SetCanFly(bool enable, bool /*packetOnly = false */)
2554 {
2555  if (!Unit::SetCanFly(enable))
2556  return false;
2557 
2558  if (!movespline->Initialized())
2559  return true;
2560 
2562  data << GetPackGUID();
2563  SendMessageToSet(&data, false);
2564  return true;
2565 }
2566 
2567 bool Creature::SetWaterWalking(bool enable, bool packetOnly /* = false */)
2568 {
2569  if (!packetOnly && !Unit::SetWaterWalking(enable))
2570  return false;
2571 
2572  if (!movespline->Initialized())
2573  return true;
2574 
2576  data << GetPackGUID();
2577  SendMessageToSet(&data, true);
2578  return true;
2579 }
2580 
2581 bool Creature::SetFeatherFall(bool enable, bool packetOnly /* = false */)
2582 {
2583  if (!packetOnly && !Unit::SetFeatherFall(enable))
2584  return false;
2585 
2586  if (!movespline->Initialized())
2587  return true;
2588 
2590  data << GetPackGUID();
2591  SendMessageToSet(&data, true);
2592  return true;
2593 }
2594 
2595 bool Creature::SetHover(bool enable, bool packetOnly /*= false*/)
2596 {
2597  if (!packetOnly && !Unit::SetHover(enable))
2598  return false;
2599 
2600  if (!movespline->Initialized())
2601  return true;
2602 
2604  data << GetPackGUID();
2605  SendMessageToSet(&data, false);
2606  return true;
2607 }
2608 
2609 bool Creature::SetLevitate(bool apply, bool packetOnly)
2610 {
2611  if (!packetOnly && !Unit::SetLevitate(apply))
2612  return false;
2613 
2614  if (!movespline->Initialized())
2615  return true;
2616 
2618  data << GetPackGUID();
2619  SendMessageToSet(&data, true);
2620  return true;
2621 }
2622 
2623 void Creature::UpdateMovementFlags(bool packetOnly)
2624 {
2626  return;
2627 
2628  // Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc)
2629  float ground = GetMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ());
2630 
2631  if (ground < INVALID_HEIGHT)
2632  {
2633  sLog.outDebug("FallGround: creature %u at map %u (x: %f, y: %f, z: %f), not able to retrive a proper GetHeight (z: %f).",
2634  GetEntry(), GetMap()->GetId(), GetPositionX(), GetPositionX(), GetPositionZ(), ground);
2635  return;
2636  }
2637 
2638  bool isInAir = (G3D::fuzzyGt(GetPositionZ(), ground + 0.05f) || G3D::fuzzyLt(GetPositionZ(), ground - 0.05f)); // Can be underground too, prevent the falling
2639 
2640  if (GetCreatureTemplate()->InhabitType & INHABIT_AIR && isInAir && !IsFalling())
2641  SetLevitate(true, packetOnly);
2642  else
2643  SetLevitate(false);
2644 
2645  if (!isInAir)
2647 
2648  SetSwim(CanSwim() && GetBaseMap()->IsSwimmable(GetPositionX(), GetPositionY(), GetPositionZ()));
2649 }
2650 
2652 {
2654 }
2655 
2657 {
2658  CreatureTextRepeatIds& repeats = m_textRepeat[textGroup];
2659  if (std::find(repeats.begin(), repeats.end(), id) == repeats.end())
2660  repeats.push_back(id);
2661  else
2662  sLog.outError("CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), GetName(), GetGUIDLow(), GetEntry(), uint32(id));
2663 }
2664 
2666 {
2668 
2669  CreatureTextRepeatGroup::const_iterator groupItr = m_textRepeat.find(textGroup);
2670  if (groupItr != m_textRepeat.end())
2671  ids = groupItr->second;
2672 
2673  return ids;
2674 }
2675 
2677 {
2678  CreatureTextRepeatGroup::iterator groupItr = m_textRepeat.find(textGroup);
2679  if (groupItr != m_textRepeat.end())
2680  groupItr->second.clear();
2681 }
2682 
2683 
2684 float Creature::GetAggroRange(Unit const* target) const
2685 {
2686  // Determines the aggro range for creatures (usually pets), used mainly for aggressive pet target selection.
2687  // Based on data from wowwiki due to lack of 3.3.5a data
2688 
2689  if (target && this->IsPet())
2690  {
2691  uint32 targetLevel = 0;
2692 
2693  if (target->GetTypeId() == TYPEID_PLAYER)
2694  targetLevel = target->getLevelForTarget(this);
2695  else if (target->GetTypeId() == TYPEID_UNIT)
2696  targetLevel = target->ToCreature()->getLevelForTarget(this);
2697 
2698  uint32 myLevel = getLevelForTarget(target);
2699  int32 levelDiff = int32(targetLevel) - int32(myLevel);
2700 
2701  // The maximum Aggro Radius is capped at 45 yards (25 level difference)
2702  if (levelDiff < -25)
2703  levelDiff = -25;
2704 
2705  // The base aggro radius for mob of same level
2706  float aggroRadius = 20;
2707 
2708  // Aggro Radius varies with level difference at a rate of roughly 1 yard/level
2709  aggroRadius -= (float)levelDiff;
2710 
2711  // detect range auras
2713 
2714  // detected range auras
2715  aggroRadius += target->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE);
2716 
2717  // Just in case, we don't want pets running all over the map
2718  if (aggroRadius > MAX_AGGRO_RADIUS)
2719  aggroRadius = MAX_AGGRO_RADIUS;
2720 
2721  // Minimum Aggro Radius for a mob seems to be combat range (5 yards)
2722  // hunter pets seem to ignore minimum aggro radius so we'll default it a little higher
2723  if (aggroRadius < 10)
2724  aggroRadius = 10;
2725 
2726  return (aggroRadius);
2727  }
2728 
2729  // Default
2730  return 0.0f;
2731 }
2732 
2734 {
2735  // Selects nearest hostile target within creature's aggro range. Used primarily by
2736  // pets set to aggressive. Will not return neutral or friendly targets.
2737 
2738  Unit* target = NULL;
2739 
2740  {
2741  Oregon::NearestHostileUnitInAggroRangeCheck u_check(this, useLOS);
2743 
2745  }
2746 
2747  return target;
2748 }
uint32 GetCurrentEquipmentId()
Definition: Creature.h:548
void RemoveFromWorld() override
Definition: Unit.cpp:11135
bool IsImmuneToSpellEffect(SpellEntry const *spellInfo, uint32 index, bool castOnSelf) const override
Definition: Creature.cpp:1737
uint32 m_corpseDelay
Definition: Creature.h:827
uint32 Category
Definition: DBCStructure.h:675
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:9804
uint32 UpdateVendorItemCurrentCount(VendorItem const *vItem, uint32 used_count)
Definition: Creature.cpp:2437
uint32 maxlevel
Definition: Creature.h:143
void SetTextRepeatId(uint8 textGroup, uint8 id)
Definition: Creature.cpp:2656
time_t GetLastDamagedTime() const
Definition: Unit.h:1995
bool SetWalk(bool enable) override
Definition: Creature.cpp:2528
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
Definition: Map.cpp:734
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1718
#define ATTACK_DISTANCE
Definition: Object.h:36
float GetSpellDamageMod(int32 Rank) const
Definition: Creature.cpp:1254
Group * GetGroup()
Definition: Player.h:2577
int32 resistance3
Definition: Creature.h:176
EventProcessor m_Events
Definition: Unit.h:1636
void SetRespawnTime(uint32 respawn)
Definition: Creature.h:657
uint32 npcflag
Definition: Creature.h:151
bool LoadCreatureFromDB(uint32 guid, Map *map, bool addToMap=true)
Definition: Creature.cpp:1300
virtual bool IsImmuneToSpell(SpellEntry const *spellInfo, bool useCharges=false)
Definition: Unit.cpp:8944
virtual void OnCreatureDeath(Creature *)
Definition: ZoneScript.h:46
const CreatureData * GetLinkedRespawnCreatureData() const
Definition: Creature.cpp:2494
uint32 EffectMechanic[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:730
Definition: Unit.h:440
uint32 InventoryType
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:3781
bool IsFlying() const
Definition: Unit.h:1973
CreatureData const * m_creatureData
Definition: Creature.h:854
virtual bool SetCanFly(bool enable, bool packetOnly=false)
Definition: Unit.cpp:13711
float ModMana
Definition: Creature.h:188
float ModArmor
Definition: Creature.h:189
void Mount(uint32 mount, uint32 spellId=0)
Definition: Unit.cpp:9270
uint8 getLevelForTarget(WorldObject const *) const override
Definition: Unit.h:1058
Position m_homePosition
Definition: Creature.h:850
void SetTarget(uint64 guid=0)
Definition: Unit.h:1591
uint32 GetMaxHealth() const
Definition: Unit.h:1075
void AddToWorld() override
Definition: Creature.cpp:181
uint32 maxcount
Definition: Creature.h:352
bool SetCanFly(bool enable, bool packetOnly=false) override
Definition: Creature.cpp:2553
bool IsSpiritHealer() const
Definition: Unit.h:1223
uint32 rank
Definition: Creature.h:155
PlayerMenu * PlayerTalkClass
Definition: Player.h:2182
void UpdateMovementFlags(bool packetOnly=false)
Definition: Creature.cpp:2623
Unit * SelectNearestTargetInAttackDistance(float dist=0) const
Definition: Creature.cpp:1887
Map * GetMap() const
Definition: Object.h:841
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
bool m_isTempWorldObject
Definition: Creature.h:803
uint8 spawnMask
Definition: Creature.h:284
uint8 movementType
Definition: Creature.h:283
uint32 spells[CREATURE_MAX_SPELLS]
Definition: Creature.h:180
uint32 GetFaction() const
Definition: Unit.h:1116
int32 resistance6
Definition: Creature.h:179
bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData *data=NULL)
Definition: Creature.cpp:260
void SetNoCallAssistance(bool val)
Definition: Creature.h:622
bool IsTrainerOf(Player *player, bool msg) const
Definition: Creature.cpp:831
void ClearMenus()
Definition: GossipDef.cpp:116
uint32 GetDBTableGUIDLow() const
Definition: Creature.h:476
uint32 id
Definition: Creature.h:269
bool BeginTransaction()
Definition: Database.cpp:533
char * Name
Definition: Creature.h:138
void SetModifierValue(UnitMods unitMod, UnitModifierType modifierType, float value)
Definition: Unit.h:1640
uint32 displayid
Definition: Creature.h:272
pet will not attack
Definition: Unit.h:760
bool RemoveItem(uint32 item_id)
Definition: Creature.cpp:64
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:3669
void SetAttackTime(WeaponAttackType att, uint32 val)
Definition: Unit.h:1108
void AddThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell=NULL)
Definition: Unit.cpp:10208
uint32 modelid4
Definition: Creature.h:137
void SendZoneUnderAttackMessage(Player *attacker)
Definition: Creature.cpp:2191
SpellSchools
bool CanTrainAndResetTalentsOf(Player *pPlayer) const
Definition: Creature.cpp:991
void AddEvent(BasicEvent *Event, uint64 e_time, bool set_addtime=true)
const char * GetNameForLocaleIdx(int32 locale_idx) const override
Definition: Creature.cpp:2479
time_t m_respawnTime
Definition: Creature.h:825
float BaseMeleeAttackPower
Definition: Creature.h:233
void InitializeReactState()
Definition: Creature.cpp:823
void SetObjectScale(float scale)
Definition: Object.h:205
AiReaction
bool IsUnderLastManaUseEffect() const
Definition: Unit.cpp:12299
#define CREATURE_Z_ATTACK_RANGE
Definition: Creature.h:451
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Definition: Creature.cpp:1864
Movement::MoveSpline * movespline
Definition: Unit.h:1907
void setActive(bool isActiveObject)
Definition: Object.cpp:1123
void UpdateSpeed(UnitMoveType mtype, bool forced)
Definition: Unit.cpp:9885
uint32 curhealth
Definition: Creature.h:281
bool IsPvP() const
Definition: Unit.h:1139
bool HasSpellCooldown(uint32 spell_id) const
Definition: Creature.cpp:2292
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:833
bool IsBattleMaster() const
Definition: Unit.h:1220
uint64 lootingGroupLeaderGUID
Definition: Object.h:925
MotionMaster * GetMotionMaster()
Definition: Unit.h:1890
uint32 GetZoneId() const
Definition: Object.cpp:1179
uint32 race
Definition: Creature.h:168
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
bool IsInCombat() const
Definition: Unit.h:1243
bool m_AlreadyCallAssistance
Definition: Creature.h:842
std::vector< uint8 > CreatureTextRepeatIds
Definition: Creature.h:456
TrainerSpellData const * GetTrainerSpells() const
Definition: Creature.cpp:2473
bool CanFly() const
Definition: Creature.h:493
virtual void SetMap(Map *map)
Definition: Object.cpp:1954
Loot loot
Definition: Creature.h:587
uint32 curmana
Definition: Creature.h:282
uint32 getMSTime()
Definition: Timer.h:32
bool IsValidAttackTarget(Unit const *target) const
Definition: Unit.cpp:9510
bool SetSwim(bool enable) override
Definition: Creature.cpp:2539
void SetCreateHealth(uint32 val)
Definition: Unit.h:1546
Definition: Unit.h:437
bool hasPlayerDamaged
Definition: Creature.h:784
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:1591
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:626
void AddObject(T *object)
float speed_walk
Definition: Creature.h:152
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 trainer_type
Definition: Creature.h:165
virtual void SaveToDB()
Definition: Creature.cpp:1050
void SetCanModifyStats(bool modifyStats)
Definition: Unit.h:1654
MovementGeneratorType GetDefaultMovementType() const
Definition: Creature.h:628
CreatureData const * GetCreatureData() const
Definition: Creature.h:558
virtual void JustRespawned()
Definition: CreatureAI.h:139
void AddToWorld() override
Definition: Unit.cpp:11129
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
ACE_INT32 int32
Definition: Define.h:67
bool IsWithinLOSInMap(const WorldObject *obj) const
Definition: Object.cpp:1229
TrainerSpellList spellList
Definition: Creature.h:418
uint32 GetNativeDisplayId()
Definition: Unit.h:1787
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:13525
std::list< Aura * > AuraList
Definition: Unit.h:917
bool HasReactState(ReactStates state) const
Definition: Creature.h:497
bool IsInEvadeMode() const
Definition: Creature.cpp:2298
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:719
NULL Dbg ErrDB Arena Chat Char Map MMap false
Definition: Log.cpp:556
int32 ModifyHealth(int32 val)
Definition: Unit.cpp:9736
static CreatureDataAddon const * GetCreatureAddon(uint32 lowguid)
Definition: ObjectMgr.h:624
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition: Unit.cpp:9209
SpellEntry const * reachWithSpellAttack(Unit *pVictim)
Definition: Creature.cpp:1765
void UpdateCharmAI()
Definition: Unit.cpp:11194
bool IsTrigger() const
Definition: Creature.h:489
float spawndist
Definition: Creature.h:279
bool IsDungeon() const
Definition: Map.h:427
bool HasSearchedAssistance() const
Definition: Creature.h:624
VirtualItemSlot
Definition: Creature.h:426
Creature * getLeader() const
void SetNativeDisplayId(uint32 modelId)
Definition: Unit.h:1791
bool IsInvisibleDueToDespawn() const override
Definition: Creature.cpp:1480
bool SetHover(bool enable, bool packetOnly=false) override
Definition: Creature.cpp:2595
void SetNoCreate()
Definition: Cell.h:76
void AddAssistant(const uint64 &guid)
Definition: Creature.h:879
void MoveFall(float z=0, uint32 id=0)
bool Initialized() const
Definition: MoveSpline.h:94
virtual bool CanAIAttack(const Unit *) const
Definition: UnitAI.h:49
uint32 GetGUIDLow() const
Definition: Object.h:166
uint32 Effect[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:724
MovementGeneratorType m_defaultMovementType
Definition: Creature.h:837
void SetEntry(uint32 entry)
Definition: Object.h:196
uint32 dynamicflags
Definition: Creature.h:163
uint64 CalculateTime(uint64 t_offset)
Definition: Unit.h:439
bool UpdateAllStats() override
Definition: StatSystem.cpp:765
uint64 LastCharmerGUID
Definition: Unit.h:1991
void AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:13463
Aura * CreateAura(SpellEntry const *spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item *castItem)
Definition: SpellAuras.cpp:502
uint32 GetCreatureType() const
Definition: Unit.cpp:10686
bool dbData
Definition: Creature.h:288
uint32 minlevel
Definition: Creature.h:142
void AllLootRemovedFromCorpse()
Definition: Creature.cpp:2348
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:985
size_t FindItemSlot(uint32 item_id) const
Definition: Creature.cpp:80
uint32 modelid1
Definition: Creature.h:134
void clear()
Definition: LootMgr.h:327
bool AIM_Initialize(CreatureAI *ai=NULL)
Definition: Creature.cpp:746
void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
Definition: Creature.cpp:2237
static ItemTemplate const * GetItemTemplate(uint32 id)
Definition: ObjectMgr.h:634
iterator begin()
Definition: MapRefManager.h:48
void apply(T *val)
Definition: ByteConverter.h:41
bool IsAIEnabled
Definition: Unit.h:1990
bool CanSwim() const
Definition: Creature.h:492
void SendGossipMenu(uint32 TitleTextId, uint64 npcGUID)
Definition: GossipDef.cpp:137
#define sObjectMgr
Definition: ObjectMgr.h:1285
CreatureTextRepeatGroup m_textRepeat
Definition: Creature.h:870
bool CommitTransaction()
Definition: Database.cpp:551
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:789
time_t _pickpocketLootRestore
Timers.
Definition: Creature.h:823
bool CanAssistTo(const Unit *u, const Unit *enemy, bool checkfaction=true) const
Definition: Creature.cpp:1982
uint32 EffectApplyAuraName[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:734
bool canStartAttack(Unit const *u, bool force) const
Definition: Creature.cpp:1499
virtual void DeleteFromDB()
Definition: Creature.cpp:1461
time_t GetLinkedCreatureRespawnTime() const
Definition: Creature.cpp:2506
void ForcedDespawn(uint32 timeMSToDespawn=0)
Definition: Creature.cpp:1702
bool PExecuteLog(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:221
uint32 rangeIndex
Definition: DBCStructure.h:714
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:922
uint32 m_combatPulseDelay
Definition: Creature.h:830
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.h:774
Definition: Common.h:181
uint32 GetPower(Powers power) const
Definition: Unit.h:1096
virtual bool SetSwim(bool enable)
Definition: Unit.cpp:13698
float posX
Definition: Creature.h:274
UnitAI * i_AI
Definition: Unit.h:2004
uint8 getLevel() const
Definition: Unit.h:1057
void SetLootRecipient(Unit *unit)
Definition: Creature.cpp:1012
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3755
uint32 flags_extra
Definition: Creature.h:195
virtual void OnCreatureCreate(Creature *, bool)
Definition: ZoneScript.h:44
void InitDefault()
uint64 GetCharmerOrOwnerGUID() const
Definition: Unit.h:1387
virtual bool IsInvisibleDueToDespawn() const
Definition: Object.h:818
TempSummon * ToTempSummon()
Definition: Unit.h:1998
void CallAssistance()
Definition: Creature.cpp:1925
bool CanAlwaysSee(WorldObject const *obj) const override
Definition: Creature.cpp:1491
Definition: Common.h:179
bool IsSpiritGuide() const
Definition: Unit.h:1224
float m_respawnradius
Definition: Creature.h:828
uint32 GetId(void) const
Definition: Map.h:333
virtual void InitializeAI()
Definition: UnitAI.h:56
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.h:770
void ClearUnitState(uint32 f)
Definition: Unit.h:1034
Powers getPowerType() const
Definition: Unit.h:1094
void DoFleeToGetAssistance()
Definition: Creature.cpp:712
bool _IsTargetAcceptable(const Unit *target) const
Definition: Creature.cpp:2031
uint8 GetTypeId() const
Definition: Object.h:210
time_t GetRespawnTimeEx() const
Definition: Creature.cpp:2312
uint32 spawntimesecs
Definition: Creature.h:278
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:125
virtual bool SetHover(bool enable, bool packetOnly=false)
Definition: Unit.cpp:13753
uint32 m_lootRecipientGroup
Definition: Creature.h:819
uint32 unit_class
Definition: Creature.h:161
void SetMeleeDamageSchool(SpellSchools school)
Definition: Creature.h:525
uint32 m_corpseRemoveTime
Definition: Creature.h:824
uint32 m_spells[CREATURE_MAX_SPELLS]
Definition: Creature.h:604
bool SetLevitate(bool enable, bool packetOnly=false) override
Definition: Creature.cpp:2609
ACE_UINT8 uint8
Definition: Define.h:73
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1097
float GetOrientation() const
Definition: Position.h:100
void setDeathState(DeathState s) override
Definition: Creature.cpp:1575
#define UI64FMTD
Definition: Common.h:149
int32 resistance4
Definition: Creature.h:177
static CreatureDataAddon const * GetCreatureTemplateAddon(uint32 entry)
Definition: ObjectMgr.h:629
void Relocate(float x, float y)
Definition: Position.h:65
uint32 DisplayInfoID
void SetControlled(bool apply, UnitState state)
Definition: Unit.cpp:12872
CreatureGroup * m_formation
Definition: Creature.h:864
const bool & IsInWorld() const
Definition: Object.h:135
#define CREATURE_REGEN_INTERVAL
Definition: Creature.h:125
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:390
float GetAggroRange(Unit const *target) const
Definition: Creature.cpp:2684
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:13499
#define sPoolMgr
Definition: PoolMgr.h:162
static float _GetHealthMod(int32 Rank)
Definition: Creature.cpp:1211
uint32 m_DBTableGuid
Definition: Creature.h:839
ZoneScript * m_zoneScript
Definition: Object.h:934
uint32 GetPhaseMask() const
Definition: Object.h:694
uint32 faction
Definition: Creature.h:150
void SetDisplayId(uint32 modelId)
Definition: Unit.cpp:11975
bool IsNeutralToAll() const
Definition: Unit.cpp:7357
TrainerSpell const * Find(uint32 spell_id) const
Definition: Creature.cpp:55
static CreatureInfo const * GetCreatureTemplate(uint32 id)
Definition: ObjectMgr.cpp:439
float speed_run
Definition: Creature.h:153
virtual void SetCanDualWield(bool value)
Definition: Unit.h:977
void MoveSeekAssistance(float x, float y, float z)
uint32 equipmentId
Definition: Creature.h:193
bool IsAlive() const
Definition: Unit.h:1336
Unit * GetVictim() const
Definition: Unit.h:1013
float posY
Definition: Creature.h:275
void SetCreateMana(uint32 val)
Definition: Unit.h:1554
float GetDistance(const WorldObject *obj) const
Definition: Object.h:718
virtual void UpdateAI(const uint32)=0
bool IsFalling() const
Definition: Unit.cpp:13667
virtual bool SetWaterWalking(bool enable, bool packetOnly=false)
Definition: Unit.cpp:13727
float GetPositionY() const
Definition: Position.h:98
void Update(uint32 time) override
Definition: Unit.cpp:520
bool Execute(uint64 e_time, uint32 p_time) override
Definition: Creature.cpp:139
int32 resistance5
Definition: Creature.h:178
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:878
DeathState m_deathState
Definition: Unit.h:2022
CreatureAI * selectAI(Creature *creature)
CreatureAI * AI() const
Definition: Creature.h:517
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:834
static Player * FindPlayer(uint64, bool force=false)
bool CanInteractWithBattleMaster(Player *player, bool msg) const
Definition: Creature.cpp:962
VendorItemData const * GetVendorItems() const
Definition: Creature.cpp:2398
uint32 GetInstanceId() const
Definition: Object.h:688
etc mysql my cnf *Then change max_allowed_packet to a bigger value
uint32 m_GlobalCooldown
Definition: Creature.h:607
float GetPositionZ() const
Definition: Position.h:99
CreatureInfo const * m_creatureInfo
Definition: Creature.h:868
bool m_regenHealth
Definition: Creature.h:844
uint32 GetFirstValidModelId() const
Definition: Creature.cpp:109
bool HasCategoryCooldown(uint32 spell_id) const
Definition: Creature.cpp:2278
bool HasSpell(uint32 spellID) const override
Definition: Creature.cpp:2303
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7339
void SetOriginalEntry(uint32 entry)
Definition: Creature.h:787
void CallForHelp(float fRadius)
Definition: Creature.cpp:1965
PackedGuid const & GetPackGUID() const
Definition: Object.h:178
virtual void CorpseRemoved(time_t)
Definition: CreatureAI.h:198
#define DEBUG_LOG(...)
Definition: Log.h:194
bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, float x, float y, float z, float ang, const CreatureData *data=NULL)
Definition: Creature.cpp:764
virtual bool SetFeatherFall(bool enable, bool packetOnly=false)
Definition: Unit.cpp:13740
bool m_AI_locked
Definition: Creature.h:845
SpellEntry const * reachWithSpellCure(Unit *pVictim)
Definition: Creature.cpp:1815
uint32 m_combatPulseTime
Definition: Creature.h:829
float GetSpellMinRange(SpellRangeEntry const *range)
Definition: SpellMgr.h:139
void SetVirtualItemRaw(VirtualItemSlot slot, uint32 display_id, uint32 info0, uint32 info1)
Definition: Creature.cpp:1432
float GetAttackDistance(Unit const *pl) const
Definition: Creature.cpp:1537
uint32 GetMapId() const
Definition: Object.h:591
void SetCanDualWield(bool value)
Definition: Creature.cpp:1369
void SetMaxHealth(uint32 val)
Definition: Unit.cpp:10938
bool isRegeneratingHealth()
Definition: Creature.h:701
bool Execute(uint64 e_time, uint32 p_time) override
Definition: Creature.cpp:118
VendorItemCounts m_vendorItemCounts
Definition: Creature.h:810
bool isEmpty() const
Definition: LinkedList.h:97
bool IsInMap(const WorldObject *obj) const
Definition: Object.h:745
uint32 m_originalEntry
Definition: Creature.h:848
bool NeedChangeAI
Definition: Unit.h:1990
bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const CreatureData *data=NULL)
Definition: Creature.cpp:1273
uint32 npcflag
Definition: Creature.h:285
float combat_reach
Definition: Creature.h:313
virtual void SetSheath(SheathState sheathed)
Definition: Unit.h:1113
Definition: Map.h:266
Map * FindMap(uint32 mapid, uint32 instanceId=0) const
Definition: MapManager.cpp:137
virtual bool SetLevitate(bool apply, bool packetOnly=false)
Definition: Unit.cpp:13685
float ModHealth
Definition: Creature.h:187
uint32 m_path_id
Definition: Creature.h:861
bool isInAccessiblePlaceFor(Creature const *c) const
Definition: Unit.cpp:3646
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition: Creature.h:605
bool HaveLootFor(uint32 loot_id) const
Definition: LootMgr.h:184
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:1902
uint32 PreventionType
Definition: DBCStructure.h:764
Group * GetLootRecipientGroup() const
Definition: Creature.cpp:1005
uint32 modelid3
Definition: Creature.h:136
virtual uint32 GetCreatureEntry(uint32, const CreatureData *data)
Definition: ZoneScript.h:35
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value)
Definition: Unit.h:1669
uint32 unit_flags
Definition: Creature.h:162
bool TriggerJustRespawned
Definition: Creature.h:866
bool hasInvolvedQuest(uint32 quest_id) const override
Definition: Creature.cpp:1450
int32 equipmentId
Definition: Creature.h:273
bool IsPet() const
Definition: Unit.h:1048
#define MAX_VISIBILITY_DISTANCE
Definition: Object.h:38
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:178
const char * GetName() const
Definition: Object.h:704
void SetPlayerDamaged(bool set)
Definition: Creature.cpp:1230
bool RegenHealth
Definition: Creature.h:192
void RemoveObject(T *object)
bool isDying() const
Definition: Unit.h:1337
void RegenerateMana()
Definition: Creature.cpp:640
DeathState
Definition: Unit.h:435
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1006
ACE_UINT64 uint64
Definition: Define.h:70
PlayerList const & GetPlayers() const
Definition: Map.h:491
Definition: Cell.h:46
uint32 modelid2
Definition: Creature.h:135
uint32 CategoryRecoveryTime
Definition: DBCStructure.h:698
Player * GetLootRecipient() const
Definition: Creature.cpp:998
void Respawn(bool force=false)
Definition: Creature.cpp:1651
uint32 MovementType
Definition: Creature.h:185
void SendAIReaction(AiReaction reactionType)
Definition: Creature.cpp:1913
uint8 getRace() const
Definition: Unit.h:1060
void RegenerateHealth()
Definition: Creature.cpp:675
Definition: Unit.h:485
bool IsGuard() const
Definition: Creature.h:490
#define sGameEventMgr
Definition: GameEventMgr.h:179
uint32 m_respawnDelay
Definition: Creature.h:826
CreatureInfo const * GetCreatureTemplate() const
Definition: Creature.h:557
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1410
uint32 GetRandomValidModelId() const
Definition: Creature.cpp:96
uint32 dynamicflags
Definition: Creature.h:287
bool IsCivilian() const
Definition: Creature.h:488
MotionMaster i_motionMaster
Definition: Unit.h:2055
CreatureDataAddonAura const * auras
Definition: Creature.h:306
float BaseRangedAttackPower
Definition: Creature.h:234
int32 exp
Definition: Creature.h:144
void SelectLevel()
Definition: Creature.cpp:1152
virtual void setDeathState(DeathState s)
Definition: Unit.cpp:10114
uint64 m_lootRecipient
Definition: Creature.h:818
uint32 unit_flags
Definition: Creature.h:286
Map const * GetBaseMap() const
Definition: Object.cpp:1984
uint32 BaseArmor
Definition: Creature.h:235
void RemoveFromWorld() override
Definition: Creature.cpp:196
VendorItem const * FindItem(uint32 item_id) const
Definition: Creature.cpp:88
void SetVirtualItem(VirtualItemSlot slot, uint32 item_id)
Definition: Creature.cpp:1406
bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData *data=NULL)
Definition: Creature.cpp:353
Player * GetSpellModOwner() const
Definition: Unit.cpp:11827
virtual void UpdateDamagePhysical(WeaponAttackType attType)
Definition: StatSystem.cpp:37
uint32 RangeAttackTime
Definition: Creature.h:158
void SaveRespawnTime() override
Definition: Creature.cpp:2063
void EndRoll()
Definition: Group.cpp:761
#define CREATURE_MAX_SPELLS
Definition: Unit.h:249
bool IsTotem() const
Definition: Unit.h:1050
bool IsCritter() const
Definition: Unit.h:1237
LootType loot_type
Definition: LootMgr.h:312
bool CreatureRespawnRelocation(Creature *c)
Definition: Map.cpp:873
int32 resistance1
Definition: Creature.h:174
bool CanCreatureAttack(Unit const *victim, bool force=true) const
Definition: Creature.cpp:2071
void SetNoSearchAssistance(bool val)
Definition: Creature.h:623
Unit * GetOwner() const
Definition: Unit.cpp:7625
Creature * ToCreature()
Definition: Object.h:395
uint32 GetEquipmentId() const
Definition: Creature.h:482
void SetZoneScript()
Definition: Object.cpp:2102
float m_SightDistance
Definition: Creature.h:789
void ResetPickPocketRefillTimer()
Definition: Creature.h:589
void SetFaction(uint32 faction)
Definition: Unit.h:1117
uint32 currentwaypoint
Definition: Creature.h:280
static void ChooseCreatureFlags(const CreatureInfo *cinfo, uint32 &npcflag, uint32 &unit_flags, uint32 &dynamicflags, const CreatureData *data=NULL)
Definition: ObjectMgr.cpp:1030
void CombatStart(Unit *target, bool initialAggro=true)
Definition: Unit.cpp:9351
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition: Unit.cpp:10681
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:859
bool IsPolymorphed() const
Definition: Unit.cpp:11966
bool isElite() const
Definition: Creature.cpp:1748
T AddPct(T &base, U pct)
Definition: Util.h:103
uint32 item
Definition: Creature.h:351
#define sFormationMgr
uint16 m_valuesCount
Definition: Object.h:438
uint32 m_regenTimer
Definition: Creature.h:836
uint8 getClass() const
Definition: Unit.h:1062
virtual bool SetWalk(bool enable)
Definition: Unit.cpp:13672
MovementGeneratorType
Definition: MotionMaster.h:33
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7334
Unit * getAttackerForHelper() const
Definition: Unit.cpp:7370
uint32 GetTeam() const
Definition: Player.h:2063
void SetPvP(bool state)
Definition: Unit.h:1143
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
void SetName(const std::string &newname)
Definition: Object.h:708
void SetPower(Powers power, uint32 val)
Definition: Unit.cpp:10997
float orientation
Definition: Creature.h:277
uint8 getLevelForTarget(Unit const *target) const
Definition: Creature.cpp:2370
std::vector< std::string > Name
Definition: Creature.h:240
void SetInCombatWithZone()
Definition: Creature.cpp:2200
uint32 Mechanic
Definition: DBCStructure.h:678
Unit * SelectNearestHostileUnitInAggroRange(bool useLOS=false) const
Definition: Creature.cpp:2733
#define MAX_AGGRO_RADIUS
Definition: Unit.h:254
Creature(bool isWorldObject=false)
Definition: Creature.cpp:145
void RemoveCorpse(bool setSpawnTime=true)
Definition: Creature.cpp:234
bool isTappedBy(Player const *player) const
Definition: Creature.cpp:1038
bool hasLootRecipient() const
Definition: Creature.h:595
void SearchFormation()
Definition: Creature.cpp:220
uint32 incrtime
Definition: Creature.h:353
#define ASSERT
Definition: Errors.h:29
void SetMaxPower(Powers power, uint32 val)
Definition: Unit.cpp:11030
bool CanHaveThreatList() const
Definition: Unit.cpp:10169
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:10014
void Update(uint32 time) override
Definition: Creature.cpp:472
static Unit * GetUnit(WorldObject &object, uint64 guid)
Definition: Unit.cpp:10671
uint16 mapid
Definition: Creature.h:270
void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time)
Definition: Creature.cpp:2242
static Unit * GetUnit(WorldObject const &, uint64 guid)
void DestroyForNearbyPlayers()
Definition: Object.cpp:2565
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:832
#define INVALID_HEIGHT
Definition: Map.h:259
void SetLevel(uint32 lvl)
Definition: Unit.cpp:10896
uint32 InhabitType
Definition: Creature.h:186
uint32 GetEntry() const
Definition: Object.h:192
void LoadEquipment(uint32 equip_entry, bool force=false)
Definition: Creature.cpp:1375
bool LoadCreaturesAddon(bool reload=false)
Definition: Creature.cpp:2140
bool IsPositionValid() const
Definition: Position.cpp:40
static float _GetDamageMod(int32 Rank)
Definition: Creature.cpp:1235
float scale
Definition: Creature.h:154
uint32 StartRecoveryTime
Definition: DBCStructure.h:758
uint32 phaseMask
Definition: Creature.h:271
#define MELEE_RANGE
Definition: Object.h:48
uint32 GetVendorItemCurrentCount(VendorItem const *vItem)
Definition: Creature.cpp:2403
#define sWorld
Definition: World.h:860
void SetFullHealth()
Definition: Unit.h:1091
AuraList const & GetAurasByType(AuraType type) const
Definition: Unit.h:1747
CreatureTextRepeatIds GetTextRepeatGroup(uint8 textGroup)
Definition: Creature.cpp:2665
uint32 classNum
Definition: Creature.h:167
float bounding_radius
Definition: Creature.h:312
void SetHealth(uint32 val)
Definition: Unit.cpp:10905
uint32 type_flags
Definition: Creature.h:170
uint32 m_equipmentId
Definition: Creature.h:840
ACE_UINT16 uint16
Definition: Define.h:72
float GetDistanceZ(const WorldObject *obj) const
Definition: Object.cpp:1195
bool isCharmed() const
Definition: Unit.h:1434
uint32 dmgschool
Definition: Creature.h:156
#define MAX_VIRTUAL_ITEM_SLOT
Definition: Creature.h:433
CreatureSpellCooldowns m_CreatureCategoryCooldowns
Definition: Creature.h:606
uint32 GetScriptId()
Definition: Creature.cpp:2393
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7187
uint32 ScriptID
Definition: Creature.h:196
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:305
ACE_UINT32 uint32
Definition: Define.h:71
void GetRespawnPosition(float &x, float &y, float &z, float *ori=NULL, float *dist=NULL) const
Definition: Creature.cpp:2321
ReputationRank GetReputationRank(uint32 faction_id) const
Definition: Player.cpp:5863
bool IsTrainer() const
Definition: Unit.h:1215
void Initialize()
float GetPositionX() const
Definition: Position.h:97
time_t lastIncrementTime
Definition: Creature.h:398
bool IsSummon() const
Definition: Unit.h:1046
LootStore LootTemplates_Skinning("skinning_loot_template","creature skinning id")
uint32 GetHealth() const
Definition: Unit.h:1074
bool isWorldBoss() const
Definition: Creature.cpp:1757
uint32 BaseAttackTime
Definition: Creature.h:157
true
Definition: Log.cpp:534
CreatureDataAddon const * GetCreatureAddon() const
Definition: Creature.cpp:2127
virtual void Reset()
Definition: UnitAI.h:61
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:498
void AddCreatureSpellCooldown(uint32 spellid)
Definition: Creature.cpp:2247
std::string GetAIName() const
Definition: Creature.cpp:2383
Definition: Unit.h:908
float m_CombatDistance
Definition: Creature.h:789
float GetObjectSize() const
Definition: Object.h:669
uint32 BaseHealth
Definition: Creature.h:230
bool GetBGAccessByLevel(uint32 bgTypeId) const
Definition: Player.cpp:19430
virtual bool IsImmuneToSpellEffect(SpellEntry const *spellInfo, uint32 index, bool castOnSelf) const
Definition: Unit.cpp:9007
bool IsImmuneToSpell(SpellEntry const *spellInfo, bool useCharges=false) override
Definition: Creature.cpp:1726
void DisappearAndDie()
Definition: Creature.cpp:212
void SetReactState(ReactStates st)
Definition: Creature.h:495
std::string GetScriptName()
Definition: Creature.cpp:2388
Definition: Player.h:922
int32 resistance2
Definition: Creature.h:175
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:25
uint32 GetInstanceId() const
Definition: Map.h:390
~Creature() override
Definition: Creature.cpp:173
uint32 m_groupLootTimer
Definition: Object.h:924
uint32 SoundOverrideSubclass
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
Definition: CellImpl.h:121
bool isTargetableForAttack(bool checkFakeDeath=true) const
Definition: Unit.cpp:9495
float GetStat(Stats stat) const
Definition: Unit.h:1066
DBCStorage< SpellRangeEntry > sSpellRangeStore(SpellRangefmt)
float posZ
Definition: Creature.h:276
Unit * ToUnit()
Definition: Object.h:398
void StartPickPocketRefillTimer()
Definition: Creature.cpp:2651
void ClearTextRepeatGroup(uint8 textGroup)
Definition: Creature.cpp:2676
bool SetFeatherFall(bool enable, bool packetOnly=false) override
Definition: Creature.cpp:2581
iterator end()
Definition: MapRefManager.h:52
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9329
bool SetWaterWalking(bool enable, bool packetOnly=false) override
Definition: Creature.cpp:2567
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:188
Definition: Group.h:154
void FormationReset(bool dismiss)
uint32 manaCost
Definition: DBCStructure.h:710
DeathState getDeathState() const
Definition: Unit.h:1339
uint32 GetSpellRecoveryTime(SpellEntry const *spellInfo)
Definition: SpellMgr.h:151
Definition: UnitAI.h:41
uint32 urand(uint32 min, uint32 max)
Definition: Util.cpp:33
uint32 HeroicEntry
Definition: Creature.h:132
uint32 count
Definition: Creature.h:397
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7641
bool IsSpiritService() const
Definition: Unit.h:1236
bool hasQuest(uint32 quest_id) const override
Definition: Creature.cpp:1439
const uint64 & GetGUID() const
Definition: Object.h:162
bool HasAura(uint32 spellId, uint8 effIndex=0) const
Definition: Unit.h:1262
uint32 StartRecoveryCategory
Definition: DBCStructure.h:757
float GetSpellMaxRange(SpellRangeEntry const *range)
Definition: SpellMgr.h:143