OregonCore  revision fb2a440-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 <http://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  uint32 equipentry[3];
254 };
255 
256 // depricated old way
258 {
260  uint32 equipmodel[3];
261  uint32 equipinfo[3];
262  uint32 equipslot[3];
263 };
264 
265 // from `creature` table
267 {
268  explicit CreatureData() : dbData(true) {}
269  uint32 id; // entry in creature_template
274  float posX;
275  float posY;
276  float posZ;
277  float orientation;
279  float spawndist;
286  uint32 unit_flags; // enum UnitFlags mask values
288  bool dbData;
289 };
290 
292 {
295 };
296 
297 // from `creature_addon` table
299 {
306  CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
307 };
308 
310 {
316 };
317 
319 {
324 };
325 
326 // Enums used by StringTextData::Type (CreatureEventAI)
328 {
336 };
337 
338 // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
339 #if defined(__GNUC__)
340 #pragma pack()
341 #else
342 #pragma pack(pop)
343 #endif
344 
345 // Vendors
347 {
348  VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
349  : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
350 
352  uint32 maxcount; // 0 for infinity item amount
353  uint32 incrtime; // time for restore items amount if maxcount != 0
355 };
356 typedef std::vector<VendorItem*> VendorItemList;
357 
359 {
361 
362  VendorItem* GetItem(uint32 slot) const
363  {
364  if (slot >= m_items.size()) return NULL;
365  return m_items[slot];
366  }
367  bool Empty() const
368  {
369  return m_items.empty();
370  }
372  {
373  return m_items.size();
374  }
375  void AddItem(uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
376  {
377  m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
378  }
379  bool RemoveItem(uint32 item_id);
380  VendorItem const* FindItem(uint32 item_id) const;
381  size_t FindItemSlot(uint32 item_id) const;
382 
383  void Clear()
384  {
385  for (VendorItemList::iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
386  delete (*itr);
387  m_items.clear();
388  }
389 };
390 
392 {
393  explicit VendorItemCount(uint32 _item, uint32 _count)
394  : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
395 
399 };
400 
401 typedef std::list<VendorItemCount> VendorItemCounts;
402 
404 {
410 };
411 
412 typedef std::vector<TrainerSpell*> TrainerSpellList;
413 
415 {
416  TrainerSpellData() : trainerType(0) {}
417 
419  uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
420  // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
421 
422  void Clear();
423  TrainerSpell const* Find(uint32 spell_id) const;
424 };
425 
427 {
431 };
432 
433 #define MAX_VIRTUAL_ITEM_SLOT 3
434 
436 {
441 
444 };
445 
446 typedef std::list<GossipOption> GossipOptionList;
447 
448 typedef std::map<uint32, time_t> CreatureSpellCooldowns;
449 
450 // max different by z coordinate for creature aggro reaction
451 #define CREATURE_Z_ATTACK_RANGE 3
452 
453 #define MAX_VENDOR_ITEMS 255 // Limitation in item count field size in SMSG_LIST_INVENTORY
454 
455 //used for handling non-repeatable random texts
456 typedef std::vector<uint8> CreatureTextRepeatIds;
457 typedef UNORDERED_MAP<uint8, CreatureTextRepeatIds> CreatureTextRepeatGroup;
458 
459 class Creature : public Unit, public GridObject<Creature>
460 {
461  public:
462 
463  explicit Creature(bool isWorldObject = false);
464  ~Creature() override;
465 
466  void AddToWorld() override;
467  void RemoveFromWorld() override;
468 
469  void DisappearAndDie();
470 
471  bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 team, float x, float y, float z, float ang, const CreatureData* data = NULL);
472  bool LoadCreaturesAddon(bool reload = false);
473  void SelectLevel();
474  void LoadEquipment(uint32 equip_entry, bool force = false);
475 
476  uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
477  char const* GetSubName() const { return GetCreatureTemplate()->SubName; }
478 
479  void Update(uint32 time) override; // overwrited Unit::Update
480  void GetRespawnPosition(float& x, float& y, float& z, float* ori = NULL, float* dist = NULL) const;
481 
482  uint32 GetEquipmentId() const { return m_equipmentId; }
483  void SetVirtualItem(VirtualItemSlot slot, uint32 item_id);
484  void SetVirtualItemRaw(VirtualItemSlot slot, uint32 display_id, uint32 info0, uint32 info1);
485 
486  void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
487  bool IsRacialLeader() const { return GetCreatureTemplate()->RacialLeader; }
488  bool IsCivilian() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN) != 0; }
489  bool IsTrigger() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) != 0; }
490  bool IsGuard() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD) != 0; }
491  bool CanWalk() const { return (GetCreatureTemplate()->InhabitType & INHABIT_GROUND) != 0; }
492  bool CanSwim() const { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) != 0 || IsPet(); }
493  bool CanFly() const { return (GetCreatureTemplate()->InhabitType & INHABIT_AIR) != 0 || HasAuraType(SPELL_AURA_FLY); }
494 
495  void SetReactState(ReactStates st) { m_reactState = st; }
496  ReactStates GetReactState() const { return m_reactState; }
497  bool HasReactState(ReactStates state) const { return (m_reactState == state); }
498  void InitializeReactState();
499 
500  bool IsTrainerOf(Player* player, bool msg) const;
501  bool CanInteractWithBattleMaster(Player* player, bool msg) const;
502  bool CanTrainAndResetTalentsOf(Player* pPlayer) const;
503  bool CanCreatureAttack(Unit const* victim, bool force = true) const;
504 
505  bool IsImmuneToSpell(SpellEntry const* spellInfo, bool useCharges = false) override;
506  bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool castOnSelf) const override;
507 
508  bool isElite() const;
509  bool isWorldBoss() const;
510 
511  uint8 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
512 
513  bool IsInEvadeMode() const;
514 
515  bool AIM_Initialize(CreatureAI* ai = NULL);
516 
517  CreatureAI* AI() const { return (CreatureAI*)i_AI; }
518 
519  uint32 GetShieldBlockValue() const override //dunno mob block value
520  {
521  return (getLevel() / 2 + uint32(GetStat(STAT_STRENGTH) / 20));
522  }
523 
524  SpellSchoolMask GetMeleeDamageSchoolMask() const override { return m_meleeDamageSchoolMask; }
525  void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
526 
527  void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time);
528  void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time);
529  void AddCreatureSpellCooldown(uint32 spellid);
530  bool HasSpellCooldown(uint32 spell_id) const;
531  bool HasCategoryCooldown(uint32 spell_id) const;
532 
533  bool HasSpell(uint32 spellID) const override;
534 
535  bool UpdateEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL);
536  void UpdateMovementFlags(bool packetOnly = false);
537  bool UpdateStats(Stats stat) override;
538  bool UpdateAllStats() override;
539  void UpdateResistances(uint32 school) override;
540  void UpdateArmor() override;
541  void UpdateMaxHealth() override;
542  void UpdateMaxPower(Powers power) override;
543  void UpdateAttackPowerAndDamage(bool ranged = false) override;
544  void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override;
545 
546  void SetCanDualWield(bool value);
547  void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; }
548  uint32 GetCurrentEquipmentId() { return m_equipmentId; }
549  float GetSpellDamageMod(int32 Rank) const;
550 
551  VendorItemData const* GetVendorItems() const;
552  uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
553  uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
554 
555  TrainerSpellData const* GetTrainerSpells() const;
556 
557  CreatureInfo const* GetCreatureTemplate() const { return m_creatureInfo; }
558  CreatureData const* GetCreatureData() const { return m_creatureData; }
559  CreatureDataAddon const* GetCreatureAddon() const;
560 
561  std::string GetAIName() const;
562  std::string GetScriptName();
564 
565  void setEmoteState(uint8 emote) { m_emoteState = emote; };
566  void Say(const char* text, uint32 language, uint64 TargetGuid) { MonsterSay(text, language, TargetGuid); }
567  void Yell(const char* text, uint32 language, uint64 TargetGuid) { MonsterYell(text, language, TargetGuid); }
568  void TextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(text, TargetGuid, IsBossEmote); }
569  void Whisper(const char* text, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(text, receiver, IsBossWhisper); }
570  void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId, language, TargetGuid); }
571  void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId, language, TargetGuid); }
572  void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId, TargetGuid, IsBossEmote); }
573  void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId, receiver, IsBossWhisper); }
574 
575  // overwrite WorldObject function for proper name localization
576  const char* GetNameForLocaleIdx(int32 locale_idx) const override;
577 
578  void setDeathState(DeathState s) override; // overwrite virtual Unit::setDeathState
579 
580  bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false); }
581  bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true);
582  virtual void SaveToDB(); // overwrited in TemporarySummon
583 
584  virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); // overwrited in Pet
585  virtual void DeleteFromDB(); // overwrited in Pet
586 
588  void StartPickPocketRefillTimer();
589  void ResetPickPocketRefillTimer() { _pickpocketLootRestore = 0; }
590  bool CanGeneratePickPocketLoot() const { return _pickpocketLootRestore <= time(NULL); }
591  void SetSkinner(uint64 guid) { _skinner = guid; }
592  uint64 GetSkinner() const { return _skinner; } // Returns the player who skinned this creature
593  Player* GetLootRecipient() const;
594  Group *GetLootRecipientGroup() const;
595  bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
596  bool isTappedBy(Player const* player) const;
597 
598  void SetLootRecipient (Unit* unit);
599  void AllLootRemovedFromCorpse();
600 
601  SpellEntry const* reachWithSpellAttack(Unit* pVictim);
602  SpellEntry const* reachWithSpellCure(Unit* pVictim);
603 
608 
609  bool canStartAttack(Unit const* u, bool force) const;
610  float GetAttackDistance(Unit const* pl) const;
611  float GetAggroRange(Unit const* target) const;
612 
613  void SendAIReaction(AiReaction reactionType);
614 
615  Unit* SelectNearestTarget(float dist = 0, bool playerOnly = false) const;
616  Unit* SelectNearestTargetInAttackDistance(float dist = 0) const;
617  Unit* SelectNearestHostileUnitInAggroRange(bool useLOS = false) const;
618 
619  void DoFleeToGetAssistance();
620  void CallForHelp(float fRadius);
621  void CallAssistance();
622  void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
623  void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
624  bool HasSearchedAssistance() const { return m_AlreadySearchedAssistance; }
625  bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
626  bool _IsTargetAcceptable(const Unit* target) const;
627 
629  {
630  return m_defaultMovementType;
631  }
633  {
634  m_defaultMovementType = mgt;
635  }
636 
637  // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
638  Cell const& GetCurrentCell() const
639  {
640  return m_currentCell;
641  }
642  void SetCurrentCell(Cell const& cell)
643  {
644  m_currentCell = cell;
645  }
646 
647  void RemoveCorpse(bool setSpawnTime = true);
648  void ForcedDespawn(uint32 timeMSToDespawn = 0);
649 
650  void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
651 
652  time_t const& GetRespawnTime() const
653  {
654  return m_respawnTime;
655  }
656  time_t GetRespawnTimeEx() const;
657  void SetRespawnTime(uint32 respawn)
658  {
659  m_respawnTime = time(NULL) + respawn;
660  }
661  void Respawn(bool force = false);
662  void SaveRespawnTime() override;
663 
665  {
666  return m_respawnDelay;
667  }
669  {
670  m_respawnDelay = delay;
671  }
672 
673  float GetRespawnRadius() const
674  {
675  return m_respawnradius;
676  }
677  void SetRespawnRadius(float dist)
678  {
679  m_respawnradius = dist;
680  }
681 
682  uint32 GetCombatPulseDelay() const { return m_combatPulseDelay; }
683  void SetCombatPulseDelay(uint32 delay) // (secs) interval at which the creature pulses the entire zone into combat (only works in dungeons)
684  {
685  m_combatPulseDelay = delay;
686  if (m_combatPulseTime == 0 || m_combatPulseTime > delay)
687  m_combatPulseTime = delay;
688  }
689 
690  // Linked Creature Respawning System
691  time_t GetLinkedCreatureRespawnTime() const;
692  const CreatureData* GetLinkedRespawnCreatureData() const;
693 
694  void SendZoneUnderAttackMessage(Player* attacker);
695 
696  void SetInCombatWithZone();
697 
698  bool hasQuest(uint32 quest_id) const override;
699  bool hasInvolvedQuest(uint32 quest_id) const override;
700 
702  {
703  return m_regenHealth;
704  }
705  void setRegeneratingHealth(bool regenHealth) { m_regenHealth = regenHealth; }
706 
707  virtual uint8 GetPetAutoSpellSize() const
708  {
709  return CREATURE_MAX_SPELLS;
710  }
711  virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
712  {
713  if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->active != ACT_ENABLED)
714  return 0;
715  else
716  return m_charmInfo->GetCharmSpell(pos)->spellId;
717  }
718 
719  void SetHomePosition(float x, float y, float z, float o)
720  {
721  m_homePosition.Relocate(x, y, z, o);
722  }
723  void SetHomePosition(const Position& pos)
724  {
725  m_homePosition.Relocate(pos);
726  }
727  void GetHomePosition(float& x, float& y, float& z, float& ori)
728  {
729  m_homePosition.GetPosition(x, y, z, ori);
730  }
732  {
733  return m_homePosition;
734  }
735 
737  {
738  return m_GlobalCooldown;
739  }
740 
742  {
743  return m_path_id;
744  }
745  void LoadPath(uint32 pathid)
746  {
747  m_path_id = pathid;
748  }
749 
751  {
752  return m_waypointID;
753  }
755  {
756  m_waypointID = wpID;
757  }
758 
759  void SearchFormation();
761  {
762  return m_formation;
763  }
764  void SetFormation(CreatureGroup* formation)
765  {
766  m_formation = formation;
767  }
768 
769  Unit* SelectVictim();
770 
771  void SetDisableReputationGain(bool disable)
772  {
773  DisableReputationGain = disable;
774  }
776  {
777  return DisableReputationGain;
778  }
780  {
781  return hasPlayerDamaged;
782  }
783  void SetPlayerDamaged(bool set);
785 
786  uint32 GetOriginalEntry() const { return m_originalEntry; }
787  void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
788 
789  float m_SightDistance, m_CombatDistance;
790 
791  bool SetLevitate(bool enable, bool packetOnly = false) override;
792  bool SetWalk(bool enable) override;
793  bool SetSwim(bool enable) override;
794  bool SetCanFly(bool enable, bool packetOnly = false) override;
795  bool SetFeatherFall(bool enable, bool packetOnly = false) override;
796  bool SetWaterWalking(bool enable, bool packetOnly = false) override;
797  bool SetHover(bool enable, bool packetOnly = false) override;
798 
799  CreatureTextRepeatIds GetTextRepeatGroup(uint8 textGroup);
800  void SetTextRepeatId(uint8 textGroup, uint8 id);
801  void ClearTextRepeatGroup(uint8 textGroup);
802 
803  bool m_isTempWorldObject; //true when possessed
804 
805  protected:
806  bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const CreatureData* data = NULL);
807  bool InitEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL);
808 
809  // vendor items
811 
812  void _RealtimeSetCreatureInfo();
813 
814  static float _GetHealthMod(int32 Rank);
815  static float _GetDamageMod(int32 Rank);
816 
821 
824  uint32 m_corpseRemoveTime; // (msecs)timer for death or corpse disappearance
825  time_t m_respawnTime; // (secs) time of next respawn
826  uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
827  uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
829  uint32 m_combatPulseTime; // (msecs) remaining time for next zone-in-combat pulse
830  uint32 m_combatPulseDelay; // (secs) how often the creature puts the entire zone in combat (only works in dungeons)
831 
833  ReactStates m_reactState; // for AI, not charmInfo
834  void RegenerateMana();
835  void RegenerateHealth();
838  Cell m_currentCell; // store current cell where creature listed
839  uint32 m_DBTableGuid; // For new or temporary creatures is 0 for saved it is lowguid
841 
846 
849 
851 
853 
855 
856  bool IsInvisibleDueToDespawn() const override;
857  bool CanAlwaysSee(WorldObject const* obj) const override;
858  private:
859  //WaypointMovementGenerator vars
862 
863  //Formation var
865 
867 
868  CreatureInfo const* m_creatureInfo; // in heroic mode can different from sObjectMgr::GetCreatureTemplate(GetEntry())
869 
871 };
872 
874 {
875  public:
876  AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
877 
878  bool Execute(uint64 e_time, uint32 p_time) override;
879  void AddAssistant(const uint64& guid)
880  {
881  m_assistants.push_back(guid);
882  }
883  private:
885 
887  std::list<uint64> m_assistants;
889 };
890 
892 {
893  public:
894  ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
895  bool Execute(uint64 e_time, uint32 p_time) override;
896 
897  private:
899 };
900 
901 #endif
902 
uint32 GetCurrentEquipmentId()
Definition: Creature.h:548
CreatureInfo const * GetCreatureTemplate(uint32 id)
Definition: ObjectMgr.cpp:7663
uint32 GossipId
Definition: Creature.h:89
uint32 m_corpseDelay
Definition: Creature.h:827
bool Coded
Definition: Creature.h:94
uint32 trainer_spell
Definition: Creature.h:166
uint32 maxlevel
Definition: Creature.h:143
ChatType
Definition: Creature.h:327
VendorItem * GetItem(uint32 slot) const
Definition: Creature.h:362
std::vector< std::string > OptionText
Definition: Creature.h:246
int32 resistance3
Definition: Creature.h:176
void SetRespawnTime(uint32 respawn)
Definition: Creature.h:657
uint32 npcflag
Definition: Creature.h:151
uint32 Id
Definition: Creature.h:88
uint32 GetRespawnDelay() const
Definition: Creature.h:664
std::list< VendorItemCount > VendorItemCounts
Definition: Creature.h:401
uint32 minmana
Definition: Creature.h:147
CreatureData const * m_creatureData
Definition: Creature.h:854
float ModMana
Definition: Creature.h:188
float ModArmor
Definition: Creature.h:189
uint32 GetScriptId(const char *name)
Definition: ObjectMgr.cpp:7648
Position m_homePosition
Definition: Creature.h:850
uint64 m_victim
Definition: Creature.h:886
uint32 maxcount
Definition: Creature.h:352
std::list< uint64 > m_assistants
Definition: Creature.h:887
bool LoadFromDB(uint32 guid, Map *map)
Definition: Creature.h:580
uint32 rank
Definition: Creature.h:155
virtual uint8 GetPetAutoSpellSize() const
Definition: Creature.h:707
uint32 Icon
Definition: Creature.h:91
bool m_isTempWorldObject
Definition: Creature.h:803
uint8 spawnMask
Definition: Creature.h:284
uint8 movementType
Definition: Creature.h:283
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:622
uint32 GetDBTableGUIDLow() const
Definition: Creature.h:476
uint32 id
Definition: Creature.h:269
uint32 reqskill
Definition: Creature.h:407
void Yell(const char *text, uint32 language, uint64 TargetGuid)
Definition: Creature.h:567
SpellSchoolMask
char * Name
Definition: Creature.h:138
uint32 reqlevel
Definition: Creature.h:409
void GetHomePosition(float &x, float &y, float &z, float &ori)
Definition: Creature.h:727
uint32 Action
Definition: Creature.h:92
uint32 entry
Definition: Creature.h:252
uint32 displayid
Definition: Creature.h:272
void UpdateWaypointID(uint32 wpID)
Definition: Creature.h:754
Gossip_Guard
Definition: Creature.h:40
void setRegeneratingHealth(bool regenHealth)
Definition: Creature.h:705
uint32 modelid4
Definition: Creature.h:137
SpellSchools
WeaponAttackType
Definition: Unit.h:498
time_t m_respawnTime
Definition: Creature.h:825
float BaseMeleeAttackPower
Definition: Creature.h:233
void Clear()
Definition: Creature.h:383
AiReaction
Unit & m_owner
Definition: Creature.h:888
uint32 curhealth
Definition: Creature.h:281
uint32 trainerType
Definition: Creature.h:419
uint32 GetWaypointPath()
Definition: Creature.h:741
uint32 race
Definition: Creature.h:168
AssistDelayEvent(const uint64 &victim, Unit &owner)
Definition: Creature.h:876
bool m_AlreadyCallAssistance
Definition: Creature.h:842
std::vector< uint8 > CreatureTextRepeatIds
Definition: Creature.h:456
bool CanFly() const
Definition: Creature.h:493
Loot loot
Definition: Creature.h:587
uint32 curmana
Definition: Creature.h:282
bool m_AlreadySearchedAssistance
Definition: Creature.h:843
bool hasPlayerDamaged
Definition: Creature.h:784
void SetCurrentCell(Cell const &cell)
Definition: Creature.h:642
float speed_walk
Definition: Creature.h:152
uint32 trainer_type
Definition: Creature.h:165
MovementGeneratorType GetDefaultMovementType() const
Definition: Creature.h:628
CreatureData const * GetCreatureData() const
Definition: Creature.h:558
std::string GetAIName() const
Definition: Creature.h:221
VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
Definition: Creature.h:348
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:547
TrainerSpellList spellList
Definition: Creature.h:418
bool HasReactState(ReactStates state) const
Definition: Creature.h:497
void SetFormation(CreatureGroup *formation)
Definition: Creature.h:764
uint8 m_emoteState
Definition: Creature.h:832
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:719
bool IsTrigger() const
Definition: Creature.h:489
float spawndist
Definition: Creature.h:279
bool HasSearchedAssistance() const
Definition: Creature.h:624
VirtualItemInfoByteOffset
Definition: Creature.h:435
VirtualItemSlot
Definition: Creature.h:426
CreatureFlagsExtra
Definition: Creature.h:99
void SetHomePosition(const Position &pos)
Definition: Creature.h:723
void AddAssistant(const uint64 &guid)
Definition: Creature.h:879
uint32 GetCombatPulseDelay() const
Definition: Creature.h:682
uint8 GetItemCount() const
Definition: Creature.h:371
void SetDisableReputationGain(bool disable)
Definition: Creature.h:771
MovementGeneratorType m_defaultMovementType
Definition: Creature.h:837
uint32 dynamicflags
Definition: Creature.h:163
uint32 GetShieldBlockValue() const override
Definition: Creature.h:519
bool dbData
Definition: Creature.h:288
uint32 minlevel
Definition: Creature.h:142
void LoadPath(uint32 pathid)
Definition: Creature.h:745
VendorItemCount(uint32 _item, uint32 _count)
Definition: Creature.h:393
uint32 modelid1
Definition: Creature.h:134
bool CanSwim() const
Definition: Creature.h:492
CreatureTextRepeatGroup m_textRepeat
Definition: Creature.h:870
void Yell(int32 textId, uint32 language, uint64 TargetGuid)
Definition: Creature.h:571
float BaseVariance
Definition: Creature.h:159
time_t _pickpocketLootRestore
Timers.
Definition: Creature.h:823
time_t const & GetRespawnTime() const
Definition: Creature.h:652
bool IsRacialLeader() const
Definition: Creature.h:487
uint32 m_combatPulseDelay
Definition: Creature.h:830
uint32 SkinLootId
Definition: Creature.h:173
float posX
Definition: Creature.h:274
bool isTameable() const
Definition: Creature.h:213
uint32 flags_extra
Definition: Creature.h:195
ReactStates m_reactState
Definition: Creature.h:833
float m_respawnradius
Definition: Creature.h:828
uint32 guidOrEntry
Definition: Creature.h:300
uint32 spawntimesecs
Definition: Creature.h:278
uint32 m_lootRecipientGroup
Definition: Creature.h:819
uint32 unit_class
Definition: Creature.h:161
void SetMeleeDamageSchool(SpellSchools school)
Definition: Creature.h:525
char * IconName
Definition: Creature.h:140
bool CanGeneratePickPocketLoot() const
Definition: Creature.h:590
#define MAX_KILL_CREDIT
Definition: Creature.h:127
uint32 m_corpseRemoveTime
Definition: Creature.h:824
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:356
CreatureGroup * m_formation
Definition: Creature.h:864
Position GetHomePosition()
Definition: Creature.h:731
char const * AIName
Definition: Creature.h:184
UNORDERED_MAP< uint8, CreatureTextRepeatIds > CreatureTextRepeatGroup
Definition: Creature.h:457
void SetSkinner(uint64 guid)
Definition: Creature.h:591
uint32 m_lootMoney
Definition: Creature.h:817
uint32 m_DBTableGuid
Definition: Creature.h:839
uint32 faction
Definition: Creature.h:150
void SetRespawnRadius(float dist)
Definition: Creature.h:677
void SetDefaultMovementType(MovementGeneratorType mgt)
Definition: Creature.h:632
uint32 type
Definition: Creature.h:169
uint32 GossipMenuId
Definition: Creature.h:141
Stats
float GetRespawnRadius() const
Definition: Creature.h:673
void AddItem(uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
Definition: Creature.h:375
float speed_run
Definition: Creature.h:153
uint32 equipmentId
Definition: Creature.h:193
Definition: LootMgr.h:290
float posY
Definition: Creature.h:275
uint32 maxhealth
Definition: Creature.h:146
int32 resistance5
Definition: Creature.h:178
InhabitTypeValues
Definition: Creature.h:318
CreatureAI * AI() const
Definition: Creature.h:517
uint32 maxgold
Definition: Creature.h:183
void SetCorpseDelay(uint32 delay)
Definition: Creature.h:486
uint32 m_GlobalCooldown
Definition: Creature.h:607
etc mysql my cnf *Then change max_allowed_packet to a bigger value
uint32 spellcost
Definition: Creature.h:406
CreatureInfo const * m_creatureInfo
Definition: Creature.h:868
bool m_regenHealth
Definition: Creature.h:844
void Say(const char *text, uint32 language, uint64 TargetGuid)
Definition: Creature.h:566
uint32 GetGlobalCooldown() const
Definition: Creature.h:736
void SetOriginalEntry(uint32 entry)
Definition: Creature.h:787
uint32 mingold
Definition: Creature.h:182
bool m_AI_locked
Definition: Creature.h:845
uint32 maxmana
Definition: Creature.h:148
uint32 m_combatPulseTime
Definition: Creature.h:829
Gossip_Guard_Skill
Definition: Creature.h:70
bool isRegeneratingHealth()
Definition: Creature.h:701
VendorItemCounts m_vendorItemCounts
Definition: Creature.h:810
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
Definition: Creature.h:711
uint32 m_originalEntry
Definition: Creature.h:848
bool CanWalk() const
Definition: Creature.h:491
uint32 npcflag
Definition: Creature.h:285
float combat_reach
Definition: Creature.h:313
bool Empty() const
Definition: Creature.h:367
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:861
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition: Creature.h:605
uint32 PetSpellDataId
Definition: Creature.h:181
uint32 modelid3
Definition: Creature.h:136
bool DisableReputationGain
Definition: Creature.h:852
uint32 unit_flags
Definition: Creature.h:162
bool TriggerJustRespawned
Definition: Creature.h:866
int32 equipmentId
Definition: Creature.h:273
SpellSchoolMask m_meleeDamageSchoolMask
Definition: Creature.h:847
bool RegenHealth
Definition: Creature.h:192
CreatureGroup * GetFormation()
Definition: Creature.h:760
DeathState
Definition: Unit.h:435
ACE_UINT64 uint64
Definition: Define.h:70
Definition: Cell.h:46
Cell m_currentCell
Definition: Creature.h:838
uint32 modelid2
Definition: Creature.h:135
Cell const & GetCurrentCell() const
Definition: Creature.h:638
uint32 MovementType
Definition: Creature.h:185
uint64 _skinner
Definition: Creature.h:820
bool IsGuard() const
Definition: Creature.h:490
ReactStates GetReactState() const
Definition: Creature.h:496
uint32 m_respawnDelay
Definition: Creature.h:826
CreatureInfo const * GetCreatureTemplate() const
Definition: Creature.h:557
uint32 MechanicImmuneMask
Definition: Creature.h:194
std::vector< TrainerSpell * > TrainerSpellList
Definition: Creature.h:412
uint32 dynamicflags
Definition: Creature.h:287
bool IsCivilian() const
Definition: Creature.h:488
CreatureDataAddonAura const * auras
Definition: Creature.h:306
float BaseRangedAttackPower
Definition: Creature.h:234
int32 exp
Definition: Creature.h:144
uint64 m_lootRecipient
Definition: Creature.h:818
uint32 unit_flags
Definition: Creature.h:286
uint32 BaseArmor
Definition: Creature.h:235
uint64 GetSkinner() const
Definition: Creature.h:592
uint32 RangeAttackTime
Definition: Creature.h:158
#define CREATURE_MAX_SPELLS
Definition: Unit.h:249
VendorItemList m_items
Definition: Creature.h:360
int32 resistance1
Definition: Creature.h:174
void SetNoSearchAssistance(bool val)
Definition: Creature.h:623
uint32 GetEquipmentId() const
Definition: Creature.h:482
uint32 GetCurrentWaypointID()
Definition: Creature.h:750
float m_SightDistance
Definition: Creature.h:789
uint32 Entry
Definition: Creature.h:131
void ResetPickPocketRefillTimer()
Definition: Creature.h:589
uint32 currentwaypoint
Definition: Creature.h:280
uint32 item
Definition: Creature.h:351
uint32 itemId
Definition: Creature.h:396
uint32 m_regenTimer
Definition: Creature.h:836
MovementGeneratorType
Definition: MotionMaster.h:33
std::list< GossipOption > GossipOptionList
Definition: Creature.h:446
uint32 modelid_other_gender
Definition: Creature.h:315
float orientation
Definition: Creature.h:277
SkillType GetRequiredLootSkill() const
Definition: Creature.h:201
std::vector< std::string > Name
Definition: Creature.h:240
bool hasLootRecipient() const
Definition: Creature.h:595
uint32 incrtime
Definition: Creature.h:353
ForcedDespawnDelayEvent(Creature &owner)
Definition: Creature.h:894
void SetCombatPulseDelay(uint32 delay)
Definition: Creature.h:683
uint32 minhealth
Definition: Creature.h:145
uint32 spell
Definition: Creature.h:405
std::string BoxText
Definition: Creature.h:96
std::map< uint32, time_t > CreatureSpellCooldowns
Definition: Creature.h:448
CreatureFamily
uint16 mapid
Definition: Creature.h:270
char const * GetSubName() const
Definition: Creature.h:477
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:573
uint32 phaseMask
Definition: Creature.h:271
uint32 classNum
Definition: Creature.h:167
uint32 ExtendedCost
Definition: Creature.h:354
float bounding_radius
Definition: Creature.h:312
uint32 type_flags
Definition: Creature.h:170
uint32 m_equipmentId
Definition: Creature.h:840
ACE_UINT16 uint16
Definition: Define.h:72
uint32 dmgschool
Definition: Creature.h:156
CreatureSpellCooldowns m_CreatureCategoryCooldowns
Definition: Creature.h:606
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:569
float RangeVariance
Definition: Creature.h:160
ACE_UINT32 uint32
Definition: Define.h:71
time_t lastIncrementTime
Definition: Creature.h:398
uint32 BaseAttackTime
Definition: Creature.h:157
true
Definition: Log.cpp:534
void Say(int32 textId, uint32 language, uint64 TargetGuid)
Definition: Creature.h:570
Gossip_Guard_Spell
Definition: Creature.h:55
CreatureFamily family
Definition: Creature.h:164
Definition: Unit.h:908
void SetRespawnDelay(uint32 delay)
Definition: Creature.h:668
uint32 BaseHealth
Definition: Creature.h:230
uint32 m_waypointID
Definition: Creature.h:860
void TextEmote(const char *text, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Creature.h:568
void SetReactState(ReactStates st)
Definition: Creature.h:495
bool IsReputationGainDisabled()
Definition: Creature.h:775
Definition: Player.h:922
int32 resistance2
Definition: Creature.h:175
std::vector< std::string > SubName
Definition: Creature.h:241
uint32 GetOriginalEntry() const
Definition: Creature.h:786
float posZ
Definition: Creature.h:276
bool IsDamageEnoughForLootingAndReward() const
Definition: Creature.h:779
void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Creature.h:572
void setEmoteState(uint8 emote)
Definition: Creature.h:565
uint32 reqskillvalue
Definition: Creature.h:408
std::vector< std::string > BoxText
Definition: Creature.h:247
Definition: Group.h:154
SpellSchoolMask GetMeleeDamageSchoolMask() const override
Definition: Creature.h:524
uint32 lootid
Definition: Creature.h:171
uint32 HeroicEntry
Definition: Creature.h:132
uint32 count
Definition: Creature.h:397
uint32 NpcFlag
Definition: Creature.h:90