OregonCore  revision be9e804-git
Your Favourite TBC server
Creature.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef OREGONCORE_CREATURE_H
19 #define OREGONCORE_CREATURE_H
20 
21 #include "Common.h"
22 #include "Unit.h"
23 #include "UpdateMask.h"
24 #include "ItemPrototype.h"
25 #include "LootMgr.h"
26 #include "Database/DatabaseEnv.h"
27 #include "Cell.h"
28 #include "CreatureGroups.h"
29 
30 #include <list>
31 
32 struct SpellEntry;
33 
34 class CreatureAI;
35 class Quest;
36 class Player;
37 class WorldSession;
38 class CreatureGroup;
39 
41 {
53 };
54 
56 {
68 };
69 
71 {
84 };
85 
87 {
94  bool Coded;
95  std::string OptionText;
96  std::string BoxText;
97 };
98 
100 {
101  CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group
102  CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility)
103  CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry
104  CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry
105  CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block
106  CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks
107  CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
108  CREATURE_FLAG_EXTRA_TRIGGER = 0x00000080, // trigger creature
109  CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00000100, // cannot be taunted
110  CREATURE_FLAG_EXTRA_GUARD = 0x00000400, // creature is a guard
111  CREATURE_FLAG_EXTRA_WORLDEVENT = 0x00004000, // custom flag for world event creatures (left room for merging)
112  CREATURE_FLAG_EXTRA_CHARM_AI = 0x00008000, // use ai when charmed
113  CREATURE_FLAG_EXTRA_NO_CRIT = 0x00020000, // creature can't do critical strikes
114  CREATURE_FLAG_EXTRA_NO_SKILLGAIN = 0x00040000, // creature won't increase weapon skills
115  CREATURE_FLAG_EXTRA_NO_DYNAMIC_MOVEMENT_FLAG = 0x00080000, // Ignore dynamic movement flag (for specific movement or wrong vmaps)
116 };
117 
118 // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
119 #if defined(__GNUC__)
120 #pragma pack(1)
121 #else
122 #pragma pack(push,1)
123 #endif
124 
125 #define CREATURE_REGEN_INTERVAL 2 * IN_MILLISECONDS
126 
127 #define MAX_KILL_CREDIT 2
128 // from `creature_template` table
130 {
133  uint32 KillCredit[MAX_KILL_CREDIT];
138  char* Name;
139  char* SubName;
140  char* IconName;
152  float speed_walk;
153  float speed_run;
154  float scale;
161  uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures.
162  uint32 unit_flags; // enum UnitFlags mask values
164  CreatureFamily family; // enum CreatureFamily values for type == CREATURE_TYPE_BEAST, or 0 in another cases
169  uint32 type; // enum CreatureType values
170  uint32 type_flags; // enum CreatureTypeFlags mask values
184  char const* AIName;
187  float ModHealth;
188  float ModMana;
189  float ModArmor;
190  float ModDamage;
197  uint32 GetRandomValidModelId() const;
198  uint32 GetFirstValidModelId() const;
199 
200  // helpers
202  {
204  return SKILL_HERBALISM;
205  else if (type_flags & CREATURE_TYPE_FLAG_MINING_SKINNING_SKILL)
206  return SKILL_MINING;
207  else if (type_flags & CREATURE_TYPE_FLAG_ENGINEERING_SKINNING_SKILL)
208  return SKILL_ENGINEERING;
209  else
210  return SKILL_SKINNING; // normal case
211  }
212 
213  bool isTameable() const
214  {
215  if (type != CREATURE_TYPE_BEAST || family == CREATURE_FAMILY_NONE || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_PET) == 0)
216  return false;
217 
218  return true;
219  }
220 
221  std::string GetAIName() const
222  {
223  return AIName;
224  }
225 };
226 
227 // Bases values for given Level and UnitClass
229 {
232  float BaseDamage;
236 };
237 
239 {
240  std::vector<std::string> Name;
241  std::vector<std::string> SubName;
242 };
243 
245 {
246  std::vector<std::string> OptionText;
247  std::vector<std::string> BoxText;
248 };
249 
251 {
253 };
254 
256 {
258  uint32 equipentry[3];
259 };
260 
261 // depricated old way
263 {
265  uint32 equipmodel[3];
266  uint32 equipinfo[3];
267  uint32 equipslot[3];
268 };
269 
270 // from `creature` table
272 {
273  explicit CreatureData() : dbData(true) {}
274  uint32 id; // entry in creature_template
279  float posX;
280  float posY;
281  float posZ;
282  float orientation;
284  float spawndist;
291  uint32 unit_flags; // enum UnitFlags mask values
293  bool dbData;
294 };
295 
297 {
300 };
301 
302 // from `creature_addon` table
304 {
312  CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
313 };
314 
316 {
320  float SpeedWalk;
321  float SpeedRun;
324 };
325 
327 {
332 };
333 
334 // Enums used by StringTextData::Type (CreatureEventAI)
336 {
344 };
345 
346 // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
347 #if defined(__GNUC__)
348 #pragma pack()
349 #else
350 #pragma pack(pop)
351 #endif
352 
353 // Vendors
355 {
356  VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
357  : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
358 
360  uint32 maxcount; // 0 for infinity item amount
361  uint32 incrtime; // time for restore items amount if maxcount != 0
363 };
364 typedef std::vector<VendorItem*> VendorItemList;
365 
367 {
369 
370  VendorItem* GetItem(uint32 slot) const
371  {
372  if (slot >= m_items.size()) return NULL;
373  return m_items[slot];
374  }
375  bool Empty() const
376  {
377  return m_items.empty();
378  }
380  {
381  return m_items.size();
382  }
383  void AddItem(uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
384  {
385  m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
386  }
387  bool RemoveItem(uint32 item_id);
388  VendorItem const* FindItem(uint32 item_id) const;
389  size_t FindItemSlot(uint32 item_id) const;
390 
391  void Clear()
392  {
393  for (VendorItemList::iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
394  delete (*itr);
395  m_items.clear();
396  }
397 };
398 
400 {
401  explicit VendorItemCount(uint32 _item, uint32 _count)
402  : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
403 
407 };
408 
409 typedef std::list<VendorItemCount> VendorItemCounts;
410 
412 {
418 };
419 
420 typedef std::vector<TrainerSpell*> TrainerSpellList;
421 
423 {
424  TrainerSpellData() : trainerType(0) {}
425 
427  uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
428  // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
429 
430  void Clear();
431  TrainerSpell const* Find(uint32 spell_id) const;
432 };
433 
435 {
439 };
440 
441 #define MAX_VIRTUAL_ITEM_SLOT 3
442 
444 {
449 
452 };
453 
454 typedef std::list<GossipOption> GossipOptionList;
455 
456 typedef std::map<uint32, time_t> CreatureSpellCooldowns;
457 
458 // max different by z coordinate for creature aggro reaction
459 #define CREATURE_Z_ATTACK_RANGE 3
460 
461 #define MAX_VENDOR_ITEMS 255 // Limitation in item count field size in SMSG_LIST_INVENTORY
462 
463 //used for handling non-repeatable random texts
464 typedef std::vector<uint8> CreatureTextRepeatIds;
465 typedef UNORDERED_MAP<uint8, CreatureTextRepeatIds> CreatureTextRepeatGroup;
466 
467 class Creature : public Unit, public GridObject<Creature>
468 {
469  public:
470 
471  explicit Creature(bool isWorldObject = false);
472  ~Creature() override;
473 
474  void AddToWorld() override;
475  void RemoveFromWorld() override;
476 
477  void DisappearAndDie();
478 
479  bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 team, float x, float y, float z, float ang, const CreatureData* data = NULL);
480  bool LoadCreaturesAddon(bool reload = false);
481  void SelectLevel();
482  void LoadEquipment(uint32 equip_entry, bool force = false);
483 
484  uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
485  char const* GetSubName() const { return GetCreatureTemplate()->SubName; }
486 
487  void Update(uint32 time) override; // overwrited Unit::Update
488  void GetRespawnPosition(float& x, float& y, float& z, float* ori = NULL, float* dist = NULL) const;
489 
490  uint32 GetEquipmentId() const { return m_equipmentId; }
491  void SetVirtualItem(VirtualItemSlot slot, uint32 item_id);
492  void SetVirtualItemRaw(VirtualItemSlot slot, uint32 display_id, uint32 info0, uint32 info1);
493 
494  void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
495  bool IsRacialLeader() const { return GetCreatureTemplate()->RacialLeader; }
496  bool IsCivilian() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN) != 0; }
497  bool IsTrigger() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) != 0; }
498  bool IsGuard() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD) != 0; }
499  bool CanWalk() const { return (GetCreatureTemplate()->InhabitType & INHABIT_GROUND) != 0; }
500  bool CanSwim() const { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) != 0 || IsPet(); }
501  bool CanFly() const { return (GetCreatureTemplate()->InhabitType & INHABIT_AIR) != 0 || HasAuraType(SPELL_AURA_FLY); }
502 
503  void SetReactState(ReactStates st) { m_reactState = st; }
504  ReactStates GetReactState() const { return m_reactState; }
505  bool HasReactState(ReactStates state) const { return (m_reactState == state); }
506  void InitializeReactState();
507 
508  bool IsTrainerOf(Player* player, bool msg) const;
509  bool CanInteractWithBattleMaster(Player* player, bool msg) const;
510  bool CanTrainAndResetTalentsOf(Player* pPlayer) const;
511  bool CanCreatureAttack(Unit const* victim, bool force = true) const;
512 
513  bool IsImmuneToSpell(SpellEntry const* spellInfo, bool useCharges = false) override;
514  bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool castOnSelf) const override;
515 
516  bool isElite() const;
517  bool isWorldBoss() const;
518 
519  uint8 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
520 
521  bool IsInEvadeMode() const;
522 
523  bool AIM_Initialize(CreatureAI* ai = NULL);
524 
525  CreatureAI* AI() const { return (CreatureAI*)i_AI; }
526 
527  uint32 GetShieldBlockValue() const override //dunno mob block value
528  {
529  return (getLevel() / 2 + uint32(GetStat(STAT_STRENGTH) / 20));
530  }
531 
532  SpellSchoolMask GetMeleeDamageSchoolMask() const override { return m_meleeDamageSchoolMask; }
533  void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
534 
535  void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time);
536  void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time);
537  void AddCreatureSpellCooldown(uint32 spellid);
538  bool HasSpellCooldown(uint32 spell_id) const;
539  bool HasCategoryCooldown(uint32 spell_id) const;
540 
541  bool HasSpell(uint32 spellID) const override;
542 
543  bool UpdateEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL);
544  void UpdateMovementFlags(bool packetOnly = false);
545  bool UpdateStats(Stats stat) override;
546  bool UpdateAllStats() override;
547  void UpdateResistances(uint32 school) override;
548  void UpdateArmor() override;
549  void UpdateMaxHealth() override;
550  void UpdateMaxPower(Powers power) override;
551  void UpdateAttackPowerAndDamage(bool ranged = false) override;
552  void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override;
553 
554  void SetCanDualWield(bool value);
555  void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; }
556  uint32 GetCurrentEquipmentId() { return m_equipmentId; }
557  float GetSpellDamageMod(int32 Rank) const;
558 
559  VendorItemData const* GetVendorItems() const;
560  uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
561  uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
562 
563  TrainerSpellData const* GetTrainerSpells() const;
564 
565  CreatureInfo const* GetCreatureTemplate() const { return m_creatureInfo; }
566  CreatureData const* GetCreatureData() const { return m_creatureData; }
567  CreatureDataAddon const* GetCreatureAddon() const;
568 
569  std::string GetAIName() const;
570  std::string GetScriptName();
572 
573  void setEmoteState(uint8 emote) { m_emoteState = emote; };
574  void Say(const char* text, uint32 language, uint64 TargetGuid) { MonsterSay(text, language, TargetGuid); }
575  void Yell(const char* text, uint32 language, uint64 TargetGuid) { MonsterYell(text, language, TargetGuid); }
576  void TextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(text, TargetGuid, IsBossEmote); }
577  void Whisper(const char* text, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(text, receiver, IsBossWhisper); }
578  void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId, language, TargetGuid); }
579  void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId, language, TargetGuid); }
580  void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId, TargetGuid, IsBossEmote); }
581  void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId, receiver, IsBossWhisper); }
582 
583  // overwrite WorldObject function for proper name localization
584  const char* GetNameForLocaleIdx(int32 locale_idx) const override;
585 
586  void setDeathState(DeathState s) override; // overwrite virtual Unit::setDeathState
587 
588  bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false); }
589  bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true);
590  virtual void SaveToDB(); // overwrited in TemporarySummon
591 
592  virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); // overwrited in Pet
593  virtual void DeleteFromDB(); // overwrited in Pet
594 
596  void StartPickPocketRefillTimer();
597  void ResetPickPocketRefillTimer() { _pickpocketLootRestore = 0; }
598  bool CanGeneratePickPocketLoot() const { return _pickpocketLootRestore <= time(NULL); }
599  void SetSkinner(uint64 guid) { _skinner = guid; }
600  uint64 GetSkinner() const { return _skinner; } // Returns the player who skinned this creature
601  Player* GetLootRecipient() const;
602  Group *GetLootRecipientGroup() const;
603  bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
604  bool isTappedBy(Player const* player) const;
605 
606  void SetLootRecipient (Unit* unit);
607  void AllLootRemovedFromCorpse();
608 
609  SpellEntry const* reachWithSpellAttack(Unit* pVictim);
610  SpellEntry const* reachWithSpellCure(Unit* pVictim);
611 
616 
617  bool canStartAttack(Unit const* u, bool force) const;
618  float GetAttackDistance(Unit const* pl) const;
619  float GetAggroRange(Unit const* target) const;
620 
621  void SendAIReaction(AiReaction reactionType);
622 
623  Unit* SelectNearestTarget(float dist = 0, bool playerOnly = false) const;
624  Unit* SelectNearestTargetInAttackDistance(float dist = 0) const;
625  Unit* SelectNearestHostileUnitInAggroRange(bool useLOS = false) const;
626 
627  void DoFleeToGetAssistance();
628  void CallForHelp(float fRadius);
629  void CallAssistance();
630  void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
631  void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
632  bool HasSearchedAssistance() const { return m_AlreadySearchedAssistance; }
633  bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
634  bool _IsTargetAcceptable(const Unit* target) const;
635 
637  {
638  return m_defaultMovementType;
639  }
641  {
642  m_defaultMovementType = mgt;
643  }
644 
645  // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
646  Cell const& GetCurrentCell() const
647  {
648  return m_currentCell;
649  }
650  void SetCurrentCell(Cell const& cell)
651  {
652  m_currentCell = cell;
653  }
654 
655  void RemoveCorpse(bool setSpawnTime = true);
656  void ForcedDespawn(uint32 timeMSToDespawn = 0);
657 
658  void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
659 
660  time_t const& GetRespawnTime() const
661  {
662  return m_respawnTime;
663  }
664  time_t GetRespawnTimeEx() const;
665  void SetRespawnTime(uint32 respawn)
666  {
667  m_respawnTime = time(NULL) + respawn;
668  }
669  void Respawn(bool force = false);
670  void SaveRespawnTime() override;
671 
673  {
674  return m_respawnDelay;
675  }
677  {
678  m_respawnDelay = delay;
679  }
680 
681  float GetRespawnRadius() const
682  {
683  return m_respawnradius;
684  }
685  void SetRespawnRadius(float dist)
686  {
687  m_respawnradius = dist;
688  }
689 
690  uint32 GetCombatPulseDelay() const { return m_combatPulseDelay; }
691  void SetCombatPulseDelay(uint32 delay) // (secs) interval at which the creature pulses the entire zone into combat (only works in dungeons)
692  {
693  m_combatPulseDelay = delay;
694  if (m_combatPulseTime == 0 || m_combatPulseTime > delay)
695  m_combatPulseTime = delay;
696  }
697 
698  // Linked Creature Respawning System
699  time_t GetLinkedCreatureRespawnTime() const;
700  const CreatureData* GetLinkedRespawnCreatureData() const;
701 
702  void SendZoneUnderAttackMessage(Player* attacker);
703 
704  void SetInCombatWithZone();
705 
706  bool hasQuest(uint32 quest_id) const override;
707  bool hasInvolvedQuest(uint32 quest_id) const override;
708 
710  {
711  return m_regenHealth;
712  }
713  void setRegeneratingHealth(bool regenHealth) { m_regenHealth = regenHealth; }
714 
715  virtual uint8 GetPetAutoSpellSize() const
716  {
717  return CREATURE_MAX_SPELLS;
718  }
719  virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
720  {
721  if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->active != ACT_ENABLED)
722  return 0;
723  else
724  return m_charmInfo->GetCharmSpell(pos)->spellId;
725  }
726 
727  void SetHomePosition(float x, float y, float z, float o)
728  {
729  m_homePosition.Relocate(x, y, z, o);
730  }
731  void SetHomePosition(const Position& pos)
732  {
733  m_homePosition.Relocate(pos);
734  }
735  void GetHomePosition(float& x, float& y, float& z, float& ori)
736  {
737  m_homePosition.GetPosition(x, y, z, ori);
738  }
740  {
741  return m_homePosition;
742  }
743 
745  {
746  return m_GlobalCooldown;
747  }
748 
750  {
751  return m_path_id;
752  }
753  void LoadPath(uint32 pathid)
754  {
755  m_path_id = pathid;
756  }
757 
759  {
760  return m_waypointID;
761  }
763  {
764  m_waypointID = wpID;
765  }
766 
767  void SearchFormation();
769  {
770  return m_formation;
771  }
772  void SetFormation(CreatureGroup* formation)
773  {
774  m_formation = formation;
775  }
776 
777  Unit* SelectVictim();
778 
779  void SetDisableReputationGain(bool disable)
780  {
781  DisableReputationGain = disable;
782  }
784  {
785  return DisableReputationGain;
786  }
788  {
789  return hasPlayerDamaged;
790  }
791  void SetPlayerDamaged(bool set);
793 
794  uint32 GetOriginalEntry() const { return m_originalEntry; }
795  void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
796 
797  float m_SightDistance, m_CombatDistance;
798 
799  bool SetLevitate(bool enable, bool packetOnly = false) override;
800  bool SetWalk(bool enable) override;
801  bool SetSwim(bool enable) override;
802  bool SetCanFly(bool enable, bool packetOnly = false) override;
803  bool SetFeatherFall(bool enable, bool packetOnly = false) override;
804  bool SetWaterWalking(bool enable, bool packetOnly = false) override;
805  bool SetHover(bool enable, bool packetOnly = false) override;
806 
807  CreatureTextRepeatIds GetTextRepeatGroup(uint8 textGroup);
808  void SetTextRepeatId(uint8 textGroup, uint8 id);
809  void ClearTextRepeatGroup(uint8 textGroup);
810 
811  bool m_isTempWorldObject; //true when possessed
812 
813  protected:
814  bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const CreatureData* data = NULL);
815  bool InitEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL);
816 
817  // vendor items
819 
820  void _RealtimeSetCreatureInfo();
821 
822  static float _GetHealthMod(int32 Rank);
823  static float _GetDamageMod(int32 Rank);
824 
829 
832  uint32 m_corpseRemoveTime; // (msecs)timer for death or corpse disappearance
833  time_t m_respawnTime; // (secs) time of next respawn
834  uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
835  uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
837  uint32 m_combatPulseTime; // (msecs) remaining time for next zone-in-combat pulse
838  uint32 m_combatPulseDelay; // (secs) how often the creature puts the entire zone in combat (only works in dungeons)
839 
841  ReactStates m_reactState; // for AI, not charmInfo
842  void RegenerateMana();
843  void RegenerateHealth();
846  Cell m_currentCell; // store current cell where creature listed
847  uint32 m_DBTableGuid; // For new or temporary creatures is 0 for saved it is lowguid
849 
854 
857 
859 
861 
863 
864  bool IsInvisibleDueToDespawn() const override;
865  bool CanAlwaysSee(WorldObject const* obj) const override;
866 
867  void SetBaseWalkSpeed(float speed) override;
868  void SetBaseRunSpeed(float speed) override;
869  private:
870  //WaypointMovementGenerator vars
873 
874  //Formation var
876 
878 
879  CreatureInfo const* m_creatureInfo; // in heroic mode can different from sObjectMgr::GetCreatureTemplate(GetEntry())
880 
882 };
883 
885 {
886  public:
887  AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
888 
889  bool Execute(uint64 e_time, uint32 p_time) override;
890  void AddAssistant(const uint64& guid)
891  {
892  m_assistants.push_back(guid);
893  }
894  private:
896 
898  std::list<uint64> m_assistants;
900 };
901 
903 {
904  public:
905  ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
906  bool Execute(uint64 e_time, uint32 p_time) override;
907 
908  private:
910 };
911 
912 #endif
913 
uint32 GetCurrentEquipmentId()
Definition: Creature.h:556
CreatureInfo const * GetCreatureTemplate(uint32 id)
Definition: ObjectMgr.cpp:7745
uint32 GossipId
Definition: Creature.h:89
uint32 m_corpseDelay
Definition: Creature.h:835
bool Coded
Definition: Creature.h:94
uint32 trainer_spell
Definition: Creature.h:166
uint32 maxlevel
Definition: Creature.h:143
ChatType
Definition: Creature.h:335
VendorItem * GetItem(uint32 slot) const
Definition: Creature.h:370
std::vector< std::string > OptionText
Definition: Creature.h:246
int32 resistance3
Definition: Creature.h:176
void SetRespawnTime(uint32 respawn)
Definition: Creature.h:665
uint32 npcflag
Definition: Creature.h:151
uint32 Id
Definition: Creature.h:88
uint32 GetRespawnDelay() const
Definition: Creature.h:672
std::list< VendorItemCount > VendorItemCounts
Definition: Creature.h:409
uint32 minmana
Definition: Creature.h:147
CreatureData const * m_creatureData
Definition: Creature.h:862
float ModMana
Definition: Creature.h:188
float ModArmor
Definition: Creature.h:189
uint32 GetScriptId(const char *name)
Definition: ObjectMgr.cpp:7730
Position m_homePosition
Definition: Creature.h:858
uint64 m_victim
Definition: Creature.h:897
uint32 maxcount
Definition: Creature.h:360
std::list< uint64 > m_assistants
Definition: Creature.h:898
bool LoadFromDB(uint32 guid, Map *map)
Definition: Creature.h:588
uint32 rank
Definition: Creature.h:155
virtual uint8 GetPetAutoSpellSize() const
Definition: Creature.h:715
uint32 Icon
Definition: Creature.h:91
bool m_isTempWorldObject
Definition: Creature.h:811
uint8 spawnMask
Definition: Creature.h:289
uint8 movementType
Definition: Creature.h:288
float ModDamage
Definition: Creature.h:190
uint32 pickpocketLootId
Definition: Creature.h:172
int32 resistance6
Definition: Creature.h:179
void SetNoCallAssistance(bool val)
Definition: Creature.h:630
uint32 GetDBTableGUIDLow() const
Definition: Creature.h:484
uint32 id
Definition: Creature.h:274
uint32 reqskill
Definition: Creature.h:415
void Yell(const char *text, uint32 language, uint64 TargetGuid)
Definition: Creature.h:575
SpellSchoolMask
char * Name
Definition: Creature.h:138
uint32 reqlevel
Definition: Creature.h:417
void GetHomePosition(float &x, float &y, float &z, float &ori)
Definition: Creature.h:735
uint32 Action
Definition: Creature.h:92
uint32 entry
Definition: Creature.h:257
uint32 displayid
Definition: Creature.h:277
void UpdateWaypointID(uint32 wpID)
Definition: Creature.h:762
Gossip_Guard
Definition: Creature.h:40
void setRegeneratingHealth(bool regenHealth)
Definition: Creature.h:713
uint32 modelid4
Definition: Creature.h:137
SpellSchools
WeaponAttackType
Definition: Unit.h:498
time_t m_respawnTime
Definition: Creature.h:833
float BaseMeleeAttackPower
Definition: Creature.h:233
void Clear()
Definition: Creature.h:391
AiReaction
Unit & m_owner
Definition: Creature.h:899
uint32 curhealth
Definition: Creature.h:286
uint32 trainerType
Definition: Creature.h:427
uint32 GetWaypointPath()
Definition: Creature.h:749
uint32 race
Definition: Creature.h:168
AssistDelayEvent(const uint64 &victim, Unit &owner)
Definition: Creature.h:887
bool m_AlreadyCallAssistance
Definition: Creature.h:850
std::vector< uint8 > CreatureTextRepeatIds
Definition: Creature.h:464
bool CanFly() const
Definition: Creature.h:501
Loot loot
Definition: Creature.h:595
uint32 curmana
Definition: Creature.h:287
bool m_AlreadySearchedAssistance
Definition: Creature.h:851
bool hasPlayerDamaged
Definition: Creature.h:792
void SetCurrentCell(Cell const &cell)
Definition: Creature.h:650
float speed_walk
Definition: Creature.h:152
uint32 trainer_type
Definition: Creature.h:165
MovementGeneratorType GetDefaultMovementType() const
Definition: Creature.h:636
CreatureData const * GetCreatureData() const
Definition: Creature.h:566
std::string GetAIName() const
Definition: Creature.h:221
VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
Definition: Creature.h:356
bool RacialLeader
Definition: Creature.h:191
ACE_INT32 int32
Definition: Define.h:67
uint32 armor
Definition: Creature.h:149
void SetCurrentEquipmentId(uint8 id)
Definition: Creature.h:555
TrainerSpellList spellList
Definition: Creature.h:426
bool HasReactState(ReactStates state) const
Definition: Creature.h:505
void SetFormation(CreatureGroup *formation)
Definition: Creature.h:772
uint8 m_emoteState
Definition: Creature.h:840
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:727
bool IsTrigger() const
Definition: Creature.h:497
float spawndist
Definition: Creature.h:284
bool HasSearchedAssistance() const
Definition: Creature.h:632
VirtualItemInfoByteOffset
Definition: Creature.h:443
VirtualItemSlot
Definition: Creature.h:434
CreatureFlagsExtra
Definition: Creature.h:99
void SetHomePosition(const Position &pos)
Definition: Creature.h:731
void AddAssistant(const uint64 &guid)
Definition: Creature.h:890
uint32 GetCombatPulseDelay() const
Definition: Creature.h:690
uint8 GetItemCount() const
Definition: Creature.h:379
void SetDisableReputationGain(bool disable)
Definition: Creature.h:779
MovementGeneratorType m_defaultMovementType
Definition: Creature.h:845
uint32 dynamicflags
Definition: Creature.h:163
uint32 GetShieldBlockValue() const override
Definition: Creature.h:527
bool dbData
Definition: Creature.h:293
uint32 minlevel
Definition: Creature.h:142
void LoadPath(uint32 pathid)
Definition: Creature.h:753
VendorItemCount(uint32 _item, uint32 _count)
Definition: Creature.h:401
uint32 modelid1
Definition: Creature.h:134
bool CanSwim() const
Definition: Creature.h:500
CreatureTextRepeatGroup m_textRepeat
Definition: Creature.h:881
void Yell(int32 textId, uint32 language, uint64 TargetGuid)
Definition: Creature.h:579
float BaseVariance
Definition: Creature.h:159
time_t _pickpocketLootRestore
Timers.
Definition: Creature.h:831
time_t const & GetRespawnTime() const
Definition: Creature.h:660
bool IsRacialLeader() const
Definition: Creature.h:495
uint32 m_combatPulseDelay
Definition: Creature.h:838
uint32 SkinLootId
Definition: Creature.h:173
float posX
Definition: Creature.h:279
bool isTameable() const
Definition: Creature.h:213
uint32 flags_extra
Definition: Creature.h:195
ReactStates m_reactState
Definition: Creature.h:841
float m_respawnradius
Definition: Creature.h:836
uint32 guidOrEntry
Definition: Creature.h:305
uint32 spawntimesecs
Definition: Creature.h:283
uint32 m_lootRecipientGroup
Definition: Creature.h:827
uint32 unit_class
Definition: Creature.h:161
void SetMeleeDamageSchool(SpellSchools school)
Definition: Creature.h:533
char * IconName
Definition: Creature.h:140
bool CanGeneratePickPocketLoot() const
Definition: Creature.h:598
#define MAX_KILL_CREDIT
Definition: Creature.h:127
uint32 m_corpseRemoveTime
Definition: Creature.h:832
char * SubName
Definition: Creature.h:139
ACE_UINT8 uint8
Definition: Define.h:73
Powers
int32 resistance4
Definition: Creature.h:177
std::vector< VendorItem * > VendorItemList
Definition: Creature.h:364
CreatureGroup * m_formation
Definition: Creature.h:875
Position GetHomePosition()
Definition: Creature.h:739
char const * AIName
Definition: Creature.h:184
UNORDERED_MAP< uint8, CreatureTextRepeatIds > CreatureTextRepeatGroup
Definition: Creature.h:465
void SetSkinner(uint64 guid)
Definition: Creature.h:599
uint32 m_lootMoney
Definition: Creature.h:825
uint32 m_DBTableGuid
Definition: Creature.h:847
uint32 faction
Definition: Creature.h:150
void SetRespawnRadius(float dist)
Definition: Creature.h:685
void SetDefaultMovementType(MovementGeneratorType mgt)
Definition: Creature.h:640
uint32 type
Definition: Creature.h:169
uint32 GossipMenuId
Definition: Creature.h:141
Stats
float GetRespawnRadius() const
Definition: Creature.h:681
void AddItem(uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
Definition: Creature.h:383
float speed_run
Definition: Creature.h:153
uint32 equipmentId
Definition: Creature.h:193
Definition: LootMgr.h:290
float posY
Definition: Creature.h:280
uint32 maxhealth
Definition: Creature.h:146
int32 resistance5
Definition: Creature.h:178
InhabitTypeValues
Definition: Creature.h:326
CreatureAI * AI() const
Definition: Creature.h:525
uint32 maxgold
Definition: Creature.h:183
void SetCorpseDelay(uint32 delay)
Definition: Creature.h:494
uint32 m_GlobalCooldown
Definition: Creature.h:615
etc mysql my cnf *Then change max_allowed_packet to a bigger value
uint32 spellcost
Definition: Creature.h:414
CreatureInfo const * m_creatureInfo
Definition: Creature.h:879
bool m_regenHealth
Definition: Creature.h:852
std::vector< std::string > StringVector
Definition: Common.h:232
void Say(const char *text, uint32 language, uint64 TargetGuid)
Definition: Creature.h:574
uint32 GetGlobalCooldown() const
Definition: Creature.h:744
void SetOriginalEntry(uint32 entry)
Definition: Creature.h:795
VisibilityDistanceType
Definition: Object.h:119
uint32 mingold
Definition: Creature.h:182
bool m_AI_locked
Definition: Creature.h:853
uint32 maxmana
Definition: Creature.h:148
uint32 m_combatPulseTime
Definition: Creature.h:837
Gossip_Guard_Skill
Definition: Creature.h:70
bool isRegeneratingHealth()
Definition: Creature.h:709
VendorItemCounts m_vendorItemCounts
Definition: Creature.h:818
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
Definition: Creature.h:719
uint32 m_originalEntry
Definition: Creature.h:856
bool CanWalk() const
Definition: Creature.h:499
uint32 npcflag
Definition: Creature.h:290
float combat_reach
Definition: Creature.h:319
bool Empty() const
Definition: Creature.h:375
Definition: Map.h:266
ReactStates
Pet&#39;s behavior.
Definition: Unit.h:758
float ModHealth
Definition: Creature.h:187
uint32 m_path_id
Definition: Creature.h:872
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition: Creature.h:613
uint32 PetSpellDataId
Definition: Creature.h:181
uint32 modelid3
Definition: Creature.h:136
bool DisableReputationGain
Definition: Creature.h:860
uint32 unit_flags
Definition: Creature.h:162
bool TriggerJustRespawned
Definition: Creature.h:877
int32 equipmentId
Definition: Creature.h:278
SpellSchoolMask m_meleeDamageSchoolMask
Definition: Creature.h:855
bool RegenHealth
Definition: Creature.h:192
CreatureGroup * GetFormation()
Definition: Creature.h:768
DeathState
Definition: Unit.h:435
ACE_UINT64 uint64
Definition: Define.h:70
Definition: Cell.h:46
Cell m_currentCell
Definition: Creature.h:846
uint32 modelid2
Definition: Creature.h:135
Cell const & GetCurrentCell() const
Definition: Creature.h:646
uint32 MovementType
Definition: Creature.h:185
uint64 _skinner
Definition: Creature.h:828
bool IsGuard() const
Definition: Creature.h:498
ReactStates GetReactState() const
Definition: Creature.h:504
uint32 m_respawnDelay
Definition: Creature.h:834
CreatureInfo const * GetCreatureTemplate() const
Definition: Creature.h:565
uint32 MechanicImmuneMask
Definition: Creature.h:194
std::vector< TrainerSpell * > TrainerSpellList
Definition: Creature.h:420
uint32 dynamicflags
Definition: Creature.h:292
bool IsCivilian() const
Definition: Creature.h:496
CreatureDataAddonAura const * auras
Definition: Creature.h:312
float BaseRangedAttackPower
Definition: Creature.h:234
int32 exp
Definition: Creature.h:144
uint64 m_lootRecipient
Definition: Creature.h:826
uint32 unit_flags
Definition: Creature.h:291
uint32 BaseArmor
Definition: Creature.h:235
uint64 GetSkinner() const
Definition: Creature.h:600
uint32 RangeAttackTime
Definition: Creature.h:158
#define CREATURE_MAX_SPELLS
Definition: Unit.h:249
VendorItemList m_items
Definition: Creature.h:368
StringVector IconName
Definition: Creature.h:252
int32 resistance1
Definition: Creature.h:174
void SetNoSearchAssistance(bool val)
Definition: Creature.h:631
uint32 GetEquipmentId() const
Definition: Creature.h:490
uint32 GetCurrentWaypointID()
Definition: Creature.h:758
float m_SightDistance
Definition: Creature.h:797
uint32 Entry
Definition: Creature.h:131
void ResetPickPocketRefillTimer()
Definition: Creature.h:597
uint32 currentwaypoint
Definition: Creature.h:285
uint32 item
Definition: Creature.h:359
uint32 itemId
Definition: Creature.h:404
uint32 m_regenTimer
Definition: Creature.h:844
MovementGeneratorType
Definition: MotionMaster.h:33
std::list< GossipOption > GossipOptionList
Definition: Creature.h:454
uint32 modelid_other_gender
Definition: Creature.h:323
float orientation
Definition: Creature.h:282
SkillType GetRequiredLootSkill() const
Definition: Creature.h:201
std::vector< std::string > Name
Definition: Creature.h:240
bool hasLootRecipient() const
Definition: Creature.h:603
uint32 incrtime
Definition: Creature.h:361
ForcedDespawnDelayEvent(Creature &owner)
Definition: Creature.h:905
void SetCombatPulseDelay(uint32 delay)
Definition: Creature.h:691
uint32 minhealth
Definition: Creature.h:145
uint32 spell
Definition: Creature.h:413
std::string BoxText
Definition: Creature.h:96
std::map< uint32, time_t > CreatureSpellCooldowns
Definition: Creature.h:456
CreatureFamily
uint16 mapid
Definition: Creature.h:275
char const * GetSubName() const
Definition: Creature.h:485
SkillType
uint32 InhabitType
Definition: Creature.h:186
uint32 BoxMoney
Definition: Creature.h:93
float scale
Definition: Creature.h:154
void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper=false)
Definition: Creature.h:581
uint32 phaseMask
Definition: Creature.h:276
uint32 classNum
Definition: Creature.h:167
uint32 ExtendedCost
Definition: Creature.h:362
float bounding_radius
Definition: Creature.h:318
uint32 type_flags
Definition: Creature.h:170
uint32 m_equipmentId
Definition: Creature.h:848
ACE_UINT16 uint16
Definition: Define.h:72
uint32 dmgschool
Definition: Creature.h:156
CreatureSpellCooldowns m_CreatureCategoryCooldowns
Definition: Creature.h:614
std::string OptionText
Definition: Creature.h:95
uint32 ScriptID
Definition: Creature.h:196
void Whisper(const char *text, uint64 receiver, bool IsBossWhisper=false)
Definition: Creature.h:577
float RangeVariance
Definition: Creature.h:160
ACE_UINT32 uint32
Definition: Define.h:71
time_t lastIncrementTime
Definition: Creature.h:406
VisibilityDistanceType visibilityDistanceType
Definition: Creature.h:311
uint32 BaseAttackTime
Definition: Creature.h:157
true
Definition: Log.cpp:534
void Say(int32 textId, uint32 language, uint64 TargetGuid)
Definition: Creature.h:578
Gossip_Guard_Spell
Definition: Creature.h:55
CreatureFamily family
Definition: Creature.h:164
Definition: Unit.h:908
void SetRespawnDelay(uint32 delay)
Definition: Creature.h:676
uint32 BaseHealth
Definition: Creature.h:230
uint32 m_waypointID
Definition: Creature.h:871
void TextEmote(const char *text, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Creature.h:576
void SetReactState(ReactStates st)
Definition: Creature.h:503
bool IsReputationGainDisabled()
Definition: Creature.h:783
Definition: Player.h:923
int32 resistance2
Definition: Creature.h:175
std::vector< std::string > SubName
Definition: Creature.h:241
uint32 GetOriginalEntry() const
Definition: Creature.h:794
float posZ
Definition: Creature.h:281
bool IsDamageEnoughForLootingAndReward() const
Definition: Creature.h:787
void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Creature.h:580
void setEmoteState(uint8 emote)
Definition: Creature.h:573
uint32 reqskillvalue
Definition: Creature.h:416
std::vector< std::string > BoxText
Definition: Creature.h:247
Definition: Group.h:154
SpellSchoolMask GetMeleeDamageSchoolMask() const override
Definition: Creature.h:532
uint32 lootid
Definition: Creature.h:171
uint32 HeroicEntry
Definition: Creature.h:132
uint32 count
Definition: Creature.h:405
uint32 NpcFlag
Definition: Creature.h:90