TrinityCore
Loading...
Searching...
No Matches
Unit.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore 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 __UNIT_H
19#define __UNIT_H
20
21#include "Object.h"
22#include "CombatManager.h"
23#include "SpellAuraDefines.h"
24#include "PetDefines.h"
25#include "ThreatManager.h"
26#include "Timer.h"
27#include "UnitDefines.h"
28#include "Util.h"
29#include <map>
30#include <memory>
31#include <stack>
32#include <queue>
33
34#define VISUAL_WAYPOINT 1 // Creature Entry ID used for waypoints show, visible only for GMs
35#define WORLD_TRIGGER 12999
36
37#define MAX_SPELL_CHARM 4
38#define MAX_SPELL_VEHICLE 6
39#define MAX_SPELL_POSSESS 8
40#define MAX_SPELL_CONTROL_BAR 10
41
42#define MAX_AGGRO_RESET_TIME 10 // in seconds
43#define MAX_AGGRO_RADIUS 45.0f // yards
44
46{
47 VICTIMSTATE_INTACT = 0, // set when attacker misses
48 VICTIMSTATE_HIT = 1, // victim got clear/blocked hit
52 VICTIMSTATE_BLOCKS = 5, // unused? not set when blocked, even on full block
56};
57
58//i would like to remove this: (it is defined in item.h
60{
62 NULL_SLOT = 255
63};
64
65struct AbstractFollower;
67struct LiquidData;
68struct LiquidTypeEntry;
69struct SpellValue;
70
71class Aura;
72class AuraApplication;
73class AuraEffect;
74class Creature;
75class DynamicObject;
76class GameClient;
77class GameObject;
78class Guardian;
79class Item;
80class Minion;
81class MotionMaster;
82class Pet;
83class PetAura;
84class Spell;
86class SpellEffectInfo;
87class SpellHistory;
88class SpellInfo;
89class Totem;
90class Transport;
91class TransportBase;
92class UnitAI;
93class UnitAura;
94class Vehicle;
96
99
100namespace Movement
101{
102 class MoveSpline;
103}
104
105typedef std::list<Unit*> UnitList;
106
108{
109 public:
110 DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges);
112
113 Aura* GetAura() const { return _aura; }
114 bool RollDispel() const;
115 uint8 GetDispelCharges() const { return _charges; }
116
117 void IncrementCharges() { ++_charges; }
119 {
120 if (!_charges)
121 return false;
122
123 --_charges;
124 return _charges > 0;
125 }
126
127 private:
131};
132typedef std::vector<DispelableAura> DispelChargesList;
133
134typedef std::unordered_multimap<uint32 /*type*/, uint32 /*spellId*/> SpellImmuneContainer;
135
142
149
155
192
201
208
217
219{
220 UNIT_STATE_DIED = 0x00000001, // player has fake death aura
221 UNIT_STATE_MELEE_ATTACKING = 0x00000002, // player is melee attacking someone
222 UNIT_STATE_CHARMED = 0x00000004, // having any kind of charm aura on self
223 UNIT_STATE_STUNNED = 0x00000008,
224 UNIT_STATE_ROAMING = 0x00000010,
225 UNIT_STATE_CHASE = 0x00000020,
227 UNIT_STATE_FLEEING = 0x00000080,
228 UNIT_STATE_IN_FLIGHT = 0x00000100, // player is in flight mode
229 UNIT_STATE_FOLLOW = 0x00000200,
230 UNIT_STATE_ROOT = 0x00000400,
233 UNIT_STATE_ISOLATED = 0x00002000, // area auras do not affect other players
235 UNIT_STATE_CASTING = 0x00008000,
236 UNIT_STATE_POSSESSED = 0x00010000, // being possessed by another unit
238 UNIT_STATE_JUMPING = 0x00040000,
240 UNIT_STATE_MOVE = 0x00100000,
242 UNIT_STATE_EVADE = 0x00400000,
248 UNIT_STATE_IGNORE_PATHFINDING = 0x10000000, // do not use pathfinding in any MovementGenerator
250
257
266
268 UNIT_STATE_ALL_STATE = 0xffffffff
270
273
300
302{
304
308
309 float newValue = 0.0f; // used if speed or height change
310 bool apply = false; // used if movement flag change
312 {
313 float vcos = 0.0f;
314 float vsin = 0.0f;
315 float speedXY = 0.0f;
316 float speedZ = 0.0f;
317 } knockbackInfo; // used if knockback
318};
319
348
349#define MAX_COMBAT_RATING 25
350
352{
353 DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells)
354 SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage
355 DOT = 2,
356 HEAL = 3,
357 NODAMAGE = 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
358 SELF_DAMAGE = 5
360
362{
363 UNIT_MASK_NONE = 0x00000000,
364 UNIT_MASK_SUMMON = 0x00000001,
365 UNIT_MASK_MINION = 0x00000002,
366 UNIT_MASK_GUARDIAN = 0x00000004,
367 UNIT_MASK_TOTEM = 0x00000008,
368 UNIT_MASK_PET = 0x00000010,
369 UNIT_MASK_VEHICLE = 0x00000020,
370 UNIT_MASK_PUPPET = 0x00000040,
373 UNIT_MASK_ACCESSORY = 0x00000200
375
391
397
399{
400 public:
401 explicit DispelInfo(WorldObject* dispeller, uint32 dispellerSpellId, uint8 chargesRemoved) :
402 _dispeller(dispeller), _dispellerSpell(dispellerSpellId), _chargesRemoved(chargesRemoved) { }
403
407 void SetRemovedCharges(uint8 amount) { _chargesRemoved = amount; }
408 private:
412};
413
425
426struct CalcDamageInfo;
428
430{
431 private:
435 SpellInfo const* const m_spellInfo;
443
444 // amalgamation constructor (used for proc)
445 DamageInfo(DamageInfo const& dmg1, DamageInfo const& dmg2);
446
447 public:
448 DamageInfo(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, DamageEffectType damageType, WeaponAttackType attackType);
449 explicit DamageInfo(CalcDamageInfo const& dmgInfo); // amalgamation wrapper
450 DamageInfo(CalcDamageInfo const& dmgInfo, uint8 damageIndex);
451 DamageInfo(SpellNonMeleeDamage const& spellNonMeleeDamage, DamageEffectType damageType, WeaponAttackType attackType, uint32 hitMask);
452
453 void ModifyDamage(int32 amount);
454 void AbsorbDamage(uint32 amount);
455 void ResistDamage(uint32 amount);
456 void BlockDamage(uint32 amount);
457
458 Unit* GetAttacker() const { return m_attacker; }
459 Unit* GetVictim() const { return m_victim; }
460 SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
461 SpellSchoolMask GetSchoolMask() const { return m_schoolMask; }
462 DamageEffectType GetDamageType() const { return m_damageType; }
463 WeaponAttackType GetAttackType() const { return m_attackType; }
464 uint32 GetDamage() const { return m_damage; }
465 uint32 GetAbsorb() const { return m_absorb; }
466 uint32 GetResist() const { return m_resist; }
467 uint32 GetBlock() const { return m_block; }
468
469 uint32 GetHitMask() const;
470};
471
473{
474 private:
475 Unit* const _healer;
476 Unit* const _target;
480 SpellInfo const* const _spellInfo;
483
484 public:
485 HealInfo(Unit* healer, Unit* target, uint32 heal, SpellInfo const* spellInfo, SpellSchoolMask schoolMask);
486
487 void AbsorbHeal(uint32 amount);
488 void SetEffectiveHeal(uint32 amount) { _effectiveHeal = amount; }
489
490 Unit* GetHealer() const { return _healer; }
491 Unit* GetTarget() const { return _target; }
492 uint32 GetHeal() const { return _heal; }
493 uint32 GetEffectiveHeal() const { return _effectiveHeal; }
494 uint32 GetAbsorb() const { return _absorb; }
495 SpellInfo const* GetSpellInfo() const { return _spellInfo; };
496 SpellSchoolMask GetSchoolMask() const { return _schoolMask; };
497
498 uint32 GetHitMask() const;
499};
500
502{
503 public:
504 ProcEventInfo(Unit* actor, Unit* actionTarget, uint32 typeMask,
505 uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask,
506 Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo);
507
508 Unit* GetActor() { return _actor; }
509 Unit* GetActionTarget() const { return _actionTarget; }
510
511 uint32 GetTypeMask() const { return _typeMask; }
512 uint32 GetSpellTypeMask() const { return _spellTypeMask; }
513 uint32 GetSpellPhaseMask() const { return _spellPhaseMask; }
514 uint32 GetHitMask() const { return _hitMask; }
515
516 SpellInfo const* GetSpellInfo() const;
517 SpellSchoolMask GetSchoolMask() const;
518
519 DamageInfo* GetDamageInfo() const { return _damageInfo; }
520 HealInfo* GetHealInfo() const { return _healInfo; }
521
522 Spell const* GetProcSpell() const { return _spell; }
523
524 private:
525 Unit* const _actor;
534};
535
536// Struct for use in Unit::CalculateMeleeDamage
537// Need create structure like in SMSG_ATTACKERSTATEUPDATE opcode
562
563// Spell damage info structure based on structure sending in SMSG_SPELLNONMELEEDAMAGELOG opcode
565{
566 SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 _SpellID, uint32 _schoolMask)
567 : target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), overkill(0), schoolMask(_schoolMask),
568 absorb(0), resist(0), periodicLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0), fullBlock(false)
569 { }
570
580 bool unused;
583 // Used for help
586};
587
589{
590 SpellPeriodicAuraLogInfo(AuraEffect const* _auraEff, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical)
591 : auraEff(_auraEff), damage(_damage), overDamage(_overDamage), absorb(_absorb), resist(_resist), multiplier(_multiplier), critical(_critical){ }
592
595 uint32 overDamage; // overkill/overheal
600};
601
603
611
612#define CURRENT_FIRST_NON_MELEE_SPELL 1
613#define CURRENT_MAX_SPELL 4
614
615#define UNIT_ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
616#define UNIT_ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
617#define MAKE_UNIT_ACTION_BUTTON(A, T) (uint32(A) | (uint32(T) << 24))
618
620{
622
624
625 // helper
629 {
630 ActiveStates Type = GetType();
631 return Type == ACT_DISABLED || Type == ACT_ENABLED || Type == ACT_PASSIVE;
632 }
633
635 {
636 packedData = MAKE_UNIT_ACTION_BUTTON(action, type);
637 }
638
643
644 void SetAction(uint32 action)
645 {
646 packedData = (packedData & 0xFF000000) | UNIT_ACTION_BUTTON_ACTION(action);
647 }
648};
649
650typedef std::list<Player*> SharedVisionList;
651
659
661
669
670#define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START)
671
673{
674 public:
675 explicit CharmInfo(Unit* unit);
676 ~CharmInfo();
677 void RestoreState();
678 uint32 GetPetNumber() const { return _petnumber; }
679 void SetPetNumber(uint32 petnumber, bool statwindow);
680
681 void SetCommandState(CommandStates st) { _CommandState = st; }
682 CommandStates GetCommandState() const { return _CommandState; }
683 bool HasCommandState(CommandStates state) const { return (_CommandState == state); }
684
685 void InitPossessCreateSpells();
686 void InitCharmCreateSpells();
687 void InitPetActionBar();
688 void InitEmptyActionBar(bool withAttack = true);
689
690 //return true if successful
691 bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE, uint8 preferredSlot = 0);
692 bool RemoveSpellFromActionBar(uint32 spell_id);
693 void LoadPetActionBar(const std::string& data);
694 void BuildActionBar(WorldPacket* data);
695 void SetSpellAutocast(SpellInfo const* spellInfo, bool state);
696 void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type)
697 {
698 PetActionBar[index].SetActionAndType(spellOrAction, type);
699 }
700 UnitActionBarEntry const* GetActionBarEntry(uint8 index) const { return &(PetActionBar[index]); }
701
702 void ToggleCreatureAutocast(SpellInfo const* spellInfo, bool apply);
703
704 CharmSpellInfo* GetCharmSpell(uint8 index) { return &(_charmspells[index]); }
705
706 void SetIsCommandAttack(bool val);
707 bool IsCommandAttack();
708 void SetIsCommandFollow(bool val);
709 bool IsCommandFollow();
710 void SetIsAtStay(bool val);
711 bool IsAtStay();
712 void SetIsFollowing(bool val);
713 bool IsFollowing();
714 void SetIsReturning(bool val);
715 bool IsReturning();
716 void SaveStayPosition();
717 void GetStayPosition(float &x, float &y, float &z);
718
719 private:
720
723 CharmSpellInfo _charmspells[4];
726
727 //for restoration after charmed
729
735 float _stayX;
736 float _stayY;
737 float _stayZ;
738};
739
740// for clearing special attacks
741#define REACTIVE_TIMER_START 4000
742
751
753{
754 void Reset()
755 {
756 Relocated = false;
757 Turned = false;
758 }
759
760 bool Relocated = false;
761 bool Turned = false;
762};
763
764// delay time next attack to prevent client attack animation problems
765#define ATTACK_DISPLAY_DELAY 200
766#define MAX_PLAYER_STEALTH_DETECT_RANGE 30.0f // max distance for detection targets by player
767
769{
770 friend class WorldSession;
771 public:
772 typedef std::set<Unit*> AttackerSet;
773 typedef std::set<Unit*> ControlList;
774 typedef std::vector<Unit*> UnitVector;
775
776 typedef std::multimap<uint32, Aura*> AuraMap;
777 typedef std::pair<AuraMap::const_iterator, AuraMap::const_iterator> AuraMapBounds;
778 typedef std::pair<AuraMap::iterator, AuraMap::iterator> AuraMapBoundsNonConst;
779
780 typedef std::multimap<uint32, AuraApplication*> AuraApplicationMap;
781 typedef std::pair<AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator> AuraApplicationMapBounds;
782 typedef std::pair<AuraApplicationMap::iterator, AuraApplicationMap::iterator> AuraApplicationMapBoundsNonConst;
783
784 typedef std::multimap<AuraStateType, AuraApplication*> AuraStateAurasMap;
785 typedef std::pair<AuraStateAurasMap::const_iterator, AuraStateAurasMap::const_iterator> AuraStateAurasMapBounds;
786
787 typedef std::list<AuraEffect*> AuraEffectList;
788 typedef std::list<Aura*> AuraList;
789 typedef std::list<AuraApplication*> AuraApplicationList;
790 typedef std::array<DiminishingReturn, DIMINISHING_MAX> Diminishing;
791
792 typedef std::vector<std::pair<uint8 /*procEffectMask*/, AuraApplication*>> AuraApplicationProcContainer;
793
794 typedef std::map<uint8, AuraApplication*> VisibleAuraMap;
795
796 virtual ~Unit();
797
798 bool IsAIEnabled() const { return (i_AI != nullptr); }
799 void AIUpdateTick(uint32 diff);
800 UnitAI* GetAI() const { return i_AI.get(); }
801 void ScheduleAIChange();
802 void PushAI(UnitAI* newAI);
803 bool PopAI();
804 protected:
805 void SetAI(UnitAI* newAI);
806 UnitAI* GetTopAI() const { return i_AIs.empty() ? nullptr : i_AIs.top().get(); }
807 void RefreshAI();
808 UnitAI* GetScheduledChangeAI();
809 bool HasScheduledAIChange() const;
810 public:
811
812 void AddToWorld() override;
813 void RemoveFromWorld() override;
814
815 void CleanupBeforeRemoveFromMap(bool finalCleanup);
816 void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
817
818 uint32 GetDynamicFlags() const override { return GetUInt32Value(UNIT_DYNAMIC_FLAGS); }
819 void ReplaceAllDynamicFlags(uint32 flag) override { SetUInt32Value(UNIT_DYNAMIC_FLAGS, flag); }
820
821 virtual bool IsAffectedByDiminishingReturns() const { return (GetCharmerOrOwnerPlayerOrPlayerItself() != nullptr); }
822 DiminishingLevels GetDiminishing(DiminishingGroup group) const;
823 void IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered);
824 bool ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, WorldObject* caster, DiminishingLevels previousLevel) const;
825 void ApplyDiminishingAura(DiminishingGroup group, bool apply);
826 void ClearDiminishings();
827
828 virtual void Update(uint32 time) override;
829
830 void Heartbeat() override;
831
832 void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; }
833 void resetAttackTimer(WeaponAttackType type = BASE_ATTACK);
834 uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; }
835 bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const { return m_attackTimer[type] == 0; }
836 bool haveOffhandWeapon() const;
837 bool CanDualWield() const { return m_canDualWield; }
838 virtual void SetCanDualWield(bool value) { m_canDualWield = value; }
839 float GetCombatReach() const override { return GetFloatValue(UNIT_FIELD_COMBATREACH); }
840 void SetCombatReach(float combatReach) { SetFloatValue(UNIT_FIELD_COMBATREACH, combatReach); }
841 float GetBoundingRadius() const { return GetFloatValue(UNIT_FIELD_BOUNDINGRADIUS); }
842 void SetBoundingRadius(float boundingRadius) { SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, boundingRadius); }
843 bool IsWithinCombatRange(Unit const* obj, float dist2compare) const;
844 bool IsWithinMeleeRange(Unit const* obj) const { return IsWithinMeleeRangeAt(GetPosition(), obj); }
845 bool IsWithinMeleeRangeAt(Position const& pos, Unit const* obj) const;
846 float GetMeleeRange(Unit const* target) const;
847 virtual SpellSchoolMask GetMeleeDamageSchoolMask(WeaponAttackType attackType = BASE_ATTACK, uint8 damageIndex = 0) const = 0;
849
850 void _addAttacker(Unit* pAttacker); // must be called only from Unit::Attack(Unit*)
851 void _removeAttacker(Unit* pAttacker); // must be called only from Unit::AttackStop()
852 Unit* getAttackerForHelper() const; // If someone wants to help, who to give them
853 bool Attack(Unit* victim, bool meleeAttack);
854 void CastStop(uint32 except_spellid = 0);
855 bool AttackStop();
856 void RemoveAllAttackers();
857 AttackerSet const& getAttackers() const { return m_attackers; }
858 bool isAttackingPlayer() const;
859 Unit* GetVictim() const { return m_attacking; }
860 // Use this only when 100% sure there is a victim
862 {
863 ASSERT(m_attacking);
864 return m_attacking;
865 }
866
867 void ValidateAttackersAndOwnTarget();
868 void CombatStop(bool includingCast = false, bool mutualPvP = true);
869 void CombatStopWithPets(bool includingCast = false);
870 void StopAttackFaction(uint32 faction_id);
871 Unit* SelectNearbyTarget(Unit* exclude = nullptr, float dist = NOMINAL_MELEE_RANGE) const;
872 void SendMeleeAttackStop(Unit* victim = nullptr);
873 void SendMeleeAttackStart(Unit* victim);
874
875 void AddUnitState(uint32 f) { m_state |= f; }
876 bool HasUnitState(const uint32 f) const { return (m_state & f) != 0; }
877 void ClearUnitState(uint32 f) { m_state &= ~f; }
878 bool CanFreeMove() const;
879
880 uint32 HasUnitTypeMask(uint32 mask) const { return mask & m_unitTypeMask; }
881 void AddUnitTypeMask(uint32 mask) { m_unitTypeMask |= mask; }
882 bool IsSummon() const { return (m_unitTypeMask & UNIT_MASK_SUMMON) != 0; }
883 bool IsGuardian() const { return (m_unitTypeMask & UNIT_MASK_GUARDIAN) != 0; }
884 bool IsPet() const { return (m_unitTypeMask & UNIT_MASK_PET) != 0; }
885 bool IsHunterPet() const{ return (m_unitTypeMask & UNIT_MASK_HUNTER_PET) != 0; }
886 bool IsTotem() const { return (m_unitTypeMask & UNIT_MASK_TOTEM) != 0; }
887 bool IsVehicle() const { return (m_unitTypeMask & UNIT_MASK_VEHICLE) != 0; }
888
889 uint8 GetLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); }
890 uint8 GetLevelForTarget(WorldObject const* /*target*/) const override { return GetLevel(); }
891 void SetLevel(uint8 lvl, bool sendUpdate = true);
892 uint8 GetRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); }
893 void SetRace(uint8 race) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, race); }
894 uint32 GetRaceMask() const { return 1 << (GetRace() - 1); }
896 void SetClass(uint8 classId) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, classId); }
897 uint32 GetClassMask() const { return 1 << (GetClass() - 1); }
899 void SetGender(Gender gender) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender); }
900 virtual Gender GetNativeGender() const { return GetGender(); }
901 virtual void SetNativeGender(Gender gender) { SetGender(gender); }
902
903 float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0 + int32(stat))); }
904 void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0 + int32(stat), val); }
905 uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL); }
906 void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); }
907
908 int32 GetResistance(SpellSchools school) const { return GetInt32Value(UNIT_FIELD_RESISTANCES + int32(school)); }
909 int32 GetResistance(SpellSchoolMask mask) const;
910 void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES + int32(school), val); }
911 static float CalculateAverageResistReduction(WorldObject const* caster, SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo = nullptr);
912
913 uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
914 uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
915
916 bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
917 bool HealthBelowPct(int32 pct) const { return GetHealth() < CountPctFromMaxHealth(pct); }
918 bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); }
919 bool HealthAbovePct(int32 pct) const { return GetHealth() > CountPctFromMaxHealth(pct); }
920 bool HealthAbovePctHealed(int32 pct, uint32 heal) const { return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); }
921 float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
922 uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePct(GetMaxHealth(), pct); }
923 uint32 CountPctFromCurHealth(int32 pct) const { return CalculatePct(GetHealth(), pct); }
924
925 void SetHealth(uint32 val);
926 void SetMaxHealth(uint32 val);
927 inline void SetFullHealth() { SetHealth(GetMaxHealth()); }
928 int32 ModifyHealth(int32 val);
929 int32 GetHealthGain(int32 dVal);
930
932 void SetPowerType(Powers power, bool sendUpdate = true);
933 void UpdateDisplayPower();
934 uint32 GetPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 + int32(power)); }
935 int32 GetMinPower(Powers /*power*/) const { return 0; }
936 uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1 + int32(power)); }
937 float GetPowerPct(Powers power) const { return GetMaxPower(power) ? 100.f * GetPower(power) / GetMaxPower(power) : 0.0f; }
938 int32 CountPctFromMaxPower(Powers power, int32 pct) const { return CalculatePct(GetMaxPower(power), pct); }
939 void SetPower(Powers power, uint32 val, bool withPowerUpdate = true, bool force = false);
940 void SetMaxPower(Powers power, uint32 val);
941 inline void SetFullPower(Powers power) { SetPower(power, GetMaxPower(power)); }
942 // returns the change in power
943 int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate = true);
944
945 uint32 GetAttackTime(WeaponAttackType att) const;
946 void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME + int32(att), val * m_modAttackSpeedPct[att]); }
947 void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply);
948 void ApplyCastTimePercentMod(float val, bool apply);
949
950 void SetModCastingSpeed(float castingSpeed) { SetFloatValue(UNIT_MOD_CAST_SPEED, castingSpeed); }
951
952 UnitFlags GetUnitFlags() const { return UnitFlags(GetUInt32Value(UNIT_FIELD_FLAGS)); }
953 bool HasUnitFlag(UnitFlags flags) const { return HasFlag(UNIT_FIELD_FLAGS, flags); }
957
958 UnitFlags2 GetUnitFlags2() const { return UnitFlags2(GetUInt32Value(UNIT_FIELD_FLAGS_2)); }
959 bool HasUnitFlag2(UnitFlags2 flags) const { return HasFlag(UNIT_FIELD_FLAGS_2, flags); }
963
964 void SetCreatedBySpell(int32 spellId) { SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId); }
965
966 Emote GetEmoteState() const { return Emote(GetUInt32Value(UNIT_NPC_EMOTESTATE)); }
967 void SetEmoteState(Emote emote) { SetUInt32Value(UNIT_NPC_EMOTESTATE, emote); }
968
970 virtual void SetSheath(SheathState sheathed) { SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHEATH_STATE, sheathed); }
971
972 // faction template id
973 uint32 GetFaction() const override { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); }
974 void SetFaction(uint32 faction) override { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); }
975
976 bool IsInPartyWith(Unit const* unit) const;
977 bool IsInRaidWith(Unit const* unit) const;
978 void GetPartyMembers(std::list<Unit*> &units);
979 bool IsContestedGuard() const;
980
986
987 bool IsInSanctuary() const { return HasPvpFlag(UNIT_BYTE2_FLAG_SANCTUARY); }
988 bool IsPvP() const { return HasPvpFlag(UNIT_BYTE2_FLAG_PVP); }
989 bool IsFFAPvP() const { return HasPvpFlag(UNIT_BYTE2_FLAG_FFA_PVP); }
990 virtual void SetPvP(bool state);
991
997
998 uint32 GetCreatureType() const;
999 uint32 GetCreatureTypeMask() const;
1000
1002 bool IsSitState() const;
1003 bool IsStandState() const;
1004 void SetStandState(UnitStandStateType state);
1005
1009
1011 void SetAnimTier(AnimTier animTier);
1012
1013 bool IsMounted() const { return HasUnitFlag(UNIT_FLAG_MOUNT); }
1014 uint32 GetMountDisplayId() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); }
1015 void SetMountDisplayId(uint32 mountDisplayId) { SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mountDisplayId); }
1016 void Mount(uint32 mount, uint32 vehicleId = 0, uint32 creatureEntry = 0);
1017 void Dismount();
1018
1019 uint32 GetMaxSkillValueForLevel(Unit const* target = nullptr) const { return (target ? GetLevelForTarget(target) : GetLevel()) * 5; }
1020 static void DealDamageMods(Unit const* victim, uint32& damage, uint32* absorb);
1021 static uint32 DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage const* cleanDamage = nullptr, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = nullptr, bool durabilityLoss = true);
1022 static void Kill(Unit* attacker, Unit* victim, bool durabilityLoss = true);
1023 void KillSelf(bool durabilityLoss = true) { Unit::Kill(this, this, durabilityLoss); }
1024 static void DealHeal(HealInfo& healInfo);
1025
1026 static void ProcSkillsAndAuras(Unit* actor, Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget,
1027 uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell,
1028 DamageInfo* damageInfo, HealInfo* healInfo);
1029
1030 void GetProcAurasTriggeredOnEvent(AuraApplicationProcContainer& aurasTriggeringProc, AuraApplicationList* procAuras, ProcEventInfo& eventInfo);
1031 void TriggerAurasProcOnEvent(Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget,
1032 uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell,
1033 DamageInfo* damageInfo, HealInfo* healInfo);
1034 void TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProcContainer& procAuras);
1035
1036 void HandleEmoteCommand(Emote emoteId);
1037 void AttackerStateUpdate (Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false);
1038
1039 void CalculateMeleeDamage(Unit* victim, CalcDamageInfo* damageInfo, WeaponAttackType attackType = BASE_ATTACK);
1040 void DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss);
1041 void HandleProcExtraAttackFor(Unit* victim, uint32 count);
1042
1043 void SetLastExtraAttackSpell(uint32 spellId) { _lastExtraAttackSpell = spellId; }
1044 uint32 GetLastExtraAttackSpell() const { return _lastExtraAttackSpell; }
1045 void AddExtraAttacks(uint32 count);
1046 void SetLastDamagedTargetGuid(ObjectGuid guid) { _lastDamagedTargetGuid = guid; }
1047 ObjectGuid GetLastDamagedTargetGuid() const { return _lastDamagedTargetGuid; }
1048
1049 void CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = BASE_ATTACK, bool crit = false, bool blocked = false, Spell* spell = nullptr);
1050 void DealSpellDamage(SpellNonMeleeDamage const* damageInfo, bool durabilityLoss);
1051
1052 // player or player's pet resilience (-1%)
1053 float GetMeleeCritChanceReduction() const { return GetCombatRatingReduction(CR_CRIT_TAKEN_MELEE); }
1054 float GetRangedCritChanceReduction() const { return GetCombatRatingReduction(CR_CRIT_TAKEN_RANGED); }
1055 float GetSpellCritChanceReduction() const { return GetCombatRatingReduction(CR_CRIT_TAKEN_SPELL); }
1056
1057 // player or player's pet resilience (-1%)
1058 uint32 GetMeleeCritDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 2.2f, 33.0f, damage); }
1059 uint32 GetRangedCritDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_RANGED, 2.2f, 33.0f, damage); }
1060 uint32 GetSpellCritDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_SPELL, 2.2f, 33.0f, damage); }
1061
1062 // player or player's pet resilience (-1%), cap 100%
1063 uint32 GetMeleeDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 2.0f, 100.0f, damage); }
1064 uint32 GetRangedDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_RANGED, 2.0f, 100.0f, damage); }
1065 uint32 GetSpellDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_SPELL, 2.0f, 100.0f, damage); }
1066
1067 virtual bool CanApplyResilience() const;
1068 static void ApplyResilience(Unit const* victim, float* crit, int32* damage, bool isCrit, CombatRating type);
1069
1070 int32 CalculateAOEAvoidance(int32 damage, uint32 schoolMask, ObjectGuid const& casterGuid) const;
1071
1072 float MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const override;
1073 SpellMissInfo MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo) const override;
1074
1075 float GetUnitDodgeChance(WeaponAttackType attType, Unit const* victim) const;
1076 float GetUnitParryChance(WeaponAttackType attType, Unit const* victim) const;
1077 float GetUnitBlockChance(WeaponAttackType attType, Unit const* victim) const;
1078 float GetUnitMissChance() const;
1079 float GetUnitCriticalChanceDone(WeaponAttackType attackType) const;
1080 float GetUnitCriticalChanceTaken(Unit const* attacker, WeaponAttackType attackType, float critDone) const;
1081 float GetUnitCriticalChanceAgainst(WeaponAttackType attackType, Unit const* victim) const;
1082 int32 GetMechanicResistChance(SpellInfo const* spellInfo) const;
1083 bool CanUseAttackType(uint8 attacktype) const;
1084
1085 virtual uint32 GetShieldBlockValue() const = 0;
1086 uint32 GetShieldBlockValue(uint32 soft_cap, uint32 hard_cap) const;
1087 uint32 GetDefenseSkillValue(Unit const* target = nullptr) const;
1088 uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = nullptr) const;
1089
1090 float GetWeaponProcChance() const;
1091 float GetPPMProcChance(uint32 WeaponSpeed, float PPM, SpellInfo const* spellProto) const;
1092
1093 MeleeHitOutcome RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackType attType) const;
1094
1095 NPCFlags GetNpcFlags() const { return NPCFlags(GetUInt32Value(UNIT_NPC_FLAGS)); }
1096 bool HasNpcFlag(NPCFlags flags) const { return HasFlag(UNIT_NPC_FLAGS, flags) != 0; }
1100
1101 bool IsVendor() const { return HasNpcFlag(UNIT_NPC_FLAG_VENDOR); }
1102 bool IsTrainer() const { return HasNpcFlag(UNIT_NPC_FLAG_TRAINER); }
1103 bool IsQuestGiver() const { return HasNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); }
1104 bool IsGossip() const { return HasNpcFlag(UNIT_NPC_FLAG_GOSSIP); }
1105 bool IsTaxi() const { return HasNpcFlag(UNIT_NPC_FLAG_FLIGHTMASTER); }
1106 bool IsGuildMaster() const { return HasNpcFlag(UNIT_NPC_FLAG_PETITIONER); }
1107 bool IsBattleMaster() const { return HasNpcFlag(UNIT_NPC_FLAG_BATTLEMASTER); }
1108 bool IsBanker() const { return HasNpcFlag(UNIT_NPC_FLAG_BANKER); }
1109 bool IsInnkeeper() const { return HasNpcFlag(UNIT_NPC_FLAG_INNKEEPER); }
1110 bool IsSpiritHealer() const { return HasNpcFlag(UNIT_NPC_FLAG_SPIRITHEALER); }
1111 bool IsSpiritGuide() const { return HasNpcFlag(UNIT_NPC_FLAG_SPIRITGUIDE); }
1112 bool IsTabardDesigner() const { return HasNpcFlag(UNIT_NPC_FLAG_TABARDDESIGNER); }
1113 bool IsAuctioner() const { return HasNpcFlag(UNIT_NPC_FLAG_AUCTIONEER); }
1114 bool IsArmorer() const { return HasNpcFlag(UNIT_NPC_FLAG_REPAIR); }
1115 bool IsServiceProvider() const;
1117 bool IsCritter() const { return GetCreatureType() == CREATURE_TYPE_CRITTER; }
1118
1119 bool IsInFlight() const { return HasUnitState(UNIT_STATE_IN_FLIGHT); }
1120
1122 bool CanHaveThreatList() const { return m_threatManager.CanHaveThreatList(); }
1123 // This value can be different from IsInCombat, for example:
1124 // - when a projectile spell is midair against a creature (combat on launch - threat+aggro on impact)
1125 // - when the creature has no targets left, but the AI has not yet ceased engaged logic
1126 virtual bool IsEngaged() const { return IsInCombat(); }
1127 bool IsEngagedBy(Unit const* who) const { return CanHaveThreatList() ? IsThreatenedBy(who) : IsInCombatWith(who); }
1128 void EngageWithTarget(Unit* who); // Adds target to threat list if applicable, otherwise just sets combat state
1129 // Combat handling
1130 CombatManager& GetCombatManager() { return m_combatManager; }
1131 CombatManager const& GetCombatManager() const { return m_combatManager; }
1132 void AtTargetAttacked(Unit* target, bool canInitialAggro);
1133
1134 bool IsImmuneToAll() const { return IsImmuneToPC() && IsImmuneToNPC(); }
1135 void SetImmuneToAll(bool apply, bool keepCombat);
1136 virtual void SetImmuneToAll(bool apply) { SetImmuneToAll(apply, false); }
1137 bool IsImmuneToPC() const { return HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); }
1138 void SetImmuneToPC(bool apply, bool keepCombat);
1139 virtual void SetImmuneToPC(bool apply) { SetImmuneToPC(apply, false); }
1140 bool IsImmuneToNPC() const { return HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC); }
1141 void SetImmuneToNPC(bool apply, bool keepCombat);
1142 virtual void SetImmuneToNPC(bool apply) { SetImmuneToNPC(apply, false); }
1143
1144 bool IsInCombat() const { return HasUnitFlag(UNIT_FLAG_IN_COMBAT); }
1145 bool IsInCombatWith(Unit const* who) const { return who && m_combatManager.IsInCombatWith(who); }
1146 void SetInCombatWith(Unit* enemy, bool addSecondUnitSuppressed = false) { if (enemy) m_combatManager.SetInCombatWith(enemy, addSecondUnitSuppressed); }
1147 void ClearInCombat() { m_combatManager.EndAllCombat(); }
1148 void UpdatePetCombatState();
1149 // Threat handling
1150 bool IsThreatened() const;
1151 bool IsThreatenedBy(Unit const* who) const { return who && m_threatManager.IsThreatenedBy(who, true); }
1152 // Exposes the threat manager directly - be careful when interfacing with this
1153 // As a general rule of thumb, any unit pointer MUST be null checked BEFORE passing it to threatmanager methods
1154 // threatmanager will NOT null check your pointers for you - misuse = crash
1155 ThreatManager& GetThreatManager() { return m_threatManager; }
1156 ThreatManager const& GetThreatManager() const { return m_threatManager; }
1157
1158 void SendClearTarget();
1159
1160 bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, flag96 familyFlags) const;
1161 bool virtual HasSpell(uint32 /*spellID*/) const { return false; }
1162 bool HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura = 0) const;
1163 bool HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel = nullptr) const;
1164
1165 bool HasStealthAura() const { return HasAuraType(SPELL_AURA_MOD_STEALTH); }
1166 bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); }
1167 bool IsFeared() const { return HasAuraType(SPELL_AURA_MOD_FEAR); }
1168 bool IsRooted() const { return HasAuraType(SPELL_AURA_MOD_ROOT); }
1169 bool IsPolymorphed() const;
1170 bool IsFrozen() const { return HasAuraState(AURA_STATE_FROZEN); }
1171
1172 bool isTargetableForAttack(bool checkFakeDeath = true) const;
1173
1174 bool IsInWater() const;
1175 bool IsUnderWater() const;
1176 bool isInAccessiblePlaceFor(Creature const* c) const;
1177
1178 void SendHealSpellLog(HealInfo& healInfo, bool critical = false);
1179 int32 HealBySpell(HealInfo& healInfo, bool critical = false);
1180 void SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, Powers powerType);
1181 void EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers powerType);
1182 void EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, Powers powerType);
1183
1184 Aura* AddAura(uint32 spellId, Unit* target);
1185 Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target);
1186 void SetAuraStack(uint32 spellId, Unit* target, uint32 stack);
1187
1188 void SendPlaySpellVisualKit(uint32 id, uint32 type) const;
1189
1190 void DeMorph();
1191
1192 void SendAttackStateUpdate(CalcDamageInfo* damageInfo);
1193 void SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount);
1194 void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const* log);
1195 void SendSpellNonMeleeDamageLog(Unit* target, uint32 spellID, uint32 damage, SpellSchoolMask damageSchoolMask, uint32 absorbedDamage, uint32 resist, bool isPeriodic, uint32 blocked, bool criticalHit = false, bool split = false);
1196 void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo);
1197 void SendSpellDamageResist(Unit* target, uint32 spellId);
1198 void SendSpellDamageImmune(Unit* target, uint32 spellId);
1199
1200 void NearTeleportTo(Position const& pos, bool casting = false);
1201 void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false) { NearTeleportTo(Position(x, y, z, orientation), casting); }
1202 void SendTeleportPacket(Position const& pos, bool teleportingTransport = false);
1203 virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false);
1204 // returns true if unit's position really changed
1205 virtual bool UpdatePosition(Position const& pos, bool teleport = false);
1206 void UpdateOrientation(float orientation);
1207 void UpdateHeight(float newZ);
1208
1209 void SendMoveKnockBack(Player* player, float speedXY, float speedZ, float vcos, float vsin);
1210 void KnockbackFrom(float x, float y, float speedXY, float speedZ);
1211 void JumpTo(float speedXY, float speedZ, bool forward = true, Optional<Position> dest = {});
1212 void JumpTo(WorldObject* obj, float speedZ, bool withOrientation = false);
1213
1214 void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false);
1215
1216 void SetHoverHeight(float hoverHeight) { SetFloatValue(UNIT_FIELD_HOVERHEIGHT, hoverHeight); }
1217
1218 bool IsGravityDisabled() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); }
1219 bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); }
1220 bool IsHovering() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_HOVER); }
1221 bool SetWalk(bool enable);
1222 bool SetDisableGravity(bool disable, bool updateAnimTier = true);
1223 bool SetFall(bool enable);
1224 bool SetSwim(bool enable);
1225 bool SetCanFly(bool enable, bool packetOnly = false);
1226 bool SetWaterWalking(bool enable);
1227 bool SetFeatherFall(bool enable);
1228 bool SetHover(bool enable, bool updateAnimTier = true);
1229
1230 void SetInFront(WorldObject const* target);
1231 void SetFacingTo(float ori, bool force = true, uint32 movementId = EVENT_FACE);
1232 void SetFacingToObject(WorldObject const* object, bool force = true, uint32 movementId = EVENT_FACE);
1233
1234 bool IsAlive() const { return (m_deathState == ALIVE); }
1235 bool isDying() const { return (m_deathState == JUST_DIED); }
1236 bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); }
1237 bool IsGhouled() const;
1238 DeathState getDeathState() const { return m_deathState; }
1239 virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet
1240
1241 ObjectGuid GetOwnerGUID() const override { return GetGuidValue(UNIT_FIELD_SUMMONEDBY); }
1242 void SetOwnerGUID(ObjectGuid owner);
1243 ObjectGuid GetCreatorGUID() const { return GetGuidValue(UNIT_FIELD_CREATEDBY); }
1244 void SetCreatorGUID(ObjectGuid creator) { SetGuidValue(UNIT_FIELD_CREATEDBY, creator); }
1245 ObjectGuid GetMinionGUID() const { return GetGuidValue(UNIT_FIELD_SUMMON); }
1246 void SetMinionGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_SUMMON, guid); }
1247 ObjectGuid GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; }
1248 void SetPetGUID(ObjectGuid guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; }
1249 ObjectGuid GetCritterGUID() const { return GetGuidValue(UNIT_FIELD_CRITTER); }
1250 void SetCritterGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CRITTER, guid); }
1251
1252 ObjectGuid GetCharmerGUID() const { return GetGuidValue(UNIT_FIELD_CHARMEDBY); }
1253 Unit* GetCharmer() const { return m_charmer; }
1254
1255 ObjectGuid GetCharmedGUID() const { return GetGuidValue(UNIT_FIELD_CHARM); }
1256 Unit* GetCharmed() const { return m_charmed; }
1257
1258 bool IsControlledByPlayer() const { return m_ControlledByPlayer; }
1259 Player* GetControllingPlayer() const;
1260 ObjectGuid GetCharmerOrOwnerGUID() const override { return IsCharmed() ? GetCharmerGUID() : GetOwnerGUID(); }
1261 bool IsCharmedOwnedByPlayerOrPlayer() const { return GetCharmerOrOwnerOrOwnGUID().IsPlayer(); }
1262
1263 Guardian* GetGuardianPet() const;
1264 Minion* GetFirstMinion() const;
1265 Unit* GetCharmerOrOwner() const { return IsCharmed() ? GetCharmer() : GetOwner(); }
1266
1267 void SetMinion(Minion *minion, bool apply);
1268 void GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry);
1269 void RemoveAllMinionsByEntry(uint32 entry);
1270 void SetCharm(Unit* target, bool apply);
1271 Unit* GetNextRandomRaidMemberOrPet(float radius);
1272 bool SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp = nullptr);
1273 void RemoveCharmedBy(Unit* charmer);
1274 void RestoreFaction();
1275
1277 Unit* GetFirstControlled() const;
1278 void RemoveAllControlled();
1279
1280 bool IsCharmed() const { return !GetCharmerGUID().IsEmpty(); }
1281 bool IsCharming() const { return !GetCharmedGUID().IsEmpty(); }
1282 bool isPossessed() const { return HasUnitState(UNIT_STATE_POSSESSED); }
1283 bool isPossessedByPlayer() const;
1284 bool isPossessing() const;
1285 bool isPossessing(Unit* u) const;
1286
1287 CharmInfo* GetCharmInfo() { return m_charmInfo; }
1288 CharmInfo* InitCharmInfo();
1289 void DeleteCharmInfo();
1290 void SetPetNumberForClient(uint32 petNumber) { SetUInt32Value(UNIT_FIELD_PETNUMBER, petNumber); }
1291 void SetPetNameTimestamp(uint32 timestamp) { SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, timestamp); }
1292
1293 // base client control of this unit (possess effects, vehicles and similar). Not affected by temporary CC.
1294 bool IsCharmerOrSelfPlayer() const { return GetCharmerOrSelf()->IsPlayer(); }
1295 Unit* GetCharmerOrSelf() const;
1296 Player* GetCharmerOrSelfPlayer() const { return ToPlayer(GetCharmerOrSelf());}
1297 Unit* GetCharmedOrSelf() const { return IsCharming() ? GetCharmed() : const_cast<Unit*>(this); }
1298
1299 // real time client control status of this unit (possess effects, vehicles and similar). For example, if this unit is a player temporarly under fear, it will return false.
1300 bool IsMovedByClient() const { return _gameClientMovingMe != nullptr; }
1301 bool IsMovedByServer() const { return !IsMovedByClient(); }
1302 GameClient* GetGameClientMovingMe() const { return _gameClientMovingMe; }
1303 void SetGameClientMovingMe(GameClient* gameClientMovingMe) { _gameClientMovingMe = gameClientMovingMe; }
1304
1305 SharedVisionList const& GetSharedVisionList() { return m_sharedVision; }
1306 void AddPlayerToVision(Player* player);
1307 void RemovePlayerFromVision(Player* player);
1308 bool HasSharedVision() const { return !m_sharedVision.empty(); }
1309 void RemoveBindSightAuras();
1310 void RemoveCharmAuras();
1311
1312 Pet* CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id = 0);
1313 Pet* CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id = 0);
1314 bool InitTamedPet(Pet* pet, uint8 level, uint32 spell_id);
1315
1316 // aura apply/remove helpers - you should better not use these
1317 Aura* _TryStackingOrRefreshingExistingAura(AuraCreateInfo& createInfo);
1318 void _AddAura(UnitAura* aura, Unit* caster);
1319 AuraApplication* _CreateAuraApplication(Aura* aura, uint8 effMask);
1320 void _ApplyAuraEffect(Aura* aura, uint8 effIndex);
1321 void _ApplyAura(AuraApplication* aurApp, uint8 effMask);
1322 void _UnapplyAura(AuraApplicationMap::iterator& i, AuraRemoveMode removeMode);
1323 void _UnapplyAura(AuraApplication* aurApp, AuraRemoveMode removeMode);
1324 void _RemoveNoStackAurasDueToAura(Aura* aura, bool owned);
1325 void _RegisterAuraEffect(AuraEffect* aurEff, bool apply);
1326
1327 // m_ownedAuras container management
1328 AuraMap & GetOwnedAuras() { return m_ownedAuras; }
1329 AuraMap const& GetOwnedAuras() const { return m_ownedAuras; }
1330
1331 void RemoveOwnedAura(AuraMap::iterator& i, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1332 void RemoveOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1333 void RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1334
1335 Aura* GetOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, Aura* except = nullptr) const;
1336
1337 // m_appliedAuras container management
1338 AuraApplicationMap & GetAppliedAuras() { return m_appliedAuras; }
1339 AuraApplicationMap const& GetAppliedAuras() const { return m_appliedAuras; }
1340
1341 void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
1342 void RemoveAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1343 void RemoveAura(AuraApplication * aurApp, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
1344 void RemoveAura(Aura* aur, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
1345
1346 // Convenience methods removing auras by predicate
1347 void RemoveAppliedAuras(std::function<bool(AuraApplication const*)> const& check, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1348 void RemoveOwnedAuras(std::function<bool(Aura const*)> const& check, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1349
1350 // Optimized overloads taking advantage of map key
1351 void RemoveAppliedAuras(uint32 spellId, std::function<bool(AuraApplication const*)> const& check, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1352 void RemoveOwnedAuras(uint32 spellId, std::function<bool(Aura const*)> const& check, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1353
1354 void RemoveAurasByType(AuraType auraType, std::function<bool(AuraApplication const*)> const& check, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1355
1356 void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1357 void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
1358 void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, WorldObject* dispeller, uint8 chargesRemoved = 1);
1359 void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, WorldObject* stealer);
1360 void RemoveAurasDueToItemSpell(uint32 spellId, ObjectGuid castItemGuid);
1361 void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID = ObjectGuid::Empty, Aura* except = nullptr, bool negative = true, bool positive = true);
1362 void RemoveNotOwnSingleTargetAuras(uint32 newPhase = 0x0);
1363 void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except = 0);
1364 void RemoveAurasWithAttribute(uint32 flags);
1365 void RemoveAurasWithFamily(SpellFamilyNames family, flag96 const& familyFlag, ObjectGuid casterGUID);
1366 void RemoveAurasWithMechanic(uint32 mechanicMaskToRemove, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT, uint32 exceptSpellId = 0, bool withEffectMechanics = false);
1367 void RemoveMovementImpairingAuras(bool withRoot);
1368 void RemoveAurasByShapeShift();
1369
1370 void RemoveAreaAurasDueToLeaveWorld();
1371 void RemoveAllAuras();
1372 void RemoveArenaAuras();
1373 void RemoveAurasOnEvade();
1374 void RemoveAllAurasOnDeath();
1375 void RemoveAllAurasRequiringDeadTarget();
1376 void RemoveAllAurasExceptType(AuraType type);
1377 void RemoveAllAurasExceptType(AuraType type1, AuraType type2);
1378 void RemoveAllGroupBuffsFromCaster(ObjectGuid casterGUID);
1379 void DelayOwnedAuras(uint32 spellId, ObjectGuid caster, int32 delaytime);
1380
1381 void _RemoveAllAuraStatMods();
1382 void _ApplyAllAuraStatMods();
1383
1384 AuraEffectList const& GetAuraEffectsByType(AuraType type) const { return m_modAuras[type]; }
1385 AuraEffectList& GetAuraEffectsByType(AuraType type) { return m_modAuras[type]; }
1386 AuraList & GetSingleCastAuras() { return m_scAuras; }
1387 AuraList const& GetSingleCastAuras() const { return m_scAuras; }
1388
1389 AuraEffect* GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const;
1390 AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const;
1391 AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; // spell mustn't have familyflags
1392 AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID = ObjectGuid::Empty) const;
1393 AuraEffect* GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const;
1394
1395 AuraApplication * GetAuraApplication(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication * except = nullptr) const;
1396 Aura* GetAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const;
1397
1398 AuraApplication * GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication * except = nullptr) const;
1399 Aura* GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const;
1400
1401 void GetDispellableAuraList(WorldObject const* caster, uint32 dispelMask, DispelChargesList& dispelList, bool isReflect = false) const;
1402
1403 bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster = ObjectGuid::Empty) const;
1404 uint32 GetAuraCount(uint32 spellId) const;
1405 bool HasAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const;
1406 bool HasAuraType(AuraType auraType) const;
1407 bool HasAuraTypeWithCaster(AuraType auraType, ObjectGuid caster) const;
1408 bool HasAuraTypeWithMiscvalue(AuraType auraType, int32 miscValue) const;
1409 bool HasAuraTypeWithAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const;
1410 bool HasAuraTypeWithValue(AuraType auraType, int32 value) const;
1411 bool HasAuraTypeWithTriggerSpell(AuraType auratype, uint32 triggerSpell) const;
1412 bool HasNegativeAuraWithInterruptFlag(uint32 flag, ObjectGuid guid = ObjectGuid::Empty) const;
1413 bool HasAuraWithMechanic(uint32 mechanicMask) const;
1414 bool HasStrongerAuraWithDR(SpellInfo const* auraSpellInfo, Unit* caster, bool triggered) const;
1415
1416 AuraEffect* IsScriptOverriden(SpellInfo const* spell, int32 script) const;
1417 uint32 GetDiseasesByCaster(ObjectGuid casterGUID, bool remove = false);
1418 uint32 GetDoTsByCaster(ObjectGuid casterGUID) const;
1419
1420 int32 GetTotalAuraModifier(AuraType auraType) const;
1421 float GetTotalAuraMultiplier(AuraType auraType) const;
1422 int32 GetMaxPositiveAuraModifier(AuraType auraType) const;
1423 int32 GetMaxNegativeAuraModifier(AuraType auraType) const;
1424
1425 int32 GetTotalAuraModifier(AuraType auraType, std::function<bool(AuraEffect const*)> const& predicate) const;
1426 float GetTotalAuraMultiplier(AuraType auraType, std::function<bool(AuraEffect const*)> const& predicate) const;
1427 int32 GetMaxPositiveAuraModifier(AuraType auraType, std::function<bool(AuraEffect const*)> const& predicate) const;
1428 int32 GetMaxNegativeAuraModifier(AuraType auraType, std::function<bool(AuraEffect const*)> const& predicate) const;
1429
1430 int32 GetTotalAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const;
1431 float GetTotalAuraMultiplierByMiscMask(AuraType auraType, uint32 misc_mask) const;
1432 int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask, AuraEffect const* except = nullptr) const;
1433 int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const;
1434
1435 int32 GetTotalAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const;
1436 float GetTotalAuraMultiplierByMiscValue(AuraType auraType, int32 misc_value) const;
1437 int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const;
1438 int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const;
1439
1440 int32 GetTotalAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const;
1441 float GetTotalAuraMultiplierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const;
1442 int32 GetMaxPositiveAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const;
1443 int32 GetMaxNegativeAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const;
1444
1445 void UpdateResistanceBuffModsMod(SpellSchools school);
1446 void InitStatBuffMods();
1447 void UpdateStatBuffMod(Stats stat);
1448 void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; }
1449 void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); }
1450 uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
1451 void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); }
1452 uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); }
1453 uint32 GetCreatePowerValue(Powers power) const;
1454 float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0 + int32(stat)); }
1455 float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0 + int32(stat)); }
1456 float GetCreateStat(Stats stat) const { return m_createStats[stat]; }
1457
1458 uint32 GetChannelSpellId() const { return GetUInt32Value(UNIT_CHANNEL_SPELL); }
1459 void SetChannelSpellId(uint32 channelSpellId) { SetUInt32Value(UNIT_CHANNEL_SPELL, channelSpellId); }
1462
1463 void SetCurrentCastSpell(Spell* pSpell);
1464 void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true, SpellCastResult result = SPELL_FAILED_INTERRUPTED, Optional<SpellCastResult> resultOther = {});
1465 void FinishSpell(CurrentSpellTypes spellType, bool ok = true);
1466
1467 // set withDelayed to true to account delayed spells as cast
1468 // delayed+channeled spells are always accounted as cast
1469 // we can skip channeled or delayed checks using flags
1470 bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false, bool isAutoshoot = false, bool skipInstant = true) const;
1471
1472 // set withDelayed to true to interrupt delayed spells too
1473 // delayed+channeled spells are always interrupted
1474 void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0, bool withInstant = true);
1475
1476 Spell* GetCurrentSpell(CurrentSpellTypes spellType) const { return m_currentSpells[spellType]; }
1477 Spell* GetCurrentSpell(uint32 spellType) const { return m_currentSpells[spellType]; }
1478 Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
1479 int32 GetCurrentSpellCastTime(uint32 spell_id) const;
1480
1481 virtual bool HasSpellFocus(Spell const* /*focusSpell*/ = nullptr) const { return false; }
1482 virtual bool IsMovementPreventedByCasting() const;
1483
1484 SpellHistory* GetSpellHistory() { return _spellHistory; }
1485 SpellHistory const* GetSpellHistory() const { return _spellHistory; }
1486
1489
1491 void SetShapeshiftForm(ShapeshiftForm form);
1492
1493 bool IsInFeralForm() const;
1494
1495 bool IsInDisallowedMountForm() const;
1496
1501
1502 float m_modAttackSpeedPct[MAX_ATTACK];
1503 uint32 m_attackTimer[MAX_ATTACK];
1504
1505 // stat system
1506 void HandleStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply);
1507 void ApplyStatPctModifier(UnitMods unitMod, UnitModifierPctType modifierType, float amount);
1508
1509 void SetStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float val);
1510 void SetStatPctModifier(UnitMods unitMod, UnitModifierPctType modifierType, float val);
1511
1512 float GetFlatModifierValue(UnitMods unitMod, UnitModifierFlatType modifierType) const;
1513 float GetPctModifierValue(UnitMods unitMod, UnitModifierPctType modifierType) const;
1514
1515 void UpdateUnitMod(UnitMods unitMod);
1516
1517 // only players have item requirements
1518 virtual bool CheckAttackFitToAuraRequirement(WeaponAttackType /*attackType*/, AuraEffect const* /*aurEff*/) const { return true; }
1519
1520 virtual void UpdateDamageDoneMods(WeaponAttackType attackType, int32 skipEnchantSlot = -1);
1521 void UpdateAllDamageDoneMods();
1522
1523 void UpdateDamagePctDoneMods(WeaponAttackType attackType);
1524 void UpdateAllDamagePctDoneMods();
1525
1526 float GetTotalStatValue(Stats stat) const;
1527 float GetTotalAuraModValue(UnitMods unitMod) const;
1528 SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const;
1529 Stats GetStatByAuraGroup(UnitMods unitMod) const;
1530 Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const;
1531 bool CanModifyStats() const { return m_canModifyStats; }
1532 void SetCanModifyStats(bool modifyStats) { m_canModifyStats = modifyStats; }
1533 virtual bool UpdateStats(Stats stat) = 0;
1534 virtual bool UpdateAllStats() = 0;
1535 virtual void UpdateResistances(uint32 school) = 0;
1536 virtual void UpdateAllResistances();
1537 virtual void UpdateArmor() = 0;
1538 virtual void UpdateMaxHealth() = 0;
1539 virtual void UpdateMaxPower(Powers power) = 0;
1540 virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0;
1541 void SetAttackPower(int32 attackPower) { SetInt32Value(UNIT_FIELD_ATTACK_POWER, attackPower); }
1542 void SetAttackPowerModPos(int32 attackPowerMod) { SetInt16Value(UNIT_FIELD_ATTACK_POWER_MODS, 0, attackPowerMod); }
1543 void SetAttackPowerModNeg(int32 attackPowerMod) { SetInt16Value(UNIT_FIELD_ATTACK_POWER_MODS, 1, attackPowerMod); }
1544 void SetAttackPowerMultiplier(float attackPowerMult) { SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, attackPowerMult); }
1545 void SetRangedAttackPower(int32 attackPower) { SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, attackPower); }
1546 void SetRangedAttackPowerModPos(int32 attackPowerMod) { SetInt16Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS, 0, attackPowerMod); }
1547 void SetRangedAttackPowerModNeg(int32 attackPowerMod) { SetInt16Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS, 1, attackPowerMod); }
1548 void SetRangedAttackPowerMultiplier(float attackPowerMult) { SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER, attackPowerMult); }
1549 virtual void UpdateDamagePhysical(WeaponAttackType attType);
1550 float GetTotalAttackPowerValue(WeaponAttackType attType) const;
1551 float GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange type, uint8 damageIndex = 0) const;
1552 void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value, uint8 damageIndex = 0) { m_weaponDamage[attType][damageRange][damageIndex] = value; }
1553 virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage, uint8 damageIndex) const = 0;
1554 uint32 CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, uint8 itemDamagesMask = 0) const;
1555 float GetAPMultiplier(WeaponAttackType attType, bool normalized) const;
1556
1557 bool isInFrontInMap(Unit const* target, float distance, float arc = float(M_PI)) const;
1558 bool isInBackInMap(Unit const* target, float distance, float arc = float(M_PI)) const;
1559
1560 // Visibility system
1561 bool IsVisible() const;
1562 void SetVisible(bool x);
1563
1564 // common function for visibility checks for player/creatures with detection code
1565 void SetPhaseMask(uint32 newPhaseMask, bool update) override;// overwrite WorldObject::SetPhaseMask
1566 void UpdateObjectVisibility(bool forced = true) override;
1567
1570
1571 VisibleAuraMap const& GetVisibleAuras() const { return m_visibleAuras; }
1572 AuraApplication* GetVisibleAura(uint8 slot) const;
1573 void SetVisibleAura(uint8 slot, AuraApplication* aurApp);
1574 void RemoveVisibleAura(uint8 slot);
1575
1576 bool HasInterruptFlag(uint32 flags) const { return (m_interruptMask & flags) != 0; }
1577 void AddInterruptMask(uint32 flags) { m_interruptMask |= flags; }
1578 void UpdateInterruptMask();
1579
1580 virtual float GetNativeObjectScale() const { return 1.0f; }
1581 virtual void RecalculateObjectScale();
1582 uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
1583 virtual void SetDisplayId(uint32 modelId);
1584 uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
1585 void RestoreDisplayId();
1586 void SetNativeDisplayId(uint32 displayId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, displayId); }
1587 void SetTransformSpell(uint32 spellid) { m_transformSpell = spellid;}
1588 uint32 GetTransformSpell() const { return m_transformSpell;}
1589
1590 // DynamicObject management
1591 void _RegisterDynObject(DynamicObject* dynObj);
1592 void _UnregisterDynObject(DynamicObject* dynObj);
1593 DynamicObject* GetDynObject(uint32 spellId) const;
1594 std::vector<DynamicObject*> GetDynObjects(uint32 spellId) const;
1595 void RemoveDynObject(uint32 spellId);
1596 void RemoveAllDynObjects();
1597
1598 GameObject* GetGameObject(uint32 spellId) const;
1599 std::vector<GameObject*> GetGameObjects(uint32 spellId) const;
1600 void AddGameObject(GameObject* gameObj);
1601 void RemoveGameObject(GameObject* gameObj, bool del);
1602 void RemoveGameObject(uint32 spellid, bool del);
1603 void RemoveAllGameObjects();
1604
1605 void ModifyAuraState(AuraStateType flag, bool apply);
1606 uint32 BuildAuraStateUpdateForTarget(Unit const* target) const;
1607 bool HasAuraState(AuraStateType flag, SpellInfo const* spellProto = nullptr, Unit const* Caster = nullptr) const;
1608 void UnsummonAllTotems();
1609 bool IsMagnet() const;
1610 Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = nullptr);
1611
1612 int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const;
1613 uint32 SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const& spellEffectInfo, Optional<float> const& donePctTotal, uint32 stack = 1) const;
1614 float SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) const;
1615 uint32 SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype) const;
1616 int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const;
1617 uint32 SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const& spellEffectInfo, Optional<float> const& donePctTotal, uint32 stack = 1) const;
1618 float SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const;
1619 uint32 SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype) const;
1620
1621 uint32 MeleeDamageBonusDone(Unit* pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const* spellProto = nullptr, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL);
1622 uint32 MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto = nullptr, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL);
1623
1624 bool IsBlockCritical();
1625 float SpellCritChanceDone(SpellInfo const* spellInfo, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK, bool isPeriodic = false) const;
1626 float SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, float doneChance, WeaponAttackType attackType = BASE_ATTACK, bool isPeriodic = false) const;
1627 static uint32 SpellCriticalDamageBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage, Unit* victim);
1628 static uint32 SpellCriticalHealingBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage, Unit* victim);
1629
1630 void SetLastManaUse(uint32 spellCastTime) { m_lastManaUse = spellCastTime; }
1631 bool IsUnderLastManaUseEffect() const;
1632
1633 uint32 GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const;
1634 float CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffectType damagetype) const;
1635
1636 void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
1637 virtual bool IsImmunedToSpell(SpellInfo const* spellInfo, WorldObject const* caster, bool requireImmunityPurgesEffectAttribute = false) const;
1638 uint32 GetSchoolImmunityMask() const;
1639 uint32 GetDamageImmunityMask() const;
1640 uint32 GetMechanicImmunityMask() const;
1641
1642 bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const;
1643 bool IsImmunedToDamage(SpellInfo const* spellInfo) const;
1644 virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster, bool requireImmunityPurgesEffectAttribute = false) const;
1645
1646 static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr);
1647 static uint32 CalcArmorReducedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK, uint8 attackerLevel = 0);
1648 static uint32 CalcSpellResistedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo);
1649 static void CalcAbsorbResist(DamageInfo& damageInfo, Spell* spell = nullptr);
1650 static void CalcHealAbsorb(HealInfo& healInfo);
1651
1652 void UpdateSpeed(UnitMoveType mtype);
1653 float GetSpeed(UnitMoveType mtype) const;
1654 float GetSpeedRate(UnitMoveType mtype) const { return m_speed_rate[mtype]; }
1655 void SetSpeed(UnitMoveType mtype, float newValue);
1656 void SetSpeedRate(UnitMoveType mtype, float rate);
1657 private:
1658 void SetSpeedRateReal(UnitMoveType mtype, float rate);
1659
1660 public:
1661 float CalculateSpellpowerCoefficientLevelPenalty(SpellInfo const* spellInfo) const;
1662
1663 void FollowerAdded(AbstractFollower* f) { m_followingMe.insert(f); }
1664 void FollowerRemoved(AbstractFollower* f) { m_followingMe.erase(f); }
1665 void RemoveAllFollowers();
1666
1667 MotionMaster* GetMotionMaster() { return i_motionMaster; }
1668 MotionMaster const* GetMotionMaster() const { return i_motionMaster; }
1669 virtual MovementGeneratorType GetDefaultMovementType() const;
1670
1671 bool IsStopped() const { return !(HasUnitState(UNIT_STATE_MOVING)); }
1672 void StopMoving(bool force = false);
1673 void PauseMovement(uint32 timer = 0, uint8 slot = 0, bool forced = true); // timer in ms
1674 void ResumeMovement(uint32 timer = 0, uint8 slot = 0); // timer in ms
1675
1676 void AddUnitMovementFlag(uint32 f) { m_movementInfo.AddMovementFlag(f); }
1677 void RemoveUnitMovementFlag(uint32 f) { m_movementInfo.RemoveMovementFlag(f); }
1678 bool HasUnitMovementFlag(uint32 f) const { return m_movementInfo.HasMovementFlag(f); }
1679 uint32 GetUnitMovementFlags() const { return m_movementInfo.GetMovementFlags(); }
1680 void SetUnitMovementFlags(uint32 f) { m_movementInfo.SetMovementFlags(f); }
1681
1682 void AddExtraUnitMovementFlag(uint32 f) { m_movementInfo.AddExtraMovementFlag(f); }
1683 void RemoveExtraUnitMovementFlag(uint32 f) { m_movementInfo.RemoveExtraMovementFlag(f); }
1684 bool HasExtraUnitMovementFlag(uint32 f) const { return m_movementInfo.HasExtraMovementFlag(f); }
1685 uint32 GetExtraUnitMovementFlags() const { return m_movementInfo.GetExtraMovementFlags(); }
1686 void SetExtraUnitMovementFlags(uint32 f) { m_movementInfo.SetExtraMovementFlags(f); }
1687
1688 bool IsSplineEnabled() const;
1689
1690 void SetControlled(bool apply, UnitState state);
1691 void ApplyControlStatesIfNeeded();
1692
1694 // This unit having CP on other units
1695 uint8 GetComboPoints(Unit const* who = nullptr) const { return (who && m_comboTarget != who) ? 0 : m_comboPoints; }
1696 uint8 GetComboPoints(ObjectGuid const& guid) const { return (m_comboTarget && m_comboTarget->GetGUID() == guid) ? m_comboPoints : 0; }
1697 Unit* GetComboTarget() const { return m_comboTarget; }
1698 ObjectGuid GetComboTargetGUID() const { return m_comboTarget ? m_comboTarget->GetGUID() : ObjectGuid::Empty; }
1699 void AddComboPoints(Unit* target, int8 count);
1700 void AddComboPoints(int8 count) { AddComboPoints(nullptr, count); }
1701 void ClearComboPoints();
1702 void SendComboPoints();
1703 // Other units having CP on this unit
1704 void AddComboPointHolder(Unit* unit) { m_ComboPointHolders.insert(unit); }
1705 void RemoveComboPointHolder(Unit* unit) { m_ComboPointHolders.erase(unit); }
1706 void ClearComboPointHolders();
1707
1709 void SendPetActionFeedback(PetActionFeedback msg, uint32 spellId) const;
1710 void SendPetActionSound(PetAction action) const;
1711 void SendPetDismissSound() const;
1712 void SendPetAIReaction(ObjectGuid guid) const;
1714
1715 void PropagateSpeedChange();
1716
1717 // reactive attacks
1718 void ClearAllReactives();
1719 void StartReactiveTimer(ReactiveType reactive) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;}
1720 void UpdateReactives(uint32 p_time);
1721
1722 // group updates
1723 void UpdateAuraForGroup(uint8 slot);
1724
1725 // proc trigger system
1726 bool CanProc() const { return !m_procDeep; }
1727 void SetCantProc(bool apply);
1728
1729 uint32 GetModelForForm(ShapeshiftForm form, uint32 spellId) const;
1730
1731 friend class VehicleJoinEvent;
1733 bool CreateVehicleKit(uint32 id, uint32 creatureEntry);
1734 void RemoveVehicleKit();
1735 Vehicle* GetVehicleKit() const { return m_vehicleKit.get(); }
1737 Vehicle* GetVehicle() const { return m_vehicle; }
1738 void SetVehicle(Vehicle* vehicle) { m_vehicle = vehicle; }
1739 bool IsOnVehicle(Unit const* vehicle) const;
1740 Unit* GetVehicleBase() const;
1741 Unit* GetVehicleRoot() const;
1742 Creature* GetVehicleCreatureBase() const;
1743 ObjectGuid GetTransGUID() const override;
1745 TransportBase* GetDirectTransport() const;
1746
1747 void HandleSpellClick(Unit* clicker, int8 seatId = -1);
1748 void EnterVehicle(Unit* base, int8 seatId = -1);
1749 virtual void ExitVehicle(Position const* exitPosition = nullptr);
1750 void ChangeSeat(int8 seatId, bool next = true);
1751
1752 // Should only be called by AuraEffect::HandleAuraControlVehicle(AuraApplication const* auraApp, uint8 mode, bool apply) const;
1753 void _ExitVehicle(Position const* exitPosition = nullptr);
1754 void _EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp = nullptr);
1755
1756 void BuildMovementPacket(ByteBuffer* data) const;
1757 static void BuildMovementPacket(Position const& pos, Position const& transportPos, MovementInfo const& movementInfo, ByteBuffer* data);
1758
1759 bool isMoving() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_MOVING); }
1760 bool isTurning() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_TURNING); }
1761 virtual bool CanFly() const = 0;
1762 bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); }
1763 bool IsFalling() const;
1764 virtual bool CanEnterWater() const = 0;
1765 virtual bool CanSwim() const;
1766
1767 float GetHoverOffset() const
1768 {
1769 return HasUnitMovementFlag(MOVEMENTFLAG_HOVER) ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f;
1770 }
1771
1772 uint32 GetMovementCounterAndInc() { return m_movementCounter++; }
1773 PlayerMovementPendingChange& PeakFirstPendingMovementChange();
1774 PlayerMovementPendingChange PopPendingMovementChange();
1775 void PushPendingMovementChange(PlayerMovementPendingChange newChange);
1776 bool HasPendingMovementChange() const { return !m_pendingMovementChanges.empty(); }
1777 bool HasPendingMovementChange(MovementChangeType changeType) const;
1778 void PurgeAndApplyPendingMovementChanges(bool informObservers = true);
1779
1780 void RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker);
1781
1782 virtual float GetFollowAngle() const { return static_cast<float>(M_PI/2); }
1783
1784 void OutDebugInfo() const;
1785 virtual bool IsLoading() const { return false; }
1786 bool IsDuringRemoveFromWorld() const {return m_duringRemoveFromWorld;}
1787
1788 Pet* ToPet() { if (IsPet()) return reinterpret_cast<Pet*>(this); else return nullptr; }
1789 Pet const* ToPet() const { if (IsPet()) return reinterpret_cast<Pet const*>(this); else return nullptr; }
1790
1791 Totem* ToTotem() { if (IsTotem()) return reinterpret_cast<Totem*>(this); else return nullptr; }
1792 Totem const* ToTotem() const { if (IsTotem()) return reinterpret_cast<Totem const*>(this); else return nullptr; }
1793
1794 TempSummon* ToTempSummon() { if (IsSummon()) return reinterpret_cast<TempSummon*>(this); else return nullptr; }
1795 TempSummon const* ToTempSummon() const { if (IsSummon()) return reinterpret_cast<TempSummon const*>(this); else return nullptr; }
1796
1797 ObjectGuid GetTarget() const { return GetGuidValue(UNIT_FIELD_TARGET); }
1798 virtual void SetTarget(ObjectGuid /*guid*/) = 0;
1799
1800 void SetInstantCast(bool set) { _instantCast = set; }
1801 bool CanInstantCast() const { return _instantCast; }
1802
1803 // Movement info
1805
1806 int32 GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue = false, int32 miscValue = 0) const;
1807 bool IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplications = false);
1808 bool IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint8 auraEffectMask, bool removeOtherAuraApplications = false);
1809
1810 virtual void Talk(std::string_view text, ChatMsg msgType, Language language, float textRange, WorldObject const* target);
1811 virtual void Say(std::string_view text, Language language, WorldObject const* target = nullptr);
1812 virtual void Yell(std::string_view text, Language language, WorldObject const* target = nullptr);
1813 virtual void TextEmote(std::string_view text, WorldObject const* target = nullptr, bool isBossEmote = false);
1814 virtual void Whisper(std::string_view text, Language language, Player* target, bool isBossWhisper = false);
1815 virtual void Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target);
1816 virtual void Say(uint32 textId, WorldObject const* target = nullptr);
1817 virtual void Yell(uint32 textId, WorldObject const* target = nullptr);
1818 virtual void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false);
1819 virtual void Whisper(uint32 textId, Player* target, bool isBossWhisper = false);
1820
1821 float GetCollisionHeight() const override;
1822 uint32 GetVirtualItemId(uint32 slot) const;
1823 void SetVirtualItem(uint32 slot, uint32 itemId);
1824
1825 // returns if the unit can't enter combat
1826 bool IsCombatDisallowed() const { return _isCombatDisallowed; }
1827 // enables / disables combat interaction of this unit
1828 void SetIsCombatDisallowed(bool apply) { _isCombatDisallowed = apply; }
1829
1830 std::string GetDebugInfo() const override;
1831
1832 protected:
1833 explicit Unit (bool isWorldObject);
1834
1835 void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player const* target) const override;
1836 void DestroyForPlayer(Player* target, bool onDeath) const override;
1837
1838 void _UpdateSpells(uint32 time);
1839 void _DeleteRemovedAuras();
1840
1841 void _UpdateAutoRepeatSpell();
1842
1844
1846
1847 float m_createStats[MAX_STATS];
1848
1851
1853
1855
1856 typedef std::list<DynamicObject*> DynObjectList;
1858
1859 typedef std::list<GameObject*> GameObjectList;
1861
1863
1864 Spell* m_currentSpells[CURRENT_MAX_SPELL];
1865
1869 AuraMap::iterator m_auraUpdateIterator;
1871
1873 AuraList m_scAuras; // cast singlecast auras
1874 AuraApplicationList m_interruptableAuras; // auras which have interrupt mask applied on unit
1875 AuraStateAurasMap m_auraStateAuras; // Used for improve performance of aura state checks on aura apply/remove
1877
1878 float m_auraFlatModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_FLAT_END];
1879 float m_auraPctModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_PCT_END];
1880 float m_weaponDamage[MAX_ATTACK][2][2];
1882
1884
1885 float m_speed_rate[MAX_MOVE_TYPE];
1886
1887 Unit* m_charmer; // Unit that is charming ME
1888 Unit* m_charmed; // Unit that is being charmed BY ME
1892
1894
1895 uint32 m_reactiveTimer[MAX_REACTIVE];
1897
1900
1903
1904 bool IsAlwaysVisibleFor(WorldObject const* seer) const override;
1905 bool IsAlwaysDetectableFor(WorldObject const* seer) const override;
1906
1907 void DisableSpline();
1908
1909 void ProcessPositionDataChanged(PositionFullTerrainStatus const& data) override;
1910 virtual void ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<LiquidData> const& newLiquidData);
1911
1912 // notifiers
1913 virtual void AtEnterCombat() { }
1914 virtual void AtExitCombat();
1915
1916 virtual void AtEngage(Unit* target);
1917 virtual void AtDisengage() {}
1918
1919 private:
1920 friend class ImmediateMovementGenerator; // for UpdateSplineMovement
1921 void UpdateSplineMovement(uint32 t_diff);
1922 void UpdateSplinePosition();
1923 void SendFlightSplineSyncUpdate();
1924 void InterruptMovementBasedAuras();
1925 void CheckPendingMovementAcks();
1926
1927 // player or player's pet
1928 float GetCombatRatingReduction(CombatRating cr) const;
1929 uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const;
1930
1931 void ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMask, uint32 hitMask, WeaponAttackType attType);
1932
1933 protected:
1934 void SetFeared(bool apply);
1935 void SetConfused(bool apply);
1936 void SetStunned(bool apply);
1937 void SetRooted(bool apply);
1938
1939 private:
1940
1941 uint32 m_state; // Even derived shouldn't modify
1943
1945
1946 // Threat+combat management
1947 friend class CombatManager;
1949 friend class ThreatManager;
1951
1952 void UpdateCharmAI();
1953 void RestoreDisabledAI();
1954 typedef std::stack<std::shared_ptr<UnitAI>> UnitAIStack;
1956 std::shared_ptr<UnitAI> i_AI;
1958
1959 std::unordered_set<AbstractFollower*> m_followingMe;
1960
1963 std::unordered_set<Unit*> m_ComboPointHolders;
1964
1966 std::unordered_map<ObjectGuid /*guid*/, uint32 /*count*/> extraAttacksTargets;
1968
1969 bool m_cleanupDone; // lock made to not add stuff after cleanup before delete
1970 bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world
1972
1975
1977
1979
1981
1982 /* Player Movement fields START*/
1983
1984 // when a player controls this unit, and when change is made to this unit which requires an ack from the client to be acted (change of speed for example), this movementCounter is incremented
1986 std::deque<PlayerMovementPendingChange> m_pendingMovementChanges;
1987
1988 /* Player Movement fields END*/
1989};
1990
1991namespace Trinity
1992{
1993 // Binary predicate for sorting Units based on percent value of a power
1995 {
1996 public:
1997 PowerPctOrderPred(Powers power, bool ascending = true) : _power(power), _ascending(ascending) { }
1998
1999 bool operator()(WorldObject const* objA, WorldObject const* objB) const
2000 {
2001 Unit const* a = objA->ToUnit();
2002 Unit const* b = objB->ToUnit();
2003 float rA = a ? a->GetPowerPct(_power) : 0.0f;
2004 float rB = b ? b->GetPowerPct(_power) : 0.0f;
2005 return _ascending ? rA < rB : rA > rB;
2006 }
2007
2008 bool operator()(Unit const* a, Unit const* b) const
2009 {
2010 float rA = a->GetPowerPct(_power);
2011 float rB = b->GetPowerPct(_power);
2012 return _ascending ? rA < rB : rA > rB;
2013 }
2014
2015 private:
2017 bool const _ascending;
2018 };
2019
2020 // Binary predicate for sorting Units based on percent value of health
2022 {
2023 public:
2024 HealthPctOrderPred(bool ascending = true) : _ascending(ascending) { }
2025
2026 bool operator()(WorldObject const* objA, WorldObject const* objB) const
2027 {
2028 Unit const* a = objA->ToUnit();
2029 Unit const* b = objB->ToUnit();
2030 float rA = (a && a->GetMaxHealth()) ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
2031 float rB = (b && b->GetMaxHealth()) ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
2032 return _ascending ? rA < rB : rA > rB;
2033 }
2034
2035 bool operator() (Unit const* a, Unit const* b) const
2036 {
2037 float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
2038 float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
2039 return _ascending ? rA < rB : rA > rB;
2040 }
2041
2042 private:
2043 bool const _ascending;
2044 };
2045}
2046
2047#endif
#define M_PI
Definition Common.h:72
#define TC_GAME_API
Definition Define.h:114
uint8_t uint8
Definition Define.h:135
int64_t int64
Definition Define.h:128
int8_t int8
Definition Define.h:131
int32_t int32
Definition Define.h:129
uint64_t uint64
Definition Define.h:132
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
uint16 flags
std::string GetDebugInfo()
Definition Errors.cpp:155
#define ASSERT
Definition Errors.h:68
ZLiquidStatus
Definition MapDefines.h:74
MovementGeneratorType
#define NOMINAL_MELEE_RANGE
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
PetActionFeedback
Definition PetDefines.h:71
PetAction
Definition PetDefines.h:80
SpellSchools
@ SPELL_SCHOOL_NORMAL
Language
Gender
SpellSchoolMask
@ SPELL_SCHOOL_MASK_NORMAL
@ EVENT_FACE
@ CREATURE_TYPE_CRITTER
WeaponAttackType
@ MAX_ATTACK
@ BASE_ATTACK
@ MAX_SPELL_IMMUNITY
SpellFamilyNames
Powers
ChatMsg
DiminishingLevels
@ DIMINISHING_LEVEL_1
DiminishingGroup
@ MAX_SUMMON_SLOT
@ SUMMON_SLOT_PET
SpellMissInfo
AuraStateType
@ AURA_STATE_FROZEN
Stats
@ MAX_STATS
#define MAX_GAMEOBJECT_SLOT
SpellCastResult
@ SPELL_FAILED_INTERRUPTED
AuraRemoveMode
@ AURA_REMOVE_BY_DEFAULT
@ TOTAL_AURAS
@ SPELL_AURA_MOD_FEAR
@ SPELL_AURA_MOD_INVISIBILITY
@ SPELL_AURA_MOD_ROOT
@ SPELL_AURA_MOD_STEALTH
ShapeshiftForm
@ UNIT_BYTES_2_OFFSET_SHEATH_STATE
Definition UnitDefines.h:77
@ UNIT_BYTES_2_OFFSET_PVP_FLAG
Definition UnitDefines.h:78
@ UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM
Definition UnitDefines.h:80
@ UNIT_BYTES_2_OFFSET_PET_FLAGS
Definition UnitDefines.h:79
@ UNIT_BYTES_0_OFFSET_POWER_TYPE
Definition UnitDefines.h:64
@ UNIT_BYTES_0_OFFSET_RACE
Definition UnitDefines.h:61
@ UNIT_BYTES_0_OFFSET_GENDER
Definition UnitDefines.h:63
@ UNIT_BYTES_0_OFFSET_CLASS
Definition UnitDefines.h:62
UnitFlags2
UnitPetFlag
HitInfo
ReactStates
UnitStandStateType
Definition UnitDefines.h:33
@ MOVEMENTFLAG_MASK_MOVING
@ MOVEMENTFLAG_DISABLE_GRAVITY
@ MOVEMENTFLAG_FLYING
@ MOVEMENTFLAG_MASK_TURNING
@ MOVEMENTFLAG_HOVER
@ MOVEMENTFLAG_WALKING
#define MAX_MOVE_TYPE
@ UNIT_BYTES_1_OFFSET_ANIM_TIER
Definition UnitDefines.h:72
@ UNIT_BYTES_1_OFFSET_STAND_STATE
Definition UnitDefines.h:69
@ UNIT_BYTES_1_OFFSET_VIS_FLAG
Definition UnitDefines.h:71
ActiveStates
@ ACT_DECIDE
@ ACT_ENABLED
@ ACT_PASSIVE
@ ACT_DISABLED
NPCFlags
Non Player Character flags.
@ UNIT_NPC_FLAG_TABARDDESIGNER
@ UNIT_NPC_FLAG_BANKER
@ UNIT_NPC_FLAG_AUCTIONEER
@ UNIT_NPC_FLAG_VENDOR
@ UNIT_NPC_FLAG_GOSSIP
@ UNIT_NPC_FLAG_BATTLEMASTER
@ UNIT_NPC_FLAG_QUESTGIVER
@ UNIT_NPC_FLAG_INNKEEPER
@ UNIT_NPC_FLAG_FLIGHTMASTER
@ UNIT_NPC_FLAG_REPAIR
@ UNIT_NPC_FLAG_TRAINER
@ UNIT_NPC_FLAG_PETITIONER
@ UNIT_NPC_FLAG_SPIRITGUIDE
@ UNIT_NPC_FLAG_SPIRITHEALER
SheathState
Definition UnitDefines.h:97
UnitPVPStateFlags
@ UNIT_BYTE2_FLAG_PVP
@ UNIT_BYTE2_FLAG_FFA_PVP
@ UNIT_BYTE2_FLAG_SANCTUARY
AnimTier
Definition UnitDefines.h:85
UnitVisFlags
Definition UnitDefines.h:50
CommandStates
UnitMoveType
UnitFlags
@ UNIT_FLAG_IN_COMBAT
@ UNIT_FLAG_IMMUNE_TO_NPC
@ UNIT_FLAG_IMMUNE_TO_PC
@ UNIT_FLAG_MOUNT
UnitModifierFlatType
Definition Unit.h:137
@ BASE_VALUE
Definition Unit.h:138
@ MODIFIER_TYPE_FLAT_END
Definition Unit.h:140
@ TOTAL_VALUE
Definition Unit.h:139
std::unordered_multimap< uint32, uint32 > SpellImmuneContainer
Definition Unit.h:134
UnitTypeMask
Definition Unit.h:362
@ UNIT_MASK_NONE
Definition Unit.h:363
@ UNIT_MASK_PUPPET
Definition Unit.h:370
@ UNIT_MASK_CONTROLABLE_GUARDIAN
Definition Unit.h:372
@ UNIT_MASK_HUNTER_PET
Definition Unit.h:371
@ UNIT_MASK_TOTEM
Definition Unit.h:367
@ UNIT_MASK_ACCESSORY
Definition Unit.h:373
@ UNIT_MASK_SUMMON
Definition Unit.h:364
@ UNIT_MASK_VEHICLE
Definition Unit.h:369
@ UNIT_MASK_GUARDIAN
Definition Unit.h:366
@ UNIT_MASK_MINION
Definition Unit.h:365
@ UNIT_MASK_PET
Definition Unit.h:368
BaseModType
Definition Unit.h:203
@ FLAT_MOD
Definition Unit.h:204
@ MOD_END
Definition Unit.h:206
@ PCT_MOD
Definition Unit.h:205
UnitActionBarEntry CharmSpellInfo
Definition Unit.h:660
#define MAX_UNIT_ACTION_BAR_INDEX
Definition Unit.h:670
MovementChangeType
Definition Unit.h:275
@ SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY
VictimState
Definition Unit.h:46
@ VICTIMSTATE_DEFLECTS
Definition Unit.h:55
@ VICTIMSTATE_INTERRUPT
Definition Unit.h:51
@ VICTIMSTATE_INTACT
Definition Unit.h:47
@ VICTIMSTATE_HIT
Definition Unit.h:48
@ VICTIMSTATE_DODGE
Definition Unit.h:49
@ VICTIMSTATE_IS_IMMUNE
Definition Unit.h:54
@ VICTIMSTATE_PARRY
Definition Unit.h:50
@ VICTIMSTATE_BLOCKS
Definition Unit.h:52
@ VICTIMSTATE_EVADES
Definition Unit.h:53
#define UNIT_ACTION_BUTTON_ACTION(X)
Definition Unit.h:615
WeaponDamageRange
Definition Unit.h:151
@ MINDAMAGE
Definition Unit.h:152
@ MAXDAMAGE
Definition Unit.h:153
UnitMods
Definition Unit.h:157
@ UNIT_MOD_DAMAGE_OFFHAND
Definition Unit.h:181
@ UNIT_MOD_RUNE
Definition Unit.h:169
@ UNIT_MOD_STAT_INTELLECT
Definition Unit.h:161
@ UNIT_MOD_POWER_END
Definition Unit.h:190
@ UNIT_MOD_STAT_SPIRIT
Definition Unit.h:162
@ UNIT_MOD_ARMOR
Definition Unit.h:171
@ UNIT_MOD_RESISTANCE_SHADOW
Definition Unit.h:176
@ UNIT_MOD_RESISTANCE_FROST
Definition Unit.h:175
@ UNIT_MOD_END
Definition Unit.h:183
@ UNIT_MOD_ATTACK_POWER
Definition Unit.h:178
@ UNIT_MOD_STAT_END
Definition Unit.h:186
@ UNIT_MOD_RESISTANCE_HOLY
Definition Unit.h:172
@ UNIT_MOD_RESISTANCE_START
Definition Unit.h:187
@ UNIT_MOD_RESISTANCE_ARCANE
Definition Unit.h:177
@ UNIT_MOD_ENERGY
Definition Unit.h:167
@ UNIT_MOD_HEALTH
Definition Unit.h:163
@ UNIT_MOD_DAMAGE_RANGED
Definition Unit.h:182
@ UNIT_MOD_POWER_START
Definition Unit.h:189
@ UNIT_MOD_RESISTANCE_FIRE
Definition Unit.h:173
@ UNIT_MOD_STAT_STRENGTH
Definition Unit.h:158
@ UNIT_MOD_RESISTANCE_NATURE
Definition Unit.h:174
@ UNIT_MOD_STAT_AGILITY
Definition Unit.h:159
@ UNIT_MOD_RESISTANCE_END
Definition Unit.h:188
@ UNIT_MOD_FOCUS
Definition Unit.h:166
@ UNIT_MOD_DAMAGE_MAINHAND
Definition Unit.h:180
@ UNIT_MOD_HAPPINESS
Definition Unit.h:168
@ UNIT_MOD_MANA
Definition Unit.h:164
@ UNIT_MOD_STAT_START
Definition Unit.h:185
@ UNIT_MOD_RAGE
Definition Unit.h:165
@ UNIT_MOD_STAT_STAMINA
Definition Unit.h:160
@ UNIT_MOD_RUNIC_POWER
Definition Unit.h:170
@ UNIT_MOD_ATTACK_POWER_RANGED
Definition Unit.h:179
TC_GAME_API float playerBaseMoveSpeed[MAX_MOVE_TYPE]
Definition Unit.cpp:100
ActionBarIndex
Definition Unit.h:663
@ ACTION_BAR_INDEX_PET_SPELL_START
Definition Unit.h:665
@ ACTION_BAR_INDEX_PET_SPELL_END
Definition Unit.h:666
@ ACTION_BAR_INDEX_END
Definition Unit.h:667
@ ACTION_BAR_INDEX_START
Definition Unit.h:664
DeathState
Definition Unit.h:210
@ CORPSE
Definition Unit.h:213
@ DEAD
Definition Unit.h:214
@ ALIVE
Definition Unit.h:211
@ JUST_RESPAWNED
Definition Unit.h:215
@ JUST_DIED
Definition Unit.h:212
CurrentSpellTypes
Definition Unit.h:605
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:608
@ CURRENT_GENERIC_SPELL
Definition Unit.h:607
@ CURRENT_MELEE_SPELL
Definition Unit.h:606
@ CURRENT_AUTOREPEAT_SPELL
Definition Unit.h:609
UnitState
Definition Unit.h:219
@ UNIT_STATE_DISTRACTED
Definition Unit.h:232
@ UNIT_STATE_NOT_MOVE
Definition Unit.h:265
@ UNIT_STATE_EVADE
Definition Unit.h:242
@ UNIT_STATE_FOLLOW_FORMATION
Definition Unit.h:239
@ UNIT_STATE_DIED
Definition Unit.h:220
@ UNIT_STATE_ATTACK_PLAYER
Definition Unit.h:234
@ UNIT_STATE_POSSESSED
Definition Unit.h:236
@ UNIT_STATE_CHASE
Definition Unit.h:225
@ UNIT_STATE_ROAMING_MOVE
Definition Unit.h:243
@ UNIT_STATE_UNATTACKABLE
Definition Unit.h:258
@ UNIT_STATE_ALL_STATE
Definition Unit.h:268
@ UNIT_STATE_LOST_CONTROL
Definition Unit.h:261
@ UNIT_STATE_ALL_STATE_SUPPORTED
Definition Unit.h:251
@ UNIT_STATE_CANNOT_AUTOATTACK
Definition Unit.h:262
@ UNIT_STATE_CONFUSED
Definition Unit.h:231
@ UNIT_STATE_FOLLOW_FORMATION_MOVE
Definition Unit.h:249
@ UNIT_STATE_FLEEING_MOVE
Definition Unit.h:245
@ UNIT_STATE_ROOT
Definition Unit.h:230
@ UNIT_STATE_SIGHTLESS
Definition Unit.h:263
@ UNIT_STATE_CONFUSED_MOVE
Definition Unit.h:244
@ UNIT_STATE_CHASE_MOVE
Definition Unit.h:246
@ UNIT_STATE_ISOLATED
Definition Unit.h:233
@ UNIT_STATE_FOLLOW
Definition Unit.h:229
@ UNIT_STATE_CHARGING
Definition Unit.h:237
@ UNIT_STATE_IGNORE_PATHFINDING
Definition Unit.h:248
@ UNIT_STATE_ROAMING
Definition Unit.h:224
@ UNIT_STATE_CONTROLLED
Definition Unit.h:260
@ UNIT_STATE_FLEEING
Definition Unit.h:227
@ UNIT_STATE_CANNOT_TURN
Definition Unit.h:264
@ UNIT_STATE_MOVING
Definition Unit.h:259
@ UNIT_STATE_FOLLOW_MOVE
Definition Unit.h:247
@ UNIT_STATE_MOVE
Definition Unit.h:240
@ UNIT_STATE_MELEE_ATTACKING
Definition Unit.h:221
@ UNIT_STATE_IN_FLIGHT
Definition Unit.h:228
@ UNIT_STATE_FOCUSING
Definition Unit.h:226
@ UNIT_STATE_CASTING
Definition Unit.h:235
@ UNIT_STATE_ROTATING
Definition Unit.h:241
@ UNIT_STATE_ALL_ERASABLE
Definition Unit.h:267
@ UNIT_STATE_STUNNED
Definition Unit.h:223
@ UNIT_STATE_CHARMED
Definition Unit.h:222
@ UNIT_STATE_JUMPING
Definition Unit.h:238
std::list< Player * > SharedVisionList
Definition Unit.h:650
MeleeHitOutcome
Definition Unit.h:393
@ MELEE_HIT_CRUSHING
Definition Unit.h:395
@ MELEE_HIT_BLOCK
Definition Unit.h:394
@ MELEE_HIT_CRIT
Definition Unit.h:395
@ MELEE_HIT_NORMAL
Definition Unit.h:395
@ MELEE_HIT_EVADE
Definition Unit.h:394
@ MELEE_HIT_DODGE
Definition Unit.h:394
@ MELEE_HIT_MISS
Definition Unit.h:394
@ MELEE_HIT_PARRY
Definition Unit.h:394
@ MELEE_HIT_GLANCING
Definition Unit.h:395
BaseModGroup
Definition Unit.h:194
@ OFFHAND_CRIT_PERCENTAGE
Definition Unit.h:197
@ BASEMOD_END
Definition Unit.h:199
@ SHIELD_BLOCK_VALUE
Definition Unit.h:198
@ CRIT_PERCENTAGE
Definition Unit.h:195
@ RANGED_CRIT_PERCENTAGE
Definition Unit.h:196
#define MAKE_UNIT_ACTION_BUTTON(A, T)
Definition Unit.h:617
std::vector< DispelableAura > DispelChargesList
Definition Unit.h:132
#define CURRENT_MAX_SPELL
Definition Unit.h:613
CombatRating
Definition Unit.h:321
@ CR_EXPERTISE
Definition Unit.h:345
@ CR_HIT_TAKEN_MELEE
Definition Unit.h:333
@ CR_WEAPON_SKILL_RANGED
Definition Unit.h:344
@ CR_HASTE_RANGED
Definition Unit.h:340
@ CR_HIT_MELEE
Definition Unit.h:327
@ CR_CRIT_TAKEN_RANGED
Definition Unit.h:337
@ CR_CRIT_TAKEN_SPELL
Definition Unit.h:338
@ CR_ARMOR_PENETRATION
Definition Unit.h:346
@ CR_CRIT_MELEE
Definition Unit.h:330
@ CR_CRIT_RANGED
Definition Unit.h:331
@ CR_HIT_TAKEN_SPELL
Definition Unit.h:335
@ CR_WEAPON_SKILL
Definition Unit.h:322
@ CR_PARRY
Definition Unit.h:325
@ CR_WEAPON_SKILL_OFFHAND
Definition Unit.h:343
@ CR_DODGE
Definition Unit.h:324
@ CR_DEFENSE_SKILL
Definition Unit.h:323
@ CR_HASTE_MELEE
Definition Unit.h:339
@ CR_BLOCK
Definition Unit.h:326
@ CR_WEAPON_SKILL_MAINHAND
Definition Unit.h:342
@ CR_HASTE_SPELL
Definition Unit.h:341
@ CR_HIT_SPELL
Definition Unit.h:329
@ CR_HIT_TAKEN_RANGED
Definition Unit.h:334
@ CR_CRIT_SPELL
Definition Unit.h:332
@ CR_HIT_RANGED
Definition Unit.h:328
@ CR_CRIT_TAKEN_MELEE
Definition Unit.h:336
InventorySlot
Definition Unit.h:60
@ NULL_BAG
Definition Unit.h:61
@ NULL_SLOT
Definition Unit.h:62
uint32 createProcHitMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missCondition)
Definition Unit.cpp:10001
#define UNIT_ACTION_BUTTON_TYPE(X)
Definition Unit.h:616
DamageEffectType
Definition Unit.h:352
@ SELF_DAMAGE
Definition Unit.h:358
@ DIRECT_DAMAGE
Definition Unit.h:353
@ NODAMAGE
Definition Unit.h:357
@ DOT
Definition Unit.h:355
@ SPELL_DIRECT_DAMAGE
Definition Unit.h:354
@ HEAL
Definition Unit.h:356
CharmType
Definition Unit.h:653
@ CHARM_TYPE_CHARM
Definition Unit.h:654
@ CHARM_TYPE_POSSESS
Definition Unit.h:655
@ CHARM_TYPE_CONVERT
Definition Unit.h:657
@ CHARM_TYPE_VEHICLE
Definition Unit.h:656
std::list< Unit * > UnitList
Definition Unit.h:105
#define REACTIVE_TIMER_START
Definition Unit.h:741
ReactiveType
Definition Unit.h:744
@ MAX_REACTIVE
Definition Unit.h:749
@ REACTIVE_OVERPOWER
Definition Unit.h:747
@ REACTIVE_DEFENSE
Definition Unit.h:745
@ REACTIVE_HUNTER_PARRY
Definition Unit.h:746
@ REACTIVE_WOLVERINE_BITE
Definition Unit.h:748
TC_GAME_API float baseMoveSpeed[MAX_MOVE_TYPE]
Definition Unit.cpp:87
UnitModifierPctType
Definition Unit.h:144
@ MODIFIER_TYPE_PCT_END
Definition Unit.h:147
@ TOTAL_PCT
Definition Unit.h:146
@ BASE_PCT
Definition Unit.h:145
@ UNIT_FIELD_RESISTANCES
@ UNIT_NPC_FLAGS
@ UNIT_FIELD_PETNUMBER
@ UNIT_FIELD_POSSTAT0
@ UNIT_FIELD_CRITTER
@ UNIT_FIELD_CHANNEL_OBJECT
@ UNIT_FIELD_HEALTH
@ UNIT_FIELD_ATTACK_POWER_MODS
@ UNIT_FIELD_SUMMONEDBY
@ UNIT_FIELD_DISPLAYID
@ UNIT_FIELD_BYTES_0
@ UNIT_FIELD_LEVEL
@ UNIT_FIELD_FACTIONTEMPLATE
@ UNIT_FIELD_RANGED_ATTACK_POWER
@ UNIT_FIELD_MAXPOWER1
@ UNIT_MOD_CAST_SPEED
@ UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER
@ UNIT_FIELD_COMBATREACH
@ UNIT_FIELD_SUMMON
@ UNIT_FIELD_FLAGS_2
@ UNIT_FIELD_MOUNTDISPLAYID
@ UNIT_FIELD_ATTACK_POWER_MULTIPLIER
@ UNIT_FIELD_ATTACK_POWER
@ UNIT_FIELD_POWER1
@ UNIT_FIELD_CHARMEDBY
@ UNIT_FIELD_CHARM
@ UNIT_FIELD_BASE_MANA
@ UNIT_FIELD_PET_NAME_TIMESTAMP
@ UNIT_FIELD_FLAGS
@ UNIT_NPC_EMOTESTATE
@ UNIT_FIELD_CREATEDBY
@ UNIT_FIELD_TARGET
@ UNIT_FIELD_RANGED_ATTACK_POWER_MODS
@ UNIT_FIELD_HOVERHEIGHT
@ UNIT_FIELD_NEGSTAT0
@ UNIT_FIELD_MAXHEALTH
@ UNIT_FIELD_BASE_HEALTH
@ UNIT_FIELD_BYTES_1
@ UNIT_FIELD_BOUNDINGRADIUS
@ UNIT_FIELD_STAT0
@ UNIT_CHANNEL_SPELL
@ UNIT_FIELD_NATIVEDISPLAYID
@ UNIT_FIELD_BYTES_2
@ UNIT_CREATED_BY_SPELL
@ UNIT_FIELD_BASEATTACKTIME
@ UNIT_DYNAMIC_FLAGS
T CalculatePct(T base, U pct)
Definition Util.h:71
uint32 m_resist
Definition Unit.h:440
Unit *const m_attacker
Definition Unit.h:432
WeaponAttackType m_attackType
Definition Unit.h:438
Unit * GetVictim() const
Definition Unit.h:459
Unit * GetAttacker() const
Definition Unit.h:458
SpellInfo const *const m_spellInfo
Definition Unit.h:435
uint32 m_block
Definition Unit.h:441
SpellInfo const * GetSpellInfo() const
Definition Unit.h:460
DamageEffectType GetDamageType() const
Definition Unit.h:462
WeaponAttackType GetAttackType() const
Definition Unit.h:463
uint32 GetResist() const
Definition Unit.h:466
SpellSchoolMask GetSchoolMask() const
Definition Unit.h:461
uint32 m_absorb
Definition Unit.h:439
uint32 m_damage
Definition Unit.h:434
uint32 GetBlock() const
Definition Unit.h:467
uint32 m_hitMask
Definition Unit.h:442
SpellSchoolMask const m_schoolMask
Definition Unit.h:436
uint32 GetDamage() const
Definition Unit.h:464
DamageEffectType const m_damageType
Definition Unit.h:437
Unit *const m_victim
Definition Unit.h:433
uint32 GetAbsorb() const
Definition Unit.h:465
uint32 GetDispellerSpellId() const
Definition Unit.h:405
DispelInfo(WorldObject *dispeller, uint32 dispellerSpellId, uint8 chargesRemoved)
Definition Unit.h:401
WorldObject * GetDispeller() const
Definition Unit.h:404
void SetRemovedCharges(uint8 amount)
Definition Unit.h:407
uint32 _dispellerSpell
Definition Unit.h:410
uint8 _chargesRemoved
Definition Unit.h:411
WorldObject * _dispeller
Definition Unit.h:409
uint8 GetRemovedCharges() const
Definition Unit.h:406
uint8 _charges
Definition Unit.h:130
void IncrementCharges()
Definition Unit.h:117
Aura * _aura
Definition Unit.h:128
Aura * GetAura() const
Definition Unit.h:113
uint8 GetDispelCharges() const
Definition Unit.h:115
int32 _chance
Definition Unit.h:129
bool DecrementCharge()
Definition Unit.h:118
uint32 _heal
Definition Unit.h:477
Unit *const _healer
Definition Unit.h:475
Unit * GetHealer() const
Definition Unit.h:490
uint32 _effectiveHeal
Definition Unit.h:478
uint32 GetAbsorb() const
Definition Unit.h:494
uint32 GetEffectiveHeal() const
Definition Unit.h:493
Unit *const _target
Definition Unit.h:476
SpellInfo const *const _spellInfo
Definition Unit.h:480
SpellInfo const * GetSpellInfo() const
Definition Unit.h:495
uint32 _absorb
Definition Unit.h:479
void SetEffectiveHeal(uint32 amount)
Definition Unit.h:488
SpellSchoolMask GetSchoolMask() const
Definition Unit.h:496
Unit * GetTarget() const
Definition Unit.h:491
SpellSchoolMask const _schoolMask
Definition Unit.h:481
uint32 GetHeal() const
Definition Unit.h:492
uint32 _hitMask
Definition Unit.h:482
Definition Item.h:62
static ObjectGuid const Empty
Definition ObjectGuid.h:140
static Unit * ToUnit(Object *o)
Definition Object.h:192
Definition Pet.h:40
uint32 GetHitMask() const
Definition Unit.h:514
HealInfo * GetHealInfo() const
Definition Unit.h:520
DamageInfo * _damageInfo
Definition Unit.h:532
HealInfo * _healInfo
Definition Unit.h:533
Unit * GetActionTarget() const
Definition Unit.h:509
uint32 GetSpellTypeMask() const
Definition Unit.h:512
Spell const * GetProcSpell() const
Definition Unit.h:522
uint32 GetTypeMask() const
Definition Unit.h:511
Unit *const _actionTarget
Definition Unit.h:526
uint32 _hitMask
Definition Unit.h:530
Unit * GetActor()
Definition Unit.h:508
uint32 _spellTypeMask
Definition Unit.h:528
uint32 GetSpellPhaseMask() const
Definition Unit.h:513
Unit *const _actor
Definition Unit.h:525
Spell * _spell
Definition Unit.h:531
DamageInfo * GetDamageInfo() const
Definition Unit.h:519
uint32 _typeMask
Definition Unit.h:527
uint32 _spellPhaseMask
Definition Unit.h:529
Definition Spell.h:152
Definition Totem.h:39
HealthPctOrderPred(bool ascending=true)
Definition Unit.h:2024
bool operator()(WorldObject const *objA, WorldObject const *objB) const
Definition Unit.h:2026
bool operator()(Unit const *a, Unit const *b) const
Definition Unit.h:2008
bool operator()(WorldObject const *objA, WorldObject const *objB) const
Definition Unit.h:1999
Powers const _power
Definition Unit.h:2016
PowerPctOrderPred(Powers power, bool ascending=true)
Definition Unit.h:1997
Specialized variant of std::shared_ptr that enforces unique ownership and/or std::unique_ptr with std...
Trinity::unique_trackable_ptr companion class, replicating what std::weak_ptr is to std::shared_ptr.
Definition Unit.h:769
float GetSpellCritChanceReduction() const
Definition Unit.h:1055
ObjectGuid GetComboTargetGUID() const
Definition Unit.h:1698
Unit * GetCharmed() const
Definition Unit.h:1256
void ClearUnitState(uint32 f)
Definition Unit.h:877
bool IsStopped() const
Definition Unit.h:1671
uint32 GetChannelSpellId() const
Definition Unit.h:1458
bool IsVehicle() const
Definition Unit.h:887
void ReplaceAllDynamicFlags(uint32 flag) override
Definition Unit.h:819
void SetLastDamagedTargetGuid(ObjectGuid guid)
Definition Unit.h:1046
std::pair< AuraApplicationMap::iterator, AuraApplicationMap::iterator > AuraApplicationMapBoundsNonConst
Definition Unit.h:782
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:844
bool IsCharmed() const
Definition Unit.h:1280
AuraList m_scAuras
Definition Unit.h:1873
bool m_duringRemoveFromWorld
Definition Unit.h:1970
float GetBoundingRadius() const
Definition Unit.h:841
Vehicle * GetVehicle() const
Definition Unit.h:1737
float GetPosStat(Stats stat) const
Definition Unit.h:1454
void AddComboPointHolder(Unit *unit)
Definition Unit.h:1704
bool IsBattleMaster() const
Definition Unit.h:1107
std::list< GameObject * > GameObjectList
Definition Unit.h:1859
bool HealthAbovePct(int32 pct) const
Definition Unit.h:919
bool HasPetFlag(UnitPetFlag flags) const
Definition Unit.h:993
bool IsHunterPet() const
Definition Unit.h:885
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:1384
float GetHealthPct() const
Definition Unit.h:921
bool IsCharmerOrSelfPlayer() const
Definition Unit.h:1294
float m_baseSpellCritChance
Definition Unit.h:1500
uint32 m_lastSanctuaryTime
Definition Unit.h:1569
void SetCreateStat(Stats stat, float val)
Definition Unit.h:1448
bool HasExtraUnitMovementFlag(uint32 f) const
Definition Unit.h:1684
void SetStat(Stats stat, int32 val)
Definition Unit.h:904
bool HasPvpFlag(UnitPVPStateFlags flags) const
Definition Unit.h:982
void KillSelf(bool durabilityLoss=true)
Definition Unit.h:1023
void SetChannelObjectGuid(ObjectGuid guid)
Definition Unit.h:1461
AuraList m_removedAuras
Definition Unit.h:1868
uint32 GetUnitMovementFlags() const
Definition Unit.h:1679
LiquidTypeEntry const * _lastLiquid
Definition Unit.h:1902
bool IsGuildMaster() const
Definition Unit.h:1106
virtual void SetTarget(ObjectGuid)=0
float GetRangedCritChanceReduction() const
Definition Unit.h:1054
Pet * ToPet()
Definition Unit.h:1788
bool CanHaveThreatList() const
====================== THREAT & COMBAT ====================
Definition Unit.h:1122
Movement::MoveSpline * movespline
Definition Unit.h:1804
void SetGender(Gender gender)
Definition Unit.h:899
std::unordered_map< ObjectGuid, uint32 > extraAttacksTargets
Definition Unit.h:1966
std::unordered_set< Unit * > m_ComboPointHolders
Definition Unit.h:1963
void AddComboPoints(int8 count)
Definition Unit.h:1700
void SetGameClientMovingMe(GameClient *gameClientMovingMe)
Definition Unit.h:1303
bool m_canModifyStats
Definition Unit.h:1881
void AddExtraUnitMovementFlag(uint32 f)
Definition Unit.h:1682
std::shared_ptr< UnitAI > i_AI
Definition Unit.h:1956
bool _isCombatDisallowed
Definition Unit.h:1980
void SetFullHealth()
Definition Unit.h:927
bool IsInnkeeper() const
Definition Unit.h:1109
void SetMinionGUID(ObjectGuid guid)
Definition Unit.h:1246
Diminishing m_Diminishing
Definition Unit.h:1944
bool IsTabardDesigner() const
Definition Unit.h:1112
void SetHoverHeight(float hoverHeight)
Definition Unit.h:1216
Unit * GetCharmedOrSelf() const
Definition Unit.h:1297
ThreatManager & GetThreatManager()
Definition Unit.h:1155
void ReplaceAllPvpFlags(UnitPVPStateFlags flags)
Definition Unit.h:985
void SetInCombatWith(Unit *enemy, bool addSecondUnitSuppressed=false)
Definition Unit.h:1146
void SetLastExtraAttackSpell(uint32 spellId)
Definition Unit.h:1043
virtual void SetCanDualWield(bool value)
Definition Unit.h:838
std::vector< std::pair< uint8, AuraApplication * > > AuraApplicationProcContainer
Definition Unit.h:792
uint8 GetClass() const
Definition Unit.h:895
void SetVisFlag(UnitVisFlags flags)
Definition Unit.h:1006
uint32 m_regenTimer
Definition Unit.h:1896
uint32 m_state
Definition Unit.h:1941
void SetCreateHealth(uint32 val)
Definition Unit.h:1449
std::list< Aura * > AuraList
Definition Unit.h:788
uint32 GetRaceMask() const
Definition Unit.h:894
uint32 GetClassMask() const
Definition Unit.h:897
virtual bool UpdateAllStats()=0
uint32 GetLastExtraAttackSpell() const
Definition Unit.h:1044
uint32 GetMountDisplayId() const
Definition Unit.h:1014
Vehicle * m_vehicle
Definition Unit.h:1898
Totem * ToTotem()
Definition Unit.h:1791
void SetRace(uint8 race)
Definition Unit.h:893
ThreatManager const & GetThreatManager() const
Definition Unit.h:1156
GameClient * _gameClientMovingMe
Definition Unit.h:1891
virtual SpellSchoolMask GetMeleeDamageSchoolMask(WeaponAttackType attackType=BASE_ATTACK, uint8 damageIndex=0) const =0
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:780
Emote GetEmoteState() const
Definition Unit.h:966
bool HealthAbovePctHealed(int32 pct, uint32 heal) const
Definition Unit.h:920
SpellHistory * _spellHistory
Definition Unit.h:1976
NPCFlags GetNpcFlags() const
Definition Unit.h:1095
bool IsMovedByClient() const
Definition Unit.h:1300
ObjectGuid GetCreatorGUID() const
Definition Unit.h:1243
ShapeshiftForm GetShapeshiftForm() const
Definition Unit.h:1490
void SetFaction(uint32 faction) override
Definition Unit.h:974
ObjectGuid GetOwnerGUID() const override
Definition Unit.h:1241
void RemoveExtraUnitMovementFlag(uint32 f)
Definition Unit.h:1683
virtual void UpdateAttackPowerAndDamage(bool ranged=false)=0
Spell * GetCurrentSpell(uint32 spellType) const
Definition Unit.h:1477
Unit * GetCharmer() const
Definition Unit.h:1253
UnitPetFlag GetPetFlags() const
Definition Unit.h:992
Trinity::unique_trackable_ptr< Vehicle > m_vehicleKit
Definition Unit.h:1899
UnitPVPStateFlags GetPvpFlags() const
Definition Unit.h:981
uint32 GetTransformSpell() const
Definition Unit.h:1588
bool IsArmorer() const
Definition Unit.h:1114
void SetAttackPowerModNeg(int32 attackPowerMod)
Definition Unit.h:1543
void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value, uint8 damageIndex=0)
Definition Unit.h:1552
uint32 _lastExtraAttackSpell
Definition Unit.h:1965
CharmInfo * m_charmInfo
Definition Unit.h:1889
bool IsPvP() const
Definition Unit.h:988
MotionMaster * i_motionMaster
Definition Unit.h:1893
virtual bool CanFly() const =0
void ReplaceAllUnitFlags(UnitFlags flags)
Definition Unit.h:956
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
AuraApplicationMap const & GetAppliedAuras() const
Definition Unit.h:1339
bool IsPet() const
Definition Unit.h:884
Powers GetPowerType() const
Definition Unit.h:931
bool HasUnitFlag(UnitFlags flags) const
Definition Unit.h:953
bool CanProc() const
Definition Unit.h:1726
bool IsFrozen() const
Definition Unit.h:1170
GameClient * GetGameClientMovingMe() const
Definition Unit.h:1302
bool _instantCast
Definition Unit.h:1971
ObjectGuid GetCharmedGUID() const
Definition Unit.h:1255
void SetCreatedBySpell(int32 spellId)
Definition Unit.h:964
bool CanDualWield() const
Definition Unit.h:837
bool CanInstantCast() const
Definition Unit.h:1801
void StartReactiveTimer(ReactiveType reactive)
Definition Unit.h:1719
void SetUnitMovementFlags(uint32 f)
Definition Unit.h:1680
uint32 GetMaxHealth() const
Definition Unit.h:914
bool IsTrainer() const
Definition Unit.h:1102
UnitAIStack i_AIs
Definition Unit.h:1955
virtual void AtDisengage()
Definition Unit.h:1917
virtual void UpdateResistances(uint32 school)=0
void SetChannelSpellId(uint32 channelSpellId)
Definition Unit.h:1459
virtual void SetImmuneToAll(bool apply)
Definition Unit.h:1136
uint32 GetSpellCritDamageReduction(uint32 damage) const
Definition Unit.h:1060
bool IsFullHealth() const
Definition Unit.h:916
float GetMeleeCritChanceReduction() const
Definition Unit.h:1053
void SetUnitFlag2(UnitFlags2 flags)
Definition Unit.h:960
bool HasUnitFlag2(UnitFlags2 flags) const
Definition Unit.h:959
bool HasInterruptFlag(uint32 flags) const
Definition Unit.h:1576
bool IsInSanctuary() const
Definition Unit.h:987
std::pair< AuraMap::const_iterator, AuraMap::const_iterator > AuraMapBounds
Definition Unit.h:777
uint32 GetRangedDamageReduction(uint32 damage) const
Definition Unit.h:1064
virtual bool IsLoading() const
Definition Unit.h:1785
uint8 GetComboPoints(ObjectGuid const &guid) const
Definition Unit.h:1696
void ReplaceAllPetFlags(UnitPetFlag flags)
Definition Unit.h:996
float GetNegStat(Stats stat) const
Definition Unit.h:1455
void SetPetNameTimestamp(uint32 timestamp)
Definition Unit.h:1291
std::stack< std::shared_ptr< UnitAI > > UnitAIStack
Definition Unit.h:1954
bool IsAlive() const
Definition Unit.h:1234
float m_modRangedHitChance
Definition Unit.h:1498
float GetCombatReach() const override
Definition Unit.h:839
void ReplaceAllVisFlags(UnitVisFlags flags)
Definition Unit.h:1008
DeathState m_deathState
Definition Unit.h:1852
std::deque< PlayerMovementPendingChange > m_pendingMovementChanges
Definition Unit.h:1986
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition Unit.h:1201
int32 GetMinPower(Powers) const
Definition Unit.h:935
uint32 m_unitTypeMask
Definition Unit.h:1901
void SetRangedAttackPowerModNeg(int32 attackPowerMod)
Definition Unit.h:1547
std::pair< AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator > AuraApplicationMapBounds
Definition Unit.h:781
void RemoveNpcFlag(NPCFlags flags)
Definition Unit.h:1098
uint32 m_removedAurasCount
Definition Unit.h:1870
uint32 GetRangedCritDamageReduction(uint32 damage) const
Definition Unit.h:1059
uint32 m_movementCounter
Definition Unit.h:1985
UnitFlags GetUnitFlags() const
Definition Unit.h:952
void SetPetFlag(UnitPetFlag flags)
Definition Unit.h:994
TempSummon * ToTempSummon()
Definition Unit.h:1794
bool IsGravityDisabled() const
Definition Unit.h:1218
bool IsQuestGiver() const
Definition Unit.h:1103
CharmInfo * GetCharmInfo()
Definition Unit.h:1287
bool HasStealthAura() const
Definition Unit.h:1165
void RemoveVisFlag(UnitVisFlags flags)
Definition Unit.h:1007
ControlList m_Controlled
Definition Unit.h:1276
bool IsInCombatWith(Unit const *who) const
Definition Unit.h:1145
ObjectGuid GetCharmerOrOwnerGUID() const override
Definition Unit.h:1260
Unit * m_comboTarget
Definition Unit.h:1961
AuraMap::iterator m_auraUpdateIterator
Definition Unit.h:1869
UnitAI * GetAI() const
Definition Unit.h:800
std::list< AuraApplication * > AuraApplicationList
Definition Unit.h:789
ObjectGuid _lastDamagedTargetGuid
Definition Unit.h:1967
std::map< uint8, AuraApplication * > VisibleAuraMap
Definition Unit.h:794
void SetNativeDisplayId(uint32 displayId)
Definition Unit.h:1586
void FollowerRemoved(AbstractFollower *f)
Definition Unit.h:1664
void SetRangedAttackPowerModPos(int32 attackPowerMod)
Definition Unit.h:1546
void FollowerAdded(AbstractFollower *f)
Definition Unit.h:1663
bool m_AutoRepeatFirstCast
Definition Unit.h:1845
AnimTier GetAnimTier() const
Definition Unit.h:1010
std::set< Unit * > ControlList
Definition Unit.h:773
TempSummon const * ToTempSummon() const
Definition Unit.h:1795
virtual bool HasSpell(uint32) const
Definition Unit.h:1161
virtual bool IsAffectedByDiminishingReturns() const
Definition Unit.h:821
std::pair< AuraStateAurasMap::const_iterator, AuraStateAurasMap::const_iterator > AuraStateAurasMapBounds
Definition Unit.h:785
void AddUnitState(uint32 f)
Definition Unit.h:875
std::multimap< AuraStateType, AuraApplication * > AuraStateAurasMap
Definition Unit.h:784
ObjectGuid GetLastDamagedTargetGuid() const
Definition Unit.h:1047
bool IsTaxi() const
Definition Unit.h:1105
void SetBoundingRadius(float boundingRadius)
Definition Unit.h:842
void SetCreateMana(uint32 val)
Definition Unit.h:1451
void RemoveComboPointHolder(Unit *unit)
Definition Unit.h:1705
bool IsCharmedOwnedByPlayerOrPlayer() const
Definition Unit.h:1261
Gender GetGender() const
Definition Unit.h:898
bool IsImmuneToNPC() const
Definition Unit.h:1140
virtual bool CanEnterWater() const =0
Pet const * ToPet() const
Definition Unit.h:1789
Unit * EnsureVictim() const
Definition Unit.h:861
uint32 getAttackTimer(WeaponAttackType type) const
Definition Unit.h:834
virtual void SetSheath(SheathState sheathed)
Definition Unit.h:970
bool IsDuringRemoveFromWorld() const
Definition Unit.h:1786
bool m_ControlledByPlayer
Definition Unit.h:1843
void AddInterruptMask(uint32 flags)
Definition Unit.h:1577
Unit * GetCharmerOrOwner() const
Definition Unit.h:1265
void SetLastManaUse(uint32 spellCastTime)
Definition Unit.h:1630
virtual Gender GetNativeGender() const
Definition Unit.h:900
AuraMap const & GetOwnedAuras() const
Definition Unit.h:1329
void SetInstantCast(bool set)
Definition Unit.h:1800
void SetRangedAttackPowerMultiplier(float attackPowerMult)
Definition Unit.h:1548
virtual void SetImmuneToNPC(bool apply)
Definition Unit.h:1142
void SetCombatReach(float combatReach)
Definition Unit.h:840
void SetEmoteState(Emote emote)
Definition Unit.h:967
uint32 CountPctFromCurHealth(int32 pct) const
Definition Unit.h:923
MotionMaster const * GetMotionMaster() const
Definition Unit.h:1668
int32 CountPctFromMaxPower(Powers power, int32 pct) const
Definition Unit.h:938
DynObjectList m_dynObj
Definition Unit.h:1857
bool IsImmuneToAll() const
Definition Unit.h:1134
PositionUpdateInfo _positionUpdateInfo
Definition Unit.h:1978
void SetPvpFlag(UnitPVPStateFlags flags)
Definition Unit.h:983
AuraApplicationList m_interruptableAuras
Definition Unit.h:1874
bool IsInFlight() const
Definition Unit.h:1119
void SetResistance(SpellSchools school, int32 val)
Definition Unit.h:910
Trinity::unique_weak_ptr< Vehicle > GetVehicleKitWeakPtr() const
Definition Unit.h:1736
uint32 GetDisplayId() const
Definition Unit.h:1582
int8 m_comboPoints
Definition Unit.h:1962
bool IsAIEnabled() const
Definition Unit.h:798
UnitAI * GetTopAI() const
Definition Unit.h:806
uint32 GetNativeDisplayId() const
Definition Unit.h:1584
virtual void UpdateArmor()=0
bool HealthBelowPct(int32 pct) const
Definition Unit.h:917
void AddUnitMovementFlag(uint32 f)
Definition Unit.h:1676
ThreatManager m_threatManager
Definition Unit.h:1950
uint32 _oldFactionId
faction before charm
Definition Unit.h:1973
bool IsHovering() const
Definition Unit.h:1220
SpellHistory const * GetSpellHistory() const
Definition Unit.h:1485
ObjectGuid GetMinionGUID() const
Definition Unit.h:1245
float GetHoverOffset() const
Definition Unit.h:1767
bool isPossessed() const
Definition Unit.h:1282
SharedVisionList const & GetSharedVisionList()
Definition Unit.h:1305
bool HasUnitMovementFlag(uint32 f) const
Definition Unit.h:1678
Unit * m_charmed
Definition Unit.h:1888
uint32 GetMaxPower(Powers power) const
Definition Unit.h:936
virtual void UpdateMaxPower(Powers power)=0
AttackerSet m_attackers
Definition Unit.h:1849
bool IsSummon() const
Definition Unit.h:882
uint32 GetHealth() const
Definition Unit.h:913
uint32 GetFaction() const override
Definition Unit.h:973
uint32 GetCreateHealth() const
Definition Unit.h:1450
AuraEffectList & GetAuraEffectsByType(AuraType type)
Definition Unit.h:1385
Unit * m_attacking
Definition Unit.h:1850
CombatManager const & GetCombatManager() const
Definition Unit.h:1131
AttackerSet const & getAttackers() const
Definition Unit.h:857
void RemoveUnitFlag2(UnitFlags2 flags)
Definition Unit.h:961
void RemovePvpFlag(UnitPVPStateFlags flags)
Definition Unit.h:984
std::multimap< uint32, Aura * > AuraMap
Definition Unit.h:776
virtual uint32 GetShieldBlockValue() const =0
void SetNpcFlag(NPCFlags flags)
Definition Unit.h:1097
bool isMoving() const
Definition Unit.h:1759
VisibleAuraMap const & GetVisibleAuras() const
Definition Unit.h:1571
Totem const * ToTotem() const
Definition Unit.h:1792
void RemovePetFlag(UnitPetFlag flags)
Definition Unit.h:995
void setAttackTimer(WeaponAttackType type, uint32 time)
Definition Unit.h:832
virtual bool UpdateStats(Stats stat)=0
bool HasNpcFlag(NPCFlags flags) const
Definition Unit.h:1096
bool IsBanker() const
Definition Unit.h:1108
virtual void AtEnterCombat()
Definition Unit.h:1913
std::array< DiminishingReturn, DIMINISHING_MAX > Diminishing
Definition Unit.h:790
uint32 GetArmor() const
Definition Unit.h:905
float m_modMeleeHitChance
Definition Unit.h:1497
virtual bool CheckAttackFitToAuraRequirement(WeaponAttackType, AuraEffect const *) const
Definition Unit.h:1518
ObjectGuid GetCritterGUID() const
Definition Unit.h:1249
uint8 GetLevelForTarget(WorldObject const *) const override
Definition Unit.h:890
void SetFullPower(Powers power)
Definition Unit.h:941
bool IsFFAPvP() const
Definition Unit.h:989
AuraList const & GetSingleCastAuras() const
Definition Unit.h:1387
bool IsRooted() const
Definition Unit.h:1168
uint32 m_transformSpell
Definition Unit.h:1862
bool CanModifyStats() const
Definition Unit.h:1531
bool IsMounted() const
Definition Unit.h:1013
void SetAttackPower(int32 attackPower)
Definition Unit.h:1541
float GetSpeedRate(UnitMoveType mtype) const
Definition Unit.h:1654
std::set< Unit * > AttackerSet
Definition Unit.h:772
virtual float GetFollowAngle() const
Definition Unit.h:1782
bool IsGuardian() const
Definition Unit.h:883
Unit * GetVictim() const
Definition Unit.h:859
std::vector< Unit * > UnitVector
Definition Unit.h:774
bool IsMovedByServer() const
Definition Unit.h:1301
uint32 GetExtraUnitMovementFlags() const
Definition Unit.h:1685
uint32 GetMeleeCritDamageReduction(uint32 damage) const
Definition Unit.h:1058
Unit * GetComboTarget() const
Definition Unit.h:1697
float GetCreateStat(Stats stat) const
Definition Unit.h:1456
DeathState getDeathState() const
Definition Unit.h:1238
ObjectGuid GetChannelObjectGuid() const
Definition Unit.h:1460
void SetArmor(int32 val)
Definition Unit.h:906
bool m_aiLocked
Definition Unit.h:1957
bool IsEngagedBy(Unit const *who) const
Definition Unit.h:1127
bool IsCritter() const
Definition Unit.h:1117
bool IsGossip() const
Definition Unit.h:1104
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
uint32 GetSpellDamageReduction(uint32 damage) const
Definition Unit.h:1065
std::unordered_set< AbstractFollower * > m_followingMe
Definition Unit.h:1959
GameObjectList m_gameObj
Definition Unit.h:1860
AuraMap m_ownedAuras
Definition Unit.h:1866
float GetPowerPct(Powers power) const
Definition Unit.h:937
void SetCanModifyStats(bool modifyStats)
Definition Unit.h:1532
std::pair< AuraMap::iterator, AuraMap::iterator > AuraMapBoundsNonConst
Definition Unit.h:778
void RemoveUnitMovementFlag(uint32 f)
Definition Unit.h:1677
AuraApplicationMap m_appliedAuras
Definition Unit.h:1867
void SetVehicle(Vehicle *vehicle)
Definition Unit.h:1738
void SetClass(uint8 classId)
Definition Unit.h:896
virtual float GetNativeObjectScale() const
Definition Unit.h:1580
bool HasInvisibilityAura() const
Definition Unit.h:1166
Player * GetCharmerOrSelfPlayer() const
Definition Unit.h:1296
virtual void UpdateMaxHealth()=0
uint32 HasUnitTypeMask(uint32 mask) const
Definition Unit.h:880
uint8 GetComboPoints(Unit const *who=nullptr) const
--------—Combo point system----------------—
Definition Unit.h:1695
void ClearInCombat()
Definition Unit.h:1147
uint32 CountPctFromMaxHealth(int32 pct) const
Definition Unit.h:922
bool isDying() const
Definition Unit.h:1235
float GetStat(Stats stat) const
Definition Unit.h:903
virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage, uint8 damageIndex) const =0
SpellHistory * GetSpellHistory()
Definition Unit.h:1484
void ReplaceAllUnitFlags2(UnitFlags2 flags)
Definition Unit.h:962
bool IsControlledByPlayer() const
Definition Unit.h:1258
Unit * m_charmer
Definition Unit.h:1887
bool m_canDualWield
Definition Unit.h:848
ObjectGuid GetCharmerGUID() const
Definition Unit.h:1252
bool IsCombatDisallowed() const
Definition Unit.h:1826
SheathState GetSheath() const
Definition Unit.h:969
UnitStandStateType GetStandState() const
Definition Unit.h:1001
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
void SetPetGUID(ObjectGuid guid)
Definition Unit.h:1248
virtual bool HasSpellFocus(Spell const *=nullptr) const
Definition Unit.h:1481
bool HasSharedVision() const
Definition Unit.h:1308
void SetCreatorGUID(ObjectGuid creator)
Definition Unit.h:1244
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true)
Definition Unit.cpp:10930
ObjectGuid LastCharmerGUID
Definition Unit.h:1732
uint32 GetPower(Powers power) const
Definition Unit.h:934
uint32 m_interruptMask
Definition Unit.h:1876
CombatManager & GetCombatManager()
Definition Unit.h:1130
uint32 GetMeleeDamageReduction(uint32 damage) const
Definition Unit.h:1063
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:954
void SetExtraUnitMovementFlags(uint32 f)
Definition Unit.h:1686
bool IsVendor() const
Definition Unit.h:1101
bool IsFlying() const
Definition Unit.h:1762
void SetCritterGUID(ObjectGuid guid)
Definition Unit.h:1250
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1338
std::list< AuraEffect * > AuraEffectList
Definition Unit.h:787
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition Unit.h:835
int32 m_procDeep
Definition Unit.h:1854
void SetAttackTime(WeaponAttackType att, uint32 val)
Definition Unit.h:946
void SetPetNumberForClient(uint32 petNumber)
Definition Unit.h:1290
bool IsSpiritHealer() const
Definition Unit.h:1110
VisibleAuraMap m_visibleAuras
Definition Unit.h:1883
uint32 GetCreateMana() const
Definition Unit.h:1452
bool IsAuctioner() const
Definition Unit.h:1113
bool IsTotem() const
Definition Unit.h:886
CombatManager m_combatManager
Definition Unit.h:1948
void SetRangedAttackPower(int32 attackPower)
Definition Unit.h:1545
virtual void SetNativeGender(Gender gender)
Definition Unit.h:901
AuraStateAurasMap m_auraStateAuras
Definition Unit.h:1875
int32 GetResistance(SpellSchools school) const
Definition Unit.h:908
AuraList & GetSingleCastAuras()
Definition Unit.h:1386
uint32 GetMovementCounterAndInc()
Definition Unit.h:1772
void AddUnitTypeMask(uint32 mask)
Definition Unit.h:881
void SetModCastingSpeed(float castingSpeed)
Definition Unit.h:950
Vehicle * GetVehicleKit() const
Definition Unit.h:1735
virtual void SetImmuneToPC(bool apply)
Definition Unit.h:1139
float m_modSpellHitChance
Definition Unit.h:1499
bool IsCharming() const
Definition Unit.h:1281
std::list< DynamicObject * > DynObjectList
Definition Unit.h:1856
virtual bool IsEngaged() const
Definition Unit.h:1126
bool IsFeared() const
Definition Unit.h:1167
void ReplaceAllNpcFlags(NPCFlags flags)
Definition Unit.h:1099
void SetAttackPowerMultiplier(float attackPowerMult)
Definition Unit.h:1544
AuraMap & GetOwnedAuras()
Definition Unit.h:1328
bool IsSpiritService() const
Definition Unit.h:1116
void SetTransformSpell(uint32 spellid)
Definition Unit.h:1587
bool IsImmuneToPC() const
Definition Unit.h:1137
bool m_cleanupDone
Definition Unit.h:1969
SharedVisionList m_sharedVision
Definition Unit.h:1890
ObjectGuid GetTarget() const
Definition Unit.h:1797
bool _isWalkingBeforeCharm
Are we walking before we were charmed?
Definition Unit.h:1974
void SetAttackPowerModPos(int32 attackPowerMod)
Definition Unit.h:1542
uint8 GetLevel() const
Definition Unit.h:889
void SetMountDisplayId(uint32 mountDisplayId)
Definition Unit.h:1015
uint8 GetRace() const
Definition Unit.h:892
bool IsInCombat() const
Definition Unit.h:1144
bool IsWalking() const
Definition Unit.h:1219
UnitFlags2 GetUnitFlags2() const
Definition Unit.h:958
void SetIsCombatDisallowed(bool apply)
Definition Unit.h:1828
bool IsThreatenedBy(Unit const *who) const
Definition Unit.h:1151
bool isTurning() const
Definition Unit.h:1760
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:955
uint32 GetDynamicFlags() const override
Definition Unit.h:818
bool HasPendingMovementChange() const
Definition Unit.h:1776
bool IsSpiritGuide() const
Definition Unit.h:1111
ObjectGuid GetPetGUID() const
Definition Unit.h:1247
bool isDead() const
Definition Unit.h:1236
uint32 m_lastManaUse
Definition Unit.h:1942
uint32 GetMaxSkillValueForLevel(Unit const *target=nullptr) const
Definition Unit.h:1019
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1476
Player session in the World.
Definition Util.h:412
WeaponAttackType AttackType
Definition Unit.h:556
uint32 DamageSchoolMask
Definition Unit.h:545
uint32 ProcVictim
Definition Unit.h:558
struct CalcDamageInfo::@227 Damages[2]
Unit * Target
Definition Unit.h:541
uint32 TargetState
Definition Unit.h:553
uint32 ProcAttacker
Definition Unit.h:557
MeleeHitOutcome HitOutCome
Definition Unit.h:560
Unit * Attacker
Definition Unit.h:540
uint32 Damage
Definition Unit.h:546
uint32 Blocked
Definition Unit.h:551
uint32 Resist
Definition Unit.h:548
uint32 CleanDamage
Definition Unit.h:559
uint32 HitInfo
Definition Unit.h:552
uint32 Absorb
Definition Unit.h:547
float _stayY
Definition Unit.h:736
uint32 GetPetNumber() const
Definition Unit.h:678
void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type)
Definition Unit.h:696
bool _isAtStay
Definition Unit.h:732
float _stayX
Definition Unit.h:735
CharmSpellInfo * GetCharmSpell(uint8 index)
Definition Unit.h:704
float _stayZ
Definition Unit.h:737
bool _isCommandFollow
Definition Unit.h:731
CommandStates GetCommandState() const
Definition Unit.h:682
CommandStates _CommandState
Definition Unit.h:724
UnitActionBarEntry const * GetActionBarEntry(uint8 index) const
Definition Unit.h:700
bool _isFollowing
Definition Unit.h:733
bool HasCommandState(CommandStates state) const
Definition Unit.h:683
bool _isCommandAttack
Definition Unit.h:730
ReactStates _oldReactState
Definition Unit.h:728
void SetCommandState(CommandStates st)
Definition Unit.h:681
bool _isReturning
Definition Unit.h:734
Unit * _unit
Definition Unit.h:721
uint32 _petnumber
Definition Unit.h:725
MeleeHitOutcome hitOutCome
Definition Unit.h:423
uint32 mitigated_damage
Definition Unit.h:420
uint32 absorbed_damage
Definition Unit.h:419
CleanDamage(uint32 mitigated, uint32 absorbed, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome)
Definition Unit.h:416
WeaponAttackType attackType
Definition Unit.h:422
uint32 hitCount
Definition Unit.h:389
uint32 hitTime
Definition Unit.h:388
uint16 stack
Definition Unit.h:387
void Clear()
Definition Unit.h:380
MovementChangeType movementChangeType
Definition Unit.h:306
struct PlayerMovementPendingChange::KnockbackInfo knockbackInfo
uint32 overkill
Definition Unit.h:575
Unit * attacker
Definition Unit.h:572
uint32 schoolMask
Definition Unit.h:576
SpellNonMeleeDamage(Unit *_attacker, Unit *_target, uint32 _SpellID, uint32 _schoolMask)
Definition Unit.h:566
uint32 cleanDamage
Definition Unit.h:584
SpellPeriodicAuraLogInfo(AuraEffect const *_auraEff, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical)
Definition Unit.h:590
AuraEffect const * auraEff
Definition Unit.h:593
ActiveStates GetType() const
Definition Unit.h:626
void SetActionAndType(uint32 action, ActiveStates type)
Definition Unit.h:634
bool IsActionBarForSpell() const
Definition Unit.h:628
void SetType(ActiveStates type)
Definition Unit.h:639
void SetAction(uint32 action)
Definition Unit.h:644
uint32 packedData
Definition Unit.h:623
uint32 GetAction() const
Definition Unit.h:627