Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
Creature.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "BattlegroundMgr.h"
7#include "BattlePet.h"
8#include "BattlePetSpawnMgr.h"
9#include "CellImpl.h"
10#include "Common.h"
11#include "Creature.h"
12#include "CreatureAI.h"
13#include "CreatureAISelector.h"
14#include "CreatureGroups.h"
15#include "DatabaseEnv.h"
16#include "Formulas.h"
17#include "GameEventMgr.h"
18#include "GossipDef.h"
19#include "GridNotifiers.h"
20#include "GridNotifiersImpl.h"
21#include "Group.h"
22#include "GroupMgr.h"
23#include "InstanceScript.h"
24#include "Log.h"
25#include "LootMgr.h"
26#include "MapManager.h"
27#include "MoveSpline.h"
28#include "MoveSplineInit.h"
29#include "ObjectMgr.h"
30#include "Opcodes.h"
31#include "OutdoorPvPMgr.h"
32#include "Player.h"
33#include "PoolMgr.h"
34#include "QuestDef.h"
35#include "SpellAuraEffects.h"
36#include "SpellMgr.h"
37#include "TemporarySummon.h"
38#include "Util.h"
39#include "Vehicle.h"
41#include "World.h"
42#include "WorldPacket.h"
43
44#include "Transport.h"
45
47{
48 TrainerSpellMap::const_iterator itr = spellList.find(spell_id);
49 if (itr != spellList.end())
50 return &itr->second;
51
52 return NULL;
53}
54
56{
57 bool found = false;
58 for (VendorItemList::iterator i = m_items.begin(); i != m_items.end();)
59 {
60 if ((*i)->item == item_id && (*i)->Type == type)
61 {
62 i = m_items.erase(i++);
63 found = true;
64 }
65 else
66 ++i;
67 }
68 return found;
69}
70
71VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extendedCost, uint8 type) const
72{
73 for (VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i)
74 if ((*i)->item == item_id && (*i)->ExtendedCost == extendedCost && (*i)->Type == type)
75 return *i;
76 return NULL;
77}
78
80{
81 uint8 c = 0;
82 uint32 modelIDs[4] = { };
83
84 if (Modelid1) modelIDs[c++] = Modelid1;
85 if (Modelid2) modelIDs[c++] = Modelid2;
86 if (Modelid3) modelIDs[c++] = Modelid3;
87 if (Modelid4) modelIDs[c++] = Modelid4;
88
89 return ((c > 0) ? modelIDs[std::rand() % c] : 0);
90}
91
93{
94 if (Modelid1) return Modelid1;
95 if (Modelid2) return Modelid2;
96 if (Modelid3) return Modelid3;
97 if (Modelid4) return Modelid4;
98 return 0;
99}
100
101bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
102{
103 if (Unit* victim = Unit::GetUnit(m_owner, m_victim))
104 {
105 while (!m_assistants.empty())
106 {
107 Creature* assistant = Unit::GetCreature(m_owner, *m_assistants.begin());
108 m_assistants.pop_front();
109
110 if (assistant && assistant->CanAssistTo(&m_owner, victim))
111 {
112 assistant->SetNoCallAssistance(true);
113 assistant->CombatStart(victim);
114 if (assistant->IsAIEnabled)
115 assistant->AI()->AttackStart(victim);
116 }
117 }
118 }
119 return true;
120}
121
123{
124 if (info->ModLevel == true)
125 return uint32(ceil(BaseHealth[1] * info->ModHealth));
126 else
127 return uint32(ceil(BaseHealth[CURRENT_CONTENT_EXP == info->expansion ? 1 : 0] * info->ModHealth));
128}
129
131{
132 return sObjectMgr->GetCreatureBaseStats(level, unitClass);
133}
134
136{
137 m_owner.DespawnOrUnsummon(); // since we are here, we are not TempSummon as object type cannot change during runtime
138 return true;
139}
140
167
169{
170 delete i_AI;
171 i_AI = NULL;
172
173 //if (m_uint32Values)
174 // SF_LOG_ERROR("entities.unit", "Deconstruct Creature Entry = %u", GetEntry());
175}
176
178{
180 if (!IsInWorld())
181 {
182 if (m_zoneScript)
183 m_zoneScript->OnCreatureCreate(this);
184 sObjectAccessor->AddObject(this);
188 if (IsVehicle())
190 }
191}
192
194{
195 if (IsInWorld())
196 {
197 if (m_zoneScript)
198 m_zoneScript->OnCreatureRemove(this);
199 if (m_formation)
200 sFormationMgr->RemoveCreatureFromGroup(m_formation, this);
202 sObjectAccessor->RemoveObject(this);
203 }
204}
205
207{
209 //SetVisibility(VISIBILITY_OFF);
210 //ObjectAccessor::UpdateObjectVisibility(this);
211 if (IsAlive())
213 RemoveCorpse(false);
214}
215
217{
218 if (IsSummon())
219 return;
220
221 uint32 lowguid = GetDBTableGUIDLow();
222 if (!lowguid)
223 return;
224
225 CreatureGroupInfoType::iterator frmdata = sFormationMgr->CreatureGroupMap.find(lowguid);
226 if (frmdata != sFormationMgr->CreatureGroupMap.end())
227 sFormationMgr->AddCreatureToGroup(frmdata->second->leaderGUID, this);
228}
229
230void Creature::RemoveCorpse(bool setSpawnTime)
231{
233 return;
234
235 m_corpseRemoveTime = time(NULL);
239 loot.clear();
240 uint32 respawnDelay = m_respawnDelay;
241 if (IsAIEnabled)
242 AI()->CorpseRemoved(respawnDelay);
243
244 // Should get removed later, just keep "compatibility" with scripts
245 if (setSpawnTime)
246 m_respawnTime = time(NULL) + respawnDelay;
247
248 float x, y, z, o;
249 GetRespawnPosition(x, y, z, &o);
250 SetHomePosition(x, y, z, o);
251 GetMap()->CreatureRelocation(this, x, y, z, o);
252}
253
257bool Creature::InitEntry(uint32 entry, uint32 /*team*/, const CreatureData* data)
258{
259 CreatureTemplate const* normalInfo = sObjectMgr->GetCreatureTemplate(entry);
260 if (!normalInfo)
261 {
262 SF_LOG_ERROR("sql.sql", "Creature::InitEntry creature entry %u does not exist.", entry);
263 return false;
264 }
265
266 CreatureTemplate const* cinfo = nullptr;
267 DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(GetMap()->GetSpawnMode());
268 while (!cinfo && difficultyEntry)
269 {
270 int32 idx = CreatureTemplate::DiffToDiffIndex(difficultyEntry->DiffID);
271 if (idx == -1)
272 break;
273
274 if (normalInfo->DifficultyEntry[idx])
275 {
276 cinfo = sObjectMgr->GetCreatureTemplate(normalInfo->DifficultyEntry[idx]);
277 break;
278 }
279
280 if (!difficultyEntry->DownscaleID)
281 break;
282
283 difficultyEntry = sDifficultyStore.LookupEntry(difficultyEntry->DownscaleID);
284 }
285
286 if (!cinfo)
287 cinfo = normalInfo;
288
289 // Initialize loot duplicate count depending on raid difficulty
290 if (GetMap()->Is25ManRaid())
291 loot.maxDuplicates = 3;
292
293 SetEntry(entry); // normal entry always
294 m_creatureInfo = cinfo; // map mode related always
295
296 // equal to player Race field, but creature does not have race
297 SetRace(0);
298
299 // known valid are: CLASS_WARRIOR, CLASS_PALADIN, CLASS_ROGUE, CLASS_MAGE
300 SetClass(uint8(cinfo->unit_class));
301
302 // Cancel load if no model defined
303 if (!(cinfo->GetFirstValidModelId()))
304 {
305 SF_LOG_ERROR("sql.sql", "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", entry);
306 return false;
307 }
308
310 CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
311 if (!minfo) // Cancel load if no model defined
312 {
313 SF_LOG_ERROR("sql.sql", "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", entry);
314 return false;
315 }
316
317 SetDisplayId(displayID);
318 SetNativeDisplayId(displayID);
319 SetGender(minfo->gender);
320
321 // Load creature equipment
322 if (data && data->equipmentId != 0)
323 {
326 }
327 else
328 LoadEquipment(); // use default equipment (if available)
329
330 SetName(normalInfo->Name); // at normal entry always
331
334
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 // Will set UNIT_FIELD_BOUNDING_RADIUS and UNIT_FIELD_COMBAT_REACH
341 SetObjectScale(cinfo->scale);
342
344
345 // checked at loading
349
350 for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
352
353 return true;
354}
355
357{
358 if (!InitEntry(Entry, team, data))
359 return false;
360
361 CreatureTemplate const* cInfo = GetCreatureTemplate();
362
363 m_regenHealth = cInfo->RegenHealth;
364
365 // creatures always have melee weapon ready if any unless specified otherwise
366 if (!GetCreatureAddon())
368
370 if (team == HORDE)
371 setFaction(cInfo->faction_H);
372 else
373 setFaction(cInfo->faction_A);
374
375 uint32 npcflag, unit_flags, dynamicflags;
376 ObjectMgr::ChooseCreatureFlags(cInfo, npcflag, unit_flags, dynamicflags, data);
377
379 SetUInt32Value(UNIT_FIELD_NPC_FLAGS, npcflag | sGameEventMgr->GetNPCFlag(this));
380 else
382
385
389
390 SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags);
392
394
396
398 CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(getLevel(), cInfo->unit_class);
399 float armor = (float)stats->GenerateArmor(cInfo);
407
408 SetCanModifyStats(true);
410
411 // checked and error show at loading templates
412 if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A))
413 {
414 if (factionTemplate->factionFlags & FACTION_TEMPLATE_FLAG_PVP)
415 SetPvP(true);
416 else
417 SetPvP(false);
418 }
419
420 // updates spell bars for vehicles and set player's faction - should be called here, to overwrite faction that is set from the new template
421 if (IsVehicle())
422 {
423 if (Player* owner = Creature::GetCharmerOrOwnerPlayerOrPlayerItself()) // this check comes in case we don't have a player
424 {
425 setFaction(owner->getFaction()); // vehicles should have same as owner faction
426 owner->VehicleSpellInitialize();
427 }
428 }
429
430 // trigger creature is always not selectable and can not be attacked
431 if (IsTrigger())
433
435
437 {
440 }
441
443 return true;
444}
445
447{
449 {
450 TriggerJustRespawned = false;
451 AI()->JustRespawned();
452 if (m_vehicleKit)
453 m_vehicleKit->Reset();
454 }
455
457
458 switch (m_deathState)
459 {
461 // Must not be called, see Creature::setDeathState JUST_RESPAWNED -> ALIVE promoting.
462 SF_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) in wrong state: JUST_RESPAWNED (4)", GetGUIDLow(), GetEntry());
463 break;
465 // Must not be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
466 SF_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) in wrong state: JUST_DEAD (1)", GetGUIDLow(), GetEntry());
467 break;
468 case DeathState::DEAD:
469 {
470 time_t now = time(NULL);
471 if (m_respawnTime <= now)
472 {
473 bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning
474 if (!allowed) // Will be rechecked on next Update call
475 break;
476
478 time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
479 if (!linkedRespawntime) // Can respawn
480 Respawn();
481 else // the master is dead
482 {
483 uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
484 if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
486 else
487 m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + (std::rand() % MINUTE + 5); // else copy time from master and add a little
488 SaveRespawnTime(); // also save to DB immediately
489 }
490 }
491 break;
492 }
494 {
495 Unit::Update(diff);
496 // deathstate changed on spells update, prevent problems
498 break;
499
501 {
502 if (m_groupLootTimer <= diff)
503 {
504 Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID);
505 if (group)
506 group->EndRoll(&loot);
509 }
510 else m_groupLootTimer -= diff;
511 }
512 else if (m_corpseRemoveTime <= time(NULL))
513 {
514 RemoveCorpse(false);
515 SF_LOG_DEBUG("entities.unit", "Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY_ID));
516 }
517 break;
518 }
520 {
521 Unit::Update(diff);
522
523 // creature can be dead after Unit::Update call
524 // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
525 if (!IsAlive())
526 break;
527
528 // if creature is charmed, switch to charmed AI (and back)
529 if (NeedChangeAI)
530 {
532 NeedChangeAI = false;
533 IsAIEnabled = true;
535 if (Unit* charmer = ObjectAccessor::GetUnit(*this, LastCharmerGUID))
536 i_AI->AttackStart(charmer);
537
538 LastCharmerGUID = 0;
539 }
540
541 if (!IsInEvadeMode() && IsAIEnabled)
542 {
543 // do not allow the AI to be changed during update
544 m_AI_locked = true;
545 i_AI->UpdateAI(diff);
546 m_AI_locked = false;
547 }
548
549 // creature can be dead after UpdateAI call
550 // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
551 if (!IsAlive())
552 break;
553
554 if (m_regenTimer > 0)
555 {
556 if (diff >= m_regenTimer)
557 m_regenTimer = 0;
558 else
559 m_regenTimer -= diff;
560 }
561
562 if (m_regenTimer != 0)
563 break;
564
565 bool bInCombat = IsInCombat() && (!GetVictim() || // if IsInCombat() is true and this has no victim
566 !GetVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() || // or the victim/owner/charmer is not a player
567 !GetVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()->IsGameMaster()); // or the victim/owner/charmer is not a GameMaster
568
569 /*if (m_regenTimer <= diff)
570 {*/
571 if (!IsInEvadeMode() && (!bInCombat || IsPolymorphed())) // regenerate health if not in combat or if polymorphed
573
574 if (getPowerType() == POWER_ENERGY)
575 {
576 if (!IsVehicle() || GetVehicleKit()->GetVehicleInfo()->m_powerType != POWER_PYRITE)
578 }
579 else
581
582 /*if (!bIsPolymorphed) // only increase the timer if not polymorphed
583 m_regenTimer += CREATURE_REGEN_INTERVAL - diff;
584 }
585 else
586 if (!bIsPolymorphed) // if polymorphed, skip the timer
587 m_regenTimer -= diff;*/
589 break;
590 }
591 default:
592 break;
593 }
594
595 sScriptMgr->OnCreatureUpdate(this, diff);
596}
597
599{
600 uint32 curValue = GetPower(POWER_MANA);
601 uint32 maxValue = GetMaxPower(POWER_MANA);
602
603 if (curValue >= maxValue)
604 return;
605
606 uint32 addvalue = 0;
607
608 // Combat and any controlled creature
610 {
611 float ManaIncreaseRate = sWorld->getRate(Rates::RATE_POWER_MANA);
612 float Spirit = GetStat(STAT_SPIRIT);
613
614 addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
615 }
616 else
617 addvalue = maxValue / 3;
618
619 // Apply modifiers (if any).
621 for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
622 if ((*i)->GetMiscValue() == POWER_MANA)
623 AddPct(addvalue, (*i)->GetAmount());
624
626
627 ModifyPower(POWER_MANA, addvalue);
628}
629
631{
633 return;
634
635 uint32 curValue = GetHealth();
636 uint32 maxValue = GetMaxHealth();
637
638 if (curValue >= maxValue)
639 return;
640
641 uint32 addvalue = 0;
642
643 // Not only pet, but any controlled creature
645 {
646 float HealthIncreaseRate = sWorld->getRate(Rates::RATE_HEALTH);
647 float Spirit = GetStat(STAT_SPIRIT);
648
649 if (GetPower(POWER_MANA) > 0)
650 addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate);
651 else
652 addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate);
653 }
654 else
655 addvalue = maxValue / 3;
656
657 // Apply modifiers (if any).
659 for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
660 AddPct(addvalue, (*i)->GetAmount());
661
663
664 ModifyHealth(addvalue);
665}
666
668{
669 if (!GetVictim())
670 return;
671
673 return;
674
676 if (radius > 0)
677 {
678 Creature* creature = NULL;
679
681 Cell cell(p);
682 cell.SetNoCreate();
685
687
688 cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
689
691 UpdateSpeed(MOVE_RUN, false);
692
693 if (!creature)
694 //SetFeared(true, GetVictim()->GetGUID(), 0, sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY));
697 else
698 GetMotionMaster()->MoveSeekAssistance(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ());
699 }
700}
701
703{
704 // make sure nothing can change the AI during AI update
705 if (m_AI_locked)
706 {
707 SF_LOG_DEBUG("scripts", "AIM_Initialize: failed to init, locked.");
708 return false;
709 }
710
711 UnitAI* oldAI = i_AI;
712
714
715 i_AI = ai ? ai : FactorySelector::selectAI(this);
716 delete oldAI;
717 IsAIEnabled = true;
718 i_AI->InitializeAI();
719 // Initialize vehicle
720 if (GetVehicleKit())
721 GetVehicleKit()->Reset();
722 return true;
723}
724
726{
727 if (!m_formation)
728 i_motionMaster.Initialize();
729 else if (m_formation->getLeader() == this)
730 {
731 m_formation->FormationReset(false);
732 i_motionMaster.Initialize();
733 }
734 else if (m_formation->isFormed())
735 i_motionMaster.MoveIdle(); //wait the order of leader
736 else
737 i_motionMaster.Initialize();
738}
739
740bool Creature::Create(uint32 guidlow, Map* map, uint32 Entry, uint32 vehId, uint32 team, float x, float y, float z, float ang, const CreatureData* data)
741{
742 ASSERT(map);
743 SetMap(map);
744
745 if (data && data->phaseid)
746 SetPhased(data->phaseid, false, true);
747
748 if (data && data->phaseGroup)
749 for (auto ph : GetPhasesForGroup(data->phaseGroup))
750 SetPhased(ph, false, true);
751
752 CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(Entry);
753 if (!cinfo)
754 {
755 SF_LOG_ERROR("sql.sql", "Creature::Create(): creature template (guidlow: %u, entry: %u) does not exist.", guidlow, Entry);
756 return false;
757 }
758
761 Relocate(x, y, z, ang);
762
763 //oX = x; oY = y; dX = x; dY = y; m_moveTime = 0; m_startMove = 0;
764 if (!CreateFromProto(guidlow, Entry, vehId, team, data))
765 return false;
766
767 if (!IsPositionValid())
768 {
769 SF_LOG_ERROR("entities.unit", "Creature::Create(): given coordinates for creature (guidlow %d, entry %d) are not valid (X: %f, Y: %f, Z: %f, O: %f)", guidlow, Entry, x, y, z, ang);
770 return false;
771 }
772
773 switch (GetCreatureTemplate()->rank)
774 {
777 break;
780 break;
783 break;
786 break;
787 default:
789 break;
790 }
791
793
796 {
798
800 Relocate(x, y, z, ang);
801 }
802
803 uint32 displayID = GetNativeDisplayId();
804 CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
805 if (minfo && !IsTotem()) // Cancel load if no model defined or if totem
806 {
807 SetDisplayId(displayID);
808 SetNativeDisplayId(displayID);
809 SetGender(minfo->gender);
810 }
811
813
815 if (IsSpiritHealer() || IsSpiritGuide())
816 {
819 }
820
821 if (Entry == VISUAL_WAYPOINT)
822 SetVisible(false);
823
824 return true;
825}
826
828{
831 else
833 /*else if (IsCivilian())
834 SetReactState(REACT_DEFENSIVE);*/
835}
836
838{
839 if (!IsBattleMaster())
840 return false;
841
842 BattlegroundTypeId bgTypeId = sBattlegroundMgr->GetBattleMasterBG(GetEntry());
843 if (!msg)
844 return player->GetBGAccessByLevel(bgTypeId);
845
846 if (!player->GetBGAccessByLevel(bgTypeId))
847 {
848 player->PlayerTalkClass->ClearMenus();
849 switch (bgTypeId)
850 {
865 default: break;
866 }
867 return false;
868 }
869 return true;
870}
871
873{
874 return player->getLevel() >= 10
876 && player->getClass() == GetCreatureTemplate()->trainer_class;
877}
878
880{
881 if (!m_lootRecipient)
882 return NULL;
884}
885
887{
889 return NULL;
890 return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup);
891}
892
894{
895 // set the player whose group should receive the right
896 // to loot the creature after it dies
897 // should be set to NULL after the loot disappears
898
899 if (!unit)
900 {
901 m_lootRecipient = 0;
904 return;
905 }
906
907 if (unit->GetTypeId() != TypeID::TYPEID_PLAYER && !unit->IsVehicle())
908 return;
909
911 if (!player) // normal creature, no player involved
912 return;
913
914 m_lootRecipient = player->GetGUID();
915 if (Group* group = player->GetGroup())
916 m_lootRecipientGroup = group->GetLowGUID();
917
919}
920
921// return true if this creature is tapped by the player or by a member of his group.
922bool Creature::isTappedBy(Player const* player) const
923{
924 if (player->GetGUID() == m_lootRecipient)
925 return true;
926
927 Group const* playerGroup = player->GetGroup();
928 if (!playerGroup || playerGroup != GetLootRecipientGroup()) // if we dont have a group we arent the recipient
929 return false; // if creature doesnt have group bound it means it was solo killed by someone else
930
931 return true;
932}
933
935{
936 // this should only be used when the creature has already been loaded
937 // preferably after adding to map, because mapid may not be valid otherwise
938 CreatureData const* data = sObjectMgr->GetCreatureData(m_DBTableGuid);
939 if (!data)
940 {
941 SF_LOG_ERROR("entities.unit", "Creature::SaveToDB failed, cannot get creature data!");
942 return;
943 }
944
946 SaveToDB(mapId, data->spawnMask);
947}
948
949void Creature::SaveToDB(uint32 mapid, uint32 spawnMask)
950{
951 // update in loaded data
952 if (!m_DBTableGuid)
954 CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_DBTableGuid);
955
956 uint32 displayId = GetNativeDisplayId();
960
961 // check if it's a custom model and if not, use 0 for displayId
962 CreatureTemplate const* cinfo = GetCreatureTemplate();
963 if (cinfo)
964 {
965 if (displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 ||
966 displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
967 displayId = 0;
968
969 if (npcflag == cinfo->npcflag)
970 npcflag = 0;
971
972 if (unit_flags == cinfo->unit_flags)
973 unit_flags = 0;
974
975 if (dynamicflags == cinfo->dynamicflags)
976 dynamicflags = 0;
977 }
978
979 // data->guid = guid must not be updated at save
980 data.id = GetEntry();
981 data.mapid = mapid;
982 data.displayid = displayId;
984 if (!GetTransport())
985 {
986 data.posX = GetPositionX();
987 data.posY = GetPositionY();
990 }
991 else
992 {
993 data.posX = GetTransOffsetX();
994 data.posY = GetTransOffsetY();
995 data.posZ = GetTransOffsetZ();
997 }
998
1000 // prevent add data integrity problems
1002 data.currentwaypoint = 0;
1003 data.curhealth = GetHealth();
1004 data.curmana = GetPower(POWER_MANA);
1005 // prevent add data integrity problems
1008 data.spawnMask = spawnMask;
1009 data.npcflag = npcflag;
1010 data.unit_flags = unit_flags;
1011 data.dynamicflags = dynamicflags;
1012
1013 // update in DB
1014 SQLTransaction trans = WorldDatabase.BeginTransaction();
1015
1016 PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
1017 stmt->setUInt32(0, m_DBTableGuid);
1018 trans->Append(stmt);
1019
1020 uint8 index = 0;
1021
1022 stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE);
1023 stmt->setUInt32(index++, m_DBTableGuid);
1024 stmt->setUInt32(index++, GetEntry());
1025 stmt->setUInt16(index++, uint16(mapid));
1026 stmt->setUInt32(index++, spawnMask);
1027 stmt->setUInt32(index++, displayId);
1028 stmt->setInt32(index++, int32(GetCurrentEquipmentId()));
1029 stmt->setFloat(index++, GetPositionX());
1030 stmt->setFloat(index++, GetPositionY());
1031 stmt->setFloat(index++, GetPositionZ());
1032 stmt->setFloat(index++, GetOrientation());
1033 stmt->setUInt32(index++, m_respawnDelay);
1034 stmt->setFloat(index++, m_respawnradius);
1035 stmt->setUInt32(index++, 0);
1036 stmt->setUInt32(index++, GetHealth());
1037 stmt->setUInt32(index++, GetPower(POWER_MANA));
1038 stmt->setUInt8(index++, uint8(GetDefaultMovementType()));
1039 stmt->setUInt32(index++, npcflag);
1040 stmt->setUInt32(index++, unit_flags);
1041 stmt->setUInt32(index++, dynamicflags);
1042 trans->Append(stmt);
1043
1044 WorldDatabase.CommitTransaction(trans);
1045}
1046
1048{
1049 uint32 rank = IsPet() ? 0 : cinfo->rank;
1050
1051 // level
1052 uint8 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel);
1053 uint8 maxlevel = std::max(cinfo->maxlevel, cinfo->minlevel);
1054 uint8 level = minlevel == maxlevel ? minlevel : uint8(std::rand() % (maxlevel - minlevel + 1) + minlevel);
1055 SetLevel(level);
1056
1057 CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(level, cinfo->unit_class);
1058
1059 // health
1060 float healthmod = _GetHealthMod(rank);
1061
1062 uint32 basehp = stats->GenerateHealth(cinfo);
1063 uint32 health = uint32(basehp * healthmod);
1064
1065 SetCreateHealth(health);
1066 SetMaxHealth(health);
1067 SetHealth(health);
1069
1070 // mana
1071 uint32 mana = stats->GenerateMana(cinfo);
1072 SetCreateMana(mana);
1073
1074 switch (getClass())
1075 {
1076 case CLASS_WARRIOR:
1078 break;
1079 case CLASS_ROGUE:
1081 break;
1082 case CLASS_MONK:
1084 break;
1085 default:
1086 SetMaxPower(POWER_MANA, mana);
1087 SetPower(POWER_MANA, mana);
1088 break;
1089 }
1090
1093
1094 //damage
1095 //float damagemod = _GetDamageMod(rank); // Set during loading templates into dmg_multiplier field
1096
1099
1102
1104}
1105
1107{
1108 switch (Rank) // define rates for each elite rank
1109 {
1111 return sWorld->getRate(Rates::RATE_CREATURE_NORMAL_HP);
1120 default:
1122 }
1123}
1124
1126{
1128 m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
1129}
1130
1132{
1133 switch (Rank) // define rates for each elite rank
1134 {
1145 default:
1147 }
1148}
1149
1151{
1152 switch (Rank) // define rates for each elite rank
1153 {
1164 default:
1166 }
1167}
1168
1170{
1171 SetZoneScript();
1172 if (m_zoneScript && data)
1173 {
1174 Entry = m_zoneScript->GetCreatureEntry(guidlow, data);
1175 if (!Entry)
1176 return false;
1177 }
1178
1179 CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(Entry);
1180 if (!cinfo)
1181 {
1182 SF_LOG_ERROR("sql.sql", "Creature::CreateFromProto(): creature template (guidlow: %u, entry: %u) does not exist.", guidlow, Entry);
1183 return false;
1184 }
1185
1187
1188 if (!vehId)
1189 vehId = cinfo->VehicleId;
1190
1192
1193 if (!UpdateEntry(Entry, team, data))
1194 return false;
1195
1196 if (vehId)
1197 CreateVehicleKit(vehId, Entry, true);
1198
1199 return true;
1200}
1201
1202bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap)
1203{
1204 CreatureData const* data = sObjectMgr->GetCreatureData(guid);
1205
1206 if (!data)
1207 {
1208 SF_LOG_ERROR("sql.sql", "Creature (GUID: %u) not found in table `creature`, can't load. ", guid);
1209 return false;
1210 }
1211
1212 m_DBTableGuid = guid;
1213 if (map->GetInstanceId() == 0)
1214 {
1215 if (map->GetCreature(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT)))
1216 return false;
1217 }
1218 else
1219 guid = sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT);
1220
1221 uint16 team = 0;
1222 if (!Create(guid, map, data->id, 0, team, data->posX, data->posY, data->posZ, data->orientation, data))
1223 return false;
1224
1225 //We should set first home position, because then AI calls home movement
1226 SetHomePosition(data->posX, data->posY, data->posZ, data->orientation);
1227
1228 m_respawnradius = data->spawndist;
1229
1232
1234 if (m_respawnTime) // respawn on Update
1235 {
1237 if (CanFly())
1238 {
1239 float tz = map->GetHeight(GetPhaseMask(), data->posX, data->posY, data->posZ, false);
1240 if (data->posZ - tz > 0.1f)
1241 Relocate(data->posX, data->posY, tz);
1242 }
1243 }
1244
1245 uint32 curhealth;
1246
1247 if (!m_regenHealth)
1248 {
1249 curhealth = data->curhealth;
1250 if (curhealth)
1251 {
1252 curhealth = uint32(curhealth * _GetHealthMod(GetCreatureTemplate()->rank));
1253 if (curhealth < 1)
1254 curhealth = 1;
1255 }
1256 SetPower(POWER_MANA, data->curmana);
1257 }
1258 else
1259 {
1260 curhealth = GetMaxHealth();
1262 }
1263
1265 {
1266 SetMaxHealth(0);
1268 }
1269
1270 SetHealth(m_deathState == DeathState::ALIVE ? curhealth : 0);
1271
1272 // checked at creature_template loading
1274
1275 m_creatureData = data;
1276
1277 if (addToMap && !GetMap()->AddToMap(this))
1278 return false;
1279 return true;
1280}
1281
1282void Creature::LoadEquipment(int8 id, bool force /*= true*/)
1283{
1284 if (id == 0)
1285 {
1286 if (force)
1287 {
1288 for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
1290 m_equipmentId = 0;
1291 }
1292 return;
1293 }
1294
1295 EquipmentInfo const* einfo = sObjectMgr->GetEquipmentInfo(GetEntry(), id);
1296 if (!einfo)
1297 return;
1298
1299 m_equipmentId = id;
1300 for (uint8 i = 0; i < 3; ++i)
1302}
1303
1304bool Creature::hasQuest(uint32 quest_id) const
1305{
1306 QuestRelationBounds qr = sObjectMgr->GetCreatureQuestRelationBounds(GetEntry());
1307 for (QuestRelations::const_iterator itr = qr.first; itr != qr.second; ++itr)
1308 {
1309 if (itr->second == quest_id)
1310 return true;
1311 }
1312 return false;
1313}
1314
1316{
1317 QuestRelationBounds qir = sObjectMgr->GetCreatureQuestInvolvedRelationBounds(GetEntry());
1318 for (QuestRelations::const_iterator itr = qir.first; itr != qir.second; ++itr)
1319 {
1320 if (itr->second == quest_id)
1321 return true;
1322 }
1323 return false;
1324}
1325
1327{
1328 if (!m_DBTableGuid)
1329 {
1330 SF_LOG_ERROR("entities.unit", "Trying to delete not saved creature! LowGUID: %u, Entry: %u", GetGUIDLow(), GetEntry());
1331 return;
1332 }
1333
1335 sObjectMgr->DeleteCreatureData(m_DBTableGuid);
1336
1337 SQLTransaction trans = WorldDatabase.BeginTransaction();
1338
1339 PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
1340 stmt->setUInt32(0, m_DBTableGuid);
1341 trans->Append(stmt);
1342
1343 stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON);
1344 stmt->setUInt32(0, m_DBTableGuid);
1345 trans->Append(stmt);
1346
1347 stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_CREATURE);
1348 stmt->setUInt32(0, m_DBTableGuid);
1349 trans->Append(stmt);
1350
1351 stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP);
1352 stmt->setUInt32(0, m_DBTableGuid);
1353 trans->Append(stmt);
1354
1355 WorldDatabase.CommitTransaction(trans);
1356}
1357
1359{
1361 return true;
1362
1363 if (IsAlive() || m_corpseRemoveTime > time(NULL))
1364 return false;
1365
1366 return true;
1367}
1368
1370{
1371 if (IsAIEnabled && AI()->CanSeeAlways(obj))
1372 return true;
1373
1374 return false;
1375}
1376
1377bool Creature::CanStartAttack(Unit const* who, bool force) const
1378{
1379 if (IsCivilian())
1380 return false;
1381
1383 return false;
1384
1385 // Do not attack non-combat pets
1387 return false;
1388
1390 //|| who->IsControlledByPlayer() && who->IsFlying()))
1391 // we cannot check flying for other creatures, too much map/vmap calculation
1393 return false;
1394
1395 if (!force)
1396 {
1397 if (!_IsTargetAcceptable(who))
1398 return false;
1399
1400 if (who->IsInCombat() && IsWithinDist(who, ATTACK_DISTANCE))
1401 if (Unit* victim = who->getAttackerForHelper())
1403 force = true;
1404
1405 if (!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who) + m_CombatDistance)))
1406 return false;
1407 }
1408
1409 if (!CanCreatureAttack(who, force))
1410 return false;
1411
1412 return IsWithinLOSInMap(who);
1413}
1414
1415float Creature::GetAttackDistance(Unit const* player) const
1416{
1417 float aggroRate = sWorld->getRate(Rates::RATE_CREATURE_AGGRO);
1418 if (aggroRate == 0)
1419 return 0.0f;
1420
1421 uint32 playerlevel = player->getLevelForTarget(this);
1422 uint32 creaturelevel = getLevelForTarget(player);
1423
1424 int32 leveldif = int32(playerlevel) - int32(creaturelevel);
1425
1426 // "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."
1427 if (leveldif < -25)
1428 leveldif = -25;
1429
1430 // "The aggro radius of a mob having the same level as the player is roughly 20 yards"
1431 float RetDistance = 20;
1432
1433 // "Aggro Radius varies with level difference at a rate of roughly 1 yard/level"
1434 // radius grow if playlevel < creaturelevel
1435 RetDistance -= (float)leveldif;
1436
1437 if (creaturelevel + 5 <= sWorld->getIntConfig(WorldIntConfigs::CONFIG_MAX_PLAYER_LEVEL))
1438 {
1439 // detect range auras
1441
1442 // detected range auras
1444 }
1445
1446 // "Minimum Aggro Radius for a mob seems to be combat range (5 yards)"
1447 if (RetDistance < 5)
1448 RetDistance = 5;
1449
1450 return (RetDistance * aggroRate);
1451}
1452
1454{
1456
1457 if (s == DeathState::JUST_DIED)
1458 {
1459 m_corpseRemoveTime = time(NULL) + m_corpseDelay;
1461
1462 // always save boss respawn time at death to prevent crash cheating
1465
1466 SetTarget(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
1468
1469 setActive(false);
1470
1471 if (!IsPet() && GetCreatureTemplate()->SkinLootId)
1472 if (LootTemplates_Skinning.HaveLootFor(GetCreatureTemplate()->SkinLootId))
1473 if (hasLootRecipient())
1475
1477 {
1478 SetNoSearchAssistance(false);
1479 UpdateSpeed(MOVE_RUN, false);
1480 }
1481
1482 //Dismiss group if is leader
1483 if (m_formation && m_formation->getLeader() == this)
1484 m_formation->FormationReset(true);
1485
1486 if ((CanFly() || IsFlying()))
1487 i_motionMaster.MoveFall();
1488
1490 }
1491 else if (s == DeathState::JUST_RESPAWNED)
1492 {
1493 //if (IsPet())
1494 // setActive(true);
1495 SetFullHealth();
1496 SetLootRecipient(NULL);
1498
1500
1501 CreatureTemplate const* cinfo = GetCreatureTemplate();
1505 LoadCreaturesAddon(true);
1507 //if (GetCreatureData() && GetPhaseMask() != GetCreatureData()->phaseMask)
1508 // SetPhaseMask(GetCreatureData()->phaseMask, false);
1510 }
1511}
1512
1513void Creature::Respawn(bool force)
1514{
1516
1517 if (force)
1518 {
1519 if (IsAlive())
1521 else if (getDeathState() != DeathState::CORPSE)
1523 }
1524
1525 RemoveCorpse(false);
1526
1528 {
1529 if (m_DBTableGuid)
1531
1532 SF_LOG_DEBUG("entities.unit", "Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)",
1533 GetName().c_str(), GetGUIDLow(), GetGUID(), GetEntry());
1534 m_respawnTime = 0;
1535 lootForPickPocketed = false;
1536 lootForBody = false;
1537
1538 if (m_originalEntry != GetEntry())
1540
1541 CreatureTemplate const* cinfo = GetCreatureTemplate();
1542 SelectLevel(cinfo);
1543
1545
1546 uint32 displayID = GetNativeDisplayId();
1547 CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
1548 if (minfo) // Cancel load if no model defined
1549 {
1550 SetDisplayId(displayID);
1551 SetNativeDisplayId(displayID);
1552 SetGender(minfo->gender);
1553 }
1554
1556
1557 //Call AI respawn virtual function
1558 if (IsAIEnabled)
1559 TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
1560
1561 uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
1562 if (poolid)
1563 sPoolMgr->UpdatePool<Creature>(poolid, GetDBTableGUIDLow());
1564
1565 //Re-initialize reactstate that could be altered by movementgenerators
1567 }
1568
1570
1571 if (IsAlive())
1572 sBattlePetSpawnMgr->OnCreatureAdded(this);
1573}
1574
1575void Creature::ForcedDespawn(uint32 timeMSToDespawn)
1576{
1577 if (timeMSToDespawn)
1578 {
1580
1581 m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn));
1582 return;
1583 }
1584
1585 if (IsAlive())
1587
1588 RemoveCorpse(false);
1589}
1590
1591void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/)
1592{
1593 if (TempSummon* summon = this->ToTempSummon())
1594 summon->UnSummon(msTimeToDespawn);
1595 else
1596 ForcedDespawn(msTimeToDespawn);
1597}
1598
1599bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
1600{
1601 if (!spellInfo)
1602 return false;
1603
1604 // Creature is immune to main mechanic of the spell
1605 if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))
1606 return true;
1607
1608 // This check must be done instead of 'if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))' for not break
1609 // the check of mechanic immunity on DB (tested) because GetCreatureTemplate()->MechanicImmuneMask and m_spellImmune[IMMUNITY_MECHANIC] don't have same data.
1610 bool immunedToAllEffects = true;
1611 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1612 {
1613 if (!spellInfo->Effects[i].IsEffect())
1614 continue;
1615 if (!IsImmunedToSpellEffect(spellInfo, i))
1616 {
1617 immunedToAllEffects = false;
1618 break;
1619 }
1620 }
1621 if (immunedToAllEffects)
1622 return true;
1623
1624 return Unit::IsImmunedToSpell(spellInfo);
1625}
1626
1627bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
1628{
1629 if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Effects[index].Mechanic - 1)))
1630 return true;
1631
1632 if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effects[index].Effect == SPELL_EFFECT_HEAL)
1633 return true;
1634
1635 return Unit::IsImmunedToSpellEffect(spellInfo, index);
1636}
1637
1639{
1640 if (IsPet())
1641 return false;
1642
1644 return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
1645}
1646
1648{
1649 if (IsPet())
1650 return false;
1651
1653}
1654
1656{
1657 if (!victim)
1658 return NULL;
1659
1660 for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
1661 {
1662 if (!m_spells[i])
1663 continue;
1664 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(m_spells[i]);
1665 if (!spellInfo)
1666 {
1667 SF_LOG_ERROR("entities.unit", "WORLD: unknown spell id %i", m_spells[i]);
1668 continue;
1669 }
1670
1671 bool bcontinue = true;
1672 for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
1673 {
1674 if ((spellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) ||
1675 (spellInfo->Effects[j].Effect == SPELL_EFFECT_INSTAKILL) ||
1677 (spellInfo->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
1678 )
1679 {
1680 bcontinue = false;
1681 break;
1682 }
1683 }
1684 if (bcontinue)
1685 continue;
1686
1687 //if (spellInfo->ManaCost > (uint32)GetPower(POWER_MANA))
1688 // continue;
1689
1690 float range = spellInfo->GetMaxRange(false);
1691 float minrange = spellInfo->GetMinRange(false);
1692 float dist = GetDistance(victim);
1693 if (dist > range || dist < minrange)
1694 continue;
1696 continue;
1698 continue;
1699 return spellInfo;
1700 }
1701 return NULL;
1702}
1703
1705{
1706 if (!victim)
1707 return NULL;
1708
1709 for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
1710 {
1711 if (!m_spells[i])
1712 continue;
1713 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(m_spells[i]);
1714 if (!spellInfo)
1715 {
1716 SF_LOG_ERROR("entities.unit", "WORLD: unknown spell id %i", m_spells[i]);
1717 continue;
1718 }
1719
1720 bool bcontinue = true;
1721 for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
1722 {
1723 if ((spellInfo->Effects[j].Effect == SPELL_EFFECT_HEAL))
1724 {
1725 bcontinue = false;
1726 break;
1727 }
1728 }
1729 if (bcontinue)
1730 continue;
1731
1732 //if (spellInfo->ManaCost > (uint32)GetPower(POWER_MANA))
1733 // continue;
1734
1735 float range = spellInfo->GetMaxRange(true);
1736 float minrange = spellInfo->GetMinRange(true);
1737 float dist = GetDistance(victim);
1738 //if (!isInFront(victim, range) && spellInfo->AttributesEx)
1739 // continue;
1740 if (dist > range || dist < minrange)
1741 continue;
1743 continue;
1745 continue;
1746 return spellInfo;
1747 }
1748 return NULL;
1749}
1750
1751// select nearest hostile unit within the given distance (regardless of threat list).
1752Unit* Creature::SelectNearestTarget(float dist, bool playerOnly /* = false */) const
1753{
1755 Cell cell(p);
1756 cell.SetNoCreate();
1757
1758 Unit* target = NULL;
1759
1760 {
1761 if (dist == 0.0f)
1763
1764 Skyfire::NearestHostileUnitCheck u_check(this, dist, playerOnly);
1766
1769
1770 cell.Visit(p, world_unit_searcher, *GetMap(), *this, dist);
1771 cell.Visit(p, grid_unit_searcher, *GetMap(), *this, dist);
1772 }
1773
1774 return target;
1775}
1776
1777// select nearest hostile unit within the given attack distance (i.e. distance is ignored if > than ATTACK_DISTANCE), regardless of threat list.
1779{
1781 Cell cell(p);
1782 cell.SetNoCreate();
1783
1784 Unit* target = NULL;
1785
1786 if (dist > MAX_VISIBILITY_DISTANCE)
1787 {
1788 SF_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) SelectNearestTargetInAttackDistance called with dist > MAX_VISIBILITY_DISTANCE. Distance set to ATTACK_DISTANCE.", GetGUIDLow(), GetEntry());
1789 dist = ATTACK_DISTANCE;
1790 }
1791
1792 {
1795
1798
1799 cell.Visit(p, world_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE > dist ? ATTACK_DISTANCE : dist);
1800 cell.Visit(p, grid_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE > dist ? ATTACK_DISTANCE : dist);
1801 }
1802
1803 return target;
1804}
1805
1807{
1808 Player* target = NULL;
1809
1810 Skyfire::NearestPlayerInObjectRangeCheck checker(this, distance);
1812 VisitNearbyObject(distance, searcher);
1813
1814 return target;
1815}
1816
1818{
1819 WorldPacket data(SMSG_AI_REACTION, 12);
1820
1821 ObjectGuid guid = GetGUID();
1822
1823 data.WriteGuidMask(guid, 5, 7, 0, 4, 6, 2, 3, 1);
1824
1825 data.WriteGuidBytes(guid, 4, 6, 5);
1826 data << uint32(reactionType);
1827 data.WriteGuidBytes(guid, 7, 1, 2, 0, 3);
1828
1829 ((WorldObject*)this)->SendMessageToSet(&data, true);
1830
1831 SF_LOG_DEBUG("network", "WORLD: Sent SMSG_AI_REACTION, type %u.", reactionType);
1832}
1833
1835{
1836 if (!m_AlreadyCallAssistance && GetVictim() && !IsPet() && !IsCharmed())
1837 {
1838 SetNoCallAssistance(true);
1839
1841
1842 if (radius > 0)
1843 {
1844 std::list<Creature*> assistList;
1845
1846 {
1848 Cell cell(p);
1849 cell.SetNoCreate();
1850
1851 Skyfire::AnyAssistCreatureInRangeCheck u_check(this, GetVictim(), radius);
1853
1855
1856 cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
1857 }
1858
1859 if (!assistList.empty())
1860 {
1861 AssistDelayEvent* e = new AssistDelayEvent(GetVictim()->GetGUID(), *this);
1862 while (!assistList.empty())
1863 {
1864 // Pushing guids because in delay can happen some creature gets despawned => invalid pointer
1865 e->AddAssistant((*assistList.begin())->GetGUID());
1866 assistList.pop_front();
1867 }
1868 m_Events.AddEvent(e, m_Events.CalculateTime(sWorld->getIntConfig(WorldIntConfigs::CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY)));
1869 }
1870 }
1871 }
1872}
1873
1874void Creature::CallForHelp(float radius)
1875{
1876 if (radius <= 0.0f || !GetVictim() || IsPet() || IsCharmed())
1877 return;
1878
1880 Cell cell(p);
1881 cell.SetNoCreate();
1882
1883 Skyfire::CallOfHelpCreatureInRangeDo u_do(this, GetVictim(), radius);
1885
1887
1888 cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
1889}
1890
1891bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
1892{
1893 // is it true?
1895 return false;
1896
1897 // we don't need help from zombies :)
1898 if (!IsAlive())
1899 return false;
1900
1901 // we don't need help from non-combatant ;)
1902 if (IsCivilian())
1903 return false;
1904
1906 return false;
1907
1908 // skip fighting creature
1909 if (IsInCombat())
1910 return false;
1911
1912 // only free creature
1914 return false;
1915
1916 // only from same creature faction
1917 if (checkfaction)
1918 {
1919 if (getFaction() != u->getFaction())
1920 return false;
1921 }
1922 else
1923 {
1924 if (!IsFriendlyTo(u))
1925 return false;
1926 }
1927
1928 // skip non hostile to caster enemy creatures
1929 if (!IsHostileTo(enemy))
1930 return false;
1931
1932 return true;
1933}
1934
1935// use this function to avoid having hostile creatures attack
1936// friendlies and other mobs they shouldn't attack
1937bool Creature::_IsTargetAcceptable(const Unit* target) const
1938{
1939 ASSERT(target);
1940
1941 // if the target cannot be attacked, the target is not acceptable
1942 if (IsFriendlyTo(target)
1943 || !target->isTargetableForAttack(false)
1944 || (m_vehicle && (IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target))))
1945 return false;
1946
1947 if (target->HasUnitState(UNIT_STATE_DIED))
1948 {
1949 // guards can detect fake death
1951 return true;
1952 else
1953 return false;
1954 }
1955
1956 const Unit* myVictim = getAttackerForHelper();
1957 const Unit* targetVictim = target->getAttackerForHelper();
1958
1959 // if I'm already fighting target, or I'm hostile towards the target, the target is acceptable
1960 if (myVictim == target || targetVictim == this || IsHostileTo(target))
1961 return true;
1962
1963 // if the target's victim is friendly, and the target is neutral, the target is acceptable
1964 if (targetVictim && IsFriendlyTo(targetVictim))
1965 return true;
1966
1967 // if the target's victim is not friendly, or the target is friendly, the target is not acceptable
1968 return false;
1969}
1970
1972{
1973 if (IsSummon() || !m_DBTableGuid || (m_creatureData && !m_creatureData->dbData))
1974 return;
1975
1977}
1978
1979// this should not be called by petAI or
1980bool Creature::CanCreatureAttack(Unit const* victim, bool /*force*/) const
1981{
1982 if (!victim->IsInMap(this))
1983 return false;
1984
1985 if (!IsValidAttackTarget(victim))
1986 return false;
1987
1988 if (!victim->isInAccessiblePlaceFor(this))
1989 return false;
1990
1991 if (IsAIEnabled && !AI()->CanAIAttack(victim))
1992 return false;
1993
1994 if (sMapStore.LookupEntry(GetMapId())->IsInstance())
1995 return true;
1996
1997 //Use AttackDistance in distance check if threat radius is lower. This prevents creature bounce in and out of combat every update tick.
1998 float dist = std::max(GetAttackDistance(victim), sWorld->GetFloatConfig(WorldFloatConfigs::CONFIG_THREAT_RADIUS)) + m_CombatDistance;
1999
2000 if (Unit* unit = GetCharmerOrOwner())
2001 return victim->IsWithinDist(unit, dist);
2002 else
2003 return victim->IsInDist(&m_homePosition, dist);
2004}
2005
2007{
2008 if (m_DBTableGuid)
2009 {
2010 if (CreatureAddon const* addon = sObjectMgr->GetCreatureAddon(m_DBTableGuid))
2011 return addon;
2012 }
2013
2014 // dependent from difficulty mode entry
2015 return sObjectMgr->GetCreatureTemplateAddon(GetCreatureTemplate()->Entry);
2016}
2017
2018//creature_addon table
2020{
2021 CreatureAddon const* cainfo = GetCreatureAddon();
2022 if (!cainfo)
2023 return false;
2024
2025 if (cainfo->mount != 0)
2026 Mount(cainfo->mount);
2027
2028 if (cainfo->bytes1 != 0)
2029 {
2030 // 0 StandState
2031 // 1 FreeTalentPoints Pet only, so always 0 for default creature
2032 // 2 StandFlags
2033 // 3 StandMiscFlags
2034
2035 SetByteValue(UNIT_FIELD_ANIM_TIER, 0, uint8(cainfo->bytes1 & 0xFF));
2036 //SetByteValue(UNIT_FIELD_ANIM_TIER, 1, uint8((cainfo->bytes1 >> 8) & 0xFF));
2038 SetByteValue(UNIT_FIELD_ANIM_TIER, 2, uint8((cainfo->bytes1 >> 16) & 0xFF));
2039 SetByteValue(UNIT_FIELD_ANIM_TIER, 3, uint8((cainfo->bytes1 >> 24) & 0xFF));
2040
2048 }
2049
2050 if (cainfo->bytes2 != 0)
2051 {
2052 // 0 SheathState
2053 // 1 Bytes2Flags
2054 // 2 UnitRename Pet only, so always 0 for default creature
2055 // 3 ShapeshiftForm Must be determined/set by shapeshift spell/aura
2056
2058 //SetByteValue(UNIT_FIELD_SHAPESHIFT_FORM, 1, uint8((cainfo->bytes2 >> 8) & 0xFF));
2059 //SetByteValue(UNIT_FIELD_SHAPESHIFT_FORM, 2, uint8((cainfo->bytes2 >> 16) & 0xFF));
2061 //SetByteValue(UNIT_FIELD_SHAPESHIFT_FORM, 3, uint8((cainfo->bytes2 >> 24) & 0xFF));
2063 }
2064
2065 if (cainfo->emote != 0)
2067
2068 //Load Path
2069 if (cainfo->path_id != 0)
2070 m_path_id = cainfo->path_id;
2071
2072 if (!cainfo->auras.empty())
2073 {
2074 for (std::vector<uint32>::const_iterator itr = cainfo->auras.begin(); itr != cainfo->auras.end(); ++itr)
2075 {
2076 SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(*itr);
2077 if (!AdditionalSpellInfo)
2078 {
2079 SF_LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.", GetGUIDLow(), GetEntry(), *itr);
2080 continue;
2081 }
2082
2083 // skip already applied aura
2084 if (HasAura(*itr))
2085 {
2086 if (!reload)
2087 SF_LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.", GetDBTableGUIDLow(), GetEntry(), *itr);
2088
2089 continue;
2090 }
2091
2092 AddAura(*itr, this);
2093 SF_LOG_DEBUG("entities.unit", "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUIDLow(), GetEntry());
2094 }
2095 }
2096
2097 return true;
2098}
2099
2102{
2103 uint32 enemy_team = attacker->GetTeam();
2104
2106 data << uint32(GetAreaId());
2107 sWorld->SendGlobalMessage(&data, NULL, (enemy_team == ALLIANCE ? HORDE : ALLIANCE));
2108}
2109
2111{
2112 if (!CanHaveThreatList())
2113 {
2114 SF_LOG_ERROR("entities.unit", "Creature entry %u call SetInCombatWithZone but creature cannot have threat list.", GetEntry());
2115 return;
2116 }
2117
2118 Map* map = GetMap();
2119
2120 if (!map->IsInstance())
2121 {
2122 SF_LOG_ERROR("entities.unit", "Creature entry %u call SetInCombatWithZone for map (id: %u) that isn't an instance.", GetEntry(), map->GetId());
2123 return;
2124 }
2125
2126 Map::PlayerList const& PlList = map->GetPlayers();
2127
2128 if (PlList.isEmpty())
2129 return;
2130
2131 for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
2132 {
2133 if (Player* player = i->GetSource())
2134 {
2135 if (player->IsGameMaster())
2136 continue;
2137
2138 if (player->IsAlive())
2139 {
2140 this->SetInCombatWith(player);
2141 player->SetInCombatWith(this);
2142 AddThreat(player, 0.0f);
2143 }
2144 }
2145 }
2146}
2147
2148void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
2149{
2150 m_CreatureSpellCooldowns[spell_id] = end_time;
2151}
2152
2153void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t apply_time)
2154{
2155 m_CreatureCategoryCooldowns[category] = apply_time;
2156}
2157
2159{
2160 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
2161 if (!spellInfo)
2162 return;
2163
2164 uint32 cooldown = spellInfo->GetRecoveryTime();
2165 if (Player* modOwner = GetSpellModOwner())
2166 modOwner->ApplySpellMod(spellid, SPELLMOD_COOLDOWN, cooldown);
2167
2168 if (cooldown)
2169 _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown / IN_MILLISECONDS);
2170
2171 if (spellInfo->GetCategory())
2172 _AddCreatureCategoryCooldown(spellInfo->GetCategory(), time(NULL));
2173}
2174
2176{
2177 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
2178 if (!spellInfo)
2179 return false;
2180
2181 CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->GetCategory());
2182 return (itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILLISECONDS)) > time(NULL));
2183}
2184
2186{
2187 CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId);
2188 time_t t = time(NULL);
2189 return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0);
2190}
2191
2193{
2194 CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id);
2195 return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id);
2196}
2197
2199{
2200 time_t curTime = time(NULL);
2201 for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
2202 {
2203 if (m_spells[i] == 0)
2204 continue;
2205
2206 uint32 unSpellId = m_spells[i];
2207 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(unSpellId);
2208 if (!spellInfo)
2209 {
2210 ASSERT(spellInfo);
2211 continue;
2212 }
2213
2214 // Not send cooldown for this spells
2215 if (spellInfo->IsCooldownStartedOnEvent())
2216 continue;
2217
2219 continue;
2220
2221 if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs)
2222 {
2223 _AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs / IN_MILLISECONDS);
2224 if (UnitAI* ai = GetAI())
2225 ai->SpellInterrupted(unSpellId, unTimeMs);
2226 }
2227 }
2228}
2229
2230bool Creature::HasSpell(uint32 spellID) const
2231{
2232 uint8 i;
2233 for (i = 0; i < CREATURE_MAX_SPELLS; ++i)
2234 if (spellID == m_spells[i])
2235 break;
2236 return i < CREATURE_MAX_SPELLS; //broke before end of iteration of known spells
2237}
2238
2240{
2241 time_t now = time(NULL);
2242 if (m_respawnTime > now)
2243 return m_respawnTime;
2244 else
2245 return now;
2246}
2247
2248void Creature::GetRespawnPosition(float& x, float& y, float& z, float* ori, float* dist) const
2249{
2250 if (m_DBTableGuid)
2251 {
2252 if (CreatureData const* data = sObjectMgr->GetCreatureData(GetDBTableGUIDLow()))
2253 {
2254 x = data->posX;
2255 y = data->posY;
2256 z = data->posZ;
2257 if (ori)
2258 *ori = data->orientation;
2259 if (dist)
2260 *dist = data->spawndist;
2261
2262 return;
2263 }
2264 }
2265
2266 x = GetPositionX();
2267 y = GetPositionY();
2268 z = GetPositionZ();
2269 if (ori)
2270 *ori = GetOrientation();
2271 if (dist)
2272 *dist = 0;
2273}
2274
2276{
2278 {
2279 time_t now = time(NULL);
2280 if (m_corpseRemoveTime <= now)
2281 return;
2282
2283 float decayRate;
2284 CreatureTemplate const* cinfo = GetCreatureTemplate();
2285
2286 decayRate = sWorld->getRate(Rates::RATE_CORPSE_DECAY_LOOTED);
2287 uint32 diff = uint32((m_corpseRemoveTime - now) * decayRate);
2288
2289 m_respawnTime -= diff;
2290
2291 // corpse skinnable, but without skinning flag, and then skinned, corpse will despawn next update
2292 if (cinfo && cinfo->SkinLootId)
2293 m_corpseRemoveTime = time(NULL);
2294 else
2295 m_corpseRemoveTime -= diff;
2296 }
2297}
2298
2300{
2301 if (!isWorldBoss() || !target->ToUnit())
2302 return Unit::getLevelForTarget(target);
2303
2304 uint16 level = target->ToUnit()->getLevel() + sWorld->getIntConfig(WorldIntConfigs::CONFIG_WORLD_BOSS_LEVEL_DIFF);
2305 if (level < 1)
2306 return 1;
2307 if (level > 255)
2308 return 255;
2309 return uint8(level);
2310}
2311
2312std::string Creature::GetAIName() const
2313{
2314 return sObjectMgr->GetCreatureTemplate(GetEntry())->AIName;
2315}
2316
2317std::string Creature::GetScriptName() const
2318{
2319 return sObjectMgr->GetScriptName(GetScriptId());
2320}
2321
2323{
2324 return sObjectMgr->GetCreatureTemplate(GetEntry())->ScriptID;
2325}
2326
2328{
2329 return sObjectMgr->GetNpcVendorItemList(GetEntry());
2330}
2331
2333{
2334 if (!vItem->maxcount)
2335 return vItem->maxcount;
2336
2337 VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
2338 for (; itr != m_vendorItemCounts.end(); ++itr)
2339 if (itr->itemId == vItem->item)
2340 break;
2341
2342 if (itr == m_vendorItemCounts.end())
2343 return vItem->maxcount;
2344
2345 VendorItemCount* vCount = &*itr;
2346
2347 time_t ptime = time(NULL);
2348
2349 if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime)
2350 if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item))
2351 {
2352 uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime);
2353 if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount)
2354 {
2355 m_vendorItemCounts.erase(itr);
2356 return vItem->maxcount;
2357 }
2358
2359 vCount->count += diff * pProto->BuyCount;
2360 vCount->lastIncrementTime = ptime;
2361 }
2362
2363 return vCount->count;
2364}
2365
2367{
2368 if (!vItem->maxcount)
2369 return 0;
2370
2371 VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
2372 for (; itr != m_vendorItemCounts.end(); ++itr)
2373 if (itr->itemId == vItem->item)
2374 break;
2375
2376 if (itr == m_vendorItemCounts.end())
2377 {
2378 uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount - used_count : 0;
2379 m_vendorItemCounts.push_back(VendorItemCount(vItem->item, new_count));
2380 return new_count;
2381 }
2382
2383 VendorItemCount* vCount = &*itr;
2384
2385 time_t ptime = time(NULL);
2386
2387 if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime)
2388 if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item))
2389 {
2390 uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime);
2391 if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount)
2392 vCount->count += diff * pProto->BuyCount;
2393 else
2394 vCount->count = vItem->maxcount;
2395 }
2396
2397 vCount->count = vCount->count > used_count ? vCount->count - used_count : 0;
2398 vCount->lastIncrementTime = ptime;
2399 return vCount->count;
2400}
2401
2403{
2404 return sObjectMgr->GetNpcTrainerSpells(GetEntry());
2405}
2406
2407// overwrite WorldObject function for proper name localization
2408std::string const& Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const
2409{
2410 if (loc_idx != DEFAULT_LOCALE)
2411 {
2412 uint8 uloc_idx = uint8(loc_idx);
2413 CreatureLocale const* cl = sObjectMgr->GetCreatureLocale(GetEntry());
2414 if (cl)
2415 {
2416 if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty())
2417 return cl->Name[uloc_idx];
2418 }
2419 }
2420
2421 return GetName();
2422}
2423
2424//Do not if this works or not, moving creature to another map is very dangerous
2425void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
2426{
2428 GetMap()->RemoveFromMap(this, false);
2429 Relocate(X, Y, Z, O);
2430 SetMap(map);
2431 GetMap()->AddToMap(this);
2432}
2433
2435{
2436 if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
2437 return 0;
2438 else
2439 return m_charmInfo->GetCharmSpell(pos)->GetAction();
2440}
2441
2442void Creature::SetPosition(float x, float y, float z, float o)
2443{
2444 // prevent crash when a bad coord is sent by the client
2445 if (!Skyfire::IsValidMapCoord(x, y, z, o))
2446 {
2447 SF_LOG_DEBUG("entities.unit", "Creature::SetPosition(%f, %f, %f) .. bad coordinates!", x, y, z);
2448 return;
2449 }
2450
2451 GetMap()->CreatureRelocation(ToCreature(), x, y, z, o);
2452 if (IsVehicle())
2454}
2455
2457{
2458 CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry());
2459 return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS);
2460}
2461
2462float Creature::GetAggroRange(Unit const* target) const
2463{
2464 // Determines the aggro range for creatures (usually pets), used mainly for aggressive pet target selection.
2465 // Based on data from wowwiki due to lack of 3.3.5a data
2466
2467 if (target && this->IsPet())
2468 {
2469 uint32 targetLevel = 0;
2470
2471 if (target->GetTypeId() == TypeID::TYPEID_PLAYER)
2472 targetLevel = target->getLevelForTarget(this);
2473 else if (target->GetTypeId() == TypeID::TYPEID_UNIT)
2474 targetLevel = target->ToCreature()->getLevelForTarget(this);
2475
2476 uint32 myLevel = getLevelForTarget(target);
2477 int32 levelDiff = int32(targetLevel) - int32(myLevel);
2478
2479 // The maximum Aggro Radius is capped at 45 yards (25 level difference)
2480 if (levelDiff < -25)
2481 levelDiff = -25;
2482
2483 // The base aggro radius for mob of same level
2484 float aggroRadius = 20;
2485
2486 // Aggro Radius varies with level difference at a rate of roughly 1 yard/level
2487 aggroRadius -= (float)levelDiff;
2488
2489 // detect range auras
2491
2492 // detected range auras
2494
2495 // Just in case, we don't want pets running all over the map
2496 if (aggroRadius > MAX_AGGRO_RADIUS)
2497 aggroRadius = MAX_AGGRO_RADIUS;
2498
2499 // Minimum Aggro Radius for a mob seems to be combat range (5 yards)
2500 // hunter pets seem to ignore minimum aggro radius so we'll default it a little higher
2501 if (aggroRadius < 10)
2502 aggroRadius = 10;
2503
2504 return (aggroRadius);
2505 }
2506
2507 // Default
2508 return 0.0f;
2509}
2510
2512{
2513 // Selects nearest hostile target within creature's aggro range. Used primarily by
2514 // pets set to aggressive. Will not return neutral or friendly targets.
2515
2516 Unit* target = NULL;
2517
2518 {
2521
2523 }
2524
2525 return target;
2526}
2527
2528void Creature::SetFlying(bool enable)
2529{
2530 if (enable)
2534 else
2536
2537 if (enable)
2538 {
2539 if (!IsLevitating())
2540 SetDisableGravity(true);
2541 SetFall(false);
2542 }
2543}
2544
2546{
2547 // Do not update movement flags if creature is controlled by a player (charm/vehicle)
2548 if (m_movedPlayer)
2549 return;
2550
2551 uint32 inhabitType = GetCreatureTemplate()->InhabitType;
2552
2553 if (CanFly() && !IsFalling())
2554 {
2556 bool isInAir = (G3D::fuzzyGt(GetPositionZMinusOffset(), ground + 0.05f) || G3D::fuzzyLt(GetPositionZMinusOffset(), ground - 0.05f));
2557
2558 SetFlying(isInAir || !(inhabitType & INHABIT_GROUND));
2559 SetCanFly(true);
2560 SetFall(false);
2561 SetSwim(false);
2562 return;
2563 }
2564
2565 // Ground creatures do not need per-tick gravity flag churn during idle wander or chase;
2566 // uneven vmap height causes bobbing/falling (notably when kiting in combat).
2567 if (!(inhabitType & INHABIT_AIR) && !HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
2568 {
2570 if (curMove == CHASE_MOTION_TYPE)
2571 {
2572 if (inhabitType & INHABIT_WATER)
2573 SetSwim(IsInWater());
2574 return;
2575 }
2576 if (!IsInCombat() && (curMove == IDLE_MOTION_TYPE || curMove == RANDOM_MOTION_TYPE))
2577 return;
2578 }
2579
2580 // Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc)
2582
2583 bool isInAir = (G3D::fuzzyGt(GetPositionZMinusOffset(), ground + 0.05f) || G3D::fuzzyLt(GetPositionZMinusOffset(), ground - 0.05f)); // Can be underground too, prevent the falling
2584
2585 if ((inhabitType & INHABIT_AIR) && isInAir && !IsFalling())
2586 {
2587 if (inhabitType & INHABIT_GROUND)
2588 SetCanFly(true);
2589 else
2590 SetDisableGravity(true);
2591 }
2592 else
2593 {
2594 SetCanFly(false);
2595 SetDisableGravity(false);
2596 }
2597
2598 if (!isInAir)
2599 SetFall(false);
2600
2601 SetSwim((inhabitType & INHABIT_WATER) && IsInWater());
2602}
2603
2605{
2606 Unit::SetObjectScale(scale);
2607
2608 if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(GetDisplayId()))
2609 {
2610 SetFloatValue(UNIT_FIELD_BOUNDING_RADIUS, minfo->bounding_radius * scale);
2611 SetFloatValue(UNIT_FIELD_COMBAT_REACH, minfo->combat_reach * scale);
2612 }
2613}
2614
2616{
2617 Unit::SetDisplayId(modelId);
2618
2619 if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
2620 {
2621 SetFloatValue(UNIT_FIELD_BOUNDING_RADIUS, minfo->bounding_radius * GetObjectScale());
2622 SetFloatValue(UNIT_FIELD_COMBAT_REACH, minfo->combat_reach * GetObjectScale());
2623 }
2624}
2625
2627{
2628 if (!_focusSpell)
2630}
2631
2632void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
2633{
2634 // already focused
2635 if (_focusSpell)
2636 return;
2637
2638 _focusSpell = focusSpell;
2642
2643 // Set serverside orientation if needed (needs to be after attribute check)
2644 SetInFront(target);
2645}
2646
2647void Creature::ReleaseFocus(Spell const* focusSpell)
2648{
2649 // focused to something else
2650 if (focusSpell != _focusSpell)
2651 return;
2652
2653 _focusSpell = NULL;
2654 if (Unit* victim = GetVictim())
2655 SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
2656 else
2658
2661}
uint8 BattlePetNormalizeWildLevel(uint8 level)
#define sBattlePetSpawnMgr
#define sBattlegroundMgr
LocaleConstant
Definition Common.h:138
#define DEFAULT_LOCALE
Definition Common.h:154
@ IN_MILLISECONDS
Definition Common.h:125
@ MINUTE
Definition Common.h:119
@ DAY
Definition Common.h:121
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
Definition Creature.h:44
@ CREATURE_FLAG_EXTRA_NO_TAUNT
Definition Creature.h:37
@ CREATURE_FLAG_EXTRA_WORLDEVENT
Definition Creature.h:38
#define CREATURE_REGEN_INTERVAL
Definition Creature.h:55
#define CREATURE_Z_ATTACK_RANGE
Definition Creature.h:422
#define MAX_EQUIPMENT_ITEMS
Definition Creature.h:59
@ INHABIT_AIR
Definition Creature.h:298
@ INHABIT_WATER
Definition Creature.h:297
@ INHABIT_GROUND
Definition Creature.h:296
#define sFormationMgr
@ FACTION_TEMPLATE_FLAG_PVP
Definition DBCEnums.h:377
std::set< uint32 > const & GetPhasesForGroup(uint32 group)
DBCStorage< DifficultyEntry > sDifficultyStore(Difficultyfmt)
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define MAX_SPELL_EFFECTS
std::int32_t int32
Definition Define.h:73
#define UI64FMTD
Definition Define.h:64
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::int8_t int8
Definition Define.h:75
std::uint64_t uint64
Definition Define.h:76
std::uint16_t uint16
Definition Define.h:78
#define ASSERT
Definition Errors.h:29
#define sGameEventMgr
TypeMapContainer< AllWorldObjectTypes > WorldTypeMapContainer
Definition GridDefines.h:72
TypeMapContainer< AllGridObjectTypes > GridTypeMapContainer
Definition GridDefines.h:71
CoordPair< TOTAL_NUMBER_OF_CELLS_PER_MAP > CellCoord
#define sGroupMgr
Definition GroupMgr.h:44
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
#define SF_LOG_ERROR(filterType__,...)
Definition Log.h:143
LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true)
MovementGeneratorType
@ IDLE_MOTION_TYPE
@ CHASE_MOTION_TYPE
@ RANDOM_MOTION_TYPE
#define VISUAL_WAYPOINT
#define ATTACK_DISTANCE
Definition Object.h:22
@ TYPEID_PLAYER
Definition Object.h:55
@ TYPEID_UNIT
Definition Object.h:54
#define MAX_VISIBILITY_DISTANCE
Definition Object.h:23
#define sObjectAccessor
@ HIGHGUID_UNIT
@ HIGHGUID_VEHICLE
uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h)
std::pair< QuestRelations::const_iterator, QuestRelations::const_iterator > QuestRelationBounds
Definition ObjectMgr.h:457
#define sObjectMgr
Definition ObjectMgr.h:1617
#define sPoolMgr
Definition PoolMgr.h:154
#define sScriptMgr
Definition ScriptMgr.h:764
@ SERVERSIDE_VISIBILITY_GHOST
@ POWER_RAGE
@ POWER_ENERGY
@ POWER_CHI
@ POWER_MANA
SpellSchools
@ SPELL_SCHOOL_SHADOW
@ SPELL_SCHOOL_NATURE
@ SPELL_SCHOOL_FROST
@ SPELL_SCHOOL_ARCANE
@ SPELL_SCHOOL_FIRE
@ SPELL_SCHOOL_HOLY
@ SPELL_EFFECT_HEALTH_LEECH
@ SPELL_EFFECT_HEAL
@ SPELL_EFFECT_ATTACK_ME
@ SPELL_EFFECT_ENVIRONMENTAL_DAMAGE
@ SPELL_EFFECT_SCHOOL_DAMAGE
@ SPELL_EFFECT_INSTAKILL
@ SPELL_PREVENTION_TYPE_SILENCE
@ SPELL_PREVENTION_TYPE_PACIFY
@ CREATURE_TYPE_CRITTER
@ CREATURE_TYPE_NON_COMBAT_PET
@ CREATURE_TYPE_MECHANICAL
@ UNIT_DYNFLAG_TAPPED
@ UNIT_DYNFLAG_LOOTABLE
AiReaction
@ CLASS_MONK
@ CLASS_WARRIOR
@ CLASS_ROGUE
@ CREATURE_ELITE_NORMAL
@ CREATURE_ELITE_WORLDBOSS
@ CREATURE_ELITE_RARE
@ CREATURE_ELITE_RAREELITE
@ CREATURE_ELITE_ELITE
@ IMMUNITY_STATE
@ IMMUNITY_EFFECT
@ ALLIANCE
@ HORDE
@ SPELL_ATTR5_DONT_TURN_DURING_CAST
BattlegroundTypeId
@ TRAINER_TYPE_CLASS
@ GHOST_VISIBILITY_GHOST
#define CURRENT_CONTENT_EXP
@ STAT_SPIRIT
@ CREATURE_TYPEFLAGS_BOSS
SpellSchoolMask
@ SPELL_SCHOOL_MASK_NORMAL
@ SPELL_AURA_MOD_POWER_REGEN
@ SPELL_AURA_PREVENTS_FLEEING
@ SPELL_AURA_MOD_HEALTH_REGEN_PERCENT
@ SPELL_AURA_MOD_DETECTED_RANGE
@ SPELL_AURA_MOD_TAUNT
@ SPELL_AURA_MOD_POWER_REGEN_PERCENT
@ SPELL_AURA_MOD_DETECT_RANGE
@ SPELL_AURA_MOD_REGEN
#define sSpellMgr
Definition SpellMgr.h:744
Skyfire::AutoPtr< Transaction, Skyfire::Mutex > SQLTransaction
Definition Transaction.h:42
@ UNIT_NPC_FLAG_WILDPET_CAPTURABLE
Definition Unit.h:716
@ UNIT_NPC_FLAG_NONE
Definition Unit.h:686
#define MAX_SPELL_CHARM
Definition Unit.h:273
@ MOVEMENTFLAG_HOVER
Definition Unit.h:751
@ SPELLMOD_COOLDOWN
Definition Unit.h:84
@ UNIT_MOD_ARMOR
Definition Unit.h:463
@ UNIT_MOD_RESISTANCE_SHADOW
Definition Unit.h:468
@ UNIT_MOD_RESISTANCE_FROST
Definition Unit.h:467
@ UNIT_MOD_ATTACK_POWER
Definition Unit.h:470
@ UNIT_MOD_RESISTANCE_HOLY
Definition Unit.h:464
@ UNIT_MOD_RESISTANCE_ARCANE
Definition Unit.h:469
@ UNIT_MOD_HEALTH
Definition Unit.h:445
@ UNIT_MOD_RESISTANCE_FIRE
Definition Unit.h:465
@ UNIT_MOD_RESISTANCE_NATURE
Definition Unit.h:466
@ UNIT_MOD_MANA
Definition Unit.h:446
@ UNIT_BYTE1_FLAG_HOVER
Definition Unit.h:189
#define MAX_AGGRO_RADIUS
Definition Unit.h:279
DeathState
Definition Unit.h:502
@ ALIVE
Definition Unit.h:503
@ JUST_DIED
Definition Unit.h:504
@ JUST_RESPAWNED
Definition Unit.h:507
@ CORPSE
Definition Unit.h:505
#define CREATURE_MAX_SPELLS
Definition Unit.h:272
@ BASE_VALUE
Definition Unit.h:384
@ SHEATH_STATE_MELEE
Definition Unit.h:246
@ ACT_ENABLED
Definition Unit.h:1148
@ UNIT_STATE_DIED
Definition Unit.h:512
@ UNIT_STATE_ALL_STATE
Definition Unit.h:550
@ UNIT_STATE_FLEEING
Definition Unit.h:519
@ UNIT_STATE_ROTATING
Definition Unit.h:532
@ ANIM_TIER_GROUND
Definition Unit.h:197
@ ANIM_TIER_HOVER
Definition Unit.h:199
@ ANIM_TIER_FLY
Definition Unit.h:200
@ MOVE_FLIGHT
Definition Unit.h:561
@ MOVE_SWIM
Definition Unit.h:558
@ MOVE_RUN
Definition Unit.h:556
@ MOVE_WALK
Definition Unit.h:555
@ REACT_PASSIVE
Definition Unit.h:1156
@ REACT_AGGRESSIVE
Definition Unit.h:1158
@ UNIT_FLAG_NON_ATTACKABLE
Definition Unit.h:626
@ UNIT_FLAG_IN_COMBAT
Definition Unit.h:644
@ UNIT_FLAG_IMMUNE_TO_NPC
Definition Unit.h:634
@ UNIT_FLAG_DISABLE_POWERS
Definition Unit.h:654
@ UNIT_FLAG_PACIFIED
Definition Unit.h:642
@ UNIT_FLAG_NOT_SELECTABLE
Definition Unit.h:650
@ UNIT_FLAG_SILENCED
Definition Unit.h:638
@ UNIT_FLAG_SKINNABLE
Definition Unit.h:651
@ UNIT_FLAG2_FEIGN_DEATH
Definition Unit.h:663
@ UNIT_FIELD_MOD_CASTING_SPEED
@ UNIT_FIELD_FLAGS2
@ UNIT_FIELD_VIRTUAL_ITEM_ID
@ UNIT_FIELD_SHAPESHIFT_FORM
@ UNIT_FIELD_MOD_SPELL_HASTE
@ UNIT_FIELD_MAX_RANGED_DAMAGE
@ UNIT_FIELD_WILD_BATTLE_PET_LEVEL
@ UNIT_FIELD_BOUNDING_RADIUS
@ UNIT_FIELD_NPC_FLAGS
@ UNIT_FIELD_ANIM_TIER
@ UNIT_END
@ UNIT_FIELD_FLAGS
@ UNIT_FIELD_COMBAT_REACH
@ UNIT_FIELD_TARGET
@ UNIT_FIELD_MIN_RANGED_DAMAGE
@ UNIT_FIELD_HOVER_HEIGHT
@ UNIT_FIELD_NPC_EMOTESTATE
@ OBJECT_FIELD_ENTRY_ID
@ OBJECT_FIELD_DYNAMIC_FLAGS
T AddPct(T &base, U pct)
Definition Util.h:109
@ POWER_PYRITE
@ WORLD_DEL_GAME_EVENT_MODEL_EQUIP
@ WORLD_DEL_CREATURE_ADDON
@ WORLD_DEL_GAME_EVENT_CREATURE
@ WORLD_DEL_CREATURE
@ WORLD_INS_CREATURE
void AddAssistant(uint64 guid)
Definition Creature.h:740
std::list< uint64 > m_assistants
Definition Creature.h:745
bool Execute(uint64 e_time, uint32 p_time) OVERRIDE
Definition Creature.cpp:101
void WriteGuidBytes(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:264
void WriteGuidMask(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:248
virtual bool CanRespawn()
Definition CreatureAI.h:83
virtual void JustRespawned()
Definition CreatureAI.h:115
virtual void CorpseRemoved(uint32 &)
== State checks =================================
Definition CreatureAI.h:153
float GetSpellDamageMod(int32 Rank) const
void SetInCombatWithZone()
uint32 m_DBTableGuid
For new or temporary creatures is 0 for saved it is lowguid.
Definition Creature.h:695
void ForcedDespawn(uint32 timeMSToDespawn=0)
VendorItemCounts m_vendorItemCounts
Definition Creature.h:676
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:626
void SetNoSearchAssistance(bool val)
Definition Creature.h:584
Loot loot
Definition Creature.h:544
void SelectLevel(const CreatureTemplate *cinfo)
bool LoadCreaturesAddon(bool reload=false)
bool UpdateAllStats() OVERRIDE
bool IsTrigger() const
Definition Creature.h:454
void Respawn(bool force=false)
uint32 m_lootRecipientGroup
Definition Creature.h:681
void ResetLootMode()
Definition Creature.h:560
void RegenerateHealth()
Definition Creature.cpp:630
VendorItemData const * GetVendorItems() const
bool IsDungeonBoss() const
SpellSchoolMask m_meleeDamageSchoolMask
Definition Creature.h:704
bool m_AI_locked
Definition Creature.h:702
bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const OVERRIDE
bool isWorldBoss() const
int8 m_originalEquipmentId
Definition Creature.h:697
void CallForHelp(float fRadius)
float GetAttackDistance(Unit const *player) const
uint32 GetDBTableGUIDLow() const
Definition Creature.h:445
Player * SelectNearestPlayer(float distance=0) const
bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData *data=NULL)
Definition Creature.cpp:356
bool IsCivilian() const
Definition Creature.h:453
virtual void DeleteFromDB()
void SetRespawnTime(uint32 respawn)
Definition Creature.h:598
bool lootForPickPocketed
Definition Creature.h:545
float m_respawnradius
Definition Creature.h:688
CreatureTemplate const * m_creatureInfo
Definition Creature.h:712
void LoadEquipment(int8 id=1, bool force=false)
bool HasReactState(ReactStates state) const
Definition Creature.h:462
void SendZoneUnderAttackMessage(Player *attacker)
Send a message to LocalDefense channel for players opposition team in the zone.
void AllLootRemovedFromCorpse()
float GetAggroRange(Unit const *target) const
void SetDisplayId(uint32 modelId) OVERRIDE
MovementGeneratorType m_defaultMovementType
Definition Creature.h:694
void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time)
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
SpellInfo const * reachWithSpellCure(Unit *victim)
void SetReactState(ReactStates st)
Definition Creature.h:460
bool CanFly() const OVERRIDE
Definition Creature.h:458
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition Creature.h:566
void ResetPlayerDamageReq()
Definition Creature.h:652
float m_SightDistance
Definition Creature.h:660
bool hasLootRecipient() const
Definition Creature.h:549
void AddCreatureSpellCooldown(uint32 spellid)
void Update(uint32 time) OVERRIDE
Definition Creature.cpp:446
uint8 getLevelForTarget(WorldObject const *target) const OVERRIDE
void ReleaseFocus(Spell const *focusSpell)
bool isRegeneratingHealth() const
Definition Creature.h:618
CreatureSpellCooldowns m_CreatureCategoryCooldowns
Definition Creature.h:567
uint32 m_respawnDelay
Definition Creature.h:686
void SetTarget(uint64 guid) OVERRIDE
void RegenerateMana()
Definition Creature.cpp:598
void SetPosition(float x, float y, float z, float o)
bool CanAssistTo(const Unit *u, const Unit *enemy, bool checkfaction=true) const
time_t m_corpseRemoveTime
Timers.
Definition Creature.h:684
void SetLootRecipient(Unit *unit)
Definition Creature.cpp:893
bool lootForBody
Definition Creature.h:546
time_t m_respawnTime
Definition Creature.h:685
void DoFleeToGetAssistance()
Definition Creature.cpp:667
void RemoveCorpse(bool setSpawnTime=true)
Definition Creature.cpp:230
void FarTeleportTo(Map *map, float X, float Y, float Z, float O)
uint32 GetScriptId() const
bool hasInvolvedQuest(uint32 quest_id) const OVERRIDE
CreatureData const * m_creatureData
Definition Creature.h:713
float m_CombatDistance
Definition Creature.h:660
bool isCanInteractWithBattleMaster(Player *player, bool msg) const
Definition Creature.cpp:837
SpellInfo const * reachWithSpellAttack(Unit *victim)
Position m_homePosition
Definition Creature.h:707
Player * GetLootRecipient() const
Definition Creature.cpp:879
static float _GetHealthMod(int32 Rank)
uint32 m_PlayerDamageReq
Definition Creature.h:653
bool TriggerJustRespawned
Definition Creature.h:729
bool m_AlreadyCallAssistance
Definition Creature.h:699
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:524
bool CanCreatureAttack(Unit const *victim, bool force=true) const
bool DisableReputationGain
Definition Creature.h:710
void FocusTarget(Spell const *focusSpell, WorldObject const *target)
CreatureGroup * m_formation
Definition Creature.h:728
MovementGeneratorType GetDefaultMovementType() const
Definition Creature.h:589
void InitializeReactState()
Definition Creature.cpp:827
bool HasSearchedAssistance() const
Definition Creature.h:585
uint32 m_corpseDelay
Definition Creature.h:687
void GetRespawnPosition(float &x, float &y, float &z, float *ori=NULL, float *dist=NULL) const
bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, uint32 team, const CreatureData *data=NULL)
std::string GetAIName() const
void Motion_Initialize()
Definition Creature.cpp:725
virtual ~Creature()
Definition Creature.cpp:168
void SetObjectScale(float scale) OVERRIDE
uint32 UpdateVendorItemCurrentCount(VendorItem const *vItem, uint32 used_count)
uint8 m_equipmentId
Definition Creature.h:696
bool isTappedBy(Player const *player) const
Definition Creature.cpp:922
Creature(bool isWorldObject=false)
Definition Creature.cpp:141
bool m_AlreadySearchedAssistance
Definition Creature.h:700
void UpdateMovementFlags()
bool HasSpell(uint32 spellID) const OVERRIDE
TrainerSpellData const * GetTrainerSpells() const
uint32 m_originalEntry
Definition Creature.h:705
void SetFlying(bool enable)
bool IsImmunedToSpell(SpellInfo const *spellInfo) const OVERRIDE
bool AIM_Initialize(CreatureAI *ai=NULL)
Definition Creature.cpp:702
Unit * SelectNearestHostileUnitInAggroRange(bool useLOS=false) const
void SearchFormation()
Definition Creature.cpp:216
bool _IsTargetAcceptable(const Unit *target) const
uint64 m_lootRecipient
Definition Creature.h:680
uint32 GetVendorItemCurrentCount(VendorItem const *vItem)
bool m_isTempWorldObject
Definition Creature.h:664
ReactStates m_reactState
Definition Creature.h:690
bool hasQuest(uint32 quest_id) const OVERRIDE
bool isCanTrainingAndResetTalentsOf(Player *player) const
Definition Creature.cpp:872
Group * GetLootRecipientGroup() const
Definition Creature.cpp:886
bool HasCategoryCooldown(uint32 spell_id) const
Spell const * _focusSpell
Definition Creature.h:731
uint32 m_spells[CREATURE_MAX_SPELLS]
Definition Creature.h:565
void AddToWorld() OVERRIDE
Definition Creature.cpp:177
std::string GetScriptName() const
bool Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehId, uint32 team, float x, float y, float z, float ang, const CreatureData *data=NULL)
Definition Creature.cpp:740
uint8 GetCurrentEquipmentId() const
Definition Creature.h:513
virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) OVERRIDE
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
void SetMeleeDamageSchool(SpellSchools school)
Definition Creature.h:486
void SaveToDB()
Definition Creature.cpp:934
Unit * SelectNearestTargetInAttackDistance(float dist=0) const
bool LoadCreatureFromDB(uint32 guid, Map *map, bool addToMap=true)
uint32 lootingGroupLowGUID
Definition Creature.h:609
bool HasSpellCooldown(uint32 spell_id) const
void SendAIReaction(AiReaction reactionType)
static float _GetDamageMod(int32 Rank)
void SetNoCallAssistance(bool val)
Definition Creature.h:583
void setDeathState(DeathState s) OVERRIDE
bool m_regenHealth
Definition Creature.h:701
void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
bool CanAlwaysSee(WorldObject const *obj) const OVERRIDE
void Regenerate(Powers power)
Definition Pet.cpp:658
time_t GetRespawnTimeEx() const
CreatureAddon const * GetCreatureAddon() const
uint32 m_path_id
Definition Creature.h:725
void CallAssistance()
std::string const & GetNameForLocaleIdx(LocaleConstant locale_idx) const OVERRIDE
bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData *data=NULL)
Definition Creature.cpp:257
bool IsInEvadeMode() const
Definition Creature.h:478
bool IsGuard() const
Definition Creature.h:455
void SaveRespawnTime() OVERRIDE
CreatureAI * AI() const
Definition Creature.h:483
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
uint32 m_groupLootTimer
Definition Creature.h:608
bool isElite() const
bool IsInvisibleDueToDespawn() const OVERRIDE
bool CanStartAttack(Unit const *u, bool force) const
void LowerPlayerDamageReq(uint32 unDamage)
void SetOriginalEntry(uint32 entry)
Definition Creature.h:656
void DisappearAndDie()
Definition Creature.cpp:206
void RemoveFromWorld() OVERRIDE
Definition Creature.cpp:193
uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const
bool Execute(uint64 e_time, uint32 p_time) OVERRIDE
Definition Creature.cpp:135
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:643
Definition Group.h:147
void EndRoll(Loot *loot)
Definition Group.cpp:1378
bool isEmpty() const
Definition LinkedList.h:86
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
Definition Map.cpp:909
bool AddToMap(T *)
Definition Map.cpp:504
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.cpp:1959
MapRefManager PlayerList
Definition Map.h:406
time_t GetCreatureRespawnTime(uint32 dbGuid) const
Definition Map.h:456
void SaveCreatureRespawnTime(uint32 dbGuid, time_t respawnTime)
Definition Map.cpp:3212
Creature * GetCreature(uint64 guid)
Definition Map.cpp:3179
void RemoveFromMap(T *, bool)
Definition Map.cpp:826
uint32 GetInstanceId() const
Definition Map.h:357
uint32 GetId(void) const
Definition Map.h:300
PlayerList const & GetPlayers() const
Definition Map.h:407
time_t GetLinkedRespawnTime(uint64 guid) const
Definition Map.cpp:3326
void RemoveCreatureRespawnTime(uint32 dbGuid)
Definition Map.cpp:3231
bool IsInstance() const
Definition Map.h:368
MapObject()
Definition Object.h:593
friend class Map
Definition Object.h:589
iterator end()
iterator begin()
LinkedListHead::Iterator< MapReference const > const_iterator
MovementGeneratorType GetCurrentMovementGeneratorType() const
void MoveSeekAssistance(float x, float y, float z)
static Unit * GetUnit(WorldObject const &, uint64 guid)
static Player * FindPlayer(uint64)
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition Object.cpp:343
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition Object.cpp:1158
float GetObjectScale() const
Definition Object.h:128
uint64 GetGUID() const
Definition Object.h:119
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:325
bool IsInWorld() const
Definition Object.h:114
uint32 GetGUIDLow() const
Definition Object.h:120
TypeID GetTypeId() const
Definition Object.h:131
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition Object.cpp:129
uint16 m_valuesCount
Definition Object.h:256
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:1261
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:1280
float GetFloatValue(uint16 index) const
Definition Object.cpp:337
uint32 GetEntry() const
Definition Object.h:125
Creature * ToCreature()
Definition Object.h:207
void SetFloatValue(uint16 index, float value)
Definition Object.cpp:1141
bool HasFlag(uint16 index, uint32 flag) const
Definition Object.cpp:1309
void SetEntry(uint32 entry)
Definition Object.h:126
virtual void SetObjectScale(float scale)
Definition Object.h:129
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:1038
void SetUInt64Value(uint16 index, uint64 value)
Definition Object.cpp:1079
Unit * ToUnit()
Definition Object.h:210
static uint32 ChooseDisplayId(CreatureTemplate const *cinfo, CreatureData const *data=NULL)
static void ChooseCreatureFlags(CreatureTemplate const *cinfo, uint32 &npcflag, uint32 &unit_flags, uint32 &dynamicflags, CreatureData const *data=NULL)
uint32 GetTeam() const
Definition Player.h:2527
Group * GetGroup()
Definition Player.h:2972
bool IsGameMaster() const
Definition Player.h:1369
PlayerMenu * PlayerTalkClass
Definition Player.h:2680
bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const
Definition Player.cpp:19319
void SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
void ClearMenus()
void setFloat(const uint8 index, const float value)
void setUInt16(const uint8 index, const uint16 value)
void setUInt32(const uint8 index, const uint32 value)
void setUInt8(const uint8 index, const uint8 value)
void setInt32(const uint8 index, const int32 value)
Mechanics Mechanic
Definition SpellInfo.h:101
bool IsEffect() const
Definition SpellInfo.cpp:59
Definition Spell.h:289
SpellInfo const * GetSpellInfo() const
Definition Spell.h:565
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition SpellInfo.h:255
uint32 PreventionType
Definition SpellInfo.h:229
uint32 GetCategory() const
bool IsCooldownStartedOnEvent() const
uint32 Mechanic
Definition SpellInfo.h:163
uint32 GetRecoveryTime() const
float GetMinRange(bool positive=false) const
uint32 CategoryRecoveryTime
Definition SpellInfo.h:195
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
SpellSchoolMask GetSchoolMask() const
uint32 AttributesEx5
Definition SpellInfo.h:169
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:16
Definition Unit.h:1367
int32 ModifyHealth(int32 val)
Definition Unit.cpp:4023
void ClearUnitState(uint32 f)
Definition Unit.h:1489
bool IsVehicle() const
Definition Unit.h:1523
uint64 LastCharmerGUID
Definition Unit.h:2736
bool IsCharmed() const
Definition Unit.h:2136
void SetVisible(bool x)
Definition Unit.cpp:4163
bool IsBattleMaster() const
Definition Unit.h:1849
bool isTargetableForAttack(bool checkFakeDeath=true) const
Definition Unit.cpp:3795
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:2243
void setFaction(uint32 faction)
Definition Unit.h:1699
Player * m_movedPlayer
Definition Unit.h:2156
bool CanHaveThreatList() const
Definition Unit.cpp:4424
bool IsValidAttackTarget(Unit const *target) const
Definition Unit.cpp:3810
bool SetFall(bool enable)
Definition Unit.cpp:9185
void UpdateObjectVisibility(bool forced=true) override
Definition Unit.cpp:7567
uint32 getFaction() const
Definition Unit.h:1695
void SetFullHealth()
Definition Unit.h:1644
void SetAnimTier(AnimTier tier)
Definition Unit.cpp:5917
void AddToWorld() override
Definition Unit.cpp:5400
bool SetPhased(uint32 id, bool update, bool apply) OVERRIDE
Definition Unit.cpp:7516
bool NeedChangeAI
Definition Unit.h:2735
void SetControlled(bool apply, UnitState state)
Definition Unit.cpp:6669
uint32 m_regenTimer
Definition Unit.h:2928
void SetCreateHealth(uint32 val)
Definition Unit.h:2317
void SetPower(Powers power, int32 val)
Definition Unit.cpp:5255
Player * GetSpellModOwner() const
Definition Unit.cpp:5818
Vehicle * m_vehicle
Definition Unit.h:2932
void SetRace(uint8 race)
Definition Unit.h:1560
uint64 GetCharmerOrOwnerGUID() const
Definition Unit.cpp:5806
bool IsPolymorphed() const
Definition Unit.cpp:5928
void SetPvP(bool state)
Definition Unit.cpp:7317
void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value)
Definition Unit.h:2428
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition Unit.cpp:4463
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Unit.cpp:2355
float GetPositionZMinusOffset() const
Definition Unit.cpp:6660
Unit * getAttackerForHelper() const
UnitAI * i_AI
Definition Unit.h:2867
CharmInfo * m_charmInfo
Definition Unit.h:2918
MotionMaster * GetMotionMaster()
Definition Unit.h:2605
bool IsPet() const
Definition Unit.h:1511
uint8 getLevelForTarget(WorldObject const *) const override
Definition Unit.h:1532
uint32 GetMaxHealth() const
Definition Unit.h:1604
Aura * AddAura(uint32 spellId, Unit *target)
bool IsLevitating() const
Definition Unit.h:2003
void CombatStart(Unit *target, bool initialAggro=true)
uint8 getClass() const
Definition Unit.h:1543
bool IsAlive() const
Definition Unit.h:2032
bool IsOnVehicle(const Unit *vehicle) const
Definition Unit.cpp:7198
DeathState m_deathState
Definition Unit.h:2883
void SetClass(uint8 newClass)
Definition Unit.h:1564
int32 GetMaxPower(Powers power) const
Definition Unit.cpp:5246
void SetHealth(uint32 val)
Definition Unit.cpp:5162
TempSummon * ToTempSummon()
Definition Unit.h:2821
int32 ModifyPower(Powers power, int32 val)
Definition Unit.cpp:4081
bool IsNeutralToAll() const
Definition Unit.cpp:2301
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
void AddUnitState(uint32 f)
Definition Unit.h:1481
void Mount(uint32 mount, uint32 vehicleId=0, uint32 creatureEntry=0)
Definition Unit.cpp:3635
void SetCreateMana(uint32 val)
Definition Unit.h:2325
bool isInAccessiblePlaceFor(Creature const *c) const
Definition Unit.cpp:1473
virtual void SetSheath(SheathState sheathed)
Definition Unit.h:1689
Unit * GetCharmerOrOwner() const
Definition Unit.cpp:2419
MotionMaster i_motionMaster
Definition Unit.h:2925
uint32 GetCreatureType() const
Definition Unit.cpp:4910
bool SetSwim(bool enable)
Definition Unit.cpp:9201
virtual bool IsImmunedToSpell(SpellInfo const *spellInfo) const
Definition Unit.cpp:3456
uint32 GetDisplayId() const
Definition Unit.h:2490
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition Unit.cpp:4905
uint32 GetNativeDisplayId() const
Definition Unit.h:2495
void UpdateCharmAI()
Definition Unit.cpp:5491
EventProcessor m_Events
Definition Unit.h:2396
void AddUnitMovementFlag(uint32 f)
Definition Unit.h:2620
bool SetCanFly(bool enable)
Definition Unit.cpp:9219
bool HasUnitMovementFlag(uint32 f) const
Definition Unit.h:2628
bool IsSummon() const
Definition Unit.h:1503
virtual bool IsInWater() const
Definition Unit.cpp:1481
uint32 GetHealth() const
Definition Unit.h:1600
void SetGender(uint8 gender)
Definition Unit.h:1568
bool HasAuraType(AuraType auraType) const
static Unit * GetUnit(WorldObject &object, uint64 guid)
Definition Unit.cpp:4895
void SetNativeDisplayId(uint32 modelId)
Definition Unit.h:2500
virtual void SetDisplayId(uint32 modelId)
Definition Unit.cpp:5941
void CleanupBeforeRemoveFromMap(bool finalCleanup)
Definition Unit.cpp:5453
Unit * GetVictim() const
Definition Unit.h:1468
int32 GetPower(Powers power) const
Definition Unit.cpp:5237
Vehicle * m_vehicleKit
Definition Unit.h:2933
DeathState getDeathState() const
Definition Unit.h:2044
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition Unit.cpp:4318
bool IsAIEnabled
Definition Unit.h:2735
bool CreateVehicleKit(uint32 id, uint32 creatureEntry, bool loading=false)
Definition Unit.cpp:7163
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const
Definition Unit.cpp:3520
bool HasUnitState(const uint32 f) const
Definition Unit.h:1485
void SetModifierValue(UnitMods unitMod, UnitModifierType modifierType, float value)
Definition Unit.h:2400
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition Unit.cpp:3580
Unit(bool isWorldObject)
Definition Unit.cpp:142
void SetCanModifyStats(bool modifyStats)
Definition Unit.h:2414
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:2283
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
void RemoveFromWorld() override
Definition Unit.cpp:5409
UnitAI * GetAI()
Definition Unit.h:1393
float GetStat(Stats stat) const
Definition Unit.h:1573
void UpdateSpeed(UnitMoveType mtype, bool forced)
Definition Unit.cpp:4173
void RemoveAllAuras()
void SetMaxPower(Powers power, int32 val)
Definition Unit.cpp:5317
bool SetDisableGravity(bool disable, bool packetOnly=false)
Definition Unit.cpp:9156
Powers getPowerType() const
Definition Unit.h:1651
virtual void setDeathState(DeathState s)
Definition Unit.cpp:4365
void SetMaxHealth(uint32 val)
Definition Unit.cpp:5206
int32 GetTotalAuraModifier(AuraType auratype) const
bool IsFlying() const
Definition Unit.h:2780
uint8 getLevel() const
Definition Unit.h:1528
std::list< AuraEffect * > AuraEffectList
Definition Unit.h:1383
void SetAttackTime(WeaponAttackType att, uint32 val)
Definition Unit.h:1678
bool IsSpiritHealer() const
Definition Unit.h:1861
void SetLevel(uint8 lvl)
Definition Unit.cpp:5150
bool IsTotem() const
Definition Unit.h:1519
void SetInFront(WorldObject const *target)
Definition Unit.cpp:9108
void setPowerType(Powers power)
Definition Unit.cpp:2079
Vehicle * GetVehicleKit() const
Definition Unit.h:2739
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:2278
bool IsSpiritService() const
Definition Unit.h:1882
bool IsFalling() const
Definition Unit.cpp:8388
void Update(uint32 time) OVERRIDE
Definition Unit.cpp:293
void SetInCombatWith(Unit *enemy)
bool IsInCombat() const
Definition Unit.h:1896
bool IsSpiritGuide() const
Definition Unit.h:1865
void Reset(bool evading=false)
Reapplies immunities and reinstalls accessories. Only has effect for creatures.
Definition Vehicle.cpp:162
void Install()
Initializes power type for vehicle. Nothing more.
Definition Vehicle.cpp:64
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
Definition Vehicle.cpp:536
uint32 GetMapId() const
Definition Object.h:546
uint32 GetPhaseMask() const
Definition Object.h:643
Map * GetMap() const
Definition Object.h:740
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition Object.cpp:1735
bool IsWithinLOSInMap(WorldObject const *obj) const
Definition Object.cpp:1656
virtual bool IsInvisibleDueToDespawn() const
Definition Object.h:831
float GetTransOffsetX() const
Definition Object.h:798
uint32 LastUsedScriptID
Definition Object.h:794
void SetName(std::string const &newname)
Definition Object.h:665
void SetZoneScript()
Definition Object.cpp:2687
void setActive(bool isActiveObject)
Definition Object.cpp:1542
ZoneScript * m_zoneScript
Definition Object.h:818
float GetTransOffsetY() const
Definition Object.h:799
std::string const & GetName() const
Definition Object.h:664
virtual void SetMap(Map *map)
Definition Object.cpp:2514
float GetTransOffsetZ() const
Definition Object.h:800
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition Object.h:782
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition Object.h:783
WorldObject(bool isWorldObject)
Definition Object.cpp:1514
void DestroyForNearbyPlayers()
Definition Object.cpp:3453
Transport * GetTransport() const
Definition Object.h:797
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition Object.h:733
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1666
uint32 GetAreaId() const
Definition Object.cpp:1602
float GetTransOffsetO() const
Definition Object.h:801
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition Object.cpp:1730
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition Object.h:732
float GetDistanceZ(WorldObject const *obj) const
Definition Object.cpp:1618
bool IsInMap(WorldObject const *obj) const
Definition Object.cpp:1703
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition Main.cpp:40
@ SMSG_ZONE_UNDER_ATTACK
Definition Opcodes.h:1070
@ SMSG_AI_REACTION
Definition Opcodes.h:512
#define sWorld
Definition World.h:910
@ CONFIG_CORPSE_DECAY_NORMAL
Definition World.h:284
@ CONFIG_CORPSE_DECAY_RARE
Definition World.h:285
@ CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY
Definition World.h:270
@ CONFIG_CORPSE_DECAY_ELITE
Definition World.h:286
@ CONFIG_WORLD_BOSS_LEVEL_DIFF
Definition World.h:272
@ CONFIG_CORPSE_DECAY_RAREELITE
Definition World.h:287
@ CONFIG_MAX_PLAYER_LEVEL
Definition World.h:224
@ CONFIG_CORPSE_DECAY_WORLDBOSS
Definition World.h:288
@ CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY
Definition World.h:111
@ RATE_CREATURE_ELITE_RARE_SPELLDAMAGE
Definition World.h:421
@ RATE_CREATURE_ELITE_WORLDBOSS_HP
Definition World.h:410
@ RATE_POWER_MANA
Definition World.h:377
@ RATE_CREATURE_ELITE_RAREELITE_DAMAGE
Definition World.h:414
@ RATE_CREATURE_ELITE_RAREELITE_HP
Definition World.h:409
@ RATE_CREATURE_NORMAL_SPELLDAMAGE
Definition World.h:417
@ RATE_CREATURE_ELITE_ELITE_HP
Definition World.h:408
@ RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE
Definition World.h:420
@ RATE_CREATURE_NORMAL_DAMAGE
Definition World.h:412
@ RATE_CREATURE_AGGRO
Definition World.h:422
@ RATE_CREATURE_NORMAL_HP
Definition World.h:407
@ RATE_CREATURE_ELITE_RARE_HP
Definition World.h:411
@ RATE_CORPSE_DECAY_LOOTED
Definition World.h:431
@ RATE_CREATURE_ELITE_ELITE_DAMAGE
Definition World.h:413
@ RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE
Definition World.h:419
@ RATE_HEALTH
Definition World.h:376
@ RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE
Definition World.h:415
@ RATE_CREATURE_ELITE_RARE_DAMAGE
Definition World.h:416
@ RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE
Definition World.h:418
@ CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS
Definition World.h:187
@ CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS
Definition World.h:186
CreatureAI * selectAI(Creature *creature)
bool IsValidMapCoord(float c)
CellCoord ComputeCellCoord(float x, float y)
Definition Cell.h:37
void SetNoCreate()
Definition Cell.h:66
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
Definition CellImpl.h:109
std::vector< uint32 > auras
Definition Creature.h:330
uint32 mount
Definition Creature.h:326
uint32 emote
Definition Creature.h:329
uint32 path_id
Definition Creature.h:325
uint32 bytes1
Definition Creature.h:327
uint32 bytes2
Definition Creature.h:328
uint32 BaseHealth[MAX_CREATURE_BASE_HP]
Definition Creature.h:199
static CreatureBaseStats const * GetBaseStats(uint8 level, uint8 unitClass)
Definition Creature.cpp:130
uint32 GenerateMana(CreatureTemplate const *info) const
Definition Creature.h:207
uint32 GenerateHealth(CreatureTemplate const *info) const
Definition Creature.cpp:122
uint32 GenerateArmor(CreatureTemplate const *info) const
Definition Creature.h:216
uint32 spawntimesecs
Definition Creature.h:270
uint32 dynamicflags
Definition Creature.h:279
uint32 phaseid
Definition Creature.h:262
uint32 id
Definition Creature.h:260
uint32 npcflag
Definition Creature.h:277
uint32 displayid
Definition Creature.h:264
uint8 movementType
Definition Creature.h:275
uint32 phaseGroup
Definition Creature.h:263
uint32 unit_flags
Definition Creature.h:278
uint32 spawnMask
Definition Creature.h:276
float spawndist
Definition Creature.h:271
uint32 curhealth
Definition Creature.h:273
float orientation
Definition Creature.h:269
uint32 curmana
Definition Creature.h:274
int8 equipmentId
Definition Creature.h:265
uint32 currentwaypoint
Definition Creature.h:272
uint16 mapid
Definition Creature.h:261
StringVector Name
Definition Creature.h:228
uint32 unit_flags
Definition Creature.h:94
uint32 trainer_class
Definition Creature.h:99
uint32 Modelid4
Definition Creature.h:70
uint32 Modelid1
Definition Creature.h:67
uint32 SkinLootId
Definition Creature.h:109
uint32 GetFirstValidModelId() const
Definition Creature.cpp:92
uint32 Modelid2
Definition Creature.h:68
std::string Name
Definition Creature.h:71
int32 resistance[MAX_SPELL_SCHOOL]
Definition Creature.h:110
uint32 DifficultyEntry[4 - 1]
Definition Creature.h:65
uint32 faction_A
Definition Creature.h:79
uint32 InhabitType
Definition Creature.h:118
uint32 MovementType
Definition Creature.h:117
uint32 flags_extra
Definition Creature.h:129
uint32 type_flags
Definition Creature.h:105
uint32 attackpower
Definition Creature.h:89
uint32 unit_flags2
Definition Creature.h:95
uint32 dmgschool
Definition Creature.h:88
uint32 rangeattacktime
Definition Creature.h:92
uint32 expansion
Definition Creature.h:77
uint32 trainer_type
Definition Creature.h:98
static int32 DiffToDiffIndex(uint32 difficulty)
Definition Creature.h:162
uint32 spells[CREATURE_MAX_SPELLS]
Definition Creature.h:111
uint32 unit_class
Definition Creature.h:93
uint32 baseattacktime
Definition Creature.h:91
uint32 faction_H
Definition Creature.h:80
uint32 Modelid3
Definition Creature.h:69
uint32 GetRandomValidModelId() const
Definition Creature.cpp:79
uint32 dynamicflags
Definition Creature.h:96
uint32 DownscaleID
uint32 DiffID
uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]
Definition Creature.h:245
struct GameObjectTemplate::@046065176235271051340241126110345143267101032070::@316212233253022127367165230227137227160036113140 moTransport
float GetPositionZ() const
Definition Object.h:330
float GetOrientation() const
Definition Object.h:331
bool IsInDist(float x, float y, float z, float dist) const
Definition Object.h:414
bool IsPositionValid() const
Definition Object.cpp:2049
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329
void Relocate(float x, float y)
Definition Object.h:302
TrainerSpellMap spellList
Definition Creature.h:413
TrainerSpell const * Find(uint32 spell_id) const
Definition Creature.cpp:46
time_t lastIncrementTime
Definition Creature.h:386
VendorItem const * FindItemCostPair(uint32 item_id, uint32 extendedCost, uint8 type) const
Definition Creature.cpp:71
VendorItemList m_items
Definition Creature.h:354
bool RemoveItem(uint32 item_id, uint8 type)
Definition Creature.cpp:55
uint32 item
Definition Creature.h:341
uint32 maxcount
Definition Creature.h:342
uint32 incrtime
Definition Creature.h:343