OregonCore  revision fb2a440-git
Your Favourite TBC server
Unit.h
Go to the documentation of this file.
1 
20 #ifndef __UNIT_H
21 #define __UNIT_H
22 
23 #include "Common.h"
24 #include "Object.h"
25 #include "Opcodes.h"
26 #include "SpellAuraDefines.h"
27 #include "UpdateFields.h"
28 #include "SharedDefines.h"
29 #include "ThreatManager.h"
30 #include "HostileRefManager.h"
31 #include "FollowerReference.h"
32 #include "FollowerRefManager.h"
34 #include "MotionMaster.h"
35 #include "DBCStructure.h"
36 #include <list>
37 
38 #define WORLD_TRIGGER 12999
39 
41 {
42  SPELL_INTERRUPT_FLAG_MOVEMENT = 0x01, // why need this for instant?
43  SPELL_INTERRUPT_FLAG_PUSH_BACK = 0x02, // push back
44  SPELL_INTERRUPT_FLAG_INTERRUPT = 0x04, // interrupt
46  SPELL_INTERRUPT_FLAG_DAMAGE = 0x10 // _complete_ interrupt on direct damage?
47 };
48 
50 {
56 };
57 
59 {
60  AURA_INTERRUPT_FLAG_HITBYSPELL = 0x00000001, // 0 removed when getting hit by a negative spell?
61  AURA_INTERRUPT_FLAG_DAMAGE = 0x00000002, // 1 removed by any damage
62  AURA_INTERRUPT_FLAG_CC = 0x00000004, // 2 crowd control
63  AURA_INTERRUPT_FLAG_MOVE = 0x00000008, // 3 removed by any movement
64  AURA_INTERRUPT_FLAG_TURNING = 0x00000010, // 4 removed by any turning
65  AURA_INTERRUPT_FLAG_JUMP = 0x00000020, // 5 removed by entering combat
66  AURA_INTERRUPT_FLAG_NOT_MOUNTED = 0x00000040, // 6 removed by unmounting
67  AURA_INTERRUPT_FLAG_NOT_ABOVEWATER = 0x00000080, // 7 removed by entering water
68  AURA_INTERRUPT_FLAG_NOT_UNDERWATER = 0x00000100, // 8 removed by leaving water
69  AURA_INTERRUPT_FLAG_NOT_SHEATHED = 0x00000200, // 9 removed by unsheathing
70  AURA_INTERRUPT_FLAG_TALK = 0x00000400, // 10 talk to npc / loot? action on creature
71  AURA_INTERRUPT_FLAG_USE = 0x00000800, // 11 mine/use/open action on gameobject
72  AURA_INTERRUPT_FLAG_ATTACK = 0x00001000, // 12 removed by attacking
73  AURA_INTERRUPT_FLAG_CAST = 0x00002000, // 13 ???
74  AURA_INTERRUPT_FLAG_UNK14 = 0x00004000, // 14
75  AURA_INTERRUPT_FLAG_TRANSFORM = 0x00008000, // 15 removed by transform?
76  AURA_INTERRUPT_FLAG_UNK16 = 0x00010000, // 16
77  AURA_INTERRUPT_FLAG_MOUNT = 0x00020000, // 17 misdirect, aspect, swim speed
78  AURA_INTERRUPT_FLAG_NOT_SEATED = 0x00040000, // 18 removed by standing up
79  AURA_INTERRUPT_FLAG_CHANGE_MAP = 0x00080000, // 19 leaving map/getting teleported
80  AURA_INTERRUPT_FLAG_UNATTACKABLE = 0x00100000, // 20 invulnerable or stealth
81  AURA_INTERRUPT_FLAG_UNK21 = 0x00200000, // 21
82  AURA_INTERRUPT_FLAG_TELEPORTED = 0x00400000, // 22
83  AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT = 0x00800000, // 23 removed by entering pvp combat
84  AURA_INTERRUPT_FLAG_DIRECT_DAMAGE = 0x01000000, // 24 removed by any direct damage
86 };
87 
89 {
90  SPELL_PARTIAL_RESIST_NONE = 0, // 0%, full hit
94  SPELL_PARTIAL_RESIST_PCT_100, // 100%, full resist
95 };
96 
97 #define NUM_SPELL_PARTIAL_RESISTS 5
98 
100 {
114  // spellmod 13 unused
126  // spellmod 25, 26 unused
129 };
130 
131 #define MAX_SPELLMOD 32
132 
134 {
140 };
141 
142 typedef std::pair<SpellValueMod, int32> CustomSpellValueMod;
143 class CustomSpellValues : public std::vector<CustomSpellValueMod>
144 {
145  public:
147  {
148  push_back(std::make_pair(mod, value));
149  }
150 };
151 
153 {
155 };
156 
157 #define BASE_MINDAMAGE 1.0f
158 #define BASE_MAXDAMAGE 2.0f
159 #define BASE_ATTACK_TIME 2000
160 
161 // byte value (UNIT_FIELD_BYTES_1,0)
163 {
173 };
174 
175 // byte flag value (UNIT_FIELD_BYTES_1,2)
177 {
180 };
181 
182 // byte flags value (UNIT_FIELD_BYTES_1,3)
184 {
188 };
189 
190 // high byte (3 from 0..3) of UNIT_FIELD_BYTES_2
192 {
193  FORM_NONE = 0x00,
194  FORM_CAT = 0x01,
195  FORM_TREE = 0x02,
196  FORM_TRAVEL = 0x03,
197  FORM_AQUA = 0x04,
198  FORM_BEAR = 0x05,
199  FORM_AMBIENT = 0x06,
200  FORM_GHOUL = 0x07,
208  FORM_TEST = 0x14,
209  FORM_ZOMBIE = 0x15,
212  FORM_SHADOW = 0x1C,
213  FORM_FLIGHT = 0x1D,
214  FORM_STEALTH = 0x1E,
215  FORM_MOONKIN = 0x1F,
217 };
218 
219 // low byte (0 from 0..3) of UNIT_FIELD_BYTES_2
221 {
222  SHEATH_STATE_UNARMED = 0, // non prepared weapon
223  SHEATH_STATE_MELEE = 1, // prepared melee weapon
224  SHEATH_STATE_RANGED = 2 // prepared ranged weapon
225 };
226 
227 #define MAX_SHEATH_STATE 3
228 
229 // byte (1 from 0..3) of UNIT_FIELD_BYTES_2
231 {
236  UNIT_BYTE2_FLAG_AURAS = 0x10, // show possitive auras as positive, and allow its dispel
237  UNIT_BYTE2_FLAG_UNK5 = 0x20, // show negative auras as positive, disallowing dispel
240 };
241 
242 // byte (2 from 0..3) of UNIT_FIELD_BYTES_2
244 {
247 };
248 
249 #define CREATURE_MAX_SPELLS 4
250 #define MAX_SPELL_CHARM 4
251 #define MAX_SPELL_POSSESS 8
252 
253 #define MAX_AGGRO_RESET_TIME 10 // In Seconds
254 #define MAX_AGGRO_RADIUS 45.0f // yards
255 
256 enum Swing
257 {
258  NOSWING = 0,
261 };
262 
264 {
274 };
275 
277 {
278  HITINFO_NORMALSWING = 0x00000000,
279  HITINFO_UNK1 = 0x00000001, // req correct packet structure
280  HITINFO_NORMALSWING2 = 0x00000002,
281  HITINFO_LEFTSWING = 0x00000004,
282  HITINFO_MISS = 0x00000010,
283  HITINFO_ABSORB = 0x00000020, // plays absorb sound
284  HITINFO_RESIST = 0x00000040, // resisted at least some damage
285  HITINFO_CRITICALHIT = 0x00000080,
286  HITINFO_UNK2 = 0x00000100, // wotlk?
287  HITINFO_UNK3 = 0x00002000, // wotlk?
288  HITINFO_GLANCING = 0x00004000,
289  HITINFO_CRUSHING = 0x00008000,
290  HITINFO_NOACTION = 0x00010000,
292 };
293 
295 {
300 };
301 
303 {
308 };
309 
311 {
316 };
317 
318 //i would like to remove this: (it is defined in item.h
320 {
321  NULL_BAG = 0,
322  NULL_SLOT = 255
323 };
324 
325 struct FactionTemplateEntry;
326 struct Modifier;
327 struct SpellEntry;
328 struct SpellValue;
329 
330 class Aura;
331 class Creature;
332 class Spell;
333 class DynamicObject;
334 class GameObject;
335 class Item;
336 class Pet;
337 class PetAura;
338 class UnitAI;
339 class Minion;
340 class Guardian;
341 class ScriptEvent;
342 
344 {
347 };
348 
349 typedef std::list<SpellImmune> SpellImmuneList;
350 
352 {
354  BASE_PCT = 1,
358 };
359 
361 {
364 };
365 
367 {
371 };
372 
374 {
377  AURA_REMOVE_BY_STACK, // at replace by semillar aura
382 };
383 
385 {
386  UNIT_MOD_STAT_STRENGTH, // UNIT_MOD_STAT_STRENGTH..UNIT_MOD_STAT_SPIRIT must be in existing order, it's accessed by index values of Stats enum.
392  UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_HAPPINESS must be in existing order, it's accessed by index values of Powers enum.
397  UNIT_MOD_ARMOR, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existing order, it's accessed by index values of SpellSchools enum.
410  // synonyms
417 };
418 
420 {
426 };
427 
429 {
433 };
434 
436 {
437  ALIVE = 0,
439  CORPSE = 2,
440  DEAD = 3,
443 };
444 
446 {
447  UNIT_STATE_DIED = 0x00000001,
448  UNIT_STATE_MELEE_ATTACKING = 0x00000002, // player is melee attacking someone
449  //UNIT_STATE_MELEE_ATTACK_BY = 0x00000004, // player is melee attack by someone
450  UNIT_STATE_STUNNED = 0x00000008,
451  UNIT_STATE_ROAMING = 0x00000010,
452  UNIT_STATE_CHASE = 0x00000020,
453  //UNIT_STATE_SEARCHING = 0x00000040,
454  UNIT_STATE_FLEEING = 0x00000080,
455  UNIT_STATE_IN_FLIGHT = 0x00000100, // player is in flight mode
456  UNIT_STATE_FOLLOW = 0x00000200,
457  UNIT_STATE_ROOT = 0x00000400,
458  UNIT_STATE_CONFUSED = 0x00000800,
459  UNIT_STATE_DISTRACTED = 0x00001000,
460  UNIT_STATE_ISOLATED = 0x00002000, // area auras do not affect other players
462  UNIT_STATE_CASTING = 0x00008000,
463  UNIT_STATE_POSSESSED = 0x00010000,
464  UNIT_STATE_CHARGING = 0x00020000,
465  UNIT_STATE_JUMPING = 0x00040000,
466  UNIT_STATE_MOVE = 0x00100000,
467  UNIT_STATE_ROTATING = 0x00200000,
468  UNIT_STATE_EVADE = 0x00400000,
469  UNIT_STATE_IGNORE_PATHFINDING = 0x10000000, // do not use pathfinding in any MovementGenerator
470 
479  UNIT_STATE_ALL_STATE = 0xffffffff //(UNIT_STATEE_STOPPED | UNIT_STATEE_MOVING | UNIT_STATEE_IN_COMBAT | UNIT_STATEE_IN_FLIGHT)
480 };
481 
483 {
485  MOVE_RUN = 1,
492 };
493 
494 #define MAX_MOVE_TYPE 8
495 
496 extern float baseMoveSpeed[MAX_MOVE_TYPE];
497 
499 {
503 };
504 
505 #define MAX_ATTACK 3
506 
508 {
511  CR_DODGE = 2,
512  CR_PARRY = 3,
513  CR_BLOCK = 4,
533 };
534 
535 #define MAX_COMBAT_RATING 24
536 
538 {
539  DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells)
540  SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage
541  DOT = 2,
542  HEAL = 3,
543  NODAMAGE = 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
545 };
546 
549 {
550  UNIT_AURAFLAG_ALIVE_INVISIBLE = 0x1, // aura which makes unit invisible for alive
551 };
552 
553 // Value masks for UNIT_FIELD_FLAGS
555 {
556  UNIT_FLAG_UNK_0 = 0x00000001,
557  UNIT_FLAG_NON_ATTACKABLE = 0x00000002, // not attackable
558  UNIT_FLAG_REMOVE_CLIENT_CONTROL = 0x00000004, // This is a legacy flag used to disable movement player's movement while controlling other units, SMSG_CLIENT_CONTROL replaces this functionality clientside now. CONFUSED and FLEEING flags have the same effect on client movement as DISABLE_MOVE_CONTROL in addition to preventing spell casts/autoattack (they all allow climbing steeper hills and emotes while moving)
559  UNIT_FLAG_PVP_ATTACKABLE = 0x00000008, // allow apply pvp rules to attackable state in addition to faction dependent state
560  UNIT_FLAG_RENAME = 0x00000010,
561  UNIT_FLAG_PREPARATION = 0x00000020, // don't take reagents for spells with SPELL_ATTR5_NO_REAGENT_WHILE_PREP
562  UNIT_FLAG_UNK_6 = 0x00000040,
563  UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080, // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE
564  UNIT_FLAG_IMMUNE_TO_PC = 0x00000100, // disables actions by PlayerCharacters (PC) on unit - see Unit::_IsValidAttackTarget, Unit::_IsValidAssistTarget
565  UNIT_FLAG_IMMUNE_TO_NPC = 0x00000200, // disables actions by NonPlayerCharacters (NPC) on unit - see Unit::_IsValidAttackTarget, Unit::_IsValidAssistTarget
566  UNIT_FLAG_LOOTING = 0x00000400, // loot animation
567  UNIT_FLAG_PET_IN_COMBAT = 0x00000800, // in combat?, 2.0.8
568  UNIT_FLAG_PVP = 0x00001000,
569  UNIT_FLAG_SILENCED = 0x00002000, // silenced, 2.1.1
570  UNIT_FLAG_CANNOT_SWIM = 0x00004000, // 2.0.8
571  UNIT_FLAG_UNK_15 = 0x00008000,
572  UNIT_FLAG_NOT_PL_SPELL_TARGET = 0x00010000, // Unit with that flag can not be direct target of player spell.
573  UNIT_FLAG_PACIFIED = 0x00020000,
574  UNIT_FLAG_STUNNED = 0x00040000, // stunned, 2.1.1
575  UNIT_FLAG_IN_COMBAT = 0x00080000,
576  UNIT_FLAG_TAXI_FLIGHT = 0x00100000, // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag
577  UNIT_FLAG_DISARMED = 0x00200000, // disable melee spells casting..., "Required melee weapon" added to melee spells tooltip.
578  UNIT_FLAG_CONFUSED = 0x00400000,
579  UNIT_FLAG_FLEEING = 0x00800000,
580  UNIT_FLAG_PLAYER_CONTROLLED = 0x01000000, // used in spell Eyes of the Beast for pet... let attack by controlled creature
582  UNIT_FLAG_SKINNABLE = 0x04000000,
583  UNIT_FLAG_MOUNT = 0x08000000,
584  UNIT_FLAG_UNK_28 = 0x10000000,
585  UNIT_FLAG_UNK_29 = 0x20000000, // used in Feing Death spell
586  UNIT_FLAG_SHEATHE = 0x40000000
587 };
588 
589 // Value masks for UNIT_FIELD_FLAGS_2
591 {
597 };
598 
599 // Non Player Character flags
601 {
602  UNIT_NPC_FLAG_NONE = 0x00000000,
603  UNIT_NPC_FLAG_GOSSIP = 0x00000001, // 100%
604  UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // guessed, probably ok
605  UNIT_NPC_FLAG_UNK1 = 0x00000004,
606  UNIT_NPC_FLAG_UNK2 = 0x00000008,
607  UNIT_NPC_FLAG_TRAINER = 0x00000010, // 100%
608  UNIT_NPC_FLAG_TRAINER_CLASS = 0x00000020, // 100%
609  UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x00000040, // 100%
610  UNIT_NPC_FLAG_VENDOR = 0x00000080, // 100%
611  UNIT_NPC_FLAG_VENDOR_AMMO = 0x00000100, // 100%, general goods vendor
612  UNIT_NPC_FLAG_VENDOR_FOOD = 0x00000200, // 100%
613  UNIT_NPC_FLAG_VENDOR_POISON = 0x00000400, // guessed
614  UNIT_NPC_FLAG_VENDOR_REAGENT = 0x00000800, // 100%
615  UNIT_NPC_FLAG_REPAIR = 0x00001000, // 100%
616  UNIT_NPC_FLAG_FLIGHTMASTER = 0x00002000, // 100%
617  UNIT_NPC_FLAG_SPIRITHEALER = 0x00004000, // guessed
618  UNIT_NPC_FLAG_SPIRITGUIDE = 0x00008000, // guessed
619  UNIT_NPC_FLAG_INNKEEPER = 0x00010000, // 100%
620  UNIT_NPC_FLAG_BANKER = 0x00020000, // 100%
621  UNIT_NPC_FLAG_PETITIONER = 0x00040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions
622  UNIT_NPC_FLAG_TABARDDESIGNER = 0x00080000, // 100%
623  UNIT_NPC_FLAG_BATTLEMASTER = 0x00100000, // 100%
624  UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100%
625  UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100%
626  UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode
627  UNIT_NPC_FLAG_SPELLCLICK = 0x01000000, // cause client to send 1015 opcode (spell click)
628 };
629 
631 {
632  UNIT_MASK_NONE = 0x00000000,
633  UNIT_MASK_SUMMON = 0x00000001,
634  UNIT_MASK_MINION = 0x00000002,
635  UNIT_MASK_GUARDIAN = 0x00000004,
636  UNIT_MASK_TOTEM = 0x00000008,
637  UNIT_MASK_PET = 0x00000010,
638  UNIT_MASK_PUPPET = 0x00000040,
639  UNIT_MASK_HUNTER_PET = 0x00000080,
641 };
642 
644 {
649 };
650 
652 {
653  DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count) : DRGroup(group), hitTime(t), hitCount(count), stack(0) {}
654 
659 };
660 
662 {
665 };
666 
668 {
669  CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) :
670  damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {}
671 
675 };
676 
677 // Struct for use in Unit::CalculateMeleeDamage
678 // Need create structure like in SMSG_ATTACKERSTATEUPDATE opcode
680 {
681  Unit* attacker; // Attacker
682  Unit* target; // Target for damage
690  // Helper
695  uint32 cleanDamage; // Used only fo rage calcultion
696  MeleeHitOutcome hitOutCome; // @todo remove this field (need use TargetState)
697 };
698 
699 // Spell damage info structure based on structure sending in SMSG_SPELLNONMELEEDAMAGELOG opcode
701 {
702  SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 _SpellID, uint32 _schoolMask) :
703  target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), schoolMask(_schoolMask),
704  absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0) {}
713  bool unused;
716  // Used for help
718 };
719 
721 
723 {
726 };
727 
728 #define MAX_DECLINED_NAME_CASES 5
729 
731 {
732  std::string name[MAX_DECLINED_NAME_CASES];
733 };
734 
736 {
741 };
742 
743 #define CURRENT_FIRST_NON_MELEE_SPELL 1
744 #define CURRENT_MAX_SPELL 4
745 
747 {
748  ACT_ENABLED = 0xC100,
749  ACT_DISABLED = 0x8100,
750  ACT_COMMAND = 0x0700,
751  ACT_REACTION = 0x0600,
752  ACT_CAST = 0x0100,
753  ACT_PASSIVE = 0x0000,
754  ACT_DECIDE = 0x0001
755 };
756 
759 {
763 };
764 
767 {
772 };
773 
775 {
778 };
779 
780 typedef std::list<Player*> SharedVisionList;
781 
783 {
786 };
787 
789 {
794 };
795 
796 #define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START)
797 
798 struct CharmInfo
799 {
800  public:
801  explicit CharmInfo(Unit* unit);
802  ~CharmInfo();
804  {
805  return m_petnumber;
806  }
807  void SetPetNumber(uint32 petnumber, bool statwindow);
808 
810  {
811  m_CommandState = st;
812  }
814  {
815  return m_CommandState;
816  }
818  {
819  return (m_CommandState == state);
820  }
821  //void SetReactState(ReactStates st) { m_reactState = st; }
822  //ReactStates GetReactState() { return m_reactState; }
823  //bool HasReactState(ReactStates state) { return (m_reactState == state); }
824 
825  void InitPossessCreateSpells(bool withAttack = true);
826  void InitCharmCreateSpells();
827  void InitPetActionBar();
828  void InitEmptyActionBar(bool withAttack = true);
829  //return true if successful
830  bool AddSpellToActionBar(uint32 oldid, uint32 newid, ActiveStates newstate = ACT_DECIDE);
831  void ToggleCreatureAutocast(uint32 spellid, bool apply);
832 
834  {
835  return &(PetActionBar[index]);
836  }
838  {
839  return &(m_charmspells[index]);
840  }
841 
842  void SetIsCommandAttack(bool val);
843  bool IsCommandAttack();
844  void SetIsCommandFollow(bool val);
845  bool IsCommandFollow();
846  void SetIsAtStay(bool val);
847  bool IsAtStay();
848  void SetIsFollowing(bool val);
849  bool IsFollowing();
850  void SetIsReturning(bool val);
851  bool IsReturning();
852  void SaveStayPosition();
853  void GetStayPosition(float& x, float& y, float& z);
854 
855  private:
857  UnitActionBarEntry PetActionBar[10];
858  CharmSpellEntry m_charmspells[4];
860  //ReactStates m_reactState;
862  bool m_barInit;
863 
864  //for restoration after charmed
866 
872  float m_stayX;
873  float m_stayY;
874  float m_stayZ;
875 };
876 
877 // for clearing special attacks
878 #define REACTIVE_TIMER_START 4000
879 
881 {
887 };
888 
889 enum
890 {
892 };
893 
894 #define MAX_REACTIVE 6
895 #define SUMMON_SLOT_PET 0
896 #define SUMMON_SLOT_TOTEM 1
897 #define MAX_TOTEM_SLOT 5
898 #define SUMMON_SLOT_MINIPET 5
899 #define SUMMON_SLOT_QUEST 6
900 #define MAX_SUMMON_SLOT 7
901 
902 // delay time next attack to prevent client attack animation problems
903 #define ATTACK_DISPLAY_DELAY 200
904 #define MAX_PLAYER_STEALTH_DETECT_RANGE 30.0f // max distance for detection targets by player
905 
906 struct SpellProcEventEntry; // used only privately
907 
908 class Unit : public WorldObject
909 {
910  friend class ScriptEvent;
911 
912  public:
913  typedef std::set<Unit*> AttackerSet;
914  typedef std::set<Unit*> ControlList;
915  typedef std::pair<uint32, uint8> spellEffectPair;
916  typedef std::multimap< spellEffectPair, Aura*> AuraMap;
917  typedef std::list<Aura*> AuraList;
918  typedef std::list<DiminishingReturn> Diminishing;
919  typedef std::set<AuraType> AuraTypeSet;
920  typedef std::set<uint32> ComboPointHolderSet;
921 
922  ~Unit () override;
923 
924  void AddToWorld() override;
925  void RemoveFromWorld() override;
926 
927  void CleanupsBeforeDelete() override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
928 
929  DiminishingLevels GetDiminishing(DiminishingGroup group);
930  void IncrDiminishing(DiminishingGroup group);
931  void ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, Unit* caster, DiminishingLevels Level);
932  void ApplyDiminishingAura(DiminishingGroup group, bool apply);
934  {
935  m_Diminishing.clear();
936  }
937 
938  //target dependent checks
939  uint32 GetSpellRadiusForTarget(Unit* target, const SpellRadiusEntry* radiusEntry);
940 
941  void Update(uint32 time) override;
942 
944  {
945  m_attackTimer[type] = time;
946  }
947  void resetAttackTimer(WeaponAttackType type = BASE_ATTACK);
949  {
950  return m_attackTimer[type];
951  }
953  {
954  return m_attackTimer[type] == 0;
955  }
956  bool haveOffhandWeapon() const;
957  bool UpdateMeleeAttackingState();
958  bool CanUseEquippedWeapon(WeaponAttackType attackType) const
959  {
960  if (IsInFeralForm())
961  return false;
962 
963  switch (attackType)
964  {
965  default:
966  case BASE_ATTACK:
967  return !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
968  case OFF_ATTACK:
969  case RANGED_ATTACK:
970  return true;
971  }
972  }
973  bool CanDualWield() const
974  {
975  return m_canDualWield;
976  }
977  virtual void SetCanDualWield(bool value) { m_canDualWield = value; }
978  float GetCombatReach() const
979  {
980  return m_floatValues[UNIT_FIELD_COMBATREACH];
981  }
982  float GetMeleeReach() const
983  {
984  float reach = m_floatValues[UNIT_FIELD_COMBATREACH];
985  return reach > MIN_MELEE_REACH ? reach : MIN_MELEE_REACH;
986  }
987  bool IsWithinCombatRange(const Unit* obj, float dist2compare) const;
988  bool IsWithinMeleeRange(Unit* obj, float dist = MELEE_RANGE) const;
989  void GetRandomContactPoint(const Unit* target, float& x, float& y, float& z, float distance2dMin, float distance2dMax) const;
992 
993  void _addAttacker(Unit* pAttacker) // must be called only from Unit::Attack(Unit*)
994  {
995  AttackerSet::iterator itr = m_attackers.find(pAttacker);
996  if (itr == m_attackers.end())
997  m_attackers.insert(pAttacker);
998  }
999  void _removeAttacker(Unit* pAttacker) // must be called only from Unit::AttackStop()
1000  {
1001  m_attackers.erase(pAttacker);
1002  }
1003  Unit* getAttackerForHelper() const; // If someone wants to help, who to give them
1004  bool Attack(Unit* victim, bool meleeAttack);
1005  void CastStop(uint32 except_spellid = 0);
1006  bool AttackStop();
1007  void RemoveAllAttackers();
1008  AttackerSet const& getAttackers() const
1009  {
1010  return m_attackers;
1011  }
1012  bool isAttackingPlayer() const;
1013  Unit* GetVictim() const { return m_attacking; }
1014 
1015  void CombatStop(bool cast = false);
1016  void CombatStopWithPets(bool cast = false);
1017  Unit* SelectNearbyTarget(Unit* exclude = NULL, float dist = NOMINAL_MELEE_RANGE) const;
1018  Player* SelectNearestPlayer(float distance = 0) const;
1019  void SendMeleeAttackStop(Unit* victim = NULL);
1020  void SendMeleeAttackStart(Unit* victim);
1021 
1022  // Minipet related functions
1023  void SetCritterGUID(uint64 guid) { miniPetGuid = guid; }
1024  uint64 GetCritterGUID() const { return miniPetGuid; }
1025 
1027  {
1028  m_state |= f;
1029  }
1030  bool HasUnitState(const uint32 f) const
1031  {
1032  return (m_state & f);
1033  }
1035  {
1036  m_state &= ~f;
1037  }
1038  bool CanFreeMove() const
1039  {
1041  UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && GetOwnerGUID() == 0;
1042  }
1043 
1044  uint32 HasUnitTypeMask(uint32 mask) const { return mask & m_unitTypeMask; }
1045  void AddUnitTypeMask(uint32 mask) { m_unitTypeMask |= mask; }
1046  bool IsSummon() const { return (m_unitTypeMask & UNIT_MASK_SUMMON) != 0; }
1047  bool IsGuardian() const { return (m_unitTypeMask & UNIT_MASK_GUARDIAN) != 0; }
1048  bool IsPet() const { return (m_unitTypeMask & UNIT_MASK_PET) != 0; }
1049  bool IsHunterPet() const{ return (m_unitTypeMask & UNIT_MASK_HUNTER_PET) != 0; }
1050  bool IsTotem() const { return (m_unitTypeMask & UNIT_MASK_TOTEM) != 0; }
1051 
1052  bool IsDuringRemoveFromWorld() const {return m_duringRemoveFromWorld;}
1053 
1054  Pet* ToPet() { if (IsPet()) return reinterpret_cast<Pet*>(this); else return NULL; }
1055  Pet const* ToPet() const { if (IsPet()) return reinterpret_cast<Pet const*>(this); else return NULL; }
1056 
1057  uint8 getLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); }
1058  uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); }
1059  void SetLevel(uint32 lvl);
1060  uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); }
1061  uint32 getRaceMask() const { return 1 << (getRace()-1); }
1062  uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
1063  uint32 getClassMask() const { return 1 << (getClass()-1); }
1064  uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); }
1065 
1066  float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); }
1067  void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); }
1068  uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL); }
1069  void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); }
1070 
1071  uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); }
1072  void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); }
1073 
1074  uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
1075  uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
1076 
1077  bool ShouldRevealHealthTo(Player* player) const;
1078  void SendHealthUpdateDueToCharm(Player* charmer);
1079 
1080  bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
1081  bool HealthBelowPct(int32 pct) const { return GetHealth() < CountPctFromMaxHealth(pct); }
1082  bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); }
1083  bool HealthAbovePct(int32 pct) const { return GetHealth() > CountPctFromMaxHealth(pct); }
1084  bool HealthAbovePctHealed(int32 pct, uint32 heal) const { return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); }
1085  float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
1086  uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePct(GetMaxHealth(), pct); }
1087  uint32 CountPctFromCurHealth(int32 pct) const { return CalculatePct(GetHealth(), pct); }
1088 
1089  void SetHealth( uint32 val);
1090  void SetMaxHealth(uint32 val);
1091  inline void SetFullHealth() { SetHealth(GetMaxHealth()); }
1092  int32 ModifyHealth(int32 val);
1093 
1095  void setPowerType(Powers power);
1096  uint32 GetPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 + power); }
1097  uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1 + power); }
1098  void SetPower(Powers power, uint32 val);
1099  void SetMaxPower(Powers power, uint32 val);
1100  int32 ModifyPower(Powers power, int32 val);
1101  void ApplyPowerMod(Powers power, uint32 val, bool apply);
1102  void ApplyMaxPowerMod(Powers power, uint32 val, bool apply);
1103 
1105  {
1106  return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME + att) / m_modAttackSpeedPct[att]);
1107  }
1108  void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME + att, val*m_modAttackSpeedPct[att]); }
1109  void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply);
1110  void ApplyCastTimePercentMod(float val, bool apply);
1111 
1113  virtual void SetSheath(SheathState sheathed) { SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHEATH_STATE, sheathed); }
1114 
1115  // faction template id
1116  uint32 GetFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); }
1117  void SetFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); }
1118  FactionTemplateEntry const* GetFactionTemplateEntry() const;
1119 
1120  ReputationRank GetReactionTo(Unit const* target) const;
1121  ReputationRank static GetFactionReactionTo(FactionTemplateEntry const* factionTemplateEntry, Unit const* target);
1122 
1123  bool IsHostileTo(Unit const* unit) const;
1124  bool IsHostileToPlayers() const;
1125  bool IsFriendlyTo(Unit const* unit) const;
1126  bool IsNeutralToAll() const;
1127  bool IsInPartyWith(Unit const* unit) const;
1128  bool IsInRaidWith(Unit const* unit) const;
1129  void GetPartyMember(std::list<Unit*>& units, float dist);
1130  void GetRaidMember(std::list<Unit*>& units, float dist);
1131  bool IsContestedGuard() const
1132  {
1133  if (FactionTemplateEntry const* entry = GetFactionTemplateEntry())
1134  return entry->IsContestedGuardFaction();
1135 
1136  return false;
1137  }
1138  bool IsInSanctuary() const;
1139  bool IsPvP() const
1140  {
1141  return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP);
1142  }
1143  void SetPvP(bool state)
1144  {
1145  if (state) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP);
1146  else RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP);
1147  }
1148  uint32 GetCreatureType() const;
1150  {
1151  uint32 creatureType = GetCreatureType();
1152  return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0;
1153  }
1154 
1156  bool IsSitState() const;
1157  bool IsStandState() const;
1158  void SetStandState(uint8 state);
1159 
1162 
1163  bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); }
1164  uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); }
1165  void Mount(uint32 mount, uint32 spellId = 0);
1166  void Dismount();
1167 
1168  bool HasShapeshiftChangingModel() const;
1169 
1170  uint32 GetMaxSkillValueForLevel(Unit const* target = nullptr) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
1171  void RemoveSpellbyDamageTaken(uint32 damage, uint32 spell);
1172  uint32 DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDamage = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const* spellProto = NULL, bool durabilityLoss = true);
1173  void Kill(Unit* victim, bool durabilityLoss = true);
1174 
1175  void ProcDamageAndSpell(Unit* victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const* procSpell = NULL, bool canTrigger = true);
1176  void ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const* procSpell, uint32 damage);
1177 
1178  void HandleEmoteCommand(uint32 anim_id);
1179  void AttackerStateUpdate (Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false);
1180 
1181  float MeleeMissChanceCalc(const Unit* victim, WeaponAttackType attType) const;
1182 
1183  void CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* damageInfo, WeaponAttackType attackType = BASE_ATTACK);
1184  void DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss);
1185 
1186  void CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellEntry const* spellInfo, WeaponAttackType attackType = BASE_ATTACK, bool crit = false);
1187  void DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss);
1188 
1189  float MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const;
1190  SpellMissInfo MeleeSpellHitResult(Unit* victim, SpellEntry const* spell, bool cMiss = true);
1191  SpellMissInfo MagicSpellHitResult(Unit* victim, SpellEntry const* spell);
1192  SpellMissInfo SpellHitResult(Unit* victim, SpellEntry const* spell, bool canReflect = false, bool canMiss = true);
1193 
1194  float GetUnitDodgeChance() const;
1195  float GetUnitParryChance() const;
1196  float GetUnitBlockChance() const;
1197  float GetUnitCriticalChance(WeaponAttackType attackType, const Unit* victim) const;
1198  int32 GetMechanicResistChance(const SpellEntry* spell);
1199  bool CanUseAttackType(uint8 attacktype) const;
1200 
1201  virtual uint32 GetShieldBlockValue() const = 0;
1202  uint32 GetUnitMeleeSkill(Unit const* target = NULL) const
1203  {
1204  return (target ? getLevelForTarget(target) : getLevel()) * 5;
1205  }
1206  uint32 GetDefenseSkillValue(Unit const* target = NULL) const;
1207  uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const;
1208  float GetWeaponProcChance() const;
1209  float GetPPMProcChance(uint32 WeaponSpeed, float PPM) const;
1210 
1211  MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackType attType) const;
1212  MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance, bool SpellCasted) const;
1213 
1214  bool IsVendor() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR); }
1215  bool IsTrainer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER); }
1216  bool IsQuestGiver() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); }
1217  bool IsGossip() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); }
1218  bool IsTaxi() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER); }
1219  bool IsGuildMaster() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER); }
1220  bool IsBattleMaster() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER); }
1221  bool IsBanker() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER); }
1222  bool IsInnkeeper() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER); }
1223  bool IsSpiritHealer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER); }
1224  bool IsSpiritGuide() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE); }
1226  bool IsAuctioner() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER); }
1227  bool IsArmorer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR); }
1228  bool isServiceProvider() const
1229  {
1230  return HasFlag(UNIT_NPC_FLAGS,
1235  }
1237  bool IsCritter() const { return GetCreatureType() == CREATURE_TYPE_CRITTER; }
1238  bool IsPlayer() const{ return GetTypeId() == TYPEID_PLAYER; }
1239  bool IsInFlight() const { return HasUnitState(UNIT_STATE_IN_FLIGHT); }
1240 
1241  // Is the unit casting, or has recently casted a combat spell but not in combat yet?
1242  bool IsInitiatingCombat() const { return m_initiatingCombat; }
1243  bool IsInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); }
1244  bool IsPetInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); }
1245  bool IsInCombatWith(Unit const* who) const;
1246  void CombatStart(Unit* target, bool initialAggro = true);
1247  void SetInCombatState(bool PvP, Unit* enemy = NULL);
1248  void SetInitiatingCombat(bool flag) { m_initiatingCombat = flag; }
1249 
1250  void SetInCombatWith(Unit* enemy);
1251  void ClearInCombat();
1252  void ClearInPetCombat();
1254  uint32 IsInPvPCombat() const { return m_CombatTimer.GetInterval() != 0; }
1255 
1256  uint32 GetAuraCount(uint32 spellId) const;
1257  bool HasAuraType(AuraType auraType) const;
1258  bool HasAuraTypeWithCaster(AuraType auratype, uint64 caster) const;
1259  bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const;
1260  bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint64 familyFlags) const;
1261  bool HasNegativeAuraWithInterruptFlag(uint32 flag);
1262  bool HasAura(uint32 spellId, uint8 effIndex = 0) const { return m_Auras.find(spellEffectPair(spellId, effIndex)) != m_Auras.end(); }
1263  bool HasHigherRankOfAura(uint32 spellid, uint8 effIndex) const;
1264 
1265  bool virtual HasSpell(uint32 /*spellID*/) const
1266  {
1267  return false;
1268  }
1269 
1270  bool HasStealthAura() const { return HasAuraType(SPELL_AURA_MOD_STEALTH); }
1271  bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); }
1272  bool IsFeared() const { return HasAuraType(SPELL_AURA_MOD_FEAR); }
1273  bool IsInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT); }
1274  bool IsPolymorphed() const;
1275 
1276  bool isFrozen() const;
1277 
1278  bool isTargetableForAttack(bool checkFakeDeath = true) const;
1279 
1280  bool IsValidAttackTarget(Unit const* target) const;
1281  bool _IsValidAttackTarget(Unit const* target, SpellEntry const* bySpell, WorldObject const* obj = NULL) const;
1282 
1283  bool isAttackableByAOE(float x = 0, float y = 0, float z = 0, bool LosCheck = false) const;
1284 
1285  bool IsValidAssistTarget(Unit const* target) const;
1286  bool _IsValidAssistTarget(Unit const* target, SpellEntry const* bySpell) const;
1287 
1288  virtual bool IsInWater() const;
1289  virtual bool IsUnderWater() const;
1290  bool isInAccessiblePlaceFor(Creature const* c) const;
1291  virtual uint32 GetHighestLearnedRankOf(uint32 spellid) const
1292  {
1293  return spellid;
1294  }
1295 
1296  void SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, bool critical = false);
1297  void SendEnergizeSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, Powers powertype);
1298  void EnergizeBySpell(Unit* victim, uint32 SpellID, uint32 Damage, Powers powertype);
1299  uint32 SpellNonMeleeDamageLog(Unit* victim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true);
1300  void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1301  void CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1302  void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1303  void CastCustomSpell(uint32 spellId, SpellValueMod mod, uint32 value, Unit* Victim = NULL, bool triggered = true, Item* castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1304  void CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* Victim = NULL, bool triggered = true, Item* castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1305  void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1306  void CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
1307  void AddAura(uint32 spellId, Unit* target);
1308 
1309  void DeMorph();
1310 
1311  void SendAttackStateUpdate(CalcDamageInfo* damageInfo);
1312  void SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount);
1313  void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log);
1314  void SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false);
1315  void SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo);
1316  void SendSpellDamageImmune(Unit* target, uint32 spellId);
1317 
1318  virtual bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
1319  bool SetPosition(const Position& pos, bool teleport = false)
1320  {
1321  return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport);
1322  }
1323 
1324  void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false);
1325  void SendTeleportPacket(Position& pos);
1326 
1327  void SendMovementFlagUpdate(bool self = false);
1328 
1329  void BuildHeartBeatMsg(WorldPacket* data) const;
1330  void BuildMovementPacket(ByteBuffer *data) const;
1331 
1332  bool isMoving() const
1333  {
1334  return HasUnitMovementFlag(MOVEMENTFLAG_MOVING) && !HasUnitMovementFlag(MOVEMENTFLAG_ROOT);
1335  }
1336  bool IsAlive() const { return (m_deathState == ALIVE); }
1337  bool isDying() const { return (m_deathState == JUST_DIED); }
1338  bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); }
1339  DeathState getDeathState() const { return m_deathState; }
1340  virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet
1341 
1343  {
1344  return GetUInt64Value(UNIT_FIELD_SUMMONEDBY);
1345  }
1347  {
1348  return GetUInt64Value(UNIT_FIELD_CREATEDBY);
1349  }
1350  void SetCreatorGUID(uint64 creator)
1351  {
1352  SetUInt64Value(UNIT_FIELD_CREATEDBY, creator);
1353  }
1355  {
1356  return GetUInt64Value(UNIT_FIELD_SUMMON);
1357  }
1359  {
1360  SetUInt64Value(UNIT_FIELD_SUMMON, guid);
1361  }
1363  {
1364  return GetUInt64Value(UNIT_FIELD_CHARMEDBY);
1365  }
1367  {
1368  SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner);
1369  }
1371  {
1372  return GetUInt64Value(UNIT_FIELD_CHARM);
1373  }
1374  void SetPetGUID(uint64 guid)
1375  {
1376  m_SummonSlot[SUMMON_SLOT_PET] = guid;
1377  }
1379  {
1380  return m_SummonSlot[SUMMON_SLOT_PET];
1381  }
1382 
1384  {
1385  return m_ControlledByPlayer;
1386  }
1388  {
1389  return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID();
1390  }
1392  {
1393  if (uint64 guid = GetCharmerOrOwnerGUID())
1394  return guid;
1395  return GetGUID();
1396  }
1398  {
1399  return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID());
1400  }
1401  Player* GetAffectingPlayer() const;
1402 
1403  Player* GetSpellModOwner() const;
1404 
1405  Unit* GetOwner() const;
1406  Guardian* GetGuardianPet() const;
1407  Minion* GetFirstMinion() const;
1408  Unit* GetCharmer() const;
1409  Unit* GetCharm() const;
1411  {
1412  return GetCharmerGUID() ? GetCharmer() : GetOwner();
1413  }
1415  {
1416  if (Unit* u = GetCharmerOrOwner())
1417  return u;
1418 
1419  return (Unit*)this;
1420  }
1421  Player* GetCharmerOrOwnerPlayerOrPlayerItself() const;
1422 
1423  void SetMinion(Minion* minion, bool apply);
1424  void RemoveAllMinionsByEntry(uint32 entry);
1425  void SetCharm(Unit* target, bool apply);
1426  void SetCharmedBy(Unit* charmer, CharmType type);
1427  void RemoveCharmedBy(Unit* charmer);
1428  void RestoreFaction();
1429 
1430  ControlList m_Controlled;
1431  Unit* GetFirstControlled() const;
1432  void RemoveAllControlled();
1433 
1434  bool isCharmed() const
1435  {
1436  return GetCharmerGUID() != 0;
1437  }
1438  bool isPossessed() const
1439  {
1440  return HasUnitState(UNIT_STATE_POSSESSED);
1441  }
1442  bool isPossessedByPlayer() const
1443  {
1444  return HasUnitState(UNIT_STATE_POSSESSED) && IS_PLAYER_GUID(GetCharmerGUID());
1445  }
1446  bool isPossessing() const
1447  {
1448  if (Unit* u = GetCharm())
1449  return u->isPossessed();
1450  else
1451  return false;
1452  }
1453  bool isPossessing(Unit* u) const
1454  {
1455  return u->isPossessed() && GetCharmGUID() == u->GetGUID();
1456  }
1457 
1459  {
1460  return m_charmInfo;
1461  }
1462  CharmInfo* InitCharmInfo();
1463  void DeleteCharmInfo();
1464  void UpdateCharmAI();
1465  SharedVisionList const& GetSharedVisionList()
1466  {
1467  return m_sharedVision;
1468  }
1469  void AddPlayerToVision(Player* plr);
1470  void RemovePlayerFromVision(Player* plr);
1471  bool HasSharedVision() const
1472  {
1473  return !m_sharedVision.empty();
1474  }
1475  void RemoveBindSightAuras();
1476  void RemoveCharmAuras();
1477 
1478  Pet* CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id = 0);
1479 
1480  bool AddAura(Aura* aur);
1481 
1482  void RemoveAura(AuraMap::iterator& i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
1483  void RemoveAura(uint32 spellId, uint32 effindex, Aura* except = NULL);
1484  void RemoveSingleAuraFromStackByDispel(uint32 spellId);
1485  void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex);
1486  void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL);
1487  void RemoveAurasDueToItemSpell(Item* castItem, uint32 spellId);
1488  void RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID);
1489  void SetAurasDurationByCasterSpell(uint32 spellId, uint64 casterGUID, int32 duration);
1490  Aura* GetAuraByCasterSpell(uint32 spellId, uint64 casterGUID);
1491  void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit* dispeler);
1492  void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer);
1493  void RemoveAurasByType(AuraType auraType, uint64 casterGUID = 0, Aura* except = NULL, bool negative = true, bool positive = true);
1494  void RemoveAurasDueToSpellByCancel(uint32 spellId);
1495  void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo, Unit* caster);
1496  void RemoveNotOwnSingleTargetAuras();
1497 
1498  void RemoveSpellsCausingAura(AuraType auraType);
1499  void RemoveAuraTypeByCaster(AuraType auraType, uint64 casterGUID);
1500  void RemoveRankAurasDueToSpell(uint32 spellId);
1501  bool RemoveNoStackAurasDueToAura(Aura* Aur);
1502  void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except = 0);
1503  void RemoveAurasWithAttribute(uint32 flags);
1504  void RemoveAurasWithDispelType(DispelType type);
1505  void RemoveMovementImpairingAuras();
1506 
1507  void RemoveAllAuras();
1508  void RemoveArenaAuras();
1509  void RemoveAllAurasOnDeath();
1510  void DelayAura(uint32 spellId, uint32 effindex, int32 delaytime);
1511 
1512  float GetResistanceBuffMods(SpellSchools school, bool positive) const
1513  {
1514  return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + school);
1515  }
1516  void SetResistanceBuffMods(SpellSchools school, bool positive, float val)
1517  {
1518  SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + school, val);
1519  }
1520  void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply)
1521  {
1522  ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + school, val, apply);
1523  }
1524  void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply)
1525  {
1526  ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + school, val, apply);
1527  }
1529  {
1530  for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0 + i, 0);
1531  for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0 + i, 0);
1532  }
1533  void ApplyStatBuffMod(Stats stat, float val, bool apply)
1534  {
1535  ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0 + stat : UNIT_FIELD_NEGSTAT0 + stat), val, apply);
1536  }
1537  void ApplyStatPercentBuffMod(Stats stat, float val, bool apply)
1538  {
1539  ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0 + stat, val, apply);
1540  ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0 + stat, val, apply);
1541  }
1542  void SetCreateStat(Stats stat, float val)
1543  {
1544  m_createStats[stat] = val;
1545  }
1547  {
1548  SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val);
1549  }
1551  {
1552  return GetUInt32Value(UNIT_FIELD_BASE_HEALTH);
1553  }
1555  {
1556  SetUInt32Value(UNIT_FIELD_BASE_MANA, val);
1557  }
1559  {
1560  return GetUInt32Value(UNIT_FIELD_BASE_MANA);
1561  }
1562  uint32 GetCreatePowers(Powers power) const;
1563  float GetPosStat(Stats stat) const
1564  {
1565  return GetFloatValue(UNIT_FIELD_POSSTAT0 + stat);
1566  }
1567  float GetNegStat(Stats stat) const
1568  {
1569  return GetFloatValue(UNIT_FIELD_NEGSTAT0 + stat);
1570  }
1571  float GetCreateStat(Stats stat) const
1572  {
1573  return m_createStats[stat];
1574  }
1575 
1576  void SetCurrentCastedSpell(Spell* pSpell);
1577  virtual void ProhibitSpellSchool(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/) { }
1578  void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true);
1579  void FinishSpell(CurrentSpellTypes spellType, bool ok = true);
1580 
1581  // set withDelayed to true to account delayed spells as casted
1582  // delayed+channeled spells are always accounted as casted
1583  // we can skip channeled or delayed checks using flags
1584  bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false) const;
1585 
1586  // set withDelayed to true to interrupt delayed spells too
1587  // delayed+channeled spells are always interrupted
1588  void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0, bool withInstant = true);
1589 
1590  uint64 GetTarget() const { return GetUInt64Value(UNIT_FIELD_TARGET); }
1591  void SetTarget(uint64 guid = 0) { SetUInt64Value(UNIT_FIELD_TARGET, guid); };
1592 
1594  {
1595  return m_currentSpells[spellType];
1596  }
1597  Spell* GetCurrentSpell(uint32 spellType) const
1598  {
1599  return m_currentSpells[spellType];
1600  }
1601  Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
1602  int32 GetCurrentSpellCastTime(uint32 spell_id) const;
1603 
1604  // Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING
1605  bool CanMoveDuringChannel() const;
1606 
1607  uint64 m_SummonSlot[MAX_SUMMON_SLOT];
1608  uint64 m_ObjectSlot[4];
1609 
1613  bool IsInFeralForm() const
1614  {
1615  return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR;
1616  }
1617  bool IsInTravelForm() const
1618  {
1619  return m_form == FORM_TRAVEL;
1620  }
1621  bool IsInFlightForm() const
1622  {
1623  return m_form == FORM_FLIGHT_EPIC || m_form == FORM_FLIGHT;
1624  }
1629 
1630  float m_threatModifier[MAX_SPELL_SCHOOL];
1631  float m_modAttackSpeedPct[3];
1632 
1634 
1635  // Event handler
1637 
1638  // stat system
1639  bool HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply);
1640  void SetModifierValue(UnitMods unitMod, UnitModifierType modifierType, float value)
1641  {
1642  m_auraModifiersGroup[unitMod][modifierType] = value;
1643  }
1644  float GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const;
1645  float GetTotalStatValue(Stats stat) const;
1646  float GetTotalAuraModValue(UnitMods unitMod) const;
1647  SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const;
1648  Stats GetStatByAuraGroup(UnitMods unitMod) const;
1649  Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const;
1650  bool CanModifyStats() const
1651  {
1652  return m_canModifyStats;
1653  }
1654  void SetCanModifyStats(bool modifyStats)
1655  {
1656  m_canModifyStats = modifyStats;
1657  }
1658  virtual bool UpdateStats(Stats stat) = 0;
1659  virtual bool UpdateAllStats() = 0;
1660  virtual void UpdateResistances(uint32 school) = 0;
1661  virtual void UpdateAllResistances();
1662  virtual void UpdateArmor() = 0;
1663  virtual void UpdateMaxHealth() = 0;
1664  virtual void UpdateMaxPower(Powers power) = 0;
1665  virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0;
1666  virtual void UpdateDamagePhysical(WeaponAttackType attType);;
1667  float GetTotalAttackPowerValue(WeaponAttackType attType) const;
1668  float GetWeaponDamageRange(WeaponAttackType attType , WeaponDamageRange type) const;
1669  void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; }
1670  virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) = 0;
1671  uint32 CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct);
1672  float GetAPMultiplier(WeaponAttackType attType, bool normalized);
1673 
1674  bool isInFrontInMap(Unit const* target, float distance, float arc = M_PI) const;
1675  void SetInFront(Unit const* target)
1676  {
1677  if (!HasUnitState(UNIT_STATE_CANNOT_TURN))
1678  SetOrientation(GetAngle(target));
1679  }
1680  void SetInFront(float x, float y)
1681  {
1682  if(!HasUnitState(UNIT_STATE_CANNOT_TURN))
1683  SetOrientation(GetAngle(x,y));
1684  }
1685 
1686  bool isInBackInMap(Unit const* target, float distance, float arc = M_PI) const;
1687  void SetFacingTo(float ori);
1688  void SetFacingToObject(WorldObject* pObject);
1689 
1690  // Visibility system
1691  bool IsVisible() const { return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true; }
1692  void SetVisible(bool x);
1693 
1694  // common function for visibility checks for player/creatures with detection code
1695  bool isValid() const override { return WorldObject::isValid(); }
1696  void SetPhaseMask(uint32 newPhaseMask, bool update) override;// overwrite WorldObject::SetPhaseMask
1697  void UpdateObjectVisibility(bool forced = true) override;
1698 
1699  bool isInvisibleForAlive() const;
1700 
1702  {
1703  return m_scAuras;
1704  }
1705  AuraList const& GetSingleCastAuras() const
1706  {
1707  return m_scAuras;
1708  }
1709 
1712 
1713  // Threat related methods
1714  bool CanHaveThreatList() const;
1715  void AddThreat(Unit* victim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const* threatSpell = NULL);
1716  void AddAssistThreat(Unit* victim, float threatToAdd, SpellEntry const* threatSpell);
1717  float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL);
1718  void DeleteThreatList();
1719  void TauntApply(Unit* victim);
1720  void TauntFadeOut(Unit* taunter);
1722  {
1723  return m_ThreatManager;
1724  }
1725  void addHatedBy(HostileReference* pHostileReference)
1726  {
1727  m_HostileRefManager.insertFirst(pHostileReference);
1728  };
1729  void removeHatedBy(HostileReference* /*pHostileReference*/)
1730  {
1731  /* nothing to do yet */
1732  }
1734  {
1735  return m_HostileRefManager;
1736  }
1737 
1738  Aura* GetAura(uint32 spellId, uint32 effindex);
1739  AuraMap& GetAuras()
1740  {
1741  return m_Auras;
1742  }
1743  AuraMap const& GetAuras() const
1744  {
1745  return m_Auras;
1746  }
1747  AuraList const& GetAurasByType(AuraType type) const
1748  {
1749  return m_modAuras[type];
1750  }
1751  void ApplyAuraProcTriggerDamage(Aura* aura, bool apply);
1752 
1753  int32 GetTotalAuraModifier(AuraType auratype) const;
1754  float GetTotalAuraMultiplier(AuraType auratype) const;
1755  int32 GetMaxPositiveAuraModifier(AuraType auratype) const;
1756  int32 GetMaxNegativeAuraModifier(AuraType auratype) const;
1757 
1758  int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1759  float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1760  int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1761  int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
1762 
1763  int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1764  float GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const;
1765  int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1766  int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
1767 
1768  Aura* GetDummyAura(uint32 spell_id) const;
1769 
1771 
1773  {
1774  return m_interruptMask;
1775  }
1777  {
1778  m_interruptMask |= mask;
1779  }
1780  void UpdateInterruptMask();
1781 
1783  {
1784  return GetUInt32Value(UNIT_FIELD_DISPLAYID);
1785  }
1786  void SetDisplayId(uint32 modelId);
1788  {
1789  return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID);
1790  }
1792  {
1793  SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId);
1794  }
1795  void setTransForm(uint32 spellid)
1796  {
1797  m_transform = spellid;
1798  }
1800  {
1801  return m_transform;
1802  }
1803  void AddDynObject(DynamicObject* dynObj);
1804  void RemoveDynObject(uint32 spellid);
1806  {
1807  m_dynObjGUIDs.remove(guid);
1808  }
1809  void RemoveAllDynObjects();
1810  void AddGameObject(GameObject* gameObj);
1811  void RemoveGameObject(GameObject* gameObj, bool del);
1812  void RemoveGameObject(uint32 spellid, bool del);
1813  void RemoveAllGameObjects();
1814  DynamicObject* GetDynObject(uint32 spellId, uint32 effIndex);
1815  DynamicObject* GetDynObject(uint32 spellId);
1816  void ModifyAuraState(AuraState flag, bool apply);
1817  bool HasAuraState(AuraState flag) const
1818  {
1819  return HasFlag(UNIT_FIELD_AURASTATE, 1 << (flag - 1));
1820  }
1821  void UnsummonAllTotems();
1822  int32 SpellBaseDamageBonus(SpellSchoolMask schoolMask);
1823  int32 SpellBaseHealingBonus(SpellSchoolMask schoolMask);
1824  int32 SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit* victim);
1825  int32 SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit* victim);
1826  uint32 SpellDamageBonus(Unit* victim, SpellEntry const* spellProto, uint32 damage, DamageEffectType damagetype);
1827  uint32 SpellHealingBonus(SpellEntry const* spellProto, uint32 healamount, DamageEffectType damagetype, Unit* victim);
1828  bool isSpellBlocked(Unit* victim, SpellEntry const* spellProto, WeaponAttackType attackType = BASE_ATTACK);
1829  bool isSpellCrit(Unit* victim, SpellEntry const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK);
1830  uint32 SpellCriticalBonus(SpellEntry const* spellProto, uint32 damage, Unit* victim);
1831 
1832  void SetLastManaUse(uint32 spellCastTime)
1833  {
1834  m_lastManaUse = spellCastTime;
1835  }
1836  bool IsUnderLastManaUseEffect() const;
1837 
1838  void SetContestedPvP(Player* attackedPlayer = NULL);
1839 
1840  void MeleeDamageBonus(Unit* victim, uint32* damage, WeaponAttackType attType, SpellEntry const* spellProto = NULL);
1841  uint32 GetCastingTimeForBonus(SpellEntry const* spellProto, DamageEffectType damagetype, uint32 CastingTime);
1842 
1843  void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
1844  void ApplySpellDispelImmunity(const SpellEntry* spellProto, DispelType type, bool apply);
1845  virtual bool IsImmuneToSpell(SpellEntry const* spellInfo, bool useCharges = false); // redefined in Creature
1846  bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask, bool useCharges = false);
1847  bool IsImmunedToDamage(SpellEntry const* spellInfo) const;
1848  virtual bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool castOnSelf) const; // redefined in Creature
1849 
1850  static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo = NULL, uint8 effIndex = MAX_SPELL_EFFECTS);
1851  uint32 CalculateEffectiveMagicResistance(Unit* attacker, SpellSchoolMask schoolMask) const;
1852  float CalculateMagicResistanceMitigation(Unit* attacker, uint32 resistance, bool binary) const;
1853  uint32 CalcArmorReducedDamage(Unit* victim, const uint32 damage);
1854  void CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32* absorb, uint32* resist, SpellEntry const* spellInfo = NULL, bool binary = false);
1855 
1856  void UpdateSpeed(UnitMoveType mtype, bool forced);
1857  float GetSpeed(UnitMoveType mtype) const;
1858  float GetSpeedRate(UnitMoveType mtype) const
1859  {
1860  return m_speed_rate[mtype];
1861  }
1862  void SetSpeed(UnitMoveType mtype, float rate, bool forced = false);
1863 
1864  bool isHover() const
1865  {
1866  return HasAuraType(SPELL_AURA_HOVER);
1867  }
1868 
1869  void _RemoveAllAuraMods();
1870  void _ApplyAllAuraMods();
1871 
1872  int32 CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 basePoints, Unit const* target);
1873  int32 CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target);
1874  float CalculateLevelPenalty(SpellEntry const* spellProto) const;
1875  void ModSpellCastTime(SpellEntry const* spellProto, int32& castTime, Spell* spell);
1876  void ModSpellDurationTime(SpellEntry const* spellProto, int32& duration, Spell* spell);
1877 
1879  {
1880  m_FollowingRefManager.insertFirst(pRef);
1881  }
1883  {
1884  /* nothing to do yet */
1885  }
1886  static Unit* GetUnit(WorldObject& object, uint64 guid);
1887  static Player* GetPlayer(WorldObject& object, uint64 guid);
1888  static Creature* GetCreature(WorldObject& object, uint64 guid);
1889 
1891  {
1892  return &i_motionMaster;
1893  }
1894 
1895  bool IsStopped() const
1896  {
1897  return !(HasUnitState(UNIT_STATE_MOVING));
1898  }
1899  void StopMoving();
1900 
1901  void AddUnitMovementFlag(uint32 f) { m_movementInfo.moveFlags |= f; }
1902  void RemoveUnitMovementFlag(uint32 f) { m_movementInfo.moveFlags &= ~f; }
1903  bool HasUnitMovementFlag(uint32 f) const { return m_movementInfo.moveFlags & f; }
1904  uint32 GetUnitMovementFlags() const { return m_movementInfo.moveFlags; }
1905  void SetUnitMovementFlags(uint32 f) { m_movementInfo.moveFlags = f; }
1906 
1908 
1909  void SetControlled(bool apply, UnitState state);
1910  void SetFeared(bool apply/*, uint64 casterGUID = 0, uint32 spellID = 0*/);
1911  void SetConfused(bool apply/*, uint64 casterGUID = 0, uint32 spellID = 0*/);
1912  void SetStunned(bool apply);
1913 
1914  void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false);
1915  void SendMonsterMoveWithSpeedToCurrentDestination(float speed);
1916 
1918  {
1919  m_ComboPointHolders.insert(lowguid);
1920  }
1922  {
1923  m_ComboPointHolders.erase(lowguid);
1924  }
1925  void ClearComboPointHolders();
1926 
1927  //----------Pet responses methods-----------------
1928  void SendPetCastFail(uint32 spellid, SpellCastResult msg);
1929  void SendPetActionFeedback (uint8 msg);
1930  void SendPetTalk (uint32 pettalk);
1931  void SendPetSpellCooldown (uint32 spellid, time_t cooltime);
1932  void SendPetClearCooldown (uint32 spellid);
1933  void SendPetAIReaction(uint64 guid);
1934  //----------End of Pet responses methods----------
1935 
1937  {
1938  GetMotionMaster()->propagateSpeedChange();
1939  }
1940 
1941  // reactive attacks
1942  void ClearAllReactives();
1944  {
1945  m_reactiveTimer[reactive] = REACTIVE_TIMER_START;
1946  }
1947  void UpdateReactives(uint32 p_time);
1948 
1949  // group updates
1950  void UpdateAuraForGroup(uint8 slot);
1951 
1952  // pet auras
1953  typedef std::set<PetAura const*> PetAuraSet;
1954  PetAuraSet m_petAuras;
1955  void AddPetAura(PetAura const* petSpell);
1956  void RemovePetAura(PetAura const* petSpell);
1957 
1959  {
1960  m_reducedThreatPercent = pct;
1961  m_misdirectionTargetGUID = guid;
1962  }
1964  {
1965  return m_reducedThreatPercent;
1966  }
1968  {
1969  return m_misdirectionTargetGUID ? GetUnit(*this, m_misdirectionTargetGUID) : NULL;
1970  }
1971  virtual float GetFollowAngle() const { return static_cast<float>(M_PI/2); }
1972 
1973  bool IsFlying() const { return m_movementInfo.HasMovementFlag((MovementFlags)(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_LEVITATING)); }
1974  bool IsFalling() const;
1975  bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALK_MODE); }
1976  bool IsRooted() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_ROOT); }
1977 
1978  void SetRooted(bool apply);
1979 
1980  virtual bool SetWalk(bool enable);
1981  virtual bool SetSwim(bool enable);
1982  virtual bool SetLevitate(bool apply, bool packetOnly = false);
1983  virtual bool SetCanFly(bool enable, bool packetOnly = false);
1984  virtual bool SetWaterWalking(bool enable, bool packetOnly = false);
1985  virtual bool SetFeatherFall(bool enable, bool packetOnly = false);
1986  virtual bool SetHover(bool enable, bool packetOnly = false);
1987 
1988  bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_LEVITATING); }
1989 
1990  bool IsAIEnabled, NeedChangeAI;
1993 
1994  // Part of Evade mechanics
1995  time_t GetLastDamagedTime() const { return _lastDamagedTime; }
1996  void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; }
1997 
1998  TempSummon* ToTempSummon() { if (IsSummon()) return reinterpret_cast<TempSummon*>(this); else return NULL; }
1999  TempSummon const* ToTempSummon() const { if (IsSummon()) return reinterpret_cast<TempSummon const*>(this); else return NULL; }
2000 
2001  protected:
2002  explicit Unit (bool isWorldObject);
2003 
2005 
2006  void _UpdateSpells(uint32 time);
2007  void _DeleteAuras();
2008 
2009  void _UpdateAutoRepeatSpell();
2011 
2012  // Unit is initiating combat by casting a spell at a target
2014 
2015  uint32 m_attackTimer[MAX_ATTACK];
2016 
2017  float m_createStats[MAX_STATS];
2018 
2019  AttackerSet m_attackers;
2021 
2023 
2024  AuraMap m_Auras;
2025  AuraMap::iterator m_AurasUpdateIterator;
2027 
2028  typedef std::list<uint64> DynObjectGUIDs;
2029  DynObjectGUIDs m_dynObjGUIDs;
2030 
2031  std::list<GameObject*> m_gameObj;
2034  AuraList m_removedAuras;
2035 
2036  AuraList m_modAuras[TOTAL_AURAS];
2037  AuraList m_scAuras; // casted singlecast auras
2039  AuraList m_ccAuras;
2041 
2042  float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END];
2043  float m_weaponDamage[MAX_ATTACK][2];
2045  //std::list< spellEffectPair > AuraSpells[TOTAL_AURAS]; // @todo use this if ok for mem
2046 
2047  float m_speed_rate[MAX_MOVE_TYPE];
2048 
2051  SharedVisionList m_sharedVision;
2052 
2053  virtual SpellSchoolMask GetMeleeDamageSchoolMask() const;
2054 
2056 
2058 
2059  uint32 m_reactiveTimer[MAX_REACTIVE];
2060 
2062 
2063  void DisableSpline();
2064 
2065  bool IsAlwaysVisibleFor(WorldObject const* seer) const override;
2066  bool IsAlwaysDetectableFor(WorldObject const* seer) const override;
2067 
2068  private:
2069  bool IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const*& spellProcEvent);
2070  bool HandleDummyAuraProc( Unit* victim, uint32 damage, Aura* triggredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
2071  bool HandleHasteAuraProc( Unit* victim, uint32 damage, Aura* triggredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
2072  bool HandleProcTriggerSpell(Unit* victim, uint32 damage, Aura* triggredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
2073  bool HandleOverrideClassScriptAuraProc(Unit* victim, Aura* triggredByAura, SpellEntry const* procSpell, uint32 cooldown);
2074  bool HandleMendingAuraProc(Aura* triggeredByAura);
2075 
2076  uint32 m_state; // Even derived shouldn't modify
2078 
2079  Spell* m_currentSpells[CURRENT_MAX_SPELL];
2080 
2082 
2083  Diminishing m_Diminishing;
2084  // Manage all Units threatening us
2085  // ThreatManager m_ThreatManager;
2086  // Manage all Units that are threatened by us
2088 
2090 
2091  ComboPointHolderSet m_ComboPointHolders;
2092 
2095 
2096  bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world
2097 
2099 
2100  time_t _lastDamagedTime; // Part of Evade mechanics
2101 
2102  void UpdateSplineMovement(uint32 t_diff);
2103 };
2104 
2105 namespace Oregon
2106 {
2107 template<class T>
2108 void RandomResizeList(std::list<T>& _list, uint32 _size)
2109 {
2110  while (_list.size() > _size)
2111  {
2112  typename std::list<T>::iterator itr = _list.begin();
2113  advance(itr, urand(0, _list.size() - 1));
2114  _list.erase(itr);
2115  }
2116 }
2117 }
2118 
2119 #endif
2120 
uint32 GetCreatureTypeMask() const
Definition: Unit.h:1149
AuraList m_removedAuras
Definition: Unit.h:2034
bool HasStealthAura() const
Definition: Unit.h:1270
AuraType
bool HealthAbovePctHealed(int32 pct, uint32 heal) const
Definition: Unit.h:1084
UnitMoveType
Definition: Unit.h:482
uint32 SpellOrAction
Definition: Unit.h:725
void SetMinionGUID(uint64 guid)
Definition: Unit.h:1358
uint32 GetCreateMana() const
Definition: Unit.h:1558
void SetInFront(float x, float y)
Definition: Unit.h:1680
bool IsBanker() const
Definition: Unit.h:1221
void setAttackTimer(WeaponAttackType type, uint32 time)
Definition: Unit.h:943
time_t GetLastDamagedTime() const
Definition: Unit.h:1995
bool IsVendor() const
Definition: Unit.h:1214
ShapeshiftForm
Definition: Unit.h:191
BaseModGroup
Definition: Unit.h:419
uint32 SpellID
Definition: Unit.h:707
uint32 procAttacker
Definition: Unit.h:692
Definition: Unit.h:513
EventProcessor m_Events
Definition: Unit.h:1636
time_t GetInterval() const
Definition: Timer.h:126
uint32 m_removedAurasCount
Definition: Unit.h:2026
uint64 GetCharmGUID() const
Definition: Unit.h:1370
virtual uint32 GetHighestLearnedRankOf(uint32 spellid) const
Definition: Unit.h:1291
orders pet to attack
Definition: Unit.h:770
Definition: Unit.h:440
bool IsFlying() const
Definition: Unit.h:1973
Definition: Unit.h:511
void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply)
Definition: Unit.h:1520
void SetStat(Stats stat, int32 val)
Definition: Unit.h:1067
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:1903
Unit * attacker
Definition: Unit.h:681
bool isServiceProvider() const
Definition: Unit.h:1228
#define MAX_MOVE_TYPE
Definition: Unit.h:494
UnitStandFlags
Definition: Unit.h:176
uint64 miniPetGuid
Definition: Unit.h:2057
uint8 getLevelForTarget(WorldObject const *) const override
Definition: Unit.h:1058
float baseMoveSpeed[MAX_MOVE_TYPE]
Definition: Unit.cpp:58
void SetTarget(uint64 guid=0)
Definition: Unit.h:1591
bool m_ControlledByPlayer
Definition: Unit.h:1992
uint32 GetMaxHealth() const
Definition: Unit.h:1075
float m_modMeleeHitChance
Definition: Unit.h:1625
void RandomResizeList(std::list< T > &_list, uint32 _size)
Definition: Unit.h:2108
bool IsSpiritHealer() const
Definition: Unit.h:1223
uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missCondition)
Definition: Unit.cpp:11472
SpellModOp
Definition: Unit.h:99
ReputationRank
bool IsArmorer() const
Definition: Unit.h:1227
bool IsRooted() const
Definition: Unit.h:1976
uint32 GetFaction() const
Definition: Unit.h:1116
DynObjectGUIDs m_dynObjGUIDs
Definition: Unit.h:2029
CurrentSpellTypes
Definition: Unit.h:735
uint32 GetUnitMovementFlags() const
Definition: Unit.h:1904
SpellSchoolMask
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:1082
UnitMods
Definition: Unit.h:384
bool IsControlledByPlayer() const
Definition: Unit.h:1383
bool IsTaxi() const
Definition: Unit.h:1218
bool HasCommandState(CommandStates state)
Definition: Unit.h:817
uint32 m_petnumber
Definition: Unit.h:861
uint32 blocked_amount
Definition: Unit.h:687
void SetModifierValue(UnitMods unitMod, UnitModifierType modifierType, float value)
Definition: Unit.h:1640
void AddUnitState(uint32 f)
Definition: Unit.h:1026
AuraList m_ccAuras
Definition: Unit.h:2039
pet will not attack
Definition: Unit.h:760
uint64 GetMinionGUID() const
Definition: Unit.h:1354
float GetPosStat(Stats stat) const
Definition: Unit.h:1563
uint32 HitInfo
Definition: Unit.h:688
void SetAttackTime(WeaponAttackType att, uint32 val)
Definition: Unit.h:1108
bool m_duringRemoveFromWorld
Definition: Unit.h:2096
float GetNegStat(Stats stat) const
Definition: Unit.h:1567
SpellSchools
WeaponAttackType
Definition: Unit.h:498
SharedVisionList const & GetSharedVisionList()
Definition: Unit.h:1465
uint64 GetCharmerGUID() const
Definition: Unit.h:1362
UnitModifierType
Definition: Unit.h:351
Pet * ToPet()
Definition: Unit.h:1054
AuraMap & GetAuras()
Definition: Unit.h:1739
Unit * attacker
Definition: Unit.h:706
void RemoveStandFlags(uint8 flags)
Definition: Unit.h:1161
bool IsInFlightForm() const
Definition: Unit.h:1621
int32 m_baseSpellCritChance
Definition: Unit.h:1628
UnitAuraFlags
internal used flags for marking special auras - for example some dummy-auras
Definition: Unit.h:548
uint8 GetStandState() const
Definition: Unit.h:1155
std::set< AuraType > AuraTypeSet
Definition: Unit.h:919
Movement::MoveSpline * movespline
Definition: Unit.h:1907
void addHatedBy(HostileReference *pHostileReference)
Definition: Unit.h:1725
uint32 procVictim
Definition: Unit.h:693
uint32 hitTime
Definition: Unit.h:656
void SetInitiatingCombat(bool flag)
Definition: Unit.h:1248
SharedVisionList m_sharedVision
Definition: Unit.h:2051
WeaponAttackType attackType
Definition: Unit.h:673
Definition: Unit.h:258
bool isHover() const
Definition: Unit.h:1864
bool IsPvP() const
Definition: Unit.h:1139
UnitBytes2Offsets
Definition: Unit.h:310
Definition: Unit.h:752
#define MAX_ATTACK
Definition: Unit.h:505
uint32 resist
Definition: Unit.h:686
bool IsBattleMaster() const
Definition: Unit.h:1220
MotionMaster * GetMotionMaster()
Definition: Unit.h:1890
uint32 m_reducedThreatPercent
Definition: Unit.h:2093
SpellValueMod
Definition: Unit.h:133
bool IsInCombat() const
Definition: Unit.h:1243
pet will attack only if he or his owner is attacked
Definition: Unit.h:761
CharmInfo * m_charmInfo
Definition: Unit.h:2050
CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome)
Definition: Unit.h:669
UnitActionBarEntry * GetActionBarEntry(uint8 index)
Definition: Unit.h:833
std::pair< uint32, uint8 > spellEffectPair
Definition: Unit.h:915
bool m_isSorted
Definition: Unit.h:2032
void SetCreateHealth(uint32 val)
Definition: Unit.h:1546
Definition: Unit.h:437
virtual bool HasSpell(uint32) const
Definition: Unit.h:1265
DiminishingGroup
uint32 m_lastSanctuaryTime
Definition: Unit.h:1711
void SetCanModifyStats(bool modifyStats)
Definition: Unit.h:1654
uint64 GetCharmerOrOwnerOrOwnGUID() const
Definition: Unit.h:1391
bool IsInFlight() const
Definition: Unit.h:1239
UnitTypeMask
Definition: Unit.h:630
bool IsInRoots() const
Definition: Unit.h:1273
ACE_INT32 int32
Definition: Define.h:67
Diminishing m_Diminishing
Definition: Unit.h:2083
AuraList const & GetSingleCastAuras() const
Definition: Unit.h:1705
uint32 GetNativeDisplayId()
Definition: Unit.h:1787
std::list< Aura * > AuraList
Definition: Unit.h:917
bool IsInFeralForm() const
Definition: Unit.h:1613
NULL Dbg ErrDB Arena Chat Char Map MMap false
Definition: Log.cpp:556
void SetLastManaUse(uint32 spellCastTime)
Definition: Unit.h:1832
UnitBytes0Offsets
Definition: Unit.h:294
Definition: Unit.h:541
bool m_AutoRepeatFirstCast
Definition: Unit.h:2010
bool CanFreeMove() const
Definition: Unit.h:1038
void SetNativeDisplayId(uint32 modelId)
Definition: Unit.h:1791
bool IsLevitating() const
Definition: Unit.h:1988
TimeTrackerSmall m_movesplineTimer
Definition: Unit.h:2081
DispelType
std::list< uint64 > DynObjectGUIDs
Definition: Unit.h:2028
uint32 spellId
Definition: Unit.h:346
uint16 active
Definition: Unit.h:777
UnitFlags
Definition: Unit.h:554
Definition: Unit.h:439
#define MAX_DECLINED_NAME_CASES
Definition: Unit.h:728
uint16 stack
Definition: Unit.h:658
bool IsPetInCombat() const
Definition: Unit.h:1244
uint32 cleanDamage
Definition: Unit.h:717
uint64 LastCharmerGUID
Definition: Unit.h:1991
void apply(T *val)
Definition: ByteConverter.h:41
bool IsContestedGuard() const
Definition: Unit.h:1131
MeleeHitOutcome hitOutCome
Definition: Unit.h:696
uint32 GetReducedThreatPercent()
Definition: Unit.h:1963
uint32 m_transform
Definition: Unit.h:2033
CharmInfo * GetCharmInfo()
Definition: Unit.h:1458
#define MAX_SPELL_SCHOOL
UnitFlags2
Definition: Unit.h:590
bool IsGuildMaster() const
Definition: Unit.h:1219
UnitBytes2_Flags
Definition: Unit.h:230
uint32 _oldFactionId
Definition: Unit.h:1633
Unit * GetMisdirectionTarget()
Definition: Unit.h:1967
time_t _lastDamagedTime
Definition: Unit.h:2100
uint32 m_state
Definition: Unit.h:2076
bool m_barInit
Definition: Unit.h:862
uint32 m_lastManaUse
Definition: Unit.h:2077
NPCFlags
Definition: Unit.h:600
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:1901
void SetInFront(Unit const *target)
Definition: Unit.h:1675
uint32 GetPower(Powers power) const
Definition: Unit.h:1096
CommandStates
Pet&#39;s Commands.
Definition: Unit.h:766
TempSummon const * ToTempSummon() const
Definition: Unit.h:1999
void SetResistance(SpellSchools school, int32 val)
Definition: Unit.h:1072
float GetResistanceBuffMods(SpellSchools school, bool positive) const
Definition: Unit.h:1512
uint32 procEx
Definition: Unit.h:694
UnitAI * i_disabledAI
Definition: Unit.h:2004
uint8 getLevel() const
Definition: Unit.h:1057
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.h:1104
uint64 m_misdirectionTargetGUID
Definition: Unit.h:2094
MovementFlags
Definition: Object.h:62
MeleeHitOutcome
Definition: Unit.h:661
#define MAX_SPELL_IMMUNITY
AuraList m_interruptableAuras
Definition: Unit.h:2038
uint64 GetCharmerOrOwnerGUID() const
Definition: Unit.h:1387
bool isMoving() const
Definition: Unit.h:1332
WeaponAttackType attackType
Definition: Unit.h:691
void SetCommandState(CommandStates st)
Definition: Unit.h:809
#define MAX_STATS
std::list< SpellImmune > SpellImmuneList
Definition: Unit.h:349
float GetMeleeReach() const
Definition: Unit.h:982
TempSummon * ToTempSummon()
Definition: Unit.h:1998
uint32 IsInPvPCombat() const
Definition: Unit.h:1254
SheathState
Definition: Unit.h:220
bool IsSpiritGuide() const
Definition: Unit.h:1224
CharmType
Definition: Unit.h:782
bool IsHunterPet() const
Definition: Unit.h:1049
bool IsWalking() const
Definition: Unit.h:1975
float m_modSpellHitChance
Definition: Unit.h:1627
void ClearUnitState(uint32 f)
Definition: Unit.h:1034
std::list< DiminishingReturn > Diminishing
Definition: Unit.h:918
bool isPossessing(Unit *u) const
Definition: Unit.h:1453
void SetResistanceBuffMods(SpellSchools school, bool positive, float val)
Definition: Unit.h:1516
#define IS_PLAYER_GUID(Guid)
Definition: ObjectGuid.h:69
uint32 getTransForm() const
Definition: Unit.h:1799
Powers getPowerType() const
Definition: Unit.h:1094
float GetCombatReach() const
Definition: Unit.h:978
void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply)
Definition: Unit.h:1524
Pet const * ToPet() const
Definition: Unit.h:1055
void SetCritterGUID(uint64 guid)
Definition: Unit.h:1023
bool m_isAtStay
Definition: Unit.h:869
ACE_UINT8 uint8
Definition: Define.h:73
Powers
Definition: Unit.h:430
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1097
uint32 resist
Definition: Unit.h:711
float GetOrientation() const
Definition: Position.h:100
uint16 spellId
Definition: Unit.h:776
Definition: Unit.h:432
uint32 GetDisplayId()
Definition: Unit.h:1782
bool IsQuestGiver() const
Definition: Unit.h:1216
float m_stayX
Definition: Unit.h:872
virtual void ProhibitSpellSchool(SpellSchoolMask, uint32)
Definition: Unit.h:1577
AttackerSet const & getAttackers() const
Definition: Unit.h:1008
Definition: Unit.h:543
uint64 GetTarget() const
Definition: Unit.h:1590
DiminishingGroup DRGroup
Definition: Unit.h:655
Definition: Unit.h:321
bool IsInnkeeper() const
Definition: Unit.h:1222
CommandStates GetCommandState()
Definition: Unit.h:813
bool IsGuardian() const
Definition: Unit.h:1047
HostileRefManager & getHostileRefManager()
Definition: Unit.h:1733
abandons the pet
Definition: Unit.h:771
bool IsDuringRemoveFromWorld() const
Definition: Unit.h:1052
bool IsStopped() const
Definition: Unit.h:1895
Definition: Unit.h:194
uint32 GetPetNumber() const
Definition: Unit.h:803
bool IsFullHealth() const
Definition: Unit.h:1080
Stats
DiminishingLevels
Definition: Unit.h:643
std::set< Unit * > AttackerSet
Definition: Unit.h:913
virtual void SetCanDualWield(bool value)
Definition: Unit.h:977
void AddComboPointHolder(uint32 lowguid)
Definition: Unit.h:1917
bool HasInvisibilityAura() const
Definition: Unit.h:1271
bool IsAlive() const
Definition: Unit.h:1336
Unit * GetVictim() const
Definition: Unit.h:1013
void SetCreateMana(uint32 val)
Definition: Unit.h:1554
MeleeHitOutcome hitOutCome
Definition: Unit.h:674
BaseModType
Definition: Unit.h:428
void _addAttacker(Unit *pAttacker)
Definition: Unit.h:993
float GetPositionY() const
Definition: Position.h:98
DeathState m_deathState
Definition: Unit.h:2022
bool HasAuraState(AuraState flag) const
Definition: Unit.h:1817
virtual bool isValid() const
Definition: Object.cpp:1523
DamageEffectType
Definition: Unit.h:537
Unit * m_attacking
Definition: Unit.h:2020
bool HealthBelowPct(int32 pct) const
Definition: Unit.h:1081
void SetLastDamagedTime(time_t val)
Definition: Unit.h:1996
Definition: Item.h:196
void SetArmor(int32 val)
Definition: Unit.h:1069
SpellInterruptFlags
Definition: Unit.h:40
uint32 m_ShapeShiftModelId
Definition: Unit.h:1611
bool IsInTravelForm() const
Definition: Unit.h:1617
ReactStates m_oldReactState
Definition: Unit.h:865
uint64 GetCreatorGUID() const
Definition: Unit.h:1346
std::set< Unit * > ControlList
Definition: Unit.h:914
CommandStates m_CommandState
Definition: Unit.h:859
bool m_isReturning
Definition: Unit.h:871
WeaponDamageRange
Definition: Unit.h:360
etc mysql my cnf *Then change max_allowed_packet to a bigger value
void SetCreateStat(Stats stat, float val)
Definition: Unit.h:1542
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1593
AuraMap const & GetAuras() const
Definition: Unit.h:1743
Swing
Definition: Unit.h:256
float GetPositionZ() const
Definition: Position.h:99
std::multimap< spellEffectPair, Aura * > AuraMap
Definition: Unit.h:916
UnitStandStateType
Definition: Unit.h:162
ComboPointHolderSet m_ComboPointHolders
Definition: Unit.h:2091
std::list< GameObject * > m_gameObj
Definition: Unit.h:2031
AuraList m_scAuras
Definition: Unit.h:2037
HostileRefManager m_HostileRefManager
Definition: Unit.h:2087
UnitRename
Definition: Unit.h:243
uint32 blocked
Definition: Unit.h:714
ActionBarIndex
Definition: Unit.h:788
void AddUnitTypeMask(uint32 mask)
Definition: Unit.h:1045
uint32 absorb
Definition: Unit.h:685
void SetUnitMovementFlags(uint32 f)
Definition: Unit.h:1905
uint32 TargetState
Definition: Unit.h:689
FollowerRefManager m_FollowingRefManager
Definition: Unit.h:2089
SpellFacingFlags
Definition: Unit.h:152
void SetStandFlags(uint8 flags)
Definition: Unit.h:1160
SpellMissInfo
void ClearDiminishings()
Definition: Unit.h:933
bool isPossessed() const
Definition: Unit.h:1438
AuraList & GetSingleCastAuras()
Definition: Unit.h:1701
uint32 damageSchoolMask
Definition: Unit.h:683
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:952
std::set< PetAura const * > PetAuraSet
Definition: Unit.h:1953
#define REACTIVE_TIMER_START
Definition: Unit.h:878
void RemoveComboPointHolder(uint32 lowguid)
Definition: Unit.h:1921
void addFollower(FollowerReference *pRef)
Definition: Unit.h:1878
float m_stayY
Definition: Unit.h:873
ReactiveType
Definition: Unit.h:880
bool NeedChangeAI
Definition: Unit.h:1990
bool IsVisible() const
Definition: Unit.h:1691
uint32 GetMountID() const
Definition: Unit.h:1164
virtual void SetSheath(SheathState sheathed)
Definition: Unit.h:1113
SpellChannelInterruptFlags
Definition: Unit.h:49
#define MAX_REACTIVE
Definition: Unit.h:894
ReactStates
Pet&#39;s behavior.
Definition: Unit.h:758
VictimState
Definition: Unit.h:263
AuraState
T CalculatePct(T base, U pct)
Definition: Util.h:97
bool IsCharmedOwnedByPlayerOrPlayer() const
Definition: Unit.h:1397
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:1902
uint64 GetOwnerGUID() const
Definition: Unit.h:1342
uint32 schoolMask
Definition: Unit.h:709
void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value)
Definition: Unit.h:1669
SheathState GetSheath() const
Definition: Unit.h:1112
uint32 m_AuraFlags
Definition: Unit.h:1770
ThreatManager m_ThreatManager
Definition: Unit.h:2061
bool isPossessedByPlayer() const
Definition: Unit.h:1442
#define MIN_MELEE_REACH
Definition: Object.h:46
ControlList m_Controlled
Definition: Unit.h:1430
uint32 m_ShapeShiftFormSpellId
Definition: Unit.h:1610
uint32 GetMaxSkillValueForLevel(Unit const *target=nullptr) const
Definition: Unit.h:1170
uint32 m_extraAttacks
Definition: Unit.h:990
uint32 GetArmor() const
Definition: Unit.h:1068
bool IsPet() const
Definition: Unit.h:1048
uint32 HitInfo
Definition: Unit.h:715
bool HealthAbovePct(int32 pct) const
Definition: Unit.h:1083
bool isDying() const
Definition: Unit.h:1337
DeathState
Definition: Unit.h:435
ACE_UINT64 uint64
Definition: Define.h:70
#define SUMMON_SLOT_PET
Definition: Unit.h:895
uint32 hitCount
Definition: Unit.h:657
SpellPartialResist
Definition: Unit.h:88
void removeFollower(FollowerReference *)
Definition: Unit.h:1882
uint32 GetInterruptMask() const
Definition: Unit.h:1772
ActiveStates
Definition: Unit.h:746
std::pair< SpellValueMod, int32 > CustomSpellValueMod
Definition: Unit.h:142
uint32 getClassMask() const
Definition: Unit.h:1063
uint64 GetPetGUID() const
Definition: Unit.h:1378
uint32 damage
Definition: Unit.h:708
void ApplyStatBuffMod(Stats stat, float val, bool apply)
Definition: Unit.h:1533
uint8 getRace() const
Definition: Unit.h:1060
Definition: Unit.h:485
bool isDead() const
Definition: Unit.h:1338
SpellAuraInterruptFlags
Definition: Unit.h:58
bool IsFeared() const
Definition: Unit.h:1272
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1410
orders pet to follow
Definition: Unit.h:769
MotionMaster i_motionMaster
Definition: Unit.h:2055
#define CURRENT_MAX_SPELL
Definition: Unit.h:744
Unit * target
Definition: Unit.h:705
bool IsPlayer() const
Definition: Unit.h:1238
void _removeAttacker(Unit *pAttacker)
Definition: Unit.h:999
void ApplyStatPercentBuffMod(Stats stat, float val, bool apply)
Definition: Unit.h:1537
bool m_canDualWield
Definition: Unit.h:991
AttackerSet m_attackers
Definition: Unit.h:2019
bool IsTotem() const
Definition: Unit.h:1050
bool IsCritter() const
Definition: Unit.h:1237
Unit * target
Definition: Unit.h:682
ACE_INT64 int64
Definition: Define.h:66
bool isValid() const override
Definition: Unit.h:1695
float GetCreateStat(Stats stat) const
Definition: Unit.h:1571
void StartReactiveTimer(ReactiveType reactive)
Definition: Unit.h:1943
bool IsGossip() const
Definition: Unit.h:1217
bool CanModifyStats() const
Definition: Unit.h:1650
HitInfo
Definition: Unit.h:276
DamageTypeToSchool
Definition: Unit.h:366
void SetFaction(uint32 faction)
Definition: Unit.h:1117
#define NOMINAL_MELEE_RANGE
Definition: Object.h:47
std::list< Player * > SharedVisionList
Definition: Unit.h:780
uint32 m_unitTypeMask
Definition: Unit.h:2049
uint32 cleanDamage
Definition: Unit.h:695
AuraRemoveMode
Definition: Unit.h:373
bool m_initiatingCombat
Definition: Unit.h:2013
ThreatManager & getThreatManager()
Definition: Unit.h:1721
uint8 getGender() const
Definition: Unit.h:1064
bool IsAuctioner() const
Definition: Unit.h:1226
void SetCharmerGUID(uint64 owner)
Definition: Unit.h:1366
uint32 m_interruptMask
Definition: Unit.h:2040
uint32 GetCreateHealth() const
Definition: Unit.h:1550
uint8 getClass() const
Definition: Unit.h:1062
Definition: Unit.h:431
#define MAX_SUMMON_SLOT
Definition: Unit.h:900
bool physicalLog
Definition: Unit.h:712
Definition: Unit.h:512
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1044
void SetPvP(bool state)
Definition: Unit.h:1143
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
void SetReducedThreatPercent(uint32 pct, uint64 guid)
Definition: Unit.h:1958
uint32 GetResistance(SpellSchools school) const
Definition: Unit.h:1071
bool IsMounted() const
Definition: Unit.h:1163
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:670
Spell * GetCurrentSpell(uint32 spellType) const
Definition: Unit.h:1597
bool IsInitiatingCombat() const
Definition: Unit.h:1242
UnitBytes1Offsets
Definition: Unit.h:302
uint32 damage
Definition: Unit.h:684
uint32 getRaceMask() const
Definition: Unit.h:1061
bool SetPosition(const Position &pos, bool teleport=false)
Definition: Unit.h:1319
bool CanUseEquippedWeapon(WeaponAttackType attackType) const
Definition: Unit.h:958
PetAuraSet m_petAuras
Definition: Unit.h:1954
std::set< uint32 > ComboPointHolderSet
Definition: Unit.h:920
SpellCastResult
void propagateSpeedChange()
Definition: Unit.h:1936
void setTransForm(uint32 spellid)
Definition: Unit.h:1795
bool IsTabardDesigner() const
Definition: Unit.h:1225
float m_modRangedHitChance
Definition: Unit.h:1626
uint64 GetCritterGUID() const
Definition: Unit.h:1024
#define MELEE_RANGE
Definition: Object.h:48
Definition: Unit.h:354
void SetFullHealth()
Definition: Unit.h:1091
AuraList const & GetAurasByType(AuraType type) const
Definition: Unit.h:1747
UnitState
Definition: Unit.h:445
SpellNonMeleeDamage(Unit *_attacker, Unit *_target, uint32 _SpellID, uint32 _schoolMask)
Definition: Unit.h:702
uint32 type
Definition: Unit.h:345
void SetCreatorGUID(uint64 creator)
Definition: Unit.h:1350
IntervalTimer m_CombatTimer
Definition: Unit.h:1253
ACE_UINT16 uint16
Definition: Define.h:72
bool isCharmed() const
Definition: Unit.h:1434
CharmSpellEntry * GetCharmSpell(uint8 index)
Definition: Unit.h:837
AuraMap::iterator m_AurasUpdateIterator
Definition: Unit.h:2025
bool m_isFollowing
Definition: Unit.h:870
uint32 GetUnitMeleeSkill(Unit const *target=NULL) const
Definition: Unit.h:1202
bool CanDualWield() const
Definition: Unit.h:973
ACE_UINT32 uint32
Definition: Define.h:71
void AddInterruptMask(uint32 mask)
Definition: Unit.h:1776
bool _isCommandFollow
Definition: Unit.h:868
bool IsTrainer() const
Definition: Unit.h:1215
float GetPositionX() const
Definition: Position.h:97
bool HasSharedVision() const
Definition: Unit.h:1471
void AddSpellMod(SpellValueMod mod, int32 value)
Definition: Unit.h:146
uint32 Type
Definition: Unit.h:724
DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count)
Definition: Unit.h:653
bool IsSummon() const
Definition: Unit.h:1046
orders pet to stop moving
Definition: Unit.h:768
uint32 CountPctFromCurHealth(int32 pct) const
Definition: Unit.h:1087
uint32 GetHealth() const
Definition: Unit.h:1074
uint32 m_procDeep
Definition: Unit.h:2098
bool isPossessing() const
Definition: Unit.h:1446
void RemoveDynObjectWithGUID(uint64 guid)
Definition: Unit.h:1805
Definition: Unit.h:908
CombatRating
Definition: Unit.h:507
UnitBytes1_Flags
Definition: Unit.h:183
void removeHatedBy(HostileReference *)
Definition: Unit.h:1729
Definition: Player.h:922
void InitStatBuffMods()
Definition: Unit.h:1528
AuraMap m_Auras
Definition: Unit.h:2024
Definition: Unit.h:542
void SetPetGUID(uint64 guid)
Definition: Unit.h:1374
float GetStat(Stats stat) const
Definition: Unit.h:1066
Unit * m_unit
Definition: Unit.h:856
Definition: Pet.h:146
uint32 damage
Definition: Unit.h:672
uint32 absorb
Definition: Unit.h:710
uint32 getAttackTimer(WeaponAttackType type) const
Definition: Unit.h:948
virtual float GetFollowAngle() const
Definition: Unit.h:1971
bool m_canModifyStats
Definition: Unit.h:2044
DeathState getDeathState() const
Definition: Unit.h:1339
float GetHealthPct() const
Definition: Unit.h:1085
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Unit.h:1414
InventorySlot
Definition: Unit.h:319
Definition: UnitAI.h:41
uint32 urand(uint32 min, uint32 max)
Definition: Util.cpp:33
bool m_isCommandAttack
Definition: Unit.h:867
bool IsSpiritService() const
Definition: Unit.h:1236
const uint64 & GetGUID() const
Definition: Object.h:162
ShapeshiftForm m_form
Definition: Unit.h:1612
bool HasAura(uint32 spellId, uint8 effIndex=0) const
Definition: Unit.h:1262
float m_stayZ
Definition: Unit.h:874
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1086
Definition: Spell.h:249
float GetSpeedRate(UnitMoveType mtype) const
Definition: Unit.h:1858