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

#include <Unit.h>

+ Inheritance diagram for Unit:

Public Types

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

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

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

Protected Types

typedef std::list< uint64DynObjectGUIDs
 

Protected Member Functions

 Unit (bool isWorldObject)
 
void _UpdateSpells (uint32 time)
 
void _DeleteAuras ()
 
void _UpdateAutoRepeatSpell ()
 
virtual SpellSchoolMask GetMeleeDamageSchoolMask () const
 
void DisableSpline ()
 
bool IsAlwaysVisibleFor (WorldObject const *seer) const override
 
bool IsAlwaysDetectableFor (WorldObject const *seer) const override
 
virtual void SetBaseWalkSpeed (float speed)
 
virtual void SetBaseRunSpeed (float speed)
 
- 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
 
float m_baseSpeedWalk
 
float m_baseSpeedRun
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
float m_visibilityDistanceOverride
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
uint8 m_objectTypeId
 
uint8 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
uint32m_uint32Values_mirror
 
uint16 m_valuesCount
 
bool m_objectUpdated
 

Private Member Functions

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

Private Attributes

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

Friends

class ScriptEvent
 

Detailed Description

Definition at line 908 of file Unit.h.

Member Typedef Documentation

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

Definition at line 913 of file Unit.h.

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

Definition at line 917 of file Unit.h.

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

Definition at line 916 of file Unit.h.

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

Definition at line 919 of file Unit.h.

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

Definition at line 920 of file Unit.h.

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

Definition at line 914 of file Unit.h.

Definition at line 918 of file Unit.h.

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

Definition at line 2031 of file Unit.h.

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

Definition at line 1956 of file Unit.h.

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

Definition at line 915 of file Unit.h.

Constructor & Destructor Documentation

Unit::~Unit ( )
override

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

478 {
479  // set current spells as deletable
480  for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
481  if (m_currentSpells[i])
482  {
484  m_currentSpells[i] = NULL;
485  }
486 
489  _DeleteAuras();
490 
491  delete m_charmInfo;
492  delete movespline;
493 
496  ASSERT(m_attackers.empty());
497  ASSERT(m_sharedVision.empty());
498 }
bool m_duringRemoveFromWorld
Definition: Unit.h:2105
Movement::MoveSpline * movespline
Definition: Unit.h:1910
SharedVisionList m_sharedVision
Definition: Unit.h:2054
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2088
void _DeleteAuras()
Definition: Unit.cpp:3365
CharmInfo * m_charmInfo
Definition: Unit.h:2053
ACE_UINT8 uint8
Definition: Define.h:73
Unit * m_attacking
Definition: Unit.h:2023
#define CURRENT_MAX_SPELL
Definition: Unit.h:744
AttackerSet m_attackers
Definition: Unit.h:2022
#define ASSERT
Definition: Errors.h:29
void RemoveAllGameObjects()
Definition: Unit.cpp:4824
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:482
void RemoveAllDynObjects()
Definition: Unit.cpp:4704
Unit::Unit ( bool  isWorldObject)
explicitprotected

Definition at line 364 of file Unit.cpp.

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

364  :
365  WorldObject(isWorldObject), IsAIEnabled(false),
366  NeedChangeAI(false),
367  LastCharmerGUID(0),
368  m_ControlledByPlayer(false),
369  i_AI(NULL),
370  i_disabledAI(NULL),
372  i_motionMaster(this),
373  m_ThreatManager(this),
374  m_HostileRefManager(this),
376  m_procDeep(0),
380 {
383 
385 
392 
393  m_extraAttacks = 0;
394  m_canDualWield = false;
395 
396  m_state = 0;
397  m_form = FORM_NONE;
399 
400  for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
401  m_currentSpells[i] = NULL;
402 
403  for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
404  m_SummonSlot[i] = 0;
405 
406  m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0;
407 
409  m_AuraFlags = 0;
410 
411  m_interruptMask = 0;
412  m_transform = 0;
414  m_canModifyStats = false;
415 
416  for (uint8 i = 0; i < MAX_SPELL_IMMUNITY; ++i)
417  m_spellImmune[i].clear();
418 
419  for (uint8 i = 0; i < UNIT_MOD_END; ++i)
420  {
421  m_auraModifiersGroup[i][BASE_VALUE] = 0.0f;
422  m_auraModifiersGroup[i][BASE_PCT] = 1.0f;
424  m_auraModifiersGroup[i][TOTAL_PCT] = 1.0f;
425  }
426  // implement 50% base damage from offhand
428 
429  for (uint8 i = 0; i < MAX_ATTACK; ++i)
430  {
433  }
434 
435  for (uint8 i = 0; i < MAX_STATS; ++i)
436  m_createStats[i] = 0.0f;
437 
438  m_attacking = NULL;
439  m_modMeleeHitChance = 0.0f;
440  m_modRangedHitChance = 0.0f;
441  m_modSpellHitChance = 0.0f;
443 
444  m_initiatingCombat = false;
445 
447  m_lastManaUse = 0;
448 
449  for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
450  m_threatModifier[i] = 1.0f;
451 
452  m_isSorted = true;
453 
454  for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
455  m_speed_rate[i] = 1.0f;
456 
458 
459  m_charmInfo = NULL;
462 
463  // remove aurastates allowing special moves
464  for (uint8 i = 0; i < MAX_REACTIVE; ++i)
465  m_reactiveTimer[i] = 0;
466 
467  m_duringRemoveFromWorld = false;
468 
469  m_baseSpeedWalk = 0.f;
470  m_baseSpeedRun = 0.f;
471 
472  _oldFactionId = 0;
473 
475 }
#define BASE_MINDAMAGE
Definition: Unit.h:157
uint32 m_removedAurasCount
Definition: Unit.h:2029
#define MAX_MOVE_TYPE
Definition: Unit.h:494
bool m_ControlledByPlayer
Definition: Unit.h:1995
float m_modMeleeHitChance
Definition: Unit.h:1625
bool m_duringRemoveFromWorld
Definition: Unit.h:2105
int32 m_baseSpellCritChance
Definition: Unit.h:1628
Movement::MoveSpline * movespline
Definition: Unit.h:1910
#define MAX_ATTACK
Definition: Unit.h:505
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:809
uint32 m_reducedThreatPercent
Definition: Unit.h:2102
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2088
CharmInfo * m_charmInfo
Definition: Unit.h:2053
bool m_isSorted
Definition: Unit.h:2035
Definition: Unit.h:437
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:602
uint32 m_lastSanctuaryTime
Definition: Unit.h:1711
uint32 m_reactiveTimer[MAX_REACTIVE]
Definition: Unit.h:2062
float m_speed_rate[MAX_MOVE_TYPE]
Definition: Unit.h:2050
TimeTrackerSmall m_movesplineTimer
Definition: Unit.h:2090
float m_baseSpeedRun
Definition: Unit.h:2076
uint64 LastCharmerGUID
Definition: Unit.h:1994
bool IsAIEnabled
Definition: Unit.h:1993
uint16 m_objectType
Definition: Object.h:400
uint32 m_transform
Definition: Unit.h:2036
#define MAX_SPELL_SCHOOL
uint64 m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1607
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2045
uint32 _oldFactionId
Definition: Unit.h:1633
time_t _lastDamagedTime
Definition: Unit.h:2109
uint32 m_state
Definition: Unit.h:2085
void SetInterval(time_t interval)
Definition: Timer.h:122
uint32 m_lastManaUse
Definition: Unit.h:2086
UnitAI * i_AI
Definition: Unit.h:2007
UnitAI * i_disabledAI
Definition: Unit.h:2007
uint64 m_misdirectionTargetGUID
Definition: Unit.h:2103
#define MAX_SPELL_IMMUNITY
#define MAX_STATS
float m_baseSpeedWalk
Definition: Unit.h:2075
uint8 m_objectTypeId
Definition: Object.h:402
float m_modSpellHitChance
Definition: Unit.h:1627
ACE_UINT8 uint8
Definition: Define.h:73
uint8 m_updateFlag
Definition: Object.h:403
DeathState m_deathState
Definition: Unit.h:2025
Unit * m_attacking
Definition: Unit.h:2023
HostileRefManager m_HostileRefManager
Definition: Unit.h:2096
float m_modAttackSpeedPct[3]
Definition: Unit.h:1631
#define BASE_MAXDAMAGE
Definition: Unit.h:158
float m_createStats[MAX_STATS]
Definition: Unit.h:2020
bool NeedChangeAI
Definition: Unit.h:1993
#define MAX_REACTIVE
Definition: Unit.h:894
uint32 m_AuraFlags
Definition: Unit.h:1770
ThreatManager m_ThreatManager
Definition: Unit.h:2064
uint32 m_ShapeShiftFormSpellId
Definition: Unit.h:1610
uint32 m_extraAttacks
Definition: Unit.h:990
WorldObject(bool isWorldObject)
Definition: Object.cpp:1085
MotionMaster i_motionMaster
Definition: Unit.h:2058
#define CURRENT_MAX_SPELL
Definition: Unit.h:744
bool m_canDualWield
Definition: Unit.h:991
uint32 m_unitTypeMask
Definition: Unit.h:2052
bool m_initiatingCombat
Definition: Unit.h:2016
uint32 m_interruptMask
Definition: Unit.h:2043
float m_threatModifier[MAX_SPELL_SCHOOL]
Definition: Unit.h:1630
#define MAX_SUMMON_SLOT
Definition: Unit.h:900
uint64 m_ObjectSlot[4]
Definition: Unit.h:1608
float m_modRangedHitChance
Definition: Unit.h:1626
Definition: Unit.h:354
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2018
IntervalTimer m_CombatTimer
Definition: Unit.h:1253
AuraMap::iterator m_AurasUpdateIterator
Definition: Unit.h:2028
uint32 m_procDeep
Definition: Unit.h:2107
float m_weaponDamage[MAX_ATTACK][2]
Definition: Unit.h:2046
AuraMap m_Auras
Definition: Unit.h:2027
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1710
bool m_canModifyStats
Definition: Unit.h:2047
ShapeshiftForm m_form
Definition: Unit.h:1612

Member Function Documentation

void Unit::_addAttacker ( Unit pAttacker)
inline

Definition at line 993 of file Unit.h.

Referenced by Attack().

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

Definition at line 4666 of file Unit.cpp.

References m_Auras.

Referenced by Player::_ApplyAllStatBonuses().

4667 {
4668  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
4669  (*i).second->ApplyModifier(true);
4670 }
AuraMap m_Auras
Definition: Unit.h:2027
void Unit::_DeleteAuras ( )
protected

Definition at line 3365 of file Unit.cpp.

References m_removedAuras.

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

3366 {
3367  while (!m_removedAuras.empty())
3368  {
3369  delete m_removedAuras.front();
3370  m_removedAuras.pop_front();
3371  }
3372 }
AuraList m_removedAuras
Definition: Unit.h:2037
bool Unit::_IsValidAssistTarget ( Unit const *  target,
SpellEntry const *  bySpell 
) const

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

9673 {
9674  ASSERT(target);
9675 
9676  // can assist to self
9677  if (this == target)
9678  return true;
9679 
9680  // can't assist unattackable units or GMs
9681  if (target->HasUnitState(UNIT_STATE_UNATTACKABLE)
9682  || target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
9683  return false;
9684 
9685  // can't assist invisible
9686  if (!CanSeeOrDetect(target))
9687  return false;
9688 
9689  // can't assist dead
9690  if (!target->IsAlive())
9691  return false;
9692 
9693  // can't assist untargetable
9694  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
9695  return false;
9696 
9697  if (!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
9698  {
9700  {
9701  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))
9702  return false;
9703  }
9704  else
9705  {
9706  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
9707  return false;
9708  }
9709  }
9710 
9711  // can't assist non-friendly targets
9712  if (GetReactionTo(target) < REP_NEUTRAL
9713  && target->GetReactionTo(this) < REP_NEUTRAL)
9714  return false;
9715 
9716  // PvP case
9717  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
9718  {
9719  Player const* targetPlayerOwner = target->GetAffectingPlayer();
9721  {
9722  Player const* selfPlayerOwner = GetAffectingPlayer();
9723  if (selfPlayerOwner && targetPlayerOwner)
9724  {
9725  // can't assist player which is dueling someone
9726  if (selfPlayerOwner != targetPlayerOwner
9727  && targetPlayerOwner->duel)
9728  return false;
9729  }
9730  // can't assist player in ffa_pvp zone from outside
9731  if ((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP)
9733  return false;
9734  // can't assist player out of sanctuary from sanctuary if has pvp enabled
9735  if (target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK0)
9737  return false;
9738  }
9739  }
9740  // PvC case - player can assist creature only if has specific type flags
9741  // !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) &&
9743  && (!bySpell || !(bySpell->AttributesEx6 & SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
9744  && !((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK0)))
9745  {
9746  if (Creature const* creatureTarget = target->ToCreature())
9747  return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST;
9748  }
9749  return true;
9750 }
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7237
DuelInfo * duel
Definition: Player.h:1798
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7685
Creature * ToCreature()
Definition: Object.h:371
#define ASSERT
Definition: Errors.h:29
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:281
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1612
Definition: Player.h:923
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.h:228
bool Unit::_IsValidAttackTarget ( Unit const *  target,
SpellEntry const *  bySpell,
WorldObject const *  obj = NULL 
) const

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

9560 {
9561  ASSERT(target);
9562 
9563  // can't attack self
9564  if (this == target)
9565  return false;
9566 
9567  // can't attack unattackable units or GMs
9568  if (target->HasUnitState(UNIT_STATE_UNATTACKABLE)
9569  || target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
9570  return false;
9571 
9572  // visibility checks
9573  // skip visibility check for GO casts, needs removal when go cast is implemented. Also ignore for gameobject and dynauras
9574  if (GetEntry() != WORLD_TRIGGER && (!obj || !obj->isType(TYPEMASK_GAMEOBJECT | TYPEMASK_DYNAMICOBJECT)))
9575  {
9576  // can't attack invisible
9577  if (!bySpell)
9578  {
9579  if (obj && !obj->CanSeeOrDetect(target))
9580  return false;
9581  else if (!obj)
9582  {
9583  // ignore stealth for aoe spells. Ignore stealth if target is player and unit in combat with same player
9584  bool const ignoreStealthCheck = target->GetTypeId() == TYPEID_PLAYER && target->HasStealthAura() && target->IsInCombat() && IsInCombatWith(target);
9585 
9586  if (!CanSeeOrDetect(target, ignoreStealthCheck))
9587  return false;
9588  }
9589  }
9590  }
9591 
9592  // can't attack dead
9593  if (!target->IsAlive())
9594  return false;
9595 
9596  // can't attack untargetable
9597  if (!bySpell && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
9598  return false;
9599 
9600  // check flags
9605  // 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
9607  return false;
9608 
9609  // CvC case - can attack each other only when one of them is hostile
9611  return GetReactionTo(target) <= REP_HOSTILE || target->GetReactionTo(this) <= REP_HOSTILE;
9612 
9613  // PvP, PvC, CvP case
9614  // can't attack friendly targets
9615  if (GetReactionTo(target) > REP_NEUTRAL
9616  || target->GetReactionTo(this) > REP_NEUTRAL)
9617  return false;
9618 
9619  Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : nullptr;
9620  Player const* playerAffectingTarget = target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? target->GetAffectingPlayer() : nullptr;
9621 
9622  // Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
9623  if ((playerAffectingAttacker && !playerAffectingTarget) ||
9624  (!playerAffectingAttacker && playerAffectingTarget))
9625  {
9626  Player const* player = playerAffectingAttacker ? playerAffectingAttacker : playerAffectingTarget;
9627  Unit const* creature = playerAffectingAttacker ? target : this;
9628 
9629  if (creature->IsContestedGuard() && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
9630  return true;
9631 
9632  if (FactionTemplateEntry const* factionTemplate = creature->GetFactionTemplateEntry())
9633  {
9634  if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate)))
9635  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction))
9636  if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
9637  if (!(repState->Flags & FACTION_FLAG_AT_WAR) && (!IsContestedGuard() && !player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)))
9638  return false;
9639 
9640  }
9641  }
9642 
9643  // check duel - before sanctuary checks
9644  if (playerAffectingAttacker && playerAffectingTarget)
9645  if (playerAffectingAttacker->duel && playerAffectingAttacker->duel->opponent == playerAffectingTarget && playerAffectingAttacker->duel->startTime != 0)
9646  return true;
9647 
9648  // PvP case - can't attack when attacker or target are in sanctuary
9649  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) && (target->IsInSanctuary() || IsInSanctuary()))
9650  return false;
9651 
9652  // additional checks - only PvP case
9653  if (playerAffectingAttacker && playerAffectingTarget)
9654  {
9655  if (target->IsPvP())
9656  return true;
9657 
9658  if (playerAffectingAttacker->IsFFAPvP() && playerAffectingTarget->IsFFAPvP())
9659  return true;
9660 
9662  || target->HasFlag(UNIT_FIELD_BYTES_2, UNIT_BYTE2_FLAG_UNK1);
9663  }
9664  return true;
9665 }
time_t startTime
Definition: Player.h:235
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7237
DuelInfo * duel
Definition: Player.h:1798
bool IsFFAPvP() const
Definition: Player.h:1771
#define WORLD_TRIGGER
Definition: Unit.h:38
FactionState const * GetState(FactionEntry const *factionEntry) const
Definition: ReputationMgr.h:76
bool IsContestedGuard() const
Definition: Unit.h:1131
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7685
ReputationRank const * GetForcedRankIfAny(FactionTemplateEntry const *factionTemplateEntry) const
Definition: ReputationMgr.h:97
bool IsInSanctuary() const
Definition: Unit.cpp:9550
ReputationMgr & GetReputationMgr()
Definition: Player.h:2079
Player * opponent
Definition: Player.h:233
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
#define ASSERT
Definition: Errors.h:29
uint32 GetEntry() const
Definition: Object.h:186
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7222
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:281
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1612
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:501
Definition: Unit.h:908
Definition: Player.h:923
void Unit::_RemoveAllAuraMods ( )

Definition at line 4660 of file Unit.cpp.

References m_Auras.

Referenced by Player::_RemoveAllStatBonuses().

4661 {
4662  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
4663  (*i).second->ApplyModifier(false);
4664 }
AuraMap m_Auras
Definition: Unit.h:2027
void Unit::_removeAttacker ( Unit pAttacker)
inline

Definition at line 999 of file Unit.h.

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

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

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

3427 {
3428  //check "realtime" interrupts
3429  if ((GetTypeId() == TYPEID_PLAYER && isMoving()) || IsNonMeleeSpellCast(false, false, true))
3430  {
3431  // cancel wand shoot
3432  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351)
3434  m_AutoRepeatFirstCast = true;
3435  return;
3436  }
3437 
3438  // apply delay (Auto Shot (spellID 75) not affected)
3441  m_AutoRepeatFirstCast = false;
3442 
3443  //castroutine
3445  {
3446  // Check if able to cast
3447  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true) != SPELL_CAST_OK)
3448  {
3450  return;
3451  }
3452 
3453  // we want to shoot
3454  Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, true, 0);
3455  spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
3456 
3457  // all went good, reset attack
3459  }
3460 }
void setAttackTimer(WeaponAttackType type, uint32 time)
Definition: Unit.h:943
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false) const
Definition: Unit.cpp:3578
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2088
void prepare(SpellCastTargets *targets, Aura *triggeredByAura=NULL)
Definition: Spell.cpp:2234
bool m_AutoRepeatFirstCast
Definition: Unit.h:2013
bool isMoving() const
Definition: Unit.h:1332
uint8 GetTypeId() const
Definition: Object.h:192
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:3538
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:952
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:644
uint32 getAttackTimer(WeaponAttackType type) const
Definition: Unit.h:948
Definition: Spell.h:249
void Unit::_UpdateSpells ( uint32  time)
protected

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

3375 {
3378 
3379  // remove finished spells from current pointers
3380  for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
3381  {
3382  if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
3383  {
3385  m_currentSpells[i] = NULL; // remove pointer
3386  }
3387  }
3388 
3389  // m_AurasUpdateIterator can be updated in inderect called code at aura remove to skip next planned to update but removed auras
3390  for (m_AurasUpdateIterator = m_Auras.begin(); m_AurasUpdateIterator != m_Auras.end();)
3391  {
3392  Aura* i_aura = m_AurasUpdateIterator->second;
3393  ++m_AurasUpdateIterator; // need shift to next for allow update if need into aura update
3394  i_aura->Update(time);
3395  }
3396 
3397  // remove expired auras
3398  for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
3399  {
3400  if (i->second->IsExpired())
3402  else
3403  ++i;
3404  }
3405 
3406  _DeleteAuras();
3407 
3408  if (!m_gameObj.empty())
3409  {
3410  std::list<GameObject*>::iterator itr;
3411  for (itr = m_gameObj.begin(); itr != m_gameObj.end();)
3412  {
3413  if (!(*itr)->isSpawned())
3414  {
3415  (*itr)->SetOwnerGUID(0);
3416  (*itr)->SetRespawnTime(0);
3417  (*itr)->Delete();
3418  m_gameObj.erase(itr++);
3419  }
3420  else
3421  ++itr;
3422  }
3423  }
3424 }
void _UpdateAutoRepeatSpell()
Definition: Unit.cpp:3426
virtual void Update(uint32 diff)
Definition: SpellAuras.cpp:529
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2088
void _DeleteAuras()
Definition: Unit.cpp:3365
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4475
std::list< GameObject * > m_gameObj
Definition: Unit.h:2034
#define CURRENT_MAX_SPELL
Definition: Unit.h:744
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:482
AuraMap::iterator m_AurasUpdateIterator
Definition: Unit.h:2028
ACE_UINT32 uint32
Definition: Define.h:71
AuraMap m_Auras
Definition: Unit.h:2027
void Unit::AddAssistThreat ( Unit victim,
float  threatToAdd,
SpellEntry const *  threatSpell 
)

Definition at line 10252 of file Unit.cpp.

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

Referenced by Spell::HandleThreatSpells().

10253 {
10254  // Only mobs can manage threat lists
10255  if (CanHaveThreatList())
10256  getHostileRefManager().threatAssist(victim, threatToAdd, threatSpell);
10257 }
HostileRefManager & getHostileRefManager()
Definition: Unit.h:1733
bool CanHaveThreatList() const
Definition: Unit.cpp:10204
void threatAssist(Unit *victim, float baseThreat, SpellEntry const *threatSpell=NULL)
void Unit::AddAura ( uint32  spellId,
Unit target 
)

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

13519 {
13520  if (!target)
13521  return;
13522 
13523  SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
13524  if (!spellInfo)
13525  return;
13526 
13527  if (!target->IsAlive() && !(spellInfo->AttributesEx & SPELL_ATTR0_PASSIVE) && !(spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_DEAD))
13528  return;
13529 
13530  if (target->IsImmuneToSpell(spellInfo))
13531  return;
13532 
13533  for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
13534  {
13535  if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA)
13536  {
13537  if (target->IsImmuneToSpellEffect(spellInfo, i, false))
13538  continue;
13539 
13540  if (spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER)
13541  {
13542  Aura* Aur = CreateAura(spellInfo, i, NULL, this, this);
13543  AddAura(Aur);
13544  }
13545  else
13546  {
13547  Aura* Aur = CreateAura(spellInfo, i, NULL, target, this);
13548  target->AddAura(Aur);
13549  }
13550  }
13551  }
13552 }
uint32 AttributesEx
Definition: DBCStructure.h:680
virtual bool IsImmuneToSpell(SpellEntry const *spellInfo, bool useCharges=false)
Definition: Unit.cpp:8979
uint32 AttributesEx2
Definition: DBCStructure.h:681
uint32 Effect[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:724
void AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:13518
Aura * CreateAura(SpellEntry const *spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item *castItem)
Definition: SpellAuras.cpp:502
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
bool IsAlive() const
Definition: Unit.h:1336
uint32 EffectImplicitTargetA[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:731
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:670
ACE_UINT32 uint32
Definition: Define.h:71
virtual bool IsImmuneToSpellEffect(SpellEntry const *spellInfo, uint32 index, bool castOnSelf) const
Definition: Unit.cpp:9042
bool Unit::AddAura ( Aura aur)

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

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

Definition at line 1920 of file Unit.h.

Referenced by Player::AddComboPoints().

1921  {
1922  m_ComboPointHolders.insert(lowguid);
1923  }
ComboPointHolderSet m_ComboPointHolders
Definition: Unit.h:2100
void Unit::AddDynObject ( DynamicObject dynObj)

Definition at line 4680 of file Unit.cpp.

References Object::GetGUID(), and m_dynObjGUIDs.

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

4681 {
4682  m_dynObjGUIDs.push_back(dynObj->GetGUID());
4683 }
DynObjectGUIDs m_dynObjGUIDs
Definition: Unit.h:2032
uint64 GetGUID() const
Definition: Object.h:177
void Unit::addFollower ( FollowerReference pRef)
inline

Definition at line 1881 of file Unit.h.

Referenced by FollowerReference::targetObjectBuildLink().

1882  {
1884  }
FollowerRefManager m_FollowingRefManager
Definition: Unit.h:2098
void insertFirst(LinkedListElement *pElem)
Definition: LinkedList.h:105
void Unit::AddGameObject ( GameObject gameObj)

Definition at line 4751 of file Unit.cpp.

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

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

4752 {
4753  if (!gameObj || gameObj->GetOwnerGUID() != 0)
4754  return;
4755 
4756  m_gameObj.push_back(gameObj);
4757  gameObj->SetOwnerGUID(GetGUID());
4758 }
uint64 GetOwnerGUID() const
Definition: GameObject.h:681
uint64 GetGUID() const
Definition: Object.h:177
std::list< GameObject * > m_gameObj
Definition: Unit.h:2034
void SetOwnerGUID(uint64 owner)
Definition: GameObject.h:673
void Unit::addHatedBy ( HostileReference pHostileReference)
inline

Definition at line 1725 of file Unit.h.

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

Definition at line 1776 of file Unit.h.

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

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

Definition at line 12383 of file Unit.cpp.

References TYPEID_PLAYER.

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

12384 {
12385  if (GetTypeId() != TYPEID_PLAYER)
12386  return;
12387 
12388  m_petAuras.insert(petSpell);
12389  if (Pet* pet = ToPlayer()->GetPet())
12390  pet->CastPetAura(petSpell);
12391 }
Player * ToPlayer()
Definition: Object.h:368
uint8 GetTypeId() const
Definition: Object.h:192
PetAuraSet m_petAuras
Definition: Unit.h:1957
Definition: Pet.h:146
void Unit::AddPlayerToVision ( Player plr)

Definition at line 7969 of file Unit.cpp.

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

7970 {
7971  if (m_sharedVision.empty())
7972  {
7973  setActive(true);
7974  SetWorldObject(true);
7975  }
7976  m_sharedVision.push_back(plr);
7977 }
void setActive(bool isActiveObject)
Definition: Object.cpp:1122
SharedVisionList m_sharedVision
Definition: Unit.h:2054
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 10243 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().

10244 {
10245  // Only mobs can manage threat lists
10247  m_ThreatManager.addThreat(victim, fThreat, schoolMask, threatSpell);
10248 }
ThreatManager m_ThreatManager
Definition: Unit.h:2064
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
bool CanHaveThreatList() const
Definition: Unit.cpp:10204
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 11164 of file Unit.cpp.

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

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

11165 {
11166  if (!IsInWorld())
11168 }
const bool & IsInWorld() const
Definition: Object.h:150
virtual void AddToWorld()
Definition: Object.h:154
void Unit::AddUnitMovementFlag ( uint32  f)
inline

Definition at line 1904 of file Unit.h.

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

1904 { m_movementInfo.moveFlags |= f; }
MovementInfo m_movementInfo
Definition: Object.h:890
uint32 moveFlags
Definition: Object.h:431
void Unit::AddUnitTypeMask ( uint32  mask)
inline

Definition at line 1045 of file Unit.h.

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

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

12179 {
12180  float remainingTimePct = (float)m_attackTimer[att] / (GetAttackTime(att) * m_modAttackSpeedPct[att]);
12181  if (val > 0)
12182  {
12185  }
12186  else
12187  {
12190  }
12191  m_attackTimer[att] = uint32(GetAttackTime(att) * m_modAttackSpeedPct[att] * remainingTimePct);
12192 }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:967
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.h:1104
float m_modAttackSpeedPct[3]
Definition: Unit.h:1631
void ApplyPercentModFloatVar(float &var, float val, bool apply)
Definition: Util.h:88
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2018
ACE_UINT32 uint32
Definition: Define.h:71
void Unit::ApplyAuraProcTriggerDamage ( Aura aura,
bool  apply 
)

Definition at line 11137 of file Unit.cpp.

References m_modAuras, and SPELL_AURA_PROC_TRIGGER_DAMAGE.

11138 {
11139  AuraList& tAuraProcTriggerDamage = m_modAuras[SPELL_AURA_PROC_TRIGGER_DAMAGE];
11140  if (apply)
11141  tAuraProcTriggerDamage.push_back(aura);
11142  else
11143  tAuraProcTriggerDamage.remove(aura);
11144 }
std::list< Aura * > AuraList
Definition: Unit.h:917
void apply(T *val)
Definition: ByteConverter.h:41
AuraList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2039
void Unit::ApplyCastTimePercentMod ( float  val,
bool  apply 
)

Definition at line 12194 of file Unit.cpp.

References UNIT_MOD_CAST_SPEED.

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

12195 {
12196  if (val > 0)
12198  else
12200 }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:967
void Unit::ApplyDiminishingAura ( DiminishingGroup  group,
bool  apply 
)

Definition at line 10676 of file Unit.cpp.

References getMSTime(), and m_Diminishing.

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

10677 {
10678  // Checking for existing in the table
10679  for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
10680  {
10681  if (i->DRGroup != group)
10682  continue;
10683 
10684  i->hitTime = getMSTime();
10685 
10686  if (apply)
10687  i->stack += 1;
10688  else if (i->stack)
10689  i->stack -= 1;
10690 
10691  break;
10692  }
10693 }
uint32 getMSTime()
Definition: Timer.h:32
Diminishing m_Diminishing
Definition: Unit.h:2092
void apply(T *val)
Definition: ByteConverter.h:41
void Unit::ApplyDiminishingToDuration ( DiminishingGroup  group,
int32 duration,
Unit caster,
DiminishingLevels  Level 
)

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

10626 {
10627  if (duration == -1 || group == DIMINISHING_NONE)
10628  return;
10629 
10630  // Creatures other then pets do not suffer from Diminishing Returns
10631  if (caster->GetTypeId() == TYPEID_UNIT && !caster->GetOwner())
10632  return;
10633 
10634  // Test pet/charm masters instead pets/charmedsz
10635  Unit const* targetOwner = GetCharmerOrOwner();
10636  Unit const* casterOwner = caster->GetCharmerOrOwner();
10637 
10638  // Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0)
10639  if (duration > 10000 && IsDiminishingReturnsGroupDurationLimited(group))
10640  {
10641  Unit const* target = targetOwner ? targetOwner : this;
10642  Unit const* source = casterOwner ? casterOwner : caster;
10643 
10644  if (target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER)
10645  if (source != target || GetTypeId() != TYPEID_UNIT)
10646  duration = 10000;
10647  }
10648 
10649  float mod = 1.0f;
10650 
10651  // Some diminishings applies to mobs too (for example, Stun)
10652  if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && (targetOwner ? targetOwner->GetTypeId() : GetTypeId()) == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL)
10653  {
10654  DiminishingLevels diminish = Level;
10655  switch (diminish)
10656  {
10657  case DIMINISHING_LEVEL_1:
10658  break;
10659  case DIMINISHING_LEVEL_2:
10660  mod = 0.5f;
10661  break;
10662  case DIMINISHING_LEVEL_3:
10663  mod = 0.25f;
10664  break;
10666  mod = 0.0f;
10667  break;
10668  default:
10669  break;
10670  }
10671  }
10672 
10673  duration = int32(duration * mod);
10674 }
bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group)
Definition: SpellMgr.cpp:3183
DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group)
Definition: SpellMgr.cpp:3208
ACE_INT32 int32
Definition: Define.h:67
uint8 GetTypeId() const
Definition: Object.h:192
DiminishingLevels
Definition: Unit.h:643
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1410
Unit * GetOwner() const
Definition: Unit.cpp:7660
Definition: Unit.h:908
void Unit::ApplyMaxPowerMod ( Powers  power,
uint32  val,
bool  apply 
)

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

11116 {
11118 
11119  // group update
11120  if (GetTypeId() == TYPEID_PLAYER)
11121  {
11122  if (ToPlayer()->GetGroup())
11124  }
11125  else if (IsPet())
11126  {
11127  Pet* pet = ((Pet*)this);
11128  if (pet->isControlled())
11129  {
11130  Unit* owner = GetOwner();
11131  if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
11133  }
11134  }
11135 }
Group * GetGroup()
Definition: Player.h:2577
void ApplyModUInt32Value(uint16 index, int32 val, bool apply)
Definition: Object.cpp:944
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:368
uint8 GetTypeId() const
Definition: Object.h:192
bool isControlled() const
Definition: Pet.h:163
bool IsPet() const
Definition: Unit.h:1048
Unit * GetOwner() const
Definition: Unit.cpp:7660
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2598
Definition: Unit.h:908
Definition: Pet.h:146
void Unit::ApplyPowerMod ( Powers  power,
uint32  val,
bool  apply 
)

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

11094 {
11096 
11097  // group update
11098  if (GetTypeId() == TYPEID_PLAYER)
11099  {
11100  if (ToPlayer()->GetGroup())
11102  }
11103  else if (IsPet())
11104  {
11105  Pet* pet = ((Pet*)this);
11106  if (pet->isControlled())
11107  {
11108  Unit* owner = GetOwner();
11109  if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
11111  }
11112  }
11113 }
Group * GetGroup()
Definition: Player.h:2577
void ApplyModUInt32Value(uint16 index, int32 val, bool apply)
Definition: Object.cpp:944
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:368
uint8 GetTypeId() const
Definition: Object.h:192
bool isControlled() const
Definition: Pet.h:163
bool IsPet() const
Definition: Unit.h:1048
Unit * GetOwner() const
Definition: Unit.cpp:7660
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2598
Definition: Unit.h:908
Definition: Pet.h:146
void Unit::ApplyResistanceBuffModsMod ( SpellSchools  school,
bool  positive,
float  val,
bool  apply 
)
inline
void Unit::ApplyResistanceBuffModsPercentMod ( SpellSchools  school,
bool  positive,
float  val,
bool  apply 
)
inline
void Unit::ApplySpellDispelImmunity ( const SpellEntry spellProto,
DispelType  type,
bool  apply 
)

Definition at line 9276 of file Unit.cpp.

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

Referenced by Aura::HandleAuraModDispelImmunity().

9277 {
9278  ApplySpellImmune(spellProto->Id, IMMUNITY_DISPEL, type, apply);
9279 
9282 }
uint32 AttributesEx
Definition: DBCStructure.h:680
void RemoveAurasWithDispelType(DispelType type)
Definition: Unit.cpp:4338
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition: Unit.cpp:9244
void apply(T *val)
Definition: ByteConverter.h:41
void Unit::ApplySpellImmune ( uint32  spellId,
uint32  op,
uint32  type,
bool  apply 
)

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

9245 {
9246  if (apply)
9247  {
9248  for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next)
9249  {
9250  next = itr; ++next;
9251  if (itr->type == type)
9252  {
9253  m_spellImmune[op].erase(itr);
9254  next = m_spellImmune[op].begin();
9255  }
9256  }
9257  SpellImmune Immune;
9258  Immune.spellId = spellId;
9259  Immune.type = type;
9260  m_spellImmune[op].push_back(Immune);
9261  }
9262  else
9263  {
9264  for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr)
9265  {
9266  if (itr->spellId == spellId && itr->type == type)
9267  {
9268  m_spellImmune[op].erase(itr);
9269  break;
9270  }
9271  }
9272  }
9273 
9274 }
uint32 spellId
Definition: Unit.h:346
void apply(T *val)
Definition: ByteConverter.h:41
uint32 type
Definition: Unit.h:345
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1710
void Unit::ApplyStatBuffMod ( Stats  stat,
float  val,
bool  apply 
)
inline

Definition at line 1533 of file Unit.h.

References UNIT_FIELD_NEGSTAT0, and UNIT_FIELD_POSSTAT0.

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

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

Definition at line 1537 of file Unit.h.

References UNIT_FIELD_NEGSTAT0, and UNIT_FIELD_POSSTAT0.

Referenced by Aura::HandleModTotalPercentStat().

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

Definition at line 10231 of file Unit.cpp.

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

Referenced by ThreatCalcHelper::calcThreat().

10232 {
10233  if (!HasAuraType(SPELL_AURA_MOD_THREAT) || fThreat < 0)
10234  return fThreat;
10235 
10236  SpellSchools school = GetFirstSchoolInMask(schoolMask);
10237 
10238  return fThreat * m_threatModifier[school];
10239 }
SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask)
SpellSchools
float m_threatModifier[MAX_SPELL_SCHOOL]
Definition: Unit.h:1630
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:869
bool Unit::Attack ( Unit victim,
bool  meleeAttack 
)

Definition at line 7425 of file Unit.cpp.

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

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

7426 {
7427  if (!victim || victim == this)
7428  return false;
7429 
7430  // dead units can neither attack nor be attacked
7431  if (!IsAlive() || !victim->IsInWorld() || !victim->IsAlive())
7432  return false;
7433 
7434  // player cannot attack in mount state
7435  if (GetTypeId() == TYPEID_PLAYER && IsMounted())
7436  return false;
7437 
7438  Creature* creature = ToCreature();
7439  // creatures cannot attack while evading
7440  if (creature && creature->IsInEvadeMode())
7441  return false;
7442 
7444  return false;
7445 
7446  // nobody can attack GM in GM-mode
7447  if (victim->GetTypeId() == TYPEID_PLAYER)
7448  {
7449  if (victim->ToPlayer()->IsGameMaster())
7450  return false;
7451  }
7452  else
7453  {
7454  if (victim->ToCreature()->IsInEvadeMode())
7455  return false;
7456  }
7457 
7458  // remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack)
7461 
7462  if (m_attacking)
7463  {
7464  if (m_attacking == victim)
7465  {
7466  // switch to melee attack from ranged/magic
7467  if (meleeAttack && !HasUnitState(UNIT_STATE_MELEE_ATTACKING))
7468  {
7470  SendMeleeAttackStart(victim);
7471  return true;
7472  }
7473  return false;
7474  }
7475  AttackStop();
7476  }
7477 
7478  // Set our target
7479  SetTarget(victim->GetGUID());
7480 
7481  if (meleeAttack)
7483 
7484  m_attacking = victim;
7485  m_attacking->_addAttacker(this);
7486 
7487  if (creature && !IsPet())
7488  {
7489  // should not let player enter combat by right clicking target
7490  SetInCombatWith(victim);
7491  if (victim->GetTypeId() == TYPEID_PLAYER)
7492  victim->SetInCombatWith(this);
7493  AddThreat(victim, 0.0f);
7494 
7496  creature->CallAssistance();
7497  }
7498 
7499  // delay offhand weapon attack to next attack time
7500  if (haveOffhandWeapon())
7502 
7503  if (meleeAttack)
7504  SendMeleeAttackStart(victim);
7505 
7506  // Let the pet know we've started attacking someting. Handles melee attacks only
7507  // Spells such as auto-shot and others handled in WorldSession::HandleCastSpellOpcode
7508  if (GetTypeId() == TYPEID_PLAYER)
7509  {
7510  Pet* playerPet = this->ToPlayer()->GetPet();
7511 
7512  if (playerPet && playerPet->IsAlive())
7513  playerPet->AI()->OwnerAttacked(victim);
7514  }
7515 
7516  return true;
7517 }
bool AttackStop()
Definition: Unit.cpp:7519
void SetTarget(uint64 guid=0)
Definition: Unit.h:1591
void AddUnitState(uint32 f)
Definition: Unit.h:1026
void AddThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell=NULL)
Definition: Unit.cpp:10243
void RemoveSpellsCausingAura(AuraType auraType)
Definition: Unit.cpp:732
bool IsInEvadeMode() const
Definition: Creature.cpp:2297
bool IsGameMaster() const
Definition: Player.h:1010
virtual void OwnerAttacked(Unit *)
Definition: CreatureAI.h:167
Player * ToPlayer()
Definition: Object.h:368
void CallAssistance()
Definition: Creature.cpp:1920
uint64 GetGUID() const
Definition: Object.h:177
uint8 GetTypeId() const
Definition: Object.h:192
const bool & IsInWorld() const
Definition: Object.h:150
bool IsAlive() const
Definition: Unit.h:1336
void _addAttacker(Unit *pAttacker)
Definition: Unit.h:993
Unit * m_attacking
Definition: Unit.h:2023
CreatureAI * AI() const
Definition: Creature.h:525
void SendMeleeAttackStart(Unit *victim)
Definition: Unit.cpp:2664
bool haveOffhandWeapon() const
Definition: Unit.cpp:628
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:644
bool IsPet() const
Definition: Unit.h:1048
void SendAIReaction(AiReaction reactionType)
Definition: Creature.cpp:1908
Creature * ToCreature()
Definition: Object.h:371
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
bool IsMounted() const
Definition: Unit.h:1163
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:869
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:281
Pet * GetPet() const
Definition: Player.cpp:17123
Definition: Pet.h:146
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9364
void Unit::AttackerStateUpdate ( Unit victim,
WeaponAttackType  attType = BASE_ATTACK,
bool  extra = false 
)

Definition at line 2367 of file Unit.cpp.

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

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

2368 {
2370  return;
2371 
2372  if (!victim->IsAlive())
2373  return;
2374 
2375  if ((attType == BASE_ATTACK || attType == OFF_ATTACK) && !IsWithinLOSInMap(victim))
2376  return;
2377 
2379 
2380  if (attType != BASE_ATTACK && attType != OFF_ATTACK)
2381  return; // ignore ranged case
2382 
2383  // melee attack spell casted at main hand attack only
2384  if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra)
2385  {
2387  return;
2388  }
2389 
2390  CalcDamageInfo damageInfo;
2391  CalculateMeleeDamage(victim, 0, &damageInfo, attType);
2392  // Send log damage message to client
2393  SendAttackStateUpdate(&damageInfo);
2394 
2395  ProcDamageAndSpell(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, damageInfo.procEx, damageInfo.damage, damageInfo.attackType);
2396 
2397  DealMeleeDamage(&damageInfo, true);
2398 
2399  // We call this last because DealMeleeDamage has to check for sit state to
2400  // allow critical hits, but we set STANDING in CombatStart, therefore always
2401  // nullifying the check.
2402  CombatStart(victim);
2403 
2404  #ifdef OREGON_DEBUG
2405  if (GetTypeId() == TYPEID_PLAYER)
2406  DEBUG_LOG("AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
2407  GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
2408  else
2409  DEBUG_LOG("AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
2410  GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
2411  #endif
2412 
2413 }
uint32 procAttacker
Definition: Unit.h:692
uint32 blocked_amount
Definition: Unit.h:687
void CalculateMeleeDamage(Unit *victim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK)
Definition: Unit.cpp:1638
uint32 procVictim
Definition: Unit.h:693
uint32 resist
Definition: Unit.h:686
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2088
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
Definition: Unit.cpp:1847
bool IsWithinLOSInMap(const WorldObject *obj) const
Definition: Object.cpp:1252
uint32 GetGUIDLow() const
Definition: Object.h:178
uint32 procEx
Definition: Unit.h:694
WeaponAttackType attackType
Definition: Unit.h:691
uint8 GetTypeId() const
Definition: Object.h:192
void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except=0)
Definition: Unit.cpp:773
bool IsAlive() const
Definition: Unit.h:1336
uint32 absorb
Definition: Unit.h:685
#define DEBUG_LOG(...)
Definition: Log.h:194
void SendAttackStateUpdate(CalcDamageInfo *damageInfo)
Definition: Unit.cpp:4911
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:4873
Unit * target
Definition: Unit.h:682
void CombatStart(Unit *target, bool initialAggro=true)
Definition: Unit.cpp:9386
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
uint32 damage
Definition: Unit.h:684
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:281
void cast(bool skipCheck=false)
Definition: Spell.cpp:2416
bool Unit::AttackStop ( )

Definition at line 7519 of file Unit.cpp.

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

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

7520 {
7521  if (!m_attacking)
7522  return false;
7523 
7524  Unit* victim = m_attacking;
7525 
7527  m_attacking = NULL;
7528 
7529  // Clear our target
7530  SetTarget(0);
7531 
7533 
7535 
7536  // reset only at real combat stop
7537  if (Creature* creature = ToCreature())
7538  {
7539  creature->SetNoCallAssistance(false);
7540 
7541  if (creature->HasSearchedAssistance())
7542  {
7543  creature->SetNoSearchAssistance(false);
7544  UpdateSpeed(MOVE_RUN, false);
7545  }
7546  }
7547 
7548  SendMeleeAttackStop(victim);
7549 
7550  return true;
7551 }
void SetTarget(uint64 guid=0)
Definition: Unit.h:1591
void SendMeleeAttackStop(Unit *victim=NULL)
Definition: Unit.cpp:2673
void UpdateSpeed(UnitMoveType mtype, bool forced)
Definition: Unit.cpp:9920
void ClearUnitState(uint32 f)
Definition: Unit.h:1034
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:3538
Unit * m_attacking
Definition: Unit.h:2023
Definition: Unit.h:485
void _removeAttacker(Unit *pAttacker)
Definition: Unit.h:999
Creature * ToCreature()
Definition: Object.h:371
Definition: Unit.h:908
void Unit::BuildHeartBeatMsg ( WorldPacket data) const

Definition at line 1953 of file Object.cpp.

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

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

1954 {
1955  data->Initialize(MSG_MOVE_HEARTBEAT, 32);
1956  *data << GetPackGUID();
1957  BuildMovementPacket(data);
1958 }
void BuildMovementPacket(ByteBuffer *data) const
Definition: Unit.cpp:13655
void Initialize(uint16 opcode, size_t newres=200)
Definition: WorldPacket.h:37
PackedGuid const & GetPackGUID() const
Definition: Object.h:181
void Unit::BuildMovementPacket ( ByteBuffer data) const

Definition at line 13655 of file Unit.cpp.

References getMSTime().

Referenced by SetSpeed().

13656 {
13657  *data << uint32(GetUnitMovementFlags()); // movement flags
13658  *data << uint8(0); // 2.3.0 @todo: Implement extra movement flags
13659  *data << uint32(getMSTime()); // time / counter
13660  *data << float(GetPositionX());
13661  *data << float(GetPositionY());
13662  *data << float(GetPositionZ());
13663  *data << float(GetOrientation());
13664  *data << uint32(0);
13665 }
uint32 GetUnitMovementFlags() const
Definition: Unit.h:1907
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 2105 of file Unit.cpp.

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

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

2106 {
2107  if (!victim || !victim->IsAlive() || !damage)
2108  return;
2109 
2110  // Magic damage, check for resists
2111  if (!spellInfo || (spellInfo->AttributesEx4 & SPELL_ATTR4_IGNORE_RESISTANCES) == 0 && (schoolMask & SPELL_SCHOOL_MASK_MAGIC) && (!binary || damagetype == DOT))
2112  {
2113  const float mitigation = victim->CalculateMagicResistanceMitigation(victim, victim->CalculateEffectiveMagicResistance(victim, schoolMask), false);
2114  const SpellPartialResistChanceEntry &chances = SPELL_PARTIAL_RESIST_DISTRIBUTION.at(uint32(mitigation * 10000));
2115  // We choose which portion of damage is resisted below, none by default
2116  uint8 portion = SPELL_PARTIAL_RESIST_NONE;
2117  // If we got to this point, we already rolled for full resist on hit
2118  // We do a roll between remaining chances
2119  const uint8 outcomes = (NUM_SPELL_PARTIAL_RESISTS - 1);
2120  const uint32 roll = urand(1, (10000 - chances.at(SPELL_PARTIAL_RESIST_PCT_100)));
2121  uint32 sum = 0;
2122  for (uint8 outcome = SPELL_PARTIAL_RESIST_NONE; outcome < outcomes; ++outcome)
2123  {
2124  if (const uint32 chance = chances.at(outcome))
2125  {
2126  sum += chance;
2127  if (roll <= sum)
2128  {
2129  portion = outcome;
2130  break;
2131  }
2132  }
2133  }
2134  const uint32 amount = uint32(damage * (portion * (1.0f / float(outcomes))));
2135  // We already rolled for full resist on hit, so we need to deal at least *some* amount of damage...
2136  *resist = (amount >= damage) ? (damage - 1) : amount;
2137  }
2138  else
2139  *resist = 0;
2140 
2141  int32 RemainingDamage = damage - *resist;
2142 
2143  // Paladin Blessed Life 4/7/10% chance to cause 50% dmg
2144  AuraList const& blessedLife = victim->GetAurasByType(SPELL_AURA_REUSED_BLESSED_LIFE);
2145  AuraList::const_iterator blessedAura = blessedLife.begin();
2146  if (blessedAura != blessedLife.end() && *blessedAura)
2147  {
2148  if (urand(0, 100) <= (*blessedAura)->GetSpellProto()->procChance)
2149  RemainingDamage /= 2;
2150  }
2151 
2152  // Need to remove expired auras after
2153  bool expiredExists = false;
2154 
2155  // absorb without mana cost
2156  int32 reflectDamage = 0;
2157  Aura* reflectAura = NULL;
2158  AuraList const& vSchoolAbsorb = victim->GetAurasByType(SPELL_AURA_SCHOOL_ABSORB);
2159  for (AuraList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end() && RemainingDamage > 0; ++i)
2160  {
2161  int32* p_absorbAmount = &(*i)->GetModifier()->m_amount;
2162 
2163  // should not happen....