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