OregonCore  revision fb2a440-git
Your Favourite TBC server
Unit Class Referenceabstract

#include <Unit.h>

+ Inheritance diagram for Unit:

Public Types

typedef std::set< Unit * > AttackerSet
 
typedef std::set< Unit * > ControlList
 
typedef std::pair< uint32, uint8spellEffectPair
 
typedef std::multimap< spellEffectPair, Aura * > AuraMap
 
typedef std::list< Aura * > AuraList
 
typedef std::list< DiminishingReturnDiminishing
 
typedef std::set< AuraTypeAuraTypeSet
 
typedef std::set< uint32ComboPointHolderSet
 
typedef std::set< PetAura const * > PetAuraSet
 

Public Member Functions

 ~Unit () override
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void CleanupsBeforeDelete () override
 
DiminishingLevels GetDiminishing (DiminishingGroup group)
 
void IncrDiminishing (DiminishingGroup group)
 
void ApplyDiminishingToDuration (DiminishingGroup group, int32 &duration, Unit *caster, DiminishingLevels Level)
 
void ApplyDiminishingAura (DiminishingGroup group, bool apply)
 
void ClearDiminishings ()
 
uint32 GetSpellRadiusForTarget (Unit *target, const SpellRadiusEntry *radiusEntry)
 
void Update (uint32 time) override
 
void setAttackTimer (WeaponAttackType type, uint32 time)
 
void resetAttackTimer (WeaponAttackType type=BASE_ATTACK)
 
uint32 getAttackTimer (WeaponAttackType type) const
 
bool isAttackReady (WeaponAttackType type=BASE_ATTACK) const
 
bool haveOffhandWeapon () const
 
bool UpdateMeleeAttackingState ()
 
bool CanUseEquippedWeapon (WeaponAttackType attackType) const
 
bool CanDualWield () const
 
virtual void SetCanDualWield (bool value)
 
float GetCombatReach () const
 
float GetMeleeReach () const
 
bool IsWithinCombatRange (const Unit *obj, float dist2compare) const
 
bool IsWithinMeleeRange (Unit *obj, float dist=MELEE_RANGE) const
 
void GetRandomContactPoint (const Unit *target, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const
 
void _addAttacker (Unit *pAttacker)
 
void _removeAttacker (Unit *pAttacker)
 
UnitgetAttackerForHelper () const
 
bool Attack (Unit *victim, bool meleeAttack)
 
void CastStop (uint32 except_spellid=0)
 
bool AttackStop ()
 
void RemoveAllAttackers ()
 
AttackerSet const & getAttackers () const
 
bool isAttackingPlayer () const
 
UnitGetVictim () const
 
void CombatStop (bool cast=false)
 
void CombatStopWithPets (bool cast=false)
 
UnitSelectNearbyTarget (Unit *exclude=NULL, float dist=NOMINAL_MELEE_RANGE) const
 
PlayerSelectNearestPlayer (float distance=0) const
 
void SendMeleeAttackStop (Unit *victim=NULL)
 
void SendMeleeAttackStart (Unit *victim)
 
void SetCritterGUID (uint64 guid)
 
uint64 GetCritterGUID () const
 
void AddUnitState (uint32 f)
 
bool HasUnitState (const uint32 f) const
 
void ClearUnitState (uint32 f)
 
bool CanFreeMove () const
 
uint32 HasUnitTypeMask (uint32 mask) const
 
void AddUnitTypeMask (uint32 mask)
 
bool IsSummon () const
 
bool IsGuardian () const
 
bool IsPet () const
 
bool IsHunterPet () const
 
bool IsTotem () const
 
bool IsDuringRemoveFromWorld () const
 
PetToPet ()
 
Pet const * ToPet () const
 
uint8 getLevel () const
 
uint8 getLevelForTarget (WorldObject const *) const override
 
void SetLevel (uint32 lvl)
 
uint8 getRace () const
 
uint32 getRaceMask () const
 
uint8 getClass () const
 
uint32 getClassMask () const
 
uint8 getGender () const
 
float GetStat (Stats stat) const
 
void SetStat (Stats stat, int32 val)
 
uint32 GetArmor () const
 
void SetArmor (int32 val)
 
uint32 GetResistance (SpellSchools school) const
 
void SetResistance (SpellSchools school, int32 val)
 
uint32 GetHealth () const
 
uint32 GetMaxHealth () const
 
bool ShouldRevealHealthTo (Player *player) const
 
void SendHealthUpdateDueToCharm (Player *charmer)
 
bool IsFullHealth () const
 
bool HealthBelowPct (int32 pct) const
 
bool HealthBelowPctDamaged (int32 pct, uint32 damage) const
 
bool HealthAbovePct (int32 pct) const
 
bool HealthAbovePctHealed (int32 pct, uint32 heal) const
 
float GetHealthPct () const
 
uint32 CountPctFromMaxHealth (int32 pct) const
 
uint32 CountPctFromCurHealth (int32 pct) const
 
void SetHealth (uint32 val)
 
void SetMaxHealth (uint32 val)
 
void SetFullHealth ()
 
int32 ModifyHealth (int32 val)
 
Powers getPowerType () const
 
void setPowerType (Powers power)
 
uint32 GetPower (Powers power) const
 
uint32 GetMaxPower (Powers power) const
 
void SetPower (Powers power, uint32 val)
 
void SetMaxPower (Powers power, uint32 val)
 
int32 ModifyPower (Powers power, int32 val)
 
void ApplyPowerMod (Powers power, uint32 val, bool apply)
 
void ApplyMaxPowerMod (Powers power, uint32 val, bool apply)
 
uint32 GetAttackTime (WeaponAttackType att) const
 
void SetAttackTime (WeaponAttackType att, uint32 val)
 
void ApplyAttackTimePercentMod (WeaponAttackType att, float val, bool apply)
 
void ApplyCastTimePercentMod (float val, bool apply)
 
SheathState GetSheath () const
 
virtual void SetSheath (SheathState sheathed)
 
uint32 GetFaction () const
 
void SetFaction (uint32 faction)
 
FactionTemplateEntry const * GetFactionTemplateEntry () const
 
ReputationRank GetReactionTo (Unit const *target) const
 
bool IsHostileTo (Unit const *unit) const
 
bool IsHostileToPlayers () const
 
bool IsFriendlyTo (Unit const *unit) const
 
bool IsNeutralToAll () const
 
bool IsInPartyWith (Unit const *unit) const
 
bool IsInRaidWith (Unit const *unit) const
 
void GetPartyMember (std::list< Unit * > &units, float dist)
 
void GetRaidMember (std::list< Unit * > &units, float dist)
 
bool IsContestedGuard () const
 
bool IsInSanctuary () const
 
bool IsPvP () const
 
void SetPvP (bool state)
 
uint32 GetCreatureType () const
 
uint32 GetCreatureTypeMask () const
 
uint8 GetStandState () const
 
bool IsSitState () const
 
bool IsStandState () const
 
void SetStandState (uint8 state)
 
void SetStandFlags (uint8 flags)
 
void RemoveStandFlags (uint8 flags)
 
bool IsMounted () const
 
uint32 GetMountID () const
 
void Mount (uint32 mount, uint32 spellId=0)
 
void Dismount ()
 
bool HasShapeshiftChangingModel () const
 
uint32 GetMaxSkillValueForLevel (Unit const *target=nullptr) const
 
void RemoveSpellbyDamageTaken (uint32 damage, uint32 spell)
 
uint32 DealDamage (Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *spellProto=NULL, bool durabilityLoss=true)
 
void Kill (Unit *victim, bool durabilityLoss=true)
 
void ProcDamageAndSpell (Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellEntry const *procSpell=NULL, bool canTrigger=true)
 
void ProcDamageAndSpellFor (bool isVictim, Unit *pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const *procSpell, uint32 damage)
 
void HandleEmoteCommand (uint32 anim_id)
 
void AttackerStateUpdate (Unit *victim, WeaponAttackType attType=BASE_ATTACK, bool extra=false)
 
float MeleeMissChanceCalc (const Unit *victim, WeaponAttackType attType) const
 
void CalculateMeleeDamage (Unit *victim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK)
 
void DealMeleeDamage (CalcDamageInfo *damageInfo, bool durabilityLoss)
 
void CalculateSpellDamageTaken (SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType=BASE_ATTACK, bool crit=false)
 
void DealSpellDamage (SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
 
float MeleeSpellMissChance (const Unit *victim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const
 
SpellMissInfo MeleeSpellHitResult (Unit *victim, SpellEntry const *spell, bool cMiss=true)
 
SpellMissInfo MagicSpellHitResult (Unit *victim, SpellEntry const *spell)
 
SpellMissInfo SpellHitResult (Unit *victim, SpellEntry const *spell, bool canReflect=false, bool canMiss=true)
 
float GetUnitDodgeChance () const
 
float GetUnitParryChance () const
 
float GetUnitBlockChance () const
 
float GetUnitCriticalChance (WeaponAttackType attackType, const Unit *victim) const
 
int32 GetMechanicResistChance (const SpellEntry *spell)
 
bool CanUseAttackType (uint8 attacktype) const
 
virtual uint32 GetShieldBlockValue () const =0
 
uint32 GetUnitMeleeSkill (Unit const *target=NULL) const
 
uint32 GetDefenseSkillValue (Unit const *target=NULL) const
 
uint32 GetWeaponSkillValue (WeaponAttackType attType, Unit const *target=NULL) const
 
float GetWeaponProcChance () const
 
float GetPPMProcChance (uint32 WeaponSpeed, float PPM) const
 
MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *victim, WeaponAttackType attType) const
 
MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *victim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance, bool SpellCasted) const
 
bool IsVendor () const
 
bool IsTrainer () const
 
bool IsQuestGiver () const
 
bool IsGossip () const
 
bool IsTaxi () const
 
bool IsGuildMaster () const
 
bool IsBattleMaster () const
 
bool IsBanker () const
 
bool IsInnkeeper () const
 
bool IsSpiritHealer () const
 
bool IsSpiritGuide () const
 
bool IsTabardDesigner () const
 
bool IsAuctioner () const
 
bool IsArmorer () const
 
bool isServiceProvider () const
 
bool IsSpiritService () const
 
bool IsCritter () const
 
bool IsPlayer () const
 
bool IsInFlight () const
 
bool IsInitiatingCombat () const
 
bool IsInCombat () const
 
bool IsPetInCombat () const
 
bool IsInCombatWith (Unit const *who) const
 
void CombatStart (Unit *target, bool initialAggro=true)
 
void SetInCombatState (bool PvP, Unit *enemy=NULL)
 
void SetInitiatingCombat (bool flag)
 
void SetInCombatWith (Unit *enemy)
 
void ClearInCombat ()
 
void ClearInPetCombat ()
 
uint32 IsInPvPCombat () const
 
uint32 GetAuraCount (uint32 spellId) const
 
bool HasAuraType (AuraType auraType) const
 
bool HasAuraTypeWithCaster (AuraType auratype, uint64 caster) const
 
bool HasAuraTypeWithMiscvalue (AuraType auratype, int32 miscvalue) const
 
bool HasAuraTypeWithFamilyFlags (AuraType auraType, uint32 familyName, uint64 familyFlags) const
 
bool HasNegativeAuraWithInterruptFlag (uint32 flag)
 
bool HasAura (uint32 spellId, uint8 effIndex=0) const
 
bool HasHigherRankOfAura (uint32 spellid, uint8 effIndex) const
 
virtual bool HasSpell (uint32) const
 
bool HasStealthAura () const
 
bool HasInvisibilityAura () const
 
bool IsFeared () const
 
bool IsInRoots () const
 
bool IsPolymorphed () const
 
bool isFrozen () const
 
bool isTargetableForAttack (bool checkFakeDeath=true) const
 
bool IsValidAttackTarget (Unit const *target) const
 
bool _IsValidAttackTarget (Unit const *target, SpellEntry const *bySpell, WorldObject const *obj=NULL) const
 
bool isAttackableByAOE (float x=0, float y=0, float z=0, bool LosCheck=false) const
 
bool IsValidAssistTarget (Unit const *target) const
 
bool _IsValidAssistTarget (Unit const *target, SpellEntry const *bySpell) const
 
virtual bool IsInWater () const
 
virtual bool IsUnderWater () const
 
bool isInAccessiblePlaceFor (Creature const *c) const
 
virtual uint32 GetHighestLearnedRankOf (uint32 spellid) const
 
void SendHealSpellLog (Unit *victim, uint32 SpellID, uint32 Damage, bool critical=false)
 
void SendEnergizeSpellLog (Unit *victim, uint32 SpellID, uint32 Damage, Powers powertype)
 
void EnergizeBySpell (Unit *victim, uint32 SpellID, uint32 Damage, Powers powertype)
 
uint32 SpellNonMeleeDamageLog (Unit *victim, uint32 spellID, uint32 damage, bool isTriggeredSpell=false, bool useSpellDamage=true)
 
void CastSpell (Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
 
void CastSpell (Unit *Victim, SpellEntry const *spellInfo, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
 
void CastCustomSpell (Unit *Victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
 
void CastCustomSpell (uint32 spellId, SpellValueMod mod, uint32 value, Unit *Victim=NULL, bool triggered=true, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
 
void CastCustomSpell (uint32 spellId, CustomSpellValues const &value, Unit *Victim=NULL, bool triggered=true, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
 
void CastSpell (float x, float y, float z, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
 
void CastSpell (GameObject *go, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
 
void AddAura (uint32 spellId, Unit *target)
 
void DeMorph ()
 
void SendAttackStateUpdate (CalcDamageInfo *damageInfo)
 
void SendAttackStateUpdate (uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount)
 
void SendSpellNonMeleeDamageLog (SpellNonMeleeDamage *log)
 
void SendSpellNonMeleeDamageLog (Unit *target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit=false)
 
void SendSpellMiss (Unit *target, uint32 spellID, SpellMissInfo missInfo)
 
void SendSpellDamageImmune (Unit *target, uint32 spellId)
 
virtual bool SetPosition (float x, float y, float z, float orientation, bool teleport=false)
 
bool SetPosition (const Position &pos, bool teleport=false)
 
void NearTeleportTo (float x, float y, float z, float orientation, bool casting=false)
 
void SendTeleportPacket (Position &pos)
 
void SendMovementFlagUpdate (bool self=false)
 
void BuildHeartBeatMsg (WorldPacket *data) const
 
void BuildMovementPacket (ByteBuffer *data) const
 
bool isMoving () const
 
bool IsAlive () const
 
bool isDying () const
 
bool isDead () const
 
DeathState getDeathState () const
 
virtual void setDeathState (DeathState s)
 
uint64 GetOwnerGUID () const
 
uint64 GetCreatorGUID () const
 
void SetCreatorGUID (uint64 creator)
 
uint64 GetMinionGUID () const
 
void SetMinionGUID (uint64 guid)
 
uint64 GetCharmerGUID () const
 
void SetCharmerGUID (uint64 owner)
 
uint64 GetCharmGUID () const
 
void SetPetGUID (uint64 guid)
 
uint64 GetPetGUID () const
 
bool IsControlledByPlayer () const
 
uint64 GetCharmerOrOwnerGUID () const
 
uint64 GetCharmerOrOwnerOrOwnGUID () const
 
bool IsCharmedOwnedByPlayerOrPlayer () const
 
PlayerGetAffectingPlayer () const
 
PlayerGetSpellModOwner () const
 
UnitGetOwner () const
 
GuardianGetGuardianPet () const
 
MinionGetFirstMinion () const
 
UnitGetCharmer () const
 
UnitGetCharm () const
 
UnitGetCharmerOrOwner () const
 
UnitGetCharmerOrOwnerOrSelf () const
 
PlayerGetCharmerOrOwnerPlayerOrPlayerItself () const
 
void SetMinion (Minion *minion, bool apply)
 
void RemoveAllMinionsByEntry (uint32 entry)
 
void SetCharm (Unit *target, bool apply)
 
void SetCharmedBy (Unit *charmer, CharmType type)
 
void RemoveCharmedBy (Unit *charmer)
 
void RestoreFaction ()
 
UnitGetFirstControlled () const
 
void RemoveAllControlled ()
 
bool isCharmed () const
 
bool isPossessed () const
 
bool isPossessedByPlayer () const
 
bool isPossessing () const
 
bool isPossessing (Unit *u) const
 
CharmInfoGetCharmInfo ()
 
CharmInfoInitCharmInfo ()
 
void DeleteCharmInfo ()
 
void UpdateCharmAI ()
 
SharedVisionList const & GetSharedVisionList ()
 
void AddPlayerToVision (Player *plr)
 
void RemovePlayerFromVision (Player *plr)
 
bool HasSharedVision () const
 
void RemoveBindSightAuras ()
 
void RemoveCharmAuras ()
 
PetCreateTamedPetFrom (Creature *creatureTarget, uint32 spell_id=0)
 
bool AddAura (Aura *aur)
 
void RemoveAura (AuraMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAura (uint32 spellId, uint32 effindex, Aura *except=NULL)
 
void RemoveSingleAuraFromStackByDispel (uint32 spellId)
 
void RemoveSingleAuraFromStack (uint32 spellId, uint32 effindex)
 
void RemoveAurasDueToSpell (uint32 spellId, Aura *except=NULL)
 
void RemoveAurasDueToItemSpell (Item *castItem, uint32 spellId)
 
void RemoveAurasByCasterSpell (uint32 spellId, uint64 casterGUID)
 
void SetAurasDurationByCasterSpell (uint32 spellId, uint64 casterGUID, int32 duration)
 
AuraGetAuraByCasterSpell (uint32 spellId, uint64 casterGUID)
 
void RemoveAurasDueToSpellByDispel (uint32 spellId, uint64 casterGUID, Unit *dispeler)
 
void RemoveAurasDueToSpellBySteal (uint32 spellId, uint64 casterGUID, Unit *stealer)
 
void RemoveAurasByType (AuraType auraType, uint64 casterGUID=0, Aura *except=NULL, bool negative=true, bool positive=true)
 
void RemoveAurasDueToSpellByCancel (uint32 spellId)
 
void RemoveAurasAtChanneledTarget (SpellEntry const *spellInfo, Unit *caster)
 
void RemoveNotOwnSingleTargetAuras ()
 
void RemoveSpellsCausingAura (AuraType auraType)
 
void RemoveAuraTypeByCaster (AuraType auraType, uint64 casterGUID)
 
void RemoveRankAurasDueToSpell (uint32 spellId)
 
bool RemoveNoStackAurasDueToAura (Aura *Aur)
 
void RemoveAurasWithInterruptFlags (uint32 flags, uint32 except=0)
 
void RemoveAurasWithAttribute (uint32 flags)
 
void RemoveAurasWithDispelType (DispelType type)
 
void RemoveMovementImpairingAuras ()
 
void RemoveAllAuras ()
 
void RemoveArenaAuras ()
 
void RemoveAllAurasOnDeath ()
 
void DelayAura (uint32 spellId, uint32 effindex, int32 delaytime)
 
float GetResistanceBuffMods (SpellSchools school, bool positive) const
 
void SetResistanceBuffMods (SpellSchools school, bool positive, float val)
 
void ApplyResistanceBuffModsMod (SpellSchools school, bool positive, float val, bool apply)
 
void ApplyResistanceBuffModsPercentMod (SpellSchools school, bool positive, float val, bool apply)
 
void InitStatBuffMods ()
 
void ApplyStatBuffMod (Stats stat, float val, bool apply)
 
void ApplyStatPercentBuffMod (Stats stat, float val, bool apply)
 
void SetCreateStat (Stats stat, float val)
 
void SetCreateHealth (uint32 val)
 
uint32 GetCreateHealth () const
 
void SetCreateMana (uint32 val)
 
uint32 GetCreateMana () const
 
uint32 GetCreatePowers (Powers power) const
 
float GetPosStat (Stats stat) const
 
float GetNegStat (Stats stat) const
 
float GetCreateStat (Stats stat) const
 
void SetCurrentCastedSpell (Spell *pSpell)
 
virtual void ProhibitSpellSchool (SpellSchoolMask, uint32)
 
void InterruptSpell (CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
 
void FinishSpell (CurrentSpellTypes spellType, bool ok=true)
 
bool IsNonMeleeSpellCast (bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false) const
 
void InterruptNonMeleeSpells (bool withDelayed, uint32 spellid=0, bool withInstant=true)
 
uint64 GetTarget () const
 
void SetTarget (uint64 guid=0)
 
SpellGetCurrentSpell (CurrentSpellTypes spellType) const
 
SpellGetCurrentSpell (uint32 spellType) const
 
SpellFindCurrentSpellBySpellId (uint32 spell_id) const
 
int32 GetCurrentSpellCastTime (uint32 spell_id) const
 
bool CanMoveDuringChannel () const
 
bool IsInFeralForm () const
 
bool IsInTravelForm () const
 
bool IsInFlightForm () const
 
bool HandleStatModifier (UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply)
 
void SetModifierValue (UnitMods unitMod, UnitModifierType modifierType, float value)
 
float GetModifierValue (UnitMods unitMod, UnitModifierType modifierType) const
 
float GetTotalStatValue (Stats stat) const
 
float GetTotalAuraModValue (UnitMods unitMod) const
 
SpellSchools GetSpellSchoolByAuraGroup (UnitMods unitMod) const
 
Stats GetStatByAuraGroup (UnitMods unitMod) const
 
Powers GetPowerTypeByAuraGroup (UnitMods unitMod) const
 
bool CanModifyStats () const
 
void SetCanModifyStats (bool modifyStats)
 
virtual bool UpdateStats (Stats stat)=0
 
virtual bool UpdateAllStats ()=0
 
virtual void UpdateResistances (uint32 school)=0
 
virtual void UpdateAllResistances ()
 
virtual void UpdateArmor ()=0
 
virtual void UpdateMaxHealth ()=0
 
virtual void UpdateMaxPower (Powers power)=0
 
virtual void UpdateAttackPowerAndDamage (bool ranged=false)=0
 
virtual void UpdateDamagePhysical (WeaponAttackType attType)
 
float GetTotalAttackPowerValue (WeaponAttackType attType) const
 
float GetWeaponDamageRange (WeaponAttackType attType, WeaponDamageRange type) const
 
void SetBaseWeaponDamage (WeaponAttackType attType, WeaponDamageRange damageRange, float value)
 
virtual void CalculateMinMaxDamage (WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage)=0
 
uint32 CalculateDamage (WeaponAttackType attType, bool normalized, bool addTotalPct)
 
float GetAPMultiplier (WeaponAttackType attType, bool normalized)
 
bool isInFrontInMap (Unit const *target, float distance, float arc=M_PI) const
 
void SetInFront (Unit const *target)
 
void SetInFront (float x, float y)
 
bool isInBackInMap (Unit const *target, float distance, float arc=M_PI) const
 
void SetFacingTo (float ori)
 
void SetFacingToObject (WorldObject *pObject)
 
bool IsVisible () const
 
void SetVisible (bool x)
 
bool isValid () const override
 
void SetPhaseMask (uint32 newPhaseMask, bool update) override
 
void UpdateObjectVisibility (bool forced=true) override
 
bool isInvisibleForAlive () const
 returns true if creature can't be seen by alive units More...
 
AuraListGetSingleCastAuras ()
 
AuraList const & GetSingleCastAuras () const
 
bool CanHaveThreatList () const
 
void AddThreat (Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell=NULL)
 
void AddAssistThreat (Unit *victim, float threatToAdd, SpellEntry const *threatSpell)
 
float ApplyTotalThreatModifier (float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL)
 
void DeleteThreatList ()
 
void TauntApply (Unit *victim)
 
void TauntFadeOut (Unit *taunter)
 
ThreatManagergetThreatManager ()
 
void addHatedBy (HostileReference *pHostileReference)
 
void removeHatedBy (HostileReference *)
 
HostileRefManagergetHostileRefManager ()
 
AuraGetAura (uint32 spellId, uint32 effindex)
 
AuraMapGetAuras ()
 
AuraMap const & GetAuras () const
 
AuraList const & GetAurasByType (AuraType type) const
 
void ApplyAuraProcTriggerDamage (Aura *aura, bool apply)
 
int32 GetTotalAuraModifier (AuraType auratype) const
 
float GetTotalAuraMultiplier (AuraType auratype) const
 
int32 GetMaxPositiveAuraModifier (AuraType auratype) const
 
int32 GetMaxNegativeAuraModifier (AuraType auratype) const
 
int32 GetTotalAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
float GetTotalAuraMultiplierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
int32 GetMaxPositiveAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
int32 GetMaxNegativeAuraModifierByMiscMask (AuraType auratype, uint32 misc_mask) const
 
int32 GetTotalAuraModifierByMiscValue (AuraType auratype, int32 misc_value) const
 
float GetTotalAuraMultiplierByMiscValue (AuraType auratype, int32 misc_value) const
 
int32 GetMaxPositiveAuraModifierByMiscValue (AuraType auratype, int32 misc_value) const
 
int32 GetMaxNegativeAuraModifierByMiscValue (AuraType auratype, int32 misc_value) const
 
AuraGetDummyAura (uint32 spell_id) const
 
uint32 GetInterruptMask () const
 
void AddInterruptMask (uint32 mask)
 
void UpdateInterruptMask ()
 
uint32 GetDisplayId ()
 
void SetDisplayId (uint32 modelId)
 
uint32 GetNativeDisplayId ()
 
void SetNativeDisplayId (uint32 modelId)
 
void setTransForm (uint32 spellid)
 
uint32 getTransForm () const
 
void AddDynObject (DynamicObject *dynObj)
 
void RemoveDynObject (uint32 spellid)
 
void RemoveDynObjectWithGUID (uint64 guid)
 
void RemoveAllDynObjects ()
 
void AddGameObject (GameObject *gameObj)
 
void RemoveGameObject (GameObject *gameObj, bool del)
 
void RemoveGameObject (uint32 spellid, bool del)
 
void RemoveAllGameObjects ()
 
DynamicObjectGetDynObject (uint32 spellId, uint32 effIndex)
 
DynamicObjectGetDynObject (uint32 spellId)
 
void ModifyAuraState (AuraState flag, bool apply)
 
bool HasAuraState (AuraState flag) const
 
void UnsummonAllTotems ()
 
int32 SpellBaseDamageBonus (SpellSchoolMask schoolMask)
 
int32 SpellBaseHealingBonus (SpellSchoolMask schoolMask)
 
int32 SpellBaseDamageBonusForVictim (SpellSchoolMask schoolMask, Unit *victim)
 
int32 SpellBaseHealingBonusForVictim (SpellSchoolMask schoolMask, Unit *victim)
 
uint32 SpellDamageBonus (Unit *victim, SpellEntry const *spellProto, uint32 damage, DamageEffectType damagetype)
 
uint32 SpellHealingBonus (SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, Unit *victim)
 
bool isSpellBlocked (Unit *victim, SpellEntry const *spellProto, WeaponAttackType attackType=BASE_ATTACK)
 
bool isSpellCrit (Unit *victim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType=BASE_ATTACK)
 
uint32 SpellCriticalBonus (SpellEntry const *spellProto, uint32 damage, Unit *victim)
 
void SetLastManaUse (uint32 spellCastTime)
 
bool IsUnderLastManaUseEffect () const
 
void SetContestedPvP (Player *attackedPlayer=NULL)
 
void MeleeDamageBonus (Unit *victim, uint32 *damage, WeaponAttackType attType, SpellEntry const *spellProto=NULL)
 
uint32 GetCastingTimeForBonus (SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime)
 
void ApplySpellImmune (uint32 spellId, uint32 op, uint32 type, bool apply)
 
void ApplySpellDispelImmunity (const SpellEntry *spellProto, DispelType type, bool apply)
 
virtual bool IsImmuneToSpell (SpellEntry const *spellInfo, bool useCharges=false)
 
bool IsImmunedToDamage (SpellSchoolMask meleeSchoolMask, bool useCharges=false)
 
bool IsImmunedToDamage (SpellEntry const *spellInfo) const
 
virtual bool IsImmuneToSpellEffect (SpellEntry const *spellInfo, uint32 index, bool castOnSelf) const
 
uint32 CalculateEffectiveMagicResistance (Unit *attacker, SpellSchoolMask schoolMask) const
 
float CalculateMagicResistanceMitigation (Unit *attacker, uint32 resistance, bool binary) const
 
uint32 CalcArmorReducedDamage (Unit *victim, const uint32 damage)
 
void CalcAbsorbResist (Unit *victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, SpellEntry const *spellInfo=NULL, bool binary=false)
 
void UpdateSpeed (UnitMoveType mtype, bool forced)
 
float GetSpeed (UnitMoveType mtype) const
 
float GetSpeedRate (UnitMoveType mtype) const
 
void SetSpeed (UnitMoveType mtype, float rate, bool forced=false)
 
bool isHover () const
 
void _RemoveAllAuraMods ()
 
void _ApplyAllAuraMods ()
 
int32 CalculateSpellDamage (SpellEntry const *spellProto, uint8 effect_index, int32 basePoints, Unit const *target)
 
int32 CalculateSpellDuration (SpellEntry const *spellProto, uint8 effect_index, Unit const *target)
 
float CalculateLevelPenalty (SpellEntry const *spellProto) const
 
void ModSpellCastTime (SpellEntry const *spellProto, int32 &castTime, Spell *spell)
 
void ModSpellDurationTime (SpellEntry const *spellProto, int32 &duration, Spell *spell)
 
void addFollower (FollowerReference *pRef)
 
void removeFollower (FollowerReference *)
 
MotionMasterGetMotionMaster ()
 
bool IsStopped () const
 
void StopMoving ()
 
void AddUnitMovementFlag (uint32 f)
 
void RemoveUnitMovementFlag (uint32 f)
 
bool HasUnitMovementFlag (uint32 f) const
 
uint32 GetUnitMovementFlags () const
 
void SetUnitMovementFlags (uint32 f)
 
void SetControlled (bool apply, UnitState state)
 
void SetFeared (bool apply)
 
void SetConfused (bool apply)
 
void SetStunned (bool apply)
 
void MonsterMoveWithSpeed (float x, float y, float z, float speed, bool generatePath=false, bool forceDestination=false)
 
void SendMonsterMoveWithSpeedToCurrentDestination (float speed)
 
void AddComboPointHolder (uint32 lowguid)
 
void RemoveComboPointHolder (uint32 lowguid)
 
void ClearComboPointHolders ()
 
void SendPetCastFail (uint32 spellid, SpellCastResult msg)
 
void SendPetActionFeedback (uint8 msg)
 
void SendPetTalk (uint32 pettalk)
 
void SendPetSpellCooldown (uint32 spellid, time_t cooltime)
 
void SendPetClearCooldown (uint32 spellid)
 
void SendPetAIReaction (uint64 guid)
 
void propagateSpeedChange ()
 
void ClearAllReactives ()
 
void StartReactiveTimer (ReactiveType reactive)
 
void UpdateReactives (uint32 p_time)
 
void UpdateAuraForGroup (uint8 slot)
 
void AddPetAura (PetAura const *petSpell)
 
void RemovePetAura (PetAura const *petSpell)
 
void SetReducedThreatPercent (uint32 pct, uint64 guid)
 
uint32 GetReducedThreatPercent ()
 
UnitGetMisdirectionTarget ()
 
virtual float GetFollowAngle () const
 
bool IsFlying () const
 
bool IsFalling () const
 
bool IsWalking () const
 
bool IsRooted () const
 
void SetRooted (bool apply)
 
virtual bool SetWalk (bool enable)
 
virtual bool SetSwim (bool enable)
 
virtual bool SetLevitate (bool apply, bool packetOnly=false)
 
virtual bool SetCanFly (bool enable, bool packetOnly=false)
 
virtual bool SetWaterWalking (bool enable, bool packetOnly=false)
 
virtual bool SetFeatherFall (bool enable, bool packetOnly=false)
 
virtual bool SetHover (bool enable, bool packetOnly=false)
 
bool IsLevitating () const
 
time_t GetLastDamagedTime () const
 
void SetLastDamagedTime (time_t val)
 
TempSummonToTempSummon ()
 
TempSummon const * ToTempSummon () const
 
- Public Member Functions inherited from WorldObject
 ~WorldObject () override
 
void _Create (uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
 
void GetNearPoint2D (float &x, float &y, float distance, float absAngle) const
 
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
 
void GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
 
void MovePosition (Position &pos, float dist, float angle)
 
Position GetNearPosition (float dist, float angle)
 
void MovePositionToFirstCollision (Position &pos, float dist, float angle)
 
Position GetFirstCollisionPosition (float dist, float angle)
 
float GetPositionZTarget (Position &pos, float destx, float desty)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (const WorldObject *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
virtual float GetObjectBoundingRadius () const
 
float GetObjectSize () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z) const
 
void GetRandomPoint (const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
void GetRandomPoint (const Position &srcPos, float distance, Position &pos) const
 
float GetDistanceSqr (float x, float y, float z) const
 
bool HasInArc (float arcangle, const Position *pos) const
 
bool HasInArc (const float arcangle, const float x, const float y) const
 
uint32 GetInstanceId () const
 
uint32 GetPhaseMask () const
 
bool InSamePhase (uint32 phasemask) const
 
bool InSamePhase (WorldObject const *obj) const
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
InstanceDataGetInstanceData ()
 
const char * GetName () const
 
void SetName (const std::string &newname)
 
virtual const char * GetNameForLocaleIdx (int32) const
 
float GetDistance (const WorldObject *obj) const
 
float GetDistance (const Position &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (const WorldObject *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (const WorldObject *obj) const
 
bool IsInMap (const WorldObject *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (const Position *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (const Position *pos, float dist) const
 
bool _IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinLOS (float x, float y, float z) const
 
bool IsWithinLOSInMap (const WorldObject *obj) const
 
Position GetHitSpherePointFor (Position const &dest) const
 
void GetHitSpherePointFor (Position const &dest, float &x, float &y, float &z) const
 
bool GetDistanceOrder (WorldObject const *obj1, WorldObject const *obj2, bool is3D=true) const
 
bool IsInRange (WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
 
bool IsInRange2d (float x, float y, float minRange, float maxRange) const
 
bool IsInRange3d (float x, float y, float z, float minRange, float maxRange) const
 
virtual void SendMessageToSet (WorldPacket *data, bool self)
 
virtual void SendMessageToSetInRange (WorldPacket *data, float dist, bool self)
 
void MonsterSay (const char *text, uint32 language, uint64 TargetGuid)
 
void MonsterYell (const char *text, uint32 language, uint64 TargetGuid)
 
void MonsterTextEmote (const char *text, uint64 TargetGuid, bool IsBossEmote=false)
 
void MonsterWhisper (const char *text, uint64 receiver, bool IsBossWhisper=false)
 
void MonsterSay (int32 textId, uint32 language, uint64 TargetGuid)
 
void MonsterYell (int32 textId, uint32 language, uint64 TargetGuid)
 
void MonsterTextEmote (int32 textId, uint64 TargetGuid, bool IsBossEmote=false)
 
void MonsterWhisper (int32 textId, uint64 receiver, bool IsBossWhisper=false)
 
void MonsterYellToZone (int32 textId, uint32 language, uint64 TargetGuid)
 
void BuildMonsterChat (WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
 
void PlayDistanceSound (uint32 sound_id, Player *target=NULL)
 
void PlayDirectSound (uint32 sound_id, Player *target=NULL)
 
void SendObjectDeSpawnAnim (uint64 guid)
 
void SendObjectCustomAnim (uint64 guid, uint32 anim=0)
 
virtual void SaveRespawnTime ()
 
void AddObjectToRemoveList ()
 
virtual bool IsNeverVisible () const
 
virtual bool IsInvisibleDueToDespawn () const
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
float GetSightRange (const WorldObject *target=NULL) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
void SendPlaySound (uint32 Sound, bool OnlySelf)
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
Map const * GetBaseMap () const
 
void SetZoneScript ()
 
TempSummonSummonCreature (uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=NULL)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true)
 
GameObjectFindNearestGameObject (uint32 entry, float range)
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &gameobjectList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &creatureList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibilityOnCreate ()
 
void BuildUpdate (UpdateDataMapType &) override
 
void AddToNotify (uint16 f)
 
bool isNeedNotify (uint16 f) const
 
uint16 GetNotifyFlags () const
 
bool NotifyExecuted (uint16 f) const
 
void SetNotified (uint16 f)
 
void ResetAllNotifies ()
 
bool isActiveObject () const
 
void setActive (bool isActiveObject)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
template<class NOTIFIER >
void VisitNearbyWorldObject (const float &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyGridObject (float const &radius, NOTIFIER &notifier) const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
const bool & IsInWorld () const
 
const uint64GetGUID () const
 
uint32 GetGUIDLow () const
 
uint32 GetGUIDMid () const
 
uint32 GetGUIDHigh () const
 
PackedGuid const & GetPackGUID () const
 
ObjectGuid const & GetObjectGUID () const
 
std::string GetGuidStr () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
void SetObjectScale (float scale)
 
uint8 GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
 
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
 
const int32GetInt32Value (uint16 index) const
 
const uint32GetUInt32Value (uint16 index) const
 
const uint64GetUInt64Value (uint16 index) const
 
const float & GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
ObjectGuid const & GetGuidValue (uint16 index) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, const uint64 &value)
 
void SetFloatValue (uint16 index, float value)
 
void SetByteValue (uint16 index, uint8 offset, uint8 value)
 
void SetUInt16Value (uint16 index, uint8 offset, uint16 value)
 
void SetInt16Value (uint16 index, uint8 offset, int16 value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddUInt64Value (uint16 index, const uint64 &value)
 
bool RemoveUInt64Value (uint16 index, const uint64 &value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt64Value (uint16 index, int32 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
 
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void ToggleFlag (uint16 index, uint8 offset, uint8 flag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
bool LoadValues (const char *data)
 
uint16 GetValuesCount () const
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) const
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void ForceValuesUpdateAtIndex (uint32)
 
PlayerToPlayer ()
 
Player const * ToPlayer () const
 
CreatureToCreature ()
 
Creature const * ToCreature () const
 
UnitToUnit ()
 
Unit const * ToUnit () const
 
GameObjectToGameObject ()
 
GameObject const * ToGameObject () const
 
CorpseToCorpse ()
 
Corpse const * ToCorpse () const
 
DynamicObjectToDynObject ()
 
DynamicObject const * ToDynObject () const
 
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 _mapid=MAPID_INVALID, float _x=0, float _y=0, float _z=0, float _o=0)
 
 WorldLocation (const WorldLocation &loc)
 
void WorldRelocate (const WorldLocation &loc)
 
uint32 GetMapId () const
 
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 
 Position (Position const &loc)
 
bool operator== (Position const &a)
 
bool operator!= (Position const &a)
 
void Relocate (float x, float y)
 
void Relocate (float x, float y, float z)
 
void Relocate (float x, float y, float z, float orientation)
 
void Relocate (Position const &pos)
 
void Relocate (Position const *pos)
 
void RelocateOffset (Position const &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
Position::PositionXYStreamer PositionXYStream ()
 
Position::PositionXYZStreamer PositionXYZStream ()
 
Position::PositionXYZOStreamer PositionXYZOStream ()
 
bool IsPositionValid () const
 
float GetExactDist2dSq (float x, float y) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (Position const &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (Position const *pos) const
 
float GetAngle (float x, float y) const
 
float GetRelativeAngle (Position const *pos) const
 
float GetRelativeAngle (float x, float y) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (Position const *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (Position const *pos, float dist) const
 
bool IsWithinBox (const Position &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, Position const *pos, float border=2.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
std::string ToString () const
 

Static Public Member Functions

static ReputationRank GetFactionReactionTo (FactionTemplateEntry const *factionTemplateEntry, Unit const *target)
 
static bool IsDamageReducedByArmor (SpellSchoolMask damageSchoolMask, SpellEntry const *spellInfo=NULL, uint8 effIndex=MAX_SPELL_EFFECTS)
 
static UnitGetUnit (WorldObject &object, uint64 guid)
 
static PlayerGetPlayer (WorldObject &object, uint64 guid)
 
static CreatureGetCreature (WorldObject &object, uint64 guid)
 
- Static Public Member Functions inherited from WorldObject
static bool InSamePhase (WorldObject const *a, WorldObject const *b)
 
- Static Public Member Functions inherited from Position
static float NormalizeOrientation (float o)
 

Public Attributes

uint32 m_extraAttacks
 
bool m_canDualWield
 
IntervalTimer m_CombatTimer
 
ControlList m_Controlled
 
uint64 m_SummonSlot [MAX_SUMMON_SLOT]
 
uint64 m_ObjectSlot [4]
 
uint32 m_ShapeShiftFormSpellId
 
uint32 m_ShapeShiftModelId
 
ShapeshiftForm m_form
 
float m_modMeleeHitChance
 
float m_modRangedHitChance
 
float m_modSpellHitChance
 
int32 m_baseSpellCritChance
 
float m_threatModifier [MAX_SPELL_SCHOOL]
 
float m_modAttackSpeedPct [3]
 
uint32 _oldFactionId
 
EventProcessor m_Events
 
SpellImmuneList m_spellImmune [MAX_SPELL_IMMUNITY]
 
uint32 m_lastSanctuaryTime
 
uint32 m_AuraFlags
 
Movement::MoveSplinemovespline
 
PetAuraSet m_petAuras
 
bool IsAIEnabled
 
bool NeedChangeAI
 
uint64 LastCharmerGUID
 
bool m_ControlledByPlayer
 
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealth
 
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealthDetect
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibility
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibilityDetect
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibility
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibilityDetect
 
uint32 m_groupLootTimer
 
uint64 lootingGroupLeaderGUID
 
MovementInfo m_movementInfo
 
- Public Attributes inherited from WorldLocation
uint32 m_mapId
 
- Public Attributes inherited from Position
float m_positionX
 
float m_positionY
 
float m_positionZ
 

Protected Types

typedef std::list< uint64DynObjectGUIDs
 

Protected Member Functions

 Unit (bool isWorldObject)
 
void _UpdateSpells (uint32 time)
 
void _DeleteAuras ()
 
void _UpdateAutoRepeatSpell ()
 
virtual SpellSchoolMask GetMeleeDamageSchoolMask () const
 
void DisableSpline ()
 
bool IsAlwaysVisibleFor (WorldObject const *seer) const override
 
bool IsAlwaysDetectableFor (WorldObject const *seer) const override
 
- Protected Member Functions inherited from WorldObject
 WorldObject (bool isWorldObject)
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (uint32 guidlow, uint32 entry, HighGuid guidhigh)
 
void _LoadIntoDataField (const char *data, uint32 startOffset, uint32 count)
 
virtual void _SetUpdateBits (UpdateMask *updateMask, Player *target) const
 
virtual void _SetCreateBits (UpdateMask *updateMask, Player *target) const
 
void _BuildMovementUpdate (ByteBuffer *data, uint8 updateFlags) const
 
void _BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, UpdateMask *updateMask, Player *target) const
 

Protected Attributes

UnitAIi_AI
 
UnitAIi_disabledAI
 
bool m_AutoRepeatFirstCast
 
bool m_initiatingCombat
 
uint32 m_attackTimer [MAX_ATTACK]
 
float m_createStats [MAX_STATS]
 
AttackerSet m_attackers
 
Unitm_attacking
 
DeathState m_deathState
 
AuraMap m_Auras
 
AuraMap::iterator m_AurasUpdateIterator
 
uint32 m_removedAurasCount
 
DynObjectGUIDs m_dynObjGUIDs
 
std::list< GameObject * > m_gameObj
 
bool m_isSorted
 
uint32 m_transform
 
AuraList m_removedAuras
 
AuraList m_modAuras [TOTAL_AURAS]
 
AuraList m_scAuras
 
AuraList m_interruptableAuras
 
AuraList m_ccAuras
 
uint32 m_interruptMask
 
float m_auraModifiersGroup [UNIT_MOD_END][MODIFIER_TYPE_END]
 
float m_weaponDamage [MAX_ATTACK][2]
 
bool m_canModifyStats
 
float m_speed_rate [MAX_MOVE_TYPE]
 
uint32 m_unitTypeMask
 
CharmInfom_charmInfo
 
SharedVisionList m_sharedVision
 
MotionMaster i_motionMaster
 
uint64 miniPetGuid
 
uint32 m_reactiveTimer [MAX_REACTIVE]
 
ThreatManager m_ThreatManager
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
uint8 m_objectTypeId
 
uint8 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
uint32m_uint32Values_mirror
 
uint16 m_valuesCount
 
bool m_objectUpdated
 

Private Member Functions

bool IsTriggeredAtSpellProcEvent (Unit *victim, Aura *aura, SpellEntry const *procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const *&spellProcEvent)
 
bool HandleDummyAuraProc (Unit *victim, uint32 damage, Aura *triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
 
bool HandleHasteAuraProc (Unit *victim, uint32 damage, Aura *triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
 
bool HandleProcTriggerSpell (Unit *victim, uint32 damage, Aura *triggredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
 
bool HandleOverrideClassScriptAuraProc (Unit *victim, Aura *triggredByAura, SpellEntry const *procSpell, uint32 cooldown)
 
bool HandleMendingAuraProc (Aura *triggeredByAura)
 
void UpdateSplineMovement (uint32 t_diff)
 

Private Attributes

uint32 m_state
 
uint32 m_lastManaUse
 
Spellm_currentSpells [CURRENT_MAX_SPELL]
 
TimeTrackerSmall m_movesplineTimer
 
Diminishing m_Diminishing
 
HostileRefManager m_HostileRefManager
 
FollowerRefManager m_FollowingRefManager
 
ComboPointHolderSet m_ComboPointHolders
 
uint32 m_reducedThreatPercent
 
uint64 m_misdirectionTargetGUID
 
bool m_duringRemoveFromWorld
 
uint32 m_procDeep
 
time_t _lastDamagedTime
 

Friends

class ScriptEvent
 

Detailed Description

Definition at line 908 of file Unit.h.

Member Typedef Documentation

typedef std::set<Unit*> Unit::AttackerSet

Definition at line 913 of file Unit.h.

typedef std::list<Aura*> Unit::AuraList

Definition at line 917 of file Unit.h.

typedef std::multimap< spellEffectPair, Aura*> Unit::AuraMap

Definition at line 916 of file Unit.h.

typedef std::set<AuraType> Unit::AuraTypeSet

Definition at line 919 of file Unit.h.

typedef std::set<uint32> Unit::ComboPointHolderSet

Definition at line 920 of file Unit.h.

typedef std::set<Unit*> Unit::ControlList

Definition at line 914 of file Unit.h.

Definition at line 918 of file Unit.h.

typedef std::list<uint64> Unit::DynObjectGUIDs
protected

Definition at line 2028 of file Unit.h.

typedef std::set<PetAura const*> Unit::PetAuraSet

Definition at line 1953 of file Unit.h.

typedef std::pair<uint32, uint8> Unit::spellEffectPair

Definition at line 915 of file Unit.h.

Constructor & Destructor Documentation

Unit::~Unit ( )
override

Definition at line 474 of file Unit.cpp.

References _DeleteAuras(), ASSERT, CURRENT_MAX_SPELL, m_attackers, m_attacking, m_charmInfo, m_currentSpells, m_duringRemoveFromWorld, m_sharedVision, movespline, RemoveAllDynObjects(), RemoveAllGameObjects(), and Spell::SetReferencedFromCurrent().

475 {
476  // set current spells as deletable
477  for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
478  if (m_currentSpells[i])
479  {
481  m_currentSpells[i] = NULL;
482  }
483 
486  _DeleteAuras();
487 
488  delete m_charmInfo;
489  delete movespline;
490 
493  ASSERT(m_attackers.empty());
494  ASSERT(m_sharedVision.empty());
495 }
bool m_duringRemoveFromWorld
Definition: Unit.h:2096
Movement::MoveSpline * movespline
Definition: Unit.h:1907
SharedVisionList m_sharedVision
Definition: Unit.h:2051
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2079
void _DeleteAuras()
Definition: Unit.cpp:3334
CharmInfo * m_charmInfo
Definition: Unit.h:2050
ACE_UINT8 uint8
Definition: Define.h:73
Unit * m_attacking
Definition: Unit.h:2020
#define CURRENT_MAX_SPELL
Definition: Unit.h:744
AttackerSet m_attackers
Definition: Unit.h:2019
#define ASSERT
Definition: Errors.h:29
void RemoveAllGameObjects()
Definition: Unit.cpp:4793
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:482
void RemoveAllDynObjects()
Definition: Unit.cpp:4673
Unit::Unit ( bool  isWorldObject)
explicitprotected

Definition at line 364 of file Unit.cpp.

References _oldFactionId, ALIVE, BASE_ATTACK, BASE_MAXDAMAGE, BASE_MINDAMAGE, BASE_PCT, BASE_VALUE, CURRENT_MAX_SPELL, FORM_NONE, GHOST_VISIBILITY_ALIVE, m_attacking, m_attackTimer, m_AuraFlags, m_auraModifiersGroup, m_Auras, m_AurasUpdateIterator, m_baseSpellCritChance, m_canDualWield, m_canModifyStats, m_charmInfo, m_CombatTimer, m_createStats, m_currentSpells, m_deathState, m_duringRemoveFromWorld, m_extraAttacks, m_form, m_initiatingCombat, m_interruptMask, m_isSorted, m_lastManaUse, m_misdirectionTargetGUID, m_modAttackSpeedPct, m_modMeleeHitChance, m_modRangedHitChance, m_modSpellHitChance, m_ObjectSlot, Object::m_objectType, Object::m_objectTypeId, m_reactiveTimer, m_reducedThreatPercent, WorldObject::m_serverSideVisibility, m_ShapeShiftFormSpellId, m_speed_rate, m_spellImmune, m_state, m_SummonSlot, m_threatModifier, m_transform, m_unitTypeMask, Object::m_updateFlag, m_weaponDamage, MAX_ATTACK, MAX_MOVE_TYPE, MAX_REACTIVE, MAX_SPELL_IMMUNITY, MAX_SPELL_SCHOOL, MAX_STATS, MAX_SUMMON_SLOT, MAXDAMAGE, MINDAMAGE, OFF_ATTACK, RANGED_ATTACK, SERVERSIDE_VISIBILITY_GHOST, IntervalTimer::SetInterval(), FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::SetValue(), TOTAL_PCT, TOTAL_VALUE, TYPEID_UNIT, TYPEMASK_UNIT, UNIT_MASK_NONE, UNIT_MOD_DAMAGE_OFFHAND, UNIT_MOD_END, UPDATEFLAG_HAS_POSITION, UPDATEFLAG_HIGHGUID, and UPDATEFLAG_LIVING.

364  :
365  WorldObject(isWorldObject), IsAIEnabled(false),
366  NeedChangeAI(false),
367  LastCharmerGUID(0),
368  m_ControlledByPlayer(false),
369  i_AI(NULL),
370  i_disabledAI(NULL),
372  i_motionMaster(this),
373  m_ThreatManager(this),
374  m_HostileRefManager(this),
376  m_procDeep(0),
380 {
383 
385 
392 
393  m_extraAttacks = 0;
394  m_canDualWield = false;
395 
396  m_state = 0;
397  m_form = FORM_NONE;
399 
400  for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
401  m_currentSpells[i] = NULL;
402 
403  for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
404  m_SummonSlot[i] = 0;
405 
406  m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0;
407 
409  m_AuraFlags = 0;
410 
411  m_interruptMask = 0;
412  m_transform = 0;
414  m_canModifyStats = false;
415 
416  for (uint8 i = 0; i < MAX_SPELL_IMMUNITY; ++i)
417  m_spellImmune[i].clear();
418 
419  for (uint8 i = 0; i < UNIT_MOD_END; ++i)
420  {
421  m_auraModifiersGroup[i][BASE_VALUE] = 0.0f;
422  m_auraModifiersGroup[i][BASE_PCT] = 1.0f;
424  m_auraModifiersGroup[i][TOTAL_PCT] = 1.0f;
425  }
426  // implement 50% base damage from offhand
428 
429  for (uint8 i = 0; i < MAX_ATTACK; ++i)
430  {
433  }
434 
435  for (uint8 i = 0; i < MAX_STATS; ++i)
436  m_createStats[i] = 0.0f;
437 
438  m_attacking = NULL;
439  m_modMeleeHitChance = 0.0f;
440  m_modRangedHitChance = 0.0f;
441  m_modSpellHitChance = 0.0f;
443 
444  m_initiatingCombat = false;
445 
447  m_lastManaUse = 0;
448 
449  for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
450  m_threatModifier[i] = 1.0f;
451 
452  m_isSorted = true;
453 
454  for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
455  m_speed_rate[i] = 1.0f;
456 
458 
459  m_charmInfo = NULL;
462 
463  // remove aurastates allowing special moves
464  for (uint8 i = 0; i < MAX_REACTIVE; ++i)
465  m_reactiveTimer[i] = 0;
466 
467  m_duringRemoveFromWorld = false;
468 
469  _oldFactionId = 0;
470 
472 }
#define BASE_MINDAMAGE
Definition: Unit.h:157
uint32 m_removedAurasCount
Definition: Unit.h:2026
#define MAX_MOVE_TYPE
Definition: Unit.h:494
bool m_ControlledByPlayer
Definition: Unit.h:1992
float m_modMeleeHitChance
Definition: Unit.h:1625
bool m_duringRemoveFromWorld
Definition: Unit.h:2096
int32 m_baseSpellCritChance
Definition: Unit.h:1628
Movement::MoveSpline * movespline
Definition: Unit.h:1907
#define MAX_ATTACK
Definition: Unit.h:505
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:833
uint32 m_reducedThreatPercent
Definition: Unit.h:2093
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2079
CharmInfo * m_charmInfo
Definition: Unit.h:2050
bool m_isSorted
Definition: Unit.h:2032
Definition: Unit.h:437
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:626
uint32 m_lastSanctuaryTime
Definition: Unit.h:1711
uint32 m_reactiveTimer[MAX_REACTIVE]
Definition: Unit.h:2059
float m_speed_rate[MAX_MOVE_TYPE]
Definition: Unit.h:2047
TimeTrackerSmall m_movesplineTimer
Definition: Unit.h:2081
uint64 LastCharmerGUID
Definition: Unit.h:1991
bool IsAIEnabled
Definition: Unit.h:1990
uint16 m_objectType
Definition: Object.h:424
uint32 m_transform
Definition: Unit.h:2033
#define MAX_SPELL_SCHOOL
uint64 m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1607
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2042
uint32 _oldFactionId
Definition: Unit.h:1633
time_t _lastDamagedTime
Definition: Unit.h:2100
uint32 m_state
Definition: Unit.h:2076
void SetInterval(time_t interval)
Definition: Timer.h:122
uint32 m_lastManaUse
Definition: Unit.h:2077
UnitAI * i_AI
Definition: Unit.h:2004
UnitAI * i_disabledAI
Definition: Unit.h:2004
uint64 m_misdirectionTargetGUID
Definition: Unit.h:2094
#define MAX_SPELL_IMMUNITY
#define MAX_STATS
uint8 m_objectTypeId
Definition: Object.h:426
float m_modSpellHitChance
Definition: Unit.h:1627
ACE_UINT8 uint8
Definition: Define.h:73
uint8 m_updateFlag
Definition: Object.h:427
DeathState m_deathState
Definition: Unit.h:2022
Unit * m_attacking
Definition: Unit.h:2020
HostileRefManager m_HostileRefManager
Definition: Unit.h:2087
float m_modAttackSpeedPct[3]
Definition: Unit.h:1631
#define BASE_MAXDAMAGE
Definition: Unit.h:158
float m_createStats[MAX_STATS]
Definition: Unit.h:2017
bool NeedChangeAI
Definition: Unit.h:1990
#define MAX_REACTIVE
Definition: Unit.h:894
uint32 m_AuraFlags
Definition: Unit.h:1770
ThreatManager m_ThreatManager
Definition: Unit.h:2061
uint32 m_ShapeShiftFormSpellId
Definition: Unit.h:1610
uint32 m_extraAttacks
Definition: Unit.h:990
WorldObject(bool isWorldObject)
Definition: Object.cpp:1087
MotionMaster i_motionMaster
Definition: Unit.h:2055
#define CURRENT_MAX_SPELL
Definition: Unit.h:744
bool m_canDualWield
Definition: Unit.h:991
uint32 m_unitTypeMask
Definition: Unit.h:2049
bool m_initiatingCombat
Definition: Unit.h:2013
uint32 m_interruptMask
Definition: Unit.h:2040
float m_threatModifier[MAX_SPELL_SCHOOL]
Definition: Unit.h:1630
#define MAX_SUMMON_SLOT
Definition: Unit.h:900
uint64 m_ObjectSlot[4]
Definition: Unit.h:1608
float m_modRangedHitChance
Definition: Unit.h:1626
Definition: Unit.h:354
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2015
IntervalTimer m_CombatTimer
Definition: Unit.h:1253
AuraMap::iterator m_AurasUpdateIterator
Definition: Unit.h:2025
uint32 m_procDeep
Definition: Unit.h:2098
float m_weaponDamage[MAX_ATTACK][2]
Definition: Unit.h:2043
AuraMap m_Auras
Definition: Unit.h:2024
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1710
bool m_canModifyStats
Definition: Unit.h:2044
ShapeshiftForm m_form
Definition: Unit.h:1612

Member Function Documentation

void Unit::_addAttacker ( Unit pAttacker)
inline

Definition at line 993 of file Unit.h.

Referenced by Attack().

994  {
995  AttackerSet::iterator itr = m_attackers.find(pAttacker);
996  if (itr == m_attackers.end())
997  m_attackers.insert(pAttacker);
998  }
AttackerSet m_attackers
Definition: Unit.h:2019
void Unit::_ApplyAllAuraMods ( )

Definition at line 4635 of file Unit.cpp.

References m_Auras.

Referenced by Player::_ApplyAllStatBonuses().

4636 {
4637  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
4638  (*i).second->ApplyModifier(true);
4639 }
AuraMap m_Auras
Definition: Unit.h:2024
void Unit::_DeleteAuras ( )
protected

Definition at line 3334 of file Unit.cpp.

References m_removedAuras.

Referenced by _UpdateSpells(), and ~Unit().

3335 {
3336  while (!m_removedAuras.empty())
3337  {
3338  delete m_removedAuras.front();
3339  m_removedAuras.pop_front();
3340  }
3341 }
AuraList m_removedAuras
Definition: Unit.h:2034
bool Unit::_IsValidAssistTarget ( Unit const *  target,
SpellEntry const *  bySpell 
) const

Definition at line 9637 of file Unit.cpp.

References ASSERT, SpellEntry::AttributesEx6, WorldObject::CanSeeOrDetect(), CREATURE_TYPE_FLAG_CAN_ASSIST, Player::duel, GetAffectingPlayer(), Object::GetByteValue(), GetReactionTo(), Object::GetTypeId(), Object::HasFlag(), HasUnitState(), IsAlive(), Player::IsGameMaster(), PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY, REP_NEUTRAL, SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG, Object::ToCreature(), Object::ToPlayer(), TYPEID_PLAYER, UNIT_BYTE2_FLAG_FFA_PVP, UNIT_BYTE2_FLAG_UNK0, UNIT_FIELD_BYTES_2, UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC, UNIT_FLAG_IMMUNE_TO_PC, UNIT_FLAG_NOT_SELECTABLE, UNIT_FLAG_PVP_ATTACKABLE, and UNIT_STATE_UNATTACKABLE.

Referenced by IsValidAssistTarget(), and Oregon::SpellNotifierCreatureAndPlayer::Visit().

9638 {
9639  ASSERT(target);
9640 
9641  // can assist to self
9642  if (this == target)
9643  return true;
9644 
9645  // can't assist unattackable units or GMs
9646  if (target->HasUnitState(UNIT_STATE_UNATTACKABLE)
9647  || target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
9648  return false;
9649 
9650  // can't assist invisible
9651  if (!CanSeeOrDetect(target))
9652  return false;
9653 
9654  // can't assist dead
9655  if (!target->IsAlive())
9656  return false;
9657 
9658  // can't assist untargetable
9659  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
9660  return false;
9661 
9662  if (!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
9663  {
9665  {
9666  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))
9667  return false;
9668  }
9669  else
9670  {
9671  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
9672  return false;
9673  }
9674  }
9675 
9676  // can't assist non-friendly targets
9677  if (GetReactionTo(target) < REP_NEUTRAL
9678  && target->GetReactionTo(this) < REP_NEUTRAL)
9679  return false;
9680 
9681  // PvP case
9682  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
9683  {
9684  Player const* targetPlayerOwner = target->GetAffectingPlayer();
9686  {
9687  Player const* selfPlayerOwner = GetAffectingPlayer();
9688  if (selfPlayerOwner && targetPlayerOwner)
9689  {
9690  // can't assist player which is dueling someone
9691  if (selfPlayerOwner != targetPlayerOwner
9692  && targetPlayerOwner->duel)
9693  return false;
9694  }
9695  // can't assist player in ffa_pvp zone from outside
9696  if ((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP)
9698  return false;
9699  // can't assist player out of sanctuary from sanctuary if has pvp enabled
9700  if (target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK0)
9702  return false;
9703  }
9704  }
9705  // PvC case - player can assist creature only if has specific type flags
9706  // !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) &&
9708  && (!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
9709  && !((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK0)))
9710  {
9711  if (Creature const* creatureTarget = target->ToCreature())
9712  return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST;
9713  }
9714  return true;
9715 }
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7202
DuelInfo * duel
Definition: Player.h:1795
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7650
Creature * ToCreature()
Definition: Object.h:395
#define ASSERT
Definition: Errors.h:29
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:305
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1585
Definition: Player.h:922
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.h:252
bool Unit::_IsValidAttackTarget ( Unit const *  target,
SpellEntry const *  bySpell,
WorldObject const *  obj = NULL 
) const

Definition at line 9524 of file Unit.cpp.

References ASSERT, WorldObject::CanSeeOrDetect(), Player::duel, FACTION_FLAG_AT_WAR, GetAffectingPlayer(), Object::GetEntry(), GetFactionTemplateEntry(), ReputationMgr::GetForcedRankIfAny(), GetReactionTo(), Player::GetReputationMgr(), ReputationMgr::GetState(), Object::GetTypeId(), Object::HasFlag(), HasStealthAura(), HasUnitState(), IsAlive(), IsContestedGuard(), Player::IsFFAPvP(), Player::IsGameMaster(), IsInCombat(), IsInCombatWith(), IsInSanctuary(), IsPvP(), Object::isType(), DuelInfo::opponent, PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP, REP_HOSTILE, REP_NEUTRAL, sFactionStore, DuelInfo::startTime, Object::ToPlayer(), TYPEID_PLAYER, TYPEMASK_DYNAMICOBJECT, TYPEMASK_GAMEOBJECT, UNIT_BYTE2_FLAG_UNK1, UNIT_FIELD_BYTES_2, UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC, UNIT_FLAG_IMMUNE_TO_PC, UNIT_FLAG_NON_ATTACKABLE, UNIT_FLAG_NOT_ATTACKABLE_1, UNIT_FLAG_NOT_PL_SPELL_TARGET, UNIT_FLAG_NOT_SELECTABLE, UNIT_FLAG_PVP_ATTACKABLE, UNIT_FLAG_TAXI_FLIGHT, UNIT_STATE_UNATTACKABLE, and WORLD_TRIGGER.

Referenced by IsValidAttackTarget(), and Oregon::SpellNotifierCreatureAndPlayer::Visit().

9525 {
9526  ASSERT(target);
9527 
9528  // can't attack self
9529  if (this == target)
9530  return false;
9531 
9532  // can't attack unattackable units or GMs
9533  if (target->HasUnitState(UNIT_STATE_UNATTACKABLE)
9534  || target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
9535  return false;
9536 
9537  // visibility checks
9538  // skip visibility check for GO casts, needs removal when go cast is implemented. Also ignore for gameobject and dynauras
9539  if (GetEntry() != WORLD_TRIGGER && (!obj || !obj->isType(TYPEMASK_GAMEOBJECT | TYPEMASK_DYNAMICOBJECT)))
9540  {
9541  // can't attack invisible
9542  if (!bySpell)
9543  {
9544  if (obj && !obj->CanSeeOrDetect(target))
9545  return false;
9546  else if (!obj)
9547  {
9548  // ignore stealth for aoe spells. Ignore stealth if target is player and unit in combat with same player
9549  bool const ignoreStealthCheck = target->GetTypeId() == TYPEID_PLAYER && target->HasStealthAura() && target->IsInCombat() && IsInCombatWith(target);
9550 
9551  if (!CanSeeOrDetect(target, ignoreStealthCheck))
9552  return false;
9553  }
9554  }
9555  }
9556 
9557  // can't attack dead
9558  if (!target->IsAlive())
9559  return false;
9560 
9561  // can't attack untargetable
9562  if (!bySpell && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
9563  return false;
9564 
9565  // check flags
9570  // check if this is a world trigger cast - GOs are using world triggers to cast their spells, so we need to ignore their immunity flag here, this is a temp workaround, needs removal when go cast is implemented properly
9572  return false;
9573 
9574  // CvC case - can attack each other only when one of them is hostile
9576  return GetReactionTo(target) <= REP_HOSTILE || target->GetReactionTo(this) <= REP_HOSTILE;
9577 
9578  // PvP, PvC, CvP case
9579  // can't attack friendly targets
9580  if (GetReactionTo(target) > REP_NEUTRAL
9581  || target->GetReactionTo(this) > REP_NEUTRAL)
9582  return false;
9583 
9584  Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : nullptr;
9585  Player const* playerAffectingTarget = target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? target->GetAffectingPlayer() : nullptr;
9586 
9587  // Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
9588  if ((playerAffectingAttacker && !playerAffectingTarget) ||
9589  (!playerAffectingAttacker && playerAffectingTarget))
9590  {
9591  Player const* player = playerAffectingAttacker ? playerAffectingAttacker : playerAffectingTarget;
9592  Unit const* creature = playerAffectingAttacker ? target : this;
9593 
9594  if (creature->IsContestedGuard() && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
9595  return true;
9596 
9597  if (FactionTemplateEntry const* factionTemplate = creature->GetFactionTemplateEntry())
9598  {
9599  if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate)))
9600  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction))
9601  if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
9602  if (!(repState->Flags & FACTION_FLAG_AT_WAR) && (!IsContestedGuard() && !player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)))
9603  return false;
9604 
9605  }
9606  }
9607 
9608  // check duel - before sanctuary checks
9609  if (playerAffectingAttacker && playerAffectingTarget)
9610  if (playerAffectingAttacker->duel && playerAffectingAttacker->duel->opponent == playerAffectingTarget && playerAffectingAttacker->duel->startTime != 0)
9611  return true;
9612 
9613  // PvP case - can't attack when attacker or target are in sanctuary
9614  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) && (target->IsInSanctuary() || IsInSanctuary()))
9615  return false;
9616 
9617  // additional checks - only PvP case
9618  if (playerAffectingAttacker && playerAffectingTarget)
9619  {
9620  if (target->IsPvP())
9621  return true;
9622 
9623  if (playerAffectingAttacker->IsFFAPvP() && playerAffectingTarget->IsFFAPvP())
9624  return true;
9625 
9627  || target->HasFlag(UNIT_FIELD_BYTES_2, UNIT_BYTE2_FLAG_UNK1);
9628  }
9629  return true;
9630 }
time_t startTime
Definition: Player.h:235
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7202
DuelInfo * duel
Definition: Player.h:1795
bool IsFFAPvP() const
Definition: Player.h:1768
#define WORLD_TRIGGER
Definition: Unit.h:38
FactionState const * GetState(FactionEntry const *factionEntry) const
Definition: ReputationMgr.h:76
bool IsContestedGuard() const
Definition: Unit.h:1131
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7650
ReputationRank const * GetForcedRankIfAny(FactionTemplateEntry const *factionTemplateEntry) const
Definition: ReputationMgr.h:97
bool IsInSanctuary() const
Definition: Unit.cpp:9515
ReputationMgr & GetReputationMgr()
Definition: Player.h:2079
Player * opponent
Definition: Player.h:233
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
#define ASSERT
Definition: Errors.h:29
uint32 GetEntry() const
Definition: Object.h:192
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7187
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:305
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1585
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:498
Definition: Unit.h:908
Definition: Player.h:922
void Unit::_RemoveAllAuraMods ( )

Definition at line 4629 of file Unit.cpp.

References m_Auras.

Referenced by Player::_RemoveAllStatBonuses().

4630 {
4631  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
4632  (*i).second->ApplyModifier(false);
4633 }
AuraMap m_Auras
Definition: Unit.h:2024
void Unit::_removeAttacker ( Unit pAttacker)
inline

Definition at line 999 of file Unit.h.

Referenced by AttackStop(), and Creature::SelectVictim().

1000  {
1001  m_attackers.erase(pAttacker);
1002  }
AttackerSet m_attackers
Definition: Unit.h:2019
void Unit::_UpdateAutoRepeatSpell ( )
protected

Definition at line 3395 of file Unit.cpp.

References CURRENT_AUTOREPEAT_SPELL, getAttackTimer(), Object::GetTypeId(), InterruptSpell(), isAttackReady(), isMoving(), IsNonMeleeSpellCast(), m_AutoRepeatFirstCast, m_currentSpells, Spell::prepare(), RANGED_ATTACK, resetAttackTimer(), setAttackTimer(), SPELL_CAST_OK, and TYPEID_PLAYER.

Referenced by _UpdateSpells().

3396 {
3397  //check "realtime" interrupts
3398  if ((GetTypeId() == TYPEID_PLAYER && isMoving()) || IsNonMeleeSpellCast(false, false, true))
3399  {
3400  // cancel wand shoot
3401  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351)
3403  m_AutoRepeatFirstCast = true;
3404  return;
3405  }
3406 
3407  // apply delay (Auto Shot (spellID 75) not affected)
3410  m_AutoRepeatFirstCast = false;
3411 
3412  //castroutine
3414  {
3415  // Check if able to cast
3416  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true) != SPELL_CAST_OK)
3417  {
3419  return;
3420  }
3421 
3422  // we want to shoot
3423  Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, true, 0);
3424  spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
3425 
3426  // all went good, reset attack
3428  }
3429 }
void setAttackTimer(WeaponAttackType type, uint32 time)
Definition: Unit.h:943
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false) const
Definition: Unit.cpp:3547
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2079
void prepare(SpellCastTargets *targets, Aura *triggeredByAura=NULL)
Definition: Spell.cpp:2222
bool m_AutoRepeatFirstCast
Definition: Unit.h:2010
bool isMoving() const
Definition: Unit.h:1332
uint8 GetTypeId() const
Definition: Object.h:210
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:3507
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:952
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:632
uint32 getAttackTimer(WeaponAttackType type) const
Definition: Unit.h:948
Definition: Spell.h:249
void Unit::_UpdateSpells ( uint32  time)
protected

Definition at line 3343 of file Unit.cpp.

References _DeleteAuras(), _UpdateAutoRepeatSpell(), AURA_REMOVE_BY_EXPIRE, CURRENT_AUTOREPEAT_SPELL, CURRENT_MAX_SPELL, m_Auras, m_AurasUpdateIterator, m_currentSpells, m_gameObj, RemoveAura(), Spell::SetReferencedFromCurrent(), SPELL_STATE_FINISHED, and Aura::Update().

Referenced by Update().

3344 {
3347 
3348  // remove finished spells from current pointers
3349  for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
3350  {
3351  if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
3352  {
3354  m_currentSpells[i] = NULL; // remove pointer
3355  }
3356  }
3357 
3358  // m_AurasUpdateIterator can be updated in inderect called code at aura remove to skip next planned to update but removed auras
3359  for (m_AurasUpdateIterator = m_Auras.begin(); m_AurasUpdateIterator != m_Auras.end();)
3360  {
3361  Aura* i_aura = m_AurasUpdateIterator->second;
3362  ++m_AurasUpdateIterator; // need shift to next for allow update if need into aura update
3363  i_aura->Update(time);
3364  }
3365 
3366  // remove expired auras
3367  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
3368  {
3369  if (i->second->IsExpired())
3371  else
3372  ++i;
3373  }
3374 
3375  _DeleteAuras();
3376 
3377  if (!m_gameObj.empty())
3378  {
3379  std::list<GameObject*>::iterator itr;
3380  for (itr = m_gameObj.begin(); itr != m_gameObj.end();)
3381  {
3382  if (!(*itr)->isSpawned())
3383  {
3384  (*itr)->SetOwnerGUID(0);
3385  (*itr)->SetRespawnTime(0);
3386  (*itr)->Delete();
3387  m_gameObj.erase(itr++);
3388  }
3389  else
3390  ++itr;
3391  }
3392  }
3393 }
void _UpdateAutoRepeatSpell()
Definition: Unit.cpp:3395
virtual void Update(uint32 diff)
Definition: SpellAuras.cpp:529
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2079
void _DeleteAuras()
Definition: Unit.cpp:3334
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4444
std::list< GameObject * > m_gameObj
Definition: Unit.h:2031
#define CURRENT_MAX_SPELL
Definition: Unit.h:744
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:482
AuraMap::iterator m_AurasUpdateIterator
Definition: Unit.h:2025
ACE_UINT32 uint32
Definition: Define.h:71
AuraMap m_Auras
Definition: Unit.h:2024
void Unit::AddAssistThreat ( Unit victim,
float  threatToAdd,
SpellEntry const *  threatSpell 
)

Definition at line 10217 of file Unit.cpp.

References CanHaveThreatList(), getHostileRefManager(), and HostileRefManager::threatAssist().

Referenced by Spell::HandleThreatSpells().

10218 {
10219  // Only mobs can manage threat lists
10220  if (CanHaveThreatList())
10221  getHostileRefManager().threatAssist(victim, threatToAdd, threatSpell);
10222 }
HostileRefManager & getHostileRefManager()
Definition: Unit.h:1733
bool CanHaveThreatList() const
Definition: Unit.cpp:10169
void threatAssist(Unit *victim, float baseThreat, SpellEntry const *threatSpell=NULL)
void Unit::AddAura ( uint32  spellId,
Unit target 
)

Definition at line 13463 of file Unit.cpp.

References AddAura(), SpellEntry::AttributesEx, SpellEntry::AttributesEx2, CreateAura(), SpellEntry::Effect, SpellEntry::EffectImplicitTargetA, IsAlive(), IsImmuneToSpell(), IsImmuneToSpellEffect(), MAX_SPELL_EFFECTS, SPELL_ATTR0_PASSIVE, SPELL_ATTR2_CAN_TARGET_DEAD, SPELL_EFFECT_APPLY_AURA, sSpellStore, and TARGET_UNIT_CASTER.

Referenced by Pet::_LoadAuras(), Player::_LoadAuras(), AddAura(), Battleground::AddPlayerToResurrectQueue(), Spell::EffectApplyAura(), ChatHandler::HandleAuraCommand(), ChatHandler::HandleFreezeCommand(), WorldSession::HandlePlayerLogin(), ChatHandler::HandleVisibleCommand(), Creature::LoadCreaturesAddon(), and RemoveAurasDueToSpellBySteal().

13464 {
13465  if (!target)
13466  return;
13467 
13468  SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
13469  if (!spellInfo)
13470  return;
13471 
13472  if (!target->IsAlive() && !(spellInfo->AttributesEx & SPELL_ATTR0_PASSIVE) && !(spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_DEAD))
13473  return;
13474 
13475  if (target->IsImmuneToSpell(spellInfo))
13476  return;
13477 
13478  for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
13479  {
13480  if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA)
13481  {
13482  if (target->IsImmuneToSpellEffect(spellInfo, i, false))
13483  continue;
13484 
13485  if (spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER)
13486  {
13487  Aura* Aur = CreateAura(spellInfo, i, NULL, this, this);
13488  AddAura(Aur);
13489  }
13490  else
13491  {
13492  Aura* Aur = CreateAura(spellInfo, i, NULL, target, this);
13493  target->AddAura(Aur);
13494  }
13495  }
13496  }
13497 }
uint32 AttributesEx
Definition: DBCStructure.h:680
virtual bool IsImmuneToSpell(SpellEntry const *spellInfo, bool useCharges=false)
Definition: Unit.cpp:8944
uint32 AttributesEx2
Definition: DBCStructure.h:681
uint32 Effect[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:724
void AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:13463
Aura * CreateAura(SpellEntry const *spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item *castItem)
Definition: SpellAuras.cpp:502
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
bool IsAlive() const
Definition: Unit.h:1336
uint32 EffectImplicitTargetA[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:731
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:670
ACE_UINT32 uint32
Definition: Define.h:71
virtual bool IsImmuneToSpellEffect(SpellEntry const *spellInfo, uint32 index, bool castOnSelf) const
Definition: Unit.cpp:9007
bool Unit::AddAura ( Aura aur)

Definition at line 3841 of file Unit.cpp.

References Aura::_AddAura(), AddInterruptMask(), Aura::ApplyModifier(), ApplySpellImmune(), ASSERT, SpellEntry::Attributes, AURA_REMOVE_BY_STACK, SpellEntry::AuraInterruptFlags, DEBUG_LOG, Aura::GetAuraMaxDuration(), Aura::GetCaster(), Aura::GetCasterGUID(), Aura::GetCastItemGUID(), Aura::GetEffIndex(), Object::GetGUIDLow(), Aura::GetId(), Aura::GetModifier(), Player::GetSession(), GetSingleCastAuras(), Aura::GetSpellProto(), Aura::GetStackAmount(), Aura::GetTarget(), Object::GetTypeId(), IMMUNITY_ID, IsAlive(), Aura::IsPassive(), IsPassiveStackableSpell(), Aura::IsPersistent(), Aura::IsSingleTarget(), IsSingleTargetSpells(), Modifier::m_auraname, m_Auras, m_ccAuras, m_interruptableAuras, m_modAuras, Aura::m_procCharges, WorldSession::PlayerLoading(), RemoveAura(), RemoveNoStackAurasDueToAura(), Aura::SetAuraDuration(), Aura::SetAuraProcCharges(), Aura::SetStackAmount(), sLog, SPELL_ATTR0_HEARTBEAT_RESIST_CHECK, SPELL_ATTR_CU_LINK_AURA, SPELL_AURA_MOD_POSSESS, SPELL_LINK_AURA, sSpellMgr, SpellEntry::StackAmount, Object::ToPlayer(), TOTAL_AURAS, TYPEID_PLAYER, Aura::UpdateAuraCharges(), and Aura::UpdateAuraDuration().

3842 {
3843  // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load)
3844  if (!IsAlive() && Aur->GetId() != 20584 && Aur->GetId() != 8326 && Aur->GetId() != 2584 &&
3846  {
3847  delete Aur;
3848  return false;
3849  }
3850 
3851  if (Aur->GetTarget() != this)
3852  {
3853  sLog.outError("Aura (spell %u eff %u) add to aura list of %s (lowguid: %u) but Aura target is %s (lowguid: %u)",
3854  Aur->GetId(), Aur->GetEffIndex(), (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(),
3855  (Aur->GetTarget()->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), Aur->GetTarget()->GetGUIDLow());
3856  delete Aur;
3857  return false;
3858  }
3859 
3860  SpellEntry const* aurSpellInfo = Aur->GetSpellProto();
3861 
3862  spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex());
3863  bool stackModified = false;
3864 
3865  // Handle aura stacking down below...
3866  if (!Aur->IsPassive() && !Aur->IsPersistent())
3867  {
3868  for (AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair);)
3869  {
3870  Aura* aur2 = i2->second;
3871 
3872  if (aur2 && !stackModified)
3873  {
3874  ASSERT(aur2->GetId() == Aur->GetId());
3875 
3876  // @todo: fix this hack
3877  // Allow mongoose proc from different weapons... this should be corrected to allow multiple
3878  // auras triggered by different enchanted items this is not possible currently since we only have
3879  // GUID and not even information if the Aura was "triggered" see m_IsTriggeredSpell in Spell.h
3880  if (Aur->GetCastItemGUID() && Aur->GetId() == 28093)
3881  {
3882  bool allow = true;
3883 
3884  for (AuraMap::const_iterator i3 = m_Auras.lower_bound(spair); i3 != m_Auras.upper_bound(spair); i3++)
3885  if (i3->second->GetCastItemGUID() == Aur->GetCastItemGUID())
3886  allow = false;
3887 
3888  if (allow)
3889  break;
3890  }
3891 
3892  if (sSpellMgr.IsNoStackSpellDueToSpell(Aur->GetId(), aur2->GetId(), Aur->GetCasterGUID() == aur2->GetCasterGUID()))
3893  {
3894  // Non stackable and capped auras do not allow stacking
3895  if (!(aurSpellInfo->StackAmount && uint32(aur2->GetStackAmount()) < aurSpellInfo->StackAmount))
3896  {
3897  // Do not let the stack size exceed the maximum stack limit
3898  // Instead of adding a new stack, just set the duration time
3899  // we need to use time from Aur because of diminishing effects
3900  aur2->SetAuraDuration(Aur->GetAuraMaxDuration());
3901  aur2->SetAuraProcCharges(Aur->m_procCharges);
3902  aur2->UpdateAuraDuration();
3903  aur2->UpdateAuraCharges();
3904  *aur2->GetModifier() = *Aur->GetModifier();
3905  delete Aur;
3906  return true;
3907  }
3908 
3909  // Increment aura's stack, one stack per one call
3910  Aur->SetStackAmount(aur2->GetStackAmount() + 1);
3911  stackModified = true;
3912 
3913  // Existing aura will be replaced with the newly created one
3915  i2 = m_Auras.lower_bound(spair);
3916  continue;
3917  }
3918  }
3919 
3920  ++i2;
3921  }
3922  }
3923 
3924  // passive auras stack with all (except passive spell proc auras)
3925  if ((!Aur->IsPassive() || !IsPassiveStackableSpell(Aur->GetId())) &&
3926  !(Aur->GetId() == 20584 || Aur->GetId() == 8326))
3927  {
3928  if (!RemoveNoStackAurasDueToAura(Aur))
3929  {
3930  delete Aur;
3931  return false; // couldn't remove conflicting aura with higher rank
3932  }
3933  }
3934 
3935  // update single target auras list (before aura add to aura list, to prevent unexpected remove recently added aura)
3936  if (Aur->IsSingleTarget() && Aur->GetTarget())
3937  {
3938  // caster pointer can be deleted in time aura remove, find it by guid at each iteration
3939  for (;;)
3940  {
3941  Unit* caster = Aur->GetCaster();
3942  if (!caster) // caster deleted and not required adding scAura
3943  break;
3944 
3945  bool restart = false;
3946  AuraList& scAuras = caster->GetSingleCastAuras();
3947  for (AuraList::iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr)
3948  {
3949  if ((*itr)->GetTarget() != Aur->GetTarget() &&
3950  IsSingleTargetSpells((*itr)->GetSpellProto(), aurSpellInfo))
3951  {
3952  if ((*itr)->IsInUse())
3953  {
3954  sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for IsSingleTargetSpell", (*itr)->GetId(), (*itr)->GetEffIndex(), Aur->GetId(), Aur->GetEffIndex());
3955  continue;
3956  }
3957  (*itr)->GetTarget()->RemoveAura((*itr)->GetId(), (*itr)->GetEffIndex());
3958  restart = true;
3959  break;
3960  }
3961  }
3962 
3963  if (!restart)
3964  {
3965  // done
3966  scAuras.push_back(Aur);
3967  break;
3968  }
3969  }
3970  }
3971 
3972  // add aura, register in lists and arrays
3973  Aur->_AddAura();
3974  m_Auras.insert(AuraMap::value_type(spellEffectPair(Aur->GetId(), Aur->GetEffIndex()), Aur));
3975  if (Aur->GetModifier()->m_auraname < TOTAL_AURAS)
3976  {
3977  m_modAuras[Aur->GetModifier()->m_auraname].push_back(Aur);
3978  if (Aur->GetSpellProto()->AuraInterruptFlags)
3979  {
3980  m_interruptableAuras.push_back(Aur);
3981  AddInterruptMask(Aur->GetSpellProto()->AuraInterruptFlags);
3982  }
3983  if ((Aur->GetSpellProto()->Attributes & SPELL_ATTR0_HEARTBEAT_RESIST_CHECK)
3984  && (Aur->GetModifier()->m_auraname != SPELL_AURA_MOD_POSSESS)) //only dummy aura is breakable
3985  m_ccAuras.push_back(Aur);
3986  }
3987 
3988  Aur->ApplyModifier(true, true);
3989 
3990  uint32 id = Aur->GetId();
3991  if (sSpellMgr.GetSpellCustomAttr(id) & SPELL_ATTR_CU_LINK_AURA)
3992  {
3993  if (const std::vector<int32>* spell_triggered = sSpellMgr.GetSpellLinked(id + SPELL_LINK_AURA))
3994  {
3995  for (std::vector<int32>::const_iterator itr = spell_triggered->begin(); itr != spell_triggered->end(); ++itr)
3996  if (*itr < 0)
3997  ApplySpellImmune(id, IMMUNITY_ID, -(*itr), true);
3998  else if (Unit* caster = Aur->GetCaster())
3999  caster->AddAura(*itr, this);
4000  }
4001  }
4002 
4003  DEBUG_LOG("Aura %u now is in use", Aur->GetModifier()->m_auraname);
4004  return true;
4005 }
bool IsPassiveStackableSpell(uint32 spellId)
Definition: Unit.cpp:138
bool RemoveNoStackAurasDueToAura(Aura *Aur)
Definition: Unit.cpp:4033
bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellInfo2)
Definition: SpellMgr.cpp:807
AuraList m_ccAuras
Definition: Unit.h:2039
std::pair< uint32, uint8 > spellEffectPair
Definition: Unit.h:915
void SetAuraDuration(int32 duration)
Definition: SpellAuras.h:279
#define sLog
Log class singleton.
Definition: Log.h:187
std::list< Aura * > AuraList
Definition: Unit.h:917
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition: Unit.cpp:9209
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4444
uint32 GetGUIDLow() const
Definition: Object.h:166
void AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:13463
void SetAuraProcCharges(int32 charges)
Definition: SpellAuras.h:418
Player * ToPlayer()
Definition: Object.h:392
AuraList m_interruptableAuras
Definition: Unit.h:2038
uint8 GetTypeId() const
Definition: Object.h:210
bool IsAlive() const
Definition: Unit.h:1336
void UpdateAuraDuration()
Definition: SpellAuras.cpp:810
uint32 StackAmount
Definition: DBCStructure.h:717
#define sSpellMgr
Definition: SpellMgr.h:1239
Modifier * GetModifier()
Definition: SpellAuras.h:221
#define DEBUG_LOG(...)
Definition: Log.h:194
AuraList & GetSingleCastAuras()
Definition: Unit.h:1701
uint64 const & GetCasterGUID() const
Definition: SpellAuras.h:304
AuraList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2036
int32 GetStackAmount()
Definition: SpellAuras.h:443
#define ASSERT
Definition: Errors.h:29
WorldSession * GetSession() const
Definition: Player.h:1944
ACE_UINT32 uint32
Definition: Define.h:71
void AddInterruptMask(uint32 mask)
Definition: Unit.h:1776
Definition: Unit.h:908
bool PlayerLoading() const
Definition: WorldSession.h:73
AuraMap m_Auras
Definition: Unit.h:2024
void UpdateAuraCharges()
Definition: SpellAuras.h:335
uint32 GetId() const
Definition: SpellAuras.h:250
void Unit::AddComboPointHolder ( uint32  lowguid)
inline

Definition at line 1917 of file Unit.h.

Referenced by Player::AddComboPoints().

1918  {
1919  m_ComboPointHolders.insert(lowguid);
1920  }
ComboPointHolderSet m_ComboPointHolders
Definition: Unit.h:2091
void Unit::AddDynObject ( DynamicObject dynObj)

Definition at line 4649 of file Unit.cpp.

References Object::GetGUID(), and m_dynObjGUIDs.

Referenced by Spell::EffectAddFarsight(), and Spell::EffectPersistentAA().

4650 {
4651  m_dynObjGUIDs.push_back(dynObj->GetGUID());
4652 }
DynObjectGUIDs m_dynObjGUIDs
Definition: Unit.h:2029
const uint64 & GetGUID() const
Definition: Object.h:162
void Unit::addFollower ( FollowerReference pRef)
inline

Definition at line 1878 of file Unit.h.

Referenced by FollowerReference::targetObjectBuildLink().

1879  {
1881  }
FollowerRefManager m_FollowingRefManager
Definition: Unit.h:2089
void insertFirst(LinkedListElement *pElem)
Definition: LinkedList.h:105
void Unit::AddGameObject ( GameObject gameObj)

Definition at line 4720 of file Unit.cpp.

References Object::GetGUID(), GameObject::GetOwnerGUID(), m_gameObj, and GameObject::SetOwnerGUID().

Referenced by Spell::EffectDuel(), Spell::EffectSummonObject(), and Spell::EffectTransmitted().

4721 {
4722  if (!gameObj || gameObj->GetOwnerGUID() != 0)
4723  return;
4724 
4725  m_gameObj.push_back(gameObj);
4726  gameObj->SetOwnerGUID(GetGUID());
4727 }
uint64 GetOwnerGUID() const
Definition: GameObject.h:664
std::list< GameObject * > m_gameObj
Definition: Unit.h:2031
void SetOwnerGUID(uint64 owner)
Definition: GameObject.h:656
const uint64 & GetGUID() const
Definition: Object.h:162
void Unit::addHatedBy ( HostileReference pHostileReference)
inline

Definition at line 1725 of file Unit.h.

1726  {
1727  m_HostileRefManager.insertFirst(pHostileReference);
1728  };
HostileRefManager m_HostileRefManager
Definition: Unit.h:2087
void insertFirst(LinkedListElement *pElem)
Definition: LinkedList.h:105
void Unit::AddInterruptMask ( uint32  mask)
inline

Definition at line 1776 of file Unit.h.

Referenced by AddAura(), and Spell::handle_immediate().

1777  {
1778  m_interruptMask |= mask;
1779  }
uint32 m_interruptMask
Definition: Unit.h:2040
void Unit::AddPetAura ( PetAura const *  petSpell)

Definition at line 12328 of file Unit.cpp.

References TYPEID_PLAYER.

Referenced by Spell::EffectDummy(), and Aura::HandleAuraDummy().

12329 {
12330  if (GetTypeId() != TYPEID_PLAYER)
12331  return;
12332 
12333  m_petAuras.insert(petSpell);
12334  if (Pet* pet = ToPlayer()->GetPet())
12335  pet->CastPetAura(petSpell);
12336 }
Player * ToPlayer()
Definition: Object.h:392
uint8 GetTypeId() const
Definition: Object.h:210
PetAuraSet m_petAuras
Definition: Unit.h:1954
Definition: Pet.h:146
void Unit::AddPlayerToVision ( Player plr)

Definition at line 7934 of file Unit.cpp.

References m_sharedVision, WorldObject::setActive(), and WorldObject::SetWorldObject().

7935 {
7936  if (m_sharedVision.empty())
7937  {
7938  setActive(true);
7939  SetWorldObject(true);
7940  }
7941  m_sharedVision.push_back(plr);
7942 }
void setActive(bool isActiveObject)
Definition: Object.cpp:1123
SharedVisionList m_sharedVision
Definition: Unit.h:2051
void SetWorldObject(bool apply)
Definition: Object.cpp:1104
void Unit::AddThreat ( Unit victim,
float  threat,
SpellSchoolMask  schoolMask = SPELL_SCHOOL_MASK_NORMAL,
SpellEntry const *  threatSpell = NULL 
)

Definition at line 10208 of file Unit.cpp.

References ThreatManager::addThreat(), CanHaveThreatList(), HasUnitState(), m_ThreatManager, and UNIT_STATE_EVADE.

Referenced by FollowerAI::AssistPlayerInCombat(), npc_escortAI::AssistPlayerInCombat(), SmartAI::AssistPlayerInCombat(), Attack(), FollowerAI::AttackStart(), DealDamage(), CreatureAI::DoZoneInCombat(), CreatureAI::DoZoneInCombatWithPlayers(), Spell::EffectThreat(), Aura::HandleAuraDummy(), Spell::HandleThreatSpells(), FollowerAI::MoveInLineOfSight(), npc_escortAI::MoveInLineOfSight(), Aura::PeriodicTick(), Creature::SetInCombatWithZone(), and Creature::Update().

10209 {
10210  // Only mobs can manage threat lists
10212  m_ThreatManager.addThreat(victim, fThreat, schoolMask, threatSpell);
10213 }
ThreatManager m_ThreatManager
Definition: Unit.h:2061
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
bool CanHaveThreatList() const
Definition: Unit.cpp:10169
void addThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell=NULL)
void Unit::AddToWorld ( )
overridevirtual

Reimplemented from Object.

Definition at line 11129 of file Unit.cpp.

References Object::AddToWorld(), and Object::IsInWorld().

Referenced by Pet::AddToWorld(), Creature::AddToWorld(), and Player::AddToWorld().

11130 {
11131  if (!IsInWorld())
11133 }
const bool & IsInWorld() const
Definition: Object.h:135
virtual void AddToWorld()
Definition: Object.h:139
void Unit::AddUnitMovementFlag ( uint32  f)
inline

Definition at line 1901 of file Unit.h.

Referenced by MotionMaster::MoveFall(), and Player::TeleportTo().

1901 { m_movementInfo.moveFlags |= f; }
MovementInfo m_movementInfo
Definition: Object.h:927
uint32 moveFlags
Definition: Object.h:455
void Unit::AddUnitTypeMask ( uint32  mask)
inline

Definition at line 1045 of file Unit.h.

1045 { m_unitTypeMask |= mask; }
uint32 m_unitTypeMask
Definition: Unit.h:2049
void Unit::ApplyAttackTimePercentMod ( WeaponAttackType  att,
float  val,
bool  apply 
)

Definition at line 12123 of file Unit.cpp.

References ApplyPercentModFloatVar(), and UNIT_FIELD_BASEATTACKTIME.

Referenced by Player::ApplyRatingMod(), Aura::HandleAuraModRangedHaste(), Aura::HandleHaste(), Aura::HandleModAttackSpeed(), Aura::HandleModCombatSpeedPct(), Aura::HandleModMeleeRangedSpeedPct(), and Aura::HandleRangedAmmoHaste().

12124 {
12125  float remainingTimePct = (float)m_attackTimer[att] / (GetAttackTime(att) * m_modAttackSpeedPct[att]);
12126  if (val > 0)
12127  {
12130  }
12131  else
12132  {
12135  }
12136  m_attackTimer[att] = uint32(GetAttackTime(att) * m_modAttackSpeedPct[att] * remainingTimePct);
12137 }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:969
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.h:1104
float m_modAttackSpeedPct[3]
Definition: Unit.h:1631
void ApplyPercentModFloatVar(float &var, float val, bool apply)
Definition: Util.h:88
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2015
ACE_UINT32 uint32
Definition: Define.h:71
void Unit::ApplyAuraProcTriggerDamage ( Aura aura,
bool  apply 
)

Definition at line 11102 of file Unit.cpp.

References m_modAuras, and SPELL_AURA_PROC_TRIGGER_DAMAGE.

11103 {
11104  AuraList& tAuraProcTriggerDamage = m_modAuras[SPELL_AURA_PROC_TRIGGER_DAMAGE];
11105  if (apply)
11106  tAuraProcTriggerDamage.push_back(aura);
11107  else
11108  tAuraProcTriggerDamage.remove(aura);
11109 }
std::list< Aura * > AuraList
Definition: Unit.h:917
void apply(T *val)
Definition: ByteConverter.h:41
AuraList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2036
void Unit::ApplyCastTimePercentMod ( float  val,
bool  apply 
)

Definition at line 12139 of file Unit.cpp.

References UNIT_MOD_CAST_SPEED.

Referenced by Player::ApplyRatingMod(), Aura::HandleModCastingSpeed(), and Aura::HandleModCombatSpeedPct().

12140 {
12141  if (val > 0)
12143  else
12145 }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:969
void Unit::ApplyDiminishingAura ( DiminishingGroup  group,
bool  apply 
)

Definition at line 10641 of file Unit.cpp.

References getMSTime(), and m_Diminishing.

Referenced by Aura::_AddAura(), and Aura::_RemoveAura().

10642 {
10643  // Checking for existing in the table
10644  for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
10645  {
10646  if (i->DRGroup != group)
10647  continue;
10648 
10649  i->hitTime = getMSTime();
10650 
10651  if (apply)
10652  i->stack += 1;
10653  else if (i->stack)
10654  i->stack -= 1;
10655 
10656  break;
10657  }
10658 }
uint32 getMSTime()
Definition: Timer.h:32
Diminishing m_Diminishing
Definition: Unit.h:2083
void apply(T *val)
Definition: ByteConverter.h:41
void Unit::ApplyDiminishingToDuration ( DiminishingGroup  group,
int32 duration,
Unit caster,
DiminishingLevels  Level 
)

Definition at line 10590 of file Unit.cpp.

References DIMINISHING_LEVEL_1, DIMINISHING_LEVEL_2, DIMINISHING_LEVEL_3, DIMINISHING_LEVEL_IMMUNE, DIMINISHING_NONE, DRTYPE_ALL, DRTYPE_PLAYER, GetCharmerOrOwner(), GetDiminishingReturnsGroupType(), GetOwner(), Object::GetTypeId(), IsDiminishingReturnsGroupDurationLimited(), TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by Spell::EffectApplyAura(), and Spell::handle_immediate().

10591 {
10592  if (duration == -1 || group == DIMINISHING_NONE)
10593  return;
10594 
10595  // Creatures other then pets do not suffer from Diminishing Returns
10596  if (caster->GetTypeId() == TYPEID_UNIT && !caster->GetOwner())
10597  return;
10598 
10599  // Test pet/charm masters instead pets/charmedsz
10600  Unit const* targetOwner = GetCharmerOrOwner();
10601  Unit const* casterOwner = caster->GetCharmerOrOwner();
10602 
10603  // Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0)
10604  if (duration > 10000 && IsDiminishingReturnsGroupDurationLimited(group))
10605  {
10606  Unit const* target = targetOwner ? targetOwner : this;
10607  Unit const* source = casterOwner ? casterOwner : caster;
10608 
10609  if (target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER)
10610  if (source != target || GetTypeId() != TYPEID_UNIT)
10611  duration = 10000;
10612  }
10613 
10614  float mod = 1.0f;
10615 
10616  // Some diminishings applies to mobs too (for example, Stun)
10617  if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && (targetOwner ? targetOwner->GetTypeId() : GetTypeId()) == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL)
10618  {
10619  DiminishingLevels diminish = Level;
10620  switch (diminish)
10621  {
10622  case DIMINISHING_LEVEL_1:
10623  break;
10624  case DIMINISHING_LEVEL_2:
10625  mod = 0.5f;
10626  break;
10627  case DIMINISHING_LEVEL_3:
10628  mod = 0.25f;
10629  break;
10631  mod = 0.0f;
10632  break;
10633  default:
10634  break;
10635  }
10636  }
10637 
10638  duration = int32(duration * mod);
10639 }
bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group)
Definition: SpellMgr.cpp:3180
DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group)
Definition: SpellMgr.cpp:3205
ACE_INT32 int32
Definition: Define.h:67
uint8 GetTypeId() const
Definition: Object.h:210
DiminishingLevels
Definition: Unit.h:643
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1410
Unit * GetOwner() const
Definition: Unit.cpp:7625
Definition: Unit.h:908
void Unit::ApplyMaxPowerMod ( Powers  power,
uint32  val,
bool  apply 
)

Definition at line 11080 of file Unit.cpp.

References Object::ApplyModUInt32Value(), Player::GetGroup(), GetOwner(), Object::GetTypeId(), GROUP_UPDATE_FLAG_MAX_POWER, GROUP_UPDATE_FLAG_PET_MAX_POWER, Pet::isControlled(), IsPet(), Player::SetGroupUpdateFlag(), Object::ToPlayer(), TYPEID_PLAYER, and UNIT_FIELD_MAXPOWER1.

11081 {
11083 
11084  // group update
11085  if (GetTypeId() == TYPEID_PLAYER)
11086  {
11087  if (ToPlayer()->GetGroup())
11089  }
11090  else if (IsPet())
11091  {
11092  Pet* pet = ((Pet*)this);
11093  if (pet->isControlled())
11094  {
11095  Unit* owner = GetOwner();
11096  if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
11098  }
11099  }
11100 }
Group * GetGroup()
Definition: Player.h:2577
void ApplyModUInt32Value(uint16 index, int32 val, bool apply)
Definition: Object.cpp:946
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:392
uint8 GetTypeId() const
Definition: Object.h:210
bool isControlled() const
Definition: Pet.h:163
bool IsPet() const
Definition: Unit.h:1048
Unit * GetOwner() const
Definition: Unit.cpp:7625
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2598
Definition: Unit.h:908
Definition: Pet.h:146
void Unit::ApplyPowerMod ( Powers  power,
uint32  val,
bool  apply 
)

Definition at line 11058 of file Unit.cpp.

References Object::ApplyModUInt32Value(), Player::GetGroup(), GetOwner(), Object::GetTypeId(), GROUP_UPDATE_FLAG_CUR_POWER, GROUP_UPDATE_FLAG_PET_CUR_POWER, Pet::isControlled(), IsPet(), Player::SetGroupUpdateFlag(), Object::ToPlayer(), TYPEID_PLAYER, and UNIT_FIELD_POWER1.

Referenced by CalcAbsorbResist().

11059 {
11061 
11062  // group update
11063  if (GetTypeId() == TYPEID_PLAYER)
11064  {
11065  if (ToPlayer()->GetGroup())
11067  }
11068  else if (IsPet())
11069  {
11070  Pet* pet = ((Pet*)this);
11071  if (pet->isControlled())
11072  {
11073  Unit* owner = GetOwner();
11074  if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
11076  }
11077  }
11078 }
Group * GetGroup()
Definition: Player.h:2577
void ApplyModUInt32Value(uint16 index, int32 val, bool apply)
Definition: Object.cpp:946
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:392
uint8 GetTypeId() const
Definition: Object.h:210
bool isControlled() const
Definition: Pet.h:163
bool IsPet() const
Definition: Unit.h:1048
Unit * GetOwner() const
Definition: Unit.cpp:7625
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2598
Definition: Unit.h:908
Definition: Pet.h:146
void Unit::ApplyResistanceBuffModsMod ( SpellSchools  school,
bool  positive,
float  val,
bool  apply 
)
inline
void Unit::ApplyResistanceBuffModsPercentMod ( SpellSchools  school,
bool  positive,
float  val,
bool  apply 
)
inline
void Unit::ApplySpellDispelImmunity ( const SpellEntry spellProto,
DispelType  type,
bool  apply 
)

Definition at line 9241 of file Unit.cpp.

References ApplySpellImmune(), SpellEntry::AttributesEx, SpellEntry::Id, IMMUNITY_DISPEL, RemoveAurasWithDispelType(), and SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY.

Referenced by Aura::HandleAuraModDispelImmunity().

9242 {
9243  ApplySpellImmune(spellProto->Id, IMMUNITY_DISPEL, type, apply);
9244 
9247 }
uint32 AttributesEx
Definition: DBCStructure.h:680
void RemoveAurasWithDispelType(DispelType type)
Definition: Unit.cpp:4307
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition: Unit.cpp:9209
void apply(T *val)
Definition: ByteConverter.h:41
void Unit::ApplySpellImmune ( uint32  spellId,
uint32  op,
uint32  type,
bool  apply 
)

Definition at line 9209 of file Unit.cpp.

References m_spellImmune, SpellImmune::spellId, and SpellImmune::type.

Referenced by AddAura(), ApplySpellDispelImmunity(), Aura::HandleAuraModDispelImmunity(), Aura::HandleAuraModDmgImmunity(), Aura::HandleAuraModEffectImmunity(), Aura::HandleAuraModIncreaseFlightSpeed(), Aura::HandleAuraModSchoolImmunity(), Aura::HandleAuraModStateImmunity(), Aura::HandleModMechanicImmunity(), Aura::HandlePreventFleeing(), Guardian::InitStatsForLevel(), RemoveAura(), and Creature::UpdateEntry().

9210 {
9211  if (apply)
9212  {
9213  for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next)
9214  {
9215  next = itr; ++next;
9216  if (itr->type == type)
9217  {
9218  m_spellImmune[op].erase(itr);
9219  next = m_spellImmune[op].begin();
9220  }
9221  }
9222  SpellImmune Immune;
9223  Immune.spellId = spellId;
9224  Immune.type = type;
9225  m_spellImmune[op].push_back(Immune);
9226  }
9227  else
9228  {
9229  for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr)
9230  {
9231  if (itr->spellId == spellId && itr->type == type)
9232  {
9233  m_spellImmune[op].erase(itr);
9234  break;
9235  }
9236  }
9237  }
9238 
9239 }
uint32 spellId
Definition: Unit.h:346
void apply(T *val)
Definition: ByteConverter.h:41
uint32 type
Definition: Unit.h:345
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1710
void Unit::ApplyStatBuffMod ( Stats  stat,
float  val,
bool  apply 
)
inline

Definition at line 1533 of file Unit.h.

References UNIT_FIELD_NEGSTAT0, and UNIT_FIELD_POSSTAT0.

Referenced by Player::_ApplyItemBonuses(), Player::ApplyEnchantment(), and Aura::HandleAuraModStat().

1534  {
1535  ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0 + stat : UNIT_FIELD_NEGSTAT0 + stat), val, apply);
1536  }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyModSignedFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:962
void Unit::ApplyStatPercentBuffMod ( Stats  stat,
float  val,
bool  apply 
)
inline

Definition at line 1537 of file Unit.h.

References UNIT_FIELD_NEGSTAT0, and UNIT_FIELD_POSSTAT0.

Referenced by Aura::HandleModTotalPercentStat().

1538  {
1541  }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:969
float Unit::ApplyTotalThreatModifier ( float  threat,
SpellSchoolMask  schoolMask = SPELL_SCHOOL_MASK_NORMAL 
)

Definition at line 10196 of file Unit.cpp.

References GetFirstSchoolInMask(), HasAuraType(), m_threatModifier, and SPELL_AURA_MOD_THREAT.

Referenced by ThreatCalcHelper::calcThreat().

10197 {
10198  if (!HasAuraType(SPELL_AURA_MOD_THREAT) || fThreat < 0)
10199  return fThreat;
10200 
10201  SpellSchools school = GetFirstSchoolInMask(schoolMask);
10202 
10203  return fThreat * m_threatModifier[school];
10204 }
SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask)
SpellSchools
float m_threatModifier[MAX_SPELL_SCHOOL]
Definition: Unit.h:1630
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:832
bool Unit::Attack ( Unit victim,
bool  meleeAttack 
)

Definition at line 7390 of file Unit.cpp.

References _addAttacker(), AddThreat(), AddUnitState(), Creature::AI(), AI_REACTION_HOSTILE, AttackStop(), Creature::CallAssistance(), Object::GetGUID(), Player::GetPet(), Object::GetTypeId(), HasAuraType(), Object::HasFlag(), HasUnitState(), haveOffhandWeapon(), IsAlive(), Player::IsGameMaster(), Creature::IsInEvadeMode(), Object::IsInWorld(), IsMounted(), IsPet(), m_attacking, OFF_ATTACK, CreatureAI::OwnerAttacked(), RemoveSpellsCausingAura(), resetAttackTimer(), Creature::SendAIReaction(), SendMeleeAttackStart(), SetInCombatWith(), SetTarget(), SPELL_AURA_MOD_UNATTACKABLE, Object::ToCreature(), Object::ToPlayer(), TYPEID_PLAYER, UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED, and UNIT_STATE_MELEE_ATTACKING.

Referenced by FollowerAI::AttackStart(), PossessedAI::AttackStart(), UnitAI::AttackStart(), npc_escortAI::AttackStart(), SmartAI::AttackStart(), Scripted_NoMovementAI::AttackStart(), CreatureEventAI::AttackStart(), UnitAI::AttackStartCaster(), ScriptedAI::AttackStartNoMove(), DealDamage(), PetAI::DoAttack(), Spell::EffectCharge(), WorldSession::HandleAttackSwingOpcode(), WorldSession::HandlePetActionHelper(), and Player::UpdateCharmedAI().

7391 {
7392  if (!victim || victim == this)
7393  return false;
7394 
7395  // dead units can neither attack nor be attacked
7396  if (!IsAlive() || !victim->IsInWorld() || !victim->IsAlive())
7397  return false;
7398 
7399  // player cannot attack in mount state
7400  if (GetTypeId() == TYPEID_PLAYER && IsMounted())
7401  return false;
7402 
7403  Creature* creature = ToCreature();
7404  // creatures cannot attack while evading
7405  if (creature && creature->IsInEvadeMode())
7406  return false;
7407 
7409  return false;
7410 
7411  // nobody can attack GM in GM-mode
7412  if (victim->GetTypeId() == TYPEID_PLAYER)
7413  {
7414  if (victim->ToPlayer()->IsGameMaster())
7415  return false;
7416  }
7417  else
7418  {
7419  if (victim->ToCreature()->IsInEvadeMode())
7420  return false;
7421  }
7422 
7423  // remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack)
7426 
7427  if (m_attacking)
7428  {
7429  if (m_attacking == victim)
7430  {
7431  // switch to melee attack from ranged/magic
7432  if (meleeAttack && !HasUnitState(UNIT_STATE_MELEE_ATTACKING))
7433  {
7435  SendMeleeAttackStart(victim);
7436  return true;
7437  }
7438  return false;
7439  }
7440  AttackStop();
7441  }
7442 
7443  // Set our target
7444  SetTarget(victim->GetGUID());
7445 
7446  if (meleeAttack)
7448 
7449  m_attacking = victim;
7450  m_attacking->_addAttacker(this);
7451 
7452  if (creature && !IsPet())
7453  {
7454  // should not let player enter combat by right clicking target
7455  SetInCombatWith(victim);
7456  if (victim->GetTypeId() == TYPEID_PLAYER)
7457  victim->SetInCombatWith(this);
7458  AddThreat(victim, 0.0f);
7459 
7461  creature->CallAssistance();
7462  }
7463 
7464  // delay offhand weapon attack to next attack time
7465  if (haveOffhandWeapon())
7467 
7468  if (meleeAttack)
7469  SendMeleeAttackStart(victim);
7470 
7471  // Let the pet know we've started attacking someting. Handles melee attacks only
7472  // Spells such as auto-shot and others handled in WorldSession::HandleCastSpellOpcode
7473  if (GetTypeId() == TYPEID_PLAYER)
7474  {
7475  Pet* playerPet = this->ToPlayer()->GetPet();
7476 
7477  if (playerPet && playerPet->IsAlive())
7478  playerPet->AI()->OwnerAttacked(victim);
7479  }
7480 
7481  return true;
7482 }
bool AttackStop()
Definition: Unit.cpp:7484
void SetTarget(uint64 guid=0)
Definition: Unit.h:1591
void AddUnitState(uint32 f)
Definition: Unit.h:1026
void AddThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell=NULL)
Definition: Unit.cpp:10208
void RemoveSpellsCausingAura(AuraType auraType)
Definition: Unit.cpp:697
bool IsInEvadeMode() const
Definition: Creature.cpp:2298
bool IsGameMaster() const
Definition: Player.h:1009
virtual void OwnerAttacked(Unit *)
Definition: CreatureAI.h:167
Player * ToPlayer()
Definition: Object.h:392
void CallAssistance()
Definition: Creature.cpp:1925
uint8 GetTypeId() const
Definition: Object.h:210
const bool & IsInWorld() const
Definition: Object.h:135
bool IsAlive() const
Definition: Unit.h:1336
void _addAttacker(Unit *pAttacker)
Definition: Unit.h:993
Unit * m_attacking
Definition: Unit.h:2020
CreatureAI * AI() const
Definition: Creature.h:517
void SendMeleeAttackStart(Unit *victim)
Definition: Unit.cpp:2633
bool haveOffhandWeapon() const
Definition: Unit.cpp:616
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:632
bool IsPet() const
Definition: Unit.h:1048
void SendAIReaction(AiReaction reactionType)
Definition: Creature.cpp:1913
Creature * ToCreature()
Definition: Object.h:395
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
bool IsMounted() const
Definition: Unit.h:1163
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:832
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:305
Pet * GetPet() const
Definition: Player.cpp:17121
Definition: Pet.h:146
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9329
const uint64 & GetGUID() const
Definition: Object.h:162
void Unit::AttackerStateUpdate ( Unit victim,
WeaponAttackType  attType = BASE_ATTACK,
bool  extra = false 
)

Definition at line 2336 of file Unit.cpp.

References CalcDamageInfo::absorb, CalcDamageInfo::attackType, AURA_INTERRUPT_FLAG_ATTACK, BASE_ATTACK, CalcDamageInfo::blocked_amount, CalculateMeleeDamage(), Spell::cast(), CombatStart(), CURRENT_MELEE_SPELL, CalcDamageInfo::damage, DealMeleeDamage(), DEBUG_LOG, Object::GetGUIDLow(), Object::GetTypeId(), Object::HasFlag(), HasUnitState(), IsAlive(), WorldObject::IsWithinLOSInMap(), m_currentSpells, OFF_ATTACK, CalcDamageInfo::procAttacker, ProcDamageAndSpell(), CalcDamageInfo::procEx, CalcDamageInfo::procVictim, RemoveAurasWithInterruptFlags(), CalcDamageInfo::resist, SendAttackStateUpdate(), CalcDamageInfo::target, TYPEID_PLAYER, UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED, and UNIT_STATE_CANNOT_AUTOATTACK.

Referenced by UnitAI::DoMeleeAttackIfReady(), Spell::EffectAddExtraAttacks(), ReactorAI::UpdateAI(), guardAI::UpdateAI(), and UpdateMeleeAttackingState().

2337 {
2339  return;
2340 
2341  if (!victim->IsAlive())
2342  return;
2343 
2344  if ((attType == BASE_ATTACK || attType == OFF_ATTACK) && !IsWithinLOSInMap(victim))
2345  return;
2346 
2348 
2349  if (attType != BASE_ATTACK && attType != OFF_ATTACK)
2350  return; // ignore ranged case
2351 
2352  // melee attack spell casted at main hand attack only
2353  if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra)
2354  {
2356  return;
2357  }
2358 
2359  CalcDamageInfo damageInfo;
2360  CalculateMeleeDamage(victim, 0, &damageInfo, attType);
2361  // Send log damage message to client
2362  SendAttackStateUpdate(&damageInfo);
2363 
2364  ProcDamageAndSpell(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, damageInfo.procEx, damageInfo.damage, damageInfo.attackType);
2365 
2366  DealMeleeDamage(&damageInfo, true);
2367 
2368  // We call this last because DealMeleeDamage has to check for sit state to
2369  // allow critical hits, but we set STANDING in CombatStart, therefore always
2370  // nullifying the check.
2371  CombatStart(victim);
2372 
2373  #ifdef OREGON_DEBUG
2374  if (GetTypeId() == TYPEID_PLAYER)
2375  DEBUG_LOG("AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
2376  GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
2377  else
2378  DEBUG_LOG("AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
2379  GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
2380  #endif
2381 
2382 }
uint32 procAttacker
Definition: Unit.h:692
uint32 blocked_amount
Definition: Unit.h:687
void CalculateMeleeDamage(Unit *victim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK)
Definition: Unit.cpp:1601
uint32 procVictim
Definition: Unit.h:693
uint32 resist
Definition: Unit.h:686
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2079
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
Definition: Unit.cpp:1810
bool IsWithinLOSInMap(const WorldObject *obj) const
Definition: Object.cpp:1229
uint32 GetGUIDLow() const
Definition: Object.h:166
uint32 procEx
Definition: Unit.h:694
WeaponAttackType attackType
Definition: Unit.h:691
uint8 GetTypeId() const
Definition: Object.h:210
void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except=0)
Definition: Unit.cpp:736
bool IsAlive() const
Definition: Unit.h:1336
uint32 absorb
Definition: Unit.h:685
#define DEBUG_LOG(...)
Definition: Log.h:194
void SendAttackStateUpdate(CalcDamageInfo *damageInfo)
Definition: Unit.cpp:4880
void ProcDamageAndSpell(Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellEntry const *procSpell=NULL, bool canTrigger=true)
Definition: Unit.cpp:4842
Unit * target
Definition: Unit.h:682
void CombatStart(Unit *target, bool initialAggro=true)
Definition: Unit.cpp:9351
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
uint32 damage
Definition: Unit.h:684
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:305
void cast(bool skipCheck=false)
Definition: Spell.cpp:2404
bool Unit::AttackStop ( )

Definition at line 7484 of file Unit.cpp.

References _removeAttacker(), ClearUnitState(), CURRENT_MELEE_SPELL, InterruptSpell(), m_attacking, MOVE_RUN, SendMeleeAttackStop(), SetTarget(), Object::ToCreature(), UNIT_STATE_MELEE_ATTACKING, and UpdateSpeed().

Referenced by PetAI::_stopAttack(), Attack(), CombatStop(), ScriptedAI::DoStopAttack(), Player::DuelComplete(), Spell::EffectDummy(), TimedFleeingMovementGenerator::Finalize(), Spell::finish(), WorldSession::HandleAttackStopOpcode(), Aura::HandleAuraModPacify(), WorldSession::HandlePetActionHelper(), WorldSession::HandlePetStopAttack(), RotateMovementGenerator::Initialize(), PetAI::KilledUnit(), MotionMaster::MoveSeekAssistance(), and PossessedAI::UpdateAI().

7485 {
7486  if (!m_attacking)
7487  return false;
7488 
7489  Unit* victim = m_attacking;
7490 
7492  m_attacking = NULL;
7493 
7494  // Clear our target
7495  SetTarget(0);
7496 
7498 
7500 
7501  // reset only at real combat stop
7502  if (Creature* creature = ToCreature())
7503  {
7504  creature->SetNoCallAssistance(false);
7505 
7506  if (creature->HasSearchedAssistance())
7507  {
7508  creature->SetNoSearchAssistance(false);
7509  UpdateSpeed(MOVE_RUN, false);
7510  }
7511  }
7512 
7513  SendMeleeAttackStop(victim);
7514 
7515  return true;
7516 }
void SetTarget(uint64 guid=0)
Definition: Unit.h:1591
void SendMeleeAttackStop(Unit *victim=NULL)
Definition: Unit.cpp:2642
void UpdateSpeed(UnitMoveType mtype, bool forced)
Definition: Unit.cpp:9885
void ClearUnitState(uint32 f)
Definition: Unit.h:1034
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:3507
Unit * m_attacking
Definition: Unit.h:2020
Definition: Unit.h:485
void _removeAttacker(Unit *pAttacker)
Definition: Unit.h:999
Creature * ToCreature()
Definition: Object.h:395
Definition: Unit.h:908
void Unit::BuildHeartBeatMsg ( WorldPacket data) const

Definition at line 1926 of file Object.cpp.

References Object::GetPackGUID(), WorldPacket::Initialize(), and MSG_MOVE_HEARTBEAT.

Referenced by Spell::EffectDummy(), and Spell::EffectScriptEffect().

1927 {
1928  data->Initialize(MSG_MOVE_HEARTBEAT, 32);
1929  *data << GetPackGUID();
1930  BuildMovementPacket(data);
1931 }
void BuildMovementPacket(ByteBuffer *data) const
Definition: Unit.cpp:13600
void Initialize(uint16 opcode, size_t newres=200)
Definition: WorldPacket.h:37
PackedGuid const & GetPackGUID() const
Definition: Object.h:178
void Unit::BuildMovementPacket ( ByteBuffer data) const

Definition at line 13600 of file Unit.cpp.

References getMSTime().

Referenced by SetSpeed().

13601 {
13602  *data << uint32(GetUnitMovementFlags()); // movement flags
13603  *data << uint8(0); // 2.3.0 @todo: Implement extra movement flags
13604  *data << uint32(getMSTime()); // time / counter
13605  *data << float(GetPositionX());
13606  *data << float(GetPositionY());
13607  *data << float(GetPositionZ());
13608  *data << float(GetOrientation());
13609  *data << uint32(0);
13610 }
uint32 GetUnitMovementFlags() const
Definition: Unit.h:1904
uint32 getMSTime()
Definition: Timer.h:32
ACE_UINT8 uint8
Definition: Define.h:73
float GetOrientation() const
Definition: Position.h:100
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
ACE_UINT32 uint32
Definition: Define.h:71
float GetPositionX() const
Definition: Position.h:97
void Unit::CalcAbsorbResist ( Unit victim,
SpellSchoolMask  schoolMask,
DamageEffectType  damagetype,
const uint32  damage,
uint32 absorb,
uint32 resist,
SpellEntry const *  spellInfo = NULL,
bool  binary = false 
)

Definition at line 2074 of file Unit.cpp.

References Player::AddSpellCooldown(), ApplyPowerMod(), SpellEntry::AttributesEx4, BASE_ATTACK, CalculateEffectiveMagicResistance(), CalculateMagicResistanceMitigation(), CalculatePct(), CastCustomSpell(), CastSpell(), CountPctFromMaxHealth(), DealDamage(), DOT, GetAurasByType(), GetHealth(), Aura::GetId(), Aura::GetModifier(), GetPower(), GetSpellModOwner(), Player::HasSpellCooldown(), IsAlive(), IsImmunedToDamage(), Object::IsInWorld(), Modifier::m_amount, m_removedAurasCount, MELEE_HIT_NORMAL, NUM_SPELL_PARTIAL_RESISTS, POWER_MANA, PROC_EX_NORMAL_HIT, PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG, ProcDamageAndSpellFor(), RemoveAurasDueToSpell(), roll_chance_i(), SendSpellNonMeleeDamageLog(), SPELL_ATTR4_IGNORE_RESISTANCES, SPELL_AURA_MANA_SHIELD, SPELL_AURA_OVERRIDE_CLASS_SCRIPTS, SPELL_AURA_REUSED_BLESSED_LIFE, SPELL_AURA_SCHOOL_ABSORB, SPELL_AURA_SPLIT_DAMAGE_FLAT, SPELL_AURA_SPLIT_DAMAGE_PCT, SPELL_PARTIAL_RESIST_NONE, SPELL_PARTIAL_RESIST_PCT_100, SPELL_SCHOOL_MASK_MAGIC, SPELLFAMILY_PRIEST, SPELLFAMILY_ROGUE, SPELLMOD_MULTIPLE_VALUE, Object::ToPlayer(), and urand().

Referenced by CalculateMeleeDamage(), CalculateSpellDamageTaken(), Player::EnvironmentalDamage(), ChatHandler::HandleDamageCommand(), and Aura::PeriodicTick().

2075 {
2076  if (!victim || !victim->IsAlive() || !damage)
2077  return;
2078 
2079  // Magic damage, check for resists
2080  if (!spellInfo || (spellInfo->AttributesEx4 & SPELL_ATTR4_IGNORE_RESISTANCES) == 0 && (schoolMask & SPELL_SCHOOL_MASK_MAGIC) && (!binary || damagetype == DOT))
2081  {
2082  const float mitigation = victim->CalculateMagicResistanceMitigation(victim, victim->CalculateEffectiveMagicResistance(victim, schoolMask), false);
2083  const SpellPartialResistChanceEntry &chances = SPELL_PARTIAL_RESIST_DISTRIBUTION.at(uint32(mitigation * 10000));
2084  // We choose which portion of damage is resisted below, none by default
2085  uint8 portion = SPELL_PARTIAL_RESIST_NONE;
2086  // If we got to this point, we already rolled for full resist on hit
2087  // We do a roll between remaining chances
2088  const uint8 outcomes = (NUM_SPELL_PARTIAL_RESISTS - 1);
2089  const uint32 roll = urand(1, (10000 - chances.at(SPELL_PARTIAL_RESIST_PCT_100)));
2090  uint32 sum = 0;
2091  for (uint8 outcome = SPELL_PARTIAL_RESIST_NONE; outcome < outcomes; ++outcome)
2092  {
2093  if (const uint32 chance = chances.at(outcome))
2094  {
2095  sum += chance;
2096  if (roll <= sum)
2097  {
2098  portion = outcome;
2099  break;
2100  }
2101  }
2102  }
2103  const uint32 amount = uint32(damage * (portion * (1.0f / float(outcomes))));
2104  // We already rolled for full resist on hit, so we need to deal at least *some* amount of damage...
2105  *resist = (amount >= damage) ? (damage - 1) : amount;
2106  }
2107  else
2108  *resist = 0;
2109 
2110  int32 RemainingDamage = damage - *resist;
2111 
2112  // Paladin Blessed Life 4/7/10% chance to cause 50% dmg
2113  AuraList const& blessedLife = victim->GetAurasByType(SPELL_AURA_REUSED_BLESSED_LIFE);
2114  AuraList::const_iterator blessedAura = blessedLife.begin();
2115  if (blessedAura != blessedLife.end() && *blessedAura)
2116  {
2117  if (urand(0, 100) <= (*blessedAura)->GetSpellProto()->procChance)
2118  RemainingDamage /= 2;
2119  }
2120 
2121  // Need to remove expired auras after
2122  bool expiredExists = false;
2123 
2124  // absorb without mana cost
2125  int32 reflectDamage = 0;
2126  Aura* reflectAura = NULL;
2127  AuraList const& vSchoolAbsorb = victim->GetAurasByType(SPELL_AURA_SCHOOL_ABSORB);
2128  for (AuraList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end() && RemainingDamage > 0; ++i)
2129  {
2130  int32* p_absorbAmount = &(*i)->GetModifier()->m_amount;
2131 
2132  // should not happen....
2133  if (*p_absorbAmount <= 0)
2134  {
2135  expiredExists = true;
2136  continue;
2137  }
2138 
2139  if (((*i)->GetModifier()->m_miscvalue & schoolMask) == 0)
2140  continue;
2141 
2142  // Cheat Death
2143  if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_ROGUE && (*i)->GetSpellProto()->SpellIconID == 2109)
2144  {
2145  if (victim->ToPlayer()->HasSpellCooldown(31231))
2146  continue;
2147  if (int32(victim->GetHealth()) <= RemainingDamage)
2148  {
2149  int32 chance = *p_absorbAmount;
2150  if (roll_chance_i(chance))
2151  {
2152  victim->CastSpell(victim, 31231, true);
2153  victim->ToPlayer()->AddSpellCooldown(31231, 0, time(NULL) + 60);
2154 
2155  // with health > 10% lost health until health == 10%, in other case no losses
2156  uint32 health10 = victim->CountPctFromMaxHealth(10);
2157  RemainingDamage = victim->GetHealth() > health10 ? victim->GetHealth() - health10 : 0;
2158  }
2159  }
2160  continue;
2161  }
2162 
2163  int32 currentAbsorb;
2164 
2165  //Reflective Shield
2166  if ((victim != this) &&am