OregonCore  revision 3611e8a-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 CanDualWield () const
 
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
 
uint32 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
 
uint16 GetMaxSkillValueForLevel (Unit const *target=NULL) 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 GetCombatTimer () 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
 
virtual void MoveOutOfRange (Player &)
 
bool isMoving () const
 
bool IsAlive () const
 
bool isDying () const
 
bool isDead () const
 
DeathState getDeathState ()
 
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)=0
 
float GetTotalAttackPowerValue (WeaponAttackType attType) const
 
float GetWeaponDamageRange (WeaponAttackType attType, WeaponDamageRange type) const
 
void SetBaseWeaponDamage (WeaponAttackType attType, WeaponDamageRange damageRange, float value)
 
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 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)
 
uint32 CalculateDamage (WeaponAttackType attType, bool normalized)
 
float GetAPMultiplier (WeaponAttackType attType, bool normalized)
 
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)
 
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 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 Position
static float NormalizeOrientation (float o)
 

Public Attributes

uint32 m_extraAttacks
 
bool m_canDualWield
 
ControlList m_Controlled
 
uint32 m_addDmgOnce
 
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_CombatTimer
 
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 884 of file Unit.h.

Member Typedef Documentation

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

Definition at line 889 of file Unit.h.

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

Definition at line 893 of file Unit.h.

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

Definition at line 892 of file Unit.h.

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

Definition at line 895 of file Unit.h.

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

Definition at line 896 of file Unit.h.

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

Definition at line 890 of file Unit.h.

Definition at line 894 of file Unit.h.

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

Definition at line 2139 of file Unit.h.

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

Definition at line 2064 of file Unit.h.

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

Definition at line 891 of file Unit.h.

Constructor & Destructor Documentation

Unit::~Unit ( )
override

Definition at line 476 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().

477 {
478  // set current spells as deletable
479  for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
480  if (m_currentSpells[i])
481  {
483  m_currentSpells[i] = NULL;
484  }
485 
488  _DeleteAuras();
489 
490  delete m_charmInfo;
491  delete movespline;
492 
495  ASSERT(m_attackers.empty());
496  ASSERT(m_sharedVision.empty());
497 }
bool m_duringRemoveFromWorld
Definition: Unit.h:2208
Movement::MoveSpline * movespline
Definition: Unit.h:2018
SharedVisionList m_sharedVision
Definition: Unit.h:2162
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2191
void _DeleteAuras()
Definition: Unit.cpp:3282
CharmInfo * m_charmInfo
Definition: Unit.h:2161
ACE_UINT8 uint8
Definition: Define.h:73
Unit * m_attacking
Definition: Unit.h:2131
#define CURRENT_MAX_SPELL
Definition: Unit.h:720
AttackerSet m_attackers
Definition: Unit.h:2130
#define ASSERT
Definition: Errors.h:33
void RemoveAllGameObjects()
Definition: Unit.cpp:4738
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:482
void RemoveAllDynObjects()
Definition: Unit.cpp:4618
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_addDmgOnce, 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, 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  m_addDmgOnce = 0;
404 
405  for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
406  m_SummonSlot[i] = 0;
407 
408  m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0;
409 
411  m_AuraFlags = 0;
412 
413  m_interruptMask = 0;
414  m_transform = 0;
416  m_canModifyStats = false;
417 
418  for (uint8 i = 0; i < MAX_SPELL_IMMUNITY; ++i)
419  m_spellImmune[i].clear();
420 
421  for (uint8 i = 0; i < UNIT_MOD_END; ++i)
422  {
423  m_auraModifiersGroup[i][BASE_VALUE] = 0.0f;
424  m_auraModifiersGroup[i][BASE_PCT] = 1.0f;
426  m_auraModifiersGroup[i][TOTAL_PCT] = 1.0f;
427  }
428  // implement 50% base damage from offhand
430 
431  for (uint8 i = 0; i < MAX_ATTACK; ++i)
432  {
435  }
436 
437  for (uint8 i = 0; i < MAX_STATS; ++i)
438  m_createStats[i] = 0.0f;
439 
440  m_attacking = NULL;
441  m_modMeleeHitChance = 0.0f;
442  m_modRangedHitChance = 0.0f;
443  m_modSpellHitChance = 0.0f;
445 
446  m_initiatingCombat = false;
447 
448  m_CombatTimer = 0;
449  m_lastManaUse = 0;
450 
451  for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
452  m_threatModifier[i] = 1.0f;
453 
454  m_isSorted = true;
455 
456  for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
457  m_speed_rate[i] = 1.0f;
458 
460 
461  m_charmInfo = NULL;
464 
465  // remove aurastates allowing special moves
466  for (uint8 i = 0; i < MAX_REACTIVE; ++i)
467  m_reactiveTimer[i] = 0;
468 
469  m_duringRemoveFromWorld = false;
470 
471  _oldFactionId = 0;
472 
474 }
#define BASE_MINDAMAGE
Definition: Unit.h:157
uint32 m_removedAurasCount
Definition: Unit.h:2137
#define MAX_MOVE_TYPE
Definition: Unit.h:470
bool m_ControlledByPlayer
Definition: Unit.h:2103
float m_modMeleeHitChance
Definition: Unit.h:1735
bool m_duringRemoveFromWorld
Definition: Unit.h:2208
int32 m_baseSpellCritChance
Definition: Unit.h:1738
Movement::MoveSpline * movespline
Definition: Unit.h:2018
#define MAX_ATTACK
Definition: Unit.h:481
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:821
uint32 m_reducedThreatPercent
Definition: Unit.h:2205
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2191
CharmInfo * m_charmInfo
Definition: Unit.h:2161
bool m_isSorted
Definition: Unit.h:2143
Definition: Unit.h:413
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:620
uint32 m_lastSanctuaryTime
Definition: Unit.h:1820
uint32 m_reactiveTimer[MAX_REACTIVE]
Definition: Unit.h:2170
float m_speed_rate[MAX_MOVE_TYPE]
Definition: Unit.h:2158
TimeTrackerSmall m_movesplineTimer
Definition: Unit.h:2193
uint64 LastCharmerGUID
Definition: Unit.h:2102
bool IsAIEnabled
Definition: Unit.h:2101
uint16 m_objectType
Definition: Object.h:418
uint32 m_transform
Definition: Unit.h:2144
#define MAX_SPELL_SCHOOL
uint32 m_addDmgOnce
Definition: Unit.h:1716
uint64 m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1717
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2153
uint32 _oldFactionId
Definition: Unit.h:1743
time_t _lastDamagedTime
Definition: Unit.h:2212
uint32 m_state
Definition: Unit.h:2187
uint32 m_lastManaUse
Definition: Unit.h:2189
UnitAI * i_AI
Definition: Unit.h:2115
UnitAI * i_disabledAI
Definition: Unit.h:2115
uint64 m_misdirectionTargetGUID
Definition: Unit.h:2206
#define MAX_SPELL_IMMUNITY
#define MAX_STATS
uint8 m_objectTypeId
Definition: Object.h:420
float m_modSpellHitChance
Definition: Unit.h:1737
ACE_UINT8 uint8
Definition: Define.h:73
uint8 m_updateFlag
Definition: Object.h:421
DeathState m_deathState
Definition: Unit.h:2133
Unit * m_attacking
Definition: Unit.h:2131
HostileRefManager m_HostileRefManager
Definition: Unit.h:2199
float m_modAttackSpeedPct[3]
Definition: Unit.h:1741
#define BASE_MAXDAMAGE
Definition: Unit.h:158
float m_createStats[MAX_STATS]
Definition: Unit.h:2128
bool NeedChangeAI
Definition: Unit.h:2101
#define MAX_REACTIVE
Definition: Unit.h:870
uint32 m_AuraFlags
Definition: Unit.h:1879
ThreatManager m_ThreatManager
Definition: Unit.h:2172
uint32 m_ShapeShiftFormSpellId
Definition: Unit.h:1720
uint32 m_extraAttacks
Definition: Unit.h:953
WorldObject(bool isWorldObject)
Definition: Object.cpp:1087
MotionMaster i_motionMaster
Definition: Unit.h:2166
#define CURRENT_MAX_SPELL
Definition: Unit.h:720
bool m_canDualWield
Definition: Unit.h:954
uint32 m_unitTypeMask
Definition: Unit.h:2160
bool m_initiatingCombat
Definition: Unit.h:2124
uint32 m_interruptMask
Definition: Unit.h:2151
uint32 m_CombatTimer
Definition: Unit.h:2188
float m_threatModifier[MAX_SPELL_SCHOOL]
Definition: Unit.h:1740
#define MAX_SUMMON_SLOT
Definition: Unit.h:876
uint64 m_ObjectSlot[4]
Definition: Unit.h:1718
float m_modRangedHitChance
Definition: Unit.h:1736
Definition: Unit.h:330
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2126
AuraMap::iterator m_AurasUpdateIterator
Definition: Unit.h:2136
uint32 m_procDeep
Definition: Unit.h:2210
float m_weaponDamage[MAX_ATTACK][2]
Definition: Unit.h:2154
AuraMap m_Auras
Definition: Unit.h:2135
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1819
bool m_canModifyStats
Definition: Unit.h:2155
ShapeshiftForm m_form
Definition: Unit.h:1722

Member Function Documentation

void Unit::_addAttacker ( Unit pAttacker)
inline

Definition at line 956 of file Unit.h.

Referenced by Attack().

957  {
958  AttackerSet::iterator itr = m_attackers.find(pAttacker);
959  if (itr == m_attackers.end())
960  m_attackers.insert(pAttacker);
961  }
AttackerSet m_attackers
Definition: Unit.h:2130
void Unit::_ApplyAllAuraMods ( )

Definition at line 4580 of file Unit.cpp.

References m_Auras.

Referenced by Player::_ApplyAllStatBonuses().

4581 {
4582  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
4583  (*i).second->ApplyModifier(true);
4584 }
AuraMap m_Auras
Definition: Unit.h:2135
void Unit::_DeleteAuras ( )
protected

Definition at line 3282 of file Unit.cpp.

References m_removedAuras.

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

3283 {
3284  while (!m_removedAuras.empty())
3285  {
3286  delete m_removedAuras.front();
3287  m_removedAuras.pop_front();
3288  }
3289 }
AuraList m_removedAuras
Definition: Unit.h:2145
bool Unit::_IsValidAssistTarget ( Unit const *  target,
SpellEntry const *  bySpell 
) const

Definition at line 9558 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().

9559 {
9560  ASSERT(target);
9561 
9562  // can assist to self
9563  if (this == target)
9564  return true;
9565 
9566  // can't assist unattackable units or GMs
9567  if (target->HasUnitState(UNIT_STATE_UNATTACKABLE)
9568  || target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
9569  return false;
9570 
9571  // can't assist invisible
9572  if (!CanSeeOrDetect(target))
9573  return false;
9574 
9575  // can't assist dead
9576  if (!target->IsAlive())
9577  return false;
9578 
9579  // can't assist untargetable
9580  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
9581  return false;
9582 
9583  if (!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
9584  {
9586  {
9587  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))
9588  return false;
9589  }
9590  else
9591  {
9592  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
9593  return false;
9594  }
9595  }
9596 
9597  // can't assist non-friendly targets
9598  if (GetReactionTo(target) < REP_NEUTRAL
9599  && target->GetReactionTo(this) < REP_NEUTRAL)
9600  return false;
9601 
9602  // PvP case
9603  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
9604  {
9605  Player const* targetPlayerOwner = target->GetAffectingPlayer();
9607  {
9608  Player const* selfPlayerOwner = GetAffectingPlayer();
9609  if (selfPlayerOwner && targetPlayerOwner)
9610  {
9611  // can't assist player which is dueling someone
9612  if (selfPlayerOwner != targetPlayerOwner
9613  && targetPlayerOwner->duel)
9614  return false;
9615  }
9616  // can't assist player in ffa_pvp zone from outside
9617  if ((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP)
9619  return false;
9620  // can't assist player out of sanctuary from sanctuary if has pvp enabled
9621  if (target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK0)
9623  return false;
9624  }
9625  }
9626  // PvC case - player can assist creature only if has specific type flags
9627  // !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) &&
9629  && (!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
9630  && !((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK0)))
9631  {
9632  if (Creature const* creatureTarget = target->ToCreature())
9633  return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST;
9634  }
9635  return true;
9636 }
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7147
DuelInfo * duel
Definition: Player.h:1809
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7574
Creature * ToCreature()
Definition: Object.h:389
#define ASSERT
Definition: Errors.h:33
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:299
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1582
Definition: Player.h:922
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.h:246
bool Unit::_IsValidAttackTarget ( Unit const *  target,
SpellEntry const *  bySpell,
WorldObject const *  obj = NULL 
) const

Definition at line 9447 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().

9448 {
9449  ASSERT(target);
9450 
9451  // can't attack self
9452  if (this == target)
9453  return false;
9454 
9455  // can't attack unattackable units or GMs
9456  if (target->HasUnitState(UNIT_STATE_UNATTACKABLE)
9457  || target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
9458  return false;
9459 
9460  // visibility checks
9461  // skip visibility check for GO casts, needs removal when go cast is implemented. Also ignore for gameobject and dynauras
9462  if (GetEntry() != WORLD_TRIGGER && (!obj || !obj->isType(TYPEMASK_GAMEOBJECT | TYPEMASK_DYNAMICOBJECT)))
9463  {
9464  // can't attack invisible
9465  if (!bySpell)
9466  {
9467  if (obj && !obj->CanSeeOrDetect(target))
9468  return false;
9469  else if (!obj)
9470  {
9471  // ignore stealth for aoe spells. Ignore stealth if target is player and unit in combat with same player
9472  bool const ignoreStealthCheck = target->GetTypeId() == TYPEID_PLAYER && target->HasStealthAura() && target->IsInCombat() && IsInCombatWith(target);
9473 
9474  if (!CanSeeOrDetect(target, ignoreStealthCheck))
9475  return false;
9476  }
9477  }
9478  }
9479 
9480  // can't attack dead
9481  if (!target->IsAlive())
9482  return false;
9483 
9484  // can't attack untargetable
9485  if (!bySpell && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
9486  return false;
9487 
9488  // check flags
9493  // 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
9495  return false;
9496 
9497  // CvC case - can attack each other only when one of them is hostile
9499  return GetReactionTo(target) <= REP_HOSTILE || target->GetReactionTo(this) <= REP_HOSTILE;
9500 
9501  // PvP, PvC, CvP case
9502  // can't attack friendly targets
9503  if (GetReactionTo(target) > REP_NEUTRAL
9504  || target->GetReactionTo(this) > REP_NEUTRAL)
9505  return false;
9506 
9507  Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : nullptr;
9508  Player const* playerAffectingTarget = target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? target->GetAffectingPlayer() : nullptr;
9509 
9510  // Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
9511  if ((playerAffectingAttacker && !playerAffectingTarget) ||
9512  (!playerAffectingAttacker && playerAffectingTarget))
9513  {
9514  Player const* player = playerAffectingAttacker ? playerAffectingAttacker : playerAffectingTarget;
9515  Unit const* creature = playerAffectingAttacker ? target : this;
9516 
9517  if (FactionTemplateEntry const* factionTemplate = creature->GetFactionTemplateEntry())
9518  {
9519  if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate)))
9520  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction))
9521  if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
9523  return false;
9524 
9525  }
9526  }
9527 
9528  // check duel - before sanctuary checks
9529  if (playerAffectingAttacker && playerAffectingTarget)
9530  if (playerAffectingAttacker->duel && playerAffectingAttacker->duel->opponent == playerAffectingTarget && playerAffectingAttacker->duel->startTime != 0)
9531  return true;
9532 
9533  // PvP case - can't attack when attacker or target are in sanctuary
9534  if ((target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) && (target->IsInSanctuary()))
9536  return false;
9537 
9538  // additional checks - only PvP case
9539  if (playerAffectingAttacker && playerAffectingTarget)
9540  {
9541  if (target->IsPvP())
9542  return true;
9543 
9544  if (playerAffectingAttacker->IsFFAPvP() && playerAffectingTarget->IsFFAPvP())
9545  return true;
9546 
9548  || target->HasFlag(UNIT_FIELD_BYTES_2, UNIT_BYTE2_FLAG_UNK1);
9549  }
9550  return true;
9551 }
time_t startTime
Definition: Player.h:235
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7147
DuelInfo * duel
Definition: Player.h:1809
bool IsFFAPvP() const
Definition: Player.h:1782
#define WORLD_TRIGGER
Definition: Unit.h:38
FactionState const * GetState(FactionEntry const *factionEntry) const
Definition: ReputationMgr.h:75
bool IsContestedGuard() const
Definition: Unit.h:1132
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7574
ReputationRank const * GetForcedRankIfAny(FactionTemplateEntry const *factionTemplateEntry) const
Definition: ReputationMgr.h:96
bool IsInSanctuary() const
Definition: Unit.cpp:9438
ReputationMgr & GetReputationMgr()
Definition: Player.h:2091
Player * opponent
Definition: Player.h:233
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
#define ASSERT
Definition: Errors.h:33
uint32 GetEntry() const
Definition: Object.h:186
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7132
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:299
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1582
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:500
Definition: Unit.h:884
Definition: Player.h:922
void Unit::_RemoveAllAuraMods ( )

Definition at line 4574 of file Unit.cpp.

References m_Auras.

Referenced by Player::_RemoveAllStatBonuses().

4575 {
4576  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
4577  (*i).second->ApplyModifier(false);
4578 }
AuraMap m_Auras
Definition: Unit.h:2135
void Unit::_removeAttacker ( Unit pAttacker)
inline

Definition at line 962 of file Unit.h.

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

963  {
964  m_attackers.erase(pAttacker);
965  }
AttackerSet m_attackers
Definition: Unit.h:2130
void Unit::_UpdateAutoRepeatSpell ( )
protected

Definition at line 3343 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().

3344 {
3345  //check "realtime" interrupts
3346  if ((GetTypeId() == TYPEID_PLAYER && isMoving()) || IsNonMeleeSpellCast(false, false, true))
3347  {
3348  // cancel wand shoot
3349  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351)
3351  m_AutoRepeatFirstCast = true;
3352  return;
3353  }
3354 
3355  // apply delay (Auto Shot (spellID 75) not affected)
3358  m_AutoRepeatFirstCast = false;
3359 
3360  //castroutine
3362  {
3363  // Check if able to cast
3364  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true) != SPELL_CAST_OK)
3365  {
3367  return;
3368  }
3369 
3370  // we want to shoot
3371  Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, true, 0);
3372  spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
3373 
3374  // all went good, reset attack
3376  }
3377 }
void setAttackTimer(WeaponAttackType type, uint32 time)
Definition: Unit.h:919
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false) const
Definition: Unit.cpp:3493
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2191
void prepare(SpellCastTargets *targets, Aura *triggeredByAura=NULL)
Definition: Spell.cpp:2222
bool m_AutoRepeatFirstCast
Definition: Unit.h:2121
bool isMoving() const
Definition: Unit.h:1429
uint8 GetTypeId() const
Definition: Object.h:204
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:3455
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:928
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:583
uint32 getAttackTimer(WeaponAttackType type) const
Definition: Unit.h:924
Definition: Spell.h:249
void Unit::_UpdateSpells ( uint32  time)
protected

Definition at line 3291 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().

3292 {
3295 
3296  // remove finished spells from current pointers
3297  for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
3298  {
3299  if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
3300  {
3302  m_currentSpells[i] = NULL; // remove pointer
3303  }
3304  }
3305 
3306  // m_AurasUpdateIterator can be updated in inderect called code at aura remove to skip next planned to update but removed auras
3307  for (m_AurasUpdateIterator = m_Auras.begin(); m_AurasUpdateIterator != m_Auras.end();)
3308  {
3309  Aura* i_aura = m_AurasUpdateIterator->second;
3310  ++m_AurasUpdateIterator; // need shift to next for allow update if need into aura update
3311  i_aura->Update(time);
3312  }
3313 
3314  // remove expired auras
3315  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
3316  {
3317  if (i->second->IsExpired())
3319  else
3320  ++i;
3321  }
3322 
3323  _DeleteAuras();
3324 
3325  if (!m_gameObj.empty())
3326  {
3327  std::list<GameObject*>::iterator itr;
3328  for (itr = m_gameObj.begin(); itr != m_gameObj.end();)
3329  {
3330  if (!(*itr)->isSpawned())
3331  {
3332  (*itr)->SetOwnerGUID(0);
3333  (*itr)->SetRespawnTime(0);
3334  (*itr)->Delete();
3335  m_gameObj.erase(itr++);
3336  }
3337  else
3338  ++itr;
3339  }
3340  }
3341 }
void _UpdateAutoRepeatSpell()
Definition: Unit.cpp:3343
virtual void Update(uint32 diff)
Definition: SpellAuras.cpp:529
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2191
void _DeleteAuras()
Definition: Unit.cpp:3282
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4389
std::list< GameObject * > m_gameObj
Definition: Unit.h:2142
#define CURRENT_MAX_SPELL
Definition: Unit.h:720
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:482
AuraMap::iterator m_AurasUpdateIterator
Definition: Unit.h:2136
ACE_UINT32 uint32
Definition: Define.h:71
AuraMap m_Auras
Definition: Unit.h:2135
void Unit::AddAssistThreat ( Unit victim,
float  threatToAdd,
SpellEntry const *  threatSpell 
)

Definition at line 10138 of file Unit.cpp.

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

Referenced by Spell::HandleThreatSpells().

10139 {
10140  // Only mobs can manage threat lists
10141  if (CanHaveThreatList())
10142  getHostileRefManager().threatAssist(victim, threatToAdd, threatSpell);
10143 }
HostileRefManager & getHostileRefManager()
Definition: Unit.h:1842
bool CanHaveThreatList() const
Definition: Unit.cpp:10090
void threatAssist(Unit *victim, float baseThreat, SpellEntry const *threatSpell=NULL)
void Unit::AddAura ( uint32  spellId,
Unit target 
)

Definition at line 13382 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().

13383 {
13384  if (!target)
13385  return;
13386 
13387  SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
13388  if (!spellInfo)
13389  return;
13390 
13391  if (!target->IsAlive() && !(spellInfo->AttributesEx & SPELL_ATTR0_PASSIVE) && !(spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_DEAD))
13392  return;
13393 
13394  if (target->IsImmuneToSpell(spellInfo))
13395  return;
13396 
13397  for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
13398  {
13399  if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA)
13400  {
13401  if (target->IsImmuneToSpellEffect(spellInfo, i, false))
13402  continue;
13403 
13404  if (spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER)
13405  {
13406  Aura* Aur = CreateAura(spellInfo, i, NULL, this, this);
13407  AddAura(Aur);
13408  }
13409  else
13410  {
13411  Aura* Aur = CreateAura(spellInfo, i, NULL, target, this);
13412  target->AddAura(Aur);
13413  }
13414  }
13415  }
13416 }
uint32 AttributesEx
Definition: DBCStructure.h:680
virtual bool IsImmuneToSpell(SpellEntry const *spellInfo, bool useCharges=false)
Definition: Unit.cpp:8868
uint32 AttributesEx2
Definition: DBCStructure.h:681
uint32 Effect[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:724
void AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:13382
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:1433
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:8931
bool Unit::AddAura ( Aura aur)

Definition at line 3787 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().

3788 {
3789  // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load)
3790  if (!IsAlive() && Aur->GetId() != 20584 && Aur->GetId() != 8326 && Aur->GetId() != 2584 &&
3792  {
3793  delete Aur;
3794  return false;
3795  }
3796 
3797  if (Aur->GetTarget() != this)
3798  {
3799  sLog.outError("Aura (spell %u eff %u) add to aura list of %s (lowguid: %u) but Aura target is %s (lowguid: %u)",
3800  Aur->GetId(), Aur->GetEffIndex(), (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(),
3801  (Aur->GetTarget()->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), Aur->GetTarget()->GetGUIDLow());
3802  delete Aur;
3803  return false;
3804  }
3805 
3806  SpellEntry const* aurSpellInfo = Aur->GetSpellProto();
3807 
3808  spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex());
3809  bool stackModified = false;
3810 
3811  // Handle aura stacking down below...
3812  if (!Aur->IsPassive() && !Aur->IsPersistent())
3813  {
3814  for (AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair);)
3815  {
3816  Aura* aur2 = i2->second;
3817  if (aur2 && !stackModified)
3818  {
3819  ASSERT(aur2->GetId() == Aur->GetId());
3820 
3821  // @todo: fix this hack
3822  // Allow mongoose proc from different weapons... this should be corrected to allow multiple
3823  // auras triggered by different enchanted items this is not possible currently since we only have
3824  // GUID and not even information if the Aura was "triggered" see m_IsTriggeredSpell in Spell.h
3825  if (Aur->GetCastItemGUID() && Aur->GetId() == 28093)
3826  {
3827  bool allow = true;
3828 
3829  for (AuraMap::const_iterator i3 = m_Auras.lower_bound(spair); i3 != m_Auras.upper_bound(spair); i3++)
3830  if (i3->second->GetCastItemGUID() == Aur->GetCastItemGUID())
3831  allow = false;
3832 
3833  if (allow)
3834  break;
3835  }
3836 
3837  // Not the same caster - might allow stacking - based on spell_group and spell_group_stack_rules tables
3838  if (Aur->GetCasterGUID() != aur2->GetCasterGUID())
3839  if (!sSpellMgr.IsNoStackSpellDueToSpell(Aur->GetId(), aur2->GetId(), false))
3840  break;
3841 
3842  // Non stackable and capped auras do not allow stacking
3843  if (!(aurSpellInfo->StackAmount && uint32(aur2->GetStackAmount()) < aurSpellInfo->StackAmount))
3844  {
3845  // Do not let the stack size exceed the maximum stack limit
3846  // Instead of adding a new stack, just set the duration time
3847  // we need to use time from Aur because of diminishing effects
3848  aur2->SetAuraDuration(Aur->GetAuraMaxDuration());
3849  aur2->SetAuraProcCharges(Aur->m_procCharges);
3850  aur2->UpdateAuraDuration();
3851  aur2->UpdateAuraCharges();
3852  *aur2->GetModifier() = *Aur->GetModifier();
3853  delete Aur;
3854  return true;
3855  }
3856 
3857  // Increment aura's stack, one stack per one call
3858  Aur->SetStackAmount(aur2->GetStackAmount() + 1);
3859  stackModified = true;
3860 
3861  // Existing aura will be replaced with the newly created one
3863  i2 = m_Auras.lower_bound(spair);
3864  continue;
3865  }
3866  ++i2;
3867  }
3868  }
3869  // passive auras stack with all (except passive spell proc auras)
3870  if ((!Aur->IsPassive() || !IsPassiveStackableSpell(Aur->GetId())) &&
3871  !(Aur->GetId() == 20584 || Aur->GetId() == 8326))
3872  {
3873  if (!RemoveNoStackAurasDueToAura(Aur))
3874  {
3875  delete Aur;
3876  return false; // couldn't remove conflicting aura with higher rank
3877  }
3878  }
3879 
3880  // update single target auras list (before aura add to aura list, to prevent unexpected remove recently added aura)
3881  if (Aur->IsSingleTarget() && Aur->GetTarget())
3882  {
3883  // caster pointer can be deleted in time aura remove, find it by guid at each iteration
3884  for (;;)
3885  {
3886  Unit* caster = Aur->GetCaster();
3887  if (!caster) // caster deleted and not required adding scAura
3888  break;
3889 
3890  bool restart = false;
3891  AuraList& scAuras = caster->GetSingleCastAuras();
3892  for (AuraList::iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr)
3893  {
3894  if ((*itr)->GetTarget() != Aur->GetTarget() &&
3895  IsSingleTargetSpells((*itr)->GetSpellProto(), aurSpellInfo))
3896  {
3897  if ((*itr)->IsInUse())
3898  {
3899  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());
3900  continue;
3901  }
3902  (*itr)->GetTarget()->RemoveAura((*itr)->GetId(), (*itr)->GetEffIndex());
3903  restart = true;
3904  break;
3905  }
3906  }
3907 
3908  if (!restart)
3909  {
3910  // done
3911  scAuras.push_back(Aur);
3912  break;
3913  }
3914  }
3915  }
3916 
3917  // add aura, register in lists and arrays
3918  Aur->_AddAura();
3919  m_Auras.insert(AuraMap::value_type(spellEffectPair(Aur->GetId(), Aur->GetEffIndex()), Aur));
3920  if (Aur->GetModifier()->m_auraname < TOTAL_AURAS)
3921  {
3922  m_modAuras[Aur->GetModifier()->m_auraname].push_back(Aur);
3923  if (Aur->GetSpellProto()->AuraInterruptFlags)
3924  {
3925  m_interruptableAuras.push_back(Aur);
3926  AddInterruptMask(Aur->GetSpellProto()->AuraInterruptFlags);
3927  }
3928  if ((Aur->GetSpellProto()->Attributes & SPELL_ATTR0_HEARTBEAT_RESIST_CHECK)
3929  && (Aur->GetModifier()->m_auraname != SPELL_AURA_MOD_POSSESS)) //only dummy aura is breakable
3930  m_ccAuras.push_back(Aur);
3931  }
3932 
3933  Aur->ApplyModifier(true, true);
3934 
3935  uint32 id = Aur->GetId();
3936  if (sSpellMgr.GetSpellCustomAttr(id) & SPELL_ATTR_CU_LINK_AURA)
3937  {
3938  if (const std::vector<int32>* spell_triggered = sSpellMgr.GetSpellLinked(id + SPELL_LINK_AURA))
3939  {
3940  for (std::vector<int32>::const_iterator itr = spell_triggered->begin(); itr != spell_triggered->end(); ++itr)
3941  if (*itr < 0)
3942  ApplySpellImmune(id, IMMUNITY_ID, -(*itr), true);
3943  else if (Unit* caster = Aur->GetCaster())
3944  caster->AddAura(*itr, this);
3945  }
3946  }
3947 
3948  DEBUG_LOG("Aura %u now is in use", Aur->GetModifier()->m_auraname);
3949  return true;
3950 }
bool IsPassiveStackableSpell(uint32 spellId)
Definition: Unit.cpp:138
bool RemoveNoStackAurasDueToAura(Aura *Aur)
Definition: Unit.cpp:3978
bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellInfo2)
Definition: SpellMgr.cpp:807
AuraList m_ccAuras
Definition: Unit.h:2150
std::pair< uint32, uint8 > spellEffectPair
Definition: Unit.h:891
void SetAuraDuration(int32 duration)
Definition: SpellAuras.h:278
#define sLog
Log class singleton.
Definition: Log.h:187
std::list< Aura * > AuraList
Definition: Unit.h:893
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition: Unit.cpp:9133
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4389
uint32 GetGUIDLow() const
Definition: Object.h:160
void AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:13382
void SetAuraProcCharges(int32 charges)
Definition: SpellAuras.h:417
Player * ToPlayer()
Definition: Object.h:386
AuraList m_interruptableAuras
Definition: Unit.h:2149
uint8 GetTypeId() const
Definition: Object.h:204
bool IsAlive() const
Definition: Unit.h:1433
void UpdateAuraDuration()
Definition: SpellAuras.cpp:810
uint32 StackAmount
Definition: DBCStructure.h:717
#define sSpellMgr
Definition: SpellMgr.h:1239
Modifier * GetModifier()
Definition: SpellAuras.h:220
#define DEBUG_LOG(...)
Definition: Log.h:194
AuraList & GetSingleCastAuras()
Definition: Unit.h:1810
uint64 const & GetCasterGUID() const
Definition: SpellAuras.h:303
AuraList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2147
int32 GetStackAmount()
Definition: SpellAuras.h:442
#define ASSERT
Definition: Errors.h:33
WorldSession * GetSession() const
Definition: Player.h:1959
ACE_UINT32 uint32
Definition: Define.h:71
void AddInterruptMask(uint32 mask)
Definition: Unit.h:1885
Definition: Unit.h:884
bool PlayerLoading() const
Definition: WorldSession.h:73
AuraMap m_Auras
Definition: Unit.h:2135
void UpdateAuraCharges()
Definition: SpellAuras.h:334
uint32 GetId() const
Definition: SpellAuras.h:249
void Unit::AddComboPointHolder ( uint32  lowguid)
inline

Definition at line 2028 of file Unit.h.

Referenced by Player::AddComboPoints().

2029  {
2030  m_ComboPointHolders.insert(lowguid);
2031  }
ComboPointHolderSet m_ComboPointHolders
Definition: Unit.h:2203
void Unit::AddDynObject ( DynamicObject dynObj)

Definition at line 4594 of file Unit.cpp.

References Object::GetGUID(), and m_dynObjGUIDs.

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

4595 {
4596  m_dynObjGUIDs.push_back(dynObj->GetGUID());
4597 }
DynObjectGUIDs m_dynObjGUIDs
Definition: Unit.h:2140
const uint64 & GetGUID() const
Definition: Object.h:156
void Unit::addFollower ( FollowerReference pRef)
inline

Definition at line 1989 of file Unit.h.

Referenced by FollowerReference::targetObjectBuildLink().

1990  {
1992  }
FollowerRefManager m_FollowingRefManager
Definition: Unit.h:2201
void insertFirst(LinkedListElement *pElem)
Definition: LinkedList.h:105
void Unit::AddGameObject ( GameObject gameObj)

Definition at line 4665 of file Unit.cpp.

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

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

4666 {
4667  if (!gameObj || gameObj->GetOwnerGUID() != 0)
4668  return;
4669 
4670  m_gameObj.push_back(gameObj);
4671  gameObj->SetOwnerGUID(GetGUID());
4672 }
uint64 GetOwnerGUID() const
Definition: GameObject.h:662
std::list< GameObject * > m_gameObj
Definition: Unit.h:2142
void SetOwnerGUID(uint64 owner)
Definition: GameObject.h:654
const uint64 & GetGUID() const
Definition: Object.h:156
void Unit::addHatedBy ( HostileReference pHostileReference)
inline

Definition at line 1834 of file Unit.h.

1835  {
1836  m_HostileRefManager.insertFirst(pHostileReference);
1837  };
HostileRefManager m_HostileRefManager
Definition: Unit.h:2199
void insertFirst(LinkedListElement *pElem)
Definition: LinkedList.h:105
void Unit::AddInterruptMask ( uint32  mask)
inline

Definition at line 1885 of file Unit.h.

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

1886  {
1887  m_interruptMask |= mask;
1888  }
uint32 m_interruptMask
Definition: Unit.h:2151
void Unit::AddPetAura ( PetAura const *  petSpell)

Definition at line 12248 of file Unit.cpp.

References TYPEID_PLAYER.

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

12249 {
12250  if (GetTypeId() != TYPEID_PLAYER)
12251  return;
12252 
12253  m_petAuras.insert(petSpell);
12254  if (Pet* pet = ToPlayer()->GetPet())
12255  pet->CastPetAura(petSpell);
12256 }
Player * ToPlayer()
Definition: Object.h:386
uint8 GetTypeId() const
Definition: Object.h:204
PetAuraSet m_petAuras
Definition: Unit.h:2065
Definition: Pet.h:146
void Unit::AddPlayerToVision ( Player plr)

Definition at line 7858 of file Unit.cpp.

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

7859 {
7860  if (m_sharedVision.empty())
7861  {
7862  setActive(true);
7863  SetWorldObject(true);
7864  }
7865  m_sharedVision.push_back(plr);
7866 }
void setActive(bool isActiveObject)
Definition: Object.cpp:1122
SharedVisionList m_sharedVision
Definition: Unit.h:2162
void SetWorldObject(bool apply)
Definition: Object.cpp:1103
void Unit::AddThreat ( Unit victim,
float  threat,
SpellSchoolMask  schoolMask = SPELL_SCHOOL_MASK_NORMAL,
SpellEntry const *  threatSpell = NULL 
)

Definition at line 10129 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().

10130 {
10131  // Only mobs can manage threat lists
10133  m_ThreatManager.addThreat(victim, fThreat, schoolMask, threatSpell);
10134 }
ThreatManager m_ThreatManager
Definition: Unit.h:2172
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1002
bool CanHaveThreatList() const
Definition: Unit.cpp:10090
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 11050 of file Unit.cpp.

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

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

11051 {
11052  if (!IsInWorld())
11054 }
const bool & IsInWorld() const
Definition: Object.h:129
virtual void AddToWorld()
Definition: Object.h:133
void Unit::AddUnitMovementFlag ( uint32  f)
inline

Definition at line 2012 of file Unit.h.

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

2012 { m_movementInfo.moveFlags |= f; }
MovementInfo m_movementInfo
Definition: Object.h:915
uint32 moveFlags
Definition: Object.h:449
void Unit::AddUnitTypeMask ( uint32  mask)
inline

Definition at line 1017 of file Unit.h.

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

Definition at line 12044 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().

12045 {
12046  float remainingTimePct = (float)m_attackTimer[att] / (GetAttackTime(att) * m_modAttackSpeedPct[att]);
12047  if (val > 0)
12048  {
12051  }
12052  else
12053  {
12056  }
12057  m_attackTimer[att] = uint32(GetAttackTime(att) * m_modAttackSpeedPct[att] * remainingTimePct);
12058 }
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:1090
float m_modAttackSpeedPct[3]
Definition: Unit.h:1741
void ApplyPercentModFloatVar(float &var, float val, bool apply)
Definition: Util.h:94
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2126
ACE_UINT32 uint32
Definition: Define.h:71
void Unit::ApplyAuraProcTriggerDamage ( Aura aura,
bool  apply 
)

Definition at line 11023 of file Unit.cpp.

References m_modAuras, and SPELL_AURA_PROC_TRIGGER_DAMAGE.

11024 {
11025  AuraList& tAuraProcTriggerDamage = m_modAuras[SPELL_AURA_PROC_TRIGGER_DAMAGE];
11026  if (apply)
11027  tAuraProcTriggerDamage.push_back(aura);
11028  else
11029  tAuraProcTriggerDamage.remove(aura);
11030 }
std::list< Aura * > AuraList
Definition: Unit.h:893
void apply(T *val)
Definition: ByteConverter.h:41
AuraList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2147
void Unit::ApplyCastTimePercentMod ( float  val,
bool  apply 
)

Definition at line 12060 of file Unit.cpp.

References UNIT_MOD_CAST_SPEED.

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

12061 {
12062  if (val > 0)
12064  else
12066 }
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 10562 of file Unit.cpp.

References getMSTime(), and m_Diminishing.

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

10563 {
10564  // Checking for existing in the table
10565  for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
10566  {
10567  if (i->DRGroup != group)
10568  continue;
10569 
10570  i->hitTime = getMSTime();
10571 
10572  if (apply)
10573  i->stack += 1;
10574  else if (i->stack)
10575  i->stack -= 1;
10576 
10577  break;
10578  }
10579 }
uint32 getMSTime()
Definition: Timer.h:32
Diminishing m_Diminishing
Definition: Unit.h:2195
void apply(T *val)
Definition: ByteConverter.h:41
void Unit::ApplyDiminishingToDuration ( DiminishingGroup  group,
int32 duration,
Unit caster,
DiminishingLevels  Level 
)

Definition at line 10511 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().

10512 {
10513  if (duration == -1 || group == DIMINISHING_NONE)
10514  return;
10515 
10516  // Creatures other then pets do not suffer from Diminishing Returns
10517  if (caster->GetTypeId() == TYPEID_UNIT && !caster->GetOwner())
10518  return;
10519 
10520  // Test pet/charm masters instead pets/charmedsz
10521  Unit const* targetOwner = GetCharmerOrOwner();
10522  Unit const* casterOwner = caster->GetCharmerOrOwner();
10523 
10524  // Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0)
10525  if (duration > 10000 && IsDiminishingReturnsGroupDurationLimited(group))
10526  {
10527  Unit const* target = targetOwner ? targetOwner : this;
10528  Unit const* source = casterOwner ? casterOwner : caster;
10529 
10530  if (target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER)
10531  if (source != target || GetTypeId() != TYPEID_UNIT)
10532  duration = 10000;
10533  }
10534 
10535  float mod = 1.0f;
10536 
10537  // Some diminishings applies to mobs too (for example, Stun)
10538  if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && (targetOwner ? targetOwner->GetTypeId() : GetTypeId()) == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL)
10539  {
10540  DiminishingLevels diminish = Level;
10541  switch (diminish)
10542  {
10543  case DIMINISHING_LEVEL_1:
10544  break;
10545  case DIMINISHING_LEVEL_2:
10546  mod = 0.5f;
10547  break;
10548  case DIMINISHING_LEVEL_3:
10549  mod = 0.25f;
10550  break;
10552  mod = 0.0f;
10553  break;
10554  default:
10555  break;
10556  }
10557  }
10558 
10559  duration = int32(duration * mod);
10560 }
bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group)
Definition: SpellMgr.cpp:3163
DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group)
Definition: SpellMgr.cpp:3188
ACE_INT32 int32
Definition: Define.h:67
uint8 GetTypeId() const
Definition: Object.h:204
DiminishingLevels
Definition: Unit.h:619
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1519
Unit * GetOwner() const
Definition: Unit.cpp:7549
Definition: Unit.h:884
void Unit::ApplyMaxPowerMod ( Powers  power,
uint32  val,
bool  apply 
)

Definition at line 11001 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.

11002 {
11004 
11005  // group update
11006  if (GetTypeId() == TYPEID_PLAYER)
11007  {
11008  if (ToPlayer()->GetGroup())
11010  }
11011  else if (IsPet())
11012  {
11013  Pet* pet = ((Pet*)this);
11014  if (pet->isControlled())
11015  {
11016  Unit* owner = GetOwner();
11017  if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
11019  }
11020  }
11021 }
Group * GetGroup()
Definition: Player.h:2589
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:386
uint8 GetTypeId() const
Definition: Object.h:204
bool isControlled() const
Definition: Pet.h:163
bool IsPet() const
Definition: Unit.h:1020
Unit * GetOwner() const
Definition: Unit.cpp:7549
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2610
Definition: Unit.h:884
Definition: Pet.h:146
void Unit::ApplyPowerMod ( Powers  power,
uint32  val,
bool  apply 
)

Definition at line 10979 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().

10980 {
10982 
10983  // group update
10984  if (GetTypeId() == TYPEID_PLAYER)
10985  {
10986  if (ToPlayer()->GetGroup())
10988  }
10989  else if (IsPet())
10990  {
10991  Pet* pet = ((Pet*)this);
10992  if (pet->isControlled())
10993  {
10994  Unit* owner = GetOwner();
10995  if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
10997  }
10998  }
10999 }
Group * GetGroup()
Definition: Player.h:2589
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:386
uint8 GetTypeId() const
Definition: Object.h:204
bool isControlled() const
Definition: Pet.h:163
bool IsPet() const
Definition: Unit.h:1020
Unit * GetOwner() const
Definition: Unit.cpp:7549
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2610
Definition: Unit.h:884
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 9165 of file Unit.cpp.

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

Referenced by Aura::HandleAuraModDispelImmunity().

9166 {
9167  ApplySpellImmune(spellProto->Id, IMMUNITY_DISPEL, type, apply);
9168 
9171 }
uint32 AttributesEx
Definition: DBCStructure.h:680
void RemoveAurasWithDispelType(DispelType type)
Definition: Unit.cpp:4252
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition: Unit.cpp:9133
void apply(T *val)
Definition: ByteConverter.h:41
void Unit::ApplySpellImmune ( uint32  spellId,
uint32  op,
uint32  type,
bool  apply 
)

Definition at line 9133 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().

9134 {
9135  if (apply)
9136  {
9137  for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next)
9138  {
9139  next = itr; ++next;
9140  if (itr->type == type)
9141  {
9142  m_spellImmune[op].erase(itr);
9143  next = m_spellImmune[op].begin();
9144  }
9145  }
9146  SpellImmune Immune;
9147  Immune.spellId = spellId;
9148  Immune.type = type;
9149  m_spellImmune[op].push_back(Immune);
9150  }
9151  else
9152  {
9153  for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr)
9154  {
9155  if (itr->spellId == spellId && itr->type == type)
9156  {
9157  m_spellImmune[op].erase(itr);
9158  break;
9159  }
9160  }
9161  }
9162 
9163 }
uint32 spellId
Definition: Unit.h:322
void apply(T *val)
Definition: ByteConverter.h:41
uint32 type
Definition: Unit.h:321
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1819
void Unit::ApplyStatBuffMod ( Stats  stat,
float  val,
bool  apply 
)
inline

Definition at line 1642 of file Unit.h.

References UNIT_FIELD_NEGSTAT0, and UNIT_FIELD_POSSTAT0.

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

1643  {
1644  ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0 + stat : UNIT_FIELD_NEGSTAT0 + stat), val, apply);
1645  }
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 1646 of file Unit.h.

References UNIT_FIELD_NEGSTAT0, and UNIT_FIELD_POSSTAT0.

Referenced by Aura::HandleModTotalPercentStat().

1647  {
1650  }
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 10117 of file Unit.cpp.

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

Referenced by ThreatCalcHelper::calcThreat().

10118 {
10119  if (!HasAuraType(SPELL_AURA_MOD_THREAT) || fThreat < 0)
10120  return fThreat;
10121 
10122  SpellSchools school = GetFirstSchoolInMask(schoolMask);
10123 
10124  return fThreat * m_threatModifier[school];
10125 }
SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask)
SpellSchools
float m_threatModifier[MAX_SPELL_SCHOOL]
Definition: Unit.h:1740
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:783
bool Unit::Attack ( Unit victim,
bool  meleeAttack 
)

Definition at line 7315 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(), SendMeleeAttackStart(), SetInCombatWith(), SetTarget(), SMSG_AI_REACTION, SPELL_AURA_MOD_UNATTACKABLE, Object::ToCreature(), Object::ToPlayer(), TYPEID_PLAYER, TYPEID_UNIT, 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().

7316 {
7317  if (!victim || victim == this)
7318  return false;
7319 
7320  // dead units can neither attack nor be attacked
7321  if (!IsAlive() || !victim->IsInWorld() || !victim->IsAlive())
7322  return false;
7323 
7324  // player cannot attack in mount state
7325  if (GetTypeId() == TYPEID_PLAYER && IsMounted())
7326  return false;
7327 
7329  return false;
7330 
7331  // nobody can attack GM in GM-mode
7332  if (victim->GetTypeId() == TYPEID_PLAYER)
7333  {
7334  if (victim->ToPlayer()->IsGameMaster())
7335  return false;
7336  }
7337  else
7338  {
7339  if (victim->ToCreature()->IsInEvadeMode())
7340  return false;
7341  }
7342 
7343  // remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack)
7346 
7347  if (m_attacking)
7348  {
7349  if (m_attacking == victim)
7350  {
7351  // switch to melee attack from ranged/magic
7352  if (meleeAttack && !HasUnitState(UNIT_STATE_MELEE_ATTACKING))
7353  {
7355  SendMeleeAttackStart(victim);
7356  return true;
7357  }
7358  return false;
7359  }
7360  AttackStop();
7361  }
7362 
7363  // Set our target
7364  SetTarget(victim->GetGUID());
7365 
7366  if (meleeAttack)
7368 
7369  m_attacking = victim;
7370  m_attacking->_addAttacker(this);
7371 
7372  if (GetTypeId() == TYPEID_UNIT && !IsPet())
7373  {
7374  // should not let player enter combat by right clicking target
7375  SetInCombatWith(victim);
7376  if (victim->GetTypeId() == TYPEID_PLAYER)
7377  victim->SetInCombatWith(this);
7378  AddThreat(victim, 0.0f);
7379 
7380  WorldPacket data(SMSG_AI_REACTION, 12);
7381  data << uint64(GetGUID());
7382  data << uint32(AI_REACTION_HOSTILE); // Aggro sound
7383  ((WorldObject*)this)->SendMessageToSet(&data, true);
7384 
7386  }
7387 
7388  // delay offhand weapon attack to next attack time
7389  if (haveOffhandWeapon())
7391 
7392  if (meleeAttack)
7393  SendMeleeAttackStart(victim);
7394 
7395  // Let the pet know we've started attacking someting. Handles melee attacks only
7396  // Spells such as auto-shot and others handled in WorldSession::HandleCastSpellOpcode
7397  if (this->GetTypeId() == TYPEID_PLAYER)
7398  {
7399  Pet* playerPet = this->ToPlayer()->GetPet();
7400 
7401  if (playerPet && playerPet->IsAlive())
7402  playerPet->AI()->OwnerAttacked(victim);
7403  }
7404 
7405  return true;
7406 }
bool AttackStop()
Definition: Unit.cpp:7408
void SetTarget(uint64 guid=0)
Definition: Unit.h:1700
void AddUnitState(uint32 f)
Definition: Unit.h:998
void AddThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell=NULL)
Definition: Unit.cpp:10129
void RemoveSpellsCausingAura(AuraType auraType)
Definition: Unit.cpp:648
bool IsInEvadeMode() const
Definition: Creature.cpp:2284
bool IsGameMaster() const
Definition: Player.h:1009
virtual void OwnerAttacked(Unit *)
Definition: CreatureAI.h:167
Player * ToPlayer()
Definition: Object.h:386
void CallAssistance()
Definition: Creature.cpp:1906
uint8 GetTypeId() const
Definition: Object.h:204
const bool & IsInWorld() const
Definition: Object.h:129
bool IsAlive() const
Definition: Unit.h:1433
void _addAttacker(Unit *pAttacker)
Definition: Unit.h:956
Unit * m_attacking
Definition: Unit.h:2131
CreatureAI * AI() const
Definition: Creature.h:548
void SendMeleeAttackStart(Unit *victim)
Definition: Unit.cpp:2581
bool haveOffhandWeapon() const
Definition: Unit.cpp:575
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:583
bool IsPet() const
Definition: Unit.h:1020
ACE_UINT64 uint64
Definition: Define.h:70
Creature * ToCreature()
Definition: Object.h:389
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1002
bool IsMounted() const
Definition: Unit.h:1173
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:783
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:299
ACE_UINT32 uint32
Definition: Define.h:71
Pet * GetPet() const
Definition: Player.cpp:17104
Definition: Pet.h:146
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9255
const uint64 & GetGUID() const
Definition: Object.h:156
void Unit::AttackerStateUpdate ( Unit victim,
WeaponAttackType  attType = BASE_ATTACK,
bool  extra = false 
)

Definition at line 2287 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(), Player::Update(), ReactorAI::UpdateAI(), and guardAI::UpdateAI().

2288 {
2290  return;
2291 
2292  if (!victim->IsAlive())
2293  return;
2294 
2295  if ((attType == BASE_ATTACK || attType == OFF_ATTACK) && !IsWithinLOSInMap(victim))
2296  return;
2297 
2299 
2300  if (attType != BASE_ATTACK && attType != OFF_ATTACK)
2301  return; // ignore ranged case
2302 
2303  // melee attack spell casted at main hand attack only
2304  if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra)
2305  {
2307  return;
2308  }
2309 
2310  CalcDamageInfo damageInfo;
2311  CalculateMeleeDamage(victim, 0, &damageInfo, attType);
2312  // Send log damage message to client
2313  SendAttackStateUpdate(&damageInfo);
2314 
2315  ProcDamageAndSpell(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, damageInfo.procEx, damageInfo.damage, damageInfo.attackType);
2316 
2317  DealMeleeDamage(&damageInfo, true);
2318 
2319  // We call this last because DealMeleeDamage has to check for sit state to
2320  // allow critical hits, but we set STANDING in CombatStart, therefore always
2321  // nullifying the check.
2322  CombatStart(victim);
2323 
2324  #ifdef OREGON_DEBUG
2325  if (GetTypeId() == TYPEID_PLAYER)
2326  DEBUG_LOG("AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
2327  GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
2328  else
2329  DEBUG_LOG("AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
2330  GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
2331  #endif
2332 
2333 }
uint32 procAttacker
Definition: Unit.h:668
uint32 blocked_amount
Definition: Unit.h:663
void CalculateMeleeDamage(Unit *victim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK)
Definition: Unit.cpp:1552
uint32 procVictim
Definition: Unit.h:669
uint32 resist
Definition: Unit.h:662
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2191
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
Definition: Unit.cpp:1761
bool IsWithinLOSInMap(const WorldObject *obj) const
Definition: Object.cpp:1226
uint32 GetGUIDLow() const
Definition: Object.h:160
uint32 procEx
Definition: Unit.h:670
WeaponAttackType attackType
Definition: Unit.h:667
uint8 GetTypeId() const
Definition: Object.h:204
void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except=0)
Definition: Unit.cpp:687
bool IsAlive() const
Definition: Unit.h:1433
uint32 absorb
Definition: Unit.h:661
#define DEBUG_LOG(...)
Definition: Log.h:194
void SendAttackStateUpdate(CalcDamageInfo *damageInfo)
Definition: Unit.cpp:4825
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:4787
Unit * target
Definition: Unit.h:658
void CombatStart(Unit *target, bool initialAggro=true)
Definition: Unit.cpp:9277
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1002
uint32 damage
Definition: Unit.h:660
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:299
void cast(bool skipCheck=false)
Definition: Spell.cpp:2407
bool Unit::AttackStop ( )

Definition at line 7408 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(), RotateMovementGenerator::Initialize(), PetAI::KilledUnit(), MotionMaster::MoveSeekAssistance(), and PossessedAI::UpdateAI().

7409 {
7410  if (!m_attacking)
7411  return false;
7412 
7413  Unit* victim = m_attacking;
7414 
7416  m_attacking = NULL;
7417 
7418  // Clear our target
7419  SetTarget(0);
7420 
7422 
7424 
7425  // reset only at real combat stop
7426  if (Creature* creature = ToCreature())
7427  {
7428  creature->SetNoCallAssistance(false);
7429 
7430  if (creature->HasSearchedAssistance())
7431  {
7432  creature->SetNoSearchAssistance(false);
7433  UpdateSpeed(MOVE_RUN, false);
7434  }
7435  }
7436 
7437  SendMeleeAttackStop(victim);
7438 
7439  return true;
7440 }
void SetTarget(uint64 guid=0)
Definition: Unit.h:1700
void SendMeleeAttackStop(Unit *victim=NULL)
Definition: Unit.cpp:2590
void UpdateSpeed(UnitMoveType mtype, bool forced)
Definition: Unit.cpp:9806
void ClearUnitState(uint32 f)
Definition: Unit.h:1006
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:3455
Unit * m_attacking
Definition: Unit.h:2131
Definition: Unit.h:461
void _removeAttacker(Unit *pAttacker)
Definition: Unit.h:962
Creature * ToCreature()
Definition: Object.h:389
Definition: Unit.h:884
void Unit::BuildHeartBeatMsg ( WorldPacket data) const

Definition at line 1923 of file Object.cpp.

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

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

1924 {
1925  data->Initialize(MSG_MOVE_HEARTBEAT, 32);
1926  *data << GetPackGUID();
1927  BuildMovementPacket(data);
1928 }
void BuildMovementPacket(ByteBuffer *data) const
Definition: Unit.cpp:13493
void Initialize(uint16 opcode, size_t newres=200)
Definition: WorldPacket.h:37
PackedGuid const & GetPackGUID() const
Definition: Object.h:172
void Unit::BuildMovementPacket ( ByteBuffer data) const

Definition at line 13493 of file Unit.cpp.

References getMSTime().

Referenced by SetSpeed().

13494 {
13495  *data << uint32(GetUnitMovementFlags()); // movement flags
13496  *data << uint8(0); // 2.3.0 @todo: Implement extra movement flags
13497  *data << uint32(getMSTime()); // time / counter
13498  *data << float(GetPositionX());
13499  *data << float(GetPositionY());
13500  *data << float(GetPositionZ());
13501  *data << float(GetOrientation());
13502  *data << uint32(0);
13503 }
uint32 GetUnitMovementFlags() const
Definition: Unit.h:2015
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 2025 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(), Spell::EffectEnvironmentalDMG(), Player::EnvironmentalDamage(), ChatHandler::HandleDamageCommand(), and Aura::PeriodicTick().

2026 {
2027  if (!victim || !victim->IsAlive() || !damage)
2028  return;
2029 
2030  // Magic damage, check for resists
2031  if (!spellInfo || (spellInfo->AttributesEx4 & SPELL_ATTR4_IGNORE_RESISTANCES) == 0 && (schoolMask & SPELL_SCHOOL_MASK_MAGIC) && (!binary || damagetype == DOT))
2032  {
2033  const float mitigation = CalculateMagicResistanceMitigation(victim, CalculateEffectiveMagicResistance(victim, schoolMask), false);
2034  const SpellPartialResistChanceEntry &chances = SPELL_PARTIAL_RESIST_DISTRIBUTION.at(uint32(mitigation * 10000));
2035  // We choose which portion of damage is resisted below, none by default
2036  uint8 portion = SPELL_PARTIAL_RESIST_NONE;
2037  // If we got to this point, we already rolled for full resist on hit
2038  // We do a roll between remaining chances
2039  const uint8 outcomes = (NUM_SPELL_PARTIAL_RESISTS - 1);
2040  const uint32 roll = urand(1, (10000 - chances.at(SPELL_PARTIAL_RESIST_PCT_100)));
2041  uint32 sum = 0;
2042  for (uint8 outcome = SPELL_PARTIAL_RESIST_NONE; outcome < outcomes; ++outcome)
2043  {
2044  if (const uint32 chance = chances.at(outcome))
2045  {
2046  sum += chance;
2047  if (roll <= sum)
2048  {
2049  portion = outcome;
2050  break;
2051  }
2052  }
2053  }
2054  const uint32 amount = uint32(damage * (portion * (1.0f / float(outcomes))));
2055  // We already rolled for full resist on hit, so we need to deal at least *some* amount of damage...
2056  *resist = (amount >= damage) ? (damage - 1) : amount;
2057  }
2058  else
2059  *resist = 0;
2060 
2061  int32 RemainingDamage = damage - *resist;
2062 
2063  // Paladin Blessed Life 4/7/10% chance to cause 50% dmg
2064  AuraList const& blessedLife = victim->GetAurasByType(SPELL_AURA_REUSED_BLESSED_LIFE);
2065  AuraList::const_iterator blessedAura = blessedLife.begin();
2066  if (blessedAura != blessedLife.end() && *blessedAura)
2067  {
2068  if (urand(0, 100) <= (*blessedAura)->GetSpellProto()->procChance)
2069  RemainingDamage /= 2;
2070  }
2071 
2072  // Need to remove expired auras after
2073  bool expiredExists = false;
2074 
2075  // absorb without mana cost
2076  int32 reflectDamage = 0;
2077  Aura* reflectAura = NULL;
2078  AuraList const& vSchoolAbsorb = victim->GetAurasByType(SPELL_AURA_SCHOOL_ABSORB);
2079  for (AuraList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end() && RemainingDamage > 0; ++i)
2080  {
2081  int32* p_absorbAmount = &(*i)->GetModifier()->m_amount;
2082 
2083  // should not happen....
2084  if (*p_absorbAmount <= 0)
2085  {
2086  expiredExists = true;
2087  continue;
2088  }
2089 
2090  if (((*i)->GetModifier()->m_miscvalue & schoolMask) == 0)
2091  continue;
2092 
2093  // Cheat Death
2094  if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_ROGUE && (*i)->GetSpellProto()->SpellIconID == 2109)
2095  {
2096  if (victim->ToPlayer()->HasSpellCooldown(31231))
2097  continue;
2098  if (int32(victim->GetHealth()) <= RemainingDamage)
2099  {
2100  int32 chance = *p_absorbAmount;
2101  if (roll_chance_i(chance))
2102  {
2103  victim->CastSpell(victim, 31231, true);
2104  victim->ToPlayer()->AddSpellCooldown(31231, 0, time(NULL) + 60);
2105 
2106  // with health > 10% lost health until health == 10%, in other case no losses
2107  uint32 health10 = victim->CountPctFromMaxHealth(10);
2108  RemainingDamage = victim->GetHealth() > health10 ? victim->GetHealth() - health10 : 0;
2109  }
2110  }
2111  continue;
2112  }
2113 
2114  int32 currentAbsorb;
2115 
2116  //Reflective Shield
2117  if ((victim != this) && (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST && (*i)->GetSpellProto()->SpellFamilyFlags == 0x1)
2118  {
2119  if (Unit* caster = (*i)->GetCaster())
2120  {
2121  AuraList const& vOverRideCS = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);