TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Unit Class Referenceabstract

#include <Unit.h>

Public Types

typedef std::set< Unit * > AttackerSet
 
typedef std::set< Unit * > ControlList
 
typedef std::multimap< uint32,
Aura * > 
AuraMap
 
typedef std::pair
< AuraMap::const_iterator,
AuraMap::const_iterator > 
AuraMapBounds
 
typedef std::pair
< AuraMap::iterator,
AuraMap::iterator > 
AuraMapBoundsNonConst
 
typedef std::multimap< uint32,
AuraApplication * > 
AuraApplicationMap
 
typedef std::pair
< AuraApplicationMap::const_iterator,
AuraApplicationMap::const_iterator > 
AuraApplicationMapBounds
 
typedef std::pair
< AuraApplicationMap::iterator,
AuraApplicationMap::iterator > 
AuraApplicationMapBoundsNonConst
 
typedef std::multimap
< AuraStateType,
AuraApplication * > 
AuraStateAurasMap
 
typedef std::pair
< AuraStateAurasMap::const_iterator,
AuraStateAurasMap::const_iterator > 
AuraStateAurasMapBounds
 
typedef std::list< AuraEffect * > AuraEffectList
 
typedef std::list< Aura * > AuraList
 
typedef std::list
< AuraApplication * > 
AuraApplicationList
 
typedef std::list
< DiminishingReturn
Diminishing
 
typedef std::map< uint8,
AuraApplication * > 
VisibleAuraMap
 
typedef std::set< PetAura const * > PetAuraSet
 

Public Member Functions

virtual ~Unit ()
 
UnitAIGetAI ()
 
void SetAI (UnitAI *newAI)
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void CleanupBeforeRemoveFromMap (bool finalCleanup)
 
void CleanupsBeforeDelete (bool finalCleanup=true) override
 
void SendCombatLogMessage (WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
 
DiminishingLevels GetDiminishing (DiminishingGroup group)
 
void IncrDiminishing (DiminishingGroup group)
 
float ApplyDiminishingToDuration (DiminishingGroup group, int32 &duration, Unit *caster, DiminishingLevels Level, int32 limitduration)
 
void ApplyDiminishingAura (DiminishingGroup group, bool apply)
 
void ClearDiminishings ()
 
float GetSpellMaxRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
float GetSpellMinRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
virtual void Update (uint32 time) override
 
void setAttackTimer (WeaponAttackType type, uint32 time)
 
void resetAttackTimer (WeaponAttackType type=BASE_ATTACK)
 
uint32 getAttackTimer (WeaponAttackType type) const
 
bool isAttackReady (WeaponAttackType type=BASE_ATTACK) const
 
bool haveOffhandWeapon () const
 
bool CanDualWield () const
 
virtual void SetCanDualWield (bool value)
 
float GetCombatReach () const
 
float GetMeleeReach () const
 
bool IsWithinCombatRange (const Unit *obj, float dist2compare) const
 
bool IsWithinMeleeRange (const 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 MustReacquireTarget ()
 
void CastStop (uint32 except_spellid=0)
 
bool AttackStop ()
 
void RemoveAllAttackers ()
 
AttackerSet constgetAttackers () const
 
bool isAttackingPlayer () const
 
UnitGetVictim () const
 
UnitEnsureVictim () const
 
void CombatStop (bool includingCast=false)
 
void CombatStopWithPets (bool includingCast=false)
 
void StopAttackFaction (uint32 faction_id)
 
UnitSelectNearbyTarget (Unit *exclude=NULL, float dist=NOMINAL_MELEE_RANGE) const
 
void SendMeleeAttackStop (Unit *victim=NULL)
 
void SendMeleeAttackStart (Unit *victim)
 
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 IsVehicle () const
 
uint8 getLevel () const
 
uint8 getLevelForTarget (WorldObject const *) const override
 
void SetLevel (uint8 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
 
uint32 GetResistance (SpellSchoolMask mask) const
 
void SetResistance (SpellSchools school, int32 val)
 
uint32 GetHealth () const
 
uint32 GetMaxHealth () const
 
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)
 
int32 GetHealthGain (int32 dVal)
 
Powers getPowerType () const
 
void setPowerType (Powers power)
 
int32 GetPower (Powers power) const
 
int32 GetMinPower (Powers power) const
 
int32 GetMaxPower (Powers power) const
 
float GetPowerPct (Powers power) const
 
int32 CountPctFromMaxPower (Powers power, int32 pct) const
 
void SetPower (Powers power, int32 val)
 
void SetMaxPower (Powers power, int32 val)
 
int32 ModifyPower (Powers power, int32 val)
 
int32 ModifyPowerPct (Powers power, float pct, bool apply=true)
 
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 constGetFactionTemplateEntry () 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 GetPartyMembers (std::list< Unit * > &units)
 
bool IsContestedGuard () const
 
bool IsPvP () const
 
bool IsFFAPvP () const
 
virtual void SetPvP (bool state)
 
uint32 GetCreatureType () const
 
uint32 GetCreatureTypeMask () const
 
UnitStandStateType GetStandState () const
 
bool IsSitState () const
 
bool IsStandState () const
 
void SetStandState (UnitStandStateType state, uint32 animKitID=0)
 
void SetStandFlags (uint8 flags)
 
void RemoveStandFlags (uint8 flags)
 
bool IsMounted () const
 
uint32 GetMountID () const
 
void Mount (uint32 mount, uint32 vehicleId=0, uint32 creatureEntry=0)
 
void Dismount ()
 
MountCapabilityEntry constGetMountCapability (uint32 mountType) const
 
void SendDurabilityLoss (Player *receiver, uint32 percent)
 
void PlayOneShotAnimKitId (uint16 animKitId)
 
void SetAIAnimKitId (uint16 animKitId)
 
uint16 GetAIAnimKitId () const override
 
void SetMovementAnimKitId (uint16 animKitId)
 
uint16 GetMovementAnimKitId () const override
 
void SetMeleeAnimKitId (uint16 animKitId)
 
uint16 GetMeleeAnimKitId () const override
 
uint16 GetMaxSkillValueForLevel (Unit const *target=NULL) const
 
void DealDamageMods (Unit *victim, uint32 &damage, uint32 *absorb)
 
uint32 DealDamage (Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=NULL, bool durabilityLoss=true)
 
void Kill (Unit *victim, bool durabilityLoss=true)
 
void KillSelf (bool durabilityLoss=true)
 
int32 DealHeal (Unit *victim, uint32 addhealth)
 
void ProcDamageAndSpell (Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellInfo const *procSpell=NULL, SpellInfo const *procAura=NULL)
 
void ProcDamageAndSpellFor (bool isVictim, Unit *target, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellInfo const *procSpell, uint32 damage, SpellInfo const *procAura=NULL)
 
void GetProcAurasTriggeredOnEvent (AuraApplicationList &aurasTriggeringProc, AuraApplicationList *procAuras, ProcEventInfo eventInfo)
 
void TriggerAurasProcOnEvent (CalcDamageInfo &damageInfo)
 
void TriggerAurasProcOnEvent (AuraApplicationList *myProcAuras, AuraApplicationList *targetProcAuras, Unit *actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell *spell, DamageInfo *damageInfo, HealInfo *healInfo)
 
void TriggerAurasProcOnEvent (ProcEventInfo &eventInfo, AuraApplicationList &procAuras)
 
void HandleEmoteCommand (uint32 anim_id)
 
void AttackerStateUpdate (Unit *victim, WeaponAttackType attType=BASE_ATTACK, bool extra=false)
 
void CalculateMeleeDamage (Unit *victim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK)
 
void DealMeleeDamage (CalcDamageInfo *damageInfo, bool durabilityLoss)
 
void HandleProcExtraAttackFor (Unit *victim)
 
void CalculateSpellDamageTaken (SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType=BASE_ATTACK, bool crit=false)
 
void DealSpellDamage (SpellNonMeleeDamage const *damageInfo, bool durabilityLoss)
 
uint32 GetDamageReduction (uint32 damage) const
 
void ApplyResilience (Unit const *victim, int32 *damage) const
 
float MeleeSpellMissChance (Unit const *victim, WeaponAttackType attType, uint32 spellId) const
 
SpellMissInfo MeleeSpellHitResult (Unit *victim, SpellInfo const *spellInfo)
 
SpellMissInfo MagicSpellHitResult (Unit *victim, SpellInfo const *spellInfo)
 
SpellMissInfo SpellHitResult (Unit *victim, SpellInfo const *spellInfo, bool canReflect=false)
 
float GetUnitDodgeChanceAgainst (Unit const *attacker) const
 
float GetUnitParryChanceAgainst (Unit const *attacker) const
 
float GetUnitBlockChanceAgainst (Unit const *attacker) const
 
float GetUnitMissChance (WeaponAttackType attType) const
 
float GetUnitCriticalChance (WeaponAttackType attackType, const Unit *victim) const
 
int32 GetMechanicResistChance (SpellInfo const *spellInfo) const
 
bool CanUseAttackType (uint8 attacktype) const
 
virtual uint32 GetBlockPercent () const
 
float GetWeaponProcChance () const
 
float GetPPMProcChance (uint32 WeaponSpeed, float PPM, const SpellInfo *spellProto) const
 
MeleeHitOutcome RollMeleeOutcomeAgainst (Unit const *victim, WeaponAttackType attType) 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 IsInFlight () const
 
bool IsInCombat () const
 
bool IsInCombatWith (Unit const *who) const
 
void CombatStart (Unit *target, bool initialAggro=true)
 
void SetInCombatState (bool PvP, Unit *enemy=NULL)
 
void SetInCombatWith (Unit *enemy)
 
void ClearInCombat ()
 
uint32 GetCombatTimer () const
 
bool HasAuraTypeWithFamilyFlags (AuraType auraType, uint32 familyName, uint32 familyFlags) 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, SpellInfo const *bySpell, WorldObject const *obj=NULL) const
 
bool IsValidAssistTarget (Unit const *target) const
 
bool _IsValidAssistTarget (Unit const *target, SpellInfo const *bySpell) const
 
virtual bool IsInWater () const
 
virtual bool IsUnderWater () const
 
virtual void UpdateUnderwaterState (Map *m, float x, float y, float z)
 
bool isInAccessiblePlaceFor (Creature const *c) const
 
void SendHealSpellLog (Unit *victim, uint32 spellID, uint32 health, uint32 overHeal, uint32 absorbed, bool crit=false)
 
int32 HealBySpell (Unit *victim, SpellInfo const *spellInfo, uint32 addHealth, bool critical=false)
 
void SendEnergizeSpellLog (Unit *victim, uint32 spellID, int32 damage, Powers powertype)
 
void EnergizeBySpell (Unit *victim, uint32 SpellID, int32 Damage, Powers powertype)
 
void CastSpell (SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastSpell (Unit *victim, uint32 spellId, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastSpell (Unit *victim, uint32 spellId, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastSpell (Unit *victim, SpellInfo const *spellInfo, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastSpell (Unit *victim, SpellInfo const *spellInfo, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastSpell (float x, float y, float z, uint32 spellId, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastSpell (GameObject *go, uint32 spellId, bool triggered, Item *castItem=NULL, AuraEffect *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastCustomSpell (Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastCustomSpell (uint32 spellId, SpellValueMod mod, int32 value, Unit *victim, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastCustomSpell (uint32 spellId, SpellValueMod mod, int32 value, Unit *victim=NULL, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
void CastCustomSpell (uint32 spellId, CustomSpellValues const &value, Unit *victim=NULL, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
 
AuraAddAura (uint32 spellId, Unit *target)
 
AuraAddAura (SpellInfo const *spellInfo, uint32 effMask, Unit *target)
 
void SetAuraStack (uint32 spellId, Unit *target, uint32 stack)
 
void SendPlaySpellVisualKit (uint32 id, uint32 type)
 
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 const *log)
 
void SendPeriodicAuraLog (SpellPeriodicAuraLogInfo *pInfo)
 
void SendSpellMiss (Unit *target, uint32 spellID, SpellMissInfo missInfo)
 
void SendSpellDamageResist (Unit *target, uint32 spellId)
 
void SendSpellDamageImmune (Unit *target, uint32 spellId, bool isPeriodic)
 
void NearTeleportTo (float x, float y, float z, float orientation, bool casting=false)
 
void SendTeleportPacket (Position &pos)
 
virtual bool UpdatePosition (float x, float y, float z, float ang, bool teleport=false)
 
virtual bool UpdatePosition (const Position &pos, bool teleport=false)
 
void UpdateOrientation (float orientation)
 Only server-side orientation update, does not broadcast to client. More...
 
void UpdateHeight (float newZ)
 Only server-side height update, does not broadcast to client. More...
 
void SendMoveKnockBack (Player *player, float speedXY, float speedZ, float vcos, float vsin)
 
void KnockbackFrom (float x, float y, float speedXY, float speedZ)
 
void JumpTo (float speedXY, float speedZ, bool forward=true)
 
void JumpTo (WorldObject *obj, float speedZ, bool withOrientation=false)
 
void MonsterMoveWithSpeed (float x, float y, float z, float speed, bool generatePath=false, bool forceDestination=false)
 
void SendSetPlayHoverAnim (bool enable)
 
bool IsLevitating () const
 
bool IsWalking () const
 
bool IsHovering () const
 
bool SetWalk (bool enable)
 
bool SetDisableGravity (bool disable, bool packetOnly=false)
 
bool SetFall (bool enable)
 
bool SetSwim (bool enable)
 
bool SetCanFly (bool enable)
 
bool SetWaterWalking (bool enable, bool packetOnly=false)
 
bool SetFeatherFall (bool enable, bool packetOnly=false)
 
bool SetHover (bool enable, bool packetOnly=false)
 
bool SetCollision (bool disable)
 
void SendSetVehicleRecId (uint32 vehicleId)
 
void SetInFront (WorldObject const *target)
 
void SetFacingTo (float ori)
 
void SetFacingToObject (WorldObject const *object)
 
void SendChangeCurrentVictimOpcode (HostileReference *pHostileReference)
 
void SendClearThreatListOpcode ()
 
void SendRemoveFromThreatListOpcode (HostileReference *pHostileReference)
 
void SendThreatListUpdate ()
 
void SendClearTarget ()
 
bool IsAlive () const
 
bool isDying () const
 
bool isDead () const
 
DeathState getDeathState () const
 
virtual void setDeathState (DeathState s)
 
ObjectGuid GetOwnerGUID () const
 
void SetOwnerGUID (ObjectGuid owner)
 
ObjectGuid GetCreatorGUID () const
 
void SetCreatorGUID (ObjectGuid creator)
 
ObjectGuid GetMinionGUID () const
 
void SetMinionGUID (ObjectGuid guid)
 
ObjectGuid GetCharmerGUID () const
 
void SetCharmerGUID (ObjectGuid owner)
 
ObjectGuid GetCharmGUID () const
 
void SetPetGUID (ObjectGuid guid)
 
ObjectGuid GetPetGUID () const
 
void SetCritterGUID (ObjectGuid guid)
 
ObjectGuid GetCritterGUID () const
 
bool IsControlledByPlayer () const
 
ObjectGuid GetCharmerOrOwnerGUID () const
 
ObjectGuid GetCharmerOrOwnerOrOwnGUID () const
 
bool IsCharmedOwnedByPlayerOrPlayer () const
 
PlayerGetSpellModOwner () const
 
UnitGetOwner () const
 
GuardianGetGuardianPet () const
 
MinionGetFirstMinion () const
 
UnitGetCharmer () const
 
UnitGetCharm () const
 
UnitGetCharmerOrOwner () const
 
UnitGetCharmerOrOwnerOrSelf () const
 
PlayerGetCharmerOrOwnerPlayerOrPlayerItself () const
 
PlayerGetAffectingPlayer () const
 
void SetMinion (Minion *minion, bool apply)
 
void GetAllMinionsByEntry (std::list< TempSummon * > &Minions, uint32 entry)
 
void RemoveAllMinionsByEntry (uint32 entry)
 
void SetCharm (Unit *target, bool apply)
 
UnitGetNextRandomRaidMemberOrPet (float radius)
 
bool SetCharmedBy (Unit *charmer, CharmType type, AuraApplication const *aurApp=NULL)
 
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 constGetSharedVisionList ()
 
void AddPlayerToVision (Player *player)
 
void RemovePlayerFromVision (Player *player)
 
bool HasSharedVision () const
 
void RemoveBindSightAuras ()
 
void RemoveCharmAuras ()
 
PetCreateTamedPetFrom (Creature *creatureTarget, uint32 spell_id=0)
 
PetCreateTamedPetFrom (uint32 creatureEntry, uint32 spell_id=0)
 
bool InitTamedPet (Pet *pet, uint8 level, uint32 spell_id)
 
Aura_TryStackingOrRefreshingExistingAura (SpellInfo const *newAura, uint32 effMask, Unit *caster, int32 *baseAmount=NULL, Item *castItem=NULL, ObjectGuid casterGUID=ObjectGuid::Empty, int32 castItemLevel=-1)
 
void _AddAura (UnitAura *aura, Unit *caster)
 
AuraApplication_CreateAuraApplication (Aura *aura, uint32 effMask)
 
void _ApplyAuraEffect (Aura *aura, uint8 effIndex)
 
void _ApplyAura (AuraApplication *aurApp, uint32 effMask)
 
void _UnapplyAura (AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
 
void _UnapplyAura (AuraApplication *aurApp, AuraRemoveMode removeMode)
 
void _RemoveNoStackAuraApplicationsDueToAura (Aura *aura)
 
void _RemoveNoStackAurasDueToAura (Aura *aura)
 
bool _IsNoStackAuraDueToAura (Aura *appliedAura, Aura *existingAura) const
 
void _RegisterAuraEffect (AuraEffect *aurEff, bool apply)
 
AuraMapGetOwnedAuras ()
 
AuraMap constGetOwnedAuras () const
 
void RemoveOwnedAura (AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveOwnedAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveOwnedAura (Aura *aura, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
AuraGetOwnedAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, Aura *except=NULL) const
 
AuraApplicationMapGetAppliedAuras ()
 
AuraApplicationMap constGetAppliedAuras () const
 
void RemoveAura (AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAura (AuraApplication *aurApp, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAura (Aura *aur, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAppliedAuras (std::function< bool(AuraApplication const *)> const &check)
 
void RemoveOwnedAuras (std::function< bool(Aura const *)> const &check)
 
void RemoveAppliedAuras (uint32 spellId, std::function< bool(AuraApplication const *)> const &check)
 
void RemoveOwnedAuras (uint32 spellId, std::function< bool(Aura const *)> const &check)
 
void RemoveAurasByType (AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
 
void RemoveAurasDueToSpell (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAuraFromStack (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void RemoveAurasDueToSpellByDispel (uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit *dispeller, uint8 chargesRemoved=1)
 
void RemoveAurasDueToSpellBySteal (uint32 spellId, ObjectGuid casterGUID, Unit *stealer)
 
void RemoveAurasDueToItemSpell (uint32 spellId, ObjectGuid castItemGuid)
 
void RemoveAurasByType (AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=NULL, bool negative=true, bool positive=true)
 
void RemoveNotOwnSingleTargetAuras (uint32 newPhase=0x0, bool phaseid=false)
 
void RemoveAurasWithInterruptFlags (uint32 flag, uint32 except=0)
 
void RemoveAurasWithAttribute (uint32 flags)
 
void RemoveAurasWithFamily (SpellFamilyNames family, flag128 const &familyFlag, ObjectGuid casterGUID)
 
void RemoveAurasWithMechanic (uint32 mechanic_mask, AuraRemoveMode removemode=AURA_REMOVE_BY_DEFAULT, uint32 except=0)
 
void RemoveMovementImpairingAuras ()
 
void RemoveAreaAurasDueToLeaveWorld ()
 
void RemoveAllAuras ()
 
void RemoveArenaAuras ()
 
void RemoveAllAurasOnDeath ()
 
void RemoveAllAurasRequiringDeadTarget ()
 
void RemoveAllAurasExceptType (AuraType type)
 
void RemoveAllAurasExceptType (AuraType type1, AuraType type2)
 
void DelayOwnedAuras (uint32 spellId, ObjectGuid caster, int32 delaytime)
 
void _RemoveAllAuraStatMods ()
 
void _ApplyAllAuraStatMods ()
 
AuraEffectList constGetAuraEffectsByType (AuraType type) const
 
AuraListGetSingleCastAuras ()
 
AuraList constGetSingleCastAuras () const
 
AuraEffectGetAuraEffect (uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffectGetAuraEffectOfRankedSpell (uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffectGetAuraEffect (AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
 
AuraEffectGetAuraEffect (AuraType type, SpellFamilyNames family, flag128 const &familyFlag, ObjectGuid casterGUID=ObjectGuid::Empty) const
 
AuraEffectGetDummyAuraEffect (SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
 
AuraApplicationGetAuraApplication (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraApplication *except=NULL) const
 
AuraGetAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
 
AuraApplicationGetAuraApplicationOfRankedSpell (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraApplication *except=NULL) const
 
AuraGetAuraOfRankedSpell (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
 
void GetDispellableAuraList (Unit *caster, uint32 dispelMask, DispelChargesList &dispelList)
 
bool HasAuraEffect (uint32 spellId, uint8 effIndex, ObjectGuid caster=ObjectGuid::Empty) const
 
uint32 GetAuraCount (uint32 spellId) const
 
bool HasAura (uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
 
bool HasAuraType (AuraType auraType) const
 
bool HasAuraTypeWithCaster (AuraType auratype, ObjectGuid caster) const
 
bool HasAuraTypeWithMiscvalue (AuraType auratype, int32 miscvalue) const
 
bool HasAuraTypeWithAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
bool HasAuraTypeWithValue (AuraType auratype, int32 value) const
 
bool HasNegativeAuraWithInterruptFlag (uint32 flag, ObjectGuid guid=ObjectGuid::Empty) const
 
bool HasNegativeAuraWithAttribute (uint32 flag, ObjectGuid guid=ObjectGuid::Empty) const
 
bool HasAuraWithMechanic (uint32 mechanicMask) const
 
AuraEffectIsScriptOverriden (SpellInfo const *spell, int32 script) const
 
uint32 GetDiseasesByCaster (ObjectGuid casterGUID, bool remove=false)
 
uint32 GetDoTsByCaster (ObjectGuid casterGUID) const
 
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 AuraEffect *except=NULL) 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
 
int32 GetTotalAuraModifierByAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
float GetTotalAuraMultiplierByAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
int32 GetMaxPositiveAuraModifierByAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
int32 GetMaxNegativeAuraModifierByAffectMask (AuraType auratype, SpellInfo const *affectedSpell) const
 
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 GetPowerIndex (uint32 powerType) const
 
int32 GetCreatePowers (Powers power) const
 
float GetPosStat (Stats stat) const
 
float GetNegStat (Stats stat) const
 
float GetCreateStat (Stats stat) const
 
ObjectGuid GetChannelObjectGuid () const
 
void SetChannelObjectGuid (ObjectGuid guid)
 
void SetCurrentCastSpell (Spell *pSpell)
 
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, bool isAutoshoot=false, bool skipInstant=true) const
 
void InterruptNonMeleeSpells (bool withDelayed, uint32 spellid=0, bool withInstant=true)
 
SpellGetCurrentSpell (CurrentSpellTypes spellType) const
 
SpellGetCurrentSpell (uint32 spellType) const
 
SpellFindCurrentSpellBySpellId (uint32 spell_id) const
 
int32 GetCurrentSpellCastTime (uint32 spell_id) const
 
virtual SpellInfo constGetCastSpellInfo (SpellInfo const *spellInfo) const
 
SpellHistoryGetSpellHistory ()
 
SpellHistory constGetSpellHistory () const
 
ShapeshiftForm GetShapeshiftForm () const
 
void SetShapeshiftForm (ShapeshiftForm form)
 
bool IsInFeralForm () const
 
bool IsInDisallowedMountForm () 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=float(M_PI)) const
 
bool isInBackInMap (Unit const *target, float distance, float arc=float(M_PI)) const
 
bool IsVisible () const
 
void SetVisible (bool x)
 
bool SetInPhase (uint32 id, bool update, bool apply) override
 
void UpdateObjectVisibility (bool forced=true) override
 
bool CanHaveThreatList (bool skipAliveCheck=false) const
 
void AddThreat (Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
 
float ApplyTotalThreatModifier (float fThreat, 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 ()
 
VisibleAuraMap constGetVisibleAuras ()
 
AuraApplicationGetVisibleAura (uint8 slot) const
 
void SetVisibleAura (uint8 slot, AuraApplication *aur)
 
void RemoveVisibleAura (uint8 slot)
 
uint32 GetInterruptMask () const
 
void AddInterruptMask (uint32 mask)
 
void UpdateInterruptMask ()
 
uint32 GetDisplayId () const
 
virtual void SetDisplayId (uint32 modelId)
 
uint32 GetNativeDisplayId () const
 
void RestoreDisplayId ()
 
void SetNativeDisplayId (uint32 modelId)
 
void setTransForm (uint32 spellid)
 
uint32 getTransForm () const
 
void _RegisterDynObject (DynamicObject *dynObj)
 
void _UnregisterDynObject (DynamicObject *dynObj)
 
DynamicObjectGetDynObject (uint32 spellId)
 
void RemoveDynObject (uint32 spellId)
 
void RemoveAllDynObjects ()
 
GameObjectGetGameObject (uint32 spellId) const
 
void AddGameObject (GameObject *gameObj)
 
void RemoveGameObject (GameObject *gameObj, bool del)
 
void RemoveGameObject (uint32 spellid, bool del)
 
void RemoveAllGameObjects ()
 
void ModifyAuraState (AuraStateType flag, bool apply)
 
uint32 BuildAuraStateUpdateForTarget (Unit *target) const
 
bool HasAuraState (AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
 
void UnsummonAllTotems ()
 
bool IsMagnet () const
 
UnitGetMagicHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo)
 
UnitGetMeleeHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo=NULL)
 
int32 SpellBaseDamageBonusDone (SpellSchoolMask schoolMask) const
 
int32 SpellBaseDamageBonusTaken (SpellSchoolMask schoolMask) const
 
uint32 SpellDamageBonusDone (Unit *victim, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
 
float SpellDamagePctDone (Unit *victim, SpellInfo const *spellProto, DamageEffectType damagetype) const
 
uint32 SpellDamageBonusTaken (Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
 
int32 SpellBaseHealingBonusDone (SpellSchoolMask schoolMask) const
 
int32 SpellBaseHealingBonusTaken (SpellSchoolMask schoolMask) const
 
uint32 SpellHealingBonusDone (Unit *victim, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
 
float SpellHealingPctDone (Unit *victim, SpellInfo const *spellProto) const
 
uint32 SpellHealingBonusTaken (Unit *caster, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
 
uint32 MeleeDamageBonusDone (Unit *pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const *spellProto=NULL)
 
uint32 MeleeDamageBonusTaken (Unit *attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const *spellProto=NULL)
 
bool isSpellBlocked (Unit *victim, SpellInfo const *spellProto, WeaponAttackType attackType=BASE_ATTACK)
 
bool isBlockCritical ()
 
bool IsSpellCrit (Unit *victim, SpellInfo const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType=BASE_ATTACK) const
 
float GetUnitSpellCriticalChance (Unit *victim, SpellInfo const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType=BASE_ATTACK) const
 
uint32 SpellCriticalDamageBonus (SpellInfo const *spellProto, uint32 damage, Unit *victim)
 
uint32 SpellCriticalHealingBonus (SpellInfo const *spellProto, uint32 damage, Unit *victim)
 
void SetContestedPvP (Player *attackedPlayer=NULL)
 
uint32 GetCastingTimeForBonus (SpellInfo const *spellProto, DamageEffectType damagetype, uint32 CastingTime) const
 
float CalculateDefaultCoefficient (SpellInfo const *spellInfo, DamageEffectType damagetype) const
 
uint32 GetRemainingPeriodicAmount (ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex=0) const
 
void ApplySpellImmune (uint32 spellId, uint32 op, uint32 type, bool apply)
 
void ApplySpellDispelImmunity (const SpellInfo *spellProto, DispelType type, bool apply)
 
virtual bool IsImmunedToSpell (SpellInfo const *spellInfo) const
 
uint32 GetSchoolImmunityMask () const
 
uint32 GetMechanicImmunityMask () const
 
bool IsImmunedToDamage (SpellSchoolMask meleeSchoolMask) const
 
bool IsImmunedToDamage (SpellInfo const *spellInfo) const
 
virtual bool IsImmunedToSpellEffect (SpellInfo const *spellInfo, uint32 index) const
 
bool IsDamageReducedByArmor (SpellSchoolMask damageSchoolMask, SpellInfo const *spellInfo=NULL, uint8 effIndex=MAX_SPELL_EFFECTS)
 
uint32 CalcArmorReducedDamage (Unit *victim, const uint32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType=MAX_ATTACK)
 
uint32 CalcSpellResistance (Unit *victim, SpellSchoolMask schoolMask, SpellInfo const *spellInfo) const
 
void CalcAbsorbResist (Unit *victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32 *absorb, uint32 *resist, SpellInfo const *spellInfo=NULL)
 
void CalcHealAbsorb (Unit *victim, SpellInfo const *spellInfo, uint32 &healAmount, uint32 &absorb)
 
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)
 
float ApplyEffectModifiers (SpellInfo const *spellProto, uint8 effect_index, float value) const
 
int32 CalculateSpellDamage (Unit const *target, SpellInfo const *spellProto, uint8 effect_index, int32 const *basePoints=nullptr, float *variance=nullptr, int32 itemLevel=-1) const
 
int32 CalcSpellDuration (SpellInfo const *spellProto)
 
int32 ModSpellDuration (SpellInfo const *spellProto, Unit const *target, int32 duration, bool positive, uint32 effectMask)
 
void ModSpellCastTime (SpellInfo const *spellProto, int32 &castTime, Spell *spell=NULL)
 
void ModSpellDurationTime (SpellInfo const *spellProto, int32 &castTime, Spell *spell=NULL)
 
float CalculateLevelPenalty (SpellInfo const *spellProto) const
 
void addFollower (FollowerReference *pRef)
 
void removeFollower (FollowerReference *)
 
MotionMasterGetMotionMaster ()
 
const MotionMasterGetMotionMaster () const
 
bool IsStopped () const
 
void StopMoving ()
 -------—End of Pet responses methods-------— More...
 
void AddUnitMovementFlag (uint32 f)
 
void RemoveUnitMovementFlag (uint32 f)
 
bool HasUnitMovementFlag (uint32 f) const
 
uint32 GetUnitMovementFlags () const
 
void SetUnitMovementFlags (uint32 f)
 
void AddExtraUnitMovementFlag (uint16 f)
 
void RemoveExtraUnitMovementFlag (uint16 f)
 
uint16 HasExtraUnitMovementFlag (uint16 f) const
 
uint16 GetExtraUnitMovementFlags () const
 
void SetExtraUnitMovementFlags (uint16 f)
 
bool IsSplineEnabled () const
 
float GetPositionZMinusOffset () const
 
void SetControlled (bool apply, UnitState state)
 
void SendPetActionFeedback (uint8 msg)
 -------—Pet responses methods--------------— More...
 
void SendPetTalk (uint32 pettalk)
 
void SendPetAIReaction (ObjectGuid guid)
 
void propagateSpeedChange ()
 -------—End of Pet responses methods-------— More...
 
void ClearAllReactives ()
 
void StartReactiveTimer (ReactiveType reactive)
 
void UpdateReactives (uint32 p_time)
 
void UpdateAuraForGroup (uint8 slot)
 
bool CanProc () const
 
void SetCantProc (bool apply)
 
void AddPetAura (PetAura const *petSpell)
 
void RemovePetAura (PetAura const *petSpell)
 
uint32 GetModelForForm (ShapeshiftForm form) const
 
uint32 GetModelForTotem (PlayerTotemType totemType)
 
void SetRedirectThreat (ObjectGuid guid, uint32 pct)
 
void ResetRedirectThreat ()
 
void ModifyRedirectThreat (int32 amount)
 
uint32 GetRedirectThreatPercent () const
 
UnitGetRedirectThreatTarget ()
 
bool CreateVehicleKit (uint32 id, uint32 creatureEntry, bool loading=false)
 
void RemoveVehicleKit (bool onRemoveFromWorld=false)
 
VehicleGetVehicleKit () const
 
VehicleGetVehicle () const
 
void SetVehicle (Vehicle *vehicle)
 
bool IsOnVehicle (const Unit *vehicle) const
 
UnitGetVehicleBase () const
 
CreatureGetVehicleCreatureBase () const
 
ObjectGuid GetTransGUID () const override
 
TransportBaseGetDirectTransport () const
 Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) More...
 
bool HandleSpellClick (Unit *clicker, int8 seatId=-1)
 
void EnterVehicle (Unit *base, int8 seatId=-1)
 
void ExitVehicle (Position const *exitPosition=NULL)
 
void ChangeSeat (int8 seatId, bool next=true)
 
void _ExitVehicle (Position const *exitPosition=NULL)
 
void _EnterVehicle (Vehicle *vehicle, int8 seatId, AuraApplication const *aurApp=NULL)
 
bool isMoving () const
 
bool isTurning () const
 
virtual bool CanFly () const =0
 
bool IsFlying () const
 
bool IsFalling () const
 
void RewardRage (uint32 baseRage, bool attacker)
 
virtual float GetFollowAngle () const
 
void OutDebugInfo () const
 
virtual bool IsLoading () const
 
bool IsDuringRemoveFromWorld () const
 
PetToPet ()
 
Pet constToPet () const
 
TotemToTotem ()
 
Totem constToTotem () const
 
TempSummonToTempSummon ()
 
TempSummon constToTempSummon () const
 
ObjectGuid GetTarget () const
 
virtual void SetTarget (ObjectGuid const &)=0
 
time_t GetLastDamagedTime () const
 
void SetLastDamagedTime (time_t val)
 
int32 GetHighestExclusiveSameEffectSpellGroupValue (AuraEffect const *aurEff, AuraType auraType, bool checkMiscValue=false, int32 miscValue=0) const
 
bool IsHighestExclusiveAura (Aura const *aura, bool removeOtherAuraApplications=false)
 
virtual void Talk (std::string const &text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
 
virtual void Say (std::string const &text, Language language, WorldObject const *target=nullptr)
 
virtual void Yell (std::string const &text, Language language, WorldObject const *target=nullptr)
 
virtual void TextEmote (std::string const &text, WorldObject const *target=nullptr, bool isBossEmote=false)
 
virtual void Whisper (std::string const &text, Language language, Player *target, bool isBossWhisper=false)
 
void Talk (uint32 textId, ChatMsg msgType, float textRange, WorldObject const *target)
 
void Say (uint32 textId, WorldObject const *target=nullptr)
 
void Yell (uint32 textId, WorldObject const *target=nullptr)
 
void TextEmote (uint32 textId, WorldObject const *target=nullptr, bool isBossEmote=false)
 
void Whisper (uint32 textId, Player *target, bool isBossWhisper=false)
 
uint32 GetVirtualItemId (uint32 slot) const
 
void SetVirtualItem (uint32 slot, uint32 itemId, uint16 appearanceModId=0)
 
- Public Member Functions inherited from WorldObject
virtual ~WorldObject ()
 
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)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
float GetObjectSize () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z) const
 
void GetRandomPoint (Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (Position const &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
virtual void SetPhaseMask (uint32 newPhaseMask, bool update)
 
void CopyPhaseFrom (WorldObject *obj, bool update=false)
 
void UpdateAreaPhase ()
 
void ClearPhases (bool update=false)
 
void RebuildTerrainSwaps ()
 
void RebuildWorldMapAreaSwaps ()
 
bool HasInPhaseList (uint32 phase)
 
uint32 GetPhaseMask () const
 
bool IsInPhase (uint32 phase) const
 
bool IsInPhase (WorldObject const *obj) const
 
bool IsInTerrainSwap (uint32 terrainSwap) const
 
std::set< uint32 > constGetPhases () const
 
std::set< uint32 > constGetTerrainSwaps () const
 
std::set< uint32 > constGetWorldMapAreaSwaps () const
 
int32 GetDBPhase () const
 
void SetDBPhase (int32 p)
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
void GetZoneAndAreaId (uint32 &zoneid, uint32 &areaid) const
 
InstanceScriptGetInstanceScript ()
 
std::string constGetName () const
 
void SetName (std::string const &newname)
 
virtual std::string constGetNameForLocaleIdx (LocaleConstant) const
 
float GetDistance (WorldObject const *obj) const
 
float GetDistance (Position const &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (WorldObject const *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (WorldObject const *obj) const
 
bool IsSelfOrInSameMap (WorldObject const *obj) const
 
bool IsInMap (WorldObject const *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (Position const *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (Position const *pos, float dist) 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 (WorldObject const *obj) 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
 
bool isInFront (WorldObject const *target, float arc=float(M_PI)) const
 
bool isInBack (WorldObject const *target, float arc=float(M_PI)) const
 
bool IsInBetween (WorldObject const *obj1, WorldObject const *obj2, float size=0) const
 
virtual void SendMessageToSet (WorldPacket const *data, bool self)
 
virtual void SendMessageToSetInRange (WorldPacket const *data, float dist, bool self)
 
virtual void SendMessageToSet (WorldPacket const *data, Player const *skipped_rcvr)
 
void PlayDistanceSound (uint32 sound_id, Player *target=NULL)
 
void PlayDirectSound (uint32 sound_id, Player *target=NULL)
 
void SendObjectDeSpawnAnim (ObjectGuid guid)
 
virtual void SaveRespawnTime ()
 
void AddObjectToRemoveList ()
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
float GetSightRange (WorldObject const *target=NULL) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
Map constGetBaseMap () const
 
void SetZoneScript ()
 
ZoneScriptGetZoneScript () const
 
TempSummonSummonCreature (uint32 id, Position const &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang=0, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0) const
 
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) const
 
GameObjectFindNearestGameObject (uint32 entry, float range) const
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetPlayerListInGrid (std::list< Player * > &lList, float fMaxSearchRange) const
 
void DestroyForNearbyPlayers ()
 
void BuildUpdate (UpdateDataMapType &) override
 
void AddToObjectUpdate () override
 
void RemoveFromObjectUpdate () override
 
void AddToNotify (uint16 f)
 
bool isNeedNotify (uint16 f) const
 
uint16 GetNotifyFlags () const
 
bool NotifyExecuted (uint16 f) const
 
void SetNotified (uint16 f)
 
void ResetAllNotifies ()
 
bool isActiveObject () const
 
void setActive (bool isActiveObject)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
template<class NOTIFIER >
void VisitNearbyObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyGridObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyWorldObject (float const &radius, NOTIFIER &notifier) const
 
TransportGetTransport () const
 
float GetTransOffsetX () const
 
float GetTransOffsetY () const
 
float GetTransOffsetZ () const
 
float GetTransOffsetO () const
 
uint32 GetTransTime () const
 
int8 GetTransSeat () const
 
void SetTransport (Transport *t)
 
virtual float GetStationaryX () const
 
virtual float GetStationaryY () const
 
virtual float GetStationaryZ () const
 
virtual float GetStationaryO () const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
ObjectGuid constGetGUID () const
 
PackedGuid constGetPackGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
virtual void SetObjectScale (float scale)
 
TypeID 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
 
int32 GetInt32Value (uint16 index) const
 
uint32 GetUInt32Value (uint16 index) const
 
uint64 GetUInt64Value (uint16 index) const
 
float GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
ObjectGuid constGetGuidValue (uint16 index) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void UpdateUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, 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 SetGuidValue (uint16 index, ObjectGuid const &value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddGuidValue (uint16 index, ObjectGuid const &value)
 
bool RemoveGuidValue (uint16 index, ObjectGuid const &value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt16Value (uint16 index, uint8 offset, int16 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 ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void ToggleByteFlag (uint16 index, uint8 offset, uint8 flag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
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)
 
std::vector< uint32 > constGetDynamicValues (uint16 index) const
 
void AddDynamicValue (uint16 index, uint32 value)
 
void RemoveDynamicValue (uint16 index, uint32 value)
 
void ClearDynamicValue (uint16 index)
 
void SetDynamicValue (uint16 index, uint8 offset, uint32 value)
 
void ClearUpdateMask (bool remove)
 
uint16 GetValuesCount () const
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) const
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
PlayerToPlayer ()
 
Player constToPlayer () const
 
CreatureToCreature ()
 
Creature constToCreature () const
 
UnitToUnit ()
 
Unit constToUnit () const
 
GameObjectToGameObject ()
 
GameObject constToGameObject () const
 
CorpseToCorpse ()
 
Corpse constToCorpse () const
 
DynamicObjectToDynObject ()
 
DynamicObject constToDynObject () const
 
AreaTriggerToAreaTrigger ()
 
AreaTrigger constToAreaTrigger () const
 
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
 WorldLocation (WorldLocation const &loc)
 
void WorldRelocate (WorldLocation const &loc)
 
void WorldRelocate (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
WorldLocation GetWorldLocation () const
 
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 Relocate (G3D::Vector3 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 Public Member Functions inherited from Position
static float NormalizeOrientation (float o)
 

Public Attributes

uint32 m_extraAttacks
 
bool m_canDualWield
 
ControlList m_Controlled
 
Playerm_movedPlayer
 
ObjectGuid m_SummonSlot [MAX_SUMMON_SLOT]
 
ObjectGuid m_ObjectSlot [MAX_GAMEOBJECT_SLOT]
 
float m_modMeleeHitChance
 
float m_modRangedHitChance
 
float m_modSpellHitChance
 
int32 m_baseSpellCritChance
 
float m_threatModifier [MAX_SPELL_SCHOOL]
 
float m_modAttackSpeedPct [3]
 
EventProcessor m_Events
 
SpellImmuneList m_spellImmune [MAX_SPELL_IMMUNITY]
 
uint32 m_lastSanctuaryTime
 
PetAuraSet m_petAuras
 
bool IsAIEnabled
 
bool NeedChangeAI
 
ObjectGuid LastCharmerGUID
 
bool m_ControlledByPlayer
 
Movement::MoveSplinemovespline
 
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32,
uint32, StealthType,
TOTAL_STEALTH_TYPES
m_stealth
 
FlaggedValuesArray32< int32,
uint32, StealthType,
TOTAL_STEALTH_TYPES
m_stealthDetect
 
FlaggedValuesArray32< int32,
uint32, InvisibilityType,
TOTAL_INVISIBILITY_TYPES
m_invisibility
 
FlaggedValuesArray32< int32,
uint32, InvisibilityType,
TOTAL_INVISIBILITY_TYPES
m_invisibilityDetect
 
FlaggedValuesArray32< int32,
uint32,
ServerSideVisibilityType,
TOTAL_SERVERSIDE_VISIBILITY_TYPES
m_serverSideVisibility
 
FlaggedValuesArray32< int32,
uint32,
ServerSideVisibilityType,
TOTAL_SERVERSIDE_VISIBILITY_TYPES
m_serverSideVisibilityDetect
 
uint32 LastUsedScriptID
 
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
< DynamicObject * > 
DynObjectList
 
typedef std::list< GameObject * > GameObjectList
 

Protected Member Functions

 Unit (bool isWorldObject)
 
void BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, Player *target) const override
 
void DestroyForPlayer (Player *target) const override
 
void _UpdateSpells (uint32 time)
 
void _DeleteRemovedAuras ()
 
void _UpdateAutoRepeatSpell ()
 
virtual SpellSchoolMask GetMeleeDamageSchoolMask () const
 
bool IsAlwaysVisibleFor (WorldObject const *seer) const override
 
bool IsAlwaysDetectableFor (WorldObject const *seer) const override
 
void DisableSpline ()
 
void SetFeared (bool apply)
 
void SetConfused (bool apply)
 
void SetStunned (bool apply)
 
void SetRooted (bool apply, bool packetOnly=false)
 
- Protected Member Functions inherited from WorldObject
 WorldObject (bool isWorldObject)
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
virtual bool IsNeverVisible () const
 
virtual bool IsInvisibleDueToDespawn () const
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid const &guid)
 
std::string _ConcatFields (uint16 startIndex, uint16 size) const
 
void _LoadIntoDataField (std::string const &data, uint32 startOffset, uint32 count)
 
uint32 GetUpdateFieldData (Player const *target, uint32 *&flags) const
 
uint32 GetDynamicUpdateFieldData (Player const *target, uint32 *&flags) const
 
void BuildMovementUpdate (ByteBuffer *data, uint32 flags) const
 
virtual void BuildDynamicValuesUpdate (uint8 updatetype, ByteBuffer *data, Player *target) const
 
void AddToObjectUpdateIfNeeded ()
 

Protected Attributes

UnitAIi_AI
 
UnitAIi_disabledAI
 
bool m_AutoRepeatFirstCast
 
uint32 m_attackTimer [MAX_ATTACK]
 
float m_createStats [MAX_STATS]
 
AttackerSet m_attackers
 
Unitm_attacking
 
bool m_shouldReacquireTarget
 
DeathState m_deathState
 
int32 m_procDeep
 
DynObjectList m_dynObj
 
GameObjectList m_gameObj
 
uint32 m_transform
 
Spellm_currentSpells [CURRENT_MAX_SPELL]
 
AuraMap m_ownedAuras
 
AuraApplicationMap m_appliedAuras
 
AuraList m_removedAuras
 
AuraMap::iterator m_auraUpdateIterator
 
uint32 m_removedAurasCount
 
AuraEffectList m_modAuras [TOTAL_AURAS]
 
AuraList m_scAuras
 
AuraApplicationList m_interruptableAuras
 
AuraStateAurasMap m_auraStateAuras
 
uint32 m_interruptMask
 
float m_auraModifiersGroup [UNIT_MOD_END][MODIFIER_TYPE_END]
 
float m_weaponDamage [MAX_ATTACK][2]
 
bool m_canModifyStats
 
VisibleAuraMap m_visibleAuras
 
float m_speed_rate [MAX_MOVE_TYPE]
 
CharmInfom_charmInfo
 
SharedVisionList m_sharedVision
 
MotionMasteri_motionMaster
 
uint32 m_reactiveTimer [MAX_REACTIVE]
 
uint32 m_regenTimer
 
ThreatManager m_ThreatManager
 
Vehiclem_vehicle
 
Vehiclem_vehicleKit
 
uint32 m_unitTypeMask
 
LiquidTypeEntry const_lastLiquid
 
uint32 m_movementCounter
 Incrementing counter used in movement packets. More...
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
Transportm_transport
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
TypeID m_objectTypeId
 
uint32 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
std::vector< uint32 > * _dynamicValues
 
UpdateMask _changesMask
 
UpdateMask _dynamicChangesMask
 
UpdateMask_dynamicChangesArrayMask
 
uint16 m_valuesCount
 
uint16 _dynamicValuesCount
 
uint16 _fieldNotifyFlags
 
bool m_objectUpdated
 

Private Member Functions

bool IsTriggeredAtSpellProcEvent (Unit *victim, Aura *aura, SpellInfo const *procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const *&spellProcEvent)
 
bool HandleDummyAuraProc (Unit *victim, uint32 damage, AuraEffect *triggeredByAura, SpellInfo const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
 
bool HandleAuraProc (Unit *victim, uint32 damage, Aura *triggeredByAura, SpellInfo const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown, bool *handled)
 
bool HandleProcTriggerSpell (Unit *victim, uint32 damage, AuraEffect *triggeredByAura, SpellInfo const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
 
bool HandleOverrideClassScriptAuraProc (Unit *victim, uint32 damage, AuraEffect *triggeredByAura, SpellInfo const *procSpell, uint32 cooldown)
 
bool HandleAuraRaidProcFromChargeWithValue (AuraEffect *triggeredByAura)
 
bool HandleAuraRaidProcFromCharge (AuraEffect *triggeredByAura)
 
void UpdateSplineMovement (uint32 t_diff)
 
void UpdateSplinePosition ()
 
float GetCombatRatingReduction (CombatRating cr) const
 
uint32 GetCombatRatingDamageReduction (CombatRating cr, float rate, float cap, uint32 damage) const
 

Private Attributes

uint32 m_state
 
uint32 m_CombatTimer
 
TimeTrackerSmall m_movesplineTimer
 
Diminishing m_Diminishing
 
HostileRefManager m_HostileRefManager
 
FollowerRefManager m_FollowingRefManager
 
RedirectThreatInfo _redirectThreadInfo
 
bool m_cleanupDone
 
bool m_duringRemoveFromWorld
 
uint32 _oldFactionId
 faction before charm More...
 
bool _isWalkingBeforeCharm
 Are we walking before we were charmed? More...
 
uint16 _aiAnimKitId
 
uint16 _movementAnimKitId
 
uint16 _meleeAnimKitId
 
time_t _lastDamagedTime
 
SpellHistory_spellHistory
 

Friends

class VehicleJoinEvent
 

Member Typedef Documentation

typedef std::set<Unit*> Unit::AttackerSet
typedef std::pair<AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator> Unit::AuraApplicationMapBounds
typedef std::pair<AuraApplicationMap::iterator, AuraApplicationMap::iterator> Unit::AuraApplicationMapBoundsNonConst
typedef std::list<AuraEffect*> Unit::AuraEffectList
typedef std::list<Aura*> Unit::AuraList
typedef std::multimap<uint32, Aura*> Unit::AuraMap
typedef std::pair<AuraMap::const_iterator, AuraMap::const_iterator> Unit::AuraMapBounds
typedef std::pair<AuraMap::iterator, AuraMap::iterator> Unit::AuraMapBoundsNonConst
typedef std::pair<AuraStateAurasMap::const_iterator, AuraStateAurasMap::const_iterator> Unit::AuraStateAurasMapBounds
typedef std::set<Unit*> Unit::ControlList
typedef std::list<DynamicObject*> Unit::DynObjectList
protected
typedef std::list<GameObject*> Unit::GameObjectList
protected
typedef std::set<PetAura const*> Unit::PetAuraSet

Constructor & Destructor Documentation

Unit::~Unit ( )
virtual
311 {
312  // set current spells as deletable
313  for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
314  if (m_currentSpells[i])
315  {
317  m_currentSpells[i] = NULL;
318  }
319 
321 
322  delete i_motionMaster;
323  delete m_charmInfo;
324  delete movespline;
325  delete _spellHistory;
326 
329  ASSERT(m_attackers.empty());
330  ASSERT(m_sharedVision.empty());
331  ASSERT(m_Controlled.empty());
332  ASSERT(m_appliedAuras.empty());
333  ASSERT(m_ownedAuras.empty());
334  ASSERT(m_removedAuras.empty());
335  ASSERT(m_gameObj.empty());
336  ASSERT(m_dynObj.empty());
337 }
AuraList m_removedAuras
Definition: Unit.h:2275
AuraMap m_ownedAuras
Definition: Unit.h:2273
SpellHistory * _spellHistory
Definition: Unit.h:2364
bool m_duringRemoveFromWorld
Definition: Unit.h:2353
Movement::MoveSpline * movespline
Definition: Unit.h:2213
SharedVisionList m_sharedVision
Definition: Unit.h:2293
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
CharmInfo * m_charmInfo
Definition: Unit.h:2292
arena_t NULL
Definition: jemalloc_internal.h:624
void _DeleteRemovedAuras()
Definition: Unit.cpp:2668
GameObjectList m_gameObj
Definition: Unit.h:2267
MotionMaster * i_motionMaster
Definition: Unit.h:2297
Unit * m_attacking
Definition: Unit.h:2256
ControlList m_Controlled
Definition: Unit.h:1738
#define CURRENT_MAX_SPELL
Definition: Unit.h:1115
DynObjectList m_dynObj
Definition: Unit.h:2264
AttackerSet m_attackers
Definition: Unit.h:2255
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:601
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

Unit::Unit ( bool  isWorldObject)
explicitprotected
197  :
198  WorldObject(isWorldObject), m_movedPlayer(NULL), m_lastSanctuaryTime(0),
199  IsAIEnabled(false), NeedChangeAI(false), LastCharmerGUID(),
206 {
209 
211 
218 
219  m_extraAttacks = 0;
220  m_canDualWield = false;
221 
222  m_movementCounter = 0;
223 
224  m_state = 0;
226 
227  for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
228  m_currentSpells[i] = NULL;
229 
230  for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
231  m_SummonSlot[i].Clear();
232 
233  for (uint8 i = 0; i < MAX_GAMEOBJECT_SLOT; ++i)
234  m_ObjectSlot[i].Clear();
235 
237 
238  m_interruptMask = 0;
239  m_transform = 0;
240  m_canModifyStats = false;
241 
242  for (uint8 i = 0; i < MAX_SPELL_IMMUNITY; ++i)
243  m_spellImmune[i].clear();
244 
245  for (uint8 i = 0; i < UNIT_MOD_END; ++i)
246  {
247  m_auraModifiersGroup[i][BASE_VALUE] = 0.0f;
249  m_auraModifiersGroup[i][BASE_PCT] = 1.0f;
251  m_auraModifiersGroup[i][TOTAL_PCT] = 1.0f;
252  }
253  // implement 50% base damage from offhand
255 
256  for (uint8 i = 0; i < MAX_ATTACK; ++i)
257  {
260  }
261 
262  for (uint8 i = 0; i < MAX_STATS; ++i)
263  m_createStats[i] = 0.0f;
264 
265  m_attacking = nullptr;
266  m_shouldReacquireTarget = false;
267  if (GetTypeId() == TYPEID_PLAYER)
268  {
269  m_modMeleeHitChance = 7.5f;
270  m_modRangedHitChance = 7.5f;
271  m_modSpellHitChance = 15.0f;
272  }
273  else
274  {
275  m_modMeleeHitChance = 0.0f;
276  m_modRangedHitChance = 0.0f;
277  m_modSpellHitChance = 0.0f;
278  }
280 
281  m_CombatTimer = 0;
282 
283  for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
284  m_threatModifier[i] = 1.0f;
285 
286  for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
287  m_speed_rate[i] = 1.0f;
288 
289  m_charmInfo = nullptr;
290 
292 
293  // remove aurastates allowing special moves
294  for (uint8 i = 0; i < MAX_REACTIVE; ++i)
295  m_reactiveTimer[i] = 0;
296 
297  m_cleanupDone = false;
298  m_duringRemoveFromWorld = false;
299 
301 
302  _lastLiquid = NULL;
303 
304  _oldFactionId = 0;
305  _isWalkingBeforeCharm = false;
306 }
Definition: MoveSpline.h:49
Definition: Unit.h:620
#define BASE_MINDAMAGE
Definition: Unit.h:200
uint32 m_removedAurasCount
Definition: Unit.h:2277
uint16 _meleeAnimKitId
Definition: Unit.h:2360
#define MAX_MOVE_TYPE
Definition: Unit.h:610
#define MAX_GAMEOBJECT_SLOT
Definition: Unit.h:1287
bool m_ControlledByPlayer
Definition: Unit.h:2175
float m_modMeleeHitChance
Definition: Unit.h:1939
AuraMap m_ownedAuras
Definition: Unit.h:2273
Definition: Unit.h:444
SpellHistory * _spellHistory
Definition: Unit.h:2364
bool m_shouldReacquireTarget
Definition: Unit.h:2257
bool m_duringRemoveFromWorld
Definition: Unit.h:2353
Definition: Unit.h:1077
Definition: Unit.h:619
int32 m_baseSpellCritChance
Definition: Unit.h:1942
Movement::MoveSpline * movespline
Definition: Unit.h:2213
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:538
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
CharmInfo * m_charmInfo
Definition: Unit.h:2292
Definition: Unit.h:434
Vehicle * m_vehicleKit
Definition: Unit.h:2305
Definition: Unit.h:541
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:383
Definition: ObjectGuid.h:32
uint32 m_lastSanctuaryTime
Definition: Unit.h:1989
arena_t NULL
Definition: jemalloc_internal.h:624
uint16 _aiAnimKitId
Definition: Unit.h:2358
bool m_AutoRepeatFirstCast
Definition: Unit.h:2249
uint32 m_reactiveTimer[MAX_REACTIVE]
Definition: Unit.h:2299
float m_speed_rate[MAX_MOVE_TYPE]
Definition: Unit.h:2290
Vehicle * m_vehicle
Definition: Unit.h:2304
bool m_cleanupDone
Definition: Unit.h:2352
Definition: Unit.h:513
Definition: Unit.h:511
bool IsAIEnabled
Definition: Unit.h:2161
uint16 m_objectType
Definition: Object.h:227
uint32 m_transform
Definition: Unit.h:2269
#define MAX_SPELL_SCHOOL
Definition: SharedDefines.h:283
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2285
uint32 _oldFactionId
faction before charm
Definition: Unit.h:2355
time_t _lastDamagedTime
Definition: Unit.h:2362
uint32 m_state
Definition: Unit.h:2340
UnitAI * i_AI
Definition: Unit.h:2242
UnitAI * i_disabledAI
Definition: Unit.h:2242
Definition: SharedDefines.h:1749
#define MAX_SPELL_IMMUNITY
Definition: SharedDefines.h:1869
#define MAX_STATS
Definition: SharedDefines.h:244
Definition: ObjectGuid.h:49
int32 m_procDeep
Definition: Unit.h:2261
float m_modSpellHitChance
Definition: Unit.h:1941
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SpellHistory.h:42
TypeID m_objectTypeId
Definition: Object.h:229
Definition: Unit.h:618
Definition: MotionMaster.h:82
RedirectThreatInfo _redirectThreadInfo
Definition: Unit.h:2350
MotionMaster * i_motionMaster
Definition: Unit.h:2297
DeathState m_deathState
Definition: Unit.h:2259
Unit * m_attacking
Definition: Unit.h:2256
bool _isWalkingBeforeCharm
Are we walking before we were charmed?
Definition: Unit.h:2356
HostileRefManager m_HostileRefManager
Definition: Unit.h:2346
float m_modAttackSpeedPct[3]
Definition: Unit.h:1945
#define BASE_MAXDAMAGE
Definition: Unit.h:201
float m_createStats[MAX_STATS]
Definition: Unit.h:2253
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
bool NeedChangeAI
Definition: Unit.h:2161
#define MAX_REACTIVE
Definition: Unit.h:1279
ThreatManager m_ThreatManager
Definition: Unit.h:2302
uint32 m_extraAttacks
Definition: Unit.h:1366
Definition: Unit.h:437
Definition: UpdateData.h:42
Definition: Unit.h:438
Definition: Unit.h:445
WorldObject(bool isWorldObject)
Definition: Object.cpp:1445
Definition: ObjectGuid.h:33
#define CURRENT_MAX_SPELL
Definition: Unit.h:1115
ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT]
Definition: Unit.h:1930
Definition: Unit.h:435
uint16 _movementAnimKitId
Definition: Unit.h:2359
AuraMap::iterator m_auraUpdateIterator
Definition: Unit.h:2276
bool m_canDualWield
Definition: Unit.h:1367
uint32 m_unitTypeMask
Definition: Unit.h:2307
uint32 m_interruptMask
Definition: Unit.h:2283
uint32 m_CombatTimer
Definition: Unit.h:2341
float m_threatModifier[MAX_SPELL_SCHOOL]
Definition: Unit.h:1944
#define MAX_SUMMON_SLOT
Definition: Unit.h:1285
uint8_t uint8
Definition: Define.h:152
Definition: SharedDefines.h:1742
float m_modRangedHitChance
Definition: Unit.h:1940
Definition: Unit.h:436
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2251
float m_weaponDamage[MAX_ATTACK][2]
Definition: Unit.h:2286
Definition: Unit.h:857
Player * m_movedPlayer
Definition: Unit.h:1753
LiquidTypeEntry const * _lastLiquid
Definition: Unit.h:2308
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1988
Definition: Unit.h:617
bool m_canModifyStats
Definition: Unit.h:2287
uint32 m_regenTimer
Definition: Unit.h:2300
uint32 m_updateFlag
Definition: Object.h:230
ObjectGuid LastCharmerGUID
Definition: Unit.h:2162

+ Here is the call graph for this function:

Member Function Documentation

void Unit::_addAttacker ( Unit pAttacker)
7202 {
7203  m_attackers.insert(pAttacker);
7204 }
AttackerSet m_attackers
Definition: Unit.h:2255

+ Here is the caller graph for this function:

void Unit::_AddAura ( UnitAura aura,
Unit caster 
)
3091 {
3093  m_ownedAuras.insert(AuraMap::value_type(aura->GetId(), aura));
3094 
3096 
3097  if (aura->IsRemoved())
3098  return;
3099 
3101  if (aura->IsSingleTarget())
3102  {
3103  ASSERT((IsInWorld() && !IsDuringRemoveFromWorld()) || (aura->GetCasterGUID() == GetGUID()) ||
3105  /* @HACK: Player is not in world during loading auras.
3106  * Single target auras are not saved or loaded from database
3107  * but may be created as a result of aura links (player mounts with passengers)
3108  */
3109 
3110  // register single target aura
3111  caster->GetSingleCastAuras().push_back(aura);
3112  // remove other single target auras
3113  Unit::AuraList& scAuras = caster->GetSingleCastAuras();
3114  for (Unit::AuraList::iterator itr = scAuras.begin(); itr != scAuras.end();)
3115  {
3116  if ((*itr) != aura &&
3117  (*itr)->IsSingleTargetWith(aura))
3118  {
3119  (*itr)->Remove();
3120  itr = scAuras.begin();
3121  }
3122  else
3123  ++itr;
3124  }
3125  }
3126 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool IsSingleTargetWith(Aura const *aura) const
Definition: SpellAuras.cpp:1090
AuraMap m_ownedAuras
Definition: Unit.h:2273
virtual bool IsLoading() const
Definition: Unit.h:2197
void SetIsSingleTarget(bool val)
Definition: SpellAuras.h:206
std::list< Aura * > AuraList
Definition: Unit.h:1323
bool IsSingleTarget() const
Definition: SpellAuras.h:204
bool m_cleanupDone
Definition: Unit.h:2352
void _RemoveNoStackAurasDueToAura(Aura *aura)
Definition: Unit.cpp:3316
Definition: SpellAuraDefines.h:296
bool IsDuringRemoveFromWorld() const
Definition: Unit.h:2198
bool IsRemoved() const
Definition: SpellAuras.h:201
AuraList & GetSingleCastAuras()
Definition: Unit.h:1833
bool HasEffectType(AuraType type) const
Definition: SpellAuras.cpp:1186
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool IsSingleTarget() const
Definition: SpellInfo.cpp:1596
#define ASSERT
Definition: Errors.h:55
bool IsInWorld() const
Definition: Object.h:100
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
uint32 GetId() const
Definition: SpellAuras.h:131

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::_ApplyAllAuraStatMods ( )
4066 {
4067  for (AuraApplicationMap::iterator i = m_appliedAuras.begin(); i != m_appliedAuras.end(); ++i)
4068  (*i).second->GetBase()->HandleAllEffects(i->second, AURA_EFFECT_HANDLE_STAT, true);
4069 }
Definition: SpellAuraDefines.h:43
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
void Unit::_ApplyAura ( AuraApplication aurApp,
uint32  effMask 
)
3181 {
3182  Aura* aura = aurApp->GetBase();
3183 
3185 
3186  if (aurApp->GetRemoveMode())
3187  return;
3188 
3189  // Update target aura state flag
3190  if (AuraStateType aState = aura->GetSpellInfo()->GetAuraState(GetMap()->GetDifficultyID()))
3191  ModifyAuraState(aState, true);
3192 
3193  if (aurApp->GetRemoveMode())
3194  return;
3195 
3196  // Sitdown on apply aura req seated
3199 
3200  Unit* caster = aura->GetCaster();
3201 
3202  if (aurApp->GetRemoveMode())
3203  return;
3204 
3205  aura->HandleAuraSpecificMods(aurApp, caster, true, false);
3206  aura->HandleAuraSpecificPeriodics(aurApp, caster);
3207 
3208  // apply effects of the aura
3209  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3210  {
3211  if (effMask & 1 << i && (!aurApp->GetRemoveMode()))
3212  aurApp->_HandleEffect(i, true);
3213  }
3214 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
Definition: Unit.h:208
void ModifyAuraState(AuraStateType flag, bool apply)
Definition: Unit.cpp:7422
Map * GetMap() const
Definition: Object.h:543
bool IsSitState() const
Definition: Unit.cpp:12757
Unit * GetCaster() const
Definition: SpellAuras.cpp:438
void HandleAuraSpecificMods(AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
Definition: SpellAuras.cpp:1238
Aura * GetBase() const
Definition: SpellAuras.h:75
AuraStateType
Definition: SharedDefines.h:1754
AuraStateType GetAuraState(uint32 difficulty) const
Definition: SpellInfo.cpp:2221
uint32 AuraInterruptFlags
Definition: SpellInfo.h:368
void HandleAuraSpecificPeriodics(AuraApplication const *aurApp, Unit *caster)
Definition: SpellAuras.cpp:1584
void _HandleEffect(uint8 effIndex, bool apply)
Definition: SpellAuras.cpp:161
void _RemoveNoStackAurasDueToAura(Aura *aura)
Definition: Unit.cpp:3316
Definition: Unit.h:72
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:12772
uint8_t uint8
Definition: Define.h:152
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
Definition: SpellAuras.h:116
Definition: Unit.h:1305
AuraRemoveMode GetRemoveMode() const
Definition: SpellAuras.h:86

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::_ApplyAuraEffect ( Aura aura,
uint8  effIndex 
)
3167 {
3168  ASSERT(aura);
3169  ASSERT(aura->HasEffect(effIndex));
3170  AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID());
3171  ASSERT(aurApp);
3172  if (!aurApp->GetEffectMask())
3173  _ApplyAura(aurApp, 1 << effIndex);
3174  else
3175  aurApp->_HandleEffect(effIndex, true);
3176 }
Definition: SpellAuras.h:50
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
void _ApplyAura(AuraApplication *aurApp, uint32 effMask)
Definition: Unit.cpp:3180
bool HasEffect(uint8 effIndex) const
Definition: SpellAuras.h:223
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

AuraApplication * Unit::_CreateAuraApplication ( Aura aura,
uint32  effMask 
)
3131 {
3132  // can't apply aura on unit which is going to be deleted - to not create a memory leak
3134  // aura musn't be removed
3135  ASSERT(!aura->IsRemoved());
3136 
3137  // aura mustn't be already applied on target
3138  ASSERT (!aura->IsAppliedOnTarget(GetGUID()) && "Unit::_CreateAuraApplication: aura musn't be applied on target");
3139 
3140  SpellInfo const* aurSpellInfo = aura->GetSpellInfo();
3141  uint32 aurId = aurSpellInfo->Id;
3142 
3143  // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load)
3144  if (!IsAlive() && !aurSpellInfo->IsDeathPersistent() &&
3145  (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->GetSession()->PlayerLoading()))
3146  return NULL;
3147 
3148  Unit* caster = aura->GetCaster();
3149 
3150  AuraApplication * aurApp = new AuraApplication(this, caster, aura, effMask);
3151  m_appliedAuras.insert(AuraApplicationMap::value_type(aurId, aurApp));
3152 
3153  if (aurSpellInfo->AuraInterruptFlags)
3154  {
3155  m_interruptableAuras.push_back(aurApp);
3156  AddInterruptMask(aurSpellInfo->AuraInterruptFlags);
3157  }
3158 
3159  if (AuraStateType aState = aura->GetSpellInfo()->GetAuraState(GetMap()->GetDifficultyID()))
3160  m_auraStateAuras.insert(AuraStateAurasMap::value_type(aState, aurApp));
3161 
3162  aura->_ApplyForTarget(this, caster, aurApp);
3163  return aurApp;
3164 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
uint32 Id
Definition: SpellInfo.h:329
Map * GetMap() const
Definition: Object.h:543
Unit * GetCaster() const
Definition: SpellAuras.cpp:438
Definition: SpellInfo.h:326
AuraStateType
Definition: SharedDefines.h:1754
AuraStateAurasMap m_auraStateAuras
Definition: Unit.h:2282
Definition: SpellAuras.h:50
AuraStateType GetAuraState(uint32 difficulty) const
Definition: SpellInfo.cpp:2221
arena_t NULL
Definition: jemalloc_internal.h:624
bool m_cleanupDone
Definition: Unit.h:2352
AuraApplicationList m_interruptableAuras
Definition: Unit.h:2281
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
bool IsRemoved() const
Definition: SpellAuras.h:201
uint32_t uint32
Definition: Define.h:150
virtual void _ApplyForTarget(Unit *target, Unit *caster, AuraApplication *auraApp)
Definition: SpellAuras.cpp:461
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
bool IsAppliedOnTarget(ObjectGuid guid) const
Definition: SpellAuras.h:235
#define ASSERT
Definition: Errors.h:55
void AddInterruptMask(uint32 mask)
Definition: Unit.h:2009
Definition: Unit.h:1305
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

void Unit::_DeleteRemovedAuras ( )
protected
2669 {
2670  while (!m_removedAuras.empty())
2671  {
2672  delete m_removedAuras.front();
2673  m_removedAuras.pop_front();
2674  }
2675 }
AuraList m_removedAuras
Definition: Unit.h:2275

+ Here is the caller graph for this function:

void Unit::_EnterVehicle ( Vehicle vehicle,
int8  seatId,
AuraApplication const aurApp = NULL 
)
15255 {
15256  // Must be called only from aura handler
15257  ASSERT(aurApp);
15258 
15259  if (!IsAlive() || GetVehicleKit() == vehicle || vehicle->GetBase()->IsOnVehicle(this))
15260  return;
15261 
15262  if (m_vehicle)
15263  {
15264  if (m_vehicle != vehicle)
15265  {
15266  TC_LOG_DEBUG("entities.vehicle", "EnterVehicle: %u exit %u and enter %u.", GetEntry(), m_vehicle->GetBase()->GetEntry(), vehicle->GetBase()->GetEntry());
15267  ExitVehicle();
15268  }
15269  else if (seatId >= 0 && seatId == GetTransSeat())
15270  return;
15271  }
15272 
15273  if (aurApp->GetRemoveMode())
15274  return;
15275 
15276  if (Player* player = ToPlayer())
15277  {
15278  if (vehicle->GetBase()->GetTypeId() == TYPEID_PLAYER && player->IsInCombat())
15279  {
15280  vehicle->GetBase()->RemoveAura(const_cast<AuraApplication*>(aurApp));
15281  return;
15282  }
15283  }
15284 
15285  ASSERT(!m_vehicle);
15286  (void)vehicle->AddPassenger(this, seatId);
15287 }
bool IsOnVehicle(const Unit *vehicle) const
Definition: Unit.cpp:14336
bool AddPassenger(Unit *passenger, int8 seatId=-1)
Attempts to add a passenger to the vehicle on 'seatId'.
Definition: Vehicle.cpp:394
Vehicle * m_vehicle
Definition: Unit.h:2304
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
Player * ToPlayer()
Definition: Object.h:191
void ExitVehicle(Position const *exitPosition=NULL)
Definition: Unit.cpp:15321
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
int8 GetTransSeat() const
Definition: Object.h:608
Definition: ObjectGuid.h:33
#define ASSERT
Definition: Errors.h:55
uint32 GetEntry() const
Definition: Object.h:107
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::_ExitVehicle ( Position const exitPosition = NULL)

It's possible m_vehicle is NULL, when this function is called indirectly from ::Abort. In that case it was not possible to add the passenger to the vehicle. The vehicle aura has already been removed from the target in the aforementioned function and we don't need to do anything else at this point.

15341 {
15345  if (!m_vehicle)
15346  return;
15347 
15348  // This should be done before dismiss, because there may be some aura removal
15349  Vehicle* vehicle = m_vehicle->RemovePassenger(this);
15350 
15351  Player* player = ToPlayer();
15352 
15353  // If the player is on mounted duel and exits the mount, he should immediatly lose the duel
15354  if (player && player->duel && player->duel->isMounted)
15355  player->DuelComplete(DUEL_FLED);
15356 
15357  SetControlled(false, UNIT_STATE_ROOT); // SMSG_MOVE_FORCE_UNROOT, ~MOVEMENTFLAG_ROOT
15358 
15359  Position pos;
15360  if (!exitPosition) // Exit position not specified
15361  pos = vehicle->GetBase()->GetPosition(); // This should use passenger's current position, leaving it as it is now
15362  // because we calculate positions incorrect (sometimes under map)
15363  else
15364  pos = *exitPosition;
15365 
15367 
15368  if (player)
15369  player->SetFallInformation(0, GetPositionZ());
15370 
15371  float height = pos.GetPositionZ();
15372 
15373  Movement::MoveSplineInit init(this);
15374 
15375  // Creatures without inhabit type air should begin falling after exiting the vehicle
15376  if (GetTypeId() == TYPEID_UNIT && !CanFly() && height > GetMap()->GetWaterOrGroundLevel(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), &height) + 0.1f)
15377  init.SetFall();
15378 
15379  init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
15380  init.SetFacing(GetOrientation());
15381  init.SetTransportExit();
15382  init.Launch();
15383 
15384  if (player)
15385  player->ResummonPetTemporaryUnSummonedIfAny();
15386 
15387  if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION) && vehicle->GetBase()->GetTypeId() == TYPEID_UNIT)
15388  if (((Minion*)vehicle->GetBase())->GetOwner() == this)
15389  vehicle->GetBase()->ToCreature()->DespawnOrUnsummon(1);
15390 
15392  {
15393  // Vehicle just died, we die too
15394  if (vehicle->GetBase()->getDeathState() == JUST_DIED)
15396  // If for other reason we as minion are exiting the vehicle (ejected, master dismounted) - unsummon
15397  else
15398  ToTempSummon()->UnSummon(2000); // Approximation
15399  }
15400 }
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
Definition: Vehicle.h:32
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:4728
void AddUnitState(uint32 f)
Definition: Unit.h:1394
Definition: Unit.h:542
Definition: Unit.h:867
Definition: ObjectGuid.h:32
Vehicle * m_vehicle
Definition: Unit.h:2304
Definition: Unit.h:859
Player * ToPlayer()
Definition: Object.h:191
TempSummon * ToTempSummon()
Definition: Unit.h:2206
virtual void UnSummon(uint32 msTime=0)
Definition: TemporarySummon.cpp:237
TypeID GetTypeId() const
Definition: Object.h:113
Definition: TemporarySummon.h:66
Definition: Unit.h:569
float GetOrientation() const
Definition: Position.h:107
void SetControlled(bool apply, UnitState state)
Definition: Unit.cpp:13808
float GetPositionY() const
Definition: Position.h:105
void GetPosition(float &x, float &y) const
Definition: Position.h:109
float GetPositionZ() const
Definition: Position.h:106
Vehicle * RemovePassenger(Unit *passenger)
Removes the passenger from the vehicle.
Definition: Vehicle.cpp:466
virtual void setDeathState(DeathState s)
Definition: Unit.cpp:10593
Unit * GetOwner() const
Definition: Unit.cpp:7542
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:560
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
Definition: Position.h:27
virtual bool CanFly() const =0
Definition: MoveSplineInit.h:52
float GetPositionX() const
Definition: Position.h:104
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49
DeathState getDeathState() const
Definition: Unit.h:1695

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::_IsNoStackAuraDueToAura ( Aura appliedAura,
Aura existingAura 
) const
bool Unit::_IsValidAssistTarget ( Unit const target,
SpellInfo const bySpell 
) const
10130 {
10131  ASSERT(target);
10132 
10133  // can assist to self
10134  if (this == target)
10135  return true;
10136 
10137  // can't assist unattackable units or GMs
10138  if (target->HasUnitState(UNIT_STATE_UNATTACKABLE)
10139  || (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster()))
10140  return false;
10141 
10142  // can't assist own vehicle or passenger
10143  if (m_vehicle)
10144  if (IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target))
10145  return false;
10146 
10147  // can't assist invisible
10148  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea(GetMap()->GetDifficultyID())))
10149  return false;
10150 
10151  // can't assist dead
10152  if ((!bySpell || !bySpell->IsAllowingDeadTarget()) && !target->IsAlive())
10153  return false;
10154 
10155  // can't assist untargetable
10156  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE))
10157  && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
10158  return false;
10159 
10160  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
10161  {
10163  {
10164  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))
10165  return false;
10166  }
10167  else
10168  {
10169  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
10170  return false;
10171  }
10172  }
10173 
10174  // can't assist non-friendly targets
10175  if (GetReactionTo(target) < REP_NEUTRAL
10176  && target->GetReactionTo(this) < REP_NEUTRAL
10178  return false;
10179 
10180  // PvP case
10181  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
10182  {
10183  Player const* targetPlayerOwner = target->GetAffectingPlayer();
10185  {
10186  Player const* selfPlayerOwner = GetAffectingPlayer();
10187  if (selfPlayerOwner && targetPlayerOwner)
10188  {
10189  // can't assist player which is dueling someone
10190  if (selfPlayerOwner != targetPlayerOwner
10191  && targetPlayerOwner->duel)
10192  return false;
10193  }
10194  // can't assist player in ffa_pvp zone from outside
10195  if ((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP)
10197  return false;
10198  // can't assist player out of sanctuary from sanctuary if has pvp enabled
10199  if (target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_PVP)
10201  return false;
10202  }
10203  }
10204  // PvC case - player can assist creature only if has specific type flags
10205  // !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) &&
10207  && (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
10208  && !((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_PVP)))
10209  {
10210  if (Creature const* creatureTarget = target->ToCreature())
10211  return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_TREAT_AS_RAID_UNIT || creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_CAN_ASSIST;
10212  }
10213  return true;
10214 }
bool IsOnVehicle(const Unit *vehicle) const
Definition: Unit.cpp:14336
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7035
Definition: UpdateFields.h:146
Map * GetMap() const
Definition: Object.h:543
Definition: Unit.h:584
Definition: Unit.h:310
Vehicle * m_vehicle
Definition: Unit.h:2304
Definition: Creature.h:467
Definition: Unit.h:681
Definition: SharedDefines.h:216
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: SharedDefines.h:3668
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7569
Definition: SharedDefines.h:575
Definition: SharedDefines.h:596
Definition: SharedDefines.h:585
Definition: Unit.h:308
Definition: Unit.h:676
Definition: Unit.h:682
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
#define ASSERT
Definition: Errors.h:55
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1940
Definition: Unit.h:311
Definition: Unit.h:698
Definition: SharedDefines.h:3682
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49
uint32 type_flags
Definition: Creature.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::_IsValidAttackTarget ( Unit const target,
SpellInfo const bySpell,
WorldObject const obj = NULL 
) const
10009 {
10010  ASSERT(target);
10011 
10012  // can't attack self
10013  if (this == target)
10014  return false;
10015 
10016  // can't attack unattackable units or GMs
10017  if (target->HasUnitState(UNIT_STATE_UNATTACKABLE)
10018  || (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster()))
10019  return false;
10020 
10021  // can't attack own vehicle or passenger
10022  if (m_vehicle)
10023  if (IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target))
10024  return false;
10025 
10026  // can't attack invisible (ignore stealth for aoe spells) also if the area being looked at is from a spell use the dynamic object created instead of the casting unit. Ignore stealth if target is player and unit in combat with same player
10027  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && (obj ? !obj->CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea(GetMap()->GetDifficultyID())) : !CanSeeOrDetect(target, (bySpell && bySpell->IsAffectingArea(GetMap()->GetDifficultyID())) || (target->GetTypeId() == TYPEID_PLAYER && target->HasStealthAura() && target->IsInCombat() && IsInCombatWith(target)))))
10028  return false;
10029 
10030  // can't attack dead
10031  if ((!bySpell || !bySpell->IsAllowingDeadTarget()) && !target->IsAlive())
10032  return false;
10033 
10034  // can't attack untargetable
10035  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE))
10036  && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
10037  return false;
10038 
10039  if (Player const* playerAttacker = ToPlayer())
10040  {
10041  if (playerAttacker->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_UBER))
10042  return false;
10043  }
10044 
10045  // check flags
10049  return false;
10050 
10051  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR8_ATTACK_IGNORE_IMMUNE_TO_PC_FLAG))
10053  // 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
10054  && GetEntry() != WORLD_TRIGGER)
10055  return false;
10056 
10057  // CvC case - can attack each other only when one of them is hostile
10059  return GetReactionTo(target) <= REP_HOSTILE || target->GetReactionTo(this) <= REP_HOSTILE;
10060 
10061  // PvP, PvC, CvP case
10062  // can't attack friendly targets
10063  if ( GetReactionTo(target) > REP_NEUTRAL
10064  || target->GetReactionTo(this) > REP_NEUTRAL)
10065  return false;
10066 
10067  // Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
10068  if (GetReactionTo(target) == REP_NEUTRAL &&
10069  target->GetReactionTo(this) <= REP_NEUTRAL)
10070  {
10071  if (!(target->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER) &&
10072  !(target->GetTypeId() == TYPEID_UNIT && GetTypeId() == TYPEID_UNIT))
10073  {
10074  Player const* player = target->GetTypeId() == TYPEID_PLAYER ? target->ToPlayer() : ToPlayer();
10075  Unit const* creature = target->GetTypeId() == TYPEID_UNIT ? target : this;
10076 
10077  if (FactionTemplateEntry const* factionTemplate = creature->GetFactionTemplateEntry())
10078  {
10079  if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate)))
10080  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->Faction))
10081  if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
10082  if (!(repState->Flags & FACTION_FLAG_AT_WAR))
10083  return false;
10084 
10085  }
10086  }
10087  }
10088 
10089  Creature const* creatureAttacker = ToCreature();
10090  if (creatureAttacker && creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_TREAT_AS_RAID_UNIT)
10091  return false;
10092 
10093  Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : NULL;
10094  Player const* playerAffectingTarget = target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? target->GetAffectingPlayer() : NULL;
10095 
10096  // check duel - before sanctuary checks
10097  if (playerAffectingAttacker && playerAffectingTarget)
10098  if (playerAffectingAttacker->duel && playerAffectingAttacker->duel->opponent == playerAffectingTarget && playerAffectingAttacker->duel->startTime != 0)
10099  return true;
10100 
10101  // PvP case - can't attack when attacker or target are in sanctuary
10102  // however, 13850 client doesn't allow to attack when one of the unit's has sanctuary flag and is pvp
10105  return false;
10106 
10107  // additional checks - only PvP case
10108  if (playerAffectingAttacker && playerAffectingTarget)
10109  {
10110  if (target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_PVP)
10111  return true;
10112 
10114  && target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP)
10115  return true;
10116 
10118  || (target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK1);
10119  }
10120  return true;
10121 }
bool IsOnVehicle(const Unit *vehicle) const
Definition: Unit.cpp:14336
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7035
Definition: UpdateFields.h:146
Definition: Unit.h:674
Map * GetMap() const
Definition: Object.h:543
Definition: ReputationMgr.h:39
Definition: Unit.h:584
#define WORLD_TRIGGER
Definition: Unit.h:33
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Unit.h:310
Vehicle * m_vehicle
Definition: Unit.h:2304
Definition: Creature.h:467
Definition: Unit.h:681
Definition: SharedDefines.h:216
Player * ToPlayer()
Definition: Object.h:191
Definition: Unit.h:309
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7569
Definition: SharedDefines.h:214
Definition: SharedDefines.h:596
Definition: Unit.h:689
Definition: SharedDefines.h:585
Definition: Unit.h:308
Definition: DBCStructure.h:433
Definition: Unit.h:676
Definition: DBCStructure.h:405
Definition: Unit.h:682
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
Definition: SharedDefines.h:675
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:680
#define ASSERT
Definition: Errors.h:55
Definition: UpdateFields.h:191
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
uint32 GetEntry() const
Definition: Object.h:107
Definition: Player.h:536
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7019
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1940
Definition: Unit.h:311
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:340
Definition: Unit.h:693
Definition: Unit.h:1305
Definition: Unit.h:698
Definition: ReputationMgr.h:49
Definition: SharedDefines.h:3682
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49
uint32 type_flags
Definition: Creature.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::_RegisterAuraEffect ( AuraEffect aurEff,
bool  apply 
)
3357 {
3358  if (apply)
3359  m_modAuras[aurEff->GetAuraType()].push_back(aurEff);
3360  else
3361  m_modAuras[aurEff->GetAuraType()].remove(aurEff);
3362 }
AuraEffectList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2279
void apply(T *val)
Definition: ByteConverter.h:41
AuraType GetAuraType() const
Definition: SpellAuraEffects.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::_RegisterDynObject ( DynamicObject dynObj)
4693 {
4694  m_dynObj.push_back(dynObj);
4695 }
DynObjectList m_dynObj
Definition: Unit.h:2264

+ Here is the caller graph for this function:

void Unit::_RemoveAllAuraStatMods ( )
4060 {
4061  for (AuraApplicationMap::iterator i = m_appliedAuras.begin(); i != m_appliedAuras.end(); ++i)
4062  (*i).second->GetBase()->HandleAllEffects(i->second, AURA_EFFECT_HANDLE_STAT, false);
4063 }
Definition: SpellAuraDefines.h:43
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
void Unit::_removeAttacker ( Unit pAttacker)
7207 {
7208  m_attackers.erase(pAttacker);
7209 }
AttackerSet m_attackers
Definition: Unit.h:2255

+ Here is the caller graph for this function:

void Unit::_RemoveNoStackAuraApplicationsDueToAura ( Aura aura)
void Unit::_RemoveNoStackAurasDueToAura ( Aura aura)
3317 {
3318  SpellInfo const* spellProto = aura->GetSpellInfo();
3319 
3320  // passive spell special case (only non stackable with ranks)
3321  if (spellProto->IsPassiveStackableWithRanks(GetMap()->GetDifficultyID()))
3322  return;
3323 
3324  if (!IsHighestExclusiveAura(aura))
3325  {
3326  if (!aura->GetSpellInfo()->IsAffectingArea(GetMap()->GetDifficultyID()))
3327  {
3328  Unit* caster = aura->GetCaster();
3329  if (caster && caster->GetTypeId() == TYPEID_PLAYER)
3331  }
3332 
3333  aura->Remove();
3334  return;
3335  }
3336 
3337  bool remove = false;
3338  for (AuraApplicationMap::iterator i = m_appliedAuras.begin(); i != m_appliedAuras.end(); ++i)
3339  {
3340  if (remove)
3341  {
3342  remove = false;
3343  i = m_appliedAuras.begin();
3344  }
3345 
3346  if (aura->CanStackWith(i->second->GetBase()))
3347  continue;
3348 
3350  if (i == m_appliedAuras.end())
3351  break;
3352  remove = true;
3353  }
3354 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
Map * GetMap() const
Definition: Object.h:543
Unit * GetCaster() const
Definition: SpellAuras.cpp:438
Definition: SpellInfo.h:326
bool IsPassiveStackableWithRanks(uint32 difficulty) const
Definition: SpellInfo.cpp:1454
Definition: SharedDefines.h:1277
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, OpcodeServer opcode=SMSG_CAST_FAILED, uint32 *misc=nullptr)
Definition: Spell.cpp:3732
bool CanStackWith(Aura const *existingAura) const
Definition: SpellAuras.cpp:1655
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:33
bool IsAffectingArea(uint32 difficulty) const
Definition: SpellInfo.cpp:1335
bool IsHighestExclusiveAura(Aura const *aura, bool removeOtherAuraApplications=false)
Definition: Unit.cpp:16340
Definition: Unit.h:1305
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
Definition: Unit.h:451

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Aura * Unit::_TryStackingOrRefreshingExistingAura ( SpellInfo const newAura,
uint32  effMask,
Unit caster,
int32 baseAmount = NULL,
Item castItem = NULL,
ObjectGuid  casterGUID = ObjectGuid::Empty,
int32  castItemLevel = -1 
)
3025 {
3026  ASSERT(!casterGUID.IsEmpty() || caster);
3027 
3028  // Check if these can stack anyway
3029  if (!casterGUID && !newAura->IsStackableOnOneSlotWithDifferentCasters())
3030  casterGUID = caster->GetGUID();
3031 
3032  // passive and Incanter's Absorption and auras with different type can stack with themselves any number of times
3033  if (!newAura->IsMultiSlotAura())
3034  {
3035  // check if cast item changed
3036  ObjectGuid castItemGUID;
3037  if (castItem)
3038  {
3039  castItemGUID = castItem->GetGUID();
3040  castItemLevel = castItem->GetItemLevel(castItem->GetOwner());
3041  }
3042 
3043  // find current aura from spell and change it's stackamount, or refresh it's duration
3044  if (Aura* foundAura = GetOwnedAura(newAura->Id, casterGUID, (newAura->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC)) ? castItemGUID : ObjectGuid::Empty, 0))
3045  {
3046  // effect masks do not match
3047  // extremely rare case
3048  // let's just recreate aura
3049  if (effMask != foundAura->GetEffectMask())
3050  return NULL;
3051 
3052  // update basepoints with new values - effect amount will be recalculated in ModStackAmount
3053  for (SpellEffectInfo const* effect : foundAura->GetSpellEffectInfos())
3054  {
3055  if (!effect)
3056  continue;
3057 
3058  AuraEffect const* eff = foundAura->GetEffect(effect->EffectIndex);
3059  if (!eff)
3060  continue;
3061 
3062  int bp;
3063  if (baseAmount)
3064  bp = *(baseAmount + effect->EffectIndex);
3065  else
3066  bp = effect->BasePoints;
3067 
3068  int32* oldBP = const_cast<int32*>(&(foundAura->GetEffect(effect->EffectIndex)->m_baseAmount)); // todo 6.x review GetBaseAmount and GetCastItemGUID in this case
3069  *oldBP = bp;
3070  }
3071 
3072  // correct cast item guid if needed
3073  if (castItemGUID != foundAura->GetCastItemGUID())
3074  {
3075  ObjectGuid* oldGUID = const_cast<ObjectGuid*>(&foundAura->m_castItemGuid);
3076  *oldGUID = castItemGUID;
3077  int32* oldItemLevel = const_cast<int32*>(&foundAura->m_castItemLevel);
3078  *oldItemLevel = castItemLevel;
3079  }
3080 
3081  // try to increase stack amount
3082  foundAura->ModStackAmount(1);
3083  return foundAura;
3084  }
3085  }
3086 
3087  return NULL;
3088 }
Definition: SpellAuraEffects.h:30
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
arena_t NULL
Definition: jemalloc_internal.h:624
Aura * GetOwnedAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, Aura *except=NULL) const
Definition: Unit.cpp:3426
Definition: SpellInfo.h:184
Player * GetOwner() const
Definition: Item.cpp:552
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
uint32 GetItemLevel(Player const *owner) const
Definition: Item.cpp:1871
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
Definition: ObjectGuid.h:189
Definition: SpellAuras.h:116
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::_UnapplyAura ( AuraApplicationMap::iterator &  i,
AuraRemoveMode  removeMode 
)
3218 {
3219  AuraApplication * aurApp = i->second;
3220  ASSERT(aurApp);
3221  ASSERT(!aurApp->GetRemoveMode());
3222  ASSERT(aurApp->GetTarget() == this);
3223 
3224  aurApp->SetRemoveMode(removeMode);
3225  Aura* aura = aurApp->GetBase();
3226  TC_LOG_DEBUG("spells", "Aura %u now is remove mode %d", aura->GetId(), removeMode);
3227 
3228  // dead loop is killing the server probably
3229  ASSERT(m_removedAurasCount < 0xFFFFFFFF);
3230 
3232 
3233  Unit* caster = aura->GetCaster();
3234 
3235  // Remove all pointers from lists here to prevent possible pointer invalidation on spellcast/auraapply/auraremove
3236  m_appliedAuras.erase(i);
3237 
3238  if (aura->GetSpellInfo()->AuraInterruptFlags)
3239  {
3240  m_interruptableAuras.remove(aurApp);
3242  }
3243 
3244  bool auraStateFound = false;
3245  AuraStateType auraState = aura->GetSpellInfo()->GetAuraState(GetMap()->GetDifficultyID());
3246  if (auraState)
3247  {
3248  bool canBreak = false;
3249  // Get mask of all aurastates from remaining auras
3250  for (AuraStateAurasMap::iterator itr = m_auraStateAuras.lower_bound(auraState); itr != m_auraStateAuras.upper_bound(auraState) && !(auraStateFound && canBreak);)
3251  {
3252  if (itr->second == aurApp)
3253  {
3254  m_auraStateAuras.erase(itr);
3255  itr = m_auraStateAuras.lower_bound(auraState);
3256  canBreak = true;
3257  continue;
3258  }
3259  auraStateFound = true;
3260  ++itr;
3261  }
3262  }
3263 
3264  aurApp->_Remove();
3265  aura->_UnapplyForTarget(this, caster, aurApp);
3266 
3267  // remove effects of the spell - needs to be done after removing aura from lists
3268  for (uint8 itr = 0; itr < MAX_SPELL_EFFECTS; ++itr)
3269  {
3270  if (aurApp->HasEffect(itr))
3271  aurApp->_HandleEffect(itr, false);
3272  }
3273 
3274  // all effect mustn't be applied
3275  ASSERT(!aurApp->GetEffectMask());
3276 
3277  // Remove totem at next update if totem loses its aura
3278  if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && IsTotem())
3279  {
3280  if (ToTotem()->GetSpell() == aura->GetId() && ToTotem()->GetTotemType() == TOTEM_PASSIVE)
3282  }
3283 
3284  // Remove aurastates only if were not found
3285  if (!auraStateFound)
3286  ModifyAuraState(auraState, false);
3287 
3288  aura->HandleAuraSpecificMods(aurApp, caster, false, false);
3289 
3290  // only way correctly remove all auras from list
3291  //if (removedAuras != m_removedAurasCount) new aura may be added
3292  i = m_appliedAuras.begin();
3293 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
void ModifyAuraState(AuraStateType flag, bool apply)
Definition: Unit.cpp:7422
uint32 m_removedAurasCount
Definition: Unit.h:2277
uint32 GetSpell(uint8 slot=0) const
Definition: Totem.h:47
void UpdateInterruptMask()
Definition: Unit.cpp:557
TotemType GetTotemType() const
Definition: Totem.h:50
Map * GetMap() const
Definition: Object.h:543
Unit * GetCaster() const
Definition: SpellAuras.cpp:438
Unit * GetTarget() const
Definition: SpellAuras.h:74
void HandleAuraSpecificMods(AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
Definition: SpellAuras.cpp:1238
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: Unit.h:542
void _Remove()
Definition: SpellAuras.cpp:88
AuraStateType
Definition: SharedDefines.h:1754
AuraStateAurasMap m_auraStateAuras
Definition: Unit.h:2282
Definition: SpellAuras.h:50
AuraStateType GetAuraState(uint32 difficulty) const
Definition: SpellInfo.cpp:2221
Definition: ObjectGuid.h:32
uint32 AuraInterruptFlags
Definition: SpellInfo.h:368
uint32 GetEffectMask() const
Definition: SpellAuras.h:79
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
AuraApplicationList m_interruptableAuras
Definition: Unit.h:2281
Definition: Totem.h:26
void _HandleEffect(uint8 effIndex, bool apply)
Definition: SpellAuras.cpp:161
TypeID GetTypeId() const
Definition: Object.h:113
Totem * ToTotem()
Definition: Unit.h:2203
void setDeathState(DeathState s) override
Definition: Creature.cpp:1624
bool HasEffect(uint8 effect) const
Definition: SpellAuras.h:80
virtual void _UnapplyForTarget(Unit *target, Unit *caster, AuraApplication *auraApp)
Definition: SpellAuras.cpp:481
Definition: Unit.h:454
void SetRemoveMode(AuraRemoveMode mode)
Definition: SpellAuras.h:85
bool IsTotem() const
Definition: Unit.h:1405
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
Definition: SpellAuras.h:116
Definition: Unit.h:1305
AuraRemoveMode GetRemoveMode() const
Definition: SpellAuras.h:86
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
uint32 GetId() const
Definition: SpellAuras.h:131

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::_UnapplyAura ( AuraApplication aurApp,
AuraRemoveMode  removeMode 
)
3296 {
3297  // aura can be removed from unit only if it's applied on it, shouldn't happen
3298  ASSERT(aurApp->GetBase()->GetApplicationOfTarget(GetGUID()) == aurApp);
3299 
3300  uint32 spellId = aurApp->GetBase()->GetId();
3301  AuraApplicationMapBoundsNonConst range = m_appliedAuras.equal_range(spellId);
3302 
3303  for (AuraApplicationMap::iterator iter = range.first; iter != range.second;)
3304  {
3305  if (iter->second == aurApp)
3306  {
3307  _UnapplyAura(iter, removeMode);
3308  return;
3309  }
3310  else
3311  ++iter;
3312  }
3313  ABORT();
3314 }
Aura * GetBase() const
Definition: SpellAuras.h:75
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
uint32_t uint32
Definition: Define.h:150
std::pair< AuraApplicationMap::iterator, AuraApplicationMap::iterator > AuraApplicationMapBoundsNonConst
Definition: Unit.h:1317
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ABORT
Definition: Errors.h:56
#define ASSERT
Definition: Errors.h:55
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:3217
uint32 GetId() const
Definition: SpellAuras.h:131

+ Here is the call graph for this function:

void Unit::_UnregisterDynObject ( DynamicObject dynObj)
4698 {
4699  m_dynObj.remove(dynObj);
4700 }
DynObjectList m_dynObj
Definition: Unit.h:2264

+ Here is the caller graph for this function:

void Unit::_UpdateAutoRepeatSpell ( )
protected
2736 {
2737  // check "realtime" interrupts
2738  // don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect
2739  if (((GetTypeId() == TYPEID_PLAYER && ToPlayer()->isMoving()) || IsNonMeleeSpellCast(false, false, true, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == 75)) &&
2741  {
2742  // cancel wand shoot
2743  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != 75)
2745  m_AutoRepeatFirstCast = true;
2746  return;
2747  }
2748 
2749  // apply delay (Auto Shot (spellID 75) not affected)
2752  m_AutoRepeatFirstCast = false;
2753 
2754  // castroutine
2756  {
2757  // Check if able to cast
2758  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true) != SPELL_CAST_OK)
2759  {
2761  return;
2762  }
2763 
2764  // we want to shoot
2765  Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, TRIGGERED_FULL_MASK);
2766  spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
2767 
2768  // all went good, reset attack
2770  }
2771 }
void setAttackTimer(WeaponAttackType type, uint32 time)
Definition: Unit.h:1354
Definition: Unit.h:619
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
bool m_AutoRepeatFirstCast
Definition: Unit.h:2249
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition: Unit.cpp:4270
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Definition: Unit.h:1111
Player * ToPlayer()
Definition: Object.h:191
bool isMoving() const
Definition: Unit.h:2186
void prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
Definition: Spell.cpp:2860
TypeID GetTypeId() const
Definition: Object.h:113
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:2849
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:1357
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:481
Definition: SpellAuraDefines.h:390
Definition: ObjectGuid.h:33
uint32 Id
Definition: Spell.h:567
Definition: SharedDefines.h:1538
uint32 getAttackTimer(WeaponAttackType type) const
Definition: Unit.h:1356
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::_UpdateSpells ( uint32  time)
protected
2678 {
2681 
2682  // remove finished spells from current pointers
2683  for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
2684  {
2685  if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
2686  {
2688  m_currentSpells[i] = NULL; // remove pointer
2689  }
2690  }
2691 
2692  // m_auraUpdateIterator can be updated in indirect called code at aura remove to skip next planned to update but removed auras
2694  {
2695  Aura* i_aura = m_auraUpdateIterator->second;
2696  ++m_auraUpdateIterator; // need shift to next for allow update if need into aura update
2697  i_aura->UpdateOwner(time, this);
2698  }
2699 
2700  // remove expired auras - do that after updates(used in scripts?)
2701  for (AuraMap::iterator i = m_ownedAuras.begin(); i != m_ownedAuras.end();)
2702  {
2703  if (i->second->IsExpired())
2705  else
2706  ++i;
2707  }
2708 
2709  for (VisibleAuraMap::iterator itr = m_visibleAuras.begin(); itr != m_visibleAuras.end(); ++itr)
2710  if (itr->second->IsNeedClientUpdate())
2711  itr->second->ClientUpdate();
2712 
2714 
2715  if (!m_gameObj.empty())
2716  {
2717  GameObjectList::iterator itr;
2718  for (itr = m_gameObj.begin(); itr != m_gameObj.end();)
2719  {
2720  if (!(*itr)->isSpawned())
2721  {
2722  (*itr)->SetOwnerGUID(ObjectGuid::Empty);
2723  (*itr)->SetRespawnTime(0);
2724  (*itr)->Delete();
2725  m_gameObj.erase(itr++);
2726  }
2727  else
2728  ++itr;
2729  }
2730  }
2731 
2732  _spellHistory->Update();
2733 }
void _UpdateAutoRepeatSpell()
Definition: Unit.cpp:2735
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
AuraMap m_ownedAuras
Definition: Unit.h:2273
VisibleAuraMap m_visibleAuras
Definition: Unit.h:2288
SpellHistory * _spellHistory
Definition: Unit.h:2364
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
arena_t NULL
Definition: jemalloc_internal.h:624
void Update()
Definition: SpellHistory.cpp:205
Definition: Unit.h:1111
void _DeleteRemovedAuras()
Definition: Unit.cpp:2668
GameObjectList m_gameObj
Definition: Unit.h:2267
uint32_t uint32
Definition: Define.h:150
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
Definition: Unit.h:454
#define CURRENT_MAX_SPELL
Definition: Unit.h:1115
AuraMap::iterator m_auraUpdateIterator
Definition: Unit.h:2276
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:601
Definition: SpellAuras.h:116
Definition: Spell.h:279
void UpdateOwner(uint32 diff, WorldObject *owner)
Definition: SpellAuras.cpp:692

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Aura * Unit::AddAura ( uint32  spellId,
Unit target 
)
14464 {
14465  if (!target)
14466  return NULL;
14467 
14468  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
14469  if (!spellInfo)
14470  return NULL;
14471 
14472  if (!target->IsAlive() && !spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_DEAD))
14473  return NULL;
14474 
14475  return AddAura(spellInfo, MAX_EFFECT_MASK, target);
14476 }
Definition: SpellInfo.h:326
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:14463
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:362
bool IsAlive() const
Definition: Unit.h:1692
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SharedDefines.h:428
#define sSpellMgr
Definition: SpellMgr.h:756
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1027

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Aura * Unit::AddAura ( SpellInfo const spellInfo,
uint32  effMask,
Unit target 
)
14479 {
14480  if (!spellInfo)
14481  return NULL;
14482 
14483  if (target->IsImmunedToSpell(spellInfo))
14484  return NULL;
14485 
14486  for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
14487  {
14488  if (!(effMask & (1<<i)))
14489  continue;
14490  if (target->IsImmunedToSpellEffect(spellInfo, i))
14491  effMask &= ~(1<<i);
14492  }
14493 
14494  if (Aura* aura = Aura::TryRefreshStackOrCreate(spellInfo, effMask, target, this))
14495  {
14496  aura->ApplyForTargets();
14497  return aura;
14498  }
14499  return NULL;
14500 }
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const
Definition: Unit.cpp:9339
virtual bool IsImmunedToSpell(SpellInfo const *spellInfo) const
Definition: Unit.cpp:9255
arena_t NULL
Definition: jemalloc_internal.h:624
uint32_t uint32
Definition: Define.h:150
static Aura * TryRefreshStackOrCreate(SpellInfo const *spellproto, uint32 tryEffMask, WorldObject *owner, Unit *caster, int32 *baseAmount=NULL, Item *castItem=NULL, ObjectGuid casterGUID=ObjectGuid::Empty, bool *refresh=NULL, int32 castItemLevel=-1)
Definition: SpellAuras.cpp:282
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
Definition: SpellAuras.h:116

+ Here is the call graph for this function:

void Unit::AddExtraUnitMovementFlag ( uint16  f)
inline
MovementInfo m_movementInfo
Definition: Object.h:612
void AddExtraMovementFlag(uint16 flag)
Definition: Object.h:334

+ Here is the caller graph for this function:

void Unit::addFollower ( FollowerReference pRef)
inline
FollowerRefManager m_FollowingRefManager
Definition: Unit.h:2348
void insertFirst(LinkedListElement *pElem)
Definition: LinkedList.h:110

+ Here is the caller graph for this function:

void Unit::AddGameObject ( GameObject gameObj)
4748 {
4749  if (!gameObj || !gameObj->GetOwnerGUID().IsEmpty())
4750  return;
4751 
4752  m_gameObj.push_back(gameObj);
4753  gameObj->SetOwnerGUID(GetGUID());
4754 
4755  if (gameObj->GetSpellId())
4756  {
4757  SpellInfo const* createBySpell = sSpellMgr->GetSpellInfo(gameObj->GetSpellId());
4758  // Need disable spell use for owner
4759  if (createBySpell && createBySpell->IsCooldownStartedOnEvent())
4760  // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases)
4761  GetSpellHistory()->StartCooldown(createBySpell, 0, nullptr, true);
4762  }
4763 }
Definition: SpellInfo.h:326
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
GameObjectList m_gameObj
Definition: Unit.h:2267
#define sSpellMgr
Definition: SpellMgr.h:756
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void StartCooldown(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool onHold=false)
Definition: SpellHistory.cpp:386
uint32 GetSpellId() const
Definition: GameObject.h:933
bool IsEmpty() const
Definition: ObjectGuid.h:242
void SetOwnerGUID(ObjectGuid owner)
Definition: GameObject.h:915
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1470

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::addHatedBy ( HostileReference pHostileReference)
inline
1999 { m_HostileRefManager.insertFirst(pHostileReference); }
HostileRefManager m_HostileRefManager
Definition: Unit.h:2346
void insertFirst(LinkedListElement *pElem)
Definition: LinkedList.h:110

+ Here is the caller graph for this function:

void Unit::AddInterruptMask ( uint32  mask)
inline
2009 { m_interruptMask |= mask; }
uint32 m_interruptMask
Definition: Unit.h:2283

+ Here is the caller graph for this function:

void Unit::AddPetAura ( PetAura const petSpell)
13162 {
13163  if (GetTypeId() != TYPEID_PLAYER)
13164  return;
13165 
13166  m_petAuras.insert(petSpell);
13167  if (Pet* pet = ToPlayer()->GetPet())
13168  pet->CastPetAura(petSpell);
13169 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:33
PetAuraSet m_petAuras
Definition: Unit.h:2146
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::AddPlayerToVision ( Player player)
8094 {
8095  if (m_sharedVision.empty())
8096  {
8097  setActive(true);
8098  SetWorldObject(true);
8099  }
8100  m_sharedVision.push_back(player);
8101 }
void setActive(bool isActiveObject)
Definition: Object.cpp:1473
SharedVisionList m_sharedVision
Definition: Unit.h:2293
void SetWorldObject(bool apply)
Definition: Object.cpp:1454

+ Here is the call graph for this function:

void Unit::AddThreat ( Unit victim,
float  fThreat,
SpellSchoolMask  schoolMask = SPELL_SCHOOL_MASK_NORMAL,
SpellInfo const threatSpell = NULL 
)
10692 {
10693  // Only mobs can manage threat lists
10694  if (CanHaveThreatList())
10695  m_ThreatManager.addThreat(victim, fThreat, schoolMask, threatSpell);
10696 }
void addThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: ThreatManager.cpp:406
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition: Unit.cpp:10652
ThreatManager m_ThreatManager
Definition: Unit.h:2302

+ Here is the call graph for this function:

void Unit::AddToWorld ( )
overridevirtual

Reimplemented from Object.

11725 {
11726  if (!IsInWorld())
11727  {
11729  }
11731 }
void RebuildTerrainSwaps()
Definition: Object.cpp:3109
virtual void AddToWorld()
Definition: Object.cpp:142
bool IsInWorld() const
Definition: Object.h:100

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::AddUnitMovementFlag ( uint32  f)
inline
MovementInfo m_movementInfo
Definition: Object.h:612
void AddMovementFlag(uint32 flag)
Definition: Object.h:328

+ Here is the caller graph for this function:

void Unit::AddUnitState ( uint32  f)
inline
1394 { m_state |= f; }
uint32 m_state
Definition: Unit.h:2340

+ Here is the caller graph for this function:

void Unit::AddUnitTypeMask ( uint32  mask)
inline
1400 { m_unitTypeMask |= mask; }
uint32 m_unitTypeMask
Definition: Unit.h:2307

+ Here is the caller graph for this function:

void Unit::ApplyAttackTimePercentMod ( WeaponAttackType  att,
float  val,
bool  apply 
)
12922 {
12923  float remainingTimePct = (float)m_attackTimer[att] / (GetAttackTime(att) * m_modAttackSpeedPct[att]);
12924  if (val > 0)
12925  {
12928 
12929  if (GetTypeId() == TYPEID_PLAYER)
12930  {
12931  if (att == BASE_ATTACK)
12933  else if (att == RANGED_ATTACK)
12935  }
12936  }
12937  else
12938  {
12941 
12942  if (GetTypeId() == TYPEID_PLAYER)
12943  {
12944  if (att == BASE_ATTACK)
12946  else if (att == RANGED_ATTACK)
12948  }
12949  }
12950  m_attackTimer[att] = uint32(GetAttackTime(att) * m_modAttackSpeedPct[att] * remainingTimePct);
12951 }
Definition: Unit.h:619
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:1183
Definition: UpdateFields.h:113
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.cpp:10326
Definition: UpdateFields.h:131
TypeID GetTypeId() const
Definition: Object.h:113
float m_modAttackSpeedPct[3]
Definition: Unit.h:1945
Definition: UpdateFields.h:132
void ApplyPercentModFloatVar(float &var, float val, bool apply)
Definition: Util.h:83
Definition: ObjectGuid.h:33
uint32_t uint32
Definition: g3dmath.h:168
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2251
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ApplyCastTimePercentMod ( float  val,
bool  apply 
)
12954 {
12955  if (val > 0)
12956  {
12959  }
12960  else
12961  {
12964  }
12965 }
Definition: UpdateFields.h:129
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:1183
Definition: UpdateFields.h:130

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ApplyDiminishingAura ( DiminishingGroup  group,
bool  apply 
)
11208 {
11209  // Checking for existing in the table
11210  for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
11211  {
11212  if (i->DRGroup != group)
11213  continue;
11214 
11215  if (apply)
11216  i->stack += 1;
11217  else if (i->stack)
11218  {
11219  i->stack -= 1;
11220  // Remember time after last aura from group removed
11221  if (i->stack == 0)
11222  i->hitTime = getMSTime();
11223  }
11224  break;
11225  }
11226 }
uint32 getMSTime()
Definition: Timer.h:24
Diminishing m_Diminishing
Definition: Unit.h:2344
void apply(T *val)
Definition: ByteConverter.h:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::ApplyDiminishingToDuration ( DiminishingGroup  group,
int32 duration,
Unit caster,
DiminishingLevels  Level,
int32  limitduration 
)
11127 {
11128  if (duration == -1 || group == DIMINISHING_NONE)
11129  return 1.0f;
11130 
11131  // test pet/charm masters instead pets/charmeds
11132  Unit const* targetOwner = GetCharmerOrOwner();
11133  Unit const* casterOwner = caster->GetCharmerOrOwner();
11134 
11135  if (limitduration > 0 && duration > limitduration)
11136  {
11137  Unit const* target = targetOwner ? targetOwner : this;
11138  Unit const* source = casterOwner ? casterOwner : caster;
11139 
11140  if ((target->GetTypeId() == TYPEID_PLAYER
11142  && source->GetTypeId() == TYPEID_PLAYER)
11143  duration = limitduration;
11144  }
11145 
11146  float mod = 1.0f;
11147 
11148  switch (group)
11149  {
11150  case DIMINISHING_TAUNT:
11151  {
11153  {
11154  DiminishingLevels diminish = Level;
11155  switch (diminish)
11156  {
11157  case DIMINISHING_LEVEL_1: break;
11158  case DIMINISHING_LEVEL_2: mod = 0.65f; break;
11159  case DIMINISHING_LEVEL_3: mod = 0.4225f; break;
11160  case DIMINISHING_LEVEL_4: mod = 0.274625f; break;
11161  case DIMINISHING_LEVEL_TAUNT_IMMUNE: mod = 0.0f; break;
11162  default: break;
11163  }
11164  }
11165  break;
11166  }
11168  {
11169  if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && (((targetOwner ? targetOwner : this)->ToPlayer())
11172  {
11173  DiminishingLevels diminish = Level;
11174  switch (diminish)
11175  {
11176  case DIMINISHING_LEVEL_1: break;
11177  case DIMINISHING_LEVEL_2: mod = 0.0f; break;
11178  default: break;
11179  }
11180  }
11181  break;
11182  }
11183  default:
11184  {
11185  if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && (((targetOwner ? targetOwner : this)->ToPlayer())
11186  || (ToCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))))
11188  {
11189  DiminishingLevels diminish = Level;
11190  switch (diminish)
11191  {
11192  case DIMINISHING_LEVEL_1: break;
11193  case DIMINISHING_LEVEL_2: mod = 0.5f; break;
11194  case DIMINISHING_LEVEL_3: mod = 0.25f; break;
11195  case DIMINISHING_LEVEL_IMMUNE: mod = 0.0f; break;
11196  default: break;
11197  }
11198  }
11199  break;
11200  }
11201  }
11202 
11203  duration = int32(duration * mod);
11204  return mod;
11205 }
Definition: SharedDefines.h:4364
Definition: SharedDefines.h:4371
Definition: SharedDefines.h:4877
DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group)
Definition: SpellMgr.cpp:404
Definition: ObjectGuid.h:32
Definition: Creature.h:56
uint32 flags_extra
Definition: Creature.h:142
Definition: SharedDefines.h:4876
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:4365
Definition: SharedDefines.h:4880
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
Definition: SharedDefines.h:4377
Definition: SharedDefines.h:4881
Definition: SharedDefines.h:4378
DiminishingLevels
Definition: SharedDefines.h:4874
Definition: ObjectGuid.h:33
Definition: Creature.h:55
Creature * ToCreature()
Definition: Object.h:194
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:4878
Definition: SharedDefines.h:4879
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::ApplyEffectModifiers ( SpellInfo const spellProto,
uint8  effect_index,
float  value 
) const
10903 {
10904  if (Player* modOwner = GetSpellModOwner())
10905  {
10906  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_ALL_EFFECTS, value);
10907  switch (effect_index)
10908  {
10909  case 0:
10910  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT1, value);
10911  break;
10912  case 1:
10913  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT2, value);
10914  break;
10915  case 2:
10916  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT3, value);
10917  break;
10918  case 3:
10919  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT4, value);
10920  break;
10921  case 4:
10922  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT5, value);
10923  break;
10924  }
10925  }
10926  return value;
10927 }
Definition: Unit.h:89
Definition: Unit.h:118
Definition: Unit.h:98
Definition: Unit.h:94
Definition: Unit.h:109
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
const FieldDescriptor value
Definition: descriptor.h:1522
Definition: Unit.h:119

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ApplyResilience ( Unit const victim,
int32 damage 
) const
14522 {
14523  // player mounted on multi-passenger mount is also classified as vehicle
14524  if (IsVehicle() || (victim->IsVehicle() && victim->GetTypeId() != TYPEID_PLAYER))
14525  return;
14526 
14527  // Don't consider resilience if not in PvP - player or pet
14529  return;
14530 
14531  Unit const* target = NULL;
14532  if (victim->GetTypeId() == TYPEID_PLAYER)
14533  target = victim;
14534  else if (victim->GetTypeId() == TYPEID_UNIT && victim->GetOwner() && victim->GetOwner()->GetTypeId() == TYPEID_PLAYER)
14535  target = victim->GetOwner();
14536 
14537  if (!target)
14538  return;
14539 
14540  *damage -= target->GetDamageReduction(*damage);
14541 }
uint32 GetDamageReduction(uint32 damage) const
Definition: Unit.h:1540
bool IsVehicle() const
Definition: Unit.h:1406
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: ObjectGuid.h:33
Unit * GetOwner() const
Definition: Unit.cpp:7542
Definition: Unit.h:1305
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ApplyResistanceBuffModsMod ( SpellSchools  school,
bool  positive,
float  val,
bool  apply 
)
4664 {
4666 }
void apply(T *val)
Definition: ByteConverter.h:41
Definition: UpdateFields.h:142
void ApplyModSignedFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:1176
Definition: UpdateFields.h:141

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ApplyResistanceBuffModsPercentMod ( SpellSchools  school,
bool  positive,
float  val,
bool  apply 
)
4669 {
4671 }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:1183
Definition: UpdateFields.h:142
Definition: UpdateFields.h:141

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ApplySpellDispelImmunity ( const SpellInfo spellProto,
DispelType  type,
bool  apply 
)
9647 {
9648  ApplySpellImmune(spellProto->Id, IMMUNITY_DISPEL, type, apply);
9649 
9651  {
9652  // Create dispel mask by dispel type
9653  uint32 dispelMask = SpellInfo::GetDispelMask(type);
9654  // Dispel all existing auras vs current dispel type
9656  for (AuraApplicationMap::iterator itr = auras.begin(); itr != auras.end();)
9657  {
9658  SpellInfo const* spell = itr->second->GetBase()->GetSpellInfo();
9659  if (spell->GetDispelMask() & dispelMask)
9660  {
9661  // Dispel aura
9662  RemoveAura(itr);
9663  }
9664  else
9665  ++itr;
9666  }
9667  }
9668 }
uint32 Id
Definition: SpellInfo.h:329
Definition: SpellInfo.h:326
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition: Unit.cpp:9615
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
void apply(T *val)
Definition: ByteConverter.h:41
Definition: SharedDefines.h:407
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
uint32_t uint32
Definition: Define.h:150
uint32 GetDispelMask() const
Definition: SpellInfo.cpp:2202
Definition: SharedDefines.h:1864
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ApplySpellImmune ( uint32  spellId,
uint32  op,
uint32  type,
bool  apply 
)
9616 {
9617  if (apply)
9618  {
9619  for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next)
9620  {
9621  next = itr; ++next;
9622  if (itr->type == type)
9623  {
9624  m_spellImmune[op].erase(itr);
9625  next = m_spellImmune[op].begin();
9626  }
9627  }
9628  SpellImmune Immune;
9629  Immune.spellId = spellId;
9630  Immune.type = type;
9631  m_spellImmune[op].push_back(Immune);
9632  }
9633  else
9634  {
9635  for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr)
9636  {
9637  if (itr->spellId == spellId && itr->type == type)
9638  {
9639  m_spellImmune[op].erase(itr);
9640  break;
9641  }
9642  }
9643  }
9644 }
int next(int i, int n)
Definition: RecastContour.cpp:469
uint32 spellId
Definition: Unit.h:427
void apply(T *val)
Definition: ByteConverter.h:41
uint32 type
Definition: Unit.h:426
Definition: Unit.h:424
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1988

+ Here is the call graph for this function:

void Unit::ApplyStatBuffMod ( Stats  stat,
float  val,
bool  apply 
)
4682 {
4684 }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyModSignedFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:1176
Definition: UpdateFields.h:138
Definition: UpdateFields.h:139

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ApplyStatPercentBuffMod ( Stats  stat,
float  val,
bool  apply 
)
4687 {
4690 }
void apply(T *val)
Definition: ByteConverter.h:41
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
Definition: Object.cpp:1183
Definition: UpdateFields.h:138
Definition: UpdateFields.h:139

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::ApplyTotalThreatModifier ( float  fThreat,
SpellSchoolMask  schoolMask = SPELL_SCHOOL_MASK_NORMAL 
)
10680 {
10681  if (!HasAuraType(SPELL_AURA_MOD_THREAT) || fThreat < 0)
10682  return fThreat;
10683 
10684  SpellSchools school = GetFirstSchoolInMask(schoolMask);
10685 
10686  return fThreat * m_threatModifier[school];
10687 }
SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask)
Definition: SharedDefines.h:309
Definition: SpellAuraDefines.h:70
SpellSchools
Definition: SharedDefines.h:272
float m_threatModifier[MAX_SPELL_SCHOOL]
Definition: Unit.h:1944
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::Attack ( Unit victim,
bool  meleeAttack 
)
7223 {
7224  if (!victim || victim == this)
7225  return false;
7226 
7227  // dead units can neither attack nor be attacked
7228  if (!IsAlive() || !victim->IsInWorld() || !victim->IsAlive())
7229  return false;
7230 
7231  // player cannot attack in mount state
7232  if (GetTypeId() == TYPEID_PLAYER && IsMounted())
7233  return false;
7234 
7236  return false;
7237 
7238  // nobody can attack GM in GM-mode
7239  if (victim->GetTypeId() == TYPEID_PLAYER)
7240  {
7241  if (victim->ToPlayer()->IsGameMaster())
7242  return false;
7243  }
7244  else
7245  {
7246  if (victim->ToCreature()->IsInEvadeMode())
7247  return false;
7248  }
7249 
7250  // remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack)
7253 
7255  {
7256  SetTarget(victim->GetGUID());
7257  m_shouldReacquireTarget = false;
7258  }
7259 
7260  if (m_attacking)
7261  {
7262  if (m_attacking == victim)
7263  {
7264  // switch to melee attack from ranged/magic
7265  if (meleeAttack)
7266  {
7268  {
7270  SendMeleeAttackStart(victim);
7271  return true;
7272  }
7273  }
7275  {
7277  SendMeleeAttackStop(victim);
7278  return true;
7279  }
7280  return false;
7281  }
7282 
7283  // switch target
7285  if (!meleeAttack)
7287  }
7288 
7289  if (m_attacking)
7291 
7292  m_attacking = victim;
7293  m_attacking->_addAttacker(this);
7294 
7295  // Set our target
7296  SetTarget(victim->GetGUID());
7297 
7298  if (meleeAttack)
7300 
7301  // set position before any AI calls/assistance
7302  //if (GetTypeId() == TYPEID_UNIT)
7303  // ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
7304 
7305  if (GetTypeId() == TYPEID_UNIT && !IsPet())
7306  {
7307  // should not let player enter combat by right clicking target - doesn't helps
7308  SetInCombatWith(victim);
7309  if (victim->GetTypeId() == TYPEID_PLAYER)
7310  victim->SetInCombatWith(this);
7311  AddThreat(victim, 0.0f);
7312 
7315  }
7316 
7317  // delay offhand weapon attack to next attack time
7318  if (haveOffhandWeapon())
7320 
7321  if (meleeAttack)
7322  SendMeleeAttackStart(victim);
7323 
7324  // Let the pet know we've started attacking someting. Handles melee attacks only
7325  // Spells such as auto-shot and others handled in WorldSession::HandleCastSpellOpcode
7326  if (this->GetTypeId() == TYPEID_PLAYER)
7327  {
7328  Pet* playerPet = this->ToPlayer()->GetPet();
7329 
7330  if (playerPet && playerPet->IsAlive())
7331  playerPet->AI()->OwnerAttacked(victim);
7332  }
7333 
7334  return true;
7335 }
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: Unit.cpp:10691
void SendMeleeAttackStop(Unit *victim=NULL)
Definition: Unit.cpp:2142
void AddUnitState(uint32 f)
Definition: Unit.h:1394
bool m_shouldReacquireTarget
Definition: Unit.h:2257
Definition: ObjectGuid.h:32
bool IsInEvadeMode() const
Definition: Creature.h:520
Definition: Unit.h:551
virtual void OwnerAttacked(Unit *)
Definition: CreatureAI.h:159
Player * ToPlayer()
Definition: Object.h:191
void CallAssistance()
Definition: Creature.cpp:2021
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
TypeID GetTypeId() const
Definition: Object.h:113
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:2849
Definition: SharedDefines.h:4355
Definition: Unit.h:690
Definition: Unit.h:618
Definition: Unit.h:1108
bool IsAlive() const
Definition: Unit.h:1692
void _addAttacker(Unit *pAttacker)
Definition: Unit.cpp:7201
Unit * m_attacking
Definition: Unit.h:2256
CreatureAI * AI() const
Definition: Creature.h:525
void SendMeleeAttackStart(Unit *victim)
Definition: Unit.cpp:2134
bool haveOffhandWeapon() const
Definition: Unit.cpp:418
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:481
bool IsPet() const
Definition: Unit.h:1403
void SendAIReaction(AiReaction reactionType)
Definition: Creature.cpp:2009
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
void _removeAttacker(Unit *pAttacker)
Definition: Unit.cpp:7206
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
Definition: SpellAuraDefines.h:153
virtual void SetTarget(ObjectGuid const &)=0
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
bool IsMounted() const
Definition: Unit.h:1496
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247
bool IsInWorld() const
Definition: Object.h:100
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
Definition: Pet.h:46
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9840

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::AttackerStateUpdate ( Unit victim,
WeaponAttackType  attType = BASE_ATTACK,
bool  extra = false 
)
1875 {
1877  return;
1878 
1879  if (!victim->IsAlive())
1880  return;
1881 
1882  if ((attType == BASE_ATTACK || attType == OFF_ATTACK) && !IsWithinLOSInMap(victim))
1883  return;
1884 
1885  CombatStart(victim);
1887 
1888  if (attType != BASE_ATTACK && attType != OFF_ATTACK)
1889  return; // ignore ranged case
1890 
1892  SetFacingToObject(victim); // update client side facing to face the target (prevents visual glitches when casting untargeted spells)
1893 
1894  // melee attack spell cast at main hand attack only - no normal melee dmg dealt
1895  if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra)
1897  else
1898  {
1899  // attack can be redirected to another target
1900  victim = GetMeleeHitRedirectTarget(victim);
1901 
1902  CalcDamageInfo damageInfo;
1903  CalculateMeleeDamage(victim, 0, &damageInfo, attType);
1904  // Send log damage message to client
1905  DealDamageMods(victim, damageInfo.damage, &damageInfo.absorb);
1906  SendAttackStateUpdate(&damageInfo);
1907 
1908  //TriggerAurasProcOnEvent(damageInfo);
1909  ProcDamageAndSpell(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, damageInfo.procEx, damageInfo.damage, damageInfo.attackType);
1910 
1911  DealMeleeDamage(&damageInfo, true);
1912 
1913  TC_LOG_DEBUG("entities.unit", "AttackerStateUpdate: %s attacked %s for %u dmg, absorbed %u, blocked %u, resisted %u.",
1914  GetGUID().ToString().c_str(), victim->GetGUID().ToString().c_str(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
1915  }
1916 }
uint32 procAttacker
Definition: Unit.h:1034
Unit * GetMeleeHitRedirectTarget(Unit *victim, SpellInfo const *spellInfo=NULL)
Definition: Unit.cpp:7966
uint32 blocked_amount
Definition: Unit.h:1029
bool IsWithinLOSInMap(WorldObject const *obj) const
Definition: Object.cpp:1584
void CalculateMeleeDamage(Unit *victim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType=BASE_ATTACK)
Definition: Unit.cpp:1120
uint32 procVictim
Definition: Unit.h:1035
uint32 resist
Definition: Unit.h:1028
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
Definition: Unit.cpp:1311
Definition: ObjectGuid.h:32
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 procEx
Definition: Unit.h:1036
WeaponAttackType attackType
Definition: Unit.h:1033
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:690
void SetFacingToObject(WorldObject const *object)
Definition: Unit.cpp:15787
Definition: Unit.h:618
Definition: Unit.h:1108
Definition: Unit.h:1021
bool IsAlive() const
Definition: Unit.h:1692
std::string ToString() const
Definition: Position.cpp:160
uint32 absorb
Definition: Unit.h:1027
Definition: Unit.h:590
void SendAttackStateUpdate(CalcDamageInfo *damageInfo)
Definition: Unit.cpp:4925
void DealDamageMods(Unit *victim, uint32 &damage, uint32 *absorb)
Definition: Unit.cpp:603
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void ProcDamageAndSpell(Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellInfo const *procSpell=NULL, SpellInfo const *procAura=NULL)
Definition: Unit.cpp:4860
Definition: UpdateFields.h:109
Unit * target
Definition: Unit.h:1024
void CombatStart(Unit *target, bool initialAggro=true)
Definition: Unit.cpp:9862
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
uint32 damage
Definition: Unit.h:1026
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
Definition: Unit.h:697
std::string ToString() const
Definition: ObjectGuid.cpp:99
void cast(bool skipCheck=false)
Definition: Spell.cpp:3120
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::AttackStop ( )
7338 {
7339  if (!m_attacking)
7340  return false;
7341 
7342  Unit* victim = m_attacking;
7343 
7345  m_attacking = nullptr;
7346 
7347  // Clear our target
7349 
7351 
7353 
7354  // reset only at real combat stop
7355  if (Creature* creature = ToCreature())
7356  {
7357  creature->SetNoCallAssistance(false);
7358 
7359  if (creature->HasSearchedAssistance())
7360  {
7361  creature->SetNoSearchAssistance(false);
7362  UpdateSpeed(MOVE_RUN, false);
7363  }
7364  }
7365 
7366  SendMeleeAttackStop(victim);
7367 
7368  return true;
7369 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void SendMeleeAttackStop(Unit *victim=NULL)
Definition: Unit.cpp:2142
void UpdateSpeed(UnitMoveType mtype, bool forced)
Definition: Unit.cpp:10378
Definition: Creature.h:467
Definition: Unit.h:551
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:2849
Definition: Unit.h:1108
Unit * m_attacking
Definition: Unit.h:2256
Definition: Unit.h:600
void _removeAttacker(Unit *pAttacker)
Definition: Unit.cpp:7206
Creature * ToCreature()
Definition: Object.h:194
virtual void SetTarget(ObjectGuid const &)=0
Definition: Unit.h:1305

+ Here is the call graph for this function:

uint32 Unit::BuildAuraStateUpdateForTarget ( Unit target) const
7481 {
7483  for (AuraStateAurasMap::const_iterator itr = m_auraStateAuras.begin(); itr != m_auraStateAuras.end(); ++itr)
7484  if ((1<<(itr->first-1)) & PER_CASTER_AURA_STATE_MASK)
7485  if (itr->second->GetBase()->GetCasterGUID() == target->GetGUID())
7486  auraStates |= (1<<(itr->first-1));
7487 
7488  return auraStates;
7489 }
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
AuraStateAurasMap m_auraStateAuras
Definition: Unit.h:2282
Definition: UpdateFields.h:112
uint32_t uint32
Definition: Define.h:150
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define PER_CASTER_AURA_STATE_MASK
Definition: SharedDefines.h:1784

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::BuildValuesUpdate ( uint8  updatetype,
ByteBuffer data,
Player target 
) const
overrideprotectedvirtual

Reimplemented from Object.

16138 {
16139  if (!target)
16140  return;
16141 
16142  ByteBuffer fieldBuffer;
16143  UpdateMask updateMask;
16144 
16145  uint32 valCount = m_valuesCount;
16146 
16148  uint32 visibleFlag = UF_FLAG_PUBLIC;
16149 
16150  if (target == this)
16151  visibleFlag |= UF_FLAG_PRIVATE;
16152  else if (GetTypeId() == TYPEID_PLAYER)
16153  valCount = PLAYER_FIELD_END_NOT_SELF;
16154 
16155  updateMask.SetCount(valCount);
16156 
16158  if (GetOwnerGUID() == target->GetGUID())
16159  visibleFlag |= UF_FLAG_OWNER;
16160 
16162  if (HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID()))
16163  visibleFlag |= UF_FLAG_SPECIAL_INFO;
16164 
16165  if (plr && plr->IsInSameRaidWith(target))
16166  visibleFlag |= UF_FLAG_PARTY_MEMBER;
16167 
16168  Creature const* creature = ToCreature();
16169  for (uint16 index = 0; index < valCount; ++index)
16170  {
16171  if (_fieldNotifyFlags & flags[index] ||
16172  ((flags[index] & visibleFlag) & UF_FLAG_SPECIAL_INFO) ||
16173  ((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)) ||
16175  {
16176  updateMask.SetBit(index);
16177 
16178  if (index == UNIT_NPC_FLAGS)
16179  {
16180  uint32 appendValue = m_uint32Values[UNIT_NPC_FLAGS];
16181 
16182  if (creature)
16183  if (!target->CanSeeSpellClickOn(creature))
16184  appendValue &= ~UNIT_NPC_FLAG_SPELLCLICK;
16185 
16186  fieldBuffer << uint32(appendValue);
16187  }
16188  else if (index == UNIT_FIELD_AURASTATE)
16189  {
16190  // Check per caster aura states to not enable using a spell in client if specified aura is not by target
16191  fieldBuffer << BuildAuraStateUpdateForTarget(target);
16192  }
16193  // FIXME: Some values at server stored in float format but must be sent to client in uint32 format
16194  else if (index >= UNIT_FIELD_BASEATTACKTIME && index <= UNIT_FIELD_RANGEDATTACKTIME)
16195  {
16196  // convert from float to uint32 and send
16197  fieldBuffer << uint32(m_floatValues[index] < 0 ? 0 : m_floatValues[index]);
16198  }
16199  // there are some float values which may be negative or can't get negative due to other checks
16200  else if ((index >= UNIT_FIELD_NEGSTAT && index < UNIT_FIELD_NEGSTAT + 5) ||
16203  (index >= UNIT_FIELD_POSSTAT && index < UNIT_FIELD_POSSTAT + 5))
16204  {
16205  fieldBuffer << uint32(m_floatValues[index]);
16206  }
16207  // Gamemasters should be always able to select units - remove not selectable flag
16208  else if (index == UNIT_FIELD_FLAGS)
16209  {
16210  uint32 appendValue = m_uint32Values[UNIT_FIELD_FLAGS];
16211  if (target->IsGameMaster())
16212  appendValue &= ~UNIT_FLAG_NOT_SELECTABLE;
16213 
16214  fieldBuffer << uint32(appendValue);
16215  }
16216  // use modelid_a if not gm, _h if gm for CREATURE_FLAG_EXTRA_TRIGGER creatures
16217  else if (index == UNIT_FIELD_DISPLAYID)
16218  {
16220  if (creature)
16221  {
16222  CreatureTemplate const* cinfo = creature->GetCreatureTemplate();
16223 
16224  // this also applies for transform auras
16225  if (SpellInfo const* transform = sSpellMgr->GetSpellInfo(getTransForm()))
16226  for (SpellEffectInfo const* effect : transform->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
16227  if (effect && effect->IsAura(SPELL_AURA_TRANSFORM))
16228  if (CreatureTemplate const* transformInfo = sObjectMgr->GetCreatureTemplate(effect->MiscValue))
16229  {
16230  cinfo = transformInfo;
16231  break;
16232  }
16233 
16235  if (target->IsGameMaster())
16236  displayId = cinfo->GetFirstVisibleModel();
16237  }
16238 
16239  fieldBuffer << uint32(displayId);
16240  }
16241  // hide lootable animation for unallowed players
16242  else if (index == OBJECT_DYNAMIC_FLAGS)
16243  {
16245 
16246  if (creature)
16247  {
16248  if (creature->hasLootRecipient())
16249  {
16250  dynamicFlags |= UNIT_DYNFLAG_TAPPED;
16251  if (creature->isTappedBy(target))
16252  dynamicFlags |= UNIT_DYNFLAG_TAPPED_BY_PLAYER;
16253  }
16254 
16255  if (!target->isAllowedToLoot(creature))
16256  dynamicFlags &= ~UNIT_DYNFLAG_LOOTABLE;
16257  }
16258 
16259  // unit UNIT_DYNFLAG_TRACK_UNIT should only be sent to caster of SPELL_AURA_MOD_STALKED auras
16260  if (dynamicFlags & UNIT_DYNFLAG_TRACK_UNIT)
16261  if (!HasAuraTypeWithCaster(SPELL_AURA_MOD_STALKED, target->GetGUID()))
16262  dynamicFlags &= ~UNIT_DYNFLAG_TRACK_UNIT;
16263 
16264  fieldBuffer << dynamicFlags;
16265  }
16266  // FG: pretend that OTHER players in own group are friendly ("blue")
16267  else if (index == UNIT_FIELD_BYTES_2 || index == UNIT_FIELD_FACTIONTEMPLATE)
16268  {
16269  if (IsControlledByPlayer() && target != this && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && IsInRaidWith(target))
16270  {
16272  FactionTemplateEntry const* ft2 = target->GetFactionTemplateEntry();
16273  if (ft1 && ft2 && !ft1->IsFriendlyTo(*ft2))
16274  {
16275  if (index == UNIT_FIELD_BYTES_2)
16276  // Allow targetting opposite faction in party when enabled in config
16277  fieldBuffer << (m_uint32Values[UNIT_FIELD_BYTES_2] & ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) << 8)); // this flag is at uint8 offset 1 !!
16278  else
16279  // pretend that all other HOSTILE players have own faction, to allow follow, heal, rezz (trade wont work)
16280  fieldBuffer << uint32(target->getFaction());
16281  }
16282  else
16283  fieldBuffer << m_uint32Values[index];
16284  }
16285  else
16286  fieldBuffer << m_uint32Values[index];
16287  }
16288  else
16289  {
16290  // send in current format (float as float, uint32 as uint32)
16291  fieldBuffer << m_uint32Values[index];
16292  }
16293  }
16294  }
16295 
16296  *data << uint8(updateMask.GetBlockCount());
16297  updateMask.AppendToPacket(data);
16298  data->append(fieldBuffer);
16299 }
Definition: UpdateMask.h:26
Definition: UpdateFieldFlags.h:32
Definition: Unit.h:759
Definition: ByteBuffer.h:70
UpdateMask _changesMask
Definition: Object.h:241
Definition: SharedDefines.h:4202
Definition: UpdateFields.h:146
uint32 * m_uint32Values
Definition: Object.h:235
bool HasAuraTypeWithCaster(AuraType auratype, ObjectGuid caster) const
Definition: Unit.cpp:4252
Map * GetMap() const
Definition: Object.h:543
Definition: UpdateFieldFlags.h:28
bool IsControlledByPlayer() const
Definition: Unit.h:1712
Definition: SpellInfo.h:326
Definition: SpellAuraDefines.h:128
Definition: UpdateFieldFlags.h:27
uint32 GetBlockCount() const
Definition: UpdateMask.h:64
Definition: UpdateFieldFlags.h:31
Definition: Creature.h:467
uint32 flags_extra
Definition: Creature.h:142
#define sWorld
Definition: World.h:887
void AppendToPacket(ByteBuffer *data)
Definition: UpdateMask.h:51
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: UpdateFields.h:113
Definition: SpellAuraDefines.h:116
Definition: UpdateFields.h:112
Definition: UpdateFields.h:142
uint32 getTransForm() const
Definition: Unit.h:2018
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
bool IsFriendlyTo(FactionTemplateEntry const &entry) const
Definition: DBCStructure.h:446
Definition: UpdateFields.h:138
Definition: UpdateFields.h:114
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: UpdateFields.h:141
Definition: UpdateFields.h:117
uint32 GetFirstVisibleModel() const
Definition: Creature.cpp:129
void append(T value)
Definition: ByteBuffer.h:143
Definition: SharedDefines.h:4204
Definition: DBCStructure.h:433
Definition: SharedDefines.h:4201
uint8_t uint8
Definition: g3dmath.h:164
Definition: SharedDefines.h:4205
Definition: SharedDefines.h:4203
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
Definition: UpdateFieldFlags.h:29
Definition: UpdateFields.h:211
Creature * ToCreature()
Definition: Object.h:194
float * m_floatValues
Definition: Object.h:236
void SetCount(uint32 valuesCount)
Definition: UpdateMask.h:67
uint16 m_valuesCount
Definition: Object.h:245
bool isTappedBy(Player const *player) const
Definition: Creature.cpp:1022
bool hasLootRecipient() const
Definition: Creature.h:586
Definition: UpdateFields.h:135
Definition: UpdateFields.h:30
Definition: UpdateFields.h:107
bool GetBit(uint32 index) const
Definition: UpdateMask.h:49
uint32_t uint32
Definition: g3dmath.h:168
uint8 flags
Definition: DisableMgr.cpp:44
Definition: SpellAuraDefines.h:181
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7019
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:14391
void SetBit(uint32 index)
Definition: UpdateMask.h:47
uint32 UnitUpdateFieldFlags[PLAYER_END]
Definition: UpdateFieldFlags.cpp:257
Definition: Creature.h:49
Definition: Unit.h:311
Definition: UpdateData.h:30
Definition: Unit.h:698
Definition: Creature.h:79
uint32 BuildAuraStateUpdateForTarget(Unit *target) const
Definition: Unit.cpp:7480
#define PER_CASTER_AURA_STATE_MASK
Definition: SharedDefines.h:1784
Definition: UpdateFields.h:139
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560
uint16 _fieldNotifyFlags
Definition: Object.h:248

+ Here is the call graph for this function:

void Unit::CalcAbsorbResist ( Unit victim,
SpellSchoolMask  schoolMask,
DamageEffectType  damagetype,
uint32 const  damage,
uint32 absorb,
uint32 resist,
SpellInfo const spellInfo = NULL 
)
1609 {
1610  if (!victim || !victim->IsAlive() || !damage)
1611  return;
1612 
1613  DamageInfo dmgInfo = DamageInfo(this, victim, damage, spellInfo, schoolMask, damagetype);
1614 
1615  uint32 spellResistance = CalcSpellResistance(victim, schoolMask, spellInfo);
1616  dmgInfo.ResistDamage(CalculatePct(damage, spellResistance));
1617 
1618  // Ignore Absorption Auras
1619  float auraAbsorbMod = 0;
1621  for (AuraEffectList::const_iterator itr = AbsIgnoreAurasA.begin(); itr != AbsIgnoreAurasA.end(); ++itr)
1622  {
1623  if (!((*itr)->GetMiscValue() & schoolMask))
1624  continue;
1625 
1626  if ((*itr)->GetAmount() > auraAbsorbMod)
1627  auraAbsorbMod = float((*itr)->GetAmount());
1628  }
1629 
1631  for (AuraEffectList::const_iterator itr = AbsIgnoreAurasB.begin(); itr != AbsIgnoreAurasB.end(); ++itr)
1632  {
1633  if (!((*itr)->GetMiscValue() & schoolMask))
1634  continue;
1635 
1636  if (((*itr)->GetAmount() > auraAbsorbMod) && (*itr)->IsAffectingSpell(spellInfo))
1637  auraAbsorbMod = float((*itr)->GetAmount());
1638  }
1639 
1640  RoundToInterval(auraAbsorbMod, 0.0f, 100.0f);
1641 
1642  int32 absorbIgnoringDamage = CalculatePct(dmgInfo.GetDamage(), auraAbsorbMod);
1643  dmgInfo.ModifyDamage(-absorbIgnoringDamage);
1644 
1645  // We're going to call functions which can modify content of the list during iteration over it's elements
1646  // Let's copy the list so we can prevent iterator invalidation
1647  AuraEffectList vSchoolAbsorbCopy(victim->GetAuraEffectsByType(SPELL_AURA_SCHOOL_ABSORB));
1648  vSchoolAbsorbCopy.sort(Trinity::AbsorbAuraOrderPred());
1649 
1650  // absorb without mana cost
1651  for (AuraEffectList::iterator itr = vSchoolAbsorbCopy.begin(); (itr != vSchoolAbsorbCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
1652  {
1653  AuraEffect* absorbAurEff = *itr;
1654  // Check if aura was removed during iteration - we don't need to work on such auras
1655  AuraApplication const* aurApp = absorbAurEff->GetBase()->GetApplicationOfTarget(victim->GetGUID());
1656  if (!aurApp)
1657  continue;
1658  if (!(absorbAurEff->GetMiscValue() & schoolMask))
1659  continue;
1660 
1661  // get amount which can be still absorbed by the aura
1662  int32 currentAbsorb = absorbAurEff->GetAmount();
1663  // aura with infinite absorb amount - let the scripts handle absorbtion amount, set here to 0 for safety
1664  if (currentAbsorb < 0)
1665  currentAbsorb = 0;
1666 
1667  uint32 tempAbsorb = uint32(currentAbsorb);
1668 
1669  bool defaultPrevented = false;
1670 
1671  absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented);
1672  currentAbsorb = tempAbsorb;
1673 
1674  if (defaultPrevented)
1675  continue;
1676 
1677  // absorb must be smaller than the damage itself
1678  currentAbsorb = RoundToInterval(currentAbsorb, 0, int32(dmgInfo.GetDamage()));
1679 
1680  dmgInfo.AbsorbDamage(currentAbsorb);
1681 
1682  tempAbsorb = currentAbsorb;
1683  absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb);
1684 
1685  // Check if our aura is using amount to count damage
1686  if (absorbAurEff->GetAmount() >= 0)
1687  {
1688  // Reduce shield amount
1689  absorbAurEff->SetAmount(absorbAurEff->GetAmount() - currentAbsorb);
1690  // Aura cannot absorb anything more - remove it
1691  if (absorbAurEff->GetAmount() <= 0)
1692  absorbAurEff->GetBase()->Remove(AURA_REMOVE_BY_ENEMY_SPELL);
1693  }
1694  }
1695 
1696  // absorb by mana cost
1698  for (AuraEffectList::const_iterator itr = vManaShieldCopy.begin(); (itr != vManaShieldCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
1699  {
1700  AuraEffect* absorbAurEff = *itr;
1701  // Check if aura was removed during iteration - we don't need to work on such auras
1702  AuraApplication const* aurApp = absorbAurEff->GetBase()->GetApplicationOfTarget(victim->GetGUID());
1703  if (!aurApp)
1704  continue;
1705  // check damage school mask
1706  if (!(absorbAurEff->GetMiscValue() & schoolMask))
1707  continue;
1708 
1709  // get amount which can be still absorbed by the aura
1710  int32 currentAbsorb = absorbAurEff->GetAmount();
1711  // aura with infinite absorb amount - let the scripts handle absorbtion amount, set here to 0 for safety
1712  if (currentAbsorb < 0)
1713  currentAbsorb = 0;
1714 
1715  uint32 tempAbsorb = currentAbsorb;
1716 
1717  bool defaultPrevented = false;
1718 
1719  absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented);
1720  currentAbsorb = tempAbsorb;
1721 
1722  if (defaultPrevented)
1723  continue;
1724 
1725  // absorb must be smaller than the damage itself
1726  currentAbsorb = RoundToInterval(currentAbsorb, 0, int32(dmgInfo.GetDamage()));
1727 
1728  int32 manaReduction = currentAbsorb;
1729 
1730  // lower absorb amount by talents
1731  if (float manaMultiplier = absorbAurEff->GetSpellEffectInfo()->CalcValueMultiplier(absorbAurEff->GetCaster()))
1732  manaReduction = int32(float(manaReduction) * manaMultiplier);
1733 
1734  int32 manaTaken = -victim->ModifyPower(POWER_MANA, -manaReduction);
1735 
1736  // take case when mana has ended up into account
1737  currentAbsorb = currentAbsorb ? int32(float(currentAbsorb) * (float(manaTaken) / float(manaReduction))) : 0;
1738 
1739  dmgInfo.AbsorbDamage(currentAbsorb);
1740 
1741  tempAbsorb = currentAbsorb;
1742  absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb);
1743 
1744  // Check if our aura is using amount to count damage
1745  if (absorbAurEff->GetAmount() >= 0)
1746  {
1747  absorbAurEff->SetAmount(absorbAurEff->GetAmount() - currentAbsorb);
1748  if ((absorbAurEff->GetAmount() <= 0))
1749  absorbAurEff->GetBase()->Remove(AURA_REMOVE_BY_ENEMY_SPELL);
1750  }
1751  }
1752 
1753  dmgInfo.ModifyDamage(absorbIgnoringDamage);
1754 
1755  // split damage auras - only when not damaging self
1756  if (victim != this)
1757  {
1758  // We're going to call functions which can modify content of the list during iteration over it's elements
1759  // Let's copy the list so we can prevent iterator invalidation
1760  AuraEffectList vSplitDamagePctCopy(victim->GetAuraEffectsByType(SPELL_AURA_SPLIT_DAMAGE_PCT));
1761  for (AuraEffectList::iterator itr = vSplitDamagePctCopy.begin(); itr != vSplitDamagePctCopy.end() && dmgInfo.GetDamage() > 0; ++itr)
1762  {
1763  // Check if aura was removed during iteration - we don't need to work on such auras
1764  AuraApplication const* aurApp = (*itr)->GetBase()->GetApplicationOfTarget(victim->GetGUID());
1765  if (!aurApp)
1766  continue;
1767 
1768  // check damage school mask
1769  if (!((*itr)->GetMiscValue() & schoolMask))
1770  continue;
1771 
1772  // Damage can be splitted only if aura has an alive caster
1773  Unit* caster = (*itr)->GetCaster();
1774  if (!caster || (caster == victim) || !caster->IsInWorld() || !caster->IsAlive())
1775  continue;
1776 
1777  uint32 splitDamage = CalculatePct(dmgInfo.GetDamage(), (*itr)->GetAmount());
1778 
1779  (*itr)->GetBase()->CallScriptEffectSplitHandlers((*itr), aurApp, dmgInfo, splitDamage);
1780 
1781  // absorb must be smaller than the damage itself
1782  splitDamage = RoundToInterval(splitDamage, uint32(0), uint32(dmgInfo.GetDamage()));
1783 
1784  dmgInfo.AbsorbDamage(splitDamage);
1785 
1786  // check if caster is immune to damage
1787  if (caster->IsImmunedToDamage(schoolMask))
1788  {
1789  victim->SendSpellMiss(caster, (*itr)->GetSpellInfo()->Id, SPELL_MISS_IMMUNE);
1790  continue;
1791  }
1792 
1793  uint32 split_absorb = 0;
1794  DealDamageMods(caster, splitDamage, &split_absorb);
1795 
1796  SpellNonMeleeDamage log(this, caster, (*itr)->GetSpellInfo()->Id, schoolMask);
1797  CleanDamage cleanDamage = CleanDamage(splitDamage, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
1798  DealDamage(caster, splitDamage, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*itr)->GetSpellInfo(), false);
1799  log.damage = splitDamage;
1800  log.absorb = split_absorb;
1802 
1803  // break 'Fear' and similar auras
1804  caster->ProcDamageAndSpellFor(true, this, PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG, PROC_EX_NORMAL_HIT, BASE_ATTACK, (*itr)->GetSpellInfo(), splitDamage);
1805  }
1806  }
1807 
1808  *resist = dmgInfo.GetResist();
1809  *absorb = dmgInfo.GetAbsorb();
1810 }
Definition: SpellAuraEffects.h:30
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:10285
Definition: SharedDefines.h:2028
SpellEffectInfo const * GetSpellEffectInfo() const
Definition: SpellAuraEffects.h:102
void ModifyDamage(int32 amount)
Definition: Unit.cpp:129
T RoundToInterval(T &num, T floor, T ceil)
Definition: Util.h:110
int32 GetMiscValue() const
Definition: SpellAuraEffects.h:53
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
TC_SHARED_API::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions,::google::protobuf::internal::EnumTypeTraits< ::bgs::protocol::LogOption,::bgs::protocol::LogOption_IsValid >, 14, false > log
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
void ResistDamage(uint32 amount)
Definition: Unit.cpp:142
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
float CalcValueMultiplier(Unit *caster, Spell *spell=NULL) const
Definition: SpellInfo.cpp:629
void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo)
Definition: Unit.cpp:4897
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
Unit * GetCaster() const
Definition: SpellAuraEffects.h:39
void AbsorbDamage(uint32 amount)
Definition: Unit.cpp:135
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const
Definition: Unit.cpp:9214
Definition: Unit.h:885
void ProcDamageAndSpellFor(bool isVictim, Unit *target, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellInfo const *procSpell, uint32 damage, SpellInfo const *procAura=NULL)
Definition: Unit.cpp:12232
uint32 CalcSpellResistance(Unit *victim, SpellSchoolMask schoolMask, SpellInfo const *spellInfo) const
Definition: Unit.cpp:1536
void CallScriptEffectAfterManaShieldHandlers(AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount)
Definition: SpellAuras.cpp:2194
Definition: Unit.h:1042
bool IsAlive() const
Definition: Unit.h:1692
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
Definition: SpellAuraDefines.h:141
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
void CallScriptEffectAfterAbsorbHandlers(AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount)
Definition: SpellAuras.cpp:2166
uint32 GetDamage() const
Definition: Unit.h:949
Definition: SpellAuraDefines.h:157
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: SpellMgr.h:199
Definition: SpellAuraDefines.h:254
void DealDamageMods(Unit *victim, uint32 &damage, uint32 *absorb)
Definition: Unit.cpp:603
Definition: SpellAuraEffects.h:334
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const *log)
Definition: Unit.cpp:4839
void SetAmount(int32 amount)
Definition: SpellAuraEffects.h:56
Definition: Unit.h:453
int32_t int32
Definition: g3dmath.h:167
Definition: Unit.h:662
void CallScriptEffectAbsorbHandlers(AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount, bool &defaultPrevented)
Definition: SpellAuras.cpp:2148
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellAuraDefines.h:255
bool IsInWorld() const
Definition: Object.h:100
Definition: Unit.h:907
uint32 GetResist() const
Definition: Unit.h:951
uint32 GetAbsorb() const
Definition: Unit.h:950
Definition: Unit.h:1305
void CallScriptEffectManaShieldHandlers(AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount, bool &defaultPrevented)
Definition: SpellAuras.cpp:2180
Definition: SpellAuraDefines.h:129
uint32 DealDamage(Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=NULL, bool durabilityLoss=true)
Definition: Unit.cpp:613
Definition: Unit.h:617
Definition: SharedDefines.h:248
Definition: Unit.h:921

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::CalcArmorReducedDamage ( Unit victim,
const uint32  damage,
SpellInfo const spellInfo,
WeaponAttackType  attackType = MAX_ATTACK 
)
1476 {
1477  float armor = float(victim->GetArmor());
1478 
1479  // bypass enemy armor by SPELL_AURA_BYPASS_ARMOR_FOR_CASTER
1480  int32 armorBypassPct = 0;
1482  for (AuraEffectList::const_iterator i = reductionAuras.begin(); i != reductionAuras.end(); ++i)
1483  if ((*i)->GetCasterGUID() == GetGUID())
1484  armorBypassPct += (*i)->GetAmount();
1485  armor = CalculatePct(armor, 100 - std::min(armorBypassPct, 100));
1486 
1487  // Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura
1489 
1490  if (spellInfo)
1491  if (Player* modOwner = GetSpellModOwner())
1492  modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor);
1493 
1495  for (AuraEffectList::const_iterator j = resIgnoreAuras.begin(); j != resIgnoreAuras.end(); ++j)
1496  {
1497  if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
1498  armor = std::floor(AddPct(armor, -(*j)->GetAmount()));
1499  }
1500 
1501  // Apply Player CR_ARMOR_PENETRATION rating
1502  if (GetTypeId() == TYPEID_PLAYER)
1503  {
1504  float maxArmorPen = 0;
1505  if (victim->getLevel() < 60)
1506  maxArmorPen = float(400 + 85 * victim->getLevel());
1507  else
1508  maxArmorPen = 400 + 85 * victim->getLevel() + 4.5f * 85 * (victim->getLevel() - 59);
1509 
1510  // Cap armor penetration to this number
1511  maxArmorPen = std::min((armor + maxArmorPen) / 3, armor);
1512  // Figure out how much armor do we ignore
1513  float armorPen = CalculatePct(maxArmorPen, ToPlayer()->GetRatingBonusValue(CR_ARMOR_PENETRATION));
1514  // Got the value, apply it
1515  armor -= std::min(armorPen, maxArmorPen);
1516  }
1517 
1518  if (armor < 0.0f)
1519  armor = 0.0f;
1520 
1521  float levelModifier = getLevel();
1522  if (levelModifier > 59)
1523  levelModifier = levelModifier + 4.5f * (levelModifier - 59);
1524 
1525  float tmpvalue = 0.1f * armor / (8.5f * levelModifier + 40);
1526  tmpvalue = tmpvalue / (1.0f + tmpvalue);
1527 
1528  if (tmpvalue < 0.0f)
1529  tmpvalue = 0.0f;
1530  if (tmpvalue > 0.75f)
1531  tmpvalue = 0.75f;
1532 
1533  return std::max<uint32>(uint32(damage * (1.0f - tmpvalue)), 1);
1534 }
Definition: SpellAuraDefines.h:183
static Vector3int16 floor(const Vector3 &v)
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SpellAuraDefines.h:329
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
TypeID GetTypeId() const
Definition: Object.h:113
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Definition: SharedDefines.h:288
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
T CalculatePct(T base, U pct)
Definition: Util.h:92
uint32 GetArmor() const
Definition: Unit.h:1419
int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4452
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Unit.h:99
Definition: ObjectGuid.h:33
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Definition: Unit.h:649
T AddPct(T &base, U pct)
Definition: Util.h:98
Definition: SpellAuraDefines.h:405
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::CalcHealAbsorb ( Unit victim,
SpellInfo const spellInfo,
uint32 healAmount,
uint32 absorb 
)
1813 {
1814  if (!healAmount)
1815  return;
1816 
1817  int32 RemainingHeal = healAmount;
1818 
1819  // Need remove expired auras after
1820  bool existExpired = false;
1821 
1822  // absorb without mana cost
1824  for (AuraEffectList::const_iterator i = vHealAbsorb.begin(); i != vHealAbsorb.end() && RemainingHeal > 0; ++i)
1825  {
1826  if (!((*i)->GetMiscValue() & healSpell->SchoolMask))
1827  continue;
1828 
1829  // Max Amount can be absorbed by this aura
1830  int32 currentAbsorb = (*i)->GetAmount();
1831 
1832  // Found empty aura (impossible but..)
1833  if (currentAbsorb <= 0)
1834  {
1835  existExpired = true;
1836  continue;
1837  }
1838 
1839  // currentAbsorb - damage can be absorbed by shield
1840  // If need absorb less damage
1841  if (RemainingHeal < currentAbsorb)
1842  currentAbsorb = RemainingHeal;
1843 
1844  RemainingHeal -= currentAbsorb;
1845 
1846  // Reduce shield amount
1847  (*i)->SetAmount((*i)->GetAmount() - currentAbsorb);
1848  // Need remove it later
1849  if ((*i)->GetAmount() <= 0)
1850  existExpired = true;
1851  }
1852 
1853  // Remove all expired absorb auras
1854  if (existExpired)
1855  {
1856  for (AuraEffectList::const_iterator i = vHealAbsorb.begin(); i != vHealAbsorb.end();)
1857  {
1858  AuraEffect* auraEff = *i;
1859  ++i;
1860  if (auraEff->GetAmount() <= 0)
1861  {
1862  uint32 removedAuras = victim->m_removedAurasCount;
1864  if (removedAuras+1 < victim->m_removedAurasCount)
1865  i = vHealAbsorb.begin();
1866  }
1867  }
1868  }
1869 
1870  absorb = RemainingHeal > 0 ? (healAmount - RemainingHeal) : healAmount;
1871  healAmount = RemainingHeal;
1872 }
Definition: SpellAuraEffects.h:30
uint32 m_removedAurasCount
Definition: Unit.h:2277
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
Definition: SpellAuraDefines.h:361
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: Unit.h:453

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::CalcSpellDuration ( SpellInfo const spellProto)
10940 {
10941  uint32 comboPoints = m_movedPlayer ? m_movedPlayer->GetComboPoints() : 0;
10942 
10943  int32 minduration = spellProto->GetDuration();
10944  int32 maxduration = spellProto->GetMaxDuration();
10945 
10946  int32 duration;
10947 
10948  if (comboPoints && minduration != -1 && minduration != maxduration)
10949  duration = minduration + int32((maxduration - minduration) * comboPoints / 5);
10950  else
10951  duration = minduration;
10952 
10953  return duration;
10954 }
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
int32_t int32
Definition: g3dmath.h:167
Player * m_movedPlayer
Definition: Unit.h:1753

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::CalcSpellResistance ( Unit victim,
SpellSchoolMask  schoolMask,
SpellInfo const spellInfo 
) const
1537 {
1538  // Magic damage, check for resists
1539  if (!(schoolMask & SPELL_SCHOOL_MASK_SPELL))
1540  return 0;
1541 
1542  // Ignore spells that can't be resisted
1543  if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR4_IGNORE_RESISTANCES))
1544  return 0;
1545 
1546  uint8 const bossLevel = 83;
1547  uint32 const bossResistanceConstant = 510;
1548  uint32 resistanceConstant = 0;
1549  uint8 level = victim->getLevel();
1550 
1551  if (level == bossLevel)
1552  resistanceConstant = bossResistanceConstant;
1553  else
1554  resistanceConstant = level * 5;
1555 
1556  int32 baseVictimResistance = victim->GetResistance(schoolMask);
1557  baseVictimResistance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask);
1558 
1559  if (Player const* player = ToPlayer())
1560  baseVictimResistance -= player->GetSpellPenetrationItemMod();
1561 
1562  // Resistance can't be lower then 0
1563  int32 victimResistance = std::max<int32>(baseVictimResistance, 0);
1564 
1565  if (victimResistance > 0)
1566  {
1567  int32 ignoredResistance = 0;
1568 
1570  for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr)
1571  if ((*itr)->GetMiscValue() & schoolMask)
1572  ignoredResistance += (*itr)->GetAmount();
1573 
1574  ignoredResistance = std::min<int32>(ignoredResistance, 100);
1575  ApplyPct(victimResistance, 100 - ignoredResistance);
1576  }
1577 
1578  if (victimResistance <= 0)
1579  return 0;
1580 
1581  float averageResist = float(victimResistance) / float(victimResistance + resistanceConstant);
1582 
1583  float discreteResistProbability[11];
1584  for (uint32 i = 0; i < 11; ++i)
1585  {
1586  discreteResistProbability[i] = 0.5f - 2.5f * std::fabs(0.1f * i - averageResist);
1587  if (discreteResistProbability[i] < 0.0f)
1588  discreteResistProbability[i] = 0.0f;
1589  }
1590 
1591  if (averageResist <= 0.1f)
1592  {
1593  discreteResistProbability[0] = 1.0f - 7.5f * averageResist;
1594  discreteResistProbability[1] = 5.0f * averageResist;
1595  discreteResistProbability[2] = 2.5f * averageResist;
1596  }
1597 
1598  uint32 resistance = 0;
1599  float r = float(rand_norm());
1600  float probabilitySum = discreteResistProbability[0];
1601 
1602  while (r >= probabilitySum && resistance < 10)
1603  probabilitySum += discreteResistProbability[++resistance];
1604 
1605  return resistance * 10;
1606 }
Definition: SpellAuraDefines.h:183
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
T ApplyPct(T &base, U pct)
Definition: Util.h:104
Definition: SpellAuraDefines.h:329
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
Definition: SharedDefines.h:299
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4452
double rand_norm()
Definition: Random.cpp:69
uint8_t uint8
Definition: Define.h:152
uint32 GetResistance(SpellSchools school) const
Definition: Unit.h:1422
Definition: SharedDefines.h:500

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::CalculateDamage ( WeaponAttackType  attType,
bool  normalized,
bool  addTotalPct 
)
2079 {
2080  float minDamage = 0.0f;
2081  float maxDamage = 0.0f;
2082 
2083  if (normalized || !addTotalPct)
2084  CalculateMinMaxDamage(attType, normalized, addTotalPct, minDamage, maxDamage);
2085  else
2086  {
2087  switch (attType)
2088  {
2089  case RANGED_ATTACK:
2092  break;
2093  case BASE_ATTACK:
2094  minDamage = GetFloatValue(UNIT_FIELD_MINDAMAGE);
2095  maxDamage = GetFloatValue(UNIT_FIELD_MAXDAMAGE);
2096  break;
2097  case OFF_ATTACK:
2100  break;
2101  default:
2102  break;
2103  }
2104  }
2105 
2106  minDamage = std::max(0.f, minDamage);
2107  maxDamage = std::max(0.f, maxDamage);
2108 
2109  if (minDamage > maxDamage)
2110  std::swap(minDamage, maxDamage);
2111 
2112  if (maxDamage == 0.0f)
2113  maxDamage = 5.0f;
2114 
2115  return urand(uint32(minDamage), uint32(maxDamage));
2116 }
Definition: UpdateFields.h:120
Definition: UpdateFields.h:123
Definition: Unit.h:619
Definition: UpdateFields.h:121
Definition: UpdateFields.h:155
T max(const T &x, const T &y)
Definition: g3dmath.h:320
virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage)=0
Definition: Unit.h:618
Definition: UpdateFields.h:156
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
Definition: UpdateFields.h:122
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::CalculateDefaultCoefficient ( SpellInfo const spellInfo,
DamageEffectType  damagetype 
) const
13091 {
13092  // Damage over Time spells bonus calculation
13093  float DotFactor = 1.0f;
13094  if (damagetype == DOT)
13095  {
13096 
13097  int32 DotDuration = spellInfo->GetDuration();
13098  if (!spellInfo->IsChanneled() && DotDuration > 0)
13099  DotFactor = DotDuration / 15000.0f;
13100 
13101  if (uint32 DotTicks = spellInfo->GetMaxTicks(GetMap()->GetDifficultyID()))
13102  DotFactor /= DotTicks;
13103  }
13104 
13105  int32 CastingTime = spellInfo->IsChanneled() ? spellInfo->GetDuration() : spellInfo->CalcCastTime(getLevel());
13106  // Distribute Damage over multiple effects, reduce by AoE
13107  CastingTime = GetCastingTimeForBonus(spellInfo, damagetype, CastingTime);
13108 
13109  // As wowwiki says: C = (Cast Time / 3.5)
13110  return (CastingTime / 3500.0f) * DotFactor;
13111 }
Map * GetMap() const
Definition: Object.h:543
uint32 GetCastingTimeForBonus(SpellInfo const *spellProto, DamageEffectType damagetype, uint32 CastingTime) const
Definition: Unit.cpp:12967
Definition: Unit.h:664
uint8 getLevel() const
Definition: Unit.h:1408
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150

+ Here is the call graph for this function:

float Unit::CalculateLevelPenalty ( SpellInfo const spellProto) const
2119 {
2120  if (spellProto->SpellLevel <= 0 || spellProto->SpellLevel >= spellProto->MaxLevel)
2121  return 1.0f;
2122 
2123  float LvlPenalty = 0.0f;
2124 
2125  if (spellProto->SpellLevel < 20)
2126  LvlPenalty = 20.0f - spellProto->SpellLevel * 3.75f;
2127  float LvlFactor = (float(spellProto->SpellLevel) + 6.0f) / float(getLevel());
2128  if (LvlFactor > 1.0f)
2129  LvlFactor = 1.0f;
2130 
2131  return AddPct(LvlFactor, -LvlPenalty);
2132 }
uint8 getLevel() const
Definition: Unit.h:1408
T AddPct(T &base, U pct)
Definition: Util.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::CalculateMeleeDamage ( Unit victim,
uint32  damage,
CalcDamageInfo damageInfo,
WeaponAttackType  attackType = BASE_ATTACK 
)
Todo:
for melee need create structure as in
1121 {
1122  damageInfo->attacker = this;
1123  damageInfo->target = victim;
1125  damageInfo->attackType = attackType;
1126  damageInfo->damage = 0;
1127  damageInfo->cleanDamage = 0;
1128  damageInfo->absorb = 0;
1129  damageInfo->resist = 0;
1130  damageInfo->blocked_amount = 0;
1131 
1132  damageInfo->TargetState = 0;
1133  damageInfo->HitInfo = 0;
1134  damageInfo->procAttacker = PROC_FLAG_NONE;
1135  damageInfo->procVictim = PROC_FLAG_NONE;
1136  damageInfo->procEx = PROC_EX_NONE;
1137  damageInfo->hitOutCome = MELEE_HIT_EVADE;
1138 
1139  if (!victim)
1140  return;
1141 
1142  if (!IsAlive() || !victim->IsAlive())
1143  return;
1144 
1145  // Select HitInfo/procAttacker/procVictim flag based on attack type
1146  switch (attackType)
1147  {
1148  case BASE_ATTACK:
1151  break;
1152  case OFF_ATTACK:
1155  damageInfo->HitInfo = HITINFO_OFFHAND;
1156  break;
1157  default:
1158  return;
1159  }
1160 
1161  // Physical Immune check
1162  if (damageInfo->target->IsImmunedToDamage(SpellSchoolMask(damageInfo->damageSchoolMask)))
1163  {
1164  damageInfo->HitInfo |= HITINFO_NORMALSWING;
1165  damageInfo->TargetState = VICTIMSTATE_IS_IMMUNE;
1166 
1167  damageInfo->procEx |= PROC_EX_IMMUNE;
1168  damageInfo->damage = 0;
1169  damageInfo->cleanDamage = 0;
1170  return;
1171  }
1172 
1173  damage += CalculateDamage(damageInfo->attackType, false, true);
1174  // Add melee damage bonus
1175  damage = MeleeDamageBonusDone(damageInfo->target, damage, damageInfo->attackType);
1176  damage = damageInfo->target->MeleeDamageBonusTaken(this, damage, damageInfo->attackType);
1177 
1178  // Script Hook For CalculateMeleeDamage -- Allow scripts to change the Damage pre class mitigation calculations
1179  sScriptMgr->ModifyMeleeDamage(damageInfo->target, damageInfo->attacker, damage);
1180 
1181  // Calculate armor reduction
1183  {
1184  damageInfo->damage = CalcArmorReducedDamage(damageInfo->target, damage, NULL, damageInfo->attackType);
1185  damageInfo->cleanDamage += damage - damageInfo->damage;
1186  }
1187  else
1188  damageInfo->damage = damage;
1189 
1190  damageInfo->hitOutCome = RollMeleeOutcomeAgainst(damageInfo->target, damageInfo->attackType);
1191 
1192  switch (damageInfo->hitOutCome)
1193  {
1194  case MELEE_HIT_EVADE:
1195  damageInfo->HitInfo |= HITINFO_MISS | HITINFO_SWINGNOHITSOUND;
1196  damageInfo->TargetState = VICTIMSTATE_EVADES;
1197  damageInfo->procEx |= PROC_EX_EVADE;
1198  damageInfo->damage = 0;
1199  damageInfo->cleanDamage = 0;
1200  return;
1201  case MELEE_HIT_MISS:
1202  damageInfo->HitInfo |= HITINFO_MISS;
1203  damageInfo->TargetState = VICTIMSTATE_INTACT;
1204  damageInfo->procEx |= PROC_EX_MISS;
1205  damageInfo->damage = 0;
1206  damageInfo->cleanDamage = 0;
1207  break;
1208  case MELEE_HIT_NORMAL:
1209  damageInfo->TargetState = VICTIMSTATE_HIT;
1210  damageInfo->procEx |= PROC_EX_NORMAL_HIT;
1211  break;
1212  case MELEE_HIT_CRIT:
1213  {
1214  damageInfo->HitInfo |= HITINFO_CRITICALHIT;
1215  damageInfo->TargetState = VICTIMSTATE_HIT;
1216 
1217  damageInfo->procEx |= PROC_EX_CRITICAL_HIT;
1218  // Crit bonus calc
1219  damageInfo->damage += damageInfo->damage;
1220  float mod = 0.0f;
1221  // Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE
1222  if (damageInfo->attackType == RANGED_ATTACK)
1224  else
1226 
1227  // Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS
1229 
1230  if (mod != 0)
1231  AddPct(damageInfo->damage, mod);
1232  break;
1233  }
1234  case MELEE_HIT_PARRY:
1235  damageInfo->TargetState = VICTIMSTATE_PARRY;
1236  damageInfo->procEx |= PROC_EX_PARRY;
1237  damageInfo->cleanDamage += damageInfo->damage;
1238  damageInfo->damage = 0;
1239  break;
1240  case MELEE_HIT_DODGE:
1241  damageInfo->TargetState = VICTIMSTATE_DODGE;
1242  damageInfo->procEx |= PROC_EX_DODGE;
1243  damageInfo->cleanDamage += damageInfo->damage;
1244  damageInfo->damage = 0;
1245  break;
1246  case MELEE_HIT_BLOCK:
1247  damageInfo->TargetState = VICTIMSTATE_HIT;
1248  damageInfo->HitInfo |= HITINFO_BLOCK;
1249  damageInfo->procEx |= PROC_EX_BLOCK | PROC_EX_NORMAL_HIT;
1250  // 30% damage blocked, double blocked amount if block is critical
1251  damageInfo->blocked_amount = CalculatePct(damageInfo->damage, damageInfo->target->isBlockCritical() ? damageInfo->target->GetBlockPercent() * 2 : damageInfo->target->GetBlockPercent());
1252  damageInfo->damage -= damageInfo->blocked_amount;
1253  damageInfo->cleanDamage += damageInfo->blocked_amount;
1254  break;
1255  case MELEE_HIT_GLANCING:
1256  {
1257  damageInfo->HitInfo |= HITINFO_GLANCING;
1258  damageInfo->TargetState = VICTIMSTATE_HIT;
1259  damageInfo->procEx |= PROC_EX_NORMAL_HIT;
1260  int32 leveldif = int32(victim->getLevel()) - int32(getLevel());
1261  if (leveldif > 3)
1262  leveldif = 3;
1263  float reducePercent = 1 - leveldif * 0.1f;
1264  damageInfo->cleanDamage += damageInfo->damage - uint32(reducePercent * damageInfo->damage);
1265  damageInfo->damage = uint32(reducePercent * damageInfo->damage);
1266  break;
1267  }
1268  case MELEE_HIT_CRUSHING:
1269  damageInfo->HitInfo |= HITINFO_CRUSHING;
1270  damageInfo->TargetState = VICTIMSTATE_HIT;
1271  damageInfo->procEx |= PROC_EX_NORMAL_HIT;
1272  // 150% normal damage
1273  damageInfo->damage += (damageInfo->damage / 2);
1274  break;
1275  default:
1276  break;
1277  }
1278 
1279  // Always apply HITINFO_AFFECTS_VICTIM in case its not a miss
1280  if (!(damageInfo->HitInfo & HITINFO_MISS))
1281  damageInfo->HitInfo |= HITINFO_AFFECTS_VICTIM;
1282 
1283  int32 resilienceReduction = damageInfo->damage;
1284  ApplyResilience(victim, &resilienceReduction);
1285  resilienceReduction = damageInfo->damage - resilienceReduction;
1286  damageInfo->damage -= resilienceReduction;
1287  damageInfo->cleanDamage += resilienceReduction;
1288 
1289  // Calculate absorb resist
1290  if (int32(damageInfo->damage) > 0)
1291  {
1292  damageInfo->procVictim |= PROC_FLAG_TAKEN_DAMAGE;
1293  // Calculate absorb & resists
1294  CalcAbsorbResist(damageInfo->target, SpellSchoolMask(damageInfo->damageSchoolMask), DIRECT_DAMAGE, damageInfo->damage, &damageInfo->absorb, &damageInfo->resist);
1295 
1296  if (damageInfo->absorb)
1297  {
1298  damageInfo->HitInfo |= (damageInfo->damage - damageInfo->absorb == 0 ? HITINFO_FULL_ABSORB : HITINFO_PARTIAL_ABSORB);
1299  damageInfo->procEx |= PROC_EX_ABSORB;
1300  }
1301 
1302  if (damageInfo->resist)
1303  damageInfo->HitInfo |= (damageInfo->damage - damageInfo->resist == 0 ? HITINFO_FULL_RESIST : HITINFO_PARTIAL_RESIST);
1304 
1305  damageInfo->damage -= damageInfo->absorb + damageInfo->resist;
1306  }
1307  else // Impossible get negative result but....
1308  damageInfo->damage = 0;
1309 }
Definition: SpellMgr.h:200
uint32 procAttacker
Definition: Unit.h:1034
Definition: Unit.h:351
Definition: SpellMgr.h:198
Definition: SpellMgr.h:205
Unit * attacker
Definition: Unit.h:1023
void ApplyResilience(Unit const *victim, int32 *damage) const
Definition: Unit.cpp:14521
Definition: Unit.h:353
bool isBlockCritical()
Definition: Unit.cpp:2171
Definition: SpellMgr.h:204
Definition: Unit.h:885
SpellSchoolMask
Definition: SharedDefines.h:285
uint32 blocked_amount
Definition: Unit.h:1029
virtual SpellSchoolMask GetMeleeDamageSchoolMask() const
Definition: Unit.cpp:12672
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
uint32 HitInfo
Definition: Unit.h:1030
uint32 MeleeDamageBonusTaken(Unit *attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const *spellProto=NULL)
Definition: Unit.cpp:9493
Definition: Unit.h:619
uint32 procVictim
Definition: Unit.h:1035
MeleeHitOutcome RollMeleeOutcomeAgainst(Unit const *victim, WeaponAttackType attType) const
Definition: Unit.cpp:1927
uint32 resist
Definition: Unit.h:1028
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Unit.h:366
uint32 CalcArmorReducedDamage(Unit *victim, const uint32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType=MAX_ATTACK)
Definition: Unit.cpp:1475
Definition: SpellMgr.h:114
MeleeHitOutcome hitOutCome
Definition: Unit.h:1038
Definition: SpellMgr.h:109
Definition: Unit.h:884
Definition: SpellAuraDefines.h:263
Definition: Unit.h:358
uint32 procEx
Definition: Unit.h:1036
uint8 getLevel() const
Definition: Unit.h:1408
WeaponAttackType attackType
Definition: Unit.h:1033
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const
Definition: Unit.cpp:9214
Definition: Unit.h:885
uint32 CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct)
Definition: Unit.cpp:2078
Definition: Unit.h:618
Definition: SpellAuraDefines.h:223
Definition: Unit.h:337
Definition: Unit.h:356
Definition: SpellMgr.h:141
Definition: SpellMgr.h:209
Definition: Unit.h:336
bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const *spellInfo=NULL, uint8 effIndex=MAX_SPELL_EFFECTS)
Definition: Unit.cpp:1452
Definition: Unit.h:348
bool IsAlive() const
Definition: Unit.h:1692
Definition: SpellMgr.h:144
Definition: SpellMgr.h:207
Definition: SpellMgr.h:115
int32_t int32
Definition: Define.h:146
Definition: Unit.h:362
Definition: Unit.h:338
uint32 absorb
Definition: Unit.h:1027
Definition: Unit.h:884
uint32 TargetState
Definition: Unit.h:1031
Definition: Unit.h:884
Definition: SpellMgr.h:203
Definition: Unit.h:884
uint32 damageSchoolMask
Definition: Unit.h:1025
float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4470
Definition: Unit.h:365
Definition: Unit.h:357
void CalcAbsorbResist(Unit *victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32 *absorb, uint32 *resist, SpellInfo const *spellInfo=NULL)
Definition: Unit.cpp:1608
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: Unit.h:342
Definition: SpellMgr.h:199
virtual uint32 GetBlockPercent() const
Definition: Unit.h:1557
uint32 MeleeDamageBonusDone(Unit *pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const *spellProto=NULL)
Definition: Unit.cpp:9385
Definition: SpellAuraDefines.h:264
Definition: Unit.h:884
Unit * target
Definition: Unit.h:1024
Definition: Unit.h:350
uint32 cleanDamage
Definition: Unit.h:1037
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
Definition: Unit.h:885
uint32 damage
Definition: Unit.h:1026
Definition: Unit.h:662
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: Unit.h:354
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellMgr.h:201
Definition: Unit.h:355
Definition: Unit.h:370
Definition: Unit.h:341
Definition: Unit.h:885
Definition: SpellMgr.h:145
Definition: SpellMgr.h:206
Definition: Unit.h:617
Definition: Unit.h:335

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Unit::CalculateMinMaxDamage ( WeaponAttackType  attType,
bool  normalized,
bool  addTotalPct,
float &  minDamage,
float &  maxDamage 
)
pure virtual

Implemented in Creature.

+ Here is the caller graph for this function:

int32 Unit::CalculateSpellDamage ( Unit const target,
SpellInfo const spellProto,
uint8  effect_index,
int32 const basePoints = nullptr,
float *  variance = nullptr,
int32  itemLevel = -1 
) const
10931 {
10932  SpellEffectInfo const* effect = spellProto->GetEffect(GetMap()->GetDifficultyID(), effect_index);
10933  if (variance)
10934  *variance = 0.0f;
10935 
10936  return effect ? effect->CalcValue(this, basePoints, target, variance, itemLevel) : 0;
10937 }
Map * GetMap() const
Definition: Object.h:543
Definition: SpellInfo.h:238
int32 CalcValue(Unit const *caster=nullptr, int32 const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, int32 itemLevel=-1) const
Definition: SpellInfo.cpp:455

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::CalculateSpellDamageTaken ( SpellNonMeleeDamage damageInfo,
int32  damage,
SpellInfo const spellInfo,
WeaponAttackType  attackType = BASE_ATTACK,
bool  crit = false 
)
989 {
990  if (damage < 0)
991  return;
992 
993  Unit* victim = damageInfo->target;
994  if (!victim || !victim->IsAlive())
995  return;
996 
997  SpellSchoolMask damageSchoolMask = SpellSchoolMask(damageInfo->schoolMask);
998 
999  // Spells with SPELL_ATTR4_FIXED_DAMAGE ignore resilience because their damage is based off another spell's damage.
1000  if (!spellInfo->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
1001  {
1002  if (IsDamageReducedByArmor(damageSchoolMask, spellInfo))
1003  damage = CalcArmorReducedDamage(victim, damage, spellInfo, attackType);
1004 
1005  bool blocked = false;
1006  // Per-school calc
1007  switch (spellInfo->DmgClass)
1008  {
1009  // Melee and Ranged Spells
1012  {
1013  // Physical Damage
1014  if (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL)
1015  {
1016  // Get blocked status
1017  blocked = isSpellBlocked(victim, spellInfo, attackType);
1018  }
1019 
1020  if (crit)
1021  {
1022  damageInfo->HitInfo |= SPELL_HIT_TYPE_CRIT;
1023 
1024  // Calculate crit bonus
1025  uint32 crit_bonus = damage;
1026  // Apply crit_damage bonus for melee spells
1027  if (Player* modOwner = GetSpellModOwner())
1028  modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
1029  damage += crit_bonus;
1030 
1031  // Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE
1032  float critPctDamageMod = 0.0f;
1033  if (attackType == RANGED_ATTACK)
1035  else
1037 
1038  // Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS
1039  critPctDamageMod += (GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, spellInfo->GetSchoolMask()) - 1.0f) * 100;
1040 
1041  if (critPctDamageMod != 0)
1042  AddPct(damage, critPctDamageMod);
1043  }
1044 
1045  // Spell weapon based damage CAN BE crit & blocked at same time
1046  if (blocked)
1047  {
1048  // double blocked amount if block is critical
1049  uint32 value = victim->GetBlockPercent();
1050  if (victim->isBlockCritical())
1051  value *= 2; // double blocked percent
1052  damageInfo->blocked = CalculatePct(damage, value);
1053  damage -= damageInfo->blocked;
1054  }
1055 
1056  ApplyResilience(victim, &damage);
1057  break;
1058  }
1059  // Magical Attacks
1062  {
1063  // If crit add critical bonus
1064  if (crit)
1065  {
1066  damageInfo->HitInfo |= SPELL_HIT_TYPE_CRIT;
1067  damage = SpellCriticalDamageBonus(spellInfo, damage, victim);
1068  }
1069 
1070  ApplyResilience(victim, &damage);
1071  break;
1072 
1073  }
1074  default:
1075  break;
1076  }
1077  }
1078 
1079  // Script Hook For CalculateSpellDamageTaken -- Allow scripts to change the Damage post class mitigation calculations
1080  sScriptMgr->ModifySpellDamageTaken(damageInfo->target, damageInfo->attacker, damage);
1081 
1082  // Calculate absorb resist
1083  if (damage > 0)
1084  {
1085  CalcAbsorbResist(victim, damageSchoolMask, SPELL_DIRECT_DAMAGE, damage, &damageInfo->absorb, &damageInfo->resist, spellInfo);
1086  damage -= damageInfo->absorb + damageInfo->resist;
1087  }
1088  else
1089  damage = 0;
1090 
1091  damageInfo->damage = damage;
1092 }
bool isSpellBlocked(Unit *victim, SpellInfo const *spellProto, WeaponAttackType attackType=BASE_ATTACK)
Definition: Unit.cpp:2152
Definition: SharedDefines.h:2038
void ApplyResilience(Unit const *victim, int32 *damage) const
Definition: Unit.cpp:14521
bool isBlockCritical()
Definition: Unit.cpp:2171
SpellSchoolMask
Definition: SharedDefines.h:285
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: Unit.h:619
Unit * attacker
Definition: Unit.h:1047
Definition: SharedDefines.h:2052
uint32 CalcArmorReducedDamage(Unit *victim, const uint32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType=MAX_ATTACK)
Definition: Unit.cpp:1475
uint32 SpellCriticalDamageBonus(SpellInfo const *spellProto, uint32 damage, Unit *victim)
Definition: Unit.cpp:8837
Definition: SharedDefines.h:2049
Definition: SpellAuraDefines.h:263
uint32 resist
Definition: Unit.h:1052
Definition: SpellAuraDefines.h:223
Definition: SharedDefines.h:288
Definition: Unit.h:101
bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const *spellInfo=NULL, uint8 effIndex=MAX_SPELL_EFFECTS)
Definition: Unit.cpp:1452
bool IsAlive() const
Definition: Unit.h:1692
uint32_t uint32
Definition: Define.h:150
uint32 blocked
Definition: Unit.h:1054
float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4470
void CalcAbsorbResist(Unit *victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32 *absorb, uint32 *resist, SpellInfo const *spellInfo=NULL)
Definition: Unit.cpp:1608
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: SharedDefines.h:2051
uint32 schoolMask
Definition: Unit.h:1050
virtual uint32 GetBlockPercent() const
Definition: Unit.h:1557
Definition: SharedDefines.h:2050
uint32 HitInfo
Definition: Unit.h:1055
uint32 damage
Definition: Unit.h:1049
Unit * target
Definition: Unit.h:1046
Definition: SpellAuraDefines.h:264
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
T AddPct(T &base, U pct)
Definition: Util.h:98
const FieldDescriptor value
Definition: descriptor.h:1522
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: SharedDefines.h:508
Definition: Unit.h:663
Definition: Unit.h:1305
uint32 absorb
Definition: Unit.h:1051

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::CanDualWield ( ) const
inline
1359 { return m_canDualWield; }
bool m_canDualWield
Definition: Unit.h:1367

+ Here is the caller graph for this function:

virtual bool Unit::CanFly ( ) const
pure virtual

Implemented in Creature.

+ Here is the caller graph for this function:

bool Unit::CanFreeMove ( ) const
11518 {
11521 }
Definition: Unit.h:562
Definition: Unit.h:561
Definition: Unit.h:557
Definition: Unit.h:553
Definition: Unit.h:558
Definition: Unit.h:560
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::CanHaveThreatList ( bool  skipAliveCheck = false) const
10653 {
10654  // only creatures can have threat list
10655  if (GetTypeId() != TYPEID_UNIT)
10656  return false;
10657 
10658  // only alive units can have threat list
10659  if (!skipAliveCheck && !IsAlive())
10660  return false;
10661 
10662  // totems can not have threat list
10663  if (IsTotem())
10664  return false;
10665 
10666  // vehicles can not have threat list
10667  //if (ToCreature()->IsVehicle())
10668  // return false;
10669 
10670  // summons can not have a threat list, unless they are controlled by a creature
10672  return false;
10673 
10674  return true;
10675 }
Definition: Unit.h:860
Definition: ObjectGuid.h:32
Definition: Unit.h:866
Definition: Unit.h:859
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
bool IsTotem() const
Definition: Unit.h:1405
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::CanModifyStats ( ) const
inline
1959 { return m_canModifyStats; }
bool m_canModifyStats
Definition: Unit.h:2287

+ Here is the caller graph for this function:

bool Unit::CanProc ( ) const
inline
2141 {return !m_procDeep;}
int32 m_procDeep
Definition: Unit.h:2261

+ Here is the caller graph for this function:

bool Unit::CanUseAttackType ( uint8  attacktype) const
2201 {
2202  switch (attacktype)
2203  {
2204  case BASE_ATTACK:
2206  case OFF_ATTACK:
2208  case RANGED_ATTACK:
2210  default:
2211  return true;
2212  }
2213 }
Definition: Unit.h:718
Definition: Unit.h:619
Definition: UpdateFields.h:110
Definition: Unit.h:618
Definition: UpdateFields.h:109
Definition: Unit.h:720
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
Definition: Unit.h:694
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::CastCustomSpell ( Unit victim,
uint32  spellId,
int32 const bp0,
int32 const bp1,
int32 const bp2,
bool  triggered,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
921 {
922  CustomSpellValues values;
923  if (bp0)
924  values.AddSpellMod(SPELLVALUE_BASE_POINT0, *bp0);
925  if (bp1)
926  values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1);
927  if (bp2)
928  values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2);
929  CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
930 }
Definition: Unit.h:131
Definition: Unit.h:167
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
Definition: Unit.h:130
void AddSpellMod(SpellValueMod mod, int32 value)
Definition: Unit.h:176
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:129
Definition: Unit.h:460

+ Here is the call graph for this function:

void Unit::CastCustomSpell ( uint32  spellId,
SpellValueMod  mod,
int32  value,
Unit victim,
bool  triggered,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
933 {
934  CustomSpellValues values;
935  values.AddSpellMod(mod, value);
936  CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
937 }
Definition: Unit.h:167
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
const FieldDescriptor value
Definition: descriptor.h:1522
void AddSpellMod(SpellValueMod mod, int32 value)
Definition: Unit.h:176
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:460

+ Here is the call graph for this function:

void Unit::CastCustomSpell ( uint32  spellId,
SpellValueMod  mod,
int32  value,
Unit victim = NULL,
TriggerCastFlags  triggerFlags = TRIGGERED_NONE,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
940 {
941  CustomSpellValues values;
942  values.AddSpellMod(mod, value);
943  CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster);
944 }
Definition: Unit.h:167
const FieldDescriptor value
Definition: descriptor.h:1522
void AddSpellMod(SpellValueMod mod, int32 value)
Definition: Unit.h:176
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920

+ Here is the call graph for this function:

void Unit::CastCustomSpell ( uint32  spellId,
CustomSpellValues const value,
Unit victim = NULL,
TriggerCastFlags  triggerFlags = TRIGGERED_NONE,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
947 {
948  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
949  if (!spellInfo)
950  {
951  TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s", spellId, GetGUID().ToString().c_str());
952  return;
953  }
954  SpellCastTargets targets;
955  targets.SetUnitTarget(victim);
956 
957  CastSpell(targets, spellInfo, &value, triggerFlags, castItem, triggeredByAura, originalCaster);
958 }
Definition: SpellInfo.h:326
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:230
std::string ToString() const
Definition: Position.cpp:160
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: Spell.h:170
ObjectGuid const & GetGUID() const
Definition: Object.h:105
const FieldDescriptor value
Definition: descriptor.h:1522
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

void Unit::CastSpell ( SpellCastTargets const targets,
SpellInfo const spellInfo,
CustomSpellValues const value,
TriggerCastFlags  triggerFlags = TRIGGERED_NONE,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
Todo:
this is a workaround - not needed anymore, but required for some scripts :(
870 {
871  if (!spellInfo)
872  {
873  TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell by caster: %s", GetGUID().ToString().c_str());
874  return;
875  }
876 
878  if (!originalCaster && triggeredByAura)
879  originalCaster = triggeredByAura->GetCasterGUID();
880 
881  Spell* spell = new Spell(this, spellInfo, triggerFlags, originalCaster);
882 
883  if (value)
884  for (CustomSpellValues::const_iterator itr = value->begin(); itr != value->end(); ++itr)
885  spell->SetSpellValue(itr->first, itr->second);
886 
887  spell->m_CastItem = castItem;
888  spell->prepare(&targets, triggeredByAura);
889 }
StorageType::const_iterator const_iterator
Definition: Unit.h:173
Item * m_CastItem
Definition: Spell.h:548
void prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
Definition: Spell.cpp:2860
std::string ToString() const
Definition: Position.cpp:160
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void SetSpellValue(SpellValueMod mod, int32 value)
Definition: Spell.cpp:6994
const FieldDescriptor value
Definition: descriptor.h:1522
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Spell.h:294

+ Here is the call graph for this function:

void Unit::CastSpell ( Unit victim,
uint32  spellId,
bool  triggered,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
892 {
893  CastSpell(victim, spellId, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
894 }
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: Unit.h:460

+ Here is the call graph for this function:

void Unit::CastSpell ( Unit victim,
uint32  spellId,
TriggerCastFlags  triggerFlags = TRIGGERED_NONE,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
897 {
898  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
899  if (!spellInfo)
900  {
901  TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s", spellId, GetGUID().ToString().c_str());
902  return;
903  }
904 
905  CastSpell(victim, spellInfo, triggerFlags, castItem, triggeredByAura, originalCaster);
906 }
Definition: SpellInfo.h:326
std::string ToString() const
Definition: Position.cpp:160
#define sSpellMgr
Definition: SpellMgr.h:756
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

void Unit::CastSpell ( Unit victim,
SpellInfo const spellInfo,
bool  triggered,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
909 {
910  CastSpell(victim, spellInfo, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
911 }
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: Unit.h:460

+ Here is the call graph for this function:

void Unit::CastSpell ( Unit victim,
SpellInfo const spellInfo,
TriggerCastFlags  triggerFlags = TRIGGERED_NONE,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
914 {
915  SpellCastTargets targets;
916  targets.SetUnitTarget(victim);
917  CastSpell(targets, spellInfo, NULL, triggerFlags, castItem, triggeredByAura, originalCaster);
918 }
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:230
Definition: Spell.h:170
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

void Unit::CastSpell ( float  x,
float  y,
float  z,
uint32  spellId,
bool  triggered,
Item castItem = NULL,
AuraEffect const triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
961 {
962  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
963  if (!spellInfo)
964  {
965  TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s", spellId, GetGUID().ToString().c_str());
966  return;
967  }
968  SpellCastTargets targets;
969  targets.SetDst(x, y, z, GetOrientation());
970 
971  CastSpell(targets, spellInfo, NULL, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
972 }
Definition: SpellInfo.h:326
arena_t NULL
Definition: jemalloc_internal.h:624
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
float GetOrientation() const
Definition: Position.h:107
G3D::int16 z
Definition: Vector3int16.h:46
std::string ToString() const
Definition: Position.cpp:160
#define sSpellMgr
Definition: SpellMgr.h:756
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Spell.h:170
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377
G3D::int16 x
Definition: Vector2int16.h:37
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: Unit.h:460

+ Here is the call graph for this function:

void Unit::CastSpell ( GameObject go,
uint32  spellId,
bool  triggered,
Item castItem = NULL,
AuraEffect triggeredByAura = NULL,
ObjectGuid  originalCaster = ObjectGuid::Empty 
)
975 {
976  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
977  if (!spellInfo)
978  {
979  TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s", spellId, GetGUID().ToString().c_str());
980  return;
981  }
982  SpellCastTargets targets;
983  targets.SetGOTarget(go);
984 
985  CastSpell(targets, spellInfo, NULL, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
986 }
Definition: SpellInfo.h:326
arena_t NULL
Definition: jemalloc_internal.h:624
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
void SetGOTarget(GameObject *target)
Definition: Spell.cpp:256
std::string ToString() const
Definition: Position.cpp:160
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: Spell.h:170
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: Unit.h:460

+ Here is the call graph for this function:

void Unit::CastStop ( uint32  except_spellid = 0)
863 {
865  if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id != except_spellid)
867 }
CurrentSpellTypes
Definition: Unit.h:1106
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:2849
uint32_t uint32
Definition: Define.h:150
#define CURRENT_MAX_SPELL
Definition: Unit.h:1115
uint32 Id
Definition: Spell.h:567
#define CURRENT_FIRST_NON_MELEE_SPELL
Definition: Unit.h:1114

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ChangeSeat ( int8  seatId,
bool  next = true 
)
15290 {
15291  if (!m_vehicle)
15292  return;
15293 
15294  // Don't change if current and new seat are identical
15295  if (seatId == GetTransSeat())
15296  return;
15297 
15298  SeatMap::const_iterator seat = (seatId < 0 ? m_vehicle->GetNextEmptySeat(GetTransSeat(), next) : m_vehicle->Seats.find(seatId));
15299  // The second part of the check will only return true if seatId >= 0. @Vehicle::GetNextEmptySeat makes sure of that.
15300  if (seat == m_vehicle->Seats.end() || !seat->second.IsEmpty())
15301  return;
15302 
15303  AuraEffect* rideVehicleEffect = NULL;
15305  for (AuraEffectList::const_iterator itr = vehicleAuras.begin(); itr != vehicleAuras.end(); ++itr)
15306  {
15307  if ((*itr)->GetCasterGUID() != GetGUID())
15308  continue;
15309 
15310  // Make sure there is only one ride vehicle aura on target cast by the unit changing seat
15311  ASSERT(!rideVehicleEffect);
15312  rideVehicleEffect = *itr;
15313  }
15314 
15315  // Unit riding a vehicle must always have control vehicle aura on target
15316  ASSERT(rideVehicleEffect);
15317 
15318  rideVehicleEffect->ChangeAmount(seat->first + 1);
15319 }
Definition: SpellAuraEffects.h:30
int next(int i, int n)
Definition: RecastContour.cpp:469
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
arena_t NULL
Definition: jemalloc_internal.h:624
Vehicle * m_vehicle
Definition: Unit.h:2304
void ChangeAmount(int32 newAmount, bool mark=true, bool onStackOrReapply=false)
Definition: SpellAuraEffects.cpp:828
Definition: SpellAuraDefines.h:296
SeatMap::const_iterator GetNextEmptySeat(int8 seatId, bool next) const
Gets the next empty seat based on current seat.
Definition: Vehicle.cpp:310
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
int8 GetTransSeat() const
Definition: Object.h:608
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
SeatMap Seats
The collection of all seats on the vehicle. Including vacant ones.
Definition: Vehicle.h:68
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::CleanupBeforeRemoveFromMap ( bool  finalCleanup)
11778 {
11779  // This needs to be before RemoveFromWorld to make GetCaster() return a valid pointer on aura removal
11781 
11782  if (IsInWorld())
11783  RemoveFromWorld();
11784 
11785  ASSERT(GetGUID());
11786 
11787  // A unit may be in removelist and not in world, but it is still in grid
11788  // and may have some references during delete
11789  RemoveAllAuras();
11791 
11792  if (finalCleanup)
11793  m_cleanupDone = true;
11794 
11795  m_Events.KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
11796  CombatStop();
11797  DeleteThreatList();
11799  GetMotionMaster()->Clear(false); // remove different non-standard movement generators.
11800 }
void RemoveFromWorld() override
Definition: Unit.cpp:11733
void KillAllEvents(bool force)
Definition: EventProcessor.cpp:61
void RemoveAllAuras()
Definition: Unit.cpp:3920
EventProcessor m_Events
Definition: Unit.h:1948
void Clear(bool reset=true)
Definition: MotionMaster.h:138
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool m_cleanupDone
Definition: Unit.h:2352
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void DeleteThreatList()
Definition: Unit.cpp:10700
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
#define ASSERT
Definition: Errors.h:55
void RemoveAllGameObjects()
Definition: Unit.cpp:4826
bool IsInWorld() const
Definition: Object.h:100
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
void setOnlineOfflineState(bool isOnline)
Definition: HostileRefManager.cpp:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::CleanupsBeforeDelete ( bool  finalCleanup = true)
overridevirtual

Reimplemented from WorldObject.

11803 {
11804  CleanupBeforeRemoveFromMap(finalCleanup);
11805 
11806  WorldObject::CleanupsBeforeDelete(finalCleanup);
11807 }
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Definition: Object.cpp:1506
void CleanupBeforeRemoveFromMap(bool finalCleanup)
Definition: Unit.cpp:11777

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ClearAllReactives ( )
12842 {
12843  for (uint8 i = 0; i < MAX_REACTIVE; ++i)
12844  m_reactiveTimer[i] = 0;
12845 
12850  if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
12851  ToPlayer()->ClearComboPoints();
12852 }
void ModifyAuraState(AuraStateType flag, bool apply)
Definition: Unit.cpp:7422
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
Definition: SharedDefines.h:1758
uint32 m_reactiveTimer[MAX_REACTIVE]
Definition: Unit.h:2299
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:167
TypeID GetTypeId() const
Definition: Object.h:113
#define MAX_REACTIVE
Definition: Unit.h:1279
Definition: SharedDefines.h:1764
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:169
uint8 getClass() const
Definition: Unit.h:1413
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ClearDiminishings ( )
inline
1346 { m_Diminishing.clear(); }
Diminishing m_Diminishing
Definition: Unit.h:2344

+ Here is the caller graph for this function:

void Unit::ClearInCombat ( )
9947 {
9948  m_CombatTimer = 0;
9950 
9951  // Reset rune flags after combat
9953  {
9954  for (uint8 i = 0; i < MAX_RUNES; ++i)
9955  {
9956  ToPlayer()->SetRuneTimer(i, 0xFFFFFFFF);
9957  ToPlayer()->SetLastRuneGraceTimer(i, 0);
9958  }
9959  }
9960 
9961  // Player's state will be cleared in Player::UpdateContestedPvP
9962  if (Creature* creature = ToCreature())
9963  {
9964  if (creature->GetCreatureTemplate() && creature->GetCreatureTemplate()->unit_flags & UNIT_FLAG_IMMUNE_TO_PC)
9965  SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); // set immunity state to the one from db on evade
9966 
9969  SetUInt32Value(OBJECT_DYNAMIC_FLAGS, creature->GetCreatureTemplate()->dynamicflags);
9970 
9971  if (creature->IsPet() || creature->IsGuardian())
9972  {
9973  if (Unit* owner = GetOwner())
9974  for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
9975  if (owner->GetSpeedRate(UnitMoveType(i)) > GetSpeedRate(UnitMoveType(i)))
9976  SetSpeed(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i)), true);
9977  }
9978  else if (!IsCharmed())
9979  return;
9980  }
9981  else
9982  ToPlayer()->OnCombatExit();
9983 
9985 }
UnitMoveType
Definition: Unit.h:597
Definition: Unit.h:564
#define MAX_MOVE_TYPE
Definition: Unit.h:610
Definition: SharedDefines.h:172
#define MAX_RUNES
Definition: Player.h:451
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: Creature.h:467
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
Definition: Unit.h:681
Player * ToPlayer()
Definition: Object.h:191
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:692
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
Definition: SharedDefines.h:4203
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
Unit * GetOwner() const
Definition: Unit.cpp:7542
Creature * ToCreature()
Definition: Object.h:194
uint32 m_CombatTimer
Definition: Unit.h:2341
uint8 getClass() const
Definition: Unit.h:1413
uint8_t uint8
Definition: Define.h:152
Definition: UpdateFields.h:30
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:10531
Definition: Unit.h:684
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
Definition: Unit.h:1305
bool IsCharmed() const
Definition: Unit.h:1742
float GetSpeedRate(UnitMoveType mtype) const
Definition: Unit.h:2087

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ClearUnitState ( uint32  f)
inline
1396 { m_state &= ~f; }
uint32 m_state
Definition: Unit.h:2340
void Unit::CombatStart ( Unit target,
bool  initialAggro = true 
)
9863 {
9864  if (initialAggro)
9865  {
9866  if (!target->IsStandState())
9868 
9869  if (!target->IsInCombat() && target->GetTypeId() != TYPEID_PLAYER
9870  && !target->ToCreature()->HasReactState(REACT_PASSIVE) && target->ToCreature()->IsAIEnabled)
9871  {
9872  if (target->IsPet())
9873  target->ToCreature()->AI()->AttackedBy(this); // PetAI has special handler before AttackStart()
9874  else
9875  target->ToCreature()->AI()->AttackStart(this);
9876  }
9877 
9878  SetInCombatWith(target);
9879  target->SetInCombatWith(this);
9880  }
9881  Unit* who = target->GetCharmerOrOwnerOrSelf();
9882  if (who->GetTypeId() == TYPEID_PLAYER)
9883  SetContestedPvP(who->ToPlayer());
9884 
9886  if (me && who->IsPvP()
9887  && (who->GetTypeId() != TYPEID_PLAYER
9888  || !me->duel || me->duel->opponent != who))
9889  {
9890  me->UpdatePvP(true);
9891  me->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
9892  }
9893 }
Definition: Unit.h:207
void SetContestedPvP(Player *attackedPlayer=NULL)
Definition: Unit.cpp:13138
Definition: Unit.h:1129
bool IsPvP() const
Definition: Unit.h:1481
bool IsInCombat() const
Definition: Unit.h:1584
virtual void AttackedBy(Unit *)
Definition: CreatureAI.h:136
bool HasReactState(ReactStates state) const
Definition: Creature.h:504
bool IsAIEnabled
Definition: Unit.h:2161
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
CreatureAI * AI() const
Definition: Creature.h:525
bool IsPet() const
Definition: Unit.h:1403
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:12772
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Unit.cpp:7632
Definition: Unit.h:1305
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29
bool IsStandState() const
Definition: Unit.cpp:12766
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9840
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::CombatStop ( bool  includingCast = false)
7372 {
7373  if (includingCast && IsNonMeleeSpellCast(false))
7374  InterruptNonMeleeSpells(false);
7375 
7376  AttackStop();
7378  if (GetTypeId() == TYPEID_PLAYER)
7379  ToPlayer()->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel
7380  ClearInCombat();
7381 }
bool AttackStop()
Definition: Unit.cpp:7337
void RemoveAllAttackers()
Definition: Unit.cpp:7409
void ClearInCombat()
Definition: Unit.cpp:9946
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:33
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916

+ Here is the call graph for this function:

void Unit::CombatStopWithPets ( bool  includingCast = false)
7384 {
7385  CombatStop(includingCast);
7386 
7387  for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
7388  (*itr)->CombatStop(includingCast);
7389 }
ControlList m_Controlled
Definition: Unit.h:1738
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371

+ Here is the call graph for this function:

uint32 Unit::CountPctFromCurHealth ( int32  pct) const
inline
1436 { return CalculatePct(GetHealth(), pct); }
T CalculatePct(T base, U pct)
Definition: Util.h:92
uint32 GetHealth() const
Definition: Unit.h:1426

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::CountPctFromMaxHealth ( int32  pct) const
inline
1435 { return CalculatePct(GetMaxHealth(), pct); }
uint32 GetMaxHealth() const
Definition: Unit.h:1427
T CalculatePct(T base, U pct)
Definition: Util.h:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::CountPctFromMaxPower ( Powers  power,
int32  pct 
) const
inline
1450 { return CalculatePct(GetMaxPower(power), pct); }
T CalculatePct(T base, U pct)
Definition: Util.h:92
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598

+ Here is the call graph for this function:

Pet * Unit::CreateTamedPetFrom ( Creature creatureTarget,
uint32  spell_id = 0 
)
13182 {
13183  if (GetTypeId() != TYPEID_PLAYER)
13184  return NULL;
13185 
13186  Pet* pet = new Pet(ToPlayer(), HUNTER_PET);
13187 
13188  if (!pet->CreateBaseAtCreature(creatureTarget))
13189  {
13190  delete pet;
13191  return NULL;
13192  }
13193 
13194  uint8 level = creatureTarget->getLevel() + 5 < getLevel() ? (getLevel() - 5) : creatureTarget->getLevel();
13195 
13196  InitTamedPet(pet, level, spell_id);
13197 
13198  return pet;
13199 }
arena_t NULL
Definition: jemalloc_internal.h:624
bool CreateBaseAtCreature(Creature *creature)
Definition: Pet.cpp:730
Definition: PetDefines.h:25
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:33
uint8_t uint8
Definition: Define.h:152
bool InitTamedPet(Pet *pet, uint8 level, uint32 spell_id)
Definition: Unit.cpp:13221
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Pet * Unit::CreateTamedPetFrom ( uint32  creatureEntry,
uint32  spell_id = 0 
)
13202 {
13203  if (GetTypeId() != TYPEID_PLAYER)
13204  return NULL;
13205 
13206  CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry);
13207  if (!creatureInfo)
13208  return NULL;
13209 
13210  Pet* pet = new Pet(ToPlayer(), HUNTER_PET);
13211 
13212  if (!pet->CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, getLevel(), spell_id))
13213  {
13214  delete pet;
13215  return NULL;
13216  }
13217 
13218  return pet;
13219 }
arena_t NULL
Definition: jemalloc_internal.h:624
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PetDefines.h:25
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
TypeID GetTypeId() const
Definition: Object.h:113
bool CreateBaseAtCreatureInfo(CreatureTemplate const *cinfo, Unit *owner)
Definition: Pet.cpp:763
Definition: ObjectGuid.h:33
bool InitTamedPet(Pet *pet, uint8 level, uint32 spell_id)
Definition: Unit.cpp:13221
Definition: Creature.h:79
Definition: Pet.h:46

+ Here is the call graph for this function:

bool Unit::CreateVehicleKit ( uint32  id,
uint32  creatureEntry,
bool  loading = false 
)
14303 {
14304  VehicleEntry const* vehInfo = sVehicleStore.LookupEntry(id);
14305  if (!vehInfo)
14306  return false;
14307 
14308  m_vehicleKit = new Vehicle(this, vehInfo, creatureEntry);
14311 
14312  if (!loading)
14313  SendSetVehicleRecId(id);
14314 
14315  return true;
14316 }
void SendSetVehicleRecId(uint32 vehicleId)
Definition: Unit.cpp:16106
Definition: Unit.h:863
Vehicle * m_vehicleKit
Definition: Unit.h:2305
Definition: DBCStructure.h:1271
Definition: UpdateData.h:44
DBCStorage< VehicleEntry > sVehicleStore(Vehiclefmt)
uint32 m_unitTypeMask
Definition: Unit.h:2307
uint32 m_updateFlag
Definition: Object.h:230

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::DealDamage ( Unit victim,
uint32  damage,
CleanDamage const cleanDamage = NULL,
DamageEffectType  damagetype = DIRECT_DAMAGE,
SpellSchoolMask  damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL,
SpellInfo const spellProto = NULL,
bool  durabilityLoss = true 
)
Todo:
check packets if damage is done by victim, or by attacker of victim
614 {
615  if (victim->IsAIEnabled)
616  victim->GetAI()->DamageTaken(this, damage);
617 
618  if (IsAIEnabled)
619  GetAI()->DamageDealt(victim, damage, damagetype);
620 
621  // Hook for OnDamage Event
622  sScriptMgr->OnDamage(this, victim, damage);
623 
624  if (victim->GetTypeId() == TYPEID_PLAYER && this != victim)
625  {
626  // Signal to pets that their owner was attacked
627  Pet* pet = victim->ToPlayer()->GetPet();
628 
629  if (pet && pet->IsAlive())
630  pet->AI()->OwnerAttackedBy(this);
631 
632  if (victim->ToPlayer()->GetCommandStatus(CHEAT_GOD))
633  return 0;
634  }
635 
636  // Signal the pet it was attacked so the AI can respond if needed
637  if (victim->GetTypeId() == TYPEID_UNIT && this != victim && victim->IsPet() && victim->IsAlive())
638  victim->ToPet()->AI()->AttackedBy(this);
639 
640  if (damagetype != NODAMAGE)
641  {
642  // interrupting auras with AURA_INTERRUPT_FLAG_DAMAGE before checking !damage (absorbed damage breaks that type of auras)
643  if (spellProto)
644  {
645  if (!spellProto->HasAttribute(SPELL_ATTR4_DAMAGE_DOESNT_BREAK_AURAS))
647  }
648  else
650 
651  // We're going to call functions which can modify content of the list during iteration over it's elements
652  // Let's copy the list so we can prevent iterator invalidation
654  // copy damage to casters of this aura
655  for (AuraEffectList::iterator i = vCopyDamageCopy.begin(); i != vCopyDamageCopy.end(); ++i)
656  {
657  // Check if aura was removed during iteration - we don't need to work on such auras
658  if (!((*i)->GetBase()->IsAppliedOnTarget(victim->GetGUID())))
659  continue;
660  // check damage school mask
661  if (((*i)->GetMiscValue() & damageSchoolMask) == 0)
662  continue;
663 
664  Unit* shareDamageTarget = (*i)->GetCaster();
665  if (!shareDamageTarget)
666  continue;
667  SpellInfo const* spell = (*i)->GetSpellInfo();
668 
669  uint32 share = CalculatePct(damage, (*i)->GetAmount());
670 
672  DealDamageMods(shareDamageTarget, share, NULL);
673  DealDamage(shareDamageTarget, share, NULL, NODAMAGE, spell->GetSchoolMask(), spell, false);
674  }
675  }
676 
677  // Rage from Damage made (only from direct weapon damage)
678  if (cleanDamage && damagetype == DIRECT_DAMAGE && this != victim && getPowerType() == POWER_RAGE)
679  {
680  uint32 rage = uint32(GetAttackTime(cleanDamage->attackType) / 1000.f * 8.125f);
681  switch (cleanDamage->attackType)
682  {
683  case OFF_ATTACK:
684  rage /= 2;
685  case BASE_ATTACK:
686  RewardRage(rage, true);
687  break;
688  default:
689  break;
690  }
691  }
692 
693  if (!damage)
694  {
695  // Rage from absorbed damage
696  if (cleanDamage && cleanDamage->absorbed_damage && victim->getPowerType() == POWER_RAGE)
697  victim->RewardRage(cleanDamage->absorbed_damage, false);
698 
699  return 0;
700  }
701 
702  TC_LOG_DEBUG("entities.unit", "DealDamageStart");
703 
704  uint32 health = victim->GetHealth();
705  TC_LOG_DEBUG("entities.unit", "%s dealt %u damage to %s", GetGUID().ToString().c_str(), damage, victim->GetGUID().ToString().c_str());
706 
707  // duel ends when player has 1 or less hp
708  bool duel_hasEnded = false;
709  bool duel_wasMounted = false;
710  if (victim->GetTypeId() == TYPEID_PLAYER && victim->ToPlayer()->duel && damage >= (health-1))
711  {
712  // prevent kill only if killed in duel and killed by opponent or opponent controlled creature
713  if (victim->ToPlayer()->duel->opponent == this || victim->ToPlayer()->duel->opponent->GetGUID() == GetOwnerGUID())
714  damage = health - 1;
715 
716  duel_hasEnded = true;
717  }
718  else if (victim->IsVehicle() && damage >= (health-1) && victim->GetCharmer() && victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER)
719  {
720  Player* victimRider = victim->GetCharmer()->ToPlayer();
721 
722  if (victimRider && victimRider->duel && victimRider->duel->isMounted)
723  {
724  // prevent kill only if killed in duel and killed by opponent or opponent controlled creature
725  if (victimRider->duel->opponent == this || victimRider->duel->opponent->GetGUID() == GetCharmerGUID())
726  damage = health - 1;
727 
728  duel_wasMounted = true;
729  duel_hasEnded = true;
730  }
731  }
732 
733  if (GetTypeId() == TYPEID_PLAYER && this != victim)
734  {
735  Player* killer = ToPlayer();
736 
737  // in bg, count dmg if victim is also a player
738  if (victim->GetTypeId() == TYPEID_PLAYER)
739  if (Battleground* bg = killer->GetBattleground())
740  bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage);
741 
742  killer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, damage, 0, 0, victim);
743  killer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT, damage);
744  }
745 
746  if (victim->GetTypeId() == TYPEID_PLAYER)
747  victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, damage);
748  else if (!victim->IsControlledByPlayer() || victim->IsVehicle())
749  {
750  if (!victim->ToCreature()->hasLootRecipient())
751  victim->ToCreature()->SetLootRecipient(this);
752 
753  if (IsControlledByPlayer())
754  victim->ToCreature()->LowerPlayerDamageReq(health < damage ? health : damage);
755  }
756 
757  if (health <= damage)
758  {
759  TC_LOG_DEBUG("entities.unit", "DealDamage: victim just died");
760 
761  if (victim->GetTypeId() == TYPEID_PLAYER && victim != this)
762  victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, health);
763 
764  Kill(victim, durabilityLoss);
765  }
766  else
767  {
768  TC_LOG_DEBUG("entities.unit", "DealDamageAlive");
769 
770  if (victim->GetTypeId() == TYPEID_PLAYER)
771  victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, damage);
772 
773  victim->ModifyHealth(-(int32)damage);
774 
775  if (damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE)
776  {
777  victim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DIRECT_DAMAGE, spellProto ? spellProto->Id : 0);
778  if (victim->GetTypeId() == TYPEID_UNIT && !victim->IsPet())
779  victim->SetLastDamagedTime(time(NULL));
780  }
781 
782  if (victim->GetTypeId() != TYPEID_PLAYER)
783  victim->AddThreat(this, float(damage), damageSchoolMask, spellProto);
784  else // victim is a player
785  {
786  // random durability for items (HIT TAKEN)
788  {
789  EquipmentSlots slot = EquipmentSlots(urand(0, EQUIPMENT_SLOT_END-1));
790  victim->ToPlayer()->DurabilityPointLossForEquipSlot(slot);
791  }
792  }
793 
794  // Rage from damage received
795  if (this != victim && victim->getPowerType() == POWER_RAGE)
796  {
797  uint32 rage_damage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0);
798  victim->RewardRage(rage_damage, false);
799  }
800 
801  if (GetTypeId() == TYPEID_PLAYER)
802  {
803  // random durability for items (HIT DONE)
805  {
806  EquipmentSlots slot = EquipmentSlots(urand(0, EQUIPMENT_SLOT_END-1));
807  ToPlayer()->DurabilityPointLossForEquipSlot(slot);
808  }
809  }
810 
811  if (damagetype != NODAMAGE && damage)
812  {
813  if (victim != this && victim->GetTypeId() == TYPEID_PLAYER && // does not support creature push_back
814  (!spellProto || !spellProto->HasAttribute(SPELL_ATTR7_NO_PUSHBACK_ON_DAMAGE)))
815  {
816  if (damagetype != DOT)
817  if (Spell* spell = victim->m_currentSpells[CURRENT_GENERIC_SPELL])
818  if (spell->getState() == SPELL_STATE_PREPARING)
819  {
820  uint32 interruptFlags = spell->m_spellInfo->InterruptFlags;
821  if (interruptFlags & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG)
822  victim->InterruptNonMeleeSpells(false);
823  else if (interruptFlags & SPELL_INTERRUPT_FLAG_PUSH_BACK)
824  spell->Delayed();
825  }
826 
827  if (Spell* spell = victim->m_currentSpells[CURRENT_CHANNELED_SPELL])
828  if (spell->getState() == SPELL_STATE_CASTING)
829  {
830  uint32 channelInterruptFlags = spell->m_spellInfo->ChannelInterruptFlags;
831  if (((channelInterruptFlags & CHANNEL_FLAG_DELAY) != 0) && (damagetype != DOT))
832  spell->DelayedChannel();
833  }
834  }
835  }
836 
837  // last damage from duel opponent
838  if (duel_hasEnded)
839  {
840  Player* he = duel_wasMounted ? victim->GetCharmer()->ToPlayer() : victim->ToPlayer();
841 
842  ASSERT(he && he->duel);
843 
844  if (duel_wasMounted) // In this case victim==mount
845  victim->SetHealth(1);
846  else
847  he->SetHealth(1);
848 
849  he->duel->opponent->CombatStopWithPets(true);
850  he->CombatStopWithPets(true);
851 
852  he->CastSpell(he, 7267, true); // beg
853  he->DuelComplete(DUEL_WON);
854  }
855  }
856 
857  TC_LOG_DEBUG("entities.unit", "DealDamageEnd returned %d damage", damage);
858 
859  return damage;
860 }
Unit * GetCharmer() const
Definition: Unit.cpp:7551
void Kill(Unit *victim, bool durabilityLoss=true)
Definition: Unit.cpp:13513
Definition: Unit.h:1109
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: Unit.cpp:10691
Definition: Unit.h:49
bool IsVehicle() const
Definition: Unit.h:1406
Definition: DBCEnums.h:208
bool IsControlledByPlayer() const
Definition: Unit.h:1712
Definition: SpellInfo.h:326
Definition: World.h:441
Pet * ToPet()
Definition: Unit.h:2200
Definition: Unit.h:1110
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
virtual void AttackedBy(Unit *)
Definition: CreatureAI.h:136
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:249
int32 ModifyHealth(int32 val)
Definition: Unit.cpp:10216
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
Definition: Unit.h:664
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: SharedDefines.h:514
#define sWorld
Definition: World.h:887
bool IsAIEnabled
Definition: Unit.h:2161
virtual void DamageTaken(Unit *, uint32 &)
Definition: UnitAI.h:228
Player * ToPlayer()
Definition: Object.h:191
void SetLootRecipient(Unit *unit)
Definition: Creature.cpp:993
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.cpp:10326
Definition: Unit.h:55
Powers getPowerType() const
Definition: Unit.h:1444
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:4727
Definition: SharedDefines.h:614
Definition: Unit.h:666
Definition: Unit.h:618
bool roll_chance_f(float chance)
Definition: Random.h:47
bool IsAlive() const
Definition: Unit.h:1692
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
std::string ToString() const
Definition: Position.cpp:160
void SetLastDamagedTime(time_t val)
Definition: Unit.h:2217
CreatureAI * AI() const
Definition: Creature.h:525
Definition: BattlegroundScore.h:31
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: Spell.h:278
Definition: Unit.h:38
void RewardRage(uint32 baseRage, bool attacker)
Definition: Unit.cpp:15566
T CalculatePct(T base, U pct)
Definition: Util.h:92
UnitAI * GetAI()
Definition: Unit.h:1331
bool IsPet() const
Definition: Unit.h:1403
Definition: Spell.h:277
void DealDamageMods(Unit *victim, uint32 &damage, uint32 *absorb)
Definition: Unit.cpp:603
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
uint32 ChannelInterruptFlags
Definition: SpellInfo.h:369
Creature * ToCreature()
Definition: Object.h:194
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
virtual void DamageDealt(Unit *, uint32 &, DamageEffectType)
Definition: UnitAI.h:223
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
bool hasLootRecipient() const
Definition: Creature.h:586
#define ASSERT
Definition: Errors.h:55
Definition: Unit.h:662
Definition: Battleground.h:235
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:663
void SetHealth(uint32 val)
Definition: Unit.cpp:11537
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
uint32 GetHealth() const
Definition: Unit.h:1426
Definition: SpellAuraDefines.h:360
Definition: Unit.h:1305
uint32 InterruptFlags
Definition: SpellInfo.h:367
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 DealDamage(Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=NULL, bool durabilityLoss=true)
Definition: Unit.cpp:613
virtual void OwnerAttackedBy(Unit *)
Definition: CreatureAI.h:156
void LowerPlayerDamageReq(uint32 unDamage)
Definition: Creature.cpp:1239
Definition: Pet.h:46
Definition: Unit.h:617
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::DealDamageMods ( Unit victim,
uint32 damage,
uint32 absorb 
)
604 {
605  if (!victim || !victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode()))
606  {
607  if (absorb)
608  *absorb += damage;
609  damage = 0;
610  }
611 }
Definition: ObjectGuid.h:32
bool IsInEvadeMode() const
Definition: Creature.h:520
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
Definition: Unit.h:558
Creature * ToCreature()
Definition: Object.h:194
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::DealHeal ( Unit victim,
uint32  addhealth 
)
7886 {
7887  int32 gain = 0;
7888 
7889  if (victim->IsAIEnabled)
7890  victim->GetAI()->HealReceived(this, addhealth);
7891 
7892  if (IsAIEnabled)
7893  GetAI()->HealDone(victim, addhealth);
7894 
7895  if (addhealth)
7896  gain = victim->ModifyHealth(int32(addhealth));
7897 
7898  // Hook for OnHeal Event
7899  sScriptMgr->OnHeal(this, victim, (uint32&)gain);
7900 
7901  Unit* unit = this;
7902 
7903  if (GetTypeId() == TYPEID_UNIT && IsTotem())
7904  unit = GetOwner();
7905 
7906  if (Player* player = unit->ToPlayer())
7907  {
7908  if (Battleground* bg = player->GetBattleground())
7909  bg->UpdatePlayerScore(player, SCORE_HEALING_DONE, gain);
7910 
7911  // use the actual gain, as the overheal shall not be counted, skip gain 0 (it ignored anyway in to criteria)
7912  if (gain)
7913  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, gain, 0, 0, victim);
7914 
7915  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CAST, addhealth);
7916  }
7917 
7918  if (Player* player = victim->ToPlayer())
7919  {
7920  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED, gain);
7921  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED, addhealth);
7922  }
7923 
7924  return gain;
7925 }
virtual void HealDone(Unit *, uint32 &)
Definition: UnitAI.h:234
Definition: ObjectGuid.h:32
int32 ModifyHealth(int32 val)
Definition: Unit.cpp:10216
bool IsAIEnabled
Definition: Unit.h:2161
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
UnitAI * GetAI()
Definition: Unit.h:1331
Definition: DBCEnums.h:247
bool IsTotem() const
Definition: Unit.h:1405
Unit * GetOwner() const
Definition: Unit.cpp:7542
int32_t int32
Definition: g3dmath.h:167
Definition: Battleground.h:235
#define sScriptMgr
Definition: ScriptMgr.h:837
virtual void HealReceived(Unit *, uint32 &)
Definition: UnitAI.h:231
Definition: Unit.h:1305
Definition: BattlegroundScore.h:32

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::DealMeleeDamage ( CalcDamageInfo damageInfo,
bool  durabilityLoss 
)
1312 {
1313  Unit* victim = damageInfo->target;
1314 
1315  if (!victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode()))
1316  return;
1317 
1318  // Hmmmm dont like this emotes client must by self do all animations
1319  if (damageInfo->HitInfo & HITINFO_CRITICALHIT)
1321  if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS)
1323 
1324  if (damageInfo->TargetState == VICTIMSTATE_PARRY)
1325  {
1326  // Get attack timers
1327  float offtime = float(victim->getAttackTimer(OFF_ATTACK));
1328  float basetime = float(victim->getAttackTimer(BASE_ATTACK));
1329  // Reduce attack time
1330  if (victim->haveOffhandWeapon() && offtime < basetime)
1331  {
1332  float percent20 = victim->GetAttackTime(OFF_ATTACK) * 0.20f;
1333  float percent60 = 3.0f * percent20;
1334  if (offtime > percent20 && offtime <= percent60)
1335  victim->setAttackTimer(OFF_ATTACK, uint32(percent20));
1336  else if (offtime > percent60)
1337  {
1338  offtime -= 2.0f * percent20;
1339  victim->setAttackTimer(OFF_ATTACK, uint32(offtime));
1340  }
1341  }
1342  else
1343  {
1344  float percent20 = victim->GetAttackTime(BASE_ATTACK) * 0.20f;
1345  float percent60 = 3.0f * percent20;
1346  if (basetime > percent20 && basetime <= percent60)
1347  victim->setAttackTimer(BASE_ATTACK, uint32(percent20));
1348  else if (basetime > percent60)
1349  {
1350  basetime -= 2.0f * percent20;
1351  victim->setAttackTimer(BASE_ATTACK, uint32(basetime));
1352  }
1353  }
1354  }
1355 
1356  // Call default DealDamage
1357  CleanDamage cleanDamage(damageInfo->cleanDamage, damageInfo->absorb, damageInfo->attackType, damageInfo->hitOutCome);
1358  DealDamage(victim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damageSchoolMask), NULL, durabilityLoss);
1359 
1360  // If this is a creature and it attacks from behind it has a probability to daze it's victim
1361  if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) &&
1362  GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(float(M_PI), this)
1363  && (victim->GetTypeId() == TYPEID_PLAYER || !victim->ToCreature()->isWorldBoss())&& !victim->IsVehicle())
1364  {
1365  // -probability is between 0% and 40%
1366  // 20% base chance
1367  float Probability = 20.0f;
1368 
1369  // there is a newbie protection, at level 10 just 7% base chance; assuming linear function
1370  if (victim->getLevel() < 30)
1371  Probability = 0.65f * victim->getLevel() + 0.5f;
1372 
1373  uint32 VictimDefense = victim->GetMaxSkillValueForLevel(this);
1374  uint32 AttackerMeleeSkill = GetMaxSkillValueForLevel();
1375 
1376  Probability *= AttackerMeleeSkill/(float)VictimDefense*0.16f;
1377 
1378  if (Probability < 0)
1379  Probability = 0;
1380 
1381  if (Probability > 40.0f)
1382  Probability = 40.0f;
1383 
1384  if (roll_chance_f(Probability))
1385  CastSpell(victim, 1604, true);
1386  }
1387 
1388  if (GetTypeId() == TYPEID_PLAYER)
1389  ToPlayer()->CastItemCombatSpell(victim, damageInfo->attackType, damageInfo->procVictim, damageInfo->procEx);
1390 
1391  // Do effect if any damage done to target
1392  if (damageInfo->damage)
1393  {
1394  // We're going to call functions which can modify content of the list during iteration over it's elements
1395  // Let's copy the list so we can prevent iterator invalidation
1396  AuraEffectList vDamageShieldsCopy(victim->GetAuraEffectsByType(SPELL_AURA_DAMAGE_SHIELD));
1397  for (AuraEffectList::const_iterator dmgShieldItr = vDamageShieldsCopy.begin(); dmgShieldItr != vDamageShieldsCopy.end(); ++dmgShieldItr)
1398  {
1399  SpellInfo const* i_spellProto = (*dmgShieldItr)->GetSpellInfo();
1400  // Damage shield can be resisted...
1401  if (SpellMissInfo missInfo = victim->SpellHitResult(this, i_spellProto, false))
1402  {
1403  victim->SendSpellMiss(this, i_spellProto->Id, missInfo);
1404  continue;
1405  }
1406 
1407  // ...or immuned
1408  if (IsImmunedToDamage(i_spellProto))
1409  {
1410  victim->SendSpellDamageImmune(this, i_spellProto->Id, false);
1411  continue;
1412  }
1413 
1414  uint32 damage = (*dmgShieldItr)->GetAmount();
1415 
1416  if (Unit* caster = (*dmgShieldItr)->GetCaster())
1417  {
1418  damage = caster->SpellDamageBonusDone(this, i_spellProto, damage, SPELL_DIRECT_DAMAGE, (*dmgShieldItr)->GetSpellEffectInfo());
1419  damage = this->SpellDamageBonusTaken(caster, i_spellProto, damage, SPELL_DIRECT_DAMAGE, (*dmgShieldItr)->GetSpellEffectInfo());
1420  }
1421 
1422  uint32 absorb = 0, resist = 0;
1423  victim->CalcAbsorbResist(this, SpellSchoolMask(i_spellProto->SchoolMask), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist, i_spellProto);
1424  // No Unit::CalcAbsorbResist here - opcode doesn't send that data - this damage is probably not affected by that
1425  victim->DealDamageMods(this, damage, NULL);
1426 
1428  damageShield.Attacker = victim->GetGUID();
1429  damageShield.Defender = GetGUID();
1430  damageShield.SpellID = i_spellProto->Id;
1431  damageShield.TotalDamage = damage;
1432  damageShield.OverKill = std::max(int32(damage) - int32(GetHealth()), 0);
1433  damageShield.SchoolMask = i_spellProto->SchoolMask;
1434  damageShield.LogAbsorbed = absorb;
1435 
1436  victim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, i_spellProto->GetSchoolMask(), i_spellProto, true);
1437 
1438  damageShield.LogData.Initialize(this);
1439  victim->SendCombatLogMessage(&damageShield);
1440  }
1441  }
1442 }
Definition: CombatLogPackets.h:304
int32 TotalDamage
Definition: CombatLogPackets.h:314
void setAttackTimer(WeaponAttackType type, uint32 time)
Definition: Unit.h:1354
uint32 Id
Definition: SpellInfo.h:329
void Initialize(Unit const *unit)
Definition: SpellPackets.cpp:91
bool IsVehicle() const
Definition: Unit.h:1406
Definition: Unit.h:885
SpellSchoolMask
Definition: SharedDefines.h:285
bool IsControlledByPlayer() const
Definition: Unit.h:1712
#define M_PI
Definition: Common.h:163
Definition: SpellInfo.h:326
int32 OverKill
Definition: CombatLogPackets.h:315
uint32 blocked_amount
Definition: Unit.h:1029
uint16 GetMaxSkillValueForLevel(Unit const *target=NULL) const
Definition: Unit.h:1511
uint32 HitInfo
Definition: Unit.h:1030
uint32 procVictim
Definition: Unit.h:1035
uint32 SchoolMask
Definition: SpellInfo.h:401
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsInEvadeMode() const
Definition: Creature.h:520
int32 SchoolMask
Definition: CombatLogPackets.h:316
void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo)
Definition: Unit.cpp:4897
Definition: SpellAuraDefines.h:75
MeleeHitOutcome hitOutCome
Definition: Unit.h:1038
ObjectGuid Defender
Definition: CombatLogPackets.h:312
Definition: Unit.h:358
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Player * ToPlayer()
Definition: Object.h:191
uint32 procEx
Definition: Unit.h:1036
uint8 getLevel() const
Definition: Unit.h:1408
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.cpp:10326
WeaponAttackType attackType
Definition: Unit.h:1033
int32 LogAbsorbed
Definition: CombatLogPackets.h:317
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const
Definition: Unit.cpp:9214
Definition: Unit.h:885
TypeID GetTypeId() const
Definition: Object.h:113
SpellMissInfo SpellHitResult(Unit *victim, SpellInfo const *spellInfo, bool canReflect=false)
Definition: Unit.cpp:2477
Spells::SpellCastLogData LogData
Definition: CombatLogPackets.h:38
Definition: Unit.h:340
Definition: Unit.h:618
bool roll_chance_f(float chance)
Definition: Random.h:47
bool IsAlive() const
Definition: Unit.h:1692
uint32 SpellDamageBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8493
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: Unit.h:338
uint32 absorb
Definition: Unit.h:1027
uint32 TargetState
Definition: Unit.h:1031
Definition: SharedDefines.h:2442
SpellMissInfo
Definition: SharedDefines.h:2019
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129
bool haveOffhandWeapon() const
Definition: Unit.cpp:418
uint32 damageSchoolMask
Definition: Unit.h:1025
void CalcAbsorbResist(Unit *victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32 *absorb, uint32 *resist, SpellInfo const *spellInfo=NULL)
Definition: Unit.cpp:1608
Definition: Unit.h:558
void DealDamageMods(Unit *victim, uint32 &damage, uint32 *absorb)
Definition: Unit.cpp:603
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:2448
Unit * target
Definition: Unit.h:1024
Creature * ToCreature()
Definition: Object.h:194
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
uint32 cleanDamage
Definition: Unit.h:1037
ObjectGuid Attacker
Definition: CombatLogPackets.h:311
void SendSpellDamageImmune(Unit *target, uint32 spellId, bool isPeriodic)
Definition: Unit.cpp:4915
int32_t int32
Definition: g3dmath.h:167
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
int32 SpellID
Definition: CombatLogPackets.h:313
void HandleEmoteCommand(uint32 anim_id)
Definition: Unit.cpp:1444
Definition: Unit.h:885
void SendCombatLogMessage(WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
Definition: Unit.cpp:16597
uint32 damage
Definition: Unit.h:1026
Definition: Unit.h:662
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:663
Definition: Unit.h:907
uint32 GetHealth() const
Definition: Unit.h:1426
bool isWorldBoss() const
Definition: Creature.cpp:1833
Definition: Unit.h:1305
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: Unit.h:885
uint32 DealDamage(Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=NULL, bool durabilityLoss=true)
Definition: Unit.cpp:613
Definition: Unit.h:617
uint32 getAttackTimer(WeaponAttackType type) const
Definition: Unit.h:1356

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::DealSpellDamage ( SpellNonMeleeDamage const damageInfo,
bool  durabilityLoss 
)
1095 {
1096  if (!damageInfo)
1097  return;
1098 
1099  Unit* victim = damageInfo->target;
1100 
1101  if (!victim)
1102  return;
1103 
1104  if (!victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode()))
1105  return;
1106 
1107  SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(damageInfo->SpellID);
1108  if (!spellProto)
1109  {
1110  TC_LOG_DEBUG("entities.unit", "Unit::DealSpellDamage has wrong damageInfo->SpellID: %u", damageInfo->SpellID);
1111  return;
1112  }
1113 
1114  // Call default DealDamage
1115  CleanDamage cleanDamage(damageInfo->cleanDamage, damageInfo->absorb, BASE_ATTACK, MELEE_HIT_NORMAL);
1116  DealDamage(victim, damageInfo->damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SpellSchoolMask(damageInfo->schoolMask), spellProto, durabilityLoss);
1117 }
SpellSchoolMask
Definition: SharedDefines.h:285
Definition: SpellInfo.h:326
Definition: ObjectGuid.h:32
bool IsInEvadeMode() const
Definition: Creature.h:520
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Unit.h:885
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: Unit.h:558
Creature * ToCreature()
Definition: Object.h:194
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
Definition: Unit.h:663
Definition: Unit.h:907
Definition: Unit.h:1305
uint32 DealDamage(Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=NULL, bool durabilityLoss=true)
Definition: Unit.cpp:613
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::DelayOwnedAuras ( uint32  spellId,
ObjectGuid  caster,
int32  delaytime 
)
Todo:
: once we support variadic templates use them here
4040 {
4041  AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId);
4042  for (; range.first != range.second; ++range.first)
4043  {
4044  Aura* aura = range.first->second;
4045  if (!caster || aura->GetCasterGUID() == caster)
4046  {
4047  if (aura->GetDuration() < delaytime)
4048  aura->SetDuration(0);
4049  else
4050  aura->SetDuration(aura->GetDuration() - delaytime);
4051 
4052  // update for out of range group members (on 1 slot use)
4054  TC_LOG_DEBUG("spells", "Aura %u partially interrupted on %s, new duration: %u ms", aura->GetId(), GetGUID().ToString().c_str(), aura->GetDuration());
4055  }
4056  }
4057 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::pair< AuraMap::iterator, AuraMap::iterator > AuraMapBoundsNonConst
Definition: Unit.h:1313
void SetNeedClientUpdateForTargets() const
Definition: SpellAuras.cpp:1231
int32 GetDuration() const
Definition: SpellAuras.h:163
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:806
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 GetId() const
Definition: SpellAuras.h:131

+ Here is the call graph for this function:

void Unit::DeleteCharmInfo ( )
11845 {
11846  if (!m_charmInfo)
11847  return;
11848 
11850  delete m_charmInfo;
11851  m_charmInfo = NULL;
11852 }
CharmInfo * m_charmInfo
Definition: Unit.h:2292
arena_t NULL
Definition: jemalloc_internal.h:624
void RestoreState()
Definition: Unit.cpp:11871

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::DeleteThreatList ( )
10701 {
10705 }
void SendClearThreatListOpcode()
Definition: Unit.cpp:15550
bool isThreatListEmpty() const
Definition: ThreatManager.h:220
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition: Unit.cpp:10652
void clearReferences()
Definition: ThreatManager.cpp:396
ThreatManager m_ThreatManager
Definition: Unit.h:2302

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::DeMorph ( )
3020 {
3022 }
virtual void SetDisplayId(uint32 modelId)
Definition: Unit.cpp:12799
uint32 GetNativeDisplayId() const
Definition: Unit.h:2014

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::DestroyForPlayer ( Player target) const
overrideprotectedvirtual

Reimplemented from Object.

16302 {
16303  if (Battleground* bg = target->GetBattleground())
16304  {
16305  if (bg->isArena())
16306  {
16308  destroyArenaUnit.Guid = GetGUID();
16309  target->GetSession()->SendPacket(destroyArenaUnit.Write());
16310  }
16311  }
16312 
16314 }
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:283
virtual void DestroyForPlayer(Player *target) const
Definition: Object.cpp:283
ObjectGuid Guid
Definition: BattlegroundPackets.h:390
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: BattlegroundPackets.h:383
Definition: Battleground.h:235

+ Here is the call graph for this function:

void Unit::DisableSpline ( )
protected
476 {
479 }
void RemoveMovementFlag(uint32 flag)
Definition: Object.h:329
MovementInfo m_movementInfo
Definition: Object.h:612
Movement::MoveSpline * movespline
Definition: Unit.h:2213
void _Interrupt()
Definition: MoveSpline.h:102
Definition: Unit.h:776

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Dismount ( )
9735 {
9736  if (!IsMounted())
9737  return;
9738 
9741 
9742  if (Player* thisPlayer = ToPlayer())
9743  thisPlayer->SendMovementSetCollisionHeight(thisPlayer->GetCollisionHeight(false));
9744 
9746  data.Guid = GetGUID();
9747  SendMessageToSet(data.Write(), true);
9748 
9749  // dismount as a vehicle
9750  if (GetTypeId() == TYPEID_PLAYER && GetVehicleKit())
9751  {
9752  // Remove vehicle from player
9753  RemoveVehicleKit();
9754  }
9755 
9757 
9758  // only resummon old pet if the player is already added to a map
9759  // this prevents adding a pet to a not created map which would otherwise cause a crash
9760  // (it could probably happen when logging in after a previous crash)
9761  if (Player* player = ToPlayer())
9762  {
9763  if (Pet* pPet = player->GetPet())
9764  {
9765  if (pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STATE_STUNNED))
9766  pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
9767  }
9768  else
9769  player->ResummonPetTemporaryUnSummonedIfAny();
9770  }
9771 }
void RemoveVehicleKit(bool onRemoveFromWorld=false)
Definition: Unit.cpp:14318
WorldPacket const * Write() override
Definition: MiscPackets.cpp:451
Definition: MiscPackets.h:639
ObjectGuid Guid
Definition: MiscPackets.h:646
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:60
Definition: Unit.h:553
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Unit.h:700
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
Definition: Unit.h:691
bool IsMounted() const
Definition: Unit.h:1496
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: UpdateFields.h:119
Definition: Pet.h:46
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::EnergizeBySpell ( Unit victim,
uint32  SpellID,
int32  Damage,
Powers  powertype 
)
8203 {
8204  victim->ModifyPower(powerType, damage);
8205 
8206  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
8207  victim->getHostileRefManager().threatAssist(this, float(damage) * 0.5f, spellInfo);
8208 
8209  SendEnergizeSpellLog(victim, spellId, damage, powerType);
8210 }
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:10285
void threatAssist(Unit *victim, float baseThreat, SpellInfo const *threatSpell=NULL)
Definition: HostileRefManager.cpp:35
Definition: SpellInfo.h:326
void SendEnergizeSpellLog(Unit *victim, uint32 spellID, int32 damage, Powers powertype)
Definition: Unit.cpp:8190
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
#define sSpellMgr
Definition: SpellMgr.h:756

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Unit* Unit::EnsureVictim ( ) const
inline
1382  {
1384  return m_attacking;
1385  }
Unit * m_attacking
Definition: Unit.h:2256
#define ASSERT
Definition: Errors.h:55

+ Here is the caller graph for this function:

void Unit::EnterVehicle ( Unit base,
int8  seatId = -1 
)
15250 {
15252 }
Will ignore caster aura states including combat requirements and death state.
Definition: Unit.h:473
Definition: VehicleDefines.h:74
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:129

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ExitVehicle ( Position const exitPosition = NULL)

This function can be called at upper level code to initialize an exit from the passenger's side.

The following call would not even be executed successfully as the SPELL_AURA_CONTROL_VEHICLE unapply handler already calls _ExitVehicle without specifying an exitposition. The subsequent call below would return on if (!m_vehicle).

To do: We need to allow SPELL_AURA_CONTROL_VEHICLE unapply handlers in spellscripts to specify exit coordinates and either store those per passenger, or we need to init spline movement based on those coordinates in unapply handlers, and relocate exiting passengers based on Unit::moveSpline data. Either way, Coming Soon(TM)

15322 {
15324  if (!m_vehicle)
15325  return;
15326 
15331  /*_ExitVehicle(exitPosition);*/
15338 }
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
Vehicle * m_vehicle
Definition: Unit.h:2304
Definition: SpellAuraDefines.h:296
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spell * Unit::FindCurrentSpellBySpellId ( uint32  spell_id) const
2932 {
2933  for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
2934  if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id == spell_id)
2935  return m_currentSpells[i];
2936  return NULL;
2937 }
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
arena_t NULL
Definition: jemalloc_internal.h:624
uint32_t uint32
Definition: Define.h:150
#define CURRENT_MAX_SPELL
Definition: Unit.h:1115
uint32 Id
Definition: Spell.h:567

+ Here is the caller graph for this function:

void Unit::FinishSpell ( CurrentSpellTypes  spellType,
bool  ok = true 
)
2875 {
2876  Spell* spell = m_currentSpells[spellType];
2877  if (!spell)
2878  return;
2879 
2880  if (spellType == CURRENT_CHANNELED_SPELL)
2881  spell->SendChannelUpdate(0);
2882 
2883  spell->finish(ok);
2884 }
Definition: Unit.h:1110
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
void finish(bool ok=true)
Definition: Spell.cpp:3620
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:4266
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * Unit::GetAffectingPlayer ( ) const
7570 {
7571  if (!GetCharmerOrOwnerGUID())
7572  return const_cast<Unit*>(this)->ToPlayer();
7573 
7574  if (Unit* owner = GetCharmerOrOwner())
7575  return owner->GetCharmerOrOwnerPlayerOrPlayerItself();
7576 
7577  return NULL;
7578 }
arena_t NULL
Definition: jemalloc_internal.h:624
Player * ToPlayer()
Definition: Object.h:191
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.cpp:12677
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UnitAI* Unit::GetAI ( )
inline
1331 { return i_AI; }
UnitAI * i_AI
Definition: Unit.h:2242
uint16 Unit::GetAIAnimKitId ( ) const
inlineoverridevirtual

Reimplemented from WorldObject.

1505 { return _aiAnimKitId; }
uint16 _aiAnimKitId
Definition: Unit.h:2358
void Unit::GetAllMinionsByEntry ( std::list< TempSummon * > &  Minions,
uint32  entry 
)
7793 {
7794  for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
7795  {
7796  Unit* unit = *itr;
7797  if (unit->GetEntry() == entry && unit->IsSummon()) // minion, actually
7798  Minions.push_back(unit->ToTempSummon());
7799  }
7800 }
TempSummon * ToTempSummon()
Definition: Unit.h:2206
ControlList m_Controlled
Definition: Unit.h:1738
uint32 GetEntry() const
Definition: Object.h:107
bool IsSummon() const
Definition: Unit.h:1401
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetAPMultiplier ( WeaponAttackType  attType,
bool  normalized 
)
13114 {
13115  if (!normalized || GetTypeId() != TYPEID_PLAYER)
13116  return float(GetAttackTime(attType)) / 1000.0f;
13117 
13118  Item* Weapon = ToPlayer()->GetWeaponForAttack(attType, true);
13119  if (!Weapon)
13120  return 2.4f; // fist attack
13121 
13122  switch (Weapon->GetTemplate()->GetInventoryType())
13123  {
13124  case INVTYPE_2HWEAPON:
13125  return 3.3f;
13126  case INVTYPE_RANGED:
13127  case INVTYPE_RANGEDRIGHT:
13128  case INVTYPE_THROWN:
13129  return 2.8f;
13130  case INVTYPE_WEAPON:
13132  case INVTYPE_WEAPONOFFHAND:
13133  default:
13134  return Weapon->GetTemplate()->GetSubClass() == ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7f : 2.4f;
13135  }
13136 }
Definition: ItemTemplate.h:437
Player * ToPlayer()
Definition: Object.h:191
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.cpp:10326
InventoryType GetInventoryType() const
Definition: ItemTemplate.h:664
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ItemTemplate.h:345
Definition: ItemTemplate.h:354
Definition: ItemTemplate.h:347
Definition: Item.h:259
Definition: ItemTemplate.h:357
Definition: ItemTemplate.h:349
Definition: ItemTemplate.h:353
Definition: ObjectGuid.h:33
uint32 GetSubClass() const
Definition: ItemTemplate.h:654
Definition: ItemTemplate.h:358
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AuraApplicationMap& Unit::GetAppliedAuras ( )
inline
1789 { return m_appliedAuras; }
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the caller graph for this function:

AuraApplicationMap const& Unit::GetAppliedAuras ( ) const
inline
1790 { return m_appliedAuras; }
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
uint32 Unit::GetArmor ( ) const
inline
Definition: SharedDefines.h:274
uint32 GetResistance(SpellSchools school) const
Definition: Unit.h:1422

+ Here is the caller graph for this function:

Unit * Unit::getAttackerForHelper ( ) const
7212 {
7213  if (GetVictim() != NULL)
7214  return GetVictim();
7215 
7216  if (!m_attackers.empty())
7217  return *(m_attackers.begin());
7218 
7219  return NULL;
7220 }
arena_t NULL
Definition: jemalloc_internal.h:624
Unit * GetVictim() const
Definition: Unit.h:1379
AttackerSet m_attackers
Definition: Unit.h:2255

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AttackerSet const& Unit::getAttackers ( ) const
inline
1377 { return m_attackers; }
AttackerSet m_attackers
Definition: Unit.h:2255

+ Here is the caller graph for this function:

uint32 Unit::GetAttackTime ( WeaponAttackType  att) const
10327 {
10328  float f_BaseAttackTime = GetFloatValue(UNIT_FIELD_BASEATTACKTIME+att) / m_modAttackSpeedPct[att];
10329  return (uint32)f_BaseAttackTime;
10330 }
Definition: UpdateFields.h:113
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
uint32_t uint32
Definition: Define.h:150
float m_modAttackSpeedPct[3]
Definition: Unit.h:1945

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::getAttackTimer ( WeaponAttackType  type) const
inline
1356 { return m_attackTimer[type]; }
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2251

+ Here is the caller graph for this function:

Aura * Unit::GetAura ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
ObjectGuid  itemCasterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0 
) const
4152 {
4153  AuraApplication * aurApp = GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask);
4154  return aurApp ? aurApp->GetBase() : NULL;
4155 }
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
arena_t NULL
Definition: jemalloc_internal.h:624
AuraApplication * GetAuraApplication(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraApplication *except=NULL) const
Definition: Unit.cpp:4132

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AuraApplication * Unit::GetAuraApplication ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
ObjectGuid  itemCasterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0,
AuraApplication except = NULL 
) const
4133 {
4134  AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId);
4135  for (; range.first != range.second; ++range.first)
4136  {
4137  AuraApplication* app = range.first->second;
4138  Aura const* aura = app->GetBase();
4139 
4140  if (((aura->GetEffectMask() & reqEffMask) == reqEffMask)
4141  && (!casterGUID || aura->GetCasterGUID() == casterGUID)
4142  && (!itemCasterGUID || aura->GetCastItemGUID() == itemCasterGUID)
4143  && (!except || except != app))
4144  {
4145  return app;
4146  }
4147  }
4148  return NULL;
4149 }
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:133
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
arena_t NULL
Definition: jemalloc_internal.h:624
std::pair< AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator > AuraApplicationMapBounds
Definition: Unit.h:1316
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
uint32 GetEffectMask() const
Definition: SpellAuras.cpp:1213

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AuraApplication * Unit::GetAuraApplicationOfRankedSpell ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
ObjectGuid  itemCasterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0,
AuraApplication except = NULL 
) const
4158 {
4159  uint32 rankSpell = sSpellMgr->GetFirstSpellInChain(spellId);
4160  while (rankSpell)
4161  {
4162  if (AuraApplication * aurApp = GetAuraApplication(rankSpell, casterGUID, itemCasterGUID, reqEffMask, except))
4163  return aurApp;
4164  rankSpell = sSpellMgr->GetNextSpellInChain(rankSpell);
4165  }
4166  return NULL;
4167 }
Definition: SpellAuras.h:50
arena_t NULL
Definition: jemalloc_internal.h:624
AuraApplication * GetAuraApplication(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraApplication *except=NULL) const
Definition: Unit.cpp:4132
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetAuraCount ( uint32  spellId) const
4225 {
4226  uint32 count = 0;
4227  AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId);
4228 
4229  for (AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr)
4230  {
4231  if (itr->second->GetBase()->GetStackAmount() == 0)
4232  ++count;
4233  else
4234  count += (uint32)itr->second->GetBase()->GetStackAmount();
4235  }
4236 
4237  return count;
4238 }
std::pair< AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator > AuraApplicationMapBounds
Definition: Unit.h:1316
uint32_t uint32
Definition: Define.h:150
uint32_t uint32
Definition: g3dmath.h:168
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the caller graph for this function:

AuraEffect * Unit::GetAuraEffect ( uint32  spellId,
uint8  effIndex,
ObjectGuid  casterGUID = ObjectGuid::Empty 
) const
4072 {
4073  AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId);
4074  for (AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr)
4075  {
4076  if (itr->second->HasEffect(effIndex)
4077  && (!caster || itr->second->GetBase()->GetCasterGUID() == caster))
4078  {
4079  return itr->second->GetBase()->GetEffect(effIndex);
4080  }
4081  }
4082  return NULL;
4083 }
arena_t NULL
Definition: jemalloc_internal.h:624
std::pair< AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator > AuraApplicationMapBounds
Definition: Unit.h:1316
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the caller graph for this function:

AuraEffect * Unit::GetAuraEffect ( AuraType  type,
SpellFamilyNames  name,
uint32  iconId,
uint8  effIndex 
) const
4098 {
4099  AuraEffectList const& auras = GetAuraEffectsByType(type);
4100  for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
4101  {
4102  if (effIndex != (*itr)->GetEffIndex())
4103  continue;
4104  SpellInfo const* spell = (*itr)->GetSpellInfo();
4105  if (spell->SpellIconID == iconId && spell->SpellFamilyName == uint32(name) && !spell->SpellFamilyFlags)
4106  return *itr;
4107  }
4108  return NULL;
4109 }
Definition: SpellInfo.h:326
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 SpellFamilyName
Definition: SpellInfo.h:396
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
uint32 SpellIconID
Definition: SpellInfo.h:390

+ Here is the call graph for this function:

AuraEffect * Unit::GetAuraEffect ( AuraType  type,
SpellFamilyNames  family,
flag128 const familyFlag,
ObjectGuid  casterGUID = ObjectGuid::Empty 
) const
4112 {
4113  AuraEffectList const& auras = GetAuraEffectsByType(type);
4114  for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i)
4115  {
4116  SpellInfo const* spell = (*i)->GetSpellInfo();
4117  if (spell->SpellFamilyName == uint32(family) && spell->SpellFamilyFlags & familyFlag)
4118  {
4119  if (!casterGUID.IsEmpty() && (*i)->GetCasterGUID() != casterGUID)
4120  continue;
4121  return (*i);
4122  }
4123  }
4124  return NULL;
4125 }
Definition: SpellInfo.h:326
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 SpellFamilyName
Definition: SpellInfo.h:396
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

AuraEffect * Unit::GetAuraEffectOfRankedSpell ( uint32  spellId,
uint8  effIndex,
ObjectGuid  casterGUID = ObjectGuid::Empty 
) const
4086 {
4087  uint32 rankSpell = sSpellMgr->GetFirstSpellInChain(spellId);
4088  while (rankSpell)
4089  {
4090  if (AuraEffect* aurEff = GetAuraEffect(rankSpell, effIndex, caster))
4091  return aurEff;
4092  rankSpell = sSpellMgr->GetNextSpellInChain(rankSpell);
4093  }
4094  return NULL;
4095 }
Definition: SpellAuraEffects.h:30
arena_t NULL
Definition: jemalloc_internal.h:624
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AuraEffectList const& Unit::GetAuraEffectsByType ( AuraType  type) const
inline
1832 { return m_modAuras[type]; }
AuraEffectList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2279
Aura * Unit::GetAuraOfRankedSpell ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
ObjectGuid  itemCasterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0 
) const
4170 {
4171  AuraApplication * aurApp = GetAuraApplicationOfRankedSpell(spellId, casterGUID, itemCasterGUID, reqEffMask);
4172  return aurApp ? aurApp->GetBase() : NULL;
4173 }
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
arena_t NULL
Definition: jemalloc_internal.h:624
AuraApplication * GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraApplication *except=NULL) const
Definition: Unit.cpp:4157

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual uint32 Unit::GetBlockPercent ( ) const
inlinevirtual
1557 { return 30; }

+ Here is the caller graph for this function:

uint32 Unit::GetCastingTimeForBonus ( SpellInfo const spellProto,
DamageEffectType  damagetype,
uint32  CastingTime 
) const
12968 {
12969  // Not apply this to creature cast spells with casttime == 0
12970  if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !IsPet())
12971  return 3500;
12972 
12973  if (CastingTime > 7000) CastingTime = 7000;
12974  if (CastingTime < 1500) CastingTime = 1500;
12975 
12976  if (damagetype == DOT && !spellProto->IsChanneled())
12977  CastingTime = 3500;
12978 
12979  int32 overTime = 0;
12980  uint8 effects = 0;
12981  bool DirectDamage = false;
12982  bool AreaEffect = false;
12983 
12984  for (SpellEffectInfo const* effect : spellProto->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
12985  {
12986  if (!effect)
12987  continue;
12988  switch (effect->Effect)
12989  {
12995  case SPELL_EFFECT_HEAL:
12996  DirectDamage = true;
12997  break;
12999  switch (effect->ApplyAuraName)
13000  {
13004  if (spellProto->GetDuration())
13005  overTime = spellProto->GetDuration();
13006  break;
13007  default:
13008  // -5% per additional effect
13009  ++effects;
13010  break;
13011  }
13012  default:
13013  break;
13014  }
13015 
13016  if (effect->IsTargetingArea())
13017  AreaEffect = true;
13018  }
13019 
13020  // Combined Spells with Both Over Time and Direct Damage
13021  if (overTime > 0 && CastingTime > 0 && DirectDamage)
13022  {
13023  // mainly for DoTs which are 3500 here otherwise
13024  uint32 OriginalCastTime = spellProto->CalcCastTime(getLevel());
13025  if (OriginalCastTime > 7000) OriginalCastTime = 7000;
13026  if (OriginalCastTime < 1500) OriginalCastTime = 1500;
13027  // Portion to Over Time
13028  float PtOT = (overTime / 15000.0f) / ((overTime / 15000.0f) + (OriginalCastTime / 3500.0f));
13029 
13030  if (damagetype == DOT)
13031  CastingTime = uint32(CastingTime * PtOT);
13032  else if (PtOT < 1.0f)
13033  CastingTime = uint32(CastingTime * (1 - PtOT));
13034  else
13035  CastingTime = 0;
13036  }
13037 
13038  // Area Effect Spells receive only half of bonus
13039  if (AreaEffect)
13040  CastingTime /= 2;
13041 
13042  // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing
13043  for (SpellEffectInfo const* effect : spellProto->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
13044  {
13045  if (!effect)
13046  continue;
13047  if (effect->Effect == SPELL_EFFECT_HEALTH_LEECH ||
13048  (effect->Effect == SPELL_EFFECT_APPLY_AURA && effect->ApplyAuraName == SPELL_AURA_PERIODIC_LEECH))
13049  {
13050  CastingTime /= 2;
13051  break;
13052  }
13053  }
13054 
13055  // -5% of total per any additional effect
13056  for (uint8 i = 0; i < effects; ++i)
13057  CastingTime *= 0.95f;
13058 
13059  return CastingTime;
13060 }
Definition: SpellAuraDefines.h:68
Definition: SpellAuraDefines.h:63
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:1019
Definition: SharedDefines.h:1072
Definition: SharedDefines.h:1018
Definition: ObjectGuid.h:32
Definition: Unit.h:664
Definition: SharedDefines.h:1016
Definition: SharedDefines.h:1017
uint8 getLevel() const
Definition: Unit.h:1408
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:1020
bool IsPet() const
Definition: Unit.h:1403
uint8_t uint8
Definition: Define.h:152
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellAuraDefines.h:113
Definition: SharedDefines.h:1012

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellInfo const * Unit::GetCastSpellInfo ( SpellInfo const spellInfo) const
virtual
16484 {
16487  if (!swaps2.empty())
16488  swaps.insert(swaps.end(), swaps2.begin(), swaps2.end());
16489 
16490  for (AuraEffect const* auraEffect : swaps)
16491  {
16492  if ((!auraEffect->GetSpellEffectInfo()->SpellClassMask && uint32(auraEffect->GetMiscValue()) == spellInfo->Id) ||
16493  (auraEffect->GetSpellEffectInfo()->SpellClassMask && auraEffect->IsAffectingSpell(spellInfo)))
16494  if (SpellInfo const* newInfo = sSpellMgr->GetSpellInfo(auraEffect->GetAmount()))
16495  return newInfo;
16496  }
16497 
16498  return spellInfo;
16499 }
Definition: SpellAuraEffects.h:30
Definition: SpellInfo.h:326
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SpellAuraDefines.h:392
#define sSpellMgr
Definition: SpellMgr.h:756
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellAuraDefines.h:393

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid Unit::GetChannelObjectGuid ( ) const
inline
Definition: UpdateFields.h:92
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Unit * Unit::GetCharm ( ) const
7613 {
7614  ObjectGuid charm_guid = GetCharmGUID();
7615  if (!charm_guid.IsEmpty())
7616  {
7617  if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid))
7618  return pet;
7619 
7620  TC_LOG_ERROR("entities.unit", "Unit::GetCharm: Charmed creature %s not exist.", charm_guid.ToString().c_str());
7621  const_cast<Unit*>(this)->SetGuidValue(UNIT_FIELD_CHARM, ObjectGuid::Empty);
7622  }
7623 
7624  return NULL;
7625 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1706
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: UpdateFields.h:82
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Unit * Unit::GetCharmer ( ) const
7552 {
7553  ObjectGuid charmerGUID = GetCharmerGUID();
7554  if (!charmerGUID.IsEmpty())
7555  return ObjectAccessor::GetUnit(*this, charmerGUID);
7556 
7557  return NULL;
7558 }
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
arena_t NULL
Definition: jemalloc_internal.h:624
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
Definition: ObjectGuid.h:189
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid Unit::GetCharmerGUID ( ) const
inline
Definition: UpdateFields.h:85
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Unit * Unit::GetCharmerOrOwner ( ) const
7628 {
7629  return !GetCharmerGUID().IsEmpty() ? GetCharmer() : GetOwner();
7630 }
Unit * GetCharmer() const
Definition: Unit.cpp:7551
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
Unit * GetOwner() const
Definition: Unit.cpp:7542
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid Unit::GetCharmerOrOwnerGUID ( ) const
12678 {
12679  return !GetCharmerGUID().IsEmpty() ? GetCharmerGUID() : GetOwnerGUID();
12680 }
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid Unit::GetCharmerOrOwnerOrOwnGUID ( ) const
12683 {
12685  if (!guid.IsEmpty())
12686  return guid;
12687 
12688  return GetGUID();
12689 }
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.cpp:12677
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:189
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

Unit * Unit::GetCharmerOrOwnerOrSelf ( ) const
7633 {
7634  if (Unit* u = GetCharmerOrOwner())
7635  return u;
7636 
7637  return (Unit*)this;
7638 }
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * Unit::GetCharmerOrOwnerPlayerOrPlayerItself ( ) const
7561 {
7563  if (guid.IsPlayer())
7564  return ObjectAccessor::GetPlayer(*this, guid);
7565 
7566  return const_cast<Unit*>(this)->ToPlayer();
7567 }
bool IsPlayer() const
Definition: ObjectGuid.h:249
Player * ToPlayer()
Definition: Object.h:191
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.cpp:12677
Definition: ObjectGuid.h:189
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid Unit::GetCharmGUID ( ) const
inline
1706 { return GetGuidValue(UNIT_FIELD_CHARM); }
Definition: UpdateFields.h:82
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CharmInfo* Unit::GetCharmInfo ( )
inline
1748 { return m_charmInfo; }
CharmInfo * m_charmInfo
Definition: Unit.h:2292

+ Here is the caller graph for this function:

uint8 Unit::getClass ( ) const
inline
Definition: UpdateFields.h:96
Definition: Unit.h:233
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::getClassMask ( ) const
inline
1414 { return 1 << (getClass()-1); }
uint8 getClass() const
Definition: Unit.h:1413

+ Here is the caller graph for this function:

uint32 Unit::GetCombatRatingDamageReduction ( CombatRating  cr,
float  rate,
float  cap,
uint32  damage 
) const
private
14691 {
14692  float percent = std::min(GetCombatRatingReduction(cr) * rate, cap);
14693  return CalculatePct(damage, percent);
14694 }
T min(const T &x, const T &y)
Definition: g3dmath.h:305
float GetCombatRatingReduction(CombatRating cr) const
Definition: Unit.cpp:14678
T CalculatePct(T base, U pct)
Definition: Util.h:92

+ Here is the call graph for this function:

float Unit::GetCombatRatingReduction ( CombatRating  cr) const
private
14679 {
14680  if (Player const* player = ToPlayer())
14681  return player->GetRatingBonusValue(cr);
14682  // Player's pet get resilience from owner
14683  else if (IsPet() && GetOwner())
14684  if (Player* owner = GetOwner()->ToPlayer())
14685  return owner->GetRatingBonusValue(cr);
14686 
14687  return 0.0f;
14688 }
Player * ToPlayer()
Definition: Object.h:191
bool IsPet() const
Definition: Unit.h:1403
Unit * GetOwner() const
Definition: Unit.cpp:7542

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetCombatReach ( ) const
inline
Definition: UpdateFields.h:116
float * m_floatValues
Definition: Object.h:236

+ Here is the caller graph for this function:

uint32 Unit::GetCombatTimer ( ) const
inline
1590 { return m_CombatTimer; }
uint32 m_CombatTimer
Definition: Unit.h:2341

+ Here is the caller graph for this function:

uint32 Unit::GetCreateHealth ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:145

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetCreateMana ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetCreatePowers ( Powers  power) const
11680 {
11681  switch (power)
11682  {
11683  case POWER_MANA:
11684  return GetCreateMana();
11685  case POWER_RAGE:
11686  return 1000;
11687  case POWER_FOCUS:
11688  if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_HUNTER)
11689  return 100;
11690  return (GetTypeId() == TYPEID_PLAYER || !((Creature const*)this)->IsPet() || ((Pet const*)this)->getPetType() != HUNTER_PET ? 0 : 100);
11691  case POWER_ENERGY:
11692  return 100;
11693  case POWER_COMBO_POINTS:
11694  return 5;
11695  case POWER_RUNIC_POWER:
11696  return 1000;
11697  case POWER_RUNES:
11698  return 0;
11699  case POWER_SOUL_SHARDS:
11700  return 400;
11701  case POWER_ECLIPSE:
11702  return 100;
11703  case POWER_HOLY_POWER:
11704  return 3;
11705  case POWER_CHI:
11706  return 4;
11707  case POWER_SHADOW_ORBS:
11708  return 3;
11709  case POWER_BURNING_EMBERS:
11710  return 40;
11711  case POWER_DEMONIC_FURY:
11712  return 1000;
11713  case POWER_ARCANE_CHARGES:
11714  return 4;
11715  case POWER_HEALTH:
11716  return 0;
11717  default:
11718  break;
11719  }
11720 
11721  return 0;
11722 }
uint32 GetCreateMana() const
Definition: Unit.h:1897
Definition: SharedDefines.h:252
Definition: SharedDefines.h:263
Definition: SharedDefines.h:254
Definition: SharedDefines.h:249
Definition: SharedDefines.h:262
Definition: Creature.h:467
Definition: SharedDefines.h:253
Definition: PetDefines.h:25
Definition: SharedDefines.h:250
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:255
Definition: SharedDefines.h:260
Definition: SharedDefines.h:261
bool IsPet() const
Definition: Unit.h:1403
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:251
Definition: SharedDefines.h:169
uint8 getClass() const
Definition: Unit.h:1413
Definition: SharedDefines.h:257
Definition: SharedDefines.h:264
Definition: SharedDefines.h:256
Definition: Pet.h:46
Definition: SharedDefines.h:248
Definition: SharedDefines.h:267

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetCreateStat ( Stats  stat) const
inline
1902 { return m_createStats[stat]; }
float m_createStats[MAX_STATS]
Definition: Unit.h:2253

+ Here is the caller graph for this function:

ObjectGuid Unit::GetCreatorGUID ( ) const
inline
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332
Definition: UpdateFields.h:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetCreatureType ( ) const
11249 {
11250  if (GetTypeId() == TYPEID_PLAYER)
11251  {
11253  SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(form);
11254  if (ssEntry && ssEntry->CreatureType > 0)
11255  return ssEntry->CreatureType;
11256  else
11257  return CREATURE_TYPE_HUMANOID;
11258  }
11259  else
11260  return ToCreature()->GetCreatureTemplate()->type;
11261 }
ShapeshiftForm
Definition: Unit.h:260
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:1932
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: SharedDefines.h:3560
Definition: DBCStructure.h:1160
Definition: ObjectGuid.h:33
int32 CreatureType
Definition: DBCStructure.h:1166
Creature * ToCreature()
Definition: Object.h:194
DBCStorage< SpellShapeshiftFormEntry > sSpellShapeshiftFormStore(SpellShapeshiftFormfmt)
uint32 type
Definition: Creature.h:116

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetCreatureTypeMask ( ) const
11264 {
11265  uint32 creatureType = GetCreatureType();
11266  return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0;
11267 }
uint32 GetCreatureType() const
Definition: Unit.cpp:11248
uint32_t uint32
Definition: Define.h:150

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid Unit::GetCritterGUID ( ) const
inline
1710 { return GetGuidValue(UNIT_FIELD_CRITTER); }
Definition: UpdateFields.h:84
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spell* Unit::GetCurrentSpell ( CurrentSpellTypes  spellType) const
inline
1920 { return m_currentSpells[spellType]; }
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271

+ Here is the caller graph for this function:

Spell* Unit::GetCurrentSpell ( uint32  spellType) const
inline
1921 { return m_currentSpells[spellType]; }
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
int32 Unit::GetCurrentSpellCastTime ( uint32  spell_id) const
2940 {
2941  if (Spell const* spell = FindCurrentSpellBySpellId(spell_id))
2942  return spell->GetCastTime();
2943  return 0;
2944 }
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition: Unit.cpp:2931
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetDamageReduction ( uint32  damage) const
inline
1540 { return GetCombatRatingDamageReduction(CR_RESILIENCE_PLAYER_DAMAGE_TAKEN, 1.0f, 100.0f, damage); }
Definition: Unit.h:640
uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const
Definition: Unit.cpp:14690

+ Here is the caller graph for this function:

DeathState Unit::getDeathState ( ) const
inline
1695 { return m_deathState; }
DeathState m_deathState
Definition: Unit.h:2259

+ Here is the caller graph for this function:

DiminishingLevels Unit::GetDiminishing ( DiminishingGroup  group)
11087 {
11088  for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
11089  {
11090  if (i->DRGroup != group)
11091  continue;
11092 
11093  if (!i->hitCount)
11094  return DIMINISHING_LEVEL_1;
11095 
11096  if (!i->hitTime)
11097  return DIMINISHING_LEVEL_1;
11098 
11099  // If last spell was cast more than 18 seconds ago - reset the count.
11100  if (i->stack == 0 && getMSTimeDiff(i->hitTime, getMSTime()) > 18 * IN_MILLISECONDS)
11101  {
11102  i->hitCount = DIMINISHING_LEVEL_1;
11103  return DIMINISHING_LEVEL_1;
11104  }
11105  // or else increase the count.
11106  else
11107  return DiminishingLevels(i->hitCount);
11108  }
11109  return DIMINISHING_LEVEL_1;
11110 }
uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
Definition: Timer.h:33
uint32 getMSTime()
Definition: Timer.h:24
Diminishing m_Diminishing
Definition: Unit.h:2344
Definition: SharedDefines.h:4876
DiminishingLevels
Definition: SharedDefines.h:4874
Definition: Common.h:103

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TransportBase * Unit::GetDirectTransport ( ) const

Returns the transport this unit is on directly (if on vehicle and transport, return vehicle)

14366 {
14367  if (Vehicle* veh = GetVehicle())
14368  return veh;
14369  return GetTransport();
14370 }
Definition: Vehicle.h:32
Transport * GetTransport() const
Definition: Object.h:602
Vehicle * GetVehicle() const
Definition: Unit.h:2166

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetDiseasesByCaster ( ObjectGuid  casterGUID,
bool  remove = false 
)
4341 {
4342  static const AuraType diseaseAuraTypes[] =
4343  {
4344  SPELL_AURA_PERIODIC_DAMAGE, // Frost Fever and Blood Plague
4345  SPELL_AURA_LINKED, // Crypt Fever and Ebon Plague
4347  };
4348 
4349  uint32 diseases = 0;
4350  for (AuraType const* itr = diseaseAuraTypes; *itr != SPELL_AURA_NONE; ++itr)
4351  {
4352  for (AuraEffectList::iterator i = m_modAuras[*itr].begin(); i != m_modAuras[*itr].end();)
4353  {
4354  // Get auras with disease dispel type by caster
4355  if ((*i)->GetSpellInfo()->Dispel == DISPEL_DISEASE
4356  && (*i)->GetCasterGUID() == casterGUID)
4357  {
4358  ++diseases;
4359 
4360  if (remove)
4361  {
4362  RemoveAura((*i)->GetId(), (*i)->GetCasterGUID());
4363  i = m_modAuras[*itr].begin();
4364  continue;
4365  }
4366  }
4367  ++i;
4368  }
4369  }
4370  return diseases;
4371 }
AuraType
Definition: SpellAuraDefines.h:58
Definition: SpellAuraDefines.h:63
AuraEffectList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2279
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
Definition: SharedDefines.h:1841
uint32_t uint32
Definition: Define.h:150
Definition: SpellAuraDefines.h:344
Definition: SpellAuraDefines.h:60

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::GetDispellableAuraList ( Unit caster,
uint32  dispelMask,
DispelChargesList dispelList 
)
4176 {
4177  AuraMap const& auras = GetOwnedAuras();
4178  for (AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
4179  {
4180  Aura* aura = itr->second;
4181  AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID());
4182  if (!aurApp)
4183  continue;
4184 
4185  // don't try to remove passive auras
4186  if (aura->IsPassive())
4187  continue;
4188 
4189  if (aura->GetSpellInfo()->GetDispelMask() & dispelMask)
4190  {
4191  if (aura->GetSpellInfo()->Dispel == DISPEL_MAGIC)
4192  {
4193  // do not remove positive auras if friendly target
4194  // negative auras if non-friendly target
4195  if (aurApp->IsPositive() == IsFriendlyTo(caster))
4196  continue;
4197  }
4198 
4199  // The charges / stack amounts don't count towards the total number of auras that can be dispelled.
4200  // Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell
4201  // Polymorph instead of 1 / (5 + 1) -> 16%.
4202  bool dispel_charges = (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) != 0;
4203  uint8 charges = dispel_charges ? aura->GetCharges() : aura->GetStackAmount();
4204  if (charges > 0)
4205  dispelList.push_back(std::make_pair(aura, charges));
4206  }
4207  }
4208 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool IsPassive() const
Definition: SpellAuras.cpp:1026
AuraMap & GetOwnedAuras()
Definition: Unit.h:1779
Definition: SpellAuras.h:50
uint32 Dispel
Definition: SpellInfo.h:331
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
uint32 AttributesEx7
Definition: SpellInfo.h:340
bool IsPositive() const
Definition: SpellAuras.h:81
Definition: SharedDefines.h:1839
std::multimap< uint32, Aura * > AuraMap
Definition: Unit.h:1311
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
uint32 GetDispelMask() const
Definition: SpellInfo.cpp:2202
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
uint8 GetCharges() const
Definition: SpellAuras.h:170
uint8_t uint8
Definition: Define.h:152
Definition: SpellAuras.h:116
Definition: SharedDefines.h:618

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetDisplayId ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetDoTsByCaster ( ObjectGuid  casterGUID) const
4374 {
4375  static const AuraType diseaseAuraTypes[] =
4376  {
4380  };
4381 
4382  uint32 dots = 0;
4383  for (AuraType const* itr = &diseaseAuraTypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr)
4384  {
4385  Unit::AuraEffectList const& auras = GetAuraEffectsByType(*itr);
4386  for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i)
4387  {
4388  // Get auras by caster
4389  if ((*i)->GetCasterGUID() == casterGUID)
4390  ++dots;
4391  }
4392  }
4393  return dots;
4394 }
AuraType
Definition: SpellAuraDefines.h:58
Definition: SpellAuraDefines.h:63
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: SpellAuraDefines.h:60
Definition: SpellAuraDefines.h:149

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AuraEffect * Unit::GetDummyAuraEffect ( SpellFamilyNames  name,
uint32  iconId,
uint8  effIndex 
) const
4128 {
4129  return GetAuraEffect(SPELL_AURA_DUMMY, name, iconId, effIndex);
4130 }
Definition: SpellAuraDefines.h:64
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DynamicObject * Unit::GetDynObject ( uint32  spellId)
4703 {
4704  if (m_dynObj.empty())
4705  return NULL;
4706  for (DynObjectList::const_iterator i = m_dynObj.begin(); i != m_dynObj.end();++i)
4707  {
4708  DynamicObject* dynObj = *i;
4709  if (dynObj->GetSpellId() == spellId)
4710  return dynObj;
4711  }
4712  return NULL;
4713 }
uint32 GetSpellId() const
Definition: DynamicObject.h:57
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: DynamicObject.h:35
DynObjectList m_dynObj
Definition: Unit.h:2264

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16 Unit::GetExtraUnitMovementFlags ( ) const
inline
MovementInfo m_movementInfo
Definition: Object.h:612
uint16 GetExtraMovementFlags() const
Definition: Object.h:332

+ Here is the caller graph for this function:

uint32 Unit::getFaction ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:107

+ Here is the call graph for this function:

ReputationRank Unit::GetFactionReactionTo ( FactionTemplateEntry const factionTemplateEntry,
Unit const target 
)
static
7119 {
7120  // always neutral when no template entry found
7121  if (!factionTemplateEntry)
7122  return REP_NEUTRAL;
7123 
7124  FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry();
7125  if (!targetFactionTemplateEntry)
7126  return REP_NEUTRAL;
7127 
7128  if (Player const* targetPlayerOwner = target->GetAffectingPlayer())
7129  {
7130  // check contested flags
7131  if (factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD
7132  && targetPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
7133  return REP_HOSTILE;
7134  if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(factionTemplateEntry))
7135  return *repRank;
7136  if (!target->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_IGNORE_REPUTATION))
7137  {
7138  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->Faction))
7139  {
7140  if (factionEntry->CanHaveReputation())
7141  {
7142  // CvP case - check reputation, don't allow state higher than neutral when at war
7143  ReputationRank repRank = targetPlayerOwner->GetReputationMgr().GetRank(factionEntry);
7144  if (targetPlayerOwner->GetReputationMgr().IsAtWar(factionEntry))
7145  repRank = std::min(REP_NEUTRAL, repRank);
7146  return repRank;
7147  }
7148  }
7149  }
7150  }
7151 
7152  // common faction based check
7153  if (factionTemplateEntry->IsHostileTo(*targetFactionTemplateEntry))
7154  return REP_HOSTILE;
7155  if (factionTemplateEntry->IsFriendlyTo(*targetFactionTemplateEntry))
7156  return REP_FRIENDLY;
7157  if (targetFactionTemplateEntry->IsFriendlyTo(*factionTemplateEntry))
7158  return REP_FRIENDLY;
7159  if (factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT)
7160  return REP_HOSTILE;
7161  // neutral by default
7162  return REP_NEUTRAL;
7163 }
Definition: Player.h:525
ReputationRank
Definition: SharedDefines.h:211
Definition: UpdateFields.h:110
Definition: SharedDefines.h:216
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Definition: SharedDefines.h:217
Definition: SharedDefines.h:214
bool IsFriendlyTo(FactionTemplateEntry const &entry) const
Definition: DBCStructure.h:446
Definition: DBCEnums.h:463
Definition: Unit.h:713
Definition: DBCStructure.h:433
Definition: DBCStructure.h:405
Definition: UpdateFields.h:191
DBCStorage< FactionEntry > sFactionStore(Factionfmt)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FactionTemplateEntry const * Unit::GetFactionTemplateEntry ( ) const
7020 {
7021  FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction());
7022  if (!entry)
7023  {
7024  if (Player const* player = ToPlayer())
7025  TC_LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), getFaction());
7026  else if (Creature const* creature = ToCreature())
7027  TC_LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, getFaction());
7028  else
7029  TC_LOG_ERROR("entities.unit", "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), getFaction());
7030  }
7031  return entry;
7032 }
uint32 getFaction() const
Definition: Unit.h:1466
std::string const & GetName() const
Definition: Object.h:479
Definition: Creature.h:467
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: DBCStructure.h:433
Creature * ToCreature()
Definition: Object.h:194
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplatefmt)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Unit * Unit::GetFirstControlled ( ) const
7985 {
7986  // Sequence: charmed, pet, other guardians
7987  Unit* unit = GetCharm();
7988  if (!unit)
7989  {
7990  ObjectGuid guid = GetMinionGUID();
7991  if (!guid.IsEmpty())
7992  unit = ObjectAccessor::GetUnit(*this, guid);
7993  }
7994 
7995  return unit;
7996 }
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
ObjectGuid GetMinionGUID() const
Definition: Unit.h:1702
Unit * GetCharm() const
Definition: Unit.cpp:7612
Definition: ObjectGuid.h:189
Definition: Unit.h:1305
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Minion * Unit::GetFirstMinion ( ) const
7581 {
7582  ObjectGuid pet_guid = GetMinionGUID();
7583  if (!pet_guid.IsEmpty())
7584  {
7585  if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid))
7586  if (pet->HasUnitTypeMask(UNIT_MASK_MINION))
7587  return (Minion*)pet;
7588 
7589  TC_LOG_ERROR("entities.unit", "Unit::GetFirstMinion: Minion %s not exist.", pet_guid.ToString().c_str());
7590  const_cast<Unit*>(this)->SetMinionGUID(ObjectGuid::Empty);
7591  }
7592 
7593  return NULL;
7594 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void SetMinionGUID(ObjectGuid guid)
Definition: Unit.h:1703
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
ObjectGuid GetMinionGUID() const
Definition: Unit.h:1702
Definition: Unit.h:859
Definition: TemporarySummon.h:66
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual float Unit::GetFollowAngle ( ) const
inlinevirtual

Reimplemented in Minion.

2194 { return static_cast<float>(M_PI/2); }
#define M_PI
Definition: Common.h:163

+ Here is the caller graph for this function:

GameObject * Unit::GetGameObject ( uint32  spellId) const
4739 {
4740  for (GameObjectList::const_iterator i = m_gameObj.begin(); i != m_gameObj.end(); ++i)
4741  if ((*i)->GetSpellId() == spellId)
4742  return *i;
4743 
4744  return NULL;
4745 }
arena_t NULL
Definition: jemalloc_internal.h:624
GameObjectList m_gameObj
Definition: Unit.h:2267

+ Here is the caller graph for this function:

uint8 Unit::getGender ( ) const
inline
Definition: Unit.h:234
Definition: UpdateFields.h:96
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Guardian * Unit::GetGuardianPet ( ) const
7597 {
7598  ObjectGuid pet_guid = GetPetGUID();
7599  if (!pet_guid.IsEmpty())
7600  {
7601  if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid))
7602  if (pet->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
7603  return (Guardian*)pet;
7604 
7605  TC_LOG_FATAL("entities.unit", "Unit::GetGuardianPet: Guardian %s not exist.", pet_guid.ToString().c_str());
7606  const_cast<Unit*>(this)->SetPetGUID(ObjectGuid::Empty);
7607  }
7608 
7609  return NULL;
7610 }
Definition: TemporarySummon.h:83
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: Unit.h:860
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
ObjectGuid GetPetGUID() const
Definition: Unit.h:1708
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:210
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
Definition: ObjectGuid.h:189
Definition: Unit.h:1305
void SetPetGUID(ObjectGuid guid)
Definition: Unit.h:1707
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetHealth ( ) const
inline
1426 { return GetUInt32Value(UNIT_FIELD_HEALTH); }
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:99

+ Here is the call graph for this function:

int32 Unit::GetHealthGain ( int32  dVal)
10260 {
10261  int32 gain = 0;
10262 
10263  if (dVal == 0)
10264  return 0;
10265 
10266  int32 curHealth = (int32)GetHealth();
10267 
10268  int32 val = dVal + curHealth;
10269  if (val <= 0)
10270  {
10271  return -curHealth;
10272  }
10273 
10274  int32 maxHealth = (int32)GetMaxHealth();
10275 
10276  if (val < maxHealth)
10277  gain = dVal;
10278  else if (curHealth != maxHealth)
10279  gain = maxHealth - curHealth;
10280 
10281  return gain;
10282 }
uint32 GetMaxHealth() const
Definition: Unit.h:1427
int32_t int32
Definition: Define.h:146
int32_t int32
Definition: g3dmath.h:167
uint32 GetHealth() const
Definition: Unit.h:1426

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetHealthPct ( ) const
inline
1434 { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
uint32 GetMaxHealth() const
Definition: Unit.h:1427
uint32 GetHealth() const
Definition: Unit.h:1426

+ Here is the caller graph for this function:

int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue ( AuraEffect const aurEff,
AuraType  auraType,
bool  checkMiscValue = false,
int32  miscValue = 0 
) const
16317 {
16318  int32 val = 0;
16319  SpellSpellGroupMapBounds spellGroup = sSpellMgr->GetSpellSpellGroupMapBounds(aurEff->GetSpellInfo()->GetFirstRankSpell()->Id);
16320  for (SpellSpellGroupMap::const_iterator itr = spellGroup.first; itr != spellGroup.second ; ++itr)
16321  {
16322  if (sSpellMgr->GetSpellGroupStackRule(itr->second) == SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT)
16323  {
16324  AuraEffectList const& auraEffList = GetAuraEffectsByType(auraType);
16325  for (AuraEffectList::const_iterator auraItr = auraEffList.begin(); auraItr != auraEffList.end(); ++auraItr)
16326  {
16327  if (aurEff != (*auraItr) && (!checkMiscValue || (*auraItr)->GetMiscValue() == miscValue) &&
16328  sSpellMgr->IsSpellMemberOfSpellGroup((*auraItr)->GetSpellInfo()->Id, itr->second))
16329  {
16330  // absolute value only
16331  if (abs(val) < abs((*auraItr)->GetAmount()))
16332  val = (*auraItr)->GetAmount();
16333  }
16334  }
16335  }
16336  }
16337  return val;
16338 }
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
std::pair< SpellSpellGroupMap::const_iterator, SpellSpellGroupMap::const_iterator > SpellSpellGroupMapBounds
Definition: SpellMgr.h:331
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HostileRefManager& Unit::getHostileRefManager ( )
inline
2001 { return m_HostileRefManager; }
HostileRefManager m_HostileRefManager
Definition: Unit.h:2346

+ Here is the caller graph for this function:

uint32 Unit::GetInterruptMask ( ) const
inline
2008 { return m_interruptMask; }
uint32 m_interruptMask
Definition: Unit.h:2283
time_t Unit::GetLastDamagedTime ( ) const
inline
2216 { return _lastDamagedTime; }
time_t _lastDamagedTime
Definition: Unit.h:2362

+ Here is the caller graph for this function:

uint8 Unit::getLevel ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:105
uint8_t uint8
Definition: g3dmath.h:164

+ Here is the call graph for this function:

uint8 Unit::getLevelForTarget ( WorldObject const ) const
inlineoverridevirtual

Reimplemented from WorldObject.

1409 { return getLevel(); }
uint8 getLevel() const
Definition: Unit.h:1408

+ Here is the caller graph for this function:

Unit * Unit::GetMagicHitRedirectTarget ( Unit victim,
SpellInfo const spellInfo 
)
Todo:
handle this charge drop by proc in cast phase on explicit target
7937 {
7938  // Patch 1.2 notes: Spell Reflection no longer reflects abilities
7939  if (spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR1_CANT_BE_REDIRECTED) || spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
7940  return victim;
7941 
7943  for (Unit::AuraEffectList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr)
7944  {
7945  if (Unit* magnet = (*itr)->GetBase()->GetCaster())
7946  if (spellInfo->CheckExplicitTarget(this, magnet) == SPELL_CAST_OK
7947  && _IsValidAttackTarget(magnet, spellInfo))
7948  {
7950  if (spellInfo->Speed > 0.0f)
7951  {
7952  // Set up missile speed based delay
7953  uint32 delay = uint32(std::floor(std::max<float>(victim->GetDistance(this), 5.0f) / spellInfo->Speed * 1000.0f));
7954  // Schedule charge drop
7955  (*itr)->GetBase()->DropChargeDelayed(delay, AURA_REMOVE_BY_EXPIRE);
7956  }
7957  else
7958  (*itr)->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE);
7959 
7960  return magnet;
7961  }
7962  }
7963  return victim;
7964 }
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=NULL) const
Definition: Unit.cpp:10008
static Vector3int16 floor(const Vector3 &v)
Definition: SharedDefines.h:360
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: SpellAuraDefines.h:156
Definition: Unit.h:454
uint32_t uint32
Definition: g3dmath.h:168
Definition: SharedDefines.h:385
Definition: SharedDefines.h:395
Definition: Unit.h:1305
Definition: SharedDefines.h:1538

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetMaxHealth ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:101

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetMaxNegativeAuraModifier ( AuraType  auratype) const
4441 {
4442  int32 modifier = 0;
4443 
4444  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4445  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4446  if ((*i)->GetAmount() < modifier)
4447  modifier = (*i)->GetAmount();
4448 
4449  return modifier;
4450 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetMaxNegativeAuraModifierByAffectMask ( AuraType  auratype,
SpellInfo const affectedSpell 
) const
4640 {
4641  int32 modifier = 0;
4642 
4643  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4644  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4645  {
4646  if ((*i)->IsAffectingSpell(affectedSpell) && (*i)->GetAmount() < modifier)
4647  modifier = (*i)->GetAmount();
4648  }
4649 
4650  return modifier;
4651 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

int32 Unit::GetMaxNegativeAuraModifierByMiscMask ( AuraType  auratype,
uint32  misc_mask 
) const
4508 {
4509  int32 modifier = 0;
4510 
4511  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4512  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4513  {
4514  if ((*i)->GetMiscValue()& miscMask && (*i)->GetAmount() < modifier)
4515  modifier = (*i)->GetAmount();
4516  }
4517 
4518  return modifier;
4519 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

int32 Unit::GetMaxNegativeAuraModifierByMiscValue ( AuraType  auratype,
int32  misc_value 
) const
4574 {
4575  int32 modifier = 0;
4576 
4577  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4578  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4579  {
4580  if ((*i)->GetMiscValue() == miscValue && (*i)->GetAmount() < modifier)
4581  modifier = (*i)->GetAmount();
4582  }
4583 
4584  return modifier;
4585 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetMaxPositiveAuraModifier ( AuraType  auratype) const
4427 {
4428  int32 modifier = 0;
4429 
4430  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4431  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4432  {
4433  if ((*i)->GetAmount() > modifier)
4434  modifier = (*i)->GetAmount();
4435  }
4436 
4437  return modifier;
4438 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetMaxPositiveAuraModifierByAffectMask ( AuraType  auratype,
SpellInfo const affectedSpell 
) const
4626 {
4627  int32 modifier = 0;
4628 
4629  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4630  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4631  {
4632  if ((*i)->IsAffectingSpell(affectedSpell) && (*i)->GetAmount() > modifier)
4633  modifier = (*i)->GetAmount();
4634  }
4635 
4636  return modifier;
4637 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

int32 Unit::GetMaxPositiveAuraModifierByMiscMask ( AuraType  auratype,
uint32  misc_mask,
const AuraEffect except = NULL 
) const
4494 {
4495  int32 modifier = 0;
4496 
4497  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4498  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4499  {
4500  if (except != (*i) && (*i)->GetMiscValue()& miscMask && (*i)->GetAmount() > modifier)
4501  modifier = (*i)->GetAmount();
4502  }
4503 
4504  return modifier;
4505 }
int32 GetMiscValue() const
Definition: SpellAuraEffects.h:53
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetMaxPositiveAuraModifierByMiscValue ( AuraType  auratype,
int32  misc_value 
) const
4560 {
4561  int32 modifier = 0;
4562 
4563  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4564  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4565  {
4566  if ((*i)->GetMiscValue() == miscValue && (*i)->GetAmount() > modifier)
4567  modifier = (*i)->GetAmount();
4568  }
4569 
4570  return modifier;
4571 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

int32 Unit::GetMaxPower ( Powers  power) const
11599 {
11600  uint32 powerIndex = GetPowerIndex(power);
11601  if (powerIndex == MAX_POWERS || powerIndex >= MAX_POWERS_PER_CLASS)
11602  return 0;
11603 
11604  return GetInt32Value(UNIT_FIELD_MAXPOWER + powerIndex);
11605 }
#define MAX_POWERS_PER_CLASS
Definition: SharedDefines.h:270
Definition: UpdateFields.h:102
int32 GetInt32Value(uint16 index) const
Definition: Object.cpp:294
uint32_t uint32
Definition: Define.h:150
uint32 GetPowerIndex(uint32 powerType) const
Definition: Unit.cpp:11666
Definition: SharedDefines.h:265

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16 Unit::GetMaxSkillValueForLevel ( Unit const target = NULL) const
inline
1511 { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
uint8 getLevelForTarget(WorldObject const *) const override
Definition: Unit.h:1409
uint8 getLevel() const
Definition: Unit.h:1408

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetMechanicImmunityMask ( ) const
9330 {
9331  uint32 mask = 0;
9332  SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
9333  for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
9334  mask |= (1 << itr->type);
9335 
9336  return mask;
9337 }
std::list< SpellImmune > SpellImmuneList
Definition: Unit.h:430
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:1865
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1988
int32 Unit::GetMechanicResistChance ( SpellInfo const spellInfo) const
2179 {
2180  if (!spellInfo)
2181  return 0;
2182 
2183  int32 resistMech = 0;
2184  for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
2185  {
2186  if (!effect || !effect->IsEffect())
2187  break;
2188 
2189  int32 effectMech = spellInfo->GetEffectMechanic(effect->EffectIndex, GetMap()->GetDifficultyID());
2190  if (effectMech)
2191  {
2193  if (resistMech < temp)
2194  resistMech = temp;
2195  }
2196  }
2197  return resistMech;
2198 }
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:4521
Map * GetMap() const
Definition: Object.h:543
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
Definition: SpellAuraDefines.h:177

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16 Unit::GetMeleeAnimKitId ( ) const
inlineoverridevirtual

Reimplemented from WorldObject.

1509 { return _meleeAnimKitId; }
uint16 _meleeAnimKitId
Definition: Unit.h:2360
SpellSchoolMask Unit::GetMeleeDamageSchoolMask ( ) const
protectedvirtual

Reimplemented in Creature.

12673 {
12674  return SPELL_SCHOOL_MASK_NORMAL;
12675 }
Definition: SharedDefines.h:288

+ Here is the caller graph for this function:

Unit * Unit::GetMeleeHitRedirectTarget ( Unit victim,
SpellInfo const spellInfo = NULL 
)
7967 {
7968  AuraEffectList const& hitTriggerAuras = victim->GetAuraEffectsByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
7969  for (AuraEffectList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i)
7970  {
7971  if (Unit* magnet = (*i)->GetBase()->GetCaster())
7972  if (_IsValidAttackTarget(magnet, spellInfo) && magnet->IsWithinLOSInMap(this)
7973  && (!spellInfo || (spellInfo->CheckExplicitTarget(this, magnet) == SPELL_CAST_OK
7974  && spellInfo->CheckTarget(this, magnet, false) == SPELL_CAST_OK)))
7975  if (roll_chance_i((*i)->GetAmount()))
7976  {
7977  (*i)->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE);
7978  return magnet;
7979  }
7980  }
7981  return victim;
7982 }
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=NULL) const
Definition: Unit.cpp:10008
Definition: SpellAuraDefines.h:171
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
bool roll_chance_i(int chance)
Definition: Random.h:53
Definition: Unit.h:454
Definition: Unit.h:1305
Definition: SharedDefines.h:1538

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetMeleeReach ( ) const
487 {
488  float reach = m_floatValues[UNIT_FIELD_COMBATREACH];
489  return reach > MIN_MELEE_REACH ? reach : MIN_MELEE_REACH;
490 }
Definition: UpdateFields.h:116
#define MIN_MELEE_REACH
Definition: Object.h:46
float * m_floatValues
Definition: Object.h:236

+ Here is the caller graph for this function:

ObjectGuid Unit::GetMinionGUID ( ) const
inline
1702 { return GetGuidValue(UNIT_FIELD_SUMMON); }
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332
Definition: UpdateFields.h:83

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetMinPower ( Powers  power) const
inline
1447 { return power == POWER_ECLIPSE ? -100 : 0; }
Definition: SharedDefines.h:256

+ Here is the caller graph for this function:

uint32 Unit::GetModelForForm ( ShapeshiftForm  form) const

Glyph of Arctic Wolf

14697 {
14698  if (GetTypeId() == TYPEID_PLAYER)
14699  {
14700  switch (form)
14701  {
14702  case FORM_CAT:
14703  // Based on Hair color
14704  if (getRace() == RACE_NIGHTELF)
14705  {
14707  switch (hairColor)
14708  {
14709  case 7: // Violet
14710  case 8:
14711  return 29405;
14712  case 3: // Light Blue
14713  return 29406;
14714  case 0: // Green
14715  case 1: // Light Green
14716  case 2: // Dark Green
14717  return 29407;
14718  case 4: // White
14719  return 29408;
14720  default: // original - Dark Blue
14721  return 892;
14722  }
14723  }
14724  else if (getRace() == RACE_TROLL)
14725  {
14727  switch (hairColor)
14728  {
14729  case 0: // Red
14730  case 1:
14731  return 33668;
14732  case 2: // Yellow
14733  case 3:
14734  return 33667;
14735  case 4: // Blue
14736  case 5:
14737  case 6:
14738  return 33666;
14739  case 7: // Purple
14740  case 10:
14741  return 33665;
14742  default: // original - white
14743  return 33669;
14744  }
14745  }
14746  else if (getRace() == RACE_WORGEN)
14747  {
14748  // Based on Skin color
14750  // Male
14751  if (getGender() == GENDER_MALE)
14752  {
14753  switch (skinColor)
14754  {
14755  case 1: // Brown
14756  return 33662;
14757  case 2: // Black
14758  case 7:
14759  return 33661;
14760  case 4: // yellow
14761  return 33664;
14762  case 3: // White
14763  case 5:
14764  return 33663;
14765  default: // original - Gray
14766  return 33660;
14767  }
14768  }
14769  // Female
14770  else
14771  {
14772  switch (skinColor)
14773  {
14774  case 5: // Brown
14775  case 6:
14776  return 33662;
14777  case 7: // Black
14778  case 8:
14779  return 33661;
14780  case 3: // yellow
14781  case 4:
14782  return 33664;
14783  case 2: // White
14784  return 33663;
14785  default: // original - Gray
14786  return 33660;
14787  }
14788  }
14789  }
14790  // Based on Skin color
14791  else if (getRace() == RACE_TAUREN)
14792  {
14794  // Male
14795  if (getGender() == GENDER_MALE)
14796  {
14797  switch (skinColor)
14798  {
14799  case 12: // White
14800  case 13:
14801  case 14:
14802  case 18: // Completly White
14803  return 29409;
14804  case 9: // Light Brown
14805  case 10:
14806  case 11:
14807  return 29410;
14808  case 6: // Brown
14809  case 7:
14810  case 8:
14811  return 29411;
14812  case 0: // Dark
14813  case 1:
14814  case 2:
14815  case 3: // Dark Grey
14816  case 4:
14817  case 5:
14818  return 29412;
14819  default: // original - Grey
14820  return 8571;
14821  }
14822  }
14823  // Female
14824  else
14825  {
14826  switch (skinColor)
14827  {
14828  case 10: // White
14829  return 29409;
14830  case 6: // Light Brown
14831  case 7:
14832  return 29410;
14833  case 4: // Brown
14834  case 5:
14835  return 29411;
14836  case 0: // Dark
14837  case 1:
14838  case 2:
14839  case 3:
14840  return 29412;
14841  default: // original - Grey
14842  return 8571;
14843  }
14844  }
14845  }
14846  else if (Player::TeamForRace(getRace()) == ALLIANCE)
14847  return 892;
14848  else
14849  return 8571;
14850  case FORM_BEAR:
14851  // Based on Hair color
14852  if (getRace() == RACE_NIGHTELF)
14853  {
14855  switch (hairColor)
14856  {
14857  case 0: // Green
14858  case 1: // Light Green
14859  case 2: // Dark Green
14860  return 29413; // 29415?
14861  case 6: // Dark Blue
14862  return 29414;
14863  case 4: // White
14864  return 29416;
14865  case 3: // Light Blue
14866  return 29417;
14867  default: // original - Violet
14868  return 2281;
14869  }
14870  }
14871  else if (getRace() == RACE_TROLL)
14872  {
14874  switch (hairColor)
14875  {
14876  case 0: // Red
14877  case 1:
14878  return 33657;
14879  case 2: // Yellow
14880  case 3:
14881  return 33659;
14882  case 7: // Purple
14883  case 10:
14884  return 33656;
14885  case 8: // White
14886  case 9:
14887  case 11:
14888  case 12:
14889  return 33658;
14890  default: // original - Blue
14891  return 33655;
14892  }
14893  }
14894  else if (getRace() == RACE_WORGEN)
14895  {
14896  // Based on Skin color
14898  // Male
14899  if (getGender() == GENDER_MALE)
14900  {
14901  switch (skinColor)
14902  {
14903  case 1: // Brown
14904  return 33652;
14905  case 2: // Black
14906  case 7:
14907  return 33651;
14908  case 4: // Yellow
14909  return 33653;
14910  case 3: // White
14911  case 5:
14912  return 33654;
14913  default: // original - Gray
14914  return 33650;
14915  }
14916  }
14917  // Female
14918  else
14919  {
14920  switch (skinColor)
14921  {
14922  case 5: // Brown
14923  case 6:
14924  return 33652;
14925  case 7: // Black
14926  case 8:
14927  return 33651;
14928  case 3: // yellow
14929  case 4:
14930  return 33654;
14931  case 2: // White
14932  return 33653;
14933  default: // original - Gray
14934  return 33650;
14935  }
14936  }
14937  }
14938  // Based on Skin color
14939  else if (getRace() == RACE_TAUREN)
14940  {
14942  // Male
14943  if (getGender() == GENDER_MALE)
14944  {
14945  switch (skinColor)
14946  {
14947  case 0: // Dark (Black)
14948  case 1:
14949  case 2:
14950  return 29418;
14951  case 3: // White
14952  case 4:
14953  case 5:
14954  case 12:
14955  case 13:
14956  case 14:
14957  return 29419;
14958  case 9: // Light Brown/Grey
14959  case 10:
14960  case 11:
14961  case 15:
14962  case 16:
14963  case 17:
14964  return 29420;
14965  case 18: // Completly White
14966  return 29421;
14967  default: // original - Brown
14968  return 2289;
14969  }
14970  }
14971  // Female
14972  else
14973  {
14974  switch (skinColor)
14975  {
14976  case 0: // Dark (Black)
14977  case 1:
14978  return 29418;
14979  case 2: // White
14980  case 3:
14981  return 29419;
14982  case 6: // Light Brown/Grey
14983  case 7:
14984  case 8:
14985  case 9:
14986  return 29420;
14987  case 10: // Completly White
14988  return 29421;
14989  default: // original - Brown
14990  return 2289;
14991  }
14992  }
14993  }
14994  else if (Player::TeamForRace(getRace()) == ALLIANCE)
14995  return 2281;
14996  else
14997  return 2289;
14998  case FORM_FLIGHT:
14999  if (Player::TeamForRace(getRace()) == ALLIANCE)
15000  return 20857;
15001  return 20872;
15002  case FORM_FLIGHT_EPIC:
15003  if (Player::TeamForRace(getRace()) == ALLIANCE)
15004  return (getRace() == RACE_WORGEN ? 37729 : 21243);
15005  if (getRace() == RACE_TROLL)
15006  return 37730;
15007  return 21244;
15008  case FORM_MOONKIN:
15009  switch (getRace())
15010  {
15011  case RACE_NIGHTELF:
15012  return 15374;
15013  case RACE_TAUREN:
15014  return 15375;
15015  case RACE_WORGEN:
15016  return 37173;
15017  case RACE_TROLL:
15018  return 37174;
15019  default:
15020  break;
15021  }
15022  break;
15023  case FORM_GHOSTWOLF:
15024  if (HasAura(58135))
15025  return 27312;
15026  default:
15027  break;
15028  }
15029  }
15030 
15031  uint32 modelid = 0;
15032  SpellShapeshiftFormEntry const* formEntry = sSpellShapeshiftFormStore.LookupEntry(form);
15033  if (formEntry && formEntry->CreatureDisplayID[0])
15034  {
15035  // Take the alliance modelid as default
15036  if (GetTypeId() != TYPEID_PLAYER)
15037  return formEntry->CreatureDisplayID[0];
15038  else
15039  {
15040  if (Player::TeamForRace(getRace()) == ALLIANCE)
15041  modelid = formEntry->CreatureDisplayID[0];
15042  else
15043  modelid = formEntry->CreatureDisplayID[1];
15044 
15045  // If the player is horde but there are no values for the horde modelid - take the alliance modelid
15046  if (!modelid && Player::TeamForRace(getRace()) == HORDE)
15047  modelid = formEntry->CreatureDisplayID[0];
15048  }
15049  }
15050 
15051  return modelid;
15052 }
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
Definition: SharedDefines.h:105
Definition: Unit.h:289
Definition: SharedDefines.h:107
Definition: SharedDefines.h:1000
Definition: SharedDefines.h:93
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:263
Definition: SharedDefines.h:123
uint32_t uint32
Definition: Define.h:150
Definition: Unit.h:291
Definition: DBCStructure.h:1160
Definition: Player.h:571
Definition: SharedDefines.h:999
Definition: Unit.h:267
uint8 getRace() const
Definition: Unit.h:1411
Definition: ObjectGuid.h:33
Definition: Unit.h:278
uint8 getGender() const
Definition: Unit.h:1415
Definition: Unit.h:287
uint8_t uint8
Definition: Define.h:152
Definition: SharedDefines.h:109
uint32 CreatureDisplayID[4]
Definition: DBCStructure.h:1169
DBCStorage< SpellShapeshiftFormEntry > sSpellShapeshiftFormStore(SpellShapeshiftFormfmt)
Definition: UpdateFields.h:196
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318
Definition: Player.h:574

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetModelForTotem ( PlayerTotemType  totemType)
15055 {
15056  switch (getRace())
15057  {
15058  case RACE_ORC:
15059  {
15060  switch (totemType)
15061  {
15062  case SUMMON_TYPE_TOTEM_FIRE: // fire
15063  return 30758;
15064  case SUMMON_TYPE_TOTEM_EARTH: // earth
15065  return 30757;
15066  case SUMMON_TYPE_TOTEM_WATER: // water
15067  return 30759;
15068  case SUMMON_TYPE_TOTEM_AIR: // air
15069  return 30756;
15070  }
15071  break;
15072  }
15073  case RACE_DWARF:
15074  {
15075  switch (totemType)
15076  {
15077  case SUMMON_TYPE_TOTEM_FIRE: // fire
15078  return 30754;
15079  case SUMMON_TYPE_TOTEM_EARTH: // earth
15080  return 30753;
15081  case SUMMON_TYPE_TOTEM_WATER: // water
15082  return 30755;
15083  case SUMMON_TYPE_TOTEM_AIR: // air
15084  return 30736;
15085  }
15086  break;
15087  }
15088  case RACE_TROLL:
15089  {
15090  switch (totemType)
15091  {
15092  case SUMMON_TYPE_TOTEM_FIRE: // fire
15093  return 30762;
15094  case SUMMON_TYPE_TOTEM_EARTH: // earth
15095  return 30761;
15096  case SUMMON_TYPE_TOTEM_WATER: // water
15097  return 30763;
15098  case SUMMON_TYPE_TOTEM_AIR: // air
15099  return 30760;
15100  }
15101  break;
15102  }
15103  case RACE_TAUREN:
15104  {
15105  switch (totemType)
15106  {
15107  case SUMMON_TYPE_TOTEM_FIRE: // fire
15108  return 4589;
15109  case SUMMON_TYPE_TOTEM_EARTH: // earth
15110  return 4588;
15111  case SUMMON_TYPE_TOTEM_WATER: // water
15112  return 4587;
15113  case SUMMON_TYPE_TOTEM_AIR: // air
15114  return 4590;
15115  }
15116  break;
15117  }
15118  case RACE_DRAENEI:
15119  {
15120  switch (totemType)
15121  {
15122  case SUMMON_TYPE_TOTEM_FIRE: // fire
15123  return 19074;
15124  case SUMMON_TYPE_TOTEM_EARTH: // earth
15125  return 19073;
15126  case SUMMON_TYPE_TOTEM_WATER: // water
15127  return 19075;
15128  case SUMMON_TYPE_TOTEM_AIR: // air
15129  return 19071;
15130  }
15131  break;
15132  }
15133  case RACE_GOBLIN:
15134  {
15135  switch (totemType)
15136  {
15137  case SUMMON_TYPE_TOTEM_FIRE: // fire
15138  return 30783;
15139  case SUMMON_TYPE_TOTEM_EARTH: // earth
15140  return 30782;
15141  case SUMMON_TYPE_TOTEM_WATER: // water
15142  return 30784;
15143  case SUMMON_TYPE_TOTEM_AIR: // air
15144  return 30781;
15145  }
15146  break;
15147  }
15148  }
15149  return 0;
15150 }
Definition: Unit.h:1293
Definition: SharedDefines.h:110
Definition: SharedDefines.h:112
Definition: SharedDefines.h:107
Definition: Unit.h:1292
Definition: Unit.h:1291
Definition: SharedDefines.h:104
Definition: Unit.h:1294
Definition: SharedDefines.h:103
uint8 getRace() const
Definition: Unit.h:1411
Definition: SharedDefines.h:109

+ Here is the call graph for this function:

float Unit::GetModifierValue ( UnitMods  unitMod,
UnitModifierType  modifierType 
) const
11389 {
11390  if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END)
11391  {
11392  TC_LOG_ERROR("entities.unit", "attempt to access non-existing modifier value from UnitMods!");
11393  return 0.0f;
11394  }
11395 
11396  if (modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f)
11397  return 0.0f;
11398 
11399  return m_auraModifiersGroup[unitMod][modifierType];
11400 }
Definition: Unit.h:513
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2285
Definition: Unit.h:438
Definition: Unit.h:439
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the caller graph for this function:

MotionMaster* Unit::GetMotionMaster ( )
inline
2101 { return i_motionMaster; }
MotionMaster * i_motionMaster
Definition: Unit.h:2297
const MotionMaster* Unit::GetMotionMaster ( ) const
inline
2102 { return i_motionMaster; }
MotionMaster * i_motionMaster
Definition: Unit.h:2297
MountCapabilityEntry const * Unit::GetMountCapability ( uint32  mountType) const
9774 {
9775  if (!mountType)
9776  return nullptr;
9777 
9778  DB2Manager::MountTypeXCapabilitySet const* capabilities = sDB2Manager.GetMountCapabilities(mountType);
9779  if (!capabilities)
9780  return nullptr;
9781 
9782  uint32 zoneId, areaId;
9783  GetZoneAndAreaId(zoneId, areaId);
9784  uint32 ridingSkill = 5000;
9785  if (GetTypeId() == TYPEID_PLAYER)
9786  ridingSkill = ToPlayer()->GetSkillValue(SKILL_RIDING);
9787 
9788  for (MountTypeXCapabilityEntry const* mountTypeXCapability : *capabilities)
9789  {
9790  MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(mountTypeXCapability->MountCapabilityID);
9791  if (!mountCapability)
9792  continue;
9793 
9794  if (ridingSkill < mountCapability->RequiredRidingSkill)
9795  continue;
9796 
9798  {
9799  if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_CAN_PITCH))
9800  continue;
9801  }
9803  {
9804  if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_CAN_SWIM))
9805  continue;
9806  }
9807  else if (!(mountCapability->Flags & 0x1)) // unknown flags, checked in 4.2.2 14545 client
9808  {
9809  if (!(mountCapability->Flags & 0x2))
9810  continue;
9811  }
9812 
9813  if (mountCapability->RequiredMap != -1 && int32(GetMapId()) != mountCapability->RequiredMap)
9814  continue;
9815 
9816  if (mountCapability->RequiredArea && (mountCapability->RequiredArea != zoneId && mountCapability->RequiredArea != areaId))
9817  continue;
9818 
9819  if (mountCapability->RequiredAura && !HasAura(mountCapability->RequiredAura))
9820  continue;
9821 
9822  if (mountCapability->RequiredSpell && (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->HasSpell(mountCapability->RequiredSpell)))
9823  continue;
9824 
9825  return mountCapability;
9826  }
9827 
9828  return nullptr;
9829 }
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
#define sDB2Manager
Definition: DB2Stores.h:224
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
uint32 RequiredAura
Definition: DB2Structure.h:933
Definition: DBCEnums.h:589
uint32 RequiredArea
Definition: DB2Structure.h:932
std::set< MountTypeXCapabilityEntry const *, MountTypeXCapabilityEntryComparator > MountTypeXCapabilitySet
Definition: DB2Stores.h:154
virtual bool HasSpell(uint32) const
Definition: Unit.h:1593
uint32 RequiredSpell
Definition: DB2Structure.h:934
Player * ToPlayer()
Definition: Object.h:191
Definition: DBCEnums.h:588
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:4010
Definition: Unit.h:796
int32_t int32
Definition: Define.h:146
Definition: Unit.h:840
uint32_t uint32
Definition: Define.h:150
uint32 GetMapId() const
Definition: Position.h:254
Definition: ObjectGuid.h:33
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.cpp:1535
Definition: DB2Structure.h:939
uint16 HasExtraUnitMovementFlag(uint16 f) const
Definition: Unit.h:2115
Definition: DB2Structure.h:927
uint32 Flags
Definition: DB2Structure.h:930
DB2Storage< MountCapabilityEntry > sMountCapabilityStore("MountCapability.db2", MountCapabilityFormat, HOTFIX_SEL_MOUNT_CAPABILITY)
int32 RequiredMap
Definition: DB2Structure.h:936

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetMountID ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:119

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16 Unit::GetMovementAnimKitId ( ) const
inlineoverridevirtual

Reimplemented from WorldObject.

1507 { return _movementAnimKitId; }
uint16 _movementAnimKitId
Definition: Unit.h:2359
uint32 Unit::GetNativeDisplayId ( ) const
inline
Definition: UpdateFields.h:118
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetNegStat ( Stats  stat) const
inline
1901 { return GetFloatValue(UNIT_FIELD_NEGSTAT+stat); }
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
Definition: UpdateFields.h:139

+ Here is the call graph for this function:

Unit * Unit::GetNextRandomRaidMemberOrPet ( float  radius)
8042 {
8043  Player* player = NULL;
8044  if (GetTypeId() == TYPEID_PLAYER)
8045  player = ToPlayer();
8046  // Should we enable this also for charmed units?
8047  else if (GetTypeId() == TYPEID_UNIT && IsPet())
8048  player = GetOwner()->ToPlayer();
8049 
8050  if (!player)
8051  return NULL;
8052  Group* group = player->GetGroup();
8053  // When there is no group check pet presence
8054  if (!group)
8055  {
8056  // We are pet now, return owner
8057  if (player != this)
8058  return IsWithinDistInMap(player, radius) ? player : NULL;
8059  Unit* pet = GetGuardianPet();
8060  // No pet, no group, nothing to return
8061  if (!pet)
8062  return NULL;
8063  // We are owner now, return pet
8064  return IsWithinDistInMap(pet, radius) ? pet : NULL;
8065  }
8066 
8067  std::vector<Unit*> nearMembers;
8068  // reserve place for players and pets because resizing vector every unit push is unefficient (vector is reallocated then)
8069  nearMembers.reserve(group->GetMembersCount() * 2);
8070 
8071  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
8072  if (Player* Target = itr->GetSource())
8073  {
8074  // IsHostileTo check duel and controlled by enemy
8075  if (Target != this && Target->IsAlive() && IsWithinDistInMap(Target, radius) && !IsHostileTo(Target))
8076  nearMembers.push_back(Target);
8077 
8078  // Push player's pet to vector
8079  if (Unit* pet = Target->GetGuardianPet())
8080  if (pet != this && pet->IsAlive() && IsWithinDistInMap(pet, radius) && !IsHostileTo(pet))
8081  nearMembers.push_back(pet);
8082  }
8083 
8084  if (nearMembers.empty())
8085  return NULL;
8086 
8087  uint32 randTarget = urand(0, nearMembers.size()-1);
8088  return nearMembers[randTarget];
8089 }
Guardian * GetGuardianPet() const
Definition: Unit.cpp:7596
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
uint32_t uint32
Definition: Define.h:150
GroupReference * GetFirstMember()
Definition: Group.h:295
bool IsPet() const
Definition: Unit.h:1403
Definition: ObjectGuid.h:33
uint32 GetMembersCount() const
Definition: Group.h:297
Unit * GetOwner() const
Definition: Unit.cpp:7542
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7165
Definition: Unit.h:1305
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Aura * Unit::GetOwnedAura ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
ObjectGuid  itemCasterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0,
Aura except = NULL 
) const
3427 {
3428  AuraMapBounds range = m_ownedAuras.equal_range(spellId);
3429  for (AuraMap::const_iterator itr = range.first; itr != range.second; ++itr)
3430  {
3431  if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask)
3432  && (!casterGUID || itr->second->GetCasterGUID() == casterGUID)
3433  && (!itemCasterGUID || itr->second->GetCastItemGUID() == itemCasterGUID)
3434  && (!except || except != itr->second))
3435  {
3436  return itr->second;
3437  }
3438  }
3439  return NULL;
3440 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
arena_t NULL
Definition: jemalloc_internal.h:624
std::pair< AuraMap::const_iterator, AuraMap::const_iterator > AuraMapBounds
Definition: Unit.h:1312

+ Here is the caller graph for this function:

AuraMap& Unit::GetOwnedAuras ( )
inline
1779 { return m_ownedAuras; }
AuraMap m_ownedAuras
Definition: Unit.h:2273

+ Here is the caller graph for this function:

AuraMap const& Unit::GetOwnedAuras ( ) const
inline
1780 { return m_ownedAuras; }
AuraMap m_ownedAuras
Definition: Unit.h:2273
Unit * Unit::GetOwner ( ) const
7543 {
7544  ObjectGuid ownerGUID = GetOwnerGUID();
7545  if (!ownerGUID.IsEmpty())
7546  return ObjectAccessor::GetUnit(*this, ownerGUID);
7547 
7548  return NULL;
7549 }
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: ObjectGuid.h:189
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

ObjectGuid Unit::GetOwnerGUID ( ) const
inline
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332
Definition: UpdateFields.h:86

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::GetPartyMembers ( std::list< Unit * > &  units)
14411 {
14412  Unit* owner = GetCharmerOrOwnerOrSelf();
14413  Group* group = NULL;
14414  if (owner->GetTypeId() == TYPEID_PLAYER)
14415  group = owner->ToPlayer()->GetGroup();
14416 
14417  if (group)
14418  {
14419  uint8 subgroup = owner->ToPlayer()->GetSubGroup();
14420 
14421  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
14422  {
14423  Player* Target = itr->GetSource();
14424 
14425  // IsHostileTo check duel and controlled by enemy
14426  if (Target && Target->GetSubGroup() == subgroup && !IsHostileTo(Target))
14427  {
14428  if (Target->IsAlive() && IsInMap(Target))
14429  TagUnitMap.push_back(Target);
14430 
14431  if (Guardian* pet = Target->GetGuardianPet())
14432  if (pet->IsAlive() && IsInMap(Target))
14433  TagUnitMap.push_back(pet);
14434  }
14435  }
14436  }
14437  else
14438  {
14439  if (owner->IsAlive() && (owner == this || IsInMap(owner)))
14440  TagUnitMap.push_back(owner);
14441  if (Guardian* pet = owner->GetGuardianPet())
14442  if (pet->IsAlive() && (pet == this || IsInMap(pet)))
14443  TagUnitMap.push_back(pet);
14444  }
14445 }
Definition: TemporarySummon.h:83
Guardian * GetGuardianPet() const
Definition: Unit.cpp:7596
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1631
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
GroupReference * GetFirstMember()
Definition: Group.h:295
Definition: ObjectGuid.h:33
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7165
uint8_t uint8
Definition: Define.h:152
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Unit.cpp:7632
Definition: Unit.h:1305
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

ObjectGuid Unit::GetPetGUID ( ) const
inline
1708 { return m_SummonSlot[SUMMON_SLOT_PET]; }
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
#define SUMMON_SLOT_PET
Definition: Unit.h:1280

+ Here is the caller graph for this function:

float Unit::GetPositionZMinusOffset ( ) const
13800 {
13801  float offset = 0.0f;
13804 
13805  return GetPositionZ() - offset;
13806 }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
Definition: UpdateFields.h:160
Definition: Unit.h:804
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
float GetPositionZ() const
Definition: Position.h:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetPosStat ( Stats  stat) const
inline
1900 { return GetFloatValue(UNIT_FIELD_POSSTAT+stat); }
Definition: UpdateFields.h:138
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312

+ Here is the call graph for this function:

int32 Unit::GetPower ( Powers  power) const
11590 {
11591  uint32 powerIndex = GetPowerIndex(power);
11592  if (powerIndex == MAX_POWERS || powerIndex >= MAX_POWERS_PER_CLASS)
11593  return 0;
11594 
11595  return GetUInt32Value(UNIT_FIELD_POWER + powerIndex);
11596 }
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
#define MAX_POWERS_PER_CLASS
Definition: SharedDefines.h:270
Definition: UpdateFields.h:100
uint32_t uint32
Definition: Define.h:150
uint32 GetPowerIndex(uint32 powerType) const
Definition: Unit.cpp:11666
Definition: SharedDefines.h:265

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetPowerIndex ( uint32  powerType) const

This is here because hunter pets are of the warrior class. With the current implementation, the core only gives them POWER_RAGE, so we enforce the class to hunter so that they effectively get focus power.

11667 {
11672  uint32 classId = getClass();
11673  if (ToPet() && ToPet()->getPetType() == HUNTER_PET)
11674  classId = CLASS_HUNTER;
11675 
11676  return sDB2Manager.GetPowerIndexByClass(powerType, classId);
11677 }
#define sDB2Manager
Definition: DB2Stores.h:224
Pet * ToPet()
Definition: Unit.h:2200
Definition: PetDefines.h:25
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:169
uint8 getClass() const
Definition: Unit.h:1413

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetPowerPct ( Powers  power) const
inline
1449 { return GetMaxPower(power) ? 100.f * GetPower(power) / GetMaxPower(power) : 0.0f; }
int32 GetPower(Powers power) const
Definition: Unit.cpp:11589
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598

+ Here is the caller graph for this function:

Powers Unit::getPowerType ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:97
Powers
Definition: SharedDefines.h:246

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Powers Unit::GetPowerTypeByAuraGroup ( UnitMods  unitMod) const
11478 {
11479  switch (unitMod)
11480  {
11481  case UNIT_MOD_RAGE: return POWER_RAGE;
11482  case UNIT_MOD_FOCUS: return POWER_FOCUS;
11483  case UNIT_MOD_ENERGY: return POWER_ENERGY;
11484  case UNIT_MOD_RUNE: return POWER_RUNES;
11486  default:
11487  case UNIT_MOD_MANA: return POWER_MANA;
11488  }
11489 }
Definition: Unit.h:492
Definition: SharedDefines.h:254
Definition: SharedDefines.h:249
Definition: SharedDefines.h:253
Definition: Unit.h:496
Definition: SharedDefines.h:250
Definition: Unit.h:495
Definition: Unit.h:490
Definition: SharedDefines.h:251
Definition: Unit.h:491
Definition: Unit.h:493
Definition: SharedDefines.h:248

+ Here is the caller graph for this function:

float Unit::GetPPMProcChance ( uint32  WeaponSpeed,
float  PPM,
const SpellInfo spellProto 
) const
9682 {
9683  // proc per minute chance calculation
9684  if (PPM <= 0)
9685  return 0.0f;
9686 
9687  // Apply chance modifer aura
9688  if (spellProto)
9689  if (Player* modOwner = GetSpellModOwner())
9690  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_PROC_PER_MINUTE, PPM);
9691 
9692  return std::floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60))
9693 }
uint32 Id
Definition: SpellInfo.h:329
static Vector3int16 floor(const Vector3 &v)
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Definition: Unit.h:112

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::GetProcAurasTriggeredOnEvent ( AuraApplicationList aurasTriggeringProc,
AuraApplicationList procAuras,
ProcEventInfo  eventInfo 
)
12609 {
12610  // use provided list of auras which can proc
12611  if (procAuras)
12612  {
12613  for (std::list<AuraApplication*>::iterator itr = procAuras->begin(); itr!= procAuras->end(); ++itr)
12614  {
12615  ASSERT((*itr)->GetTarget() == this);
12616  if (!(*itr)->GetRemoveMode())
12617  if ((*itr)->GetBase()->IsProcTriggeredOnEvent(*itr, eventInfo))
12618  {
12619  (*itr)->GetBase()->PrepareProcToTrigger(*itr, eventInfo);
12620  aurasTriggeringProc.push_back(*itr);
12621  }
12622  }
12623  }
12624  // or generate one on our own
12625  else
12626  {
12627  for (AuraApplicationMap::iterator itr = GetAppliedAuras().begin(); itr!= GetAppliedAuras().end(); ++itr)
12628  {
12629  if (itr->second->GetBase()->IsProcTriggeredOnEvent(itr->second, eventInfo))
12630  {
12631  itr->second->GetBase()->PrepareProcToTrigger(itr->second, eventInfo);
12632  aurasTriggeringProc.push_back(itr->second);
12633  }
12634  }
12635  }
12636 }
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8 Unit::getRace ( ) const
inline
Definition: UpdateFields.h:96
Definition: Unit.h:232
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::getRaceMask ( ) const
inline
1412 { return 1 << (getRace()-1); }
uint8 getRace() const
Definition: Unit.h:1411
void Unit::GetRandomContactPoint ( const Unit target,
float &  x,
float &  y,
float &  z,
float  distance2dMin,
float  distance2dMax 
) const
525 {
526  float combat_reach = GetCombatReach();
527  if (combat_reach < 0.1f) // sometimes bugged for players
528  combat_reach = DEFAULT_COMBAT_REACH;
529 
530  uint32 attacker_number = uint32(getAttackers().size());
531  if (attacker_number > 0)
532  --attacker_number;
533  GetNearPoint(obj, x, y, z, obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin) * (float)rand_norm(),
534  GetAngle(obj) + (attacker_number ? (static_cast<float>(M_PI/2) - static_cast<float>(M_PI) * (float)rand_norm()) * float(attacker_number) / combat_reach * 0.3f : 0));
535 }
#define M_PI
Definition: Common.h:163
float GetCombatReach() const
Definition: Unit.h:1361
AttackerSet const & getAttackers() const
Definition: Unit.h:1377
G3D::int16 z
Definition: Vector3int16.h:46
float GetAngle(Position const *pos) const
Definition: Position.cpp:63
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
double rand_norm()
Definition: Random.cpp:69
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
Definition: Object.cpp:2587
#define DEFAULT_COMBAT_REACH
Definition: Object.h:45

+ Here is the call graph for this function:

ReputationRank Unit::GetReactionTo ( Unit const target) const
7036 {
7037  // always friendly to self
7038  if (this == target)
7039  return REP_FRIENDLY;
7040 
7041  // always friendly to charmer or owner
7043  return REP_FRIENDLY;
7044 
7045  Player const* selfPlayerOwner = GetAffectingPlayer();
7046  Player const* targetPlayerOwner = target->GetAffectingPlayer();
7047 
7048  // check forced reputation to support SPELL_AURA_FORCE_REACTION
7049  if (selfPlayerOwner)
7050  {
7051  if (FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry())
7052  if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry))
7053  return *repRank;
7054  }
7055  else if (targetPlayerOwner)
7056  {
7057  if (FactionTemplateEntry const* selfFactionTemplateEntry = GetFactionTemplateEntry())
7058  if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(selfFactionTemplateEntry))
7059  return *repRank;
7060  }
7061 
7063  {
7064  if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
7065  {
7066  if (selfPlayerOwner && targetPlayerOwner)
7067  {
7068  // always friendly to other unit controlled by player, or to the player himself
7069  if (selfPlayerOwner == targetPlayerOwner)
7070  return REP_FRIENDLY;
7071 
7072  // duel - always hostile to opponent
7073  if (selfPlayerOwner->duel && selfPlayerOwner->duel->opponent == targetPlayerOwner && selfPlayerOwner->duel->startTime != 0)
7074  return REP_HOSTILE;
7075 
7076  // same group - checks dependant only on our faction - skip FFA_PVP for example
7077  if (selfPlayerOwner->IsInRaidWith(targetPlayerOwner))
7078  return REP_FRIENDLY; // return true to allow config option AllowTwoSide.Interaction.Group to work
7079  // however client seems to allow mixed group parties, because in 13850 client it works like:
7080  // return GetFactionReactionTo(GetFactionTemplateEntry(), target);
7081  }
7082 
7083  // check FFA_PVP
7085  && target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP)
7086  return REP_HOSTILE;
7087 
7088  if (selfPlayerOwner)
7089  {
7090  if (FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry())
7091  {
7092  if (!selfPlayerOwner->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_IGNORE_REPUTATION))
7093  {
7094  if (FactionEntry const* targetFactionEntry = sFactionStore.LookupEntry(targetFactionTemplateEntry->Faction))
7095  {
7096  if (targetFactionEntry->CanHaveReputation())
7097  {
7098  // check contested flags
7099  if (targetFactionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD
7100  && selfPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
7101  return REP_HOSTILE;
7102 
7103  // if faction has reputation, hostile state depends only from AtWar state
7104  if (selfPlayerOwner->GetReputationMgr().IsAtWar(targetFactionEntry))
7105  return REP_HOSTILE;
7106  return REP_FRIENDLY;
7107  }
7108  }
7109  }
7110  }
7111  }
7112  }
7113  }
7114  // do checks dependant only on our faction
7116 }
static ReputationRank GetFactionReactionTo(FactionTemplateEntry const *factionTemplateEntry, Unit const *target)
Definition: Unit.cpp:7118
Definition: Player.h:525
Definition: UpdateFields.h:146
ReputationRank
Definition: SharedDefines.h:211
Definition: Unit.h:310
Definition: UpdateFields.h:110
Player * GetAffectingPlayer() const
Definition: Unit.cpp:7569
Definition: SharedDefines.h:217
Definition: SharedDefines.h:214
Definition: DBCEnums.h:463
Definition: Unit.h:713
Definition: DBCStructure.h:433
Definition: Unit.h:676
Definition: DBCStructure.h:405
Definition: UpdateFields.h:109
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Unit.cpp:7632
Definition: UpdateFields.h:191
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7019
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetRedirectThreatPercent ( ) const
inline
2157 { return _redirectThreadInfo.GetThreatPct(); }
uint32 GetThreatPct() const
Definition: Unit.h:1084
RedirectThreatInfo _redirectThreadInfo
Definition: Unit.h:2350

+ Here is the caller graph for this function:

Unit * Unit::GetRedirectThreatTarget ( )
14298 {
14300 }
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
arena_t NULL
Definition: jemalloc_internal.h:624
ObjectGuid GetTargetGUID() const
Definition: Unit.h:1083
RedirectThreatInfo _redirectThreadInfo
Definition: Unit.h:2350
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetRemainingPeriodicAmount ( ObjectGuid  caster,
uint32  spellId,
AuraType  auraType,
uint8  effectIndex = 0 
) const
15668 {
15669  uint32 amount = 0;
15670  AuraEffectList const& periodicAuras = GetAuraEffectsByType(auraType);
15671  for (AuraEffectList::const_iterator i = periodicAuras.begin(); i != periodicAuras.end(); ++i)
15672  {
15673  if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || !(*i)->GetTotalTicks())
15674  continue;
15675  amount += uint32(((*i)->GetAmount() * std::max<int32>((*i)->GetTotalTicks() - int32((*i)->GetTickNumber()), 0)) / (*i)->GetTotalTicks());
15676  break;
15677  }
15678 
15679  return amount;
15680 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
int32_t int32
Definition: g3dmath.h:167
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetResistance ( SpellSchools  school) const
inline
1422 { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); }
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:140

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetResistance ( SpellSchoolMask  mask) const
15690 {
15691  int32 resist = -1;
15692  for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
15693  if (mask & (1 << i) && (resist < 0 || resist > int32(GetResistance(SpellSchools(i)))))
15694  resist = int32(GetResistance(SpellSchools(i)));
15695 
15696  // resist value will never be negative here
15697  return uint32(resist);
15698 }
SpellSchools
Definition: SharedDefines.h:272
#define MAX_SPELL_SCHOOL
Definition: SharedDefines.h:283
Definition: SharedDefines.h:274
int32_t int32
Definition: Define.h:146
int32_t int32
Definition: g3dmath.h:167
uint32 GetResistance(SpellSchools school) const
Definition: Unit.h:1422
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

float Unit::GetResistanceBuffMods ( SpellSchools  school,
bool  positive 
) const
4654 {
4656 }
Definition: UpdateFields.h:142
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
Definition: UpdateFields.h:141

+ Here is the call graph for this function:

uint32 Unit::GetSchoolImmunityMask ( ) const
9320 {
9321  uint32 mask = 0;
9322  SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_SCHOOL];
9323  for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
9324  mask |= itr->type;
9325 
9326  return mask;
9327 }
std::list< SpellImmune > SpellImmuneList
Definition: Unit.h:430
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:1862
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1988
ShapeshiftForm Unit::GetShapeshiftForm ( ) const
inline
ShapeshiftForm
Definition: Unit.h:260
Definition: UpdateFields.h:146
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SharedVisionList const& Unit::GetSharedVisionList ( )
inline
1754 { return m_sharedVision; }
SharedVisionList m_sharedVision
Definition: Unit.h:2293

+ Here is the caller graph for this function:

SheathState Unit::GetSheath ( ) const
inline
Definition: UpdateFields.h:146
SheathState
Definition: Unit.h:296
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the call graph for this function:

AuraList& Unit::GetSingleCastAuras ( )
inline
1833 { return m_scAuras; }
AuraList m_scAuras
Definition: Unit.h:2280

+ Here is the caller graph for this function:

AuraList const& Unit::GetSingleCastAuras ( ) const
inline
1834 { return m_scAuras; }
AuraList m_scAuras
Definition: Unit.h:2280
float Unit::GetSpeed ( UnitMoveType  mtype) const
10527 {
10528  return m_speed_rate[mtype]*(IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]);
10529 }
bool IsControlledByPlayer() const
Definition: Unit.h:1712
float m_speed_rate[MAX_MOVE_TYPE]
Definition: Unit.h:2290
float playerBaseMoveSpeed[MAX_MOVE_TYPE]
Definition: Unit.cpp:88
float baseMoveSpeed[MAX_MOVE_TYPE]
Definition: Unit.cpp:75

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetSpeedRate ( UnitMoveType  mtype) const
inline
2087 { return m_speed_rate[mtype]; }
float m_speed_rate[MAX_MOVE_TYPE]
Definition: Unit.h:2290

+ Here is the caller graph for this function:

SpellHistory* Unit::GetSpellHistory ( )
inline
1926 { return _spellHistory; }
SpellHistory * _spellHistory
Definition: Unit.h:2364

+ Here is the caller graph for this function:

SpellHistory const* Unit::GetSpellHistory ( ) const
inline
1927 { return _spellHistory; }
SpellHistory * _spellHistory
Definition: Unit.h:2364
float Unit::GetSpellMaxRangeForTarget ( Unit const target,
SpellInfo const spellInfo 
) const
11229 {
11230  if (!spellInfo->RangeEntry)
11231  return 0;
11232  if (spellInfo->RangeEntry->MaxRangeFriend == spellInfo->RangeEntry->MaxRangeHostile)
11233  return spellInfo->GetMaxRange();
11234  if (target == NULL)
11235  return spellInfo->GetMaxRange(true);
11236  return spellInfo->GetMaxRange(!IsHostileTo(target));
11237 }
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetSpellMinRangeForTarget ( Unit const target,
SpellInfo const spellInfo 
) const
11240 {
11241  if (!spellInfo->RangeEntry)
11242  return 0;
11243  if (spellInfo->RangeEntry->MinRangeFriend == spellInfo->RangeEntry->MinRangeHostile)
11244  return spellInfo->GetMinRange();
11245  return spellInfo->GetMinRange(!IsHostileTo(target));
11246 }
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * Unit::GetSpellModOwner ( ) const
12692 {
12693  if (Player* player = const_cast<Unit*>(this)->ToPlayer())
12694  return player;
12695 
12696  if (IsPet() || IsTotem())
12697  {
12698  if (Unit* owner = GetOwner())
12699  if (Player* player = owner->ToPlayer())
12700  return player;
12701  }
12702  return NULL;
12703 }
arena_t NULL
Definition: jemalloc_internal.h:624
Player * ToPlayer()
Definition: Object.h:191
bool IsPet() const
Definition: Unit.h:1403
bool IsTotem() const
Definition: Unit.h:1405
Unit * GetOwner() const
Definition: Unit.cpp:7542
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellSchools Unit::GetSpellSchoolByAuraGroup ( UnitMods  unitMod) const
11439 {
11441 
11442  switch (unitMod)
11443  {
11444  case UNIT_MOD_RESISTANCE_HOLY: school = SPELL_SCHOOL_HOLY; break;
11445  case UNIT_MOD_RESISTANCE_FIRE: school = SPELL_SCHOOL_FIRE; break;
11446  case UNIT_MOD_RESISTANCE_NATURE: school = SPELL_SCHOOL_NATURE; break;
11447  case UNIT_MOD_RESISTANCE_FROST: school = SPELL_SCHOOL_FROST; break;
11448  case UNIT_MOD_RESISTANCE_SHADOW: school = SPELL_SCHOOL_SHADOW; break;
11449  case UNIT_MOD_RESISTANCE_ARCANE: school = SPELL_SCHOOL_ARCANE; break;
11450 
11451  default:
11452  break;
11453  }
11454 
11455  return school;
11456 }
Definition: Unit.h:502
Definition: SharedDefines.h:278
Definition: SharedDefines.h:277
SpellSchools
Definition: SharedDefines.h:272
Definition: SharedDefines.h:275
Definition: SharedDefines.h:280
Definition: SharedDefines.h:276
Definition: Unit.h:504
Definition: Unit.h:503
Definition: SharedDefines.h:274
Definition: SharedDefines.h:279
Definition: Unit.h:506
Definition: Unit.h:507
Definition: Unit.h:505

+ Here is the caller graph for this function:

UnitStandStateType Unit::GetStandState ( ) const
inline
UnitStandStateType
Definition: Unit.h:205
Definition: UpdateFields.h:124
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetStat ( Stats  stat) const
inline
1417 { return float(GetUInt32Value(UNIT_FIELD_STAT+stat)); }
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Stats Unit::GetStatByAuraGroup ( UnitMods  unitMod) const
11459 {
11460  Stats stat = STAT_STRENGTH;
11461 
11462  switch (unitMod)
11463  {
11464  case UNIT_MOD_STAT_STRENGTH: stat = STAT_STRENGTH; break;
11465  case UNIT_MOD_STAT_AGILITY: stat = STAT_AGILITY; break;
11466  case UNIT_MOD_STAT_STAMINA: stat = STAT_STAMINA; break;
11467  case UNIT_MOD_STAT_INTELLECT: stat = STAT_INTELLECT; break;
11468  case UNIT_MOD_STAT_SPIRIT: stat = STAT_SPIRIT; break;
11469 
11470  default:
11471  break;
11472  }
11473 
11474  return stat;
11475 }
Definition: Unit.h:485
Definition: Unit.h:484
Definition: SharedDefines.h:239
Definition: Unit.h:488
Stats
Definition: SharedDefines.h:235
Definition: SharedDefines.h:238
Definition: SharedDefines.h:237
Definition: SharedDefines.h:240
Definition: Unit.h:486
Definition: Unit.h:487
Definition: SharedDefines.h:241

+ Here is the caller graph for this function:

ObjectGuid Unit::GetTarget ( ) const
inline
2209 { return GetGuidValue(UNIT_FIELD_TARGET); }
Definition: UpdateFields.h:89
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ThreatManager& Unit::getThreatManager ( )
inline
1998 { return m_ThreatManager; }
ThreatManager m_ThreatManager
Definition: Unit.h:2302
float Unit::GetTotalAttackPowerValue ( WeaponAttackType  attType) const
11492 {
11493  if (attType == RANGED_ATTACK)
11494  {
11496  if (ap < 0)
11497  return 0.0f;
11499  }
11500  else
11501  {
11503  if (ap < 0)
11504  return 0.0f;
11505  return ap * (1.0f + GetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER));
11506  }
11507 }
Definition: UpdateFields.h:150
Definition: Unit.h:619
Definition: UpdateFields.h:151
int32 GetInt32Value(uint16 index) const
Definition: Object.cpp:294
Definition: UpdateFields.h:154
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
int32_t int32
Definition: Define.h:146
Definition: UpdateFields.h:147

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetTotalAuraModifier ( AuraType  auratype) const
4397 {
4398  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4399  if (mTotalAuraList.empty())
4400  return 0;
4401 
4402  std::map<SpellGroup, int32> SameEffectSpellGroup;
4403  int32 modifier = 0;
4404 
4405  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4406  if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
4407  modifier += (*i)->GetAmount();
4408 
4409  for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
4410  modifier += itr->second;
4411 
4412  return modifier;
4413 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetTotalAuraModifierByAffectMask ( AuraType  auratype,
SpellInfo const affectedSpell 
) const
4588 {
4589  std::map<SpellGroup, int32> SameEffectSpellGroup;
4590  int32 modifier = 0;
4591 
4592  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4593  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4594  {
4595  if ((*i)->IsAffectingSpell(affectedSpell))
4596  if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
4597  modifier += (*i)->GetAmount();
4598  }
4599 
4600  for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
4601  modifier += itr->second;
4602 
4603  return modifier;
4604 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

int32 Unit::GetTotalAuraModifierByMiscMask ( AuraType  auratype,
uint32  misc_mask 
) const
4453 {
4454  std::map<SpellGroup, int32> SameEffectSpellGroup;
4455  int32 modifier = 0;
4456 
4457  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4458 
4459  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4460  if ((*i)->GetMiscValue() & miscMask)
4461  if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
4462  modifier += (*i)->GetAmount();
4463 
4464  for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
4465  modifier += itr->second;
4466 
4467  return modifier;
4468 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::GetTotalAuraModifierByMiscValue ( AuraType  auratype,
int32  misc_value 
) const
4522 {
4523  std::map<SpellGroup, int32> SameEffectSpellGroup;
4524  int32 modifier = 0;
4525 
4526  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4527  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4528  {
4529  if ((*i)->GetMiscValue() == miscValue)
4530  if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
4531  modifier += (*i)->GetAmount();
4532  }
4533 
4534  for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
4535  modifier += itr->second;
4536 
4537  return modifier;
4538 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetTotalAuraModValue ( UnitMods  unitMod) const
11420 {
11421  if (unitMod >= UNIT_MOD_END)
11422  {
11423  TC_LOG_ERROR("entities.unit", "attempt to access non-existing UnitMods in GetTotalAuraModValue()!");
11424  return 0.0f;
11425  }
11426 
11427  if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f)
11428  return 0.0f;
11429 
11431  value *= m_auraModifiersGroup[unitMod][BASE_PCT];
11432  value += m_auraModifiersGroup[unitMod][TOTAL_VALUE];
11433  value *= m_auraModifiersGroup[unitMod][TOTAL_PCT];
11434 
11435  return value;
11436 }
Definition: Unit.h:434
Definition: Unit.h:513
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2285
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: Unit.h:437
Definition: Unit.h:438
Definition: Unit.h:435
const FieldDescriptor value
Definition: descriptor.h:1522
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:436

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetTotalAuraMultiplier ( AuraType  auratype) const
4416 {
4417  float multiplier = 1.0f;
4418 
4419  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4420  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4421  AddPct(multiplier, (*i)->GetAmount());
4422 
4423  return multiplier;
4424 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
T AddPct(T &base, U pct)
Definition: Util.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetTotalAuraMultiplierByAffectMask ( AuraType  auratype,
SpellInfo const affectedSpell 
) const
4607 {
4608  std::map<SpellGroup, int32> SameEffectSpellGroup;
4609  float multiplier = 1.0f;
4610 
4611  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4612  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4613  {
4614  if ((*i)->IsAffectingSpell(affectedSpell))
4615  if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
4616  AddPct(multiplier, (*i)->GetAmount());
4617  }
4618 
4619  for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
4620  AddPct(multiplier, itr->second);
4621 
4622  return multiplier;
4623 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
#define sSpellMgr
Definition: SpellMgr.h:756
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
T AddPct(T &base, U pct)
Definition: Util.h:98

+ Here is the call graph for this function:

float Unit::GetTotalAuraMultiplierByMiscMask ( AuraType  auratype,
uint32  misc_mask 
) const
4471 {
4472  std::map<SpellGroup, int32> SameEffectSpellGroup;
4473  float multiplier = 1.0f;
4474 
4475  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4476  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4477  {
4478  if (((*i)->GetMiscValue() & miscMask))
4479  {
4480  // Check if the Aura Effect has a the Same Effect Stack Rule and if so, use the highest amount of that SpellGroup
4481  // If the Aura Effect does not have this Stack Rule, it returns false so we can add to the multiplier as usual
4482  if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
4483  AddPct(multiplier, (*i)->GetAmount());
4484  }
4485  }
4486  // Add the highest of the Same Effect Stack Rule SpellGroups to the multiplier
4487  for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
4488  AddPct(multiplier, itr->second);
4489 
4490  return multiplier;
4491 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
#define sSpellMgr
Definition: SpellMgr.h:756
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
T AddPct(T &base, U pct)
Definition: Util.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetTotalAuraMultiplierByMiscValue ( AuraType  auratype,
int32  misc_value 
) const
4541 {
4542  std::map<SpellGroup, int32> SameEffectSpellGroup;
4543  float multiplier = 1.0f;
4544 
4545  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4546  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4547  {
4548  if ((*i)->GetMiscValue() == miscValue)
4549  if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
4550  AddPct(multiplier, (*i)->GetAmount());
4551  }
4552 
4553  for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
4554  AddPct(multiplier, itr->second);
4555 
4556  return multiplier;
4557 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
#define sSpellMgr
Definition: SpellMgr.h:756
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
T AddPct(T &base, U pct)
Definition: Util.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetTotalStatValue ( Stats  stat) const
11403 {
11404  UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + stat);
11405 
11406  if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f)
11407  return 0.0f;
11408 
11409  // value = ((base_value * base_pct) + total_value) * total_pct
11411  value += GetCreateStat(stat);
11412  value *= m_auraModifiersGroup[unitMod][BASE_PCT];
11413  value += m_auraModifiersGroup[unitMod][TOTAL_VALUE];
11414  value *= m_auraModifiersGroup[unitMod][TOTAL_PCT];
11415 
11416  return value;
11417 }
UnitMods
Definition: Unit.h:482
Definition: Unit.h:434
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2285
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: Unit.h:437
Definition: Unit.h:438
Definition: Unit.h:435
Definition: Unit.h:515
float GetCreateStat(Stats stat) const
Definition: Unit.h:1902
const FieldDescriptor value
Definition: descriptor.h:1522
Definition: Unit.h:436

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::getTransForm ( ) const
inline
2018 { return m_transform;}
uint32 m_transform
Definition: Unit.h:2269

+ Here is the caller graph for this function:

ObjectGuid Unit::GetTransGUID ( ) const
overridevirtual

Reimplemented from WorldObject.

14356 {
14357  if (GetVehicle())
14358  return GetVehicleBase()->GetGUID();
14359  if (GetTransport())
14360  return GetTransport()->GetGUID();
14361 
14362  return ObjectGuid::Empty;
14363 }
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Transport * GetTransport() const
Definition: Object.h:602
Vehicle * GetVehicle() const
Definition: Unit.h:2166

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetUnitBlockChanceAgainst ( Unit const attacker) const
2594 {
2596  return 0.0f;
2597 
2598  if (Player const* player = ToPlayer())
2599  {
2600  if (player->CanBlock())
2601  {
2602  Item* tmpitem = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
2603  if (tmpitem && !tmpitem->IsBroken() && tmpitem->GetTemplate()->GetInventoryType() == INVTYPE_SHIELD)
2605  }
2606  // is player but has no block ability or no not broken shield equipped
2607  return 0.0f;
2608  }
2609  else
2610  {
2611  if (IsTotem())
2612  return 0.0f;
2613  else
2614  {
2615  float block = 3.0f;
2616  int32 levelDiff = getLevelForTarget(attacker) - attacker->getLevelForTarget(this);
2617  if (levelDiff > 0)
2618  block += 1.5f * levelDiff;
2620  return block > 0.0f ? block : 0.0f;
2621  }
2622  }
2623 }
#define INVENTORY_SLOT_BAG_0
uint8 getLevelForTarget(WorldObject const *) const override
Definition: Unit.h:1409
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Player * ToPlayer()
Definition: Object.h:191
InventoryType GetInventoryType() const
Definition: ItemTemplate.h:664
Definition: ItemTemplate.h:346
Definition: Item.h:259
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
int32_t int32
Definition: Define.h:146
Definition: Unit.h:587
bool IsBroken() const
Definition: Item.h:310
bool IsTotem() const
Definition: Unit.h:1405
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
Definition: SpellAuraDefines.h:111
Definition: UpdateFields.h:226
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetUnitCriticalChance ( WeaponAttackType  attackType,
const Unit victim 
) const
2626 {
2627  float crit;
2628 
2629  if (GetTypeId() == TYPEID_PLAYER)
2630  {
2631  switch (attackType)
2632  {
2633  case BASE_ATTACK:
2635  break;
2636  case OFF_ATTACK:
2638  break;
2639  case RANGED_ATTACK:
2641  break;
2642  // Just for good manner
2643  default:
2644  crit = 0.0f;
2645  break;
2646  }
2647  }
2648  else
2649  {
2650  crit = 5.0f;
2653  }
2654 
2655  // flat aura mods
2656  if (attackType == RANGED_ATTACK)
2658  else
2660 
2662 
2663  if (crit < 0.0f)
2664  crit = 0.0f;
2665  return crit;
2666 }
Definition: SpellAuraDefines.h:112
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: Unit.h:619
TypeID GetTypeId() const
Definition: Object.h:113
Definition: UpdateFields.h:229
Definition: Unit.h:618
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
Definition: UpdateFields.h:230
Definition: UpdateFields.h:231
Definition: SpellAuraDefines.h:247
Definition: ObjectGuid.h:33
Definition: SpellAuraDefines.h:248
Definition: SpellAuraDefines.h:350
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetUnitDodgeChanceAgainst ( Unit const attacker) const
2529 {
2531  return 0.0f;
2532 
2533  if (GetTypeId() == TYPEID_PLAYER)
2535  else
2536  {
2537  if (IsTotem())
2538  return 0.0f;
2539  else
2540  {
2541  float dodge = 3.0f + GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT);
2542  int32 levelDiff = getLevelForTarget(attacker) - attacker->getLevelForTarget(this);
2543  if (levelDiff > 0)
2544  dodge += 1.5f * levelDiff;
2545  return dodge > 0.0f ? dodge : 0.0f;
2546  }
2547  }
2548 }
uint8 getLevelForTarget(WorldObject const *) const override
Definition: Unit.h:1409
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
TypeID GetTypeId() const
Definition: Object.h:113
Definition: UpdateFields.h:227
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
int32_t int32
Definition: Define.h:146
Definition: Unit.h:587
Definition: SpellAuraDefines.h:109
Definition: ObjectGuid.h:33
bool IsTotem() const
Definition: Unit.h:1405
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetUnitMissChance ( WeaponAttackType  attType) const
2582 {
2583  float miss_chance = 5.00f;
2584 
2585  if (attType == RANGED_ATTACK)
2587  else
2589 
2590  return miss_chance;
2591 }
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: Unit.h:619
Definition: SpellAuraDefines.h:245
Definition: SpellAuraDefines.h:244

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::GetUnitMovementFlags ( ) const
inline
2110 { return m_movementInfo.GetMovementFlags(); }
MovementInfo m_movementInfo
Definition: Object.h:612
uint32 GetMovementFlags() const
Definition: Object.h:326

+ Here is the caller graph for this function:

float Unit::GetUnitParryChanceAgainst ( Unit const attacker) const
2551 {
2553  return 0.0f;
2554 
2555  float chance = 0.0f;
2556 
2557  if (Player const* player = ToPlayer())
2558  {
2559  if (player->CanParry())
2560  {
2561  Item* tmpitem = player->GetWeaponForAttack(BASE_ATTACK, true);
2562  if (!tmpitem)
2563  tmpitem = player->GetWeaponForAttack(OFF_ATTACK, true);
2564 
2565  if (tmpitem)
2567  }
2568  }
2569  else if (GetTypeId() == TYPEID_UNIT)
2570  {
2571  chance = 6.0f;
2572  int32 levelDiff = getLevelForTarget(attacker) - attacker->getLevelForTarget(this);
2573  if (levelDiff > 0)
2574  chance += 1.5f * levelDiff;
2576  }
2577 
2578  return chance > 0.0f ? chance : 0.0f;
2579 }
uint8 getLevelForTarget(WorldObject const *) const override
Definition: Unit.h:1409
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: SpellAuraDefines.h:107
Definition: ObjectGuid.h:32
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:618
Definition: Item.h:259
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
int32_t int32
Definition: Define.h:146
Definition: Unit.h:587
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
Definition: Unit.h:617
Definition: UpdateFields.h:228

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetUnitSpellCriticalChance ( Unit victim,
SpellInfo const spellProto,
SpellSchoolMask  schoolMask,
WeaponAttackType  attackType = BASE_ATTACK 
) const

Mobs can't crit with spells. Player Totems can Fire Elemental (from totem) can too - but this part is a hack and needs more research

Intentional fallback. Calculate critical strike chance for both Ranged and Melee spells

8649 {
8652  if (GetGUID().IsCreatureOrVehicle() && !(IsTotem() && GetOwnerGUID().IsPlayer()) && GetEntry() != 15438)
8653  return 0.0f;
8654 
8655  // not critting spell
8656  if ((spellProto->HasAttribute(SPELL_ATTR2_CANT_CRIT)))
8657  return 0.0f;
8658 
8659  float crit_chance = 0.0f;
8660  switch (spellProto->DmgClass)
8661  {
8663  // We need more spells to find a general way (if there is any)
8664  switch (spellProto->Id)
8665  {
8666  case 379: // Earth Shield
8667  case 33778: // Lifebloom Final Bloom
8668  case 64844: // Divine Hymn
8669  case 71607: // Item - Bauble of True Blood 10m
8670  case 71646: // Item - Bauble of True Blood 25m
8671  break;
8672  default:
8673  return 0.0f;
8674  }
8675  // Do not add a break here, case fallthrough is intentional! Adding a break will make above spells unable to crit.
8677  {
8678  if (schoolMask & SPELL_SCHOOL_MASK_NORMAL)
8679  crit_chance = 0.0f;
8680  // For other schools
8681  else if (GetTypeId() == TYPEID_PLAYER)
8683  else
8684  {
8685  crit_chance = (float)m_baseSpellCritChance;
8687  }
8688  // taken
8689  if (victim)
8690  {
8691  if (!spellProto->IsPositive())
8692  {
8693  // Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE
8695  // Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE
8697  }
8698  // scripted (increase crit chance ... against ... target by x%
8700  for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
8701  {
8702  if (!((*i)->IsAffectingSpell(spellProto)))
8703  continue;
8704 
8705  switch ((*i)->GetMiscValue())
8706  {
8707  case 911: // Shatter
8708  if (victim->HasAuraState(AURA_STATE_FROZEN, spellProto, this))
8709  {
8710  crit_chance *= 1.5f;
8711  if (AuraEffect const* eff = (*i)->GetBase()->GetEffect(EFFECT_1))
8712  crit_chance += eff->GetAmount();
8713  }
8714  break;
8715  case 7917: // Glyph of Shadowburn
8716  if (victim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
8717  crit_chance+=(*i)->GetAmount();
8718  break;
8719  case 7997: // Renewed Hope
8720  case 7998:
8721  if (victim->HasAura(6788))
8722  crit_chance+=(*i)->GetAmount();
8723  break;
8724  default:
8725  break;
8726  }
8727  }
8728  // Custom crit by class
8729  switch (spellProto->SpellFamilyName)
8730  {
8731  case SPELLFAMILY_MAGE:
8732  // Glyph of Fire Blast
8733  if (spellProto->SpellFamilyFlags[0] == 0x2 && spellProto->SpellIconID == 12)
8734  if (victim->HasAuraWithMechanic((1 << MECHANIC_STUN) | (1 << MECHANIC_KNOCKOUT)))
8735  if (AuraEffect const* aurEff = GetAuraEffect(56369, EFFECT_0))
8736  crit_chance += aurEff->GetAmount();
8737  break;
8738  case SPELLFAMILY_DRUID:
8739  // Improved Faerie Fire
8740  if (victim->HasAuraState(AURA_STATE_FAERIE_FIRE))
8741  if (AuraEffect const* aurEff = GetDummyAuraEffect(SPELLFAMILY_DRUID, 109, 0))
8742  crit_chance += aurEff->GetAmount();
8743 
8744  // cumulative effect - don't break
8745 
8746  // Starfire
8747  if (spellProto->SpellFamilyFlags[0] & 0x4 && spellProto->SpellIconID == 1485)
8748  {
8749  // Improved Insect Swarm
8750  if (AuraEffect const* aurEff = GetDummyAuraEffect(SPELLFAMILY_DRUID, 1771, 0))
8751  if (victim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, flag128(0x00000002, 0, 0)))
8752  crit_chance += aurEff->GetAmount();
8753  break;
8754  }
8755  break;
8756  case SPELLFAMILY_ROGUE:
8757  // Shiv-applied poisons can't crit
8758  if (FindCurrentSpellBySpellId(5938))
8759  crit_chance = 0.0f;
8760  break;
8761  case SPELLFAMILY_PALADIN:
8762  // Flash of light
8763  if (spellProto->SpellFamilyFlags[0] & 0x40000000)
8764  {
8765  // Sacred Shield
8766  if (AuraEffect const* aura = victim->GetAuraEffect(58597, 1, GetGUID()))
8767  crit_chance += aura->GetAmount();
8768  break;
8769  }
8770  // Exorcism
8771  else if (spellProto->GetCategory() == 19)
8772  {
8774  return 100.0f;
8775  break;
8776  }
8777  break;
8778  case SPELLFAMILY_SHAMAN:
8779  // Lava Burst
8780  if (spellProto->SpellFamilyFlags[1] & 0x00001000)
8781  {
8782  if (victim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, flag128(0x10000000, 0, 0), GetGUID()))
8784  return 100.0f;
8785  break;
8786  }
8787  break;
8788  }
8789  }
8790  break;
8791  }
8793  if (victim)
8794  {
8795  // Custom crit by class
8796  switch (spellProto->SpellFamilyName)
8797  {
8798  case SPELLFAMILY_DRUID:
8799  // Rend and Tear - bonus crit chance for Ferocious Bite on bleeding targets
8800  if (spellProto->SpellFamilyFlags[0] & 0x00800000
8801  && spellProto->SpellIconID == 1680
8802  && victim->HasAuraState(AURA_STATE_BLEEDING))
8803  {
8804  if (AuraEffect const* rendAndTear = GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 1))
8805  crit_chance += rendAndTear->GetAmount();
8806  break;
8807  }
8808  break;
8809  }
8810  }
8813  {
8814  if (victim)
8815  {
8816  crit_chance += GetUnitCriticalChance(attackType, victim);
8818  }
8819  break;
8820  }
8821  default:
8822  return 0.0f;
8823  }
8824  // percent done
8825  // only players use intelligence for critical chance computations
8826  if (Player* modOwner = GetSpellModOwner())
8827  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance);
8828 
8830  for (AuraEffectList::const_iterator i = critAuras.begin(); i != critAuras.end(); ++i)
8831  if ((*i)->GetCasterGUID() == GetGUID() && (*i)->IsAffectingSpell(spellProto))
8832  crit_chance += (*i)->GetAmount();
8833 
8834  return crit_chance > 0.0f ? crit_chance : 0.0f;
8835 }
uint32 GetCreatureTypeMask() const
Definition: Unit.cpp:11263
float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *victim) const
Definition: Unit.cpp:2625
Definition: SpellAuraEffects.h:30
Definition: SpellAuraDefines.h:63
Definition: SharedDefines.h:4633
SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask)
Definition: SharedDefines.h:309
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
Definition: SharedDefines.h:1802
Definition: SharedDefines.h:29
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition: Unit.cpp:2931
Definition: Unit.h:93
Definition: SharedDefines.h:28
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
int32 m_baseSpellCritChance
Definition: Unit.h:1942
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SharedDefines.h:2052
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
Definition: SpellAuraDefines.h:239
Definition: SharedDefines.h:2049
Definition: SharedDefines.h:1761
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:1771
AuraEffect * GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
Definition: Unit.cpp:4127
Definition: SharedDefines.h:4626
AuraEffect * GetEffect(uint32 index) const
Definition: SpellAuras.cpp:448
Definition: SpellAuraDefines.h:172
Definition: SharedDefines.h:288
Definition: SharedDefines.h:4634
Definition: SharedDefines.h:1776
Definition: Util.h:362
Definition: SharedDefines.h:4631
Definition: SpellAuraDefines.h:368
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: SharedDefines.h:457
Definition: SpellAuraDefines.h:131
Definition: SharedDefines.h:4630
Definition: SharedDefines.h:1770
Definition: UpdateFields.h:232
Definition: SharedDefines.h:2051
uint32 const CREATURE_TYPEMASK_DEMON_OR_UNDEAD
Definition: SharedDefines.h:3571
Definition: SharedDefines.h:2050
int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4452
bool HasAuraWithMechanic(uint32 mechanicMask) const
Definition: Unit.cpp:4311
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SharedDefines.h:1804
Definition: ObjectGuid.h:33
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
bool IsTotem() const
Definition: Unit.h:1405
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
uint32 GetEntry() const
Definition: Object.h:107
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Vehicle* Unit::GetVehicle ( ) const
inline
2166 { return m_vehicle; }
Vehicle * m_vehicle
Definition: Unit.h:2304

+ Here is the caller graph for this function:

Unit * Unit::GetVehicleBase ( ) const
14342 {
14343  return m_vehicle ? m_vehicle->GetBase() : NULL;
14344 }
arena_t NULL
Definition: jemalloc_internal.h:624
Vehicle * m_vehicle
Definition: Unit.h:2304
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Unit::GetVehicleCreatureBase ( ) const
14347 {
14348  if (Unit* veh = GetVehicleBase())
14349  if (Creature* c = veh->ToCreature())
14350  return c;
14351 
14352  return NULL;
14353 }
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Vehicle* Unit::GetVehicleKit ( ) const
inline
2165 { return m_vehicleKit; }
Vehicle * m_vehicleKit
Definition: Unit.h:2305
Unit* Unit::GetVictim ( ) const
inline
1379 { return m_attacking; }
Unit * m_attacking
Definition: Unit.h:2256
uint32 Unit::GetVirtualItemId ( uint32  slot) const
16420 {
16421  if (slot >= MAX_EQUIPMENT_ITEMS)
16422  return 0;
16423 
16424  return GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot * 2);
16425 }
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:108
#define MAX_EQUIPMENT_ITEMS
Definition: Unit.h:1297

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AuraApplication * Unit::GetVisibleAura ( uint8  slot) const
538 {
539  VisibleAuraMap::const_iterator itr = m_visibleAuras.find(slot);
540  if (itr != m_visibleAuras.end())
541  return itr->second;
542  return 0;
543 }
VisibleAuraMap m_visibleAuras
Definition: Unit.h:2288

+ Here is the caller graph for this function:

VisibleAuraMap const* Unit::GetVisibleAuras ( )
inline
2003 { return &m_visibleAuras; }
VisibleAuraMap m_visibleAuras
Definition: Unit.h:2288

+ Here is the caller graph for this function:

float Unit::GetWeaponDamageRange ( WeaponAttackType  attType,
WeaponDamageRange  type 
) const
11510 {
11511  if (attType == OFF_ATTACK && !haveOffhandWeapon())
11512  return 0.0f;
11513 
11514  return m_weaponDamage[attType][type];
11515 }
Definition: Unit.h:618
bool haveOffhandWeapon() const
Definition: Unit.cpp:418
float m_weaponDamage[MAX_ATTACK][2]
Definition: Unit.h:2286

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::GetWeaponProcChance ( ) const
9671 {
9672  // normalized proc chance for weapon attack speed
9673  // (odd formula...)
9675  return (GetAttackTime(BASE_ATTACK) * 1.8f / 1000.0f);
9677  return (GetAttackTime(OFF_ATTACK) * 1.6f / 1000.0f);
9678  return 0;
9679 }
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.cpp:10326
Definition: Unit.h:618
bool haveOffhandWeapon() const
Definition: Unit.cpp:418
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:1357
Definition: Unit.h:617

+ Here is the call graph for this function:

bool Unit::HandleAuraProc ( Unit victim,
uint32  damage,
Aura triggeredByAura,
SpellInfo const procSpell,
uint32  procFlag,
uint32  procEx,
uint32  cooldown,
bool handled 
)
private
Todo:
move those to spell scripts

Possible hack alert Don't drop charges on proc, they will be dropped on SpellMod removal Before this change, it was dropping two charges per attack, one in ProcDamageAndSpellFor, and one in RemoveSpellMods. The reason of this behaviour is Recklessness having three auras, 2 of them can not proc (isTriggeredAura array) but the other one can, making the whole spell proc.

6233 {
6234  SpellInfo const* dummySpell = triggeredByAura->GetSpellInfo();
6235 
6236  switch (dummySpell->SpellFamilyName)
6237  {
6238  case SPELLFAMILY_GENERIC:
6239  switch (dummySpell->Id)
6240  {
6241  // Nevermelting Ice Crystal
6242  case 71564:
6243  RemoveAuraFromStack(71564);
6244  *handled = true;
6245  break;
6246  // Gaseous Bloat
6247  case 70672:
6248  case 72455:
6249  case 72832:
6250  case 72833:
6251  {
6252  *handled = true;
6253  uint32 stack = triggeredByAura->GetStackAmount();
6254  int32 const mod = (GetMap()->GetSpawnMode() & 1) ? 1500 : 1250;
6255  int32 dmg = 0;
6256  for (uint8 i = 1; i <= stack; ++i)
6257  dmg += mod * i;
6258  if (Unit* caster = triggeredByAura->GetCaster())
6259  caster->CastCustomSpell(70701, SPELLVALUE_BASE_POINT0, dmg);
6260  break;
6261  }
6262  // Ball of Flames Proc
6263  case 71756:
6264  case 72782:
6265  case 72783:
6266  case 72784:
6267  RemoveAuraFromStack(dummySpell->Id);
6268  *handled = true;
6269  break;
6270  // Discerning Eye of the Beast
6271  case 59915:
6272  {
6273  CastSpell(this, 59914, true); // 59914 already has correct basepoints in DBC, no need for custom bp
6274  *handled = true;
6275  break;
6276  }
6277  // Swift Hand of Justice
6278  case 59906:
6279  {
6280  if (SpellEffectInfo const* effect = triggeredByAura->GetSpellEffectInfo(EFFECT_0))
6281  {
6282  int32 bp0 = CalculatePct(GetMaxHealth(), effect->CalcValue());
6283  CastCustomSpell(this, 59913, &bp0, NULL, NULL, true);
6284  *handled = true;
6285  }
6286  break;
6287  }
6288  }
6289 
6290  break;
6291  case SPELLFAMILY_PALADIN:
6292  {
6293  // Judgements of the Just
6294  if (dummySpell->SpellIconID == 3015)
6295  {
6296  *handled = true;
6297  CastSpell(victim, 68055, true);
6298  return true;
6299  }
6300  break;
6301  }
6302  case SPELLFAMILY_MAGE:
6303  {
6304  break;
6305  }
6307  {
6308  // Blood of the North
6309  // Reaping
6310  // Death Rune Mastery
6312  if (dummySpell->SpellIconID == 3041 || (dummySpell->SpellIconID == 22 && dummySpell->Id != 62459) || dummySpell->SpellIconID == 2622)
6313  {
6314  *handled = true;
6315  // Convert recently used Blood Rune to Death Rune
6316  if (Player* player = ToPlayer())
6317  {
6318  if (player->getClass() != CLASS_DEATH_KNIGHT)
6319  return false;
6320 
6321  RuneType rune = ToPlayer()->GetLastUsedRune();
6322  // can't proc from death rune use
6323  if (rune == RUNE_DEATH)
6324  return false;
6325  AuraEffect* aurEff = triggeredByAura->GetEffect(EFFECT_0);
6326  if (!aurEff)
6327  return false;
6328 
6329  // Reset amplitude - set death rune remove timer to 30s
6330  aurEff->ResetPeriodic(true);
6331  uint32 runesLeft;
6332 
6333  if (dummySpell->SpellIconID == 2622)
6334  runesLeft = 2;
6335  else
6336  runesLeft = 1;
6337 
6338  for (uint8 i = 0; i < MAX_RUNES && runesLeft; ++i)
6339  {
6340  if (dummySpell->SpellIconID == 2622)
6341  {
6342  if (player->GetCurrentRune(i) == RUNE_DEATH ||
6343  player->GetBaseRune(i) == RUNE_BLOOD)
6344  continue;
6345  }
6346  else
6347  {
6348  if (player->GetCurrentRune(i) == RUNE_DEATH ||
6349  player->GetBaseRune(i) != RUNE_BLOOD)
6350  continue;
6351  }
6352  if (player->GetRuneCooldown(i) != (player->GetRuneBaseCooldown(i) - player->GetLastRuneGraceTimer(i)))
6353  continue;
6354 
6355  --runesLeft;
6356  // Mark aura as used
6357  player->AddRuneByAuraEffect(i, RUNE_DEATH, aurEff);
6358  }
6359  return true;
6360  }
6361  return false;
6362  }
6363 
6364  switch (dummySpell->Id)
6365  {
6366  // Bone Shield cooldown
6367  case 49222:
6368  {
6369  *handled = true;
6370  if (cooldown && GetTypeId() == TYPEID_PLAYER)
6371  {
6372  if (GetSpellHistory()->HasCooldown(100000))
6373  return false;
6374 
6375  GetSpellHistory()->AddCooldown(100000, 0, std::chrono::seconds(cooldown));
6376  }
6377  return true;
6378  }
6379  }
6380  break;
6381  }
6382  case SPELLFAMILY_WARRIOR:
6383  {
6384  switch (dummySpell->Id)
6385  {
6386  // Item - Warrior T10 Protection 4P Bonus
6387  case 70844:
6388  {
6389  if (SpellEffectInfo const* effect = triggeredByAura->GetSpellEffectInfo(EFFECT_1))
6390  {
6391  int32 basepoints0 = CalculatePct(GetMaxHealth(), effect->CalcValue());
6392  CastCustomSpell(this, 70845, &basepoints0, NULL, NULL, true);
6393  }
6394  break;
6395  }
6396  // Recklessness
6397  case 1719:
6398  {
6403  *handled = true;
6404  break;
6405  }
6406  default:
6407  break;
6408  }
6409  break;
6410  }
6411  }
6412  return false;
6413 }
Definition: SpellAuraEffects.h:30
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
Definition: SharedDefines.h:4633
uint32 Id
Definition: SpellInfo.h:329
uint8 GetSpawnMode() const
Definition: Map.h:369
uint32 GetMaxHealth() const
Definition: Unit.h:1427
Definition: SharedDefines.h:29
void AddCooldown(uint32 spellId, uint32 itemId, std::chrono::duration< Type, Period > cooldownDuration)
Definition: SpellHistory.h:95
Definition: SharedDefines.h:172
Map * GetMap() const
Definition: Object.h:543
Unit * GetCaster() const
Definition: SpellAuras.cpp:438
Definition: SpellInfo.h:326
Definition: SharedDefines.h:28
void ResetPeriodic(bool resetPeriodicTimer=false)
Definition: SpellAuraEffects.h:85
void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3602
#define MAX_RUNES
Definition: Player.h:451
Definition: SharedDefines.h:4638
arena_t NULL
Definition: jemalloc_internal.h:624
float seconds()
Definition: units.h:97
SpellEffectInfo const * GetSpellEffectInfo(uint32 index) const
Definition: SpellAuras.cpp:396
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:4626
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
AuraEffect * GetEffect(uint32 index) const
Definition: SpellAuras.cpp:448
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Definition: Player.h:464
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:4623
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
Definition: SharedDefines.h:4627
uint32 SpellIconID
Definition: SpellInfo.h:390
uint8_t uint8
Definition: Define.h:152
Definition: Player.h:461
RuneType
Definition: Player.h:459
Definition: Unit.h:1305
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:129

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HandleAuraRaidProcFromCharge ( AuraEffect triggeredByAura)
private
13393 {
13394  // aura can be deleted at casts
13395  SpellInfo const* spellProto = triggeredByAura->GetSpellInfo();
13396 
13397  uint32 damageSpellId;
13398  switch (spellProto->Id)
13399  {
13400  case 57949: // shiver
13401  damageSpellId = 57952;
13402  //animationSpellId = 57951; dummy effects for jump spell have unknown use (see also 41637)
13403  break;
13404  case 59978: // shiver
13405  damageSpellId = 59979;
13406  break;
13407  case 43593: // Cold Stare
13408  damageSpellId = 43594;
13409  break;
13410  default:
13411  TC_LOG_ERROR("entities.unit", "Unit::HandleAuraRaidProcFromCharge, received unhandled spell: %u", spellProto->Id);
13412  return false;
13413  }
13414 
13415  ObjectGuid caster_guid = triggeredByAura->GetCasterGUID();
13416 
13417  // jumps
13418  int32 jumps = triggeredByAura->GetBase()->GetCharges()-1;
13419 
13420  // current aura expire
13421  triggeredByAura->GetBase()->SetCharges(1); // will removed at next charges decrease
13422 
13423  // next target selection
13424  if (jumps > 0)
13425  {
13426  if (Unit* caster = triggeredByAura->GetCaster())
13427  {
13428  SpellEffectInfo const* effect = triggeredByAura->GetSpellEffectInfo();
13429  float radius = effect->CalcRadius(caster);
13430  if (Unit* target= GetNextRandomRaidMemberOrPet(radius))
13431  {
13432  CastSpell(target, spellProto, true, NULL, triggeredByAura, caster_guid);
13433  if (Aura* aura = target->GetAura(spellProto->Id, caster->GetGUID()))
13434  aura->SetCharges(jumps);
13435  }
13436  }
13437  }
13438 
13439  CastSpell(this, damageSpellId, true, NULL, triggeredByAura, caster_guid);
13440 
13441  return true;
13442 }
uint32 Id
Definition: SpellInfo.h:329
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:46
SpellEffectInfo const * GetSpellEffectInfo() const
Definition: SpellAuraEffects.h:102
ObjectGuid GetCasterGUID() const
Definition: SpellAuraEffects.h:40
Definition: SpellInfo.h:326
arena_t NULL
Definition: jemalloc_internal.h:624
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
Unit * GetCaster() const
Definition: SpellAuraEffects.h:39
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
void SetCharges(uint8 charges)
Definition: SpellAuras.cpp:864
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint8 GetCharges() const
Definition: SpellAuras.h:170
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
Unit * GetNextRandomRaidMemberOrPet(float radius)
Definition: Unit.cpp:8041
Definition: SpellAuras.h:116
Definition: Unit.h:1305
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HandleAuraRaidProcFromChargeWithValue ( AuraEffect triggeredByAura)
private
13351 {
13352  // aura can be deleted at casts
13353  SpellInfo const* spellProto = triggeredByAura->GetSpellInfo();
13354  int32 heal = triggeredByAura->GetAmount();
13355  ObjectGuid caster_guid = triggeredByAura->GetCasterGUID();
13356 
13357  // Currently only Prayer of Mending
13358  if (!(spellProto->SpellFamilyName == SPELLFAMILY_PRIEST && spellProto->SpellFamilyFlags[1] & 0x20))
13359  {
13360  TC_LOG_DEBUG("spells", "Unit::HandleAuraRaidProcFromChargeWithValue, received not handled spell: %u", spellProto->Id);
13361  return false;
13362  }
13363 
13364  // jumps
13365  int32 jumps = triggeredByAura->GetBase()->GetCharges()-1;
13366 
13367  // current aura expire
13368  triggeredByAura->GetBase()->SetCharges(1); // will removed at next charges decrease
13369 
13370  // next target selection
13371  if (jumps > 0)
13372  {
13373  if (Unit* caster = triggeredByAura->GetCaster())
13374  {
13375  SpellEffectInfo const* effect = triggeredByAura->GetSpellEffectInfo();
13376  float radius = effect->CalcRadius(caster);
13377 
13378  if (Unit* target = GetNextRandomRaidMemberOrPet(radius))
13379  {
13380  CastCustomSpell(target, spellProto->Id, &heal, NULL, NULL, true, NULL, triggeredByAura, caster_guid);
13381  if (Aura* aura = target->GetAura(spellProto->Id, caster->GetGUID()))
13382  aura->SetCharges(jumps);
13383  }
13384  }
13385  }
13386 
13387  // heal
13388  CastCustomSpell(this, 33110, &heal, NULL, NULL, true, NULL, NULL, caster_guid);
13389  return true;
13390 
13391 }
uint32 Id
Definition: SpellInfo.h:329
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:46
SpellEffectInfo const * GetSpellEffectInfo() const
Definition: SpellAuraEffects.h:102
ObjectGuid GetCasterGUID() const
Definition: SpellAuraEffects.h:40
Definition: SpellInfo.h:326
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
arena_t NULL
Definition: jemalloc_internal.h:624
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Unit * GetCaster() const
Definition: SpellAuraEffects.h:39
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
void SetCharges(uint8 charges)
Definition: SpellAuras.cpp:864
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Definition: SharedDefines.h:4629
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
uint8 GetCharges() const
Definition: SpellAuras.h:170
Definition: ObjectGuid.h:189
Unit * GetNextRandomRaidMemberOrPet(float radius)
Definition: Unit.cpp:8041
Definition: SpellAuras.h:116
Definition: Unit.h:1305
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HandleDummyAuraProc ( Unit victim,
uint32  damage,
AuraEffect triggeredByAura,
SpellInfo const procSpell,
uint32  procFlag,
uint32  procEx,
uint32  cooldown 
)
private
Todo:
It should be moved to database, shouldn't it?
4967 {
4968  SpellInfo const* dummySpell = triggeredByAura->GetSpellInfo();
4969  uint32 effIndex = triggeredByAura->GetEffIndex();
4970  int32 triggerAmount = triggeredByAura->GetAmount();
4971 
4972  Item* castItem = !triggeredByAura->GetBase()->GetCastItemGUID().IsEmpty() && GetTypeId() == TYPEID_PLAYER
4973  ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
4974 
4975  uint32 triggered_spell_id = 0;
4976  uint32 cooldown_spell_id = 0; // for random trigger, will be one of the triggered spell to avoid repeatable triggers
4977  // otherwise, it's the triggered_spell_id by default
4978  Unit* target = victim;
4979  int32 basepoints0 = 0;
4980  ObjectGuid originalCaster;
4981 
4982  switch (dummySpell->SpellFamilyName)
4983  {
4984  case SPELLFAMILY_GENERIC:
4985  {
4986  switch (dummySpell->Id)
4987  {
4988  // Unstable Power
4989  case 24658:
4990  {
4991  if (!procSpell || procSpell->Id == 24659)
4992  return false;
4993  // Need remove one 24659 aura
4994  RemoveAuraFromStack(24659);
4995  return true;
4996  }
4997  // Restless Strength
4998  case 24661:
4999  {
5000  // Need remove one 24662 aura
5001  RemoveAuraFromStack(24662);
5002  return true;
5003  }
5004  // Mark of Malice
5005  case 33493:
5006  {
5007  // Cast finish spell at last charge
5008  if (triggeredByAura->GetBase()->GetCharges() > 1)
5009  return false;
5010 
5011  target = this;
5012  triggered_spell_id = 33494;
5013  break;
5014  }
5015  // Twisted Reflection (boss spell)
5016  case 21063:
5017  triggered_spell_id = 21064;
5018  break;
5019  // Vampiric Aura (boss spell)
5020  case 38196:
5021  {
5022  basepoints0 = 3 * damage; // 300%
5023  if (basepoints0 < 0)
5024  return false;
5025 
5026  triggered_spell_id = 31285;
5027  target = this;
5028  break;
5029  }
5030  // Aura of Madness (Darkmoon Card: Madness trinket)
5031  //=====================================================
5032  // 39511 Sociopath: +35 strength (Paladin, Rogue, Druid, Warrior)
5033  // 40997 Delusional: +70 attack power (Rogue, Hunter, Paladin, Warrior, Druid)
5034  // 40998 Kleptomania: +35 agility (Warrior, Rogue, Paladin, Hunter, Druid)
5035  // 40999 Megalomania: +41 damage/healing (Druid, Shaman, Priest, Warlock, Mage, Paladin)
5036  // 41002 Paranoia: +35 spell/melee/ranged crit strike rating (All classes)
5037  // 41005 Manic: +35 haste (spell, melee and ranged) (All classes)
5038  // 41009 Narcissism: +35 intellect (Druid, Shaman, Priest, Warlock, Mage, Paladin, Hunter)
5039  // 41011 Martyr Complex: +35 stamina (All classes)
5040  // 41406 Dementia: Every 5 seconds either gives you +5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin)
5041  // 41409 Dementia: Every 5 seconds either gives you -5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin)
5042  case 39446:
5043  {
5044  if (GetTypeId() != TYPEID_PLAYER || !IsAlive())
5045  return false;
5046 
5047  // Select class defined buff
5048  switch (getClass())
5049  {
5050  case CLASS_PALADIN: // 39511, 40997, 40998, 40999, 41002, 41005, 41009, 41011, 41409
5051  case CLASS_DRUID: // 39511, 40997, 40998, 40999, 41002, 41005, 41009, 41011, 41409
5052  triggered_spell_id = RAND(39511, 40997, 40998, 40999, 41002, 41005, 41009, 41011, 41409);
5053  cooldown_spell_id = 39511;
5054  break;
5055  case CLASS_ROGUE: // 39511, 40997, 40998, 41002, 41005, 41011
5056  case CLASS_WARRIOR: // 39511, 40997, 40998, 41002, 41005, 41011
5057  case CLASS_DEATH_KNIGHT:
5058  triggered_spell_id = RAND(39511, 40997, 40998, 41002, 41005, 41011);
5059  cooldown_spell_id = 39511;
5060  break;
5061  case CLASS_PRIEST: // 40999, 41002, 41005, 41009, 41011, 41406, 41409
5062  case CLASS_SHAMAN: // 40999, 41002, 41005, 41009, 41011, 41406, 41409
5063  case CLASS_MAGE: // 40999, 41002, 41005, 41009, 41011, 41406, 41409
5064  case CLASS_WARLOCK: // 40999, 41002, 41005, 41009, 41011, 41406, 41409
5065  triggered_spell_id = RAND(40999, 41002, 41005, 41009, 41011, 41406, 41409);
5066  cooldown_spell_id = 40999;
5067  break;
5068  case CLASS_HUNTER: // 40997, 40999, 41002, 41005, 41009, 41011, 41406, 41409
5069  triggered_spell_id = RAND(40997, 40999, 41002, 41005, 41009, 41011, 41406, 41409);
5070  cooldown_spell_id = 40997;
5071  break;
5072  default:
5073  return false;
5074  }
5075 
5076  target = this;
5077  if (roll_chance_i(10))
5078  ToPlayer()->Say("This is Madness!", LANG_UNIVERSAL);
5079  break;
5080  }
5081  // Sunwell Exalted Caster Neck (??? neck)
5082  // cast ??? Light's Wrath if Exalted by Aldor
5083  // cast ??? Arcane Bolt if Exalted by Scryers
5084  case 46569:
5085  return false; // old unused version
5086  // Sunwell Exalted Caster Neck (Shattered Sun Pendant of Acumen neck)
5087  // cast 45479 Light's Wrath if Exalted by Aldor
5088  // cast 45429 Arcane Bolt if Exalted by Scryers
5089  case 45481:
5090  {
5091  Player* player = ToPlayer();
5092  if (!player)
5093  return false;
5094 
5095  // Get Aldor reputation rank
5096  if (player->GetReputationRank(932) == REP_EXALTED)
5097  {
5098  target = this;
5099  triggered_spell_id = 45479;
5100  break;
5101  }
5102  // Get Scryers reputation rank
5103  if (player->GetReputationRank(934) == REP_EXALTED)
5104  {
5105  // triggered at positive/self casts also, current attack target used then
5106  if (target && IsFriendlyTo(target))
5107  {
5108  target = GetVictim();
5109  if (!target)
5110  {
5111  target = player->GetSelectedUnit();
5112  if (!target)
5113  return false;
5114  }
5115  if (IsFriendlyTo(target))
5116  return false;
5117  }
5118 
5119  triggered_spell_id = 45429;
5120  break;
5121  }
5122  return false;
5123  }
5124  // Sunwell Exalted Melee Neck (Shattered Sun Pendant of Might neck)
5125  // cast 45480 Light's Strength if Exalted by Aldor
5126  // cast 45428 Arcane Strike if Exalted by Scryers
5127  case 45482:
5128  {
5129  if (GetTypeId() != TYPEID_PLAYER)
5130  return false;
5131 
5132  // Get Aldor reputation rank
5133  if (ToPlayer()->GetReputationRank(932) == REP_EXALTED)
5134  {
5135  target = this;
5136  triggered_spell_id = 45480;
5137  break;
5138  }
5139  // Get Scryers reputation rank
5140  if (ToPlayer()->GetReputationRank(934) == REP_EXALTED)
5141  {
5142  triggered_spell_id = 45428;
5143  break;
5144  }
5145  return false;
5146  }
5147  // Sunwell Exalted Tank Neck (Shattered Sun Pendant of Resolve neck)
5148  // cast 45431 Arcane Insight if Exalted by Aldor
5149  // cast 45432 Light's Ward if Exalted by Scryers
5150  case 45483:
5151  {
5152  if (GetTypeId() != TYPEID_PLAYER)
5153  return false;
5154 
5155  // Get Aldor reputation rank
5156  if (ToPlayer()->GetReputationRank(932) == REP_EXALTED)
5157  {
5158  target = this;
5159  triggered_spell_id = 45432;
5160  break;
5161  }
5162  // Get Scryers reputation rank
5163  if (ToPlayer()->GetReputationRank(934) == REP_EXALTED)
5164  {
5165  target = this;
5166  triggered_spell_id = 45431;
5167  break;
5168  }
5169  return false;
5170  }
5171  // Sunwell Exalted Healer Neck (Shattered Sun Pendant of Restoration neck)
5172  // cast 45478 Light's Salvation if Exalted by Aldor
5173  // cast 45430 Arcane Surge if Exalted by Scryers
5174  case 45484:
5175  {
5176  if (GetTypeId() != TYPEID_PLAYER)
5177  return false;
5178 
5179  // Get Aldor reputation rank
5180  if (ToPlayer()->GetReputationRank(932) == REP_EXALTED)
5181  {
5182  target = this;
5183  triggered_spell_id = 45478;
5184  break;
5185  }
5186  // Get Scryers reputation rank
5187  if (ToPlayer()->GetReputationRank(934) == REP_EXALTED)
5188  {
5189  triggered_spell_id = 45430;
5190  break;
5191  }
5192  return false;
5193  }
5194  // Kill command
5195  case 58914:
5196  {
5197  // Remove aura stack from pet
5198  RemoveAuraFromStack(58914);
5199  Unit* owner = GetOwner();
5200  if (!owner)
5201  return true;
5202  // reduce the owner's aura stack
5203  owner->RemoveAuraFromStack(34027);
5204  return true;
5205  }
5206  // Vampiric Touch (generic, used by some boss)
5207  case 52723:
5208  case 60501:
5209  {
5210  triggered_spell_id = 52724;
5211  basepoints0 = damage / 2;
5212  target = this;
5213  break;
5214  }
5215  // Shadowfiend Death (Gain mana if pet dies with Glyph of Shadowfiend)
5216  case 57989:
5217  {
5218  Unit* owner = GetOwner();
5219  if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
5220  return false;
5221  // Glyph of Shadowfiend (need cast as self cast for owner, no hidden cooldown)
5222  owner->CastSpell(owner, 58227, true, castItem, triggeredByAura);
5223  return true;
5224  }
5225  // Divine purpose
5226  case 31871:
5227  case 31872:
5228  {
5229  // Roll chane
5230  if (!victim || !victim->IsAlive() || !roll_chance_i(triggerAmount))
5231  return false;
5232 
5233  // Remove any stun effect on target
5235  return true;
5236  }
5237  // Purified Shard of the Scale - Onyxia 10 Caster Trinket
5238  case 69755:
5239  {
5240  triggered_spell_id = (procFlag & PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS) ? 69733 : 69729;
5241  break;
5242  }
5243  // Shiny Shard of the Scale - Onyxia 25 Caster Trinket
5244  case 69739:
5245  {
5246  triggered_spell_id = (procFlag & PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS) ? 69734 : 69730;
5247  break;
5248  }
5249  case 71519: // Deathbringer's Will Normal
5250  {
5251  if (GetTypeId() != TYPEID_PLAYER)
5252  return false;
5253 
5254  std::vector<uint32> RandomSpells;
5255  switch (getClass())
5256  {
5257  case CLASS_WARRIOR:
5258  case CLASS_PALADIN:
5259  case CLASS_DEATH_KNIGHT:
5260  RandomSpells.push_back(71484);
5261  RandomSpells.push_back(71491);
5262  RandomSpells.push_back(71492);
5263  break;
5264  case CLASS_SHAMAN:
5265  case CLASS_ROGUE:
5266  RandomSpells.push_back(71486);
5267  RandomSpells.push_back(71485);
5268  RandomSpells.push_back(71492);
5269  break;
5270  case CLASS_DRUID:
5271  RandomSpells.push_back(71484);
5272  RandomSpells.push_back(71485);
5273  RandomSpells.push_back(71492);
5274  break;
5275  case CLASS_HUNTER:
5276  RandomSpells.push_back(71486);
5277  RandomSpells.push_back(71491);
5278  RandomSpells.push_back(71485);
5279  break;
5280  default:
5281  return false;
5282  }
5283  if (RandomSpells.empty()) // shouldn't happen
5284  return false;
5285 
5286  uint8 rand_spell = urand(0, (RandomSpells.size() - 1));
5287  CastSpell(target, RandomSpells[rand_spell], true, castItem, triggeredByAura, originalCaster);
5288  for (std::vector<uint32>::iterator itr = RandomSpells.begin(); itr != RandomSpells.end(); ++itr)
5289  {
5290  if (!GetSpellHistory()->HasCooldown(*itr))
5291  GetSpellHistory()->AddCooldown(*itr, 0, std::chrono::seconds(cooldown));
5292  }
5293  break;
5294  }
5295  case 71562: // Deathbringer's Will Heroic
5296  {
5297  if (GetTypeId() != TYPEID_PLAYER)
5298  return false;
5299 
5300  std::vector<uint32> RandomSpells;
5301  switch (getClass())
5302  {
5303  case CLASS_WARRIOR:
5304  case CLASS_PALADIN:
5305  case CLASS_DEATH_KNIGHT:
5306  RandomSpells.push_back(71561);
5307  RandomSpells.push_back(71559);
5308  RandomSpells.push_back(71560);
5309  break;
5310  case CLASS_SHAMAN:
5311  case CLASS_ROGUE:
5312  RandomSpells.push_back(71558);
5313  RandomSpells.push_back(71556);
5314  RandomSpells.push_back(71560);
5315  break;
5316  case CLASS_DRUID:
5317  RandomSpells.push_back(71561);
5318  RandomSpells.push_back(71556);
5319  RandomSpells.push_back(71560);
5320  break;
5321  case CLASS_HUNTER:
5322  RandomSpells.push_back(71558);
5323  RandomSpells.push_back(71559);
5324  RandomSpells.push_back(71556);
5325  break;
5326  default:
5327  return false;
5328  }
5329  if (RandomSpells.empty()) // shouldn't happen
5330  return false;
5331 
5332  uint8 rand_spell = urand(0, (RandomSpells.size() - 1));
5333  CastSpell(target, RandomSpells[rand_spell], true, castItem, triggeredByAura, originalCaster);
5334  for (std::vector<uint32>::iterator itr = RandomSpells.begin(); itr != RandomSpells.end(); ++itr)
5335  {
5336  if (!GetSpellHistory()->HasCooldown(*itr))
5337  GetSpellHistory()->AddCooldown(*itr, 0, std::chrono::seconds(cooldown));
5338  }
5339  break;
5340  }
5341  case 65032: // Boom aura (321 Boombot)
5342  {
5343  if (victim->GetEntry() != 33343) // Scrapbot
5344  return false;
5345 
5346  InstanceScript* instance = GetInstanceScript();
5347  if (!instance)
5348  return false;
5349 
5350  instance->DoCastSpellOnPlayers(65037); // Achievement criteria marker
5351  break;
5352  }
5353  case 47020: // Enter vehicle XT-002 (Scrapbot)
5354  {
5355  if (GetTypeId() != TYPEID_UNIT)
5356  return false;
5357 
5358  Unit* vehicleBase = GetVehicleBase();
5359  if (!vehicleBase)
5360  return false;
5361 
5362  // Todo: Check if this amount is blizzlike
5363  vehicleBase->ModifyHealth(int32(vehicleBase->CountPctFromMaxHealth(1)));
5364  break;
5365  }
5366  }
5367  break;
5368  }
5369  case SPELLFAMILY_MAGE:
5370  {
5371  // Hot Streak & Improved Hot Streak
5372  if (dummySpell->SpellIconID == 2999)
5373  {
5374  if (effIndex != 0)
5375  return false;
5376  AuraEffect* counter = triggeredByAura->GetBase()->GetEffect(EFFECT_1);
5377  if (!counter)
5378  return true;
5379 
5380  // Count spell criticals in a row in second aura
5381  if (procEx & PROC_EX_CRITICAL_HIT)
5382  {
5383  counter->SetAmount(counter->GetAmount() * 2);
5384  if (counter->GetAmount() < 100 && dummySpell->Id != 44445) // not enough or Hot Streak spell
5385  return true;
5386  // Crititcal counted -> roll chance
5387  if (roll_chance_i(triggerAmount))
5388  CastSpell(this, 48108, true, castItem, triggeredByAura);
5389  }
5390  counter->SetAmount(25);
5391  return true;
5392  }
5393  // Incanter's Regalia set (add trigger chance to Mana Shield)
5394  if (dummySpell->SpellFamilyFlags[0] & 0x8000)
5395  {
5396  if (GetTypeId() != TYPEID_PLAYER)
5397  return false;
5398 
5399  target = this;
5400  triggered_spell_id = 37436;
5401  break;
5402  }
5403  }
5404  case SPELLFAMILY_WARLOCK:
5405  {
5406  // Seed of Corruption
5407  if (dummySpell->SpellFamilyFlags[1] & 0x00000010)
5408  {
5409  if (procSpell && procSpell->SpellFamilyFlags[1] & 0x8000)
5410  return false;
5411  // if damage is more than need or target die from damage deal finish spell
5412  if (triggeredByAura->GetAmount() <= int32(damage) || GetHealth() <= damage)
5413  {
5414  // remember caster before aura delete
5415  Unit* caster = triggeredByAura->GetCaster();
5416 
5417  // Remove aura (before cast for prevent infinite loop handlers)
5418  RemoveAurasDueToSpell(triggeredByAura->GetId());
5419 
5420  uint32 spell = sSpellMgr->GetSpellWithRank(27285, dummySpell->GetRank());
5421 
5422  // Cast finish spell (triggeredByAura already not exist!)
5423  if (caster)
5424  caster->CastSpell(this, spell, true, castItem);
5425  return true; // no hidden cooldown
5426  }
5427 
5428  // Damage counting
5429  triggeredByAura->SetAmount(triggeredByAura->GetAmount() - damage);
5430  return true;
5431  }
5432  // Seed of Corruption (Mobs cast) - no die req
5433  if (!dummySpell->SpellFamilyFlags && dummySpell->SpellIconID == 1932)
5434  {
5435  // if damage is more than need deal finish spell
5436  if (triggeredByAura->GetAmount() <= int32(damage))
5437  {
5438  // remember caster before aura delete
5439  Unit* caster = triggeredByAura->GetCaster();
5440 
5441  // Remove aura (before cast for prevent infinite loop handlers)
5442  RemoveAurasDueToSpell(triggeredByAura->GetId());
5443 
5444  // Cast finish spell (triggeredByAura already not exist!)
5445  if (caster)
5446  caster->CastSpell(this, 32865, true, castItem);
5447  return true; // no hidden cooldown
5448  }
5449  // Damage counting
5450  triggeredByAura->SetAmount(triggeredByAura->GetAmount() - damage);
5451  return true;
5452  }
5453  switch (dummySpell->Id)
5454  {
5455  // Shadowflame (Voidheart Raiment set bonus)
5456  case 37377:
5457  {
5458  triggered_spell_id = 37379;
5459  break;
5460  }
5461  // Pet Healing (Corruptor Raiment or Rift Stalker Armor)
5462  case 37381:
5463  {
5464  target = GetGuardianPet();
5465  if (!target)
5466  return false;
5467 
5468  // heal amount
5469  basepoints0 = CalculatePct(int32(damage), triggerAmount);
5470  triggered_spell_id = 37382;
5471  break;
5472  }
5473  // Shadowflame Hellfire (Voidheart Raiment set bonus)
5474  case 39437:
5475  {
5476  triggered_spell_id = 37378;
5477  break;
5478  }
5479  }
5480  break;
5481  }
5482  case SPELLFAMILY_PRIEST:
5483  {
5484  switch (dummySpell->Id)
5485  {
5486  // Priest Tier 6 Trinket (Ashtongue Talisman of Acumen)
5487  case 40438:
5488  {
5489  // Shadow Word: Pain
5490  if (!procSpell)
5491  return false;
5492  else if (procSpell->SpellFamilyFlags[0] & 0x8000)
5493  triggered_spell_id = 40441;
5494  // Renew
5495  else if (procSpell->SpellFamilyFlags[0] & 0x40)
5496  triggered_spell_id = 40440;
5497  else
5498  return false;
5499 
5500  target = this;
5501  break;
5502  }
5503  // Oracle Healing Bonus ("Garments of the Oracle" set)
5504  case 26169:
5505  {
5506  // heal amount
5507  basepoints0 = int32(CalculatePct(damage, 10));
5508  target = this;
5509  triggered_spell_id = 26170;
5510  break;
5511  }
5512  // Frozen Shadoweave (Shadow's Embrace set) warning! its not only priest set
5513  case 39372:
5514  {
5515  if (!procSpell || (procSpell->GetSchoolMask() & (SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_SHADOW)) == 0)
5516  return false;
5517 
5518  // heal amount
5519  basepoints0 = CalculatePct(int32(damage), triggerAmount);
5520  target = this;
5521  triggered_spell_id = 39373;
5522  break;
5523  }
5524  // Greater Heal (Vestments of Faith (Priest Tier 3) - 4 pieces bonus)
5525  case 28809:
5526  {
5527  triggered_spell_id = 28810;
5528  break;
5529  }
5530  break;
5531  }
5532  break;
5533  }
5534  case SPELLFAMILY_DRUID:
5535  {
5536  switch (dummySpell->Id)
5537  {
5538  // Glyph of Bloodletting
5539  case 54815:
5540  {
5541  if (!target)
5542  return false;
5543 
5544  // try to find spell Rip on the target
5545  if (AuraEffect const* AurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, flag128(0x00800000, 0x0, 0x0), GetGUID()))
5546  {
5547  // Rip's max duration, note: spells which modifies Rip's duration also counted
5548  uint32 CountMin = AurEff->GetBase()->GetMaxDuration();
5549 
5550  // just Rip's max duration without other spells
5551  uint32 CountMax = AurEff->GetSpellInfo()->GetMaxDuration();
5552 
5553  // add possible auras' and Glyph of Shred's max duration
5554  CountMax += 3 * triggerAmount * IN_MILLISECONDS; // Glyph of Bloodletting -> +6 seconds
5555  CountMax += HasAura(60141) ? 4 * IN_MILLISECONDS : 0; // Rip Duration/Lacerate Damage -> +4 seconds
5556 
5557  // if min < max -> that means caster didn't cast 3 shred yet
5558  // so set Rip's duration and max duration
5559  if (CountMin < CountMax)
5560  {
5561  AurEff->GetBase()->SetDuration(AurEff->GetBase()->GetDuration() + triggerAmount * IN_MILLISECONDS);
5562  AurEff->GetBase()->SetMaxDuration(CountMin + triggerAmount * IN_MILLISECONDS);
5563  return true;
5564  }
5565  }
5566  // if not found Rip
5567  return false;
5568  }
5569  // Leader of the Pack
5570  case 24932:
5571  {
5572  if (triggerAmount <= 0)
5573  return false;
5574  basepoints0 = int32(CountPctFromMaxHealth(triggerAmount));
5575  target = this;
5576  triggered_spell_id = 34299;
5577  // Regenerate 4% mana
5578  int32 mana = CalculatePct(GetCreateMana(), triggerAmount);
5579  CastCustomSpell(this, 68285, &mana, NULL, NULL, true, castItem, triggeredByAura);
5580  break;
5581  }
5582  // Healing Touch (Dreamwalker Raiment set)
5583  case 28719:
5584  {
5585  if (!procSpell)
5586  return false;
5587  // mana back
5588  std::vector<SpellInfo::CostData> costs = procSpell->CalcPowerCost(this, procSpell->GetSchoolMask());
5589  auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
5590  if (m == costs.end())
5591  return false;
5592 
5593  basepoints0 = int32(CalculatePct(m->Amount, 30));
5594  target = this;
5595  triggered_spell_id = 28742;
5596  break;
5597  }
5598  // Healing Touch Refund (Idol of Longevity trinket)
5599  case 28847:
5600  {
5601  target = this;
5602  triggered_spell_id = 28848;
5603  break;
5604  }
5605  // Mana Restore (Malorne Raiment set / Malorne Regalia set)
5606  case 37288:
5607  case 37295:
5608  {
5609  target = this;
5610  triggered_spell_id = 37238;
5611  break;
5612  }
5613  // Druid Tier 6 Trinket
5614  case 40442:
5615  {
5616  float chance;
5617 
5618  if (!procSpell)
5619  return false;
5620  // Starfire
5621  if (procSpell->SpellFamilyFlags[0] & 0x4)
5622  {
5623  triggered_spell_id = 40445;
5624  chance = 25.0f;
5625  }
5626  // Rejuvenation
5627  else if (procSpell->SpellFamilyFlags[0] & 0x10)
5628  {
5629  triggered_spell_id = 40446;
5630  chance = 25.0f;
5631  }
5632  // Mangle (Bear) and Mangle (Cat)
5633  else if (procSpell->SpellFamilyFlags[1] & 0x00000440)
5634  {
5635  triggered_spell_id = 40452;
5636  chance = 40.0f;
5637  }
5638  else
5639  return false;
5640 
5641  if (!roll_chance_f(chance))
5642  return false;
5643 
5644  target = this;
5645  break;
5646  }
5647  // Item - Druid T10 Balance 4P Bonus
5648  case 70723:
5649  {
5650  // Wrath & Starfire
5651  if (procSpell && (procSpell->SpellFamilyFlags[0] & 0x5) && (procEx & PROC_EX_CRITICAL_HIT))
5652  {
5653  triggered_spell_id = 71023;
5654  SpellInfo const* triggeredSpell = sSpellMgr->GetSpellInfo(triggered_spell_id);
5655  if (!triggeredSpell)
5656  return false;
5657  SpellEffectInfo const* effect = triggeredSpell->GetEffect(DIFFICULTY_NONE, EFFECT_0);
5658  if (!effect)
5659  return false;
5660  basepoints0 = CalculatePct(int32(damage), triggerAmount) / (triggeredSpell->GetMaxDuration() / effect->ApplyAuraPeriod);
5661  // Add remaining ticks to damage done
5662  basepoints0 += victim->GetRemainingPeriodicAmount(GetGUID(), triggered_spell_id, SPELL_AURA_PERIODIC_DAMAGE);
5663  }
5664  break;
5665  }
5666  // Item - Druid T10 Restoration 4P Bonus (Rejuvenation)
5667  case 70664:
5668  {
5669  // Proc only from normal Rejuvenation
5670  if (!procSpell || procSpell->Id != 774)
5671  return false;
5672 
5673  Player* caster = ToPlayer();
5674  if (!caster)
5675  return false;
5676  if (!caster->GetGroup() && victim == this)
5677  return false;
5678 
5679  CastCustomSpell(70691, SPELLVALUE_BASE_POINT0, damage, victim, true);
5680  return true;
5681  }
5682  }
5683  break;
5684  }
5685  case SPELLFAMILY_PALADIN:
5686  {
5687  // Judgements of the Wise
5688  if (dummySpell->SpellIconID == 3017)
5689  {
5690  target = this;
5691  triggered_spell_id = 31930;
5692  break;
5693  }
5694  switch (dummySpell->Id)
5695  {
5696  // Sacred Shield
5697  case 53601:
5698  {
5700  return false;
5701 
5702  if (damage > 0)
5703  triggered_spell_id = 58597;
5704 
5705  // Item - Paladin T8 Holy 4P Bonus
5706  if (Unit* caster = triggeredByAura->GetCaster())
5707  if (AuraEffect const* aurEff = caster->GetAuraEffect(64895, 0))
5708  cooldown = aurEff->GetAmount();
5709 
5710  target = this;
5711  break;
5712  }
5713  // Holy Power (Redemption Armor set)
5714  case 28789:
5715  {
5716  if (!victim)
5717  return false;
5718 
5719  // Set class defined buff
5720  switch (victim->getClass())
5721  {
5722  case CLASS_PALADIN:
5723  case CLASS_PRIEST:
5724  case CLASS_SHAMAN:
5725  case CLASS_DRUID:
5726  triggered_spell_id = 28795; // Increases the friendly target's mana regeneration by $s1 per 5 sec. for $d.
5727  break;
5728  case CLASS_MAGE:
5729  case CLASS_WARLOCK:
5730  triggered_spell_id = 28793; // Increases the friendly target's spell damage and healing by up to $s1 for $d.
5731  break;
5732  case CLASS_HUNTER:
5733  case CLASS_ROGUE:
5734  triggered_spell_id = 28791; // Increases the friendly target's attack power by $s1 for $d.
5735  break;
5736  case CLASS_WARRIOR:
5737  triggered_spell_id = 28790; // Increases the friendly target's armor
5738  break;
5739  default:
5740  return false;
5741  }
5742  break;
5743  }
5744  case 31801:
5745  {
5746  if (effIndex != 0) // effect 2 used by seal unleashing code
5747  return false;
5748 
5749  // At melee attack or Hammer of the Righteous spell damage considered as melee attack
5750  bool stacker = !procSpell || procSpell->Id == 53595;
5751  // spells with SPELL_DAMAGE_CLASS_MELEE excluding Judgements
5752  bool damager = procSpell && (procSpell->EquippedItemClass != -1 || procSpell->Id == 71433 || procSpell->Id == 71434);
5753 
5754  if (!stacker && !damager)
5755  return false;
5756 
5757  triggered_spell_id = 31803;
5758 
5759  // On target with 5 stacks of Censure direct damage is done
5760  if (Aura* aur = victim->GetAura(triggered_spell_id, GetGUID()))
5761  {
5762  if (aur->GetStackAmount() == 5)
5763  {
5764  if (stacker)
5765  aur->RefreshDuration();
5766  CastSpell(victim, 42463, true);
5767  return true;
5768  }
5769  }
5770 
5771  if (!stacker)
5772  return false;
5773  break;
5774  }
5775  // Paladin Tier 6 Trinket (Ashtongue Talisman of Zeal)
5776  case 40470:
5777  {
5778  if (!procSpell)
5779  return false;
5780 
5781  float chance;
5782 
5783  // Flash of light/Holy light
5784  if (procSpell->SpellFamilyFlags[0] & 0xC0000000)
5785  {
5786  triggered_spell_id = 40471;
5787  chance = 15.0f;
5788  }
5789  // Judgement (any)
5790  else if (procSpell->GetSpellSpecific() == SPELL_SPECIFIC_JUDGEMENT)
5791  {
5792  triggered_spell_id = 40472;
5793  chance = 50.0f;
5794  }
5795  else
5796  return false;
5797 
5798  if (!roll_chance_f(chance))
5799  return false;
5800 
5801  break;
5802  }
5803  // Item - Paladin T8 Holy 2P Bonus
5804  case 64890:
5805  {
5806  triggered_spell_id = 64891;
5807  basepoints0 = triggerAmount * damage / 300;
5808  break;
5809  }
5810  case 71406: // Tiny Abomination in a Jar
5811  case 71545: // Tiny Abomination in a Jar (Heroic)
5812  {
5813  if (!victim || !victim->IsAlive())
5814  return false;
5815 
5816  CastSpell(this, 71432, true, NULL, triggeredByAura);
5817 
5818  Aura const* dummy = GetAura(71432);
5819  if (!dummy || dummy->GetStackAmount() < (dummySpell->Id == 71406 ? 8 : 7))
5820  return false;
5821 
5822  RemoveAurasDueToSpell(71432);
5823  triggered_spell_id = 71433; // default main hand attack
5824  // roll if offhand
5825  if (Player const* player = ToPlayer())
5826  if (player->GetWeaponForAttack(OFF_ATTACK, true) && urand(0, 1))
5827  triggered_spell_id = 71434;
5828  target = victim;
5829  break;
5830  }
5831  // Item - Icecrown 25 Normal Dagger Proc
5832  case 71880:
5833  {
5834  switch (getPowerType())
5835  {
5836  case POWER_MANA:
5837  triggered_spell_id = 71881;
5838  break;
5839  case POWER_RAGE:
5840  triggered_spell_id = 71883;
5841  break;
5842  case POWER_ENERGY:
5843  triggered_spell_id = 71882;
5844  break;
5845  case POWER_RUNIC_POWER:
5846  triggered_spell_id = 71884;
5847  break;
5848  default:
5849  return false;
5850  }
5851  break;
5852  }
5853  // Item - Icecrown 25 Heroic Dagger Proc
5854  case 71892:
5855  {
5856  switch (getPowerType())
5857  {
5858  case POWER_MANA:
5859  triggered_spell_id = 71888;
5860  break;
5861  case POWER_RAGE:
5862  triggered_spell_id = 71886;
5863  break;
5864  case POWER_ENERGY:
5865  triggered_spell_id = 71887;
5866  break;
5867  case POWER_RUNIC_POWER:
5868  triggered_spell_id = 71885;
5869  break;
5870  default:
5871  return false;
5872  }
5873  break;
5874  }
5875  }
5876  break;
5877  }
5878  case SPELLFAMILY_SHAMAN:
5879  {
5880  switch (dummySpell->Id)
5881  {
5882  // Totemic Power (The Earthshatterer set)
5883  case 28823:
5884  {
5885  if (!victim)
5886  return false;
5887 
5888  // Set class defined buff
5889  switch (victim->getClass())
5890  {
5891  case CLASS_PALADIN:
5892  case CLASS_PRIEST:
5893  case CLASS_SHAMAN:
5894  case CLASS_DRUID:
5895  triggered_spell_id = 28824; // Increases the friendly target's mana regeneration by $s1 per 5 sec. for $d.
5896  break;
5897  case CLASS_MAGE:
5898  case CLASS_WARLOCK:
5899  triggered_spell_id = 28825; // Increases the friendly target's spell damage and healing by up to $s1 for $d.
5900  break;
5901  case CLASS_HUNTER:
5902  case CLASS_ROGUE:
5903  triggered_spell_id = 28826; // Increases the friendly target's attack power by $s1 for $d.
5904  break;
5905  case CLASS_WARRIOR:
5906  triggered_spell_id = 28827; // Increases the friendly target's armor
5907  break;
5908  default:
5909  return false;
5910  }
5911  break;
5912  }
5913  // Lesser Healing Wave (Totem of Flowing Water Relic)
5914  case 28849:
5915  {
5916  target = this;
5917  triggered_spell_id = 28850;
5918  break;
5919  }
5920  // Windfury Weapon (Passive) 1-8 Ranks
5921  case 33757:
5922  {
5923  Player* player = ToPlayer();
5924  if (!player || !castItem || !castItem->IsEquipped() || !victim || !victim->IsAlive())
5925  return false;
5926 
5927  // custom cooldown processing case
5928  if (cooldown && GetSpellHistory()->HasCooldown(dummySpell->Id))
5929  return false;
5930 
5931  if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID())
5932  return false;
5933 
5934  WeaponAttackType attType = WeaponAttackType(player->GetAttackBySlot(castItem->GetSlot(), castItem->GetTemplate()->GetInventoryType()));
5935  if ((attType != BASE_ATTACK && attType != OFF_ATTACK)
5936  || (attType == BASE_ATTACK && procFlag & PROC_FLAG_DONE_OFFHAND_ATTACK)
5937  || (attType == OFF_ATTACK && procFlag & PROC_FLAG_DONE_MAINHAND_ATTACK))
5938  return false;
5939 
5940  // Now compute real proc chance...
5941  uint32 chance = 20;
5942  player->ApplySpellMod(dummySpell->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance);
5943 
5944  Item* addWeapon = player->GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK, true);
5945  uint32 enchant_id_add = addWeapon ? addWeapon->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)) : 0;
5946  SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id_add);
5947  if (pEnchant && pEnchant->EffectSpellID[0] == dummySpell->Id)
5948  chance += 14;
5949 
5950  if (!roll_chance_i(chance))
5951  return false;
5952 
5953  // Now amount of extra power stored in 1 effect of Enchant spell
5954  uint32 spellId = 8232;
5955  SpellInfo const* windfurySpellInfo = sSpellMgr->GetSpellInfo(spellId);
5956  if (!windfurySpellInfo)
5957  {
5958  TC_LOG_ERROR("entities.unit", "Unit::HandleDummyAuraProc: non-existing spell id: %u (Windfury)", spellId);
5959  return false;
5960  }
5961 
5962  int32 extra_attack_power = CalculateSpellDamage(victim, windfurySpellInfo, 1);
5963 
5964  // Value gained from additional AP
5965  basepoints0 = int32(extra_attack_power / 14.0f * GetAttackTime(attType) / 1000);
5966 
5967  if (procFlag & PROC_FLAG_DONE_MAINHAND_ATTACK)
5968  triggered_spell_id = 25504;
5969 
5970  if (procFlag & PROC_FLAG_DONE_OFFHAND_ATTACK)
5971  triggered_spell_id = 33750;
5972 
5973  // apply cooldown before cast to prevent processing itself
5974  if (cooldown)
5975  player->GetSpellHistory()->AddCooldown(dummySpell->Id, 0, std::chrono::seconds(cooldown));
5976 
5977  // Attack Twice
5978  for (uint32 i = 0; i < 2; ++i)
5979  CastCustomSpell(victim, triggered_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura);
5980 
5981  return true;
5982  }
5983  // Shaman Tier 6 Trinket
5984  case 40463:
5985  {
5986  if (!procSpell)
5987  return false;
5988 
5989  float chance;
5990  if (procSpell->SpellFamilyFlags[0] & 0x1)
5991  {
5992  triggered_spell_id = 40465; // Lightning Bolt
5993  chance = 15.0f;
5994  }
5995  else if (procSpell->SpellFamilyFlags[0] & 0x80)
5996  {
5997  triggered_spell_id = 40465; // Lesser Healing Wave
5998  chance = 10.0f;
5999  }
6000  else if (procSpell->SpellFamilyFlags[1] & 0x00000010)
6001  {
6002  triggered_spell_id = 40466; // Stormstrike
6003  chance = 50.0f;
6004  }
6005  else
6006  return false;
6007 
6008  if (!roll_chance_f(chance))
6009  return false;
6010 
6011  target = this;
6012  break;
6013  }
6014  // Spirit Hunt
6015  case 58877:
6016  {
6017  // Cast on owner
6018  target = GetOwner();
6019  if (!target)
6020  return false;
6021  basepoints0 = CalculatePct(int32(damage), triggerAmount);
6022  triggered_spell_id = 58879;
6023  // Cast on spirit wolf
6024  CastCustomSpell(this, triggered_spell_id, &basepoints0, NULL, NULL, true, NULL, triggeredByAura);
6025  break;
6026  }
6027  // Shaman T8 Elemental 4P Bonus
6028  case 64928:
6029  {
6030  basepoints0 = CalculatePct(int32(damage), triggerAmount);
6031  triggered_spell_id = 64930; // Electrified
6032  break;
6033  }
6034  // Shaman T9 Elemental 4P Bonus
6035  case 67228:
6036  {
6037  // Lava Burst
6038  if (procSpell && procSpell->SpellFamilyFlags[1] & 0x1000)
6039  {
6040  triggered_spell_id = 71824;
6041  SpellInfo const* triggeredSpell = sSpellMgr->GetSpellInfo(triggered_spell_id);
6042  if (!triggeredSpell)
6043  return false;
6044  if (SpellEffectInfo const* effect = triggeredSpell->GetEffect(DIFFICULTY_NONE, EFFECT_0))
6045  basepoints0 = CalculatePct(int32(damage), triggerAmount) / (triggeredSpell->GetMaxDuration() / effect->ApplyAuraPeriod);
6046  }
6047  break;
6048  }
6049  // Item - Shaman T10 Restoration 4P Bonus
6050  case 70808:
6051  {
6052  // Chain Heal
6053  if (procSpell && (procSpell->SpellFamilyFlags[0] & 0x100) && (procEx & PROC_EX_CRITICAL_HIT))
6054  {
6055  triggered_spell_id = 70809;
6056  SpellInfo const* triggeredSpell = sSpellMgr->GetSpellInfo(triggered_spell_id);
6057  if (!triggeredSpell)
6058  return false;
6059  if (SpellEffectInfo const* effect = triggeredSpell->GetEffect(DIFFICULTY_NONE, EFFECT_0))
6060  {
6061  basepoints0 = CalculatePct(int32(damage), triggerAmount) / (triggeredSpell->GetMaxDuration() / effect->ApplyAuraPeriod);
6062  // Add remaining ticks to healing done
6063  basepoints0 += GetRemainingPeriodicAmount(GetGUID(), triggered_spell_id, SPELL_AURA_PERIODIC_HEAL);
6064  }
6065  }
6066  break;
6067  }
6068  // Item - Shaman T10 Elemental 4P Bonus
6069  case 70817:
6070  {
6071  if (!target)
6072  return false;
6073  // try to find spell Flame Shock on the target
6074  if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, flag128(0x10000000, 0x0, 0x0), GetGUID()))
6075  {
6076  Aura* flameShock = aurEff->GetBase();
6077  int32 maxDuration = flameShock->GetMaxDuration();
6078  int32 newDuration = flameShock->GetDuration() + 2 * aurEff->GetPeriod();
6079 
6080  flameShock->SetDuration(newDuration);
6081  // is it blizzlike to change max duration for FS?
6082  if (newDuration > maxDuration)
6083  flameShock->SetMaxDuration(newDuration);
6084 
6085  return true;
6086  }
6087  // if not found Flame Shock
6088  return false;
6089  }
6090  break;
6091  }
6092  // Frozen Power
6093  if (dummySpell->SpellIconID == 3780)
6094  {
6095  if (!target)
6096  return false;
6097  if (GetDistance(target) < 15.0f)
6098  return false;
6099  float chance = (float)triggerAmount;
6100  if (!roll_chance_f(chance))
6101  return false;
6102 
6103  triggered_spell_id = 63685;
6104  break;
6105  }
6106  // Static Shock
6107  if (dummySpell->SpellIconID == 3059)
6108  {
6109  // Lightning Shield
6111  {
6112  uint32 spell = 26364;
6113 
6114  GetSpellHistory()->ResetCooldown(spell);
6115  CastSpell(target, spell, true, castItem, triggeredByAura);
6116  return true;
6117  }
6118  return false;
6119  }
6120  break;
6121  }
6123  {
6124  // Dancing Rune Weapon
6125  if (dummySpell->Id == 49028)
6126  {
6127  // 1 dummy aura for dismiss rune blade
6128  if (effIndex != 1)
6129  return false;
6130 
6131  Unit* pPet = NULL;
6132  for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) // Find Rune Weapon
6133  if ((*itr)->GetEntry() == 27893)
6134  {
6135  pPet = *itr;
6136  break;
6137  }
6138 
6139  if (pPet && pPet->GetVictim() && damage && procSpell)
6140  {
6141  uint32 procDmg = damage / 2;
6142 
6143  SpellNonMeleeDamage log(pPet, pPet->GetVictim(), procSpell->Id, procSpell->GetSchoolMask());
6144  log.damage = procDmg;
6145  pPet->DealDamage(pPet->GetVictim(), procDmg, NULL, SPELL_DIRECT_DAMAGE, procSpell->GetSchoolMask(), procSpell, true);
6147  break;
6148  }
6149  else
6150  return false;
6151  }
6152  // Threat of Thassarian
6153  if (dummySpell->SpellIconID == 2023)
6154  {
6155  // Must Dual Wield
6156  if (!procSpell || !haveOffhandWeapon())
6157  return false;
6158  // Chance as basepoints for dummy aura
6159  if (!roll_chance_i(triggerAmount))
6160  return false;
6161 
6162  switch (procSpell->Id)
6163  {
6164  case 49020: triggered_spell_id = 66198; break; // Obliterate
6165  case 49143: triggered_spell_id = 66196; break; // Frost Strike
6166  case 45462: triggered_spell_id = 66216; break; // Plague Strike
6167  case 49998: triggered_spell_id = 66188; break; // Death Strike
6168  case 56815: triggered_spell_id = 66217; break; // Rune Strike
6169  case 45902: triggered_spell_id = 66215; break; // Blood Strike
6170  default:
6171  return false;
6172  }
6173  break;
6174  }
6175  // Runic Power Back on Snare/Root
6176  if (dummySpell->Id == 61257)
6177  {
6178  // only for spells and hit/crit (trigger start always) and not start from self cast spells
6179  if (!procSpell || !(procEx & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) || this == victim)
6180  return false;
6181  // Need snare or root mechanic
6182  if (!(procSpell->GetAllEffectsMechanicMask() & ((1<<MECHANIC_ROOT)|(1<<MECHANIC_SNARE))))
6183  return false;
6184  triggered_spell_id = 61258;
6185  target = this;
6186  break;
6187  }
6188  break;
6189  }
6190  case SPELLFAMILY_PET:
6191  {
6192  break;
6193  }
6194  default:
6195  break;
6196  }
6197 
6198  // if not handled by custom case, get triggered spell from dummySpell proto
6199  if (!triggered_spell_id)
6200  triggered_spell_id = triggeredByAura->GetSpellEffectInfo()->TriggerSpell;
6201 
6202  // processed charge only counting case
6203  if (!triggered_spell_id)
6204  return true;
6205 
6206  SpellInfo const* triggerEntry = sSpellMgr->GetSpellInfo(triggered_spell_id);
6207  if (!triggerEntry)
6208  {
6209  TC_LOG_ERROR("entities.unit", "Unit::HandleDummyAuraProc: Spell %u has non-existing triggered spell %u", dummySpell->Id, triggered_spell_id);
6210  return false;
6211  }
6212 
6213  if (cooldown_spell_id == 0)
6214  cooldown_spell_id = triggered_spell_id;
6215 
6216  if (cooldown && GetTypeId() == TYPEID_PLAYER && GetSpellHistory()->HasCooldown(cooldown_spell_id))
6217  return false;
6218 
6219  if (basepoints0)
6220  CastCustomSpell(target, triggered_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura, originalCaster);
6221  else
6222  CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura, originalCaster);
6223 
6224  if (cooldown)
6225  GetSpellHistory()->AddCooldown(cooldown_spell_id, 0, std::chrono::seconds(cooldown));
6226 
6227  return true;
6228 }
void DoCastSpellOnPlayers(uint32 spell)
Definition: InstanceScript.cpp:558
Definition: SpellAuraDefines.h:68
Definition: SpellMgr.h:200
Definition: SpellAuraEffects.h:30
Definition: SpellAuraDefines.h:63
Definition: SharedDefines.h:170
uint32 GetCreateMana() const
Definition: Unit.h:1897
Definition: DBCEnums.h:404
Definition: SharedDefines.h:4633
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
uint32 Id
Definition: SpellInfo.h:329
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:46
SpellEffectInfo const * GetSpellEffectInfo() const
Definition: SpellAuraEffects.h:102
Definition: Unit.h:104
Definition: SharedDefines.h:220
Guardian * GetGuardianPet() const
Definition: Unit.cpp:7596
Definition: SharedDefines.h:1802
Definition: SharedDefines.h:961
Definition: SharedDefines.h:29
void AddCooldown(uint32 spellId, uint32 itemId, std::chrono::duration< Type, Period > cooldownDuration)
Definition: SpellHistory.h:95
uint32 GetEffIndex() const
Definition: SpellAuraEffects.h:48
Definition: SharedDefines.h:172
int32 GetMaxDuration() const
Definition: SpellAuras.h:159
Definition: SpellInfo.h:166
Definition: SpellInfo.h:326
uint32 GetId() const
Definition: SpellAuraEffects.h:47
Definition: SharedDefines.h:28
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4151
uint32 GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex=0) const
Definition: Unit.cpp:15667
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:133
InstanceScript * GetInstanceScript()
Definition: Object.cpp:1540
void SetMaxDuration(int32 duration)
Definition: SpellAuras.h:160
EnchantmentSlot
Definition: Item.h:172
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
bool IsEquipped() const
Definition: Item.cpp:764
TC_SHARED_API::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions,::google::protobuf::internal::EnumTypeTraits< ::bgs::protocol::LogOption,::bgs::protocol::LogOption_IsValid >, 14, false > log
void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3602
Definition: ObjectGuid.h:32
Definition: SharedDefines.h:4638
Definition: SharedDefines.h:254
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:249
int32 ModifyHealth(int32 val)
Definition: Unit.cpp:10216
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
Definition: SharedDefines.h:1801
Unit * GetCaster() const
Definition: SpellAuraEffects.h:39
Definition: SpellInfo.h:553
Definition: SharedDefines.h:4628
float seconds()
Definition: units.h:97
Definition: DBCStructure.h:1214
static First const & RAND(First const &first, Second const &second, Rest const &...rest)
Definition: CreatureAIImpl.h:30
Definition: SharedDefines.h:168
Player * ToPlayer()
Definition: Object.h:191
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.cpp:10326
Definition: SharedDefines.h:167
Definition: SharedDefines.h:292
InventoryType GetInventoryType() const
Definition: ItemTemplate.h:664
Powers getPowerType() const
Definition: Unit.h:1444
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:171
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: SharedDefines.h:1797
Definition: SharedDefines.h:4626
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
Definition: Item.h:175
Definition: Unit.h:1042
Definition: Unit.h:618
bool roll_chance_f(float chance)
Definition: Random.h:47
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
AuraEffect * GetEffect(uint32 index) const
Definition: SpellAuras.cpp:448
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Definition: SharedDefines.h:4634
Definition: SharedDefines.h:4629
bool IsAlive() const
Definition: Unit.h:1692
Unit * GetVictim() const
Definition: Unit.h:1379
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
Definition: SpellMgr.h:144
Definition: Item.h:259
Definition: Util.h:362
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
int32 CalculateSpellDamage(Unit const *target, SpellInfo const *spellProto, uint8 effect_index, int32 const *basePoints=nullptr, float *variance=nullptr, int32 itemLevel=-1) const
Definition: Unit.cpp:10930
uint32_t uint32
Definition: Define.h:150
bool roll_chance_i(int chance)
Definition: Random.h:53
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
Definition: SharedDefines.h:173
Definition: SharedDefines.h:293
bool haveOffhandWeapon() const
Definition: Unit.cpp:418
Definition: SharedDefines.h:4630
int32 GetDuration() const
Definition: SpellAuras.h:163
Definition: SharedDefines.h:174
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: SharedDefines.h:4640
ControlList m_Controlled
Definition: Unit.h:1738
uint8 GetSlot() const
Definition: Item.h:329
Definition: SpellMgr.h:199
int32 GetMaxDuration() const
Definition: SpellInfo.cpp:2497
SpellEffectInfo const * GetEffect(uint32 difficulty, uint32 index) const
Definition: SpellInfo.cpp:3348
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3586
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void ResetCooldown(uint32 spellId, bool update=false)
Definition: SpellHistory.cpp:549
Definition: ObjectGuid.h:33
void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const *log)
Definition: Unit.cpp:4839
void SetAmount(int32 amount)
Definition: SpellAuraEffects.h:56
Definition: SpellAuraDefines.h:102
Definition: SharedDefines.h:4623
void RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveMode removemode=AURA_REMOVE_BY_DEFAULT, uint32 except=0)
Definition: Unit.cpp:3870
Definition: Unit.h:453
Definition: SharedDefines.h:251
uint32 EffectSpellID[MAX_ITEM_ENCHANTMENT_EFFECTS]
Definition: DBCStructure.h:1220
bool HasCooldown(SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
Definition: SpellHistory.cpp:591
Unit * GetOwner() const
Definition: Unit.cpp:7542
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
Definition: SharedDefines.h:169
Definition: Common.h:103
int32_t int32
Definition: g3dmath.h:167
uint8 getClass() const
Definition: Unit.h:1413
uint32 SpellIconID
Definition: SpellInfo.h:390
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
uint8 GetCharges() const
Definition: SpellAuras.h:170
Definition: InstanceScript.h:141
uint8_t uint8
Definition: Define.h:152
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:806
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
Definition: Unit.h:663
Definition: SharedDefines.h:175
Definition: SpellAuras.h:116
uint32 GetHealth() const
Definition: Unit.h:1426
Definition: SharedDefines.h:177
WeaponAttackType
Definition: Unit.h:615
Definition: Unit.h:1305
uint8 GetRank() const
Definition: SpellInfo.cpp:2746
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: SpellMgr.h:145
uint32 DealDamage(Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=NULL, bool durabilityLoss=true)
Definition: Unit.cpp:613
bool IsEmpty() const
Definition: ObjectGuid.h:242
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:129
Definition: Unit.h:617
Definition: SharedDefines.h:248
uint32 ApplyAuraPeriod
Definition: SpellInfo.h:245
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:351
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the caller graph for this function:

void Unit::HandleEmoteCommand ( uint32  anim_id)
1445 {
1447  packet.Guid = GetGUID();
1448  packet.EmoteID = anim_id;
1449  SendMessageToSet(packet.Write(), true);
1450 }
Definition: ChatPackets.h:183
WorldPacket const * Write() override
Definition: ChatPackets.cpp:194
int32 EmoteID
Definition: ChatPackets.h:191
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
ObjectGuid Guid
Definition: ChatPackets.h:190

+ Here is the call graph for this function:

bool Unit::HandleOverrideClassScriptAuraProc ( Unit victim,
uint32  damage,
AuraEffect triggeredByAura,
SpellInfo const procSpell,
uint32  cooldown 
)
private
6917 {
6918  int32 scriptId = triggeredByAura->GetMiscValue();
6919 
6920  if (!victim || !victim->IsAlive())
6921  return false;
6922 
6923  Item* castItem = !triggeredByAura->GetBase()->GetCastItemGUID().IsEmpty() && GetTypeId() == TYPEID_PLAYER
6924  ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
6925 
6926  uint32 triggered_spell_id = 0;
6927 
6928  switch (scriptId)
6929  {
6930  case 4533: // Dreamwalker Raiment 2 pieces bonus
6931  {
6932  // Chance 50%
6933  if (!roll_chance_i(50))
6934  return false;
6935 
6936  switch (victim->getPowerType())
6937  {
6938  case POWER_MANA: triggered_spell_id = 28722; break;
6939  case POWER_RAGE: triggered_spell_id = 28723; break;
6940  case POWER_ENERGY: triggered_spell_id = 28724; break;
6941  default:
6942  return false;
6943  }
6944  break;
6945  }
6946  case 4537: // Dreamwalker Raiment 6 pieces bonus
6947  triggered_spell_id = 28750; // Blessing of the Claw
6948  break;
6949  default:
6950  break;
6951  }
6952 
6953  // not processed
6954  if (!triggered_spell_id)
6955  return false;
6956 
6957  // standard non-dummy case
6958  SpellInfo const* triggerEntry = sSpellMgr->GetSpellInfo(triggered_spell_id);
6959 
6960  if (!triggerEntry)
6961  {
6962  TC_LOG_ERROR("entities.unit", "Unit::HandleOverrideClassScriptAuraProc: Spell %u triggering for class script id %u", triggered_spell_id, scriptId);
6963  return false;
6964  }
6965 
6966  if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetSpellHistory()->HasCooldown(triggered_spell_id))
6967  return false;
6968 
6969  CastSpell(victim, triggered_spell_id, true, castItem, triggeredByAura);
6970 
6971  if (cooldown)
6972  GetSpellHistory()->AddCooldown(triggered_spell_id, 0, std::chrono::seconds(cooldown));
6973 
6974  return true;
6975 }
void AddCooldown(uint32 spellId, uint32 itemId, std::chrono::duration< Type, Period > cooldownDuration)
Definition: SpellHistory.h:95
int32 GetMiscValue() const
Definition: SpellAuraEffects.h:53
Definition: SpellInfo.h:326
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:133
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:249
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
float seconds()
Definition: units.h:97
Player * ToPlayer()
Definition: Object.h:191
Powers getPowerType() const
Definition: Unit.h:1444
TypeID GetTypeId() const
Definition: Object.h:113
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
bool IsAlive() const
Definition: Unit.h:1692
Definition: Item.h:259
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
bool roll_chance_i(int chance)
Definition: Random.h:53
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:251
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: SharedDefines.h:248

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::HandleProcExtraAttackFor ( Unit victim)
1919 {
1920  while (m_extraAttacks)
1921  {
1922  AttackerStateUpdate(victim, BASE_ATTACK, true);
1923  --m_extraAttacks;
1924  }
1925 }
void AttackerStateUpdate(Unit *victim, WeaponAttackType attType=BASE_ATTACK, bool extra=false)
Definition: Unit.cpp:1874
uint32 m_extraAttacks
Definition: Unit.h:1366
Definition: Unit.h:617

+ Here is the call graph for this function:

bool Unit::HandleProcTriggerSpell ( Unit victim,
uint32  damage,
AuraEffect triggeredByAura,
SpellInfo const procSpell,
uint32  procFlag,
uint32  procEx,
uint32  cooldown 
)
private
Todo:
: reverify and move these spells to spellscripts
6416 {
6417  // Get triggered aura spell info
6418  SpellInfo const* auraSpellInfo = triggeredByAura->GetSpellInfo();
6419 
6420  // Basepoints of trigger aura
6421  int32 triggerAmount = triggeredByAura->GetAmount();
6422 
6423  // Set trigger spell id, target, custom basepoints
6424  uint32 trigger_spell_id = triggeredByAura->GetSpellEffectInfo()->TriggerSpell;
6425 
6426  Unit* target = NULL;
6427  int32 basepoints0 = 0;
6428 
6429  if (triggeredByAura->GetAuraType() == SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE)
6430  basepoints0 = triggerAmount;
6431 
6432  Item* castItem = !triggeredByAura->GetBase()->GetCastItemGUID().IsEmpty() && GetTypeId() == TYPEID_PLAYER
6433  ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
6434 
6435  // Try handle unknown trigger spells
6436  // triggered spells exists only in serverside spell_dbc
6438  {
6439  switch (auraSpellInfo->SpellFamilyName)
6440  {
6441  case SPELLFAMILY_GENERIC:
6442  switch (auraSpellInfo->Id)
6443  {
6444  case 57345: // Darkmoon Card: Greatness
6445  {
6446  float stat = 0.0f;
6447  // strength
6448  if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 60229;stat = GetStat(STAT_STRENGTH); }
6449  // agility
6450  if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 60233;stat = GetStat(STAT_AGILITY); }
6451  // intellect
6452  if (GetStat(STAT_INTELLECT)> stat) { trigger_spell_id = 60234;stat = GetStat(STAT_INTELLECT);}
6453  // spirit
6454  if (GetStat(STAT_SPIRIT) > stat) { trigger_spell_id = 60235; }
6455  break;
6456  }
6457  case 64568: // Blood Reserve
6458  {
6459  if (HealthBelowPctDamaged(35, damage))
6460  {
6461  CastCustomSpell(this, 64569, &triggerAmount, NULL, NULL, true);
6462  RemoveAura(64568);
6463  }
6464  return false;
6465  }
6466  case 67702: // Death's Choice, Item - Coliseum 25 Normal Melee Trinket
6467  {
6468  float stat = 0.0f;
6469  // strength
6470  if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 67708;stat = GetStat(STAT_STRENGTH); }
6471  // agility
6472  if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 67703; }
6473  break;
6474  }
6475  case 67771: // Death's Choice (heroic), Item - Coliseum 25 Heroic Melee Trinket
6476  {
6477  float stat = 0.0f;
6478  // strength
6479  if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 67773;stat = GetStat(STAT_STRENGTH); }
6480  // agility
6481  if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 67772; }
6482  break;
6483  }
6484  // Mana Drain Trigger
6485  case 27522:
6486  case 40336:
6487  {
6488  // On successful melee or ranged attack gain $29471s1 mana and if possible drain $27526s1 mana from the target.
6489  if (IsAlive())
6490  CastSpell(this, 29471, true, castItem, triggeredByAura);
6491  if (victim && victim->IsAlive())
6492  CastSpell(victim, 27526, true, castItem, triggeredByAura);
6493  return true;
6494  }
6495  // Evasive Maneuvers
6496  case 50240:
6497  {
6498  // Remove a Evasive Charge
6499  Aura* charge = GetAura(50241);
6500  if (charge && charge->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL))
6501  RemoveAurasDueToSpell(50240);
6502  break;
6503  }
6504  }
6505  break;
6506  case SPELLFAMILY_DRUID:
6507  {
6508  switch (auraSpellInfo->Id)
6509  {
6510  // Druid Forms Trinket
6511  case 37336:
6512  {
6513  switch (GetShapeshiftForm())
6514  {
6515  case FORM_NONE: trigger_spell_id = 37344; break;
6516  case FORM_CAT: trigger_spell_id = 37341; break;
6517  case FORM_BEAR: trigger_spell_id = 37340; break;
6518  case FORM_TREE: trigger_spell_id = 37342; break;
6519  case FORM_MOONKIN: trigger_spell_id = 37343; break;
6520  default:
6521  return false;
6522  }
6523  break;
6524  }
6525  // Druid T9 Feral Relic (Lacerate, Swipe, Mangle, and Shred)
6526  case 67353:
6527  {
6528  switch (GetShapeshiftForm())
6529  {
6530  case FORM_CAT: trigger_spell_id = 67355; break;
6531  case FORM_BEAR: trigger_spell_id = 67354; break;
6532  default:
6533  return false;
6534  }
6535  break;
6536  }
6537  default:
6538  break;
6539  }
6540  break;
6541  }
6542  case SPELLFAMILY_HUNTER:
6543  {
6544  /*if (auraSpellInfo->SpellIconID == 3247) // Piercing Shots
6545  {
6546  trigger_spell_id = 63468; // 6.x missing from dbc but it is in the tooltip
6547  SpellInfo const* TriggerPS = sSpellMgr->GetSpellInfo(trigger_spell_id);
6548  if (!TriggerPS)
6549  return false;
6550 
6551  basepoints0 = CalculatePct(int32(damage), triggerAmount) / (TriggerPS->GetMaxDuration() / TriggerPS->Effects[0].ApplyAuraPeriod);
6552  basepoints0 += victim->GetRemainingPeriodicAmount(GetGUID(), trigger_spell_id, SPELL_AURA_PERIODIC_DAMAGE);
6553  break;
6554  }*/
6555  // Item - Hunter T9 4P Bonus
6556  if (auraSpellInfo->Id == 67151)
6557  {
6558  trigger_spell_id = 68130;
6559  target = this;
6560  break;
6561  }
6562  break;
6563  }
6564  case SPELLFAMILY_PALADIN:
6565  {
6566  switch (auraSpellInfo->Id)
6567  {
6568  // Soul Preserver
6569  case 60510:
6570  {
6571  switch (getClass())
6572  {
6573  case CLASS_DRUID:
6574  trigger_spell_id = 60512;
6575  break;
6576  case CLASS_PALADIN:
6577  trigger_spell_id = 60513;
6578  break;
6579  case CLASS_PRIEST:
6580  trigger_spell_id = 60514;
6581  break;
6582  case CLASS_SHAMAN:
6583  trigger_spell_id = 60515;
6584  break;
6585  }
6586 
6587  target = this;
6588  break;
6589  }
6590  case 37657: // Lightning Capacitor
6591  case 54841: // Thunder Capacitor
6592  case 67712: // Item - Coliseum 25 Normal Caster Trinket
6593  case 67758: // Item - Coliseum 25 Heroic Caster Trinket
6594  {
6595  if (!victim || !victim->IsAlive() || GetTypeId() != TYPEID_PLAYER)
6596  return false;
6597 
6598  uint32 stack_spell_id = 0;
6599  switch (auraSpellInfo->Id)
6600  {
6601  case 37657:
6602  stack_spell_id = 37658;
6603  trigger_spell_id = 37661;
6604  break;
6605  case 54841:
6606  stack_spell_id = 54842;
6607  trigger_spell_id = 54843;
6608  break;
6609  case 67712:
6610  stack_spell_id = 67713;
6611  trigger_spell_id = 67714;
6612  break;
6613  case 67758:
6614  stack_spell_id = 67759;
6615  trigger_spell_id = 67760;
6616  break;
6617  }
6618 
6619  CastSpell(this, stack_spell_id, true, NULL, triggeredByAura);
6620 
6621  Aura* dummy = GetAura(stack_spell_id);
6622  if (!dummy || dummy->GetStackAmount() < triggerAmount)
6623  return false;
6624 
6625  RemoveAurasDueToSpell(stack_spell_id);
6626  target = victim;
6627  break;
6628  }
6629  default:
6630  break;
6631  }
6632  break;
6633  }
6635  {
6636  // Item - Death Knight T10 Melee 4P Bonus
6637  if (auraSpellInfo->Id == 70656)
6638  {
6640  return false;
6641 
6642  for (uint8 i = 0; i < MAX_RUNES; ++i)
6643  if (ToPlayer()->GetRuneCooldown(i) == 0)
6644  return false;
6645  }
6646  break;
6647  }
6648  case SPELLFAMILY_ROGUE:
6649  {
6650  switch (auraSpellInfo->Id)
6651  {
6652  // Rogue T10 2P bonus, should only proc on caster
6653  case 70805:
6654  {
6655  if (victim != this)
6656  return false;
6657  break;
6658  }
6659  }
6660  break;
6661  }
6662  default:
6663  break;
6664  }
6665  }
6666 
6667  // All ok. Check current trigger spell
6668  SpellInfo const* triggerEntry = sSpellMgr->GetSpellInfo(trigger_spell_id);
6669  if (triggerEntry == NULL)
6670  {
6671  // Don't cast unknown spell
6672  TC_LOG_ERROR("entities.unit", "Unit::HandleProcTriggerSpell: Spell %u (effIndex: %u) has unknown TriggerSpell %u. Unhandled custom case?", auraSpellInfo->Id, triggeredByAura->GetEffIndex(), trigger_spell_id);
6673  return false;
6674  }
6675 
6676  // not allow proc extra attack spell at extra attack
6677  if (m_extraAttacks && triggerEntry->HasEffect(GetMap()->GetDifficultyID(), SPELL_EFFECT_ADD_EXTRA_ATTACKS))
6678  return false;
6679 
6680  // Custom requirements (not listed in procEx) Warning! damage dealing after this
6681  // Custom triggered spells
6682  switch (auraSpellInfo->Id)
6683  {
6684  // Deep Wounds
6685  case 12834:
6686  case 12849:
6687  case 12867:
6688  {
6689  if (GetTypeId() != TYPEID_PLAYER)
6690  return false;
6691 
6692  float averageDmg = 0;
6693  // now compute approximate weapon damage by formula from wowwiki.com
6694  if (procFlags & PROC_FLAG_DONE_OFFHAND_ATTACK)
6696  else
6698 
6699  basepoints0 = int32(averageDmg);
6700  break;
6701  }
6702  // Persistent Shield (Scarab Brooch trinket)
6703  // This spell originally trigger 13567 - Dummy Trigger (vs dummy efect)
6704  case 26467:
6705  {
6706  basepoints0 = int32(CalculatePct(damage, 15));
6707  target = victim;
6708  trigger_spell_id = 26470;
6709  break;
6710  }
6711  // Unyielding Knights (item exploit 29108\29109)
6712  case 38164:
6713  {
6714  if (!victim || victim->GetEntry() != 19457) // Proc only if your target is Grillok
6715  return false;
6716  break;
6717  }
6718  // Deflection
6719  case 52420:
6720  {
6721  if (!HealthBelowPctDamaged(35, damage))
6722  return false;
6723  break;
6724  }
6725 
6726  // Cheat Death
6727  case 28845:
6728  {
6729  // When your health drops below 20%
6730  if (HealthBelowPctDamaged(20, damage) || HealthBelowPct(20))
6731  return false;
6732  break;
6733  }
6734  // Greater Heal Refund (Avatar Raiment set)
6735  case 37594:
6736  {
6737  if (!victim || !victim->IsAlive())
6738  return false;
6739 
6740  // Doesn't proc if target already has full health
6741  if (victim->IsFullHealth())
6742  return false;
6743  // If your Greater Heal brings the target to full health, you gain $37595s1 mana.
6744  if (victim->GetHealth() + damage < victim->GetMaxHealth())
6745  return false;
6746  break;
6747  }
6748  // Bonus Healing (Crystal Spire of Karabor mace)
6749  case 40971:
6750  {
6751  // If your target is below $s1% health
6752  if (!victim || !victim->IsAlive() || victim->HealthAbovePct(triggerAmount))
6753  return false;
6754  break;
6755  }
6756  // Decimation
6757  case 108869:
6758  // Can proc only if target has hp below 25%
6759  if (!victim || !victim->HealthBelowPct(triggeredByAura->GetSpellEffectInfo()->CalcValue()))
6760  return false;
6761  break;
6762  // Deathbringer Saurfang - Blood Beast's Blood Link
6763  case 72176:
6764  basepoints0 = 3;
6765  break;
6766  // Professor Putricide - Ooze Spell Tank Protection
6767  case 71770:
6768  if (victim)
6769  victim->CastSpell(victim, trigger_spell_id, true); // EffectImplicitTarget is self
6770  return true;
6771  case 45057: // Evasive Maneuvers (Commendation of Kael`thas trinket)
6772  case 71634: // Item - Icecrown 25 Normal Tank Trinket 1
6773  case 71640: // Item - Icecrown 25 Heroic Tank Trinket 1
6774  case 75475: // Item - Chamber of Aspects 25 Normal Tank Trinket
6775  case 75481: // Item - Chamber of Aspects 25 Heroic Tank Trinket
6776  {
6777  // Procs only if damage takes health below $s1%
6778  if (!HealthBelowPctDamaged(triggerAmount, damage))
6779  return false;
6780  break;
6781  }
6782  default:
6783  break;
6784  }
6785 
6786  // Custom basepoints/target for exist spell
6787  // dummy basepoints or other customs
6788  switch (trigger_spell_id)
6789  {
6790  // Auras which should proc on area aura source (caster in this case):
6791  // Cast positive spell on enemy target
6792  case 7099: // Curse of Mending
6793  case 39703: // Curse of Mending
6794  case 29494: // Temptation
6795  case 20233: // Improved Lay on Hands (cast on target)
6796  {
6797  target = victim;
6798  break;
6799  }
6800  // Finish movies that add combo
6801  case 14189: // Seal Fate (Netherblade set)
6802  case 14157: // Ruthlessness
6803  {
6804  if (!victim || victim == this)
6805  return false;
6806  // Need add combopoint AFTER finish movie (or they dropped in finish phase)
6807  break;
6808  }
6809  // Item - Druid T10 Balance 2P Bonus
6810  case 16870:
6811  {
6812  if (HasAura(70718))
6813  CastSpell(this, 70721, true);
6814  break;
6815  }
6816  // Enlightenment (trigger only from mana cost spells)
6817  case 35095:
6818  {
6819  if (!procSpell)
6820  return false;
6821 
6822  std::vector<SpellInfo::CostData> costs = procSpell->CalcPowerCost(this, procSpell->GetSchoolMask());
6823  auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA && cost.Amount > 0; });
6824  if (m == costs.end())
6825  return false;
6826  break;
6827  }
6828  case 46916: // Slam! (Bloodsurge proc)
6829  case 52437: // Sudden Death
6830  {
6831  // Item - Warrior T10 Melee 4P Bonus
6832  if (AuraEffect const* aurEff = GetAuraEffect(70847, 0))
6833  {
6834  if (!roll_chance_i(aurEff->GetAmount()))
6835  break;
6836  CastSpell(this, 70849, true, castItem, triggeredByAura); // Extra Charge!
6837  CastSpell(this, 71072, true, castItem, triggeredByAura); // Slam GCD Reduced
6838  CastSpell(this, 71069, true, castItem, triggeredByAura); // Execute GCD Reduced
6839  }
6840  break;
6841  }
6842  // Maelstrom Weapon
6843  case 53817:
6844  {
6845  // has rank dependant proc chance, ignore too often cases
6846  // PPM = 2.5 * (rank of talent),
6847  uint32 rank = auraSpellInfo->GetRank();
6848  // 5 rank -> 100% 4 rank -> 80% and etc from full rate
6849  if (!roll_chance_i(20*rank))
6850  return false;
6851  // Item - Shaman T10 Enhancement 4P Bonus
6852  if (AuraEffect const* aurEff = GetAuraEffect(70832, 0))
6853  if (Aura const* maelstrom = GetAura(53817))
6854  if ((maelstrom->GetStackAmount() == maelstrom->GetSpellInfo()->StackAmount) && roll_chance_i(aurEff->GetAmount()))
6855  CastSpell(this, 70831, true, castItem, triggeredByAura);
6856  break;
6857  }
6858  // Glyph of Death's Embrace
6859  case 58679:
6860  {
6861  // Proc only from healing part of Death Coil. Check is essential as all Death Coil spells have 0x2000 mask in SpellFamilyFlags
6862  if (!procSpell || !(procSpell->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && procSpell->SpellFamilyFlags[0] == 0x80002000))
6863  return false;
6864  break;
6865  }
6866  // Savage Defense
6867  case 62606:
6868  {
6869  basepoints0 = CalculatePct(triggerAmount, GetTotalAttackPowerValue(BASE_ATTACK));
6870  break;
6871  }
6872  // Body and Soul
6873  case 64128:
6874  case 65081:
6875  {
6876  // Proc only from PW:S cast
6877  if (!(procSpell->SpellFamilyFlags[0] & 0x00000001))
6878  return false;
6879  break;
6880  }
6881  // Culling the Herd
6882  case 70893:
6883  {
6884  // check if we're doing a critical hit
6885  if (!(procSpell->SpellFamilyFlags[1] & 0x10000000) && (procEx != PROC_EX_CRITICAL_HIT))
6886  return false;
6887  // check if we're procced by Claw, Bite or Smack (need to use the spell icon ID to detect it)
6888  if (!(procSpell->SpellIconID == 262 || procSpell->SpellIconID == 1680 || procSpell->SpellIconID == 473))
6889  return false;
6890  break;
6891  }
6892  }
6893 
6894  if (cooldown && GetTypeId() == TYPEID_PLAYER && GetSpellHistory()->HasCooldown(trigger_spell_id))
6895  return false;
6896 
6897  // extra attack should hit same target
6898  if (triggerEntry->HasEffect(GetMap()->GetDifficultyID(), SPELL_EFFECT_ADD_EXTRA_ATTACKS))
6899  target = victim;
6900 
6901  // try detect target manually if not set
6902  if (target == NULL)
6903  target = !(procFlags & (PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS)) && triggerEntry->IsPositive() ? this : victim;
6904 
6905  if (basepoints0)
6906  CastCustomSpell(target, trigger_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura);
6907  else
6908  CastSpell(target, trigger_spell_id, true, castItem, triggeredByAura);
6909 
6910  if (cooldown)
6911  GetSpellHistory()->AddCooldown(trigger_spell_id, 0, std::chrono::seconds(cooldown));
6912 
6913  return true;
6914 }
Definition: SpellMgr.h:200
Definition: SpellAuraEffects.h:30
Definition: SharedDefines.h:4633
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
Definition: Unit.h:262
Definition: UpdateFields.h:120
uint32 Id
Definition: SpellInfo.h:329
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:46
SpellEffectInfo const * GetSpellEffectInfo() const
Definition: SpellAuraEffects.h:102
uint32 GetMaxHealth() const
Definition: Unit.h:1427
void AddCooldown(uint32 spellId, uint32 itemId, std::chrono::duration< Type, Period > cooldownDuration)
Definition: SpellHistory.h:95
uint32 GetEffIndex() const
Definition: SpellAuraEffects.h:48
Definition: SharedDefines.h:172
Map * GetMap() const
Definition: Object.h:543
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:1431
Definition: SpellInfo.h:326
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4151
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:133
Definition: UpdateFields.h:123
#define MAX_RUNES
Definition: Player.h:451
Definition: UpdateFields.h:121
Definition: SharedDefines.h:1029
Definition: SharedDefines.h:4638
arena_t NULL
Definition: jemalloc_internal.h:624
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
Definition: SharedDefines.h:238
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
Definition: SpellInfo.h:553
float seconds()
Definition: units.h:97
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:1932
AuraType GetAuraType() const
Definition: SpellAuraEffects.h:54
Definition: SharedDefines.h:168
Definition: SharedDefines.h:237
Definition: SharedDefines.h:4632
Player * ToPlayer()
Definition: Object.h:191
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:956
Definition: SharedDefines.h:240
Definition: SpellAuraDefines.h:291
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:171
uint32 TriggerSpell
Definition: SpellInfo.h:263
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
Definition: SpellMgr.h:126
bool IsPositive() const
Definition: SpellInfo.cpp:1495
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Definition: Unit.h:263
bool IsFullHealth() const
Definition: Unit.h:1429
bool IsAlive() const
Definition: Unit.h:1692
bool HealthBelowPct(int32 pct) const
Definition: Unit.h:1430
Definition: Item.h:259
Definition: SharedDefines.h:4631
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
bool roll_chance_i(int chance)
Definition: Random.h:53
Definition: SharedDefines.h:173
bool HasEffect(uint32 difficulty, SpellEffectName effect) const
Definition: SpellInfo.cpp:1169
Definition: UpdateFields.h:122
Definition: SharedDefines.h:4630
Definition: Unit.h:291
T CalculatePct(T base, U pct)
Definition: Util.h:92
uint32 m_extraAttacks
Definition: Unit.h:1366
Definition: Unit.h:267
bool HealthAbovePct(int32 pct) const
Definition: Unit.h:1432
int32 CalcValue(Unit const *caster=nullptr, int32 const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, int32 itemLevel=-1) const
Definition: SpellInfo.cpp:455
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3586
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:4623
Definition: Unit.h:453
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
int32_t int32
Definition: g3dmath.h:167
uint8 getClass() const
Definition: Unit.h:1413
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
Definition: SharedDefines.h:241
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:264
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition: Unit.cpp:11491
Definition: SpellAuras.h:116
uint32 GetHealth() const
Definition: Unit.h:1426
Definition: SharedDefines.h:177
Definition: Unit.h:1305
uint8 GetRank() const
Definition: SpellInfo.cpp:2746
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: SpellMgr.h:145
float GetStat(Stats stat) const
Definition: Unit.h:1417
bool IsEmpty() const
Definition: ObjectGuid.h:242
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:617
Definition: SharedDefines.h:248

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HandleSpellClick ( Unit clicker,
int8  seatId = -1 
)

First check simple relations from clicker to clickee

Check database conditions

15174 {
15175  bool result = false;
15176  uint32 spellClickEntry = GetVehicleKit() ? GetVehicleKit()->GetCreatureEntry() : GetEntry();
15177  SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(spellClickEntry);
15178  for (SpellClickInfoContainer::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
15179  {
15181  if (!itr->second.IsFitToRequirements(clicker, this))
15182  continue;
15183 
15185  if (!sConditionMgr->IsObjectMeetingSpellClickConditions(spellClickEntry, itr->second.spellId, clicker, this))
15186  continue;
15187 
15188  Unit* caster = (itr->second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this;
15189  Unit* target = (itr->second.castFlags & NPC_CLICK_CAST_TARGET_CLICKER) ? clicker : this;
15190  ObjectGuid origCasterGUID = (itr->second.castFlags & NPC_CLICK_CAST_ORIG_CASTER_OWNER) ? GetOwnerGUID() : clicker->GetGUID();
15191 
15192  SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->second.spellId);
15193  // if (!spellEntry) should be checked at npc_spellclick load
15194 
15195  if (seatId > -1)
15196  {
15197  uint8 i = 0;
15198  bool valid = false;
15199  for (SpellEffectInfo const* effect : spellEntry->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
15200  {
15201  if (!effect)
15202  continue;
15203 
15204  if (effect->ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
15205  {
15206  valid = true;
15207  break;
15208  }
15209  ++i;
15210  }
15211 
15212  if (!valid)
15213  {
15214  TC_LOG_ERROR("sql.sql", "Spell %u specified in npc_spellclick_spells is not a valid vehicle enter aura!", itr->second.spellId);
15215  continue;
15216  }
15217 
15218  if (IsInMap(caster))
15219  caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId + 1, target, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, NULL, NULL, origCasterGUID);
15220  else // This can happen during Player::_LoadAuras
15221  {
15222  int32 bp0[MAX_SPELL_EFFECTS];
15223  for (SpellEffectInfo const* effect : spellEntry->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
15224  if (effect)
15225  bp0[effect->EffectIndex] = effect->BasePoints;
15226 
15227  bp0[i] = seatId;
15228  Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, bp0, NULL, origCasterGUID);
15229  }
15230  }
15231  else
15232  {
15233  if (IsInMap(caster))
15234  caster->CastSpell(target, spellEntry, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, NULL, NULL, origCasterGUID);
15235  else
15236  Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, NULL, NULL, origCasterGUID);
15237  }
15238 
15239  result = true;
15240  }
15241 
15242  Creature* creature = ToCreature();
15243  if (creature && creature->IsAIEnabled)
15244  creature->AI()->OnSpellClick(clicker, result);
15245 
15246  return result;
15247 }
Will ignore caster aura states including combat requirements and death state.
Definition: Unit.h:473
Map * GetMap() const
Definition: Object.h:543
Definition: SpellInfo.h:326
SpellValueMod
Definition: Unit.h:127
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
bool IsAIEnabled
Definition: Unit.h:2161
#define sObjectMgr
Definition: ObjectMgr.h:1567
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1631
Definition: SpellAuraDefines.h:296
CreatureAI * AI() const
Definition: Creature.h:525
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
std::pair< SpellClickInfoContainer::const_iterator, SpellClickInfoContainer::const_iterator > SpellClickInfoMapBounds
Definition: ObjectMgr.h:398
#define sConditionMgr
Definition: ConditionMgr.h:307
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SharedDefines.h:870
virtual void OnSpellClick(Unit *, bool &)
Definition: CreatureAI.h:185
static Aura * TryRefreshStackOrCreate(SpellInfo const *spellproto, uint32 tryEffMask, WorldObject *owner, Unit *caster, int32 *baseAmount=NULL, Item *castItem=NULL, ObjectGuid casterGUID=ObjectGuid::Empty, bool *refresh=NULL, int32 castItemLevel=-1)
Definition: SpellAuras.cpp:282
Definition: SharedDefines.h:871
Creature * ToCreature()
Definition: Object.h:194
SpellEffectInfoVector GetEffectsForDifficulty(uint32 difficulty) const
Definition: SpellInfo.cpp:3311
uint8_t uint8
Definition: Define.h:152
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
Definition: Unit.h:1305
uint32 GetCreatureEntry() const
Definition: Vehicle.h:51
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1027
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:129
Definition: Unit.h:460
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165
Definition: SharedDefines.h:872

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HandleStatModifier ( UnitMods  unitMod,
UnitModifierType  modifierType,
float  amount,
bool  apply 
)
11324 {
11325  if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END)
11326  {
11327  TC_LOG_ERROR("entities.unit", "ERROR in HandleStatModifier(): non-existing UnitMods or wrong UnitModifierType!");
11328  return false;
11329  }
11330 
11331  switch (modifierType)
11332  {
11333  case BASE_VALUE:
11335  case TOTAL_VALUE:
11336  m_auraModifiersGroup[unitMod][modifierType] += apply ? amount : -amount;
11337  break;
11338  case BASE_PCT:
11339  case TOTAL_PCT:
11340  ApplyPercentModFloatVar(m_auraModifiersGroup[unitMod][modifierType], amount, apply);
11341  break;
11342  default:
11343  break;
11344  }
11345 
11346  if (!CanModifyStats())
11347  return false;
11348 
11349  switch (unitMod)
11350  {
11352  case UNIT_MOD_STAT_AGILITY:
11353  case UNIT_MOD_STAT_STAMINA:
11355  case UNIT_MOD_STAT_SPIRIT: UpdateStats(GetStatByAuraGroup(unitMod)); break;
11356 
11357  case UNIT_MOD_ARMOR: UpdateArmor(); break;
11358  case UNIT_MOD_HEALTH: UpdateMaxHealth(); break;
11359 
11360  case UNIT_MOD_MANA:
11361  case UNIT_MOD_RAGE:
11362  case UNIT_MOD_FOCUS:
11363  case UNIT_MOD_ENERGY:
11364  case UNIT_MOD_RUNE:
11366 
11373 
11376 
11380 
11381  default:
11382  break;
11383  }
11384 
11385  return true;
11386 }
virtual void UpdateResistances(uint32 school)=0
Definition: Unit.h:485
virtual void UpdateMaxPower(Powers power)=0
Definition: Unit.h:484
Definition: Unit.h:502
Definition: Unit.h:510
Definition: Unit.h:492
Definition: Unit.h:619
Definition: Unit.h:488
Definition: Unit.h:434
Definition: Unit.h:508
virtual void UpdateArmor()=0
Definition: Unit.h:512
Definition: Unit.h:513
Definition: Unit.h:511
void apply(T *val)
Definition: ByteConverter.h:41
Definition: Unit.h:496
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2285
Stats GetStatByAuraGroup(UnitMods unitMod) const
Definition: Unit.cpp:11458
Definition: Unit.h:495
Definition: Unit.h:486
virtual bool UpdateStats(Stats stat)=0
Definition: Unit.h:618
Definition: Unit.h:504
Definition: Unit.h:503
Definition: Unit.h:487
Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const
Definition: Unit.cpp:11477
Definition: Unit.h:437
void ApplyPercentModFloatVar(float &var, float val, bool apply)
Definition: Util.h:83
Definition: Unit.h:438
Definition: Unit.h:490
Definition: Unit.h:489
SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const
Definition: Unit.cpp:11438
Definition: Unit.h:435
virtual void UpdateDamagePhysical(WeaponAttackType attType)
Definition: StatSystem.cpp:60
Definition: Unit.h:506
bool CanModifyStats() const
Definition: Unit.h:1959
Definition: Unit.h:439
Definition: Unit.h:507
Definition: Unit.h:509
Definition: Unit.h:491
Definition: Unit.h:493
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:436
Definition: Unit.h:505
virtual void UpdateMaxHealth()=0
Definition: Unit.h:501
Definition: Unit.h:617
virtual void UpdateAttackPowerAndDamage(bool ranged=false)=0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HasAura ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
ObjectGuid  itemCasterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0 
) const
4241 {
4242  if (GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask))
4243  return true;
4244  return false;
4245 }
AuraApplication * GetAuraApplication(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraApplication *except=NULL) const
Definition: Unit.cpp:4132

+ Here is the call graph for this function:

bool Unit::HasAuraEffect ( uint32  spellId,
uint8  effIndex,
ObjectGuid  caster = ObjectGuid::Empty 
) const
4211 {
4212  AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId);
4213  for (AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr)
4214  {
4215  if (itr->second->HasEffect(effIndex)
4216  && (!caster || itr->second->GetBase()->GetCasterGUID() == caster))
4217  {
4218  return true;
4219  }
4220  }
4221  return false;
4222 }
std::pair< AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator > AuraApplicationMapBounds
Definition: Unit.h:1316
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the caller graph for this function:

bool Unit::HasAuraState ( AuraStateType  flag,
SpellInfo const spellProto = NULL,
Unit const Caster = NULL 
) const
7492 {
7493  if (Caster)
7494  {
7495  if (spellProto)
7496  {
7497  AuraEffectList const& stateAuras = Caster->GetAuraEffectsByType(SPELL_AURA_ABILITY_IGNORE_AURASTATE);
7498  for (AuraEffectList::const_iterator j = stateAuras.begin(); j != stateAuras.end(); ++j)
7499  if ((*j)->IsAffectingSpell(spellProto))
7500  return true;
7501  }
7502  // Check per caster aura state
7503  // If aura with aurastate by caster not found return false
7504  if ((1<<(flag-1)) & PER_CASTER_AURA_STATE_MASK)
7505  {
7506  AuraStateAurasMapBounds range = m_auraStateAuras.equal_range(flag);
7507  for (AuraStateAurasMap::const_iterator itr = range.first; itr != range.second; ++itr)
7508  if (itr->second->GetBase()->GetCasterGUID() == Caster->GetGUID())
7509  return true;
7510  return false;
7511  }
7512  }
7513 
7514  return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1));
7515 }
AuraStateAurasMap m_auraStateAuras
Definition: Unit.h:2282
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: UpdateFields.h:112
Definition: SpellAuraDefines.h:322
std::pair< AuraStateAurasMap::const_iterator, AuraStateAurasMap::const_iterator > AuraStateAurasMapBounds
Definition: Unit.h:1320
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
#define PER_CASTER_AURA_STATE_MASK
Definition: SharedDefines.h:1784

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HasAuraType ( AuraType  auraType) const
4248 {
4249  return (!m_modAuras[auraType].empty());
4250 }
AuraEffectList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2279

+ Here is the caller graph for this function:

bool Unit::HasAuraTypeWithAffectMask ( AuraType  auratype,
SpellInfo const affectedSpell 
) const
4271 {
4272  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4273  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4274  if ((*i)->IsAffectingSpell(affectedSpell))
4275  return true;
4276  return false;
4277 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HasAuraTypeWithCaster ( AuraType  auratype,
ObjectGuid  caster 
) const
4253 {
4254  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4255  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4256  if (caster == (*i)->GetCasterGUID())
4257  return true;
4258  return false;
4259 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HasAuraTypeWithFamilyFlags ( AuraType  auraType,
uint32  familyName,
uint32  familyFlags 
) const
569 {
570  if (!HasAuraType(auraType))
571  return false;
572  AuraEffectList const& auras = GetAuraEffectsByType(auraType);
573  for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
574  if (SpellInfo const* iterSpellProto = (*itr)->GetSpellInfo())
575  if (iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags[0] & familyFlags)
576  return true;
577  return false;
578 }
Definition: SpellInfo.h:326
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247

+ Here is the call graph for this function:

bool Unit::HasAuraTypeWithMiscvalue ( AuraType  auratype,
int32  miscvalue 
) const
4262 {
4263  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4264  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4265  if (miscvalue == (*i)->GetMiscValue())
4266  return true;
4267  return false;
4268 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HasAuraTypeWithValue ( AuraType  auratype,
int32  value 
) const
4280 {
4281  AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
4282  for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
4283  if (value == (*i)->GetAmount())
4284  return true;
4285  return false;
4286 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the call graph for this function:

bool Unit::HasAuraWithMechanic ( uint32  mechanicMask) const
4312 {
4313  for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter)
4314  {
4315  SpellInfo const* spellInfo = iter->second->GetBase()->GetSpellInfo();
4316  if (spellInfo->Mechanic && (mechanicMask & (1 << spellInfo->Mechanic)))
4317  return true;
4318 
4319  for (SpellEffectInfo const* effect : iter->second->GetBase()->GetSpellEffectInfos())
4320  if (effect && effect->Effect && effect->Mechanic)
4321  if (mechanicMask & (1 << effect->Mechanic))
4322  return true;
4323  }
4324 
4325  return false;
4326 }
Definition: SpellInfo.h:326
uint32 Mechanic
Definition: SpellInfo.h:332
Definition: SpellInfo.h:238
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the caller graph for this function:

bool Unit::HasBreakableByDamageAuraType ( AuraType  type,
uint32  excludeAura = 0 
) const
581 {
582  AuraEffectList const& auras = GetAuraEffectsByType(type);
583  for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
584  if ((!excludeAura || excludeAura != (*itr)->GetSpellInfo()->Id) && //Avoid self interrupt of channeled Crowd Control spells like Seduction
585  ((*itr)->GetSpellInfo()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_TAKE_DAMAGE))
586  return true;
587  return false;
588 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: Unit.h:55
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HasBreakableByDamageCrowdControlAura ( Unit excludeCasterChannel = NULL) const
591 {
592  uint32 excludeAura = 0;
593  if (Spell* currentChanneledSpell = excludeCasterChannel ? excludeCasterChannel->GetCurrentSpell(CURRENT_CHANNELED_SPELL) : NULL)
594  excludeAura = currentChanneledSpell->GetSpellInfo()->Id; //Avoid self interrupt of channeled Crowd Control spells like Seduction
595 
601 }
Definition: SpellAuraDefines.h:72
Definition: Unit.h:1110
bool HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura=0) const
Definition: Unit.cpp:580
Definition: SpellAuraDefines.h:67
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SpellAuraDefines.h:86
Definition: SpellAuraDefines.h:116
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1920
uint32_t uint32
Definition: Define.h:150
Definition: SpellAuraDefines.h:65
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16 Unit::HasExtraUnitMovementFlag ( uint16  f) const
inline
2115 { return m_movementInfo.HasExtraMovementFlag(f); }
MovementInfo m_movementInfo
Definition: Object.h:612
bool HasExtraMovementFlag(uint16 flag) const
Definition: Object.h:336

+ Here is the caller graph for this function:

bool Unit::HasInvisibilityAura ( ) const
inline
Definition: SpellAuraDefines.h:78
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247
bool Unit::HasNegativeAuraWithAttribute ( uint32  flag,
ObjectGuid  guid = ObjectGuid::Empty 
) const
4301 {
4302  for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter)
4303  {
4304  Aura const* aura = iter->second->GetBase();
4305  if (!iter->second->IsPositive() && aura->GetSpellInfo()->Attributes & flag && (!guid || aura->GetCasterGUID() == guid))
4306  return true;
4307  }
4308  return false;
4309 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
uint32 Attributes
Definition: SpellInfo.h:333
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

bool Unit::HasNegativeAuraWithInterruptFlag ( uint32  flag,
ObjectGuid  guid = ObjectGuid::Empty 
) const
4289 {
4290  if (!(m_interruptMask & flag))
4291  return false;
4292  for (AuraApplicationList::const_iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); ++iter)
4293  {
4294  if (!(*iter)->IsPositive() && (*iter)->GetBase()->GetSpellInfo()->AuraInterruptFlags & flag && (!guid || (*iter)->GetBase()->GetCasterGUID() == guid))
4295  return true;
4296  }
4297  return false;
4298 }
AuraApplicationList m_interruptableAuras
Definition: Unit.h:2281
uint32 m_interruptMask
Definition: Unit.h:2283

+ Here is the caller graph for this function:

bool Unit::HasSharedVision ( ) const
inline
1757 { return !m_sharedVision.empty(); }
SharedVisionList m_sharedVision
Definition: Unit.h:2293

+ Here is the caller graph for this function:

virtual bool Unit::HasSpell ( uint32  ) const
inlinevirtual

Reimplemented in Creature, and Pet.

1593 { return false; }

+ Here is the caller graph for this function:

bool Unit::HasStealthAura ( ) const
inline
Definition: SpellAuraDefines.h:76
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247

+ Here is the caller graph for this function:

bool Unit::HasUnitMovementFlag ( uint32  f) const
inline
2109 { return m_movementInfo.HasMovementFlag(f); }
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
MovementInfo m_movementInfo
Definition: Object.h:612

+ Here is the caller graph for this function:

bool Unit::HasUnitState ( const uint32  f) const
inline
1395 { return (m_state & f) != 0; }
uint32 m_state
Definition: Unit.h:2340
uint32 Unit::HasUnitTypeMask ( uint32  mask) const
inline
1399 { return mask & m_unitTypeMask; }
uint32 m_unitTypeMask
Definition: Unit.h:2307

+ Here is the caller graph for this function:

bool Unit::haveOffhandWeapon ( ) const
419 {
420  if (Player const* player = ToPlayer())
421  return player->GetWeaponForAttack(OFF_ATTACK, true) != nullptr;
422 
423  return CanDualWield();
424 }
Player * ToPlayer()
Definition: Object.h:191
Definition: Unit.h:618
bool CanDualWield() const
Definition: Unit.h:1359

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::HealBySpell ( Unit victim,
SpellInfo const spellInfo,
uint32  addHealth,
bool  critical = false 
)
8180 {
8181  uint32 absorb = 0;
8182  // calculate heal absorb and reduce healing
8183  CalcHealAbsorb(victim, spellInfo, addHealth, absorb);
8184 
8185  int32 gain = DealHeal(victim, addHealth);
8186  SendHealSpellLog(victim, spellInfo->Id, addHealth, uint32(addHealth - gain), absorb, critical);
8187  return gain;
8188 }
void SendHealSpellLog(Unit *victim, uint32 spellID, uint32 health, uint32 overHeal, uint32 absorbed, bool crit=false)
Definition: Unit.cpp:8140
int32 DealHeal(Unit *victim, uint32 addhealth)
Definition: Unit.cpp:7885
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
void CalcHealAbsorb(Unit *victim, SpellInfo const *spellInfo, uint32 &healAmount, uint32 &absorb)
Definition: Unit.cpp:1812

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::HealthAbovePct ( int32  pct) const
inline
1432 { return GetHealth() > CountPctFromMaxHealth(pct); }
uint32 GetHealth() const
Definition: Unit.h:1426
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the caller graph for this function:

bool Unit::HealthAbovePctHealed ( int32  pct,
uint32  heal 
) const
inline
1433 { return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); }
uint64_t uint64
Definition: g3dmath.h:170
uint32 GetHealth() const
Definition: Unit.h:1426
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the caller graph for this function:

bool Unit::HealthBelowPct ( int32  pct) const
inline
1430 { return GetHealth() < CountPctFromMaxHealth(pct); }
uint32 GetHealth() const
Definition: Unit.h:1426
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the caller graph for this function:

bool Unit::HealthBelowPctDamaged ( int32  pct,
uint32  damage 
) const
inline
1431 { return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); }
int64_t int64
Definition: g3dmath.h:169
uint32 GetHealth() const
Definition: Unit.h:1426
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435
void Unit::IncrDiminishing ( DiminishingGroup  group)
11113 {
11114  // Checking for existing in the table
11115  for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
11116  {
11117  if (i->DRGroup != group)
11118  continue;
11119  if (int32(i->hitCount) < GetDiminishingReturnsMaxLevel(group))
11120  i->hitCount += 1;
11121  return;
11122  }
11124 }
Definition: SharedDefines.h:4877
uint32 getMSTime()
Definition: Timer.h:24
Diminishing m_Diminishing
Definition: Unit.h:2344
DiminishingLevels GetDiminishingReturnsMaxLevel(DiminishingGroup group)
Definition: SpellMgr.cpp:419
Definition: Unit.h:870
int32_t int32
Definition: g3dmath.h:167

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CharmInfo * Unit::InitCharmInfo ( )
11837 {
11838  if (!m_charmInfo)
11839  m_charmInfo = new CharmInfo(this);
11840 
11841  return m_charmInfo;
11842 }
CharmInfo * m_charmInfo
Definition: Unit.h:2292
Definition: Unit.h:1201

+ Here is the caller graph for this function:

void Unit::InitStatBuffMods ( )
4674 {
4675  for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
4677  for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
4679 }
Definition: SharedDefines.h:237
#define MAX_STATS
Definition: SharedDefines.h:244
Definition: UpdateFields.h:138
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:1067
uint8_t uint8
Definition: Define.h:152
Definition: UpdateFields.h:139

+ Here is the call graph for this function:

bool Unit::InitTamedPet ( Pet pet,
uint8  level,
uint32  spell_id 
)
13222 {
13223  pet->SetCreatorGUID(GetGUID());
13224  pet->setFaction(getFaction());
13225  pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
13226 
13227  if (GetTypeId() == TYPEID_PLAYER)
13229 
13230  if (!pet->InitStatsForLevel(level))
13231  {
13232  TC_LOG_ERROR("entities.unit", "Pet::InitStatsForLevel() failed for creature (Entry: %u)!", pet->GetEntry());
13233  return false;
13234  }
13235 
13236  pet->CopyPhaseFrom(this);
13237 
13238  pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
13239  // this enables pet details window (Shift+P)
13240  pet->InitPetCreateSpells();
13241  //pet->InitLevelupSpellsForLevel();
13242  pet->SetFullHealth();
13243  return true;
13244 }
void SetPetNumber(uint32 petnumber, bool statwindow)
Definition: Unit.cpp:12048
uint32 getFaction() const
Definition: Unit.h:1466
Definition: UpdateFields.h:134
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
void CopyPhaseFrom(WorldObject *obj, bool update=false)
Definition: Object.cpp:2915
#define sObjectMgr
Definition: ObjectMgr.h:1567
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
void setFaction(uint32 faction)
Definition: Unit.h:1467
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:676
void InitPetCreateSpells()
Definition: Pet.cpp:1541
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
void SetCreatorGUID(ObjectGuid creator)
Definition: Unit.h:1701
bool InitStatsForLevel(uint8 level)
Definition: Pet.cpp:801
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetFullHealth()
Definition: Unit.h:1440

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::InterruptNonMeleeSpells ( bool  withDelayed,
uint32  spellid = 0,
bool  withInstant = true 
)
2917 {
2918  // generic spells are interrupted if they are not finished or delayed
2919  if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id == spell_id))
2920  InterruptSpell(CURRENT_GENERIC_SPELL, withDelayed, withInstant);
2921 
2922  // autorepeat spells are interrupted if they are not finished or delayed
2923  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == spell_id))
2924  InterruptSpell(CURRENT_AUTOREPEAT_SPELL, withDelayed, withInstant);
2925 
2926  // channeled spells are interrupted if they are not finished, even if they are delayed
2927  if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id == spell_id))
2929 }
Definition: Unit.h:1109
Definition: Unit.h:1110
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
Definition: Unit.h:1111
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:2849
uint32 Id
Definition: Spell.h:567

+ Here is the call graph for this function:

void Unit::InterruptSpell ( CurrentSpellTypes  spellType,
bool  withDelayed = true,
bool  withInstant = true 
)
2850 {
2851  //TC_LOG_DEBUG("entities.unit", "Interrupt spell for unit %u.", GetEntry());
2852  Spell* spell = m_currentSpells[spellType];
2853  if (spell
2854  && (withDelayed || spell->getState() != SPELL_STATE_DELAYED)
2855  && (withInstant || spell->GetCastTime() > 0))
2856  {
2857  // for example, do not let self-stun aura interrupt itself
2858  if (!spell->IsInterruptable())
2859  return;
2860 
2861  // send autorepeat cancel message for autorepeat spells
2862  if (spellType == CURRENT_AUTOREPEAT_SPELL)
2863  if (GetTypeId() == TYPEID_PLAYER)
2864  ToPlayer()->SendAutoRepeatCancel(this);
2865 
2866  if (spell->getState() != SPELL_STATE_FINISHED)
2867  spell->cancel();
2868 
2869  m_currentSpells[spellType] = NULL;
2870  spell->SetReferencedFromCurrent(false);
2871  }
2872 }
Definition: Spell.h:281
uint32 getState() const
Definition: Spell.h:509
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
bool IsInterruptable() const
Definition: Spell.h:602
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Unit.h:1111
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:33
void cancel()
Definition: Spell.cpp:3061
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:601
int32 GetCastTime() const
Definition: Spell.h:590
Definition: Spell.h:279
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsAlive ( ) const
inline
1692 { return (m_deathState == ALIVE); }
Definition: Unit.h:541
DeathState m_deathState
Definition: Unit.h:2259
bool Unit::IsAlwaysDetectableFor ( WorldObject const seer) const
overrideprotectedvirtual

Reimplemented from WorldObject.

10353 {
10355  return true;
10356 
10357  if (HasAuraTypeWithCaster(SPELL_AURA_MOD_STALKED, seer->GetGUID()))
10358  return true;
10359 
10360  return false;
10361 }
bool HasAuraTypeWithCaster(AuraType auratype, ObjectGuid caster) const
Definition: Unit.cpp:4252
Definition: SpellAuraDefines.h:128
virtual bool IsAlwaysDetectableFor(WorldObject const *) const
Definition: Object.h:642

+ Here is the call graph for this function:

bool Unit::IsAlwaysVisibleFor ( WorldObject const seer) const
overrideprotectedvirtual

Reimplemented from WorldObject.

10333 {
10335  return true;
10336 
10337  // Always seen by owner
10339  if (!guid.IsEmpty())
10340  if (seer->GetGUID() == guid)
10341  return true;
10342 
10343  if (Player const* seerPlayer = seer->ToPlayer())
10344  if (Unit* owner = GetOwner())
10345  if (Player* ownerPlayer = owner->ToPlayer())
10346  if (ownerPlayer->IsGroupVisibleFor(seerPlayer))
10347  return true;
10348 
10349  return false;
10350 }
virtual bool IsAlwaysVisibleFor(WorldObject const *) const
Definition: Object.h:639
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.cpp:12677
Unit * GetOwner() const
Definition: Unit.cpp:7542
Definition: ObjectGuid.h:189
Definition: Unit.h:1305
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

bool Unit::IsArmorer ( ) const
inline
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135
Definition: Unit.h:747

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isAttackingPlayer ( ) const
7392 {
7394  return true;
7395 
7396  for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
7397  if ((*itr)->isAttackingPlayer())
7398  return true;
7399 
7400  for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
7401  if (!m_SummonSlot[i].IsEmpty())
7402  if (Creature* summon = GetMap()->GetCreature(m_SummonSlot[i]))
7403  if (summon->isAttackingPlayer())
7404  return true;
7405 
7406  return false;
7407 }
Definition: Unit.h:564
Map * GetMap() const
Definition: Object.h:543
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
Definition: Creature.h:467
ControlList m_Controlled
Definition: Unit.h:1738
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535
#define MAX_SUMMON_SLOT
Definition: Unit.h:1285
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

bool Unit::isAttackReady ( WeaponAttackType  type = BASE_ATTACK) const
inline
1357 { return m_attackTimer[type] == 0; }
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2251

+ Here is the caller graph for this function:

bool Unit::IsAuctioner ( ) const
inline
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135
Definition: Unit.h:756

+ Here is the call graph for this function:

bool Unit::IsBanker ( ) const
inline
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: Unit.h:752
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

bool Unit::IsBattleMaster ( ) const
inline
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: Unit.h:755
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isBlockCritical ( )
2172 {
2174  return true;
2175  return false;
2176 }
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
bool roll_chance_i(int chance)
Definition: Random.h:53
Definition: SpellAuraDefines.h:313

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsCharmed ( ) const
inline
1742 { return !GetCharmerGUID().IsEmpty(); }
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the caller graph for this function:

bool Unit::IsCharmedOwnedByPlayerOrPlayer ( ) const
inline
1715 { return GetCharmerOrOwnerOrOwnGUID().IsPlayer(); }
bool IsPlayer() const
Definition: ObjectGuid.h:249
ObjectGuid GetCharmerOrOwnerOrOwnGUID() const
Definition: Unit.cpp:12682

+ Here is the caller graph for this function:

bool Unit::IsContestedGuard ( ) const
14448 {
14449  if (FactionTemplateEntry const* entry = GetFactionTemplateEntry())
14450  return entry->IsContestedGuardFaction();
14451 
14452  return false;
14453 }
Definition: DBCStructure.h:433
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7019

+ Here is the call graph for this function:

bool Unit::IsControlledByPlayer ( ) const
inline
1712 { return m_ControlledByPlayer; }
bool m_ControlledByPlayer
Definition: Unit.h:2175

+ Here is the caller graph for this function:

bool Unit::IsCritter ( ) const
inline
1580 { return GetCreatureType() == CREATURE_TYPE_CRITTER; }
uint32 GetCreatureType() const
Definition: Unit.cpp:11248
Definition: SharedDefines.h:3561

+ Here is the caller graph for this function:

bool Unit::IsDamageReducedByArmor ( SpellSchoolMask  damageSchoolMask,
SpellInfo const spellInfo = NULL,
uint8  effIndex = MAX_SPELL_EFFECTS 
)
1453 {
1454  // only physical spells damage gets reduced by armor
1455  if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0)
1456  return false;
1457  if (spellInfo)
1458  {
1459  // there are spells with no specific attribute but they have "ignores armor" in tooltip
1460  if (spellInfo->HasAttribute(SPELL_ATTR0_CU_IGNORE_ARMOR))
1461  return false;
1462 
1463  // bleeding effects are not reduced by armor
1464  if (SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficultyID(), effIndex))
1465  {
1466  if (effect->ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE ||
1467  effect->Effect == SPELL_EFFECT_SCHOOL_DAMAGE)
1468  if (spellInfo->GetEffectMechanicMask(effIndex) & (1<<MECHANIC_BLEED))
1469  return false;
1470  }
1471  }
1472  return true;
1473 }
Definition: SpellAuraDefines.h:63
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:288
Definition: SpellInfo.h:238
Definition: SharedDefines.h:1805
Definition: SpellInfo.h:197
Definition: SharedDefines.h:1012

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isDead ( ) const
inline
1694 { return (m_deathState == DEAD || m_deathState == CORPSE); }
Definition: Unit.h:544
Definition: Unit.h:543
DeathState m_deathState
Definition: Unit.h:2259

+ Here is the caller graph for this function:

bool Unit::IsDuringRemoveFromWorld ( ) const
inline
2198 {return m_duringRemoveFromWorld;}
bool m_duringRemoveFromWorld
Definition: Unit.h:2353

+ Here is the caller graph for this function:

bool Unit::isDying ( ) const
inline
1693 { return (m_deathState == JUST_DIED); }
Definition: Unit.h:542
DeathState m_deathState
Definition: Unit.h:2259

+ Here is the caller graph for this function:

bool Unit::IsFalling ( ) const
15403 {
15405 }
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
bool isFalling() const
Definition: MoveSpline.h:131
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:787
Movement::MoveSpline * movespline
Definition: Unit.h:2213
Definition: Unit.h:788

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isFeared ( ) const
inline
1599 { return HasAuraType(SPELL_AURA_MOD_FEAR); }
Definition: SpellAuraDefines.h:67
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247

+ Here is the caller graph for this function:

bool Unit::IsFFAPvP ( ) const
inline
Definition: UpdateFields.h:146
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition: Object.cpp:1298
Definition: Unit.h:310

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsFlying ( ) const
inline
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:800
Definition: Unit.h:785

+ Here is the caller graph for this function:

bool Unit::IsFriendlyTo ( Unit const unit) const
7171 {
7172  return GetReactionTo(unit) >= REP_FRIENDLY;
7173 }
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7035
Definition: SharedDefines.h:217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isFrozen ( ) const
12108 {
12110 }
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
Definition: SharedDefines.h:1761

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsFullHealth ( ) const
inline
1429 { return GetHealth() == GetMaxHealth(); }
uint32 GetMaxHealth() const
Definition: Unit.h:1427
uint32 GetHealth() const
Definition: Unit.h:1426

+ Here is the caller graph for this function:

bool Unit::IsGossip ( ) const
inline
Definition: Unit.h:735
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

bool Unit::IsGuardian ( ) const
inline
1402 { return (m_unitTypeMask & UNIT_MASK_GUARDIAN) != 0; }
Definition: Unit.h:860
uint32 m_unitTypeMask
Definition: Unit.h:2307

+ Here is the caller graph for this function:

bool Unit::IsGuildMaster ( ) const
inline
Definition: Unit.h:753
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

bool Unit::IsHighestExclusiveAura ( Aura const aura,
bool  removeOtherAuraApplications = false 
)
16341 {
16342  for (AuraEffect* aurEff : aura->GetAuraEffects())
16343  {
16344  if (!aurEff)
16345  continue;
16346  AuraType const auraType = AuraType(aurEff->GetSpellEffectInfo()->ApplyAuraName);
16347  AuraEffectList const& auras = GetAuraEffectsByType(auraType);
16348  for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end();)
16349  {
16350  AuraEffect const* existingAurEff = (*itr);
16351  ++itr;
16352 
16353  if (sSpellMgr->CheckSpellGroupStackRules(aura->GetSpellInfo(), existingAurEff->GetSpellInfo())
16355  {
16356  int32 diff = abs(aurEff->GetAmount()) - abs(existingAurEff->GetAmount());
16357  if (!diff)
16358  diff = int32(aura->GetEffectMask()) - int32(existingAurEff->GetBase()->GetEffectMask());
16359 
16360  if (diff > 0)
16361  {
16362  Aura const* base = existingAurEff->GetBase();
16363  // no removing of area auras from the original owner, as that completely cancels them
16364  if (removeOtherAuraApplications && (!base->IsArea() || base->GetOwner() != this))
16365  {
16366  if (AuraApplication* aurApp = existingAurEff->GetBase()->GetApplicationOfTarget(GetGUID()))
16367  {
16368  bool hasMoreThanOneEffect = base->HasMoreThanOneEffectForType(auraType);
16369  uint32 removedAuras = m_removedAurasCount;
16370  RemoveAura(aurApp);
16371  if (hasMoreThanOneEffect || m_removedAurasCount > removedAuras + 1)
16372  itr = auras.begin();
16373  }
16374  }
16375  }
16376  else if (diff < 0)
16377  return false;
16378  }
16379  }
16380  }
16381 
16382  return true;
16383 }
AuraType
Definition: SpellAuraDefines.h:58
Definition: SpellAuraEffects.h:30
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:46
uint32 m_removedAurasCount
Definition: Unit.h:2277
Definition: SpellAuras.h:50
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
bool HasMoreThanOneEffectForType(AuraType auraType) const
Definition: SpellAuras.cpp:1007
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
WorldObject * GetOwner() const
Definition: SpellAuras.h:137
uint32_t uint32
Definition: Define.h:150
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool IsArea() const
Definition: SpellAuras.cpp:1017
int32_t int32
Definition: g3dmath.h:167
Definition: SpellAuras.h:116
uint32 GetEffectMask() const
Definition: SpellAuras.cpp:1213

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsHostileTo ( Unit const unit) const
7166 {
7167  return GetReactionTo(unit) <= REP_HOSTILE;
7168 }
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7035
Definition: SharedDefines.h:214

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsHostileToPlayers ( ) const
7176 {
7177  FactionTemplateEntry const* my_faction = GetFactionTemplateEntry();
7178  if (!my_faction || !my_faction->Faction)
7179  return false;
7180 
7181  FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->Faction);
7182  if (raw_faction && raw_faction->ReputationIndex >= 0)
7183  return false;
7184 
7185  return my_faction->IsHostileToPlayers();
7186 }
bool IsHostileToPlayers() const
Definition: DBCStructure.h:476
Definition: DBCStructure.h:433
Definition: DBCStructure.h:405
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
int32 ReputationIndex
Definition: DBCStructure.h:408
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7019
uint32 Faction
Definition: DBCStructure.h:436

+ Here is the call graph for this function:

bool Unit::IsHovering ( ) const
inline
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:804

+ Here is the caller graph for this function:

bool Unit::IsHunterPet ( ) const
inline
1404 { return (m_unitTypeMask & UNIT_MASK_HUNTER_PET) != 0; }
Definition: Unit.h:865
uint32 m_unitTypeMask
Definition: Unit.h:2307

+ Here is the caller graph for this function:

bool Unit::IsImmunedToDamage ( SpellSchoolMask  meleeSchoolMask) const
9215 {
9216  // If m_immuneToSchool type contain this school type, IMMUNE damage.
9217  SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
9218  for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
9219  if (itr->type & shoolMask)
9220  return true;
9221 
9222  // If m_immuneToDamage type contain magic, IMMUNE damage.
9223  SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE];
9224  for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr)
9225  if (itr->type & shoolMask)
9226  return true;
9227 
9228  return false;
9229 }
Definition: SharedDefines.h:1863
std::list< SpellImmune > SpellImmuneList
Definition: Unit.h:430
Definition: SharedDefines.h:1862
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1988

+ Here is the caller graph for this function:

bool Unit::IsImmunedToDamage ( SpellInfo const spellInfo) const
9232 {
9233  if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
9234  return false;
9235 
9236  uint32 shoolMask = spellInfo->GetSchoolMask();
9237  if (spellInfo->Id != 42292 && spellInfo->Id != 59752)
9238  {
9239  // If m_immuneToSchool type contain this school type, IMMUNE damage.
9240  SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
9241  for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
9242  if (itr->type & shoolMask && !spellInfo->CanPierceImmuneAura(sSpellMgr->GetSpellInfo(itr->spellId)))
9243  return true;
9244  }
9245 
9246  // If m_immuneToDamage type contain magic, IMMUNE damage.
9247  SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE];
9248  for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr)
9249  if (itr->type & shoolMask)
9250  return true;
9251 
9252  return false;
9253 }
Definition: SharedDefines.h:1863
std::list< SpellImmune > SpellImmuneList
Definition: Unit.h:430
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:385
Definition: SharedDefines.h:1862
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1988

+ Here is the call graph for this function:

bool Unit::IsImmunedToSpell ( SpellInfo const spellInfo) const
virtual

Reimplemented in Creature.

9256 {
9257  if (!spellInfo)
9258  return false;
9259 
9260  // Single spell immunity.
9261  SpellImmuneList const& idList = m_spellImmune[IMMUNITY_ID];
9262  for (SpellImmuneList::const_iterator itr = idList.begin(); itr != idList.end(); ++itr)
9263  if (itr->type == spellInfo->Id)
9264  return true;
9265 
9266  if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
9267  return false;
9268 
9269  if (spellInfo->Dispel)
9270  {
9271  SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL];
9272  for (SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr)
9273  if (itr->type == spellInfo->Dispel)
9274  return true;
9275  }
9276 
9277  // Spells that don't have effectMechanics.
9278  if (spellInfo->Mechanic)
9279  {
9280  SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
9281  for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
9282  if (itr->type == spellInfo->Mechanic)
9283  return true;
9284  }
9285 
9286  bool immuneToAllEffects = true;
9287  for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
9288  {
9289  // State/effect immunities applied by aura expect full spell immunity
9290  // Ignore effects with mechanic, they are supposed to be checked separately
9291  if (!effect || !effect->IsEffect())
9292  continue;
9293  if (!IsImmunedToSpellEffect(spellInfo, effect->EffectIndex))
9294  {
9295  immuneToAllEffects = false;
9296  break;
9297  }
9298  }
9299 
9300  if (immuneToAllEffects) //Return immune only if the target is immune to all spell effects.
9301  return true;
9302 
9303  if (spellInfo->Id != 42292 && spellInfo->Id != 59752)
9304  {
9305  SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
9306  for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
9307  {
9308  SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->spellId);
9309  if ((itr->type & spellInfo->GetSchoolMask())
9310  && !(immuneSpellInfo && immuneSpellInfo->IsPositive() && spellInfo->IsPositive())
9311  && !spellInfo->CanPierceImmuneAura(immuneSpellInfo))
9312  return true;
9313  }
9314  }
9315 
9316  return false;
9317 }
Definition: SharedDefines.h:1866
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const
Definition: Unit.cpp:9339
Map * GetMap() const
Definition: Object.h:543
Definition: SpellInfo.h:326
std::list< SpellImmune > SpellImmuneList
Definition: Unit.h:430
bool IsPositive() const
Definition: SpellInfo.cpp:1495
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
Definition: SharedDefines.h:1864
Definition: SharedDefines.h:385
Definition: SharedDefines.h:1862
Definition: SharedDefines.h:1865
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1988

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsImmunedToSpellEffect ( SpellInfo const spellInfo,
uint32  index 
) const
virtual

Reimplemented in Creature, and Totem.

9340 {
9341  if (!spellInfo)
9342  return false;
9343 
9344  SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficultyID(), index);
9345  if (!effect || !effect->IsEffect())
9346  return false;
9347 
9348  if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
9349  return false;
9350 
9351  // If m_immuneToEffect type contain this effect type, IMMUNE effect.
9352  uint32 eff = effect->Effect;
9353  SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT];
9354  for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr)
9355  if (itr->type == eff)
9356  return true;
9357 
9358  if (uint32 mechanic = effect->Mechanic)
9359  {
9360  SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
9361  for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
9362  if (itr->type == mechanic)
9363  return true;
9364  }
9365 
9366  if (uint32 aura = effect->ApplyAuraName)
9367  {
9369  for (SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr)
9370  if (itr->type == aura)
9371  if (!spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
9372  return true;
9373 
9374  // Check for immune to application of harmful magical effects
9376  for (AuraEffectList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter)
9377  if (((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school
9378  !spellInfo->IsPositiveEffect(index)) // Harmful
9379  return true;
9380  }
9381 
9382  return false;
9383 }
Map * GetMap() const
Definition: Object.h:543
Definition: SpellAuraDefines.h:327
uint32 ApplyAuraName
Definition: SpellInfo.h:244
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SharedDefines.h:1861
std::list< SpellImmune > SpellImmuneList
Definition: Unit.h:430
Mechanics Mechanic
Definition: SpellInfo.h:255
Definition: SpellInfo.h:238
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:385
Definition: SharedDefines.h:1860
uint32 Effect
Definition: SpellInfo.h:243
Definition: SharedDefines.h:1865
Definition: SharedDefines.h:482
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1988
bool IsEffect() const
Definition: SpellInfo.cpp:399

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isInAccessiblePlaceFor ( Creature const c) const
2957 {
2958  if (IsInWater())
2959  return c->CanSwim();
2960  else
2961  return c->CanWalk() || c->CanFly();
2962 }
virtual bool IsInWater() const
Definition: Unit.cpp:2964

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isInBackInMap ( Unit const target,
float  distance,
float  arc = float(M_PI) 
) const
2952 {
2953  return IsWithinDistInMap(target, distance) && !HasInArc(2 * float(M_PI) - arc, target);
2954 }
#define M_PI
Definition: Common.h:163
double distance(double x, double y)
Definition: g3dmath.h:731
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsInCombat ( ) const
inline
Definition: Unit.h:692
Definition: UpdateFields.h:109
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239

+ Here is the call graph for this function:

bool Unit::IsInCombatWith ( Unit const who) const
341 {
342  // Check target exists
343  if (!who)
344  return false;
345 
346  // Search in threat list
347  ObjectGuid guid = who->GetGUID();
348  for (ThreatContainer::StorageType::const_iterator i = m_ThreatManager.getThreatList().begin(); i != m_ThreatManager.getThreatList().end(); ++i)
349  {
350  HostileReference* ref = (*i);
351 
352  // Return true if the unit matches
353  if (ref && ref->getUnitGuid() == guid)
354  return true;
355  }
356 
357  // Nothing found, false.
358  return false;
359 }
ThreatContainer::StorageType const & getThreatList() const
Definition: ThreatManager.h:263
ObjectGuid getUnitGuid() const
Definition: ThreatManager.h:107
Definition: ThreatManager.h:49
ThreatManager m_ThreatManager
Definition: Unit.h:2302
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsInDisallowedMountForm ( ) const
11281 {
11282  if (SpellInfo const* transformSpellInfo = sSpellMgr->GetSpellInfo(getTransForm()))
11283  if (transformSpellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_MOUNTED))
11284  return false;
11285 
11286  if (ShapeshiftForm form = GetShapeshiftForm())
11287  {
11288  SpellShapeshiftFormEntry const* shapeshift = sSpellShapeshiftFormStore.LookupEntry(form);
11289  if (!shapeshift)
11290  return true;
11291 
11292  if (!(shapeshift->Flags & 0x1))
11293  return true;
11294  }
11295 
11296  if (GetDisplayId() == GetNativeDisplayId())
11297  return false;
11298 
11299  CreatureDisplayInfoEntry const* display = sCreatureDisplayInfoStore.LookupEntry(GetDisplayId());
11300  if (!display)
11301  return true;
11302 
11303  CreatureDisplayInfoExtraEntry const* displayExtra = sCreatureDisplayInfoExtraStore.LookupEntry(display->ExtendedDisplayInfoID);
11304  if (!displayExtra)
11305  return true;
11306 
11307  CreatureModelDataEntry const* model = sCreatureModelDataStore.LookupEntry(display->ModelID);
11308  ChrRacesEntry const* race = sChrRacesStore.LookupEntry(displayExtra->DisplayRaceID);
11309 
11310  if (model && !(model->Flags & 0x80))
11311  if (race && !(race->Flags & 0x4))
11312  return true;
11313 
11314  return false;
11315 }
ShapeshiftForm
Definition: Unit.h:260
Definition: DBCStructure.h:263
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesfmt)
Definition: DBCStructure.h:204
uint32 GetDisplayId() const
Definition: Unit.h:2012
Definition: SpellInfo.h:326
uint32 ExtendedDisplayInfoID
Definition: DB2Structure.h:158
Definition: DBCStructure.h:294
Definition: SharedDefines.h:380
uint32 Flags
Definition: DBCStructure.h:297
uint32 DisplayRaceID
Definition: DBCStructure.h:266
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:1932
uint32 getTransForm() const
Definition: Unit.h:2018
DBCStorage< CreatureModelDataEntry > sCreatureModelDataStore(CreatureModelDatafmt)
DBCStorage< CreatureDisplayInfoExtraEntry > sCreatureDisplayInfoExtraStore(CreatureDisplayInfoExtrafmt)
#define sSpellMgr
Definition: SpellMgr.h:756
DB2Storage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore("CreatureDisplayInfo.db2", CreatureDisplayInfoFormat, HOTFIX_SEL_CREATURE_DISPLAY_INFO)
Definition: DBCStructure.h:1160
uint32 ModelID
Definition: DB2Structure.h:156
uint32 GetNativeDisplayId() const
Definition: Unit.h:2014
uint32 Flags
Definition: DBCStructure.h:207
DBCStorage< SpellShapeshiftFormEntry > sSpellShapeshiftFormStore(SpellShapeshiftFormfmt)
Definition: DB2Structure.h:153
uint32 Flags
Definition: DBCStructure.h:1165

+ Here is the call graph for this function:

bool Unit::IsInFeralForm ( ) const
11275 {
11277  return form == FORM_CAT || form == FORM_BEAR;
11278 }
ShapeshiftForm
Definition: Unit.h:260
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:1932
Definition: Unit.h:263
Definition: Unit.h:267

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsInFlight ( ) const
inline
Definition: Unit.h:558
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395

+ Here is the caller graph for this function:

bool Unit::isInFrontInMap ( Unit const target,
float  distance,
float  arc = float(M_PI) 
) const
2947 {
2948  return IsWithinDistInMap(target, distance) && HasInArc(arc, target);
2949 }
double distance(double x, double y)
Definition: g3dmath.h:731
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129

+ Here is the call graph for this function:

bool Unit::IsInnkeeper ( ) const
inline
Definition: Unit.h:751
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsInPartyWith ( Unit const unit) const
14373 {
14374  if (this == unit)
14375  return true;
14376 
14377  const Unit* u1 = GetCharmerOrOwnerOrSelf();
14378  const Unit* u2 = unit->GetCharmerOrOwnerOrSelf();
14379  if (u1 == u2)
14380  return true;
14381 
14382  if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER)
14383  return u1->ToPlayer()->IsInSameGroupWith(u2->ToPlayer());
14386  return true;
14387  else
14388  return false;
14389 }
Definition: ObjectGuid.h:32
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Unit.cpp:7632
Definition: Unit.h:1305
Definition: SharedDefines.h:3682
uint32 type_flags
Definition: Creature.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsInRaidWith ( Unit const unit) const
14392 {
14393  if (this == unit)
14394  return true;
14395 
14396  const Unit* u1 = GetCharmerOrOwnerOrSelf();
14397  const Unit* u2 = unit->GetCharmerOrOwnerOrSelf();
14398  if (u1 == u2)
14399  return true;
14400 
14401  if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER)
14402  return u1->ToPlayer()->IsInSameRaidWith(u2->ToPlayer());
14405  return true;
14406  else
14407  return false;
14408 }
Definition: ObjectGuid.h:32
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Unit.cpp:7632
Definition: Unit.h:1305
Definition: SharedDefines.h:3682
uint32 type_flags
Definition: Creature.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isInRoots ( ) const
inline
1600 { return HasAuraType(SPELL_AURA_MOD_ROOT); }
Definition: SpellAuraDefines.h:86
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247
bool Unit::IsInWater ( ) const
virtual
2965 {
2967 }
bool IsInWater(float x, float y, float z, LiquidData *data=nullptr) const
Definition: Map.cpp:2615
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
Map const * GetBaseMap() const
Definition: Object.cpp:2199
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsLevitating ( ) const
inline
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:785

+ Here is the caller graph for this function:

virtual bool Unit::IsLoading ( ) const
inlinevirtual

Reimplemented in Pet.

2197 { return false; }

+ Here is the caller graph for this function:

bool Unit::IsMagnet ( ) const
Todo:
: find a more generic solution
7928 {
7929  // Grounding Totem
7930  if (GetUInt32Value(UNIT_CREATED_BY_SPELL) == 8177)
7931  return true;
7932 
7933  return false;
7934 }
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:134

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsMounted ( ) const
inline
Definition: Unit.h:700
Definition: UpdateFields.h:109
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isMoving ( ) const
inline
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:808

+ Here is the caller graph for this function:

bool Unit::IsNeutralToAll ( ) const
7189 {
7190  FactionTemplateEntry const* my_faction = GetFactionTemplateEntry();
7191  if (!my_faction || !my_faction->Faction)
7192  return true;
7193 
7194  FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->Faction);
7195  if (raw_faction && raw_faction->ReputationIndex >= 0)
7196  return false;
7197 
7198  return my_faction->IsNeutralToAll();
7199 }
bool IsNeutralToAll() const
Definition: DBCStructure.h:477
Definition: DBCStructure.h:433
Definition: DBCStructure.h:405
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
int32 ReputationIndex
Definition: DBCStructure.h:408
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7019
uint32 Faction
Definition: DBCStructure.h:436

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsNonMeleeSpellCast ( bool  withDelayed,
bool  skipChanneled = false,
bool  skipAutorepeat = false,
bool  isAutoshoot = false,
bool  skipInstant = true 
) const
2887 {
2888  // We don't do loop here to explicitly show that melee spell is excluded.
2889  // Maybe later some special spells will be excluded too.
2890 
2891  // generic spells are cast when they are not finished and not delayed
2894  (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED))
2895  {
2896  if (!skipInstant || m_currentSpells[CURRENT_GENERIC_SPELL]->GetCastTime())
2897  {
2898  if (!isAutoshoot || !(m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS)))
2899  return true;
2900  }
2901  }
2902  // channeled spells may be delayed, but they are still considered cast
2903  if (!skipChanneled && m_currentSpells[CURRENT_CHANNELED_SPELL] &&
2905  {
2906  if (!isAutoshoot || !(m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS)))
2907  return true;
2908  }
2909  // autorepeat spells may be finished or delayed, but they are still considered cast
2910  if (!skipAutorepeat && m_currentSpells[CURRENT_AUTOREPEAT_SPELL])
2911  return true;
2912 
2913  return false;
2914 }
Definition: Unit.h:1109
Definition: Spell.h:281
Definition: Unit.h:1110
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
Definition: Unit.h:1111
Definition: SharedDefines.h:445
Definition: Spell.h:279
bool Unit::IsOnVehicle ( const Unit vehicle) const
14337 {
14338  return m_vehicle && m_vehicle == vehicle->GetVehicleKit();
14339 }
Vehicle * m_vehicle
Definition: Unit.h:2304
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsPet ( ) const
inline
1403 { return (m_unitTypeMask & UNIT_MASK_PET) != 0; }
uint32 m_unitTypeMask
Definition: Unit.h:2307
Definition: Unit.h:862
bool Unit::IsPolymorphed ( ) const
12787 {
12788  uint32 transformId = getTransForm();
12789  if (!transformId)
12790  return false;
12791 
12792  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(transformId);
12793  if (!spellInfo)
12794  return false;
12795 
12796  return spellInfo->GetSpellSpecific() == SPELL_SPECIFIC_MAGE_POLYMORPH;
12797 }
Definition: SpellInfo.h:326
uint32 getTransForm() const
Definition: Unit.h:2018
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: SpellInfo.h:165
SpellSpecificType GetSpellSpecific() const
Definition: SpellInfo.cpp:2281

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isPossessed ( ) const
inline
Definition: Unit.h:566
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395

+ Here is the caller graph for this function:

bool Unit::isPossessedByPlayer ( ) const
8024 {
8026 }
bool IsPlayer() const
Definition: ObjectGuid.h:249
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
Definition: Unit.h:566
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isPossessing ( ) const
8034 {
8035  if (Unit* u = GetCharm())
8036  return u->isPossessed();
8037  else
8038  return false;
8039 }
Unit * GetCharm() const
Definition: Unit.cpp:7612
Definition: Unit.h:1305

+ Here is the call graph for this function:

bool Unit::isPossessing ( Unit u) const
8029 {
8030  return u->isPossessed() && GetCharmGUID() == u->GetGUID();
8031 }
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1706
bool isPossessed() const
Definition: Unit.h:1743
ObjectGuid const & GetGUID() const
Definition: Object.h:105

+ Here is the call graph for this function:

bool Unit::IsPvP ( ) const
inline
Definition: UpdateFields.h:146
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition: Object.cpp:1298
Definition: Unit.h:308

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsQuestGiver ( ) const
inline
Definition: Unit.h:736
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AuraEffect * Unit::IsScriptOverriden ( SpellInfo const spell,
int32  script 
) const
4329 {
4331  for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i)
4332  {
4333  if ((*i)->GetMiscValue() == script)
4334  if ((*i)->IsAffectingSpell(spell))
4335  return (*i);
4336  }
4337  return NULL;
4338 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SpellAuraDefines.h:172
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsServiceProvider ( ) const
9832 {
9833  return HasFlag64(UNIT_NPC_FLAGS,
9838 }
Definition: Unit.h:751
Definition: Unit.h:742
Definition: Unit.h:739
Definition: Unit.h:749
Definition: Unit.h:754
Definition: Unit.h:753
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: Unit.h:755
Definition: Unit.h:752
Definition: UpdateFields.h:135
Definition: Unit.h:750
Definition: Unit.h:756
Definition: Unit.h:748

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsSitState ( ) const
12758 {
12760  return
12763  s == UNIT_STAND_STATE_SIT;
12764 }
Definition: Unit.h:208
Definition: Unit.h:212
Definition: Unit.h:209
UnitStandStateType GetStandState() const
Definition: Unit.h:1488
UnitStandStateType
Definition: Unit.h:205
Definition: Unit.h:213
Definition: Unit.h:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isSpellBlocked ( Unit victim,
SpellInfo const spellProto,
WeaponAttackType  attackType = BASE_ATTACK 
)
2153 {
2154  // These spells can't be blocked
2155  if (spellProto && spellProto->HasAttribute(SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK))
2156  return false;
2157 
2158  if (victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION) || victim->HasInArc(float(M_PI), this))
2159  {
2160  // Check creatures flags_extra for disable block
2161  if (victim->GetTypeId() == TYPEID_UNIT &&
2163  return false;
2164 
2165  if (roll_chance_f(victim->GetUnitBlockChanceAgainst(this)))
2166  return true;
2167  }
2168  return false;
2169 }
#define M_PI
Definition: Common.h:163
Definition: ObjectGuid.h:32
uint32 flags_extra
Definition: Creature.h:142
float GetUnitBlockChanceAgainst(Unit const *attacker) const
Definition: Unit.cpp:2593
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: Creature.h:46
bool roll_chance_f(float chance)
Definition: Random.h:47
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129
Definition: SharedDefines.h:377
Definition: SpellAuraDefines.h:348
Creature * ToCreature()
Definition: Object.h:194
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsSpellCrit ( Unit victim,
SpellInfo const spellProto,
SpellSchoolMask  schoolMask,
WeaponAttackType  attackType = BASE_ATTACK 
) const
8644 {
8645  return roll_chance_f(GetUnitSpellCriticalChance(victim, spellProto, schoolMask, attackType));
8646 }
float GetUnitSpellCriticalChance(Unit *victim, SpellInfo const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType=BASE_ATTACK) const
Definition: Unit.cpp:8648
bool roll_chance_f(float chance)
Definition: Random.h:47

+ Here is the call graph for this function:

bool Unit::IsSpiritGuide ( ) const
inline
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135
Definition: Unit.h:750

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsSpiritHealer ( ) const
inline
Definition: Unit.h:749
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsSpiritService ( ) const
inline
Definition: Unit.h:749
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135
Definition: Unit.h:750

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsSplineEnabled ( ) const
16133 {
16134  return movespline->Initialized() && !movespline->Finalized();
16135 }
Movement::MoveSpline * movespline
Definition: Unit.h:2213
bool Initialized() const
Definition: MoveSpline.h:106
bool Finalized() const
Definition: MoveSpline.h:129

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsStandState ( ) const
12767 {
12769  return !IsSitState() && s != UNIT_STAND_STATE_SLEEP && s != UNIT_STAND_STATE_KNEEL;
12770 }
Definition: Unit.h:215
bool IsSitState() const
Definition: Unit.cpp:12757
UnitStandStateType GetStandState() const
Definition: Unit.h:1488
UnitStandStateType
Definition: Unit.h:205
Definition: Unit.h:210

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsStopped ( ) const
inline
2104 { return !(HasUnitState(UNIT_STATE_MOVING)); }
Definition: Unit.h:586
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395

+ Here is the caller graph for this function:

bool Unit::IsSummon ( ) const
inline
1401 { return (m_unitTypeMask & UNIT_MASK_SUMMON) != 0; }
Definition: Unit.h:858
uint32 m_unitTypeMask
Definition: Unit.h:2307

+ Here is the caller graph for this function:

bool Unit::IsTabardDesigner ( ) const
inline
Definition: Unit.h:754
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

bool Unit::isTargetableForAttack ( bool  checkFakeDeath = true) const
9988 {
9989  if (!IsAlive())
9990  return false;
9991 
9994  return false;
9995 
9996  if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->IsGameMaster())
9997  return false;
9998 
9999  return !HasUnitState(UNIT_STATE_UNATTACKABLE) && (!checkFakeDeath || !HasUnitState(UNIT_STATE_DIED));
10000 }
Definition: Unit.h:674
Definition: Unit.h:584
Definition: Unit.h:681
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
Definition: ObjectGuid.h:33
Definition: Unit.h:550
Definition: UpdateFields.h:109
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
Definition: Unit.h:698

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsTaxi ( ) const
inline
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135
Definition: Unit.h:748

+ Here is the call graph for this function:

bool Unit::IsTotem ( ) const
inline
1405 { return (m_unitTypeMask & UNIT_MASK_TOTEM) != 0; }
uint32 m_unitTypeMask
Definition: Unit.h:2307
Definition: Unit.h:861

+ Here is the caller graph for this function:

bool Unit::IsTrainer ( ) const
inline
Definition: Unit.h:739
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsTriggeredAtSpellProcEvent ( Unit victim,
Aura aura,
SpellInfo const procSpell,
uint32  procFlag,
uint32  procExtra,
WeaponAttackType  attType,
bool  isVictim,
bool  active,
SpellProcEventEntry const *&  spellProcEvent 
)
private
13247 {
13248  SpellInfo const* spellProto = aura->GetSpellInfo();
13249 
13250  // let the aura be handled by new proc system if it has new entry
13251  if (sSpellMgr->GetSpellProcEntry(spellProto->Id))
13252  return false;
13253 
13254  // Get proc Event Entry
13255  spellProcEvent = sSpellMgr->GetSpellProcEvent(spellProto->Id);
13256 
13257  // Get EventProcFlag
13258  uint32 EventProcFlag;
13259  if (spellProcEvent && spellProcEvent->procFlags) // if exist get custom spellProcEvent->procFlags
13260  EventProcFlag = spellProcEvent->procFlags;
13261  else
13262  EventProcFlag = spellProto->ProcFlags; // else get from spell proto
13263  // Continue if no trigger exist
13264  if (!EventProcFlag)
13265  return false;
13266 
13267  // Additional checks for triggered spells (ignore trap casts)
13268  if (procExtra & PROC_EX_INTERNAL_TRIGGERED && !(procFlag & PROC_FLAG_DONE_TRAP_ACTIVATION))
13269  {
13271  return false;
13272  }
13273 
13274  // Check spellProcEvent data requirements
13275  if (!sSpellMgr->IsSpellProcEventCanTriggeredBy(spellProto, spellProcEvent, EventProcFlag, procSpell, procFlag, procExtra, active))
13276  return false;
13277  // In most cases req get honor or XP from kill
13278  if (EventProcFlag & PROC_FLAG_KILL && GetTypeId() == TYPEID_PLAYER)
13279  {
13280  bool allow = false;
13281 
13282  if (victim)
13283  allow = ToPlayer()->isHonorOrXPTarget(victim);
13284 
13285  // Shadow Word: Death - can trigger from every kill
13286  if (aura->GetId() == 32409)
13287  allow = true;
13288  if (!allow)
13289  return false;
13290  }
13291  // Aura added by spell can`t trigger from self (prevent drop charges/do triggers)
13292  // But except periodic and kill triggers (can triggered from self)
13293  if (procSpell && procSpell->Id == spellProto->Id
13294  && !(spellProto->ProcFlags&(PROC_FLAG_TAKEN_PERIODIC | PROC_FLAG_KILL)))
13295  return false;
13296 
13297  // Check if current equipment allows aura to proc
13298  if (!isVictim && GetTypeId() == TYPEID_PLAYER)
13299  {
13300  Player* player = ToPlayer();
13301  if (spellProto->EquippedItemClass == ITEM_CLASS_WEAPON)
13302  {
13303  Item* item = NULL;
13304  if (attType == BASE_ATTACK || attType == RANGED_ATTACK)
13305  item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
13306  else if (attType == OFF_ATTACK)
13307  item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
13308 
13309  if (player->IsInFeralForm())
13310  return false;
13311 
13312  if (!item || item->IsBroken() || item->GetTemplate()->GetClass() != ITEM_CLASS_WEAPON || !((1 << item->GetTemplate()->GetSubClass()) & spellProto->EquippedItemSubClassMask))
13313  return false;
13314  }
13315  else if (spellProto->EquippedItemClass == ITEM_CLASS_ARMOR)
13316  {
13317  // Check if player is wearing shield
13318  Item* item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
13319  if (!item || item->IsBroken() || item->GetTemplate()->GetClass() != ITEM_CLASS_ARMOR || !((1 << item->GetTemplate()->GetSubClass()) & spellProto->EquippedItemSubClassMask))
13320  return false;
13321  }
13322  }
13323  // Get chance from spell
13324  float chance = float(spellProto->ProcChance);
13325  // If in spellProcEvent exist custom chance, chance = spellProcEvent->customChance;
13326  if (spellProcEvent && spellProcEvent->customChance)
13327  chance = spellProcEvent->customChance;
13328  // If PPM exist calculate chance from PPM
13329  if (spellProcEvent && spellProcEvent->ppmRate != 0)
13330  {
13331  if (!isVictim)
13332  {
13333  uint32 weaponSpeed = GetAttackTime(attType);
13334  chance = GetPPMProcChance(weaponSpeed, spellProcEvent->ppmRate, spellProto);
13335  }
13336  else if (victim)
13337  {
13338  uint32 weaponSpeed = victim->GetAttackTime(attType);
13339  chance = victim->GetPPMProcChance(weaponSpeed, spellProcEvent->ppmRate, spellProto);
13340  }
13341  }
13342  // Apply chance modifer aura
13343  if (Player* modOwner = GetSpellModOwner())
13344  {
13345  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance);
13346  }
13347  return roll_chance_f(chance);
13348 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
uint32 Id
Definition: SpellInfo.h:329
#define INVENTORY_SLOT_BAG_0
int32 EquippedItemClass
Definition: SpellInfo.h:385
Definition: SpellMgr.h:112
Definition: Unit.h:104
Definition: SharedDefines.h:490
Definition: SpellInfo.h:326
Definition: Unit.h:619
int32 EquippedItemSubClassMask
Definition: SpellInfo.h:386
uint32 GetClass() const
Definition: ItemTemplate.h:653
arena_t NULL
Definition: jemalloc_internal.h:624
Player * ToPlayer()
Definition: Object.h:191
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.cpp:10326
Definition: SpellMgr.h:139
uint32 ProcFlags
Definition: SpellInfo.h:370
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:618
bool roll_chance_f(float chance)
Definition: Random.h:47
uint32 ProcChance
Definition: SpellInfo.h:371
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SpellMgr.h:142
Definition: Item.h:259
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: SpellMgr.h:223
bool IsBroken() const
Definition: Item.h:310
float GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellInfo *spellProto) const
Definition: Unit.cpp:9681
Definition: ItemTemplate.h:369
Definition: ObjectGuid.h:33
uint32 GetSubClass() const
Definition: ItemTemplate.h:654
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Definition: ItemTemplate.h:371
Definition: Unit.h:617
uint32 GetId() const
Definition: SpellAuras.h:131
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::isTurning ( ) const
inline
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:813
bool Unit::IsUnderWater ( ) const
virtual
2970 {
2972 }
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
bool IsUnderWater(float x, float y, float z) const
Definition: Map.cpp:2622
Map const * GetBaseMap() const
Definition: Object.cpp:2199
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsValidAssistTarget ( Unit const target) const
10124 {
10125  return _IsValidAssistTarget(target, NULL);
10126 }
arena_t NULL
Definition: jemalloc_internal.h:624
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition: Unit.cpp:10129

+ Here is the call graph for this function:

bool Unit::IsValidAttackTarget ( Unit const target) const
10003 {
10004  return _IsValidAttackTarget(target, NULL);
10005 }
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=NULL) const
Definition: Unit.cpp:10008
arena_t NULL
Definition: jemalloc_internal.h:624

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsVehicle ( ) const
inline
1406 { return (m_unitTypeMask & UNIT_MASK_VEHICLE) != 0; }
Definition: Unit.h:863
uint32 m_unitTypeMask
Definition: Unit.h:2307

+ Here is the caller graph for this function:

bool Unit::IsVendor ( ) const
inline
Definition: Unit.h:742
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsVisible ( ) const
10364 {
10366 }
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:538
Definition: Common.h:108
Definition: SharedDefines.h:1741
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:382

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsWalking ( ) const
inline
Definition: Unit.h:784
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
MovementInfo m_movementInfo
Definition: Object.h:612

+ Here is the caller graph for this function:

bool Unit::IsWithinCombatRange ( const Unit obj,
float  dist2compare 
) const
493 {
494  if (!obj || !IsInMap(obj) || !IsInPhase(obj))
495  return false;
496 
497  float dx = GetPositionX() - obj->GetPositionX();
498  float dy = GetPositionY() - obj->GetPositionY();
499  float dz = GetPositionZ() - obj->GetPositionZ();
500  float distsq = dx * dx + dy * dy + dz * dz;
501 
502  float sizefactor = GetCombatReach() + obj->GetCombatReach();
503  float maxdist = dist2compare + sizefactor;
504 
505  return distsq < maxdist * maxdist;
506 }
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1631
float GetCombatReach() const
Definition: Unit.h:1361
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
bool IsInPhase(uint32 phase) const
Definition: Object.h:462
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::IsWithinMeleeRange ( const Unit obj,
float  dist = MELEE_RANGE 
) const
509 {
510  if (!obj || !IsInMap(obj) || !IsInPhase(obj))
511  return false;
512 
513  float dx = GetPositionX() - obj->GetPositionX();
514  float dy = GetPositionY() - obj->GetPositionY();
515  float dz = GetPositionZMinusOffset() - obj->GetPositionZMinusOffset();
516  float distsq = dx*dx + dy*dy + dz*dz;
517 
518  float sizefactor = GetMeleeReach() + obj->GetMeleeReach();
519  float maxdist = dist + sizefactor;
520 
521  return distsq < maxdist * maxdist;
522 }
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1631
float GetMeleeReach() const
Definition: Unit.cpp:486
float GetPositionY() const
Definition: Position.h:105
bool IsInPhase(uint32 phase) const
Definition: Object.h:462
float GetPositionX() const
Definition: Position.h:104
float GetPositionZMinusOffset() const
Definition: Unit.cpp:13799

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::JumpTo ( float  speedXY,
float  speedZ,
bool  forward = true 
)
15153 {
15154  float angle = forward ? 0 : float(M_PI);
15155  if (GetTypeId() == TYPEID_UNIT)
15156  GetMotionMaster()->MoveJumpTo(angle, speedXY, speedZ);
15157  else
15158  {
15159  float vcos = std::cos(angle+GetOrientation());
15160  float vsin = std::sin(angle+GetOrientation());
15161  SendMoveKnockBack(ToPlayer(), speedXY, -speedZ, vcos, vsin);
15162  }
15163 }
#define M_PI
Definition: Common.h:163
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
Definition: ObjectGuid.h:32
void MoveJumpTo(float angle, float speedXY, float speedZ)
Definition: MotionMaster.cpp:352
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
float GetOrientation() const
Definition: Position.h:107
void SendMoveKnockBack(Player *player, float speedXY, float speedZ, float vcos, float vsin)
Definition: Unit.cpp:14643

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::JumpTo ( WorldObject obj,
float  speedZ,
bool  withOrientation = false 
)
15166 {
15167  float x, y, z;
15168  obj->GetContactPoint(this, x, y, z);
15169  float speedXY = GetExactDist2d(x, y) * 10.0f / speedZ;
15170  GetMotionMaster()->MoveJump(x, y, z, GetAngle(obj), speedXY, speedZ, EVENT_JUMP, withOrientation);
15171 }
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:137
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
Definition: MotionMaster.h:184
G3D::int16 z
Definition: Vector3int16.h:46
float GetAngle(Position const *pos) const
Definition: Position.cpp:63
G3D::int16 y
Definition: Vector2int16.h:38
Definition: SharedDefines.h:4414
G3D::int16 x
Definition: Vector2int16.h:37
void GetContactPoint(WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
Definition: Object.cpp:2650

+ Here is the call graph for this function:

void Unit::Kill ( Unit victim,
bool  durabilityLoss = true 
)
Todo:
do instance binding anyway if the charmer/owner is offline
13514 {
13515  // Prevent killing unit twice (and giving reward from kill twice)
13516  if (!victim->GetHealth())
13517  return;
13518 
13519  // find player: owner of controlled `this` or `this` itself maybe
13521  Creature* creature = victim->ToCreature();
13522 
13523  bool isRewardAllowed = true;
13524  if (creature)
13525  {
13526  isRewardAllowed = creature->IsDamageEnoughForLootingAndReward();
13527  if (!isRewardAllowed)
13528  creature->SetLootRecipient(NULL);
13529  }
13530 
13531  if (isRewardAllowed && creature && creature->GetLootRecipient())
13532  player = creature->GetLootRecipient();
13533 
13534  // Reward player, his pets, and group/raid members
13535  // call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop)
13536  if (isRewardAllowed && player && player != victim)
13537  {
13538  WorldPackets::Party::PartyKillLog partyKillLog;
13539  partyKillLog.Player = player->GetGUID();
13540  partyKillLog.Victim = victim->GetGUID();
13541 
13542  Player* looter = player;
13543  Group* group = player->GetGroup();
13544  bool hasLooterGuid = false;
13545 
13546  if (group)
13547  {
13548  group->BroadcastPacket(partyKillLog.Write(), group->GetMemberGroup(player->GetGUID()) != 0);
13549 
13550  if (creature)
13551  {
13552  group->UpdateLooterGuid(creature, true);
13553  if (!group->GetLooterGuid().IsEmpty())
13554  {
13555  looter = ObjectAccessor::FindPlayer(group->GetLooterGuid());
13556  if (looter)
13557  {
13558  hasLooterGuid = true;
13559  creature->SetLootRecipient(looter); // update creature loot recipient to the allowed looter.
13560  }
13561  }
13562  }
13563  }
13564  else
13565  {
13566  player->SendDirectMessage(partyKillLog.Write());
13567 
13568  if (creature)
13569  {
13571  lootList.Owner = creature->GetGUID();
13572 
13573  player->SendMessageToSet(lootList.Write(), true);
13574  }
13575  }
13576 
13577  // Generate loot before updating looter
13578  if (creature)
13579  {
13580  Loot* loot = &creature->loot;
13581 
13582  loot->clear();
13583  if (uint32 lootid = creature->GetCreatureTemplate()->lootid)
13584  loot->FillLoot(lootid, LootTemplates_Creature, looter, false, false, creature->GetLootMode());
13585 
13586  loot->generateMoneyLoot(creature->GetCreatureTemplate()->mingold, creature->GetCreatureTemplate()->maxgold);
13587 
13588  if (group)
13589  {
13590  if (hasLooterGuid)
13591  group->SendLooter(creature, looter);
13592  else
13593  group->SendLooter(creature, NULL);
13594 
13595  // Update round robin looter only if the creature had loot
13596  if (!loot->empty())
13597  group->UpdateLooterGuid(creature);
13598  }
13599  }
13600 
13601  player->RewardPlayerAndGroupAtKill(victim, false);
13602  }
13603 
13604  // Do KILL and KILLED procs. KILL proc is called only for the unit who landed the killing blow (and its owner - for pets and totems) regardless of who tapped the victim
13605  if (IsPet() || IsTotem())
13606  if (Unit* owner = GetOwner())
13607  owner->ProcDamageAndSpell(victim, PROC_FLAG_KILL, PROC_FLAG_NONE, PROC_EX_NONE, 0);
13608 
13609  if (!victim->IsCritter())
13611 
13612  // Proc auras on death - must be before aura/combat remove
13614 
13615  // update get killing blow achievements, must be done before setDeathState to be able to require auras on target
13616  // and before Spirit of Redemption as it also removes auras
13617  if (Player* killerPlayer = GetCharmerOrOwnerPlayerOrPlayerItself())
13618  killerPlayer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, 1, 0, 0, victim);
13619 
13620  // if talent known but not triggered (check priest class for speedup check)
13621  bool spiritOfRedemption = false;
13622  if (victim->GetTypeId() == TYPEID_PLAYER && victim->getClass() == CLASS_PRIEST)
13623  {
13624  AuraEffectList const& dummyAuras = victim->GetAuraEffectsByType(SPELL_AURA_DUMMY);
13625  for (AuraEffectList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
13626  {
13627  if ((*itr)->GetSpellInfo()->SpellIconID == 1654)
13628  {
13629  AuraEffect const* aurEff = *itr;
13630  // save value before aura remove
13631  uint32 ressSpellId = victim->GetUInt32Value(PLAYER_SELF_RES_SPELL);
13632  if (!ressSpellId)
13633  ressSpellId = victim->ToPlayer()->GetResurrectionSpellId();
13634  // Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers)
13635  victim->RemoveAllAurasOnDeath();
13636  // restore for use at real death
13637  victim->SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId);
13638 
13639  // FORM_SPIRITOFREDEMPTION and related auras
13640  victim->CastSpell(victim, 27827, true, NULL, aurEff);
13641  spiritOfRedemption = true;
13642  break;
13643  }
13644  }
13645  }
13646 
13647  if (!spiritOfRedemption)
13648  {
13649  TC_LOG_DEBUG("entities.unit", "SET JUST_DIED");
13650  victim->setDeathState(JUST_DIED);
13651  }
13652 
13653  // Inform pets (if any) when player kills target)
13654  // MUST come after victim->setDeathState(JUST_DIED); or pet next target
13655  // selection will get stuck on same target and break pet react state
13656  if (player)
13657  {
13658  Pet* pet = player->GetPet();
13659  if (pet && pet->IsAlive() && pet->isControlled())
13660  pet->AI()->KilledUnit(victim);
13661  }
13662 
13663  // 10% durability loss on death
13664  // clean InHateListOf
13665  if (Player* plrVictim = victim->ToPlayer())
13666  {
13667  // remember victim PvP death for corpse type and corpse reclaim delay
13668  // at original death (not at SpiritOfRedemtionTalent timeout)
13669  plrVictim->SetPvPDeath(player != NULL);
13670 
13671  // only if not player and not controlled by player pet. And not at BG
13672  if ((durabilityLoss && !player && !victim->ToPlayer()->InBattleground()) || (player && sWorld->getBoolConfig(CONFIG_DURABILITY_LOSS_IN_PVP)))
13673  {
13674  double baseLoss = sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH);
13675  uint32 loss = uint32(baseLoss - (baseLoss * plrVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_DURABILITY_LOSS)));
13676  TC_LOG_DEBUG("entities.unit", "We are dead, losing %u percent durability", loss);
13677  // Durability loss is calculated more accurately again for each item in Player::DurabilityLoss
13678  plrVictim->DurabilityLossAll(baseLoss, false);
13679  // durability lost message
13680  SendDurabilityLoss(plrVictim, loss);
13681  }
13682  // Call KilledUnit for creatures
13683  if (GetTypeId() == TYPEID_UNIT && IsAIEnabled)
13684  ToCreature()->AI()->KilledUnit(victim);
13685 
13686  // last damage from non duel opponent or opponent controlled creature
13687  if (plrVictim->duel)
13688  {
13689  plrVictim->duel->opponent->CombatStopWithPets(true);
13690  plrVictim->CombatStopWithPets(true);
13691  plrVictim->DuelComplete(DUEL_INTERRUPTED);
13692  }
13693  }
13694  else // creature died
13695  {
13696  TC_LOG_DEBUG("entities.unit", "DealDamageNotPlayer");
13697 
13698  if (!creature->IsPet())
13699  {
13700  creature->DeleteThreatList();
13701 
13702  // must be after setDeathState which resets dynamic flags
13703  if (!creature->loot.isLooted())
13705  else
13706  creature->AllLootRemovedFromCorpse();
13707  }
13708 
13709  // Call KilledUnit for creatures, this needs to be called after the lootable flag is set
13710  if (GetTypeId() == TYPEID_UNIT && IsAIEnabled)
13711  ToCreature()->AI()->KilledUnit(victim);
13712 
13713  // Call creature just died function
13714  if (creature->IsAIEnabled)
13715  creature->AI()->JustDied(this);
13716 
13717  if (TempSummon* summon = creature->ToTempSummon())
13718  if (Unit* summoner = summon->GetSummoner())
13719  if (summoner->ToCreature() && summoner->IsAIEnabled)
13720  summoner->ToCreature()->AI()->SummonedCreatureDies(creature, this);
13721 
13722  // Dungeon specific stuff, only applies to players killing creatures
13723  if (creature->GetInstanceId())
13724  {
13725  Map* instanceMap = creature->GetMap();
13726  Player* creditedPlayer = GetCharmerOrOwnerPlayerOrPlayerItself();
13728 
13729  if (instanceMap->IsDungeon() && creditedPlayer)
13730  {
13731  if (instanceMap->IsRaidOrHeroicDungeon())
13732  {
13734  ((InstanceMap*)instanceMap)->PermBindAllPlayers(creditedPlayer);
13735  }
13736  else
13737  {
13738  // the reset time is set but not added to the scheduler
13739  // until the players leave the instance
13740  time_t resettime = creature->GetRespawnTimeEx() + 2 * HOUR;
13741  if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(creature->GetInstanceId()))
13742  if (save->GetResetTime() < resettime) save->SetResetTime(resettime);
13743  }
13744  }
13745  }
13746  }
13747 
13748  // outdoor pvp things, do these after setting the death state, else the player activity notify won't work... doh...
13749  // handle player kill only if not suicide (spirit of redemption for example)
13750  if (player && this != victim)
13751  {
13752  if (OutdoorPvP* pvp = player->GetOutdoorPvP())
13753  pvp->HandleKill(player, victim);
13754 
13755  if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId()))
13756  bf->HandleKill(player, victim);
13757  }
13758 
13759  //if (victim->GetTypeId() == TYPEID_PLAYER)
13760  // if (OutdoorPvP* pvp = victim->ToPlayer()->GetOutdoorPvP())
13761  // pvp->HandlePlayerActivityChangedpVictim->ToPlayer();
13762 
13763  // battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill)
13764  if (player && player->InBattleground())
13765  {
13766  if (Battleground* bg = player->GetBattleground())
13767  {
13768  if (Player* playerVictim = victim->ToPlayer())
13769  bg->HandleKillPlayer(playerVictim, player);
13770  else
13771  bg->HandleKillUnit(victim->ToCreature(), player);
13772  }
13773  }
13774 
13775  // achievement stuff
13776  if (victim->GetTypeId() == TYPEID_PLAYER)
13777  {
13778  if (GetTypeId() == TYPEID_UNIT)
13779  victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, GetEntry());
13780  else if (GetTypeId() == TYPEID_PLAYER && victim != this)
13781  victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, ToPlayer()->GetTeam());
13782  }
13783 
13784  // Hook for OnPVPKill Event
13785  if (Player* killerPlr = ToPlayer())
13786  {
13787  if (Player* killedPlr = victim->ToPlayer())
13788  sScriptMgr->OnPVPKill(killerPlr, killedPlr);
13789  else if (Creature* killedCre = victim->ToCreature())
13790  sScriptMgr->OnCreatureKill(killerPlr, killedCre);
13791  }
13792  else if (Creature* killerCre = ToCreature())
13793  {
13794  if (Player* killed = victim->ToPlayer())
13795  sScriptMgr->OnPlayerKilledByCreature(killerCre, killed);
13796  }
13797 }
Definition: World.h:440
Definition: SpellAuraEffects.h:30
Definition: SpellMgr.h:112
Definition: SpellMgr.h:198
LootStore LootTemplates_Creature("creature_loot_template","creature entry", true)
Definition: Creature.h:42
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: TemporarySummon.h:40
Map * GetMap() const
Definition: Object.h:543
Definition: Common.h:98
Definition: Unit.h:542
ObjectGuid Player
Definition: PartyPackets.h:617
WorldPacket const * Write() override
Definition: PartyPackets.cpp:551
Loot loot
Definition: Creature.h:578
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: UpdateFields.h:268
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: SharedDefines.h:4726
bool IsDungeon() const
Definition: Map.h:395
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
uint32 flags_extra
Definition: Creature.h:142
#define sWorld
Definition: World.h:887
void AllLootRemovedFromCorpse()
Definition: Creature.cpp:2382
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
void clear()
Definition: LootMgr.h:349
bool IsAIEnabled
Definition: Unit.h:2161
Definition: SpellMgr.h:109
Player * ToPlayer()
Definition: Object.h:191
void generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
Definition: LootMgr.cpp:694
void SetLootRecipient(Unit *unit)
Definition: Creature.cpp:993
TempSummon * ToTempSummon()
Definition: Unit.h:2206
TypeID GetTypeId() const
Definition: Object.h:113
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
time_t GetRespawnTimeEx() const
Definition: Creature.cpp:2346
Definition: SharedDefines.h:171
Definition: LootPackets.h:170
Definition: Map.h:758
uint32 mingold
Definition: Creature.h:125
Definition: LootMgr.h:314
bool IsAlive() const
Definition: Unit.h:1692
virtual void KilledUnit(Unit *)
Definition: CreatureAI.h:120
bool isControlled() const
Definition: Pet.h:59
CreatureAI * AI() const
Definition: Creature.h:525
uint32 GetInstanceId() const
Definition: Object.h:451
virtual void JustDied(Unit *)
Definition: CreatureAI.h:117
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: Battlefield.h:196
Definition: SpellMgr.h:111
Definition: Map.h:259
Definition: InstanceSaveMgr.h:44
bool empty() const
Definition: LootMgr.h:374
void SendLooter(Creature *creature, Player *pLooter)
Definition: Group.cpp:964
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:243
bool IsPet() const
Definition: Unit.h:1403
ObjectGuid GetLooterGuid() const
Definition: Group.cpp:2549
Definition: SharedDefines.h:4201
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
Player * GetLootRecipient() const
Definition: Creature.cpp:977
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: OutdoorPvP.h:188
Definition: ObjectGuid.h:33
bool isLooted() const
Definition: LootMgr.h:375
virtual void setDeathState(DeathState s)
Definition: Unit.cpp:10593
void ProcDamageAndSpell(Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellInfo const *procSpell=NULL, SpellInfo const *procAura=NULL)
Definition: Unit.cpp:4860
Definition: PartyPackets.h:610
void DeleteThreatList()
Definition: Unit.cpp:10700
ObjectGuid Owner
Definition: LootPackets.h:177
bool IsTotem() const
Definition: Unit.h:1405
bool IsCritter() const
Definition: Unit.h:1580
Unit * GetOwner() const
Definition: Unit.cpp:7542
Creature * ToCreature()
Definition: Object.h:194
uint8 GetMemberGroup(ObjectGuid guid) const
Definition: Group.cpp:2613
Definition: SpellMgr.h:147
uint8 getClass() const
Definition: Unit.h:1413
Definition: SpellAuraDefines.h:64
Definition: World.h:100
void BroadcastPacket(WorldPacket const *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignoredPlayer=ObjectGuid::Empty)
Definition: Group.cpp:1698
Definition: UpdateFields.h:30
Definition: Battleground.h:235
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 GetEntry() const
Definition: Object.h:107
WorldPacket const * Write() override
Definition: LootPackets.cpp:125
void SendDurabilityLoss(Player *receiver, uint32 percent)
Definition: Unit.cpp:13444
uint32_t uint32
Definition: g3dmath.h:168
uint32 lootid
Definition: Creature.h:119
bool IsRaidOrHeroicDungeon() const
Definition: Map.h:398
uint16 GetLootMode() const
Definition: Creature.h:592
uint32 GetHealth() const
Definition: Unit.h:1426
bool FillLoot(uint32 lootId, LootStore const &store, Player *lootOwner, bool personal, bool noEmptyError=false, uint16 lootMode=LOOT_MODE_DEFAULT)
Definition: LootMgr.cpp:450
Definition: Unit.h:1305
void UpdateLooterGuid(WorldObject *pLootedObject, bool ifneed=false)
Definition: Group.cpp:1854
uint32 maxgold
Definition: Creature.h:126
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
void RemoveAllAurasOnDeath()
Definition: Unit.cpp:3953
bool IsDamageEnoughForLootingAndReward() const
Definition: Creature.h:694
Definition: SpellAuraDefines.h:398
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Pet.h:46
Definition: Unit.h:617
Definition: Group.h:191
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560
ObjectGuid Victim
Definition: PartyPackets.h:618

+ Here is the caller graph for this function:

void Unit::KillSelf ( bool  durabilityLoss = true)
inline
1515 { Kill(this, durabilityLoss); }
void Kill(Unit *victim, bool durabilityLoss=true)
Definition: Unit.cpp:13513

+ Here is the caller graph for this function:

void Unit::KnockbackFrom ( float  x,
float  y,
float  speedXY,
float  speedZ 
)
14656 {
14657  Player* player = ToPlayer();
14658  if (!player)
14659  {
14660  if (Unit* charmer = GetCharmer())
14661  {
14662  player = charmer->ToPlayer();
14663  if (player && player->m_mover != this)
14664  player = NULL;
14665  }
14666  }
14667 
14668  if (!player)
14669  GetMotionMaster()->MoveKnockbackFrom(x, y, speedXY, speedZ);
14670  else
14671  {
14672  float vcos, vsin;
14673  GetSinCos(x, y, vsin, vcos);
14674  SendMoveKnockBack(player, speedXY, -speedZ, vcos, vsin);
14675  }
14676 }
Unit * GetCharmer() const
Definition: Unit.cpp:7551
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
arena_t NULL
Definition: jemalloc_internal.h:624
void GetSinCos(float x, float y, float &vsin, float &vcos) const
Definition: Position.cpp:82
Player * ToPlayer()
Definition: Object.h:191
void SendMoveKnockBack(Player *player, float speedXY, float speedZ, float vcos, float vsin)
Definition: Unit.cpp:14643
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ)
Definition: MotionMaster.cpp:327
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellMissInfo Unit::MagicSpellHitResult ( Unit victim,
SpellInfo const spellInfo 
)
Todo:
need use unit spell resistances in calculations
2391 {
2392  // Can`t miss on dead target (on skinning for example)
2393  if ((!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER) || spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
2394  return SPELL_MISS_NONE;
2395 
2396  SpellSchoolMask schoolMask = spellInfo->GetSchoolMask();
2397  // PvP - PvE spell misschances per leveldif > 2
2398  int32 lchance = victim->GetTypeId() == TYPEID_PLAYER ? 7 : 11;
2399  int32 thisLevel = getLevelForTarget(victim);
2400  if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsTrigger())
2401  thisLevel = std::max<int32>(thisLevel, spellInfo->SpellLevel);
2402  int32 leveldif = int32(victim->getLevelForTarget(this)) - thisLevel;
2403  int32 levelBasedHitDiff = leveldif;
2404 
2405  // Base hit chance from attacker and victim levels
2406  int32 modHitChance = 100;
2407  if (levelBasedHitDiff >= 0)
2408  {
2409  if (victim->GetTypeId() != TYPEID_PLAYER)
2410  {
2411  modHitChance = 94 - 3 * std::min(levelBasedHitDiff, 3);
2412  levelBasedHitDiff -= 3;
2413  }
2414  else
2415  {
2416  modHitChance = 96 - std::min(levelBasedHitDiff, 2);
2417  levelBasedHitDiff -= 2;
2418  }
2419  if (levelBasedHitDiff > 0)
2420  modHitChance -= lchance * std::min(levelBasedHitDiff, 7);
2421  }
2422  else
2423  modHitChance = 97 - levelBasedHitDiff;
2424 
2425  // Spellmod from SPELLMOD_RESIST_MISS_CHANCE
2426  if (Player* modOwner = GetSpellModOwner())
2427  modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance);
2428 
2429  // Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will ignore target's avoidance effects
2430  if (!spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
2431  {
2432  // Chance hit from victim SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE auras
2433  modHitChance += victim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask);
2434  }
2435 
2436  int32 HitChance = modHitChance * 100;
2437  // Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings
2438  HitChance += int32(m_modSpellHitChance * 100.0f);
2439 
2440  RoundToInterval(HitChance, 100, 10000);
2441 
2442  int32 tmp = 10000 - HitChance;
2443 
2444  int32 rand = irand(0, 10000);
2445 
2446  if (rand < tmp)
2447  return SPELL_MISS_MISS;
2448 
2449  // Chance resist mechanic (select max value from every mechanic spell effect)
2450  int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100;
2451  tmp += resist_chance;
2452 
2453  // Roll chance
2454  if (rand < tmp)
2455  return SPELL_MISS_RESIST;
2456 
2457  // cast by caster in front of victim
2458  if (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
2459  {
2460  int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
2461  tmp += deflect_chance;
2462  if (rand < tmp)
2463  return SPELL_MISS_DEFLECT;
2464  }
2465 
2466  return SPELL_MISS_NONE;
2467 }
T RoundToInterval(T &num, T floor, T ceil)
Definition: Util.h:110
uint8 getLevelForTarget(WorldObject const *) const override
Definition: Unit.h:1409
Definition: SpellAuraDefines.h:246
SpellSchoolMask
Definition: SharedDefines.h:285
#define M_PI
Definition: Common.h:163
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: ObjectGuid.h:32
Definition: SharedDefines.h:2021
int32 irand(int32 min, int32 max)
Definition: Random.cpp:39
Definition: SharedDefines.h:2030
Definition: SharedDefines.h:2023
float m_modSpellHitChance
Definition: Unit.h:1941
TypeID GetTypeId() const
Definition: Object.h:113
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Definition: Unit.h:102
bool IsAlive() const
Definition: Unit.h:1692
int32_t int32
Definition: Define.h:146
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129
Definition: SpellAuraDefines.h:348
Definition: SpellAuraDefines.h:347
int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4452
Definition: ObjectGuid.h:33
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Creature * ToCreature()
Definition: Object.h:194
int32 GetMechanicResistChance(SpellInfo const *spellInfo) const
Definition: Unit.cpp:2178
Definition: SharedDefines.h:2022
int32_t int32
Definition: g3dmath.h:167
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247
Definition: SharedDefines.h:482

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::MeleeDamageBonusDone ( Unit pVictim,
uint32  damage,
WeaponAttackType  attType,
SpellInfo const spellProto = NULL 
)
9386 {
9387  if (!victim || pdamage == 0)
9388  return 0;
9389 
9390  uint32 creatureTypeMask = victim->GetCreatureTypeMask();
9391 
9392  // Done fixed damage bonus auras
9393  int32 DoneFlatBenefit = 0;
9394 
9395  // ..done
9397  for (AuraEffectList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i)
9398  if (creatureTypeMask & uint32((*i)->GetMiscValue()))
9399  DoneFlatBenefit += (*i)->GetAmount();
9400 
9401  // ..done
9402  // SPELL_AURA_MOD_DAMAGE_DONE included in weapon damage
9403 
9404  // ..done (base at attack power for marked target and base at attack power for creature type)
9405  int32 APbonus = 0;
9406 
9407  if (attType == RANGED_ATTACK)
9408  {
9409  APbonus += victim->GetTotalAuraModifier(SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS);
9410 
9411  // ..done (base at attack power and creature type)
9413  for (AuraEffectList::const_iterator i = mCreatureAttackPower.begin(); i != mCreatureAttackPower.end(); ++i)
9414  if (creatureTypeMask & uint32((*i)->GetMiscValue()))
9415  APbonus += (*i)->GetAmount();
9416  }
9417  else
9418  {
9419  APbonus += victim->GetTotalAuraModifier(SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS);
9420 
9421  // ..done (base at attack power and creature type)
9423  for (AuraEffectList::const_iterator i = mCreatureAttackPower.begin(); i != mCreatureAttackPower.end(); ++i)
9424  if (creatureTypeMask & uint32((*i)->GetMiscValue()))
9425  APbonus += (*i)->GetAmount();
9426  }
9427 
9428  if (APbonus != 0) // Can be negative
9429  {
9430  bool normalized = false;
9431  if (spellProto)
9432  for (SpellEffectInfo const* effect : spellProto->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
9433  if (effect && effect->Effect == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
9434  {
9435  normalized = true;
9436  break;
9437  }
9438  DoneFlatBenefit += int32(APbonus/14.0f * GetAPMultiplier(attType, normalized));
9439  }
9440 
9441  // Done total percent damage auras
9442  float DoneTotalMod = 1.0f;
9443 
9444  // Some spells don't benefit from pct done mods
9445  if (spellProto)
9446  if (!spellProto->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS))
9447  {
9449  for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
9450  {
9451  if ((*i)->GetMiscValue() & spellProto->GetSchoolMask() && !(spellProto->GetSchoolMask() & SPELL_SCHOOL_MASK_NORMAL))
9452  {
9453  if ((*i)->GetSpellInfo()->EquippedItemClass == -1)
9454  AddPct(DoneTotalMod, (*i)->GetAmount());
9455  else if (!((*i)->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0))
9456  AddPct(DoneTotalMod, (*i)->GetAmount());
9457  else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo()))
9458  AddPct(DoneTotalMod, (*i)->GetAmount());
9459  }
9460  }
9461  }
9462 
9464  for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
9465  if (creatureTypeMask & uint32((*i)->GetMiscValue()))
9466  AddPct(DoneTotalMod, (*i)->GetAmount());
9467 
9468  // bonus against aurastate
9470  for (AuraEffectList::const_iterator i = mDamageDoneVersusAurastate.begin(); i != mDamageDoneVersusAurastate.end(); ++i)
9471  if (victim->HasAuraState(AuraStateType((*i)->GetMiscValue())))
9472  AddPct(DoneTotalMod, (*i)->GetAmount());
9473 
9474  // Add SPELL_AURA_MOD_DAMAGE_DONE_FOR_MECHANIC percent bonus
9475  if (spellProto)
9477 
9478  // done scripted mod (take it from owner)
9479  // Unit* owner = GetOwner() ? GetOwner() : this;
9480  // AuraEffectList const& mOverrideClassScript = owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
9481 
9482  float tmpDamage = float(int32(pdamage) + DoneFlatBenefit) * DoneTotalMod;
9483 
9484  // apply spellmod to Done damage
9485  if (spellProto)
9486  if (Player* modOwner = GetSpellModOwner())
9487  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage);
9488 
9489  // bonus result can be negative
9490  return uint32(std::max(tmpDamage, 0.0f));
9491 }
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:4521
Map * GetMap() const
Definition: Object.h:543
Definition: Unit.h:619
AuraStateType
Definition: SharedDefines.h:1754
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SharedDefines.h:552
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Player * ToPlayer()
Definition: Object.h:191
Definition: SpellAuraDefines.h:228
Definition: SpellAuraDefines.h:162
Definition: SpellAuraDefines.h:336
Definition: SpellAuraDefines.h:139
Definition: SharedDefines.h:601
Definition: SharedDefines.h:288
Definition: SpellAuraDefines.h:363
Definition: SpellAuraDefines.h:191
float GetAPMultiplier(WeaponAttackType attType, bool normalized)
Definition: Unit.cpp:13113
Definition: SpellAuraDefines.h:225
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: Unit.h:86
uint32_t uint32
Definition: Define.h:150
Definition: SpellAuraDefines.h:187
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellAuraDefines.h:119
Definition: SharedDefines.h:1131

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::MeleeDamageBonusTaken ( Unit attacker,
uint32  pdamage,
WeaponAttackType  attType,
SpellInfo const spellProto = NULL 
)
9494 {
9495  if (pdamage == 0)
9496  return 0;
9497 
9498  int32 TakenFlatBenefit = 0;
9499  float TakenTotalCasterMod = 0.0f;
9500 
9501  // get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
9502  SpellSchoolMask attackSchoolMask = spellProto ? spellProto->GetSchoolMask() : SPELL_SCHOOL_MASK_NORMAL;
9503  AuraEffectList const& IgnoreResistAuras = attacker->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
9504  for (AuraEffectList::const_iterator i = IgnoreResistAuras.begin(); i != IgnoreResistAuras.end(); ++i)
9505  {
9506  if ((*i)->GetMiscValue() & attackSchoolMask)
9507  TakenTotalCasterMod += (float((*i)->GetAmount()));
9508  }
9509 
9510  // ..taken
9512  for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
9513  if ((*i)->GetMiscValue() & attacker->GetMeleeDamageSchoolMask())
9514  TakenFlatBenefit += (*i)->GetAmount();
9515 
9516  if (attType != RANGED_ATTACK)
9518  else
9520 
9521  // Taken total percent damage auras
9522  float TakenTotalMod = 1.0f;
9523 
9524  // ..taken
9526 
9527  // .. taken pct (special attacks)
9528  if (spellProto)
9529  {
9530  // From caster spells
9532  for (AuraEffectList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i)
9533  if ((*i)->GetCasterGUID() == attacker->GetGUID() && (*i)->IsAffectingSpell(spellProto))
9534  AddPct(TakenTotalMod, (*i)->GetAmount());
9535 
9536  // Mod damage from spell mechanic
9537  uint32 mechanicMask = spellProto->GetAllEffectsMechanicMask();
9538 
9539  // Shred, Maul - "Effects which increase Bleed damage also increase Shred damage"
9540  if (spellProto->SpellFamilyName == SPELLFAMILY_DRUID && spellProto->SpellFamilyFlags[0] & 0x00008800)
9541  mechanicMask |= (1<<MECHANIC_BLEED);
9542 
9543  if (mechanicMask)
9544  {
9546  for (AuraEffectList::const_iterator i = mDamageDoneMechanic.begin(); i != mDamageDoneMechanic.end(); ++i)
9547  if (mechanicMask & uint32(1<<((*i)->GetMiscValue())))
9548  AddPct(TakenTotalMod, (*i)->GetAmount());
9549  }
9550  }
9551 
9552  // .. taken pct: dummy auras
9554  for (AuraEffectList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i)
9555  {
9556  switch ((*i)->GetSpellInfo()->SpellIconID)
9557  {
9558  // Cheat Death
9559  case 2109:
9560  if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
9561  {
9562  if (Player* player = ToPlayer())
9563  {
9564  float mod = player->GetRatingBonusValue(CR_RESILIENCE_PLAYER_DAMAGE_TAKEN) * (-8.0f);
9565  AddPct(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
9566  }
9567  }
9568  break;
9569  }
9570  }
9571 
9572  // .. taken pct: class scripts
9573  //*AuraEffectList const& mclassScritAuras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
9574  //for (AuraEffectList::const_iterator i = mclassScritAuras.begin(); i != mclassScritAuras.end(); ++i)
9575  //{
9576  // switch ((*i)->GetMiscValue())
9577  // {
9578  // }
9579  //}*/
9580 
9581  if (attType != RANGED_ATTACK)
9582  {
9583  AuraEffectList const& mModMeleeDamageTakenPercent = GetAuraEffectsByType(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT);
9584  for (AuraEffectList::const_iterator i = mModMeleeDamageTakenPercent.begin(); i != mModMeleeDamageTakenPercent.end(); ++i)
9585  AddPct(TakenTotalMod, (*i)->GetAmount());
9586  }
9587  else
9588  {
9589  AuraEffectList const& mModRangedDamageTakenPercent = GetAuraEffectsByType(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT);
9590  for (AuraEffectList::const_iterator i = mModRangedDamageTakenPercent.begin(); i != mModRangedDamageTakenPercent.end(); ++i)
9591  AddPct(TakenTotalMod, (*i)->GetAmount());
9592  }
9593 
9594  float tmpDamage = 0.0f;
9595 
9596  if (TakenTotalCasterMod)
9597  {
9598  if (TakenFlatBenefit < 0)
9599  {
9600  if (TakenTotalMod < 1)
9601  tmpDamage = ((float(CalculatePct(pdamage, TakenTotalCasterMod) + TakenFlatBenefit) * TakenTotalMod) + CalculatePct(pdamage, TakenTotalCasterMod));
9602  else
9603  tmpDamage = ((float(CalculatePct(pdamage, TakenTotalCasterMod) + TakenFlatBenefit) + CalculatePct(pdamage, TakenTotalCasterMod)) * TakenTotalMod);
9604  }
9605  else if (TakenTotalMod < 1)
9606  tmpDamage = ((CalculatePct(float(pdamage) + TakenFlatBenefit, TakenTotalCasterMod) * TakenTotalMod) + CalculatePct(float(pdamage) + TakenFlatBenefit, TakenTotalCasterMod));
9607  }
9608  if (!tmpDamage)
9609  tmpDamage = (float(pdamage) + TakenFlatBenefit) * TakenTotalMod;
9610 
9611  // bonus result can be negative
9612  return uint32(std::max(tmpDamage, 0.0f));
9613 }
Definition: SpellAuraDefines.h:74
Definition: SpellAuraDefines.h:331
Definition: SpellAuraDefines.h:147
Definition: SpellAuraDefines.h:173
SpellSchoolMask
Definition: SharedDefines.h:285
virtual SpellSchoolMask GetMeleeDamageSchoolMask() const
Definition: Unit.cpp:12672
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: Unit.h:640
Definition: Unit.h:619
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SpellAuraDefines.h:329
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Player * ToPlayer()
Definition: Object.h:191
Definition: SpellAuraDefines.h:186
Definition: SpellAuraDefines.h:185
Definition: SharedDefines.h:288
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: SpellAuraDefines.h:174
Definition: SharedDefines.h:1805
Definition: SharedDefines.h:4630
float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4470
Definition: SpellAuraDefines.h:315
T CalculatePct(T base, U pct)
Definition: Util.h:92
ObjectGuid const & GetGUID() const
Definition: Object.h:105
T AddPct(T &base, U pct)
Definition: Util.h:98
Definition: SpellAuraDefines.h:64
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellMissInfo Unit::MeleeSpellHitResult ( Unit victim,
SpellInfo const spellInfo 
)
2217 {
2218  // Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will additionally fully ignore
2219  // resist and deflect chances
2220  if (spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
2221  return SPELL_MISS_NONE;
2222 
2223  WeaponAttackType attType = BASE_ATTACK;
2224 
2225  // Check damage class instead of attack type to correctly handle judgements
2226  // - they are meele, but can't be dodged/parried/deflected because of ranged dmg class
2227  if (spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED)
2228  attType = RANGED_ATTACK;
2229 
2230  uint32 roll = urand(0, 10000);
2231 
2232  uint32 missChance = uint32(MeleeSpellMissChance(victim, attType, spellInfo->Id) * 100.0f);
2233 
2234  // Roll miss
2235  uint32 tmp = missChance;
2236  if (roll < tmp)
2237  return SPELL_MISS_MISS;
2238 
2239  // Chance resist mechanic (select max value from every mechanic spell effect)
2240  int32 resist_mech = 0;
2241  // Get effects mechanic and chance
2242  for (uint8 eff = 0; eff < MAX_SPELL_EFFECTS; ++eff)
2243  {
2244  int32 effect_mech = spellInfo->GetEffectMechanic(eff, GetMap()->GetDifficultyID());
2245  if (effect_mech)
2246  {
2248  if (resist_mech < temp * 100)
2249  resist_mech = temp * 100;
2250  }
2251  }
2252  // Roll chance
2253  tmp += resist_mech;
2254  if (roll < tmp)
2255  return SPELL_MISS_RESIST;
2256 
2257  bool canDodge = true;
2258  bool canParry = true;
2259  bool canBlock = spellInfo->HasAttribute(SPELL_ATTR3_BLOCKABLE_SPELL);
2260 
2261  // Same spells cannot be parry/dodge
2262  if (spellInfo->HasAttribute(SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK))
2263  return SPELL_MISS_NONE;
2264 
2265  // Chance resist mechanic
2266  int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100;
2267  tmp += resist_chance;
2268  if (roll < tmp)
2269  return SPELL_MISS_RESIST;
2270 
2271  // Ranged attacks can only miss, resist and deflect
2272  if (attType == RANGED_ATTACK)
2273  {
2274  canParry = false;
2275  canDodge = false;
2276 
2277  // only if in front
2278  if (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
2279  {
2280  int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
2281  tmp += deflect_chance;
2282  if (roll < tmp)
2283  return SPELL_MISS_DEFLECT;
2284  }
2285  return SPELL_MISS_NONE;
2286  }
2287 
2288  // Check for attack from behind
2289  if (!victim->HasInArc(float(M_PI), this))
2290  {
2292  {
2293  // Can`t dodge from behind in PvP (but its possible in PvE)
2294  if (victim->GetTypeId() == TYPEID_PLAYER)
2295  canDodge = false;
2296  // Can`t parry or block
2297  canParry = false;
2298  canBlock = false;
2299  }
2300  else // Only deterrence as of 3.3.5
2301  {
2302  if (spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET))
2303  canParry = false;
2304  }
2305  }
2306  // Check creatures flags_extra for disable parry
2307  if (victim->GetTypeId() == TYPEID_UNIT)
2308  {
2309  uint32 flagEx = victim->ToCreature()->GetCreatureTemplate()->flags_extra;
2310  if (flagEx & CREATURE_FLAG_EXTRA_NO_PARRY)
2311  canParry = false;
2312  // Check creatures flags_extra for disable block
2313  if (flagEx & CREATURE_FLAG_EXTRA_NO_BLOCK)
2314  canBlock = false;
2315  }
2316  // Ignore combat result aura
2318  for (AuraEffectList::const_iterator i = ignore.begin(); i != ignore.end(); ++i)
2319  {
2320  if (!(*i)->IsAffectingSpell(spellInfo))
2321  continue;
2322  switch ((*i)->GetMiscValue())
2323  {
2324  case MELEE_HIT_DODGE:
2325  canDodge = false;
2326  break;
2327  case MELEE_HIT_BLOCK:
2328  canBlock = false;
2329  break;
2330  case MELEE_HIT_PARRY:
2331  canParry = false;
2332  break;
2333  default:
2334  TC_LOG_DEBUG("entities.unit", "Spell %u SPELL_AURA_IGNORE_COMBAT_RESULT has unhandled state %d", (*i)->GetId(), (*i)->GetMiscValue());
2335  break;
2336  }
2337  }
2338 
2339  if (canDodge)
2340  {
2341  // Roll dodge
2342  int32 dodgeChance = int32(victim->GetUnitDodgeChanceAgainst(this) * 100.0f);
2343  // Reduce enemy dodge chance by SPELL_AURA_MOD_COMBAT_RESULT_CHANCE
2345  dodgeChance = int32(float(dodgeChance) * GetTotalAuraMultiplier(SPELL_AURA_MOD_ENEMY_DODGE));
2346  // Reduce dodge chance by attacker expertise rating
2347  if (GetTypeId() == TYPEID_PLAYER)
2348  dodgeChance -= int32(ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100.0f);
2349  else
2350  dodgeChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
2351  if (dodgeChance < 0)
2352  dodgeChance = 0;
2353 
2354  if (roll < (tmp += dodgeChance))
2355  return SPELL_MISS_DODGE;
2356  }
2357 
2358  if (canParry)
2359  {
2360  // Roll parry
2361  int32 parryChance = int32(victim->GetUnitParryChanceAgainst(this) * 100.0f);
2362  // Reduce parry chance by attacker expertise rating
2363  if (GetTypeId() == TYPEID_PLAYER)
2364  parryChance -= int32(ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100.0f);
2365  else
2366  parryChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
2367  if (parryChance < 0)
2368  parryChance = 0;
2369 
2370  tmp += parryChance;
2371  if (roll < tmp)
2372  return SPELL_MISS_PARRY;
2373  }
2374 
2375  if (canBlock)
2376  {
2377  int32 blockChance = int32(victim->GetUnitBlockChanceAgainst(this) * 100.0f);
2378  if (blockChance < 0)
2379  blockChance = 0;
2380  tmp += blockChance;
2381 
2382  if (roll < tmp)
2383  return SPELL_MISS_BLOCK;
2384  }
2385 
2386  return SPELL_MISS_NONE;
2387 }
Definition: SpellAuraDefines.h:300
float GetUnitParryChanceAgainst(Unit const *attacker) const
Definition: Unit.cpp:2550
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:4521
Definition: SpellAuraDefines.h:311
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:2025
#define M_PI
Definition: Common.h:163
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: Unit.h:619
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
Definition: SharedDefines.h:2052
float MeleeSpellMissChance(Unit const *victim, WeaponAttackType attType, uint32 spellId) const
Definition: Unit.cpp:14545
Definition: SharedDefines.h:2021
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 flags_extra
Definition: Creature.h:142
float GetUnitBlockChanceAgainst(Unit const *attacker) const
Definition: Unit.cpp:2593
Definition: SharedDefines.h:2024
Definition: Unit.h:884
Player * ToPlayer()
Definition: Object.h:191
Definition: Creature.h:44
Definition: SharedDefines.h:2030
Definition: SharedDefines.h:2023
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: Creature.h:46
Definition: SharedDefines.h:2026
Definition: Unit.h:337
Definition: SharedDefines.h:467
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129
Definition: SharedDefines.h:377
Definition: Unit.h:884
Definition: Unit.h:884
Definition: SpellAuraDefines.h:262
Definition: SpellAuraDefines.h:348
Definition: SpellAuraDefines.h:347
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
int32 GetMechanicResistChance(SpellInfo const *spellInfo) const
Definition: Unit.cpp:2178
Definition: SharedDefines.h:2022
int32_t int32
Definition: g3dmath.h:167
uint8_t uint8
Definition: Define.h:152
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247
Definition: SpellAuraDefines.h:308
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellAuraDefines.h:177
WeaponAttackType
Definition: Unit.h:615
Definition: SharedDefines.h:482
Definition: SpellInfo.h:199
float GetUnitDodgeChanceAgainst(Unit const *attacker) const
Definition: Unit.cpp:2528
Definition: Unit.h:617
float GetTotalAuraMultiplier(AuraType auratype) const
Definition: Unit.cpp:4415

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::MeleeSpellMissChance ( Unit const victim,
WeaponAttackType  attType,
uint32  spellId 
) const
14546 {
14547  //calculate miss chance
14548  float missChance = victim->GetUnitMissChance(attType);
14549 
14550  if (!spellId && haveOffhandWeapon())
14551  missChance += 19;
14552 
14553  // Calculate hit chance
14554  float hitChance = 100.0f;
14555 
14556  // Spellmod from SPELLMOD_RESIST_MISS_CHANCE
14557  if (spellId)
14558  {
14559  if (Player* modOwner = GetSpellModOwner())
14560  modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, hitChance);
14561  }
14562 
14563  missChance += hitChance - 100.0f;
14564 
14565  if (attType == RANGED_ATTACK)
14566  missChance -= m_modRangedHitChance;
14567  else
14568  missChance -= m_modMeleeHitChance;
14569 
14570  // Limit miss chance from 0 to 60%
14571  if (missChance < 0.0f)
14572  return 0.0f;
14573  if (missChance > 77.0f)
14574  return 77.0f;
14575  return missChance;
14576 }
float m_modMeleeHitChance
Definition: Unit.h:1939
Definition: Unit.h:619
Definition: Unit.h:102
bool haveOffhandWeapon() const
Definition: Unit.cpp:418
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
float m_modRangedHitChance
Definition: Unit.h:1940

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ModifyAuraState ( AuraStateType  flag,
bool  apply 
)
7423 {
7424  if (apply)
7425  {
7426  if (!HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)))
7427  {
7428  SetFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1));
7429  if (GetTypeId() == TYPEID_PLAYER)
7430  {
7431  PlayerSpellMap const& sp_list = ToPlayer()->GetSpellMap();
7432  for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
7433  {
7434  if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
7435  continue;
7436  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
7437  if (!spellInfo || !spellInfo->IsPassive())
7438  continue;
7439  if (spellInfo->CasterAuraState == uint32(flag))
7440  CastSpell(this, itr->first, true, NULL);
7441  }
7442  }
7443  else if (Pet* pet = ToCreature()->ToPet())
7444  {
7445  for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr)
7446  {
7447  if (itr->second.state == PETSPELL_REMOVED)
7448  continue;
7449  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
7450  if (!spellInfo || !spellInfo->IsPassive())
7451  continue;
7452  if (spellInfo->CasterAuraState == uint32(flag))
7453  CastSpell(this, itr->first, true, NULL);
7454  }
7455  }
7456  }
7457  }
7458  else
7459  {
7460  if (HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)))
7461  {
7462  RemoveFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1));
7463 
7464  if (flag != AURA_STATE_ENRAGE) // enrage aura state triggering continues auras
7465  {
7467  for (Unit::AuraApplicationMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
7468  {
7469  SpellInfo const* spellProto = (*itr).second->GetBase()->GetSpellInfo();
7470  if (spellProto->CasterAuraState == uint32(flag))
7471  RemoveAura(itr);
7472  else
7473  ++itr;
7474  }
7475  }
7476  }
7477  }
7478 }
Definition: Player.h:106
bool IsPassive() const
Definition: SpellInfo.cpp:1403
Definition: SpellInfo.h:326
Pet * ToPet()
Definition: Unit.h:2200
arena_t NULL
Definition: jemalloc_internal.h:624
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:191
Definition: UpdateFields.h:112
TypeID GetTypeId() const
Definition: Object.h:113
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
std::unordered_map< uint32, PlayerSpell * > PlayerSpellMap
Definition: Player.h:197
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:1775
Definition: PetDefines.h:53
uint32 CasterAuraState
Definition: SpellInfo.h:354
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::ModifyHealth ( int32  val)
10217 {
10218  int32 gain = 0;
10219 
10220  if (dVal == 0)
10221  return 0;
10222 
10223  int32 curHealth = (int32)GetHealth();
10224 
10225  int32 val = dVal + curHealth;
10226  if (val <= 0)
10227  {
10228  SetHealth(0);
10229  return -curHealth;
10230  }
10231 
10232  int32 maxHealth = (int32)GetMaxHealth();
10233 
10234  if (val < maxHealth)
10235  {
10236  SetHealth(val);
10237  gain = val - curHealth;
10238  }
10239  else if (curHealth != maxHealth)
10240  {
10241  SetHealth(maxHealth);
10242  gain = maxHealth - curHealth;
10243  }
10244 
10245  if (dVal < 0)
10246  {
10248  packet.Guid = GetGUID();
10249  packet.Health = GetHealth();
10250 
10252  player->GetSession()->SendPacket(packet.Write());
10253 
10254  }
10255 
10256  return gain;
10257 }
uint32 GetMaxHealth() const
Definition: Unit.h:1427
WorldPacket const * Write() override
Definition: CombatPackets.cpp:130
int32_t int32
Definition: Define.h:146
Definition: CombatPackets.h:181
ObjectGuid const & GetGUID() const
Definition: Object.h:105
int32_t int32
Definition: g3dmath.h:167
ObjectGuid Guid
Definition: CombatPackets.h:188
void SetHealth(uint32 val)
Definition: Unit.cpp:11537
int32 Health
Definition: CombatPackets.h:189
uint32 GetHealth() const
Definition: Unit.h:1426
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::ModifyPower ( Powers  power,
int32  val 
)
10286 {
10287  int32 gain = 0;
10288 
10289  if (dVal == 0)
10290  return 0;
10291 
10292  int32 curPower = GetPower(power);
10293 
10294  int32 val = dVal + curPower;
10295  if (val <= GetMinPower(power))
10296  {
10297  SetPower(power, GetMinPower(power));
10298  return -curPower;
10299  }
10300 
10301  int32 maxPower = GetMaxPower(power);
10302 
10303  if (val < maxPower)
10304  {
10305  SetPower(power, val);
10306  gain = val - curPower;
10307  }
10308  else if (curPower != maxPower)
10309  {
10310  SetPower(power, maxPower);
10311  gain = maxPower - curPower;
10312  }
10313 
10314  return gain;
10315 }
int32 GetPower(Powers power) const
Definition: Unit.cpp:11589
int32 GetMinPower(Powers power) const
Definition: Unit.h:1447
int32_t int32
Definition: Define.h:146
void SetPower(Powers power, int32 val)
Definition: Unit.cpp:11607
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::ModifyPowerPct ( Powers  power,
float  pct,
bool  apply = true 
)
10319 {
10320  float amount = (float)GetMaxPower(power);
10321  ApplyPercentModFloatVar(amount, pct, apply);
10322 
10323  return ModifyPower(power, (int32)amount - GetMaxPower(power));
10324 }
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:10285
void apply(T *val)
Definition: ByteConverter.h:41
int32_t int32
Definition: Define.h:146
void ApplyPercentModFloatVar(float &var, float val, bool apply)
Definition: Util.h:83
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ModifyRedirectThreat ( int32  amount)
inline
void ModifyThreatPct(int32 amount)
Definition: Unit.h:1092
RedirectThreatInfo _redirectThreadInfo
Definition: Unit.h:2350
void Unit::ModSpellCastTime ( SpellInfo const spellProto,
int32 castTime,
Spell spell = NULL 
)
11050 {
11051  if (!spellInfo || castTime < 0)
11052  return;
11053 
11054  // called from caster
11055  if (Player* modOwner = GetSpellModOwner())
11056  modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, castTime, spell);
11057 
11058  if (!((spellInfo->Attributes & (SPELL_ATTR0_ABILITY | SPELL_ATTR0_TRADESPELL)) || (spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS))) &&
11059  ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT))
11060  castTime = int32(float(castTime) * GetFloatValue(UNIT_MOD_CAST_SPEED));
11061  else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG))
11062  castTime = int32(float(castTime) * m_modAttackSpeedPct[RANGED_ATTACK]);
11063  else if (IsPartOfSkillLine(SKILL_COOKING, spellInfo->Id) && HasAura(67556)) // cooking with Chef Hat.
11064  castTime = 500;
11065 }
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
Definition: Unit.h:619
Definition: SharedDefines.h:360
Definition: ObjectGuid.h:32
Definition: UpdateFields.h:129
Definition: SharedDefines.h:361
Definition: Unit.h:96
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:433
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
float m_modAttackSpeedPct[3]
Definition: Unit.h:1945
Definition: SharedDefines.h:3937
Definition: SharedDefines.h:493
Definition: ObjectGuid.h:33
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:357
bool IsPartOfSkillLine(uint32 skillId, uint32 spellId)
Definition: SpellMgr.cpp:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::ModSpellDuration ( SpellInfo const spellProto,
Unit const target,
int32  duration,
bool  positive,
uint32  effectMask 
)
10957 {
10958  // don't mod permanent auras duration
10959  if (duration < 0)
10960  return duration;
10961 
10962  // some auras are not affected by duration modifiers
10963  if (spellProto->HasAttribute(SPELL_ATTR7_IGNORE_DURATION_MODS))
10964  return duration;
10965 
10966  // cut duration only of negative effects
10967  if (!positive)
10968  {
10969  int32 mechanic = spellProto->GetSpellMechanicMaskByEffectMask(effectMask);
10970 
10971  int32 durationMod;
10972  int32 durationMod_always = 0;
10973  int32 durationMod_not_stack = 0;
10974 
10975  for (uint8 i = 1; i <= MECHANIC_ENRAGED; ++i)
10976  {
10977  if (!(mechanic & 1<<i))
10978  continue;
10979  // Find total mod value (negative bonus)
10980  int32 new_durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD, i);
10981  // Find max mod (negative bonus)
10982  int32 new_durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, i);
10983  // Check if mods applied before were weaker
10984  if (new_durationMod_always < durationMod_always)
10985  durationMod_always = new_durationMod_always;
10986  if (new_durationMod_not_stack < durationMod_not_stack)
10987  durationMod_not_stack = new_durationMod_not_stack;
10988  }
10989 
10990  // Select strongest negative mod
10991  if (durationMod_always > durationMod_not_stack)
10992  durationMod = durationMod_not_stack;
10993  else
10994  durationMod = durationMod_always;
10995 
10996  if (durationMod != 0)
10997  AddPct(duration, durationMod);
10998 
10999  // there are only negative mods currently
11000  durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL, spellProto->Dispel);
11001  durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK, spellProto->Dispel);
11002 
11003  durationMod = 0;
11004  if (durationMod_always > durationMod_not_stack)
11005  durationMod += durationMod_not_stack;
11006  else
11007  durationMod += durationMod_always;
11008 
11009  if (durationMod != 0)
11010  AddPct(duration, durationMod);
11011  }
11012  else
11013  {
11014  // else positive mods here, there are no currently
11015  // when there will be, change GetTotalAuraModifierByMiscValue to GetTotalPositiveAuraModifierByMiscValue
11016 
11017  // Mixology - duration boost
11018  if (target->GetTypeId() == TYPEID_PLAYER)
11019  {
11020  if (spellProto->SpellFamilyName == SPELLFAMILY_POTION && (
11021  sSpellMgr->IsSpellMemberOfSpellGroup(spellProto->Id, SPELL_GROUP_ELIXIR_BATTLE) ||
11022  sSpellMgr->IsSpellMemberOfSpellGroup(spellProto->Id, SPELL_GROUP_ELIXIR_GUARDIAN)))
11023  {
11024  SpellEffectInfo const* effect = spellProto->GetEffect(DIFFICULTY_NONE, EFFECT_0);
11025  if (target->HasAura(53042) && effect && target->HasSpell(effect->TriggerSpell))
11026  duration *= 2;
11027  }
11028  }
11029  }
11030 
11031  // Glyphs which increase duration of selfcast buffs
11032  if (target == this)
11033  {
11034  switch (spellProto->SpellFamilyName)
11035  {
11036  case SPELLFAMILY_DRUID:
11037  if (spellProto->SpellFamilyFlags[0] & 0x100)
11038  {
11039  // Glyph of Thorns
11040  if (AuraEffect* aurEff = GetAuraEffect(57862, 0))
11041  duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS;
11042  }
11043  break;
11044  }
11045  }
11046  return std::max(duration, 0);
11047 }
Definition: SpellAuraEffects.h:30
Definition: SharedDefines.h:1821
Definition: DBCEnums.h:404
Definition: SharedDefines.h:609
Definition: SharedDefines.h:28
Definition: SharedDefines.h:4636
Definition: SpellAuraDefines.h:294
Definition: Common.h:97
T max(const T &x, const T &y)
Definition: g3dmath.h:320
uint32 TriggerSpell
Definition: SpellInfo.h:263
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
Definition: SpellMgr.h:320
Definition: SharedDefines.h:4630
Definition: SpellAuraDefines.h:305
Definition: ObjectGuid.h:33
Definition: SpellAuraDefines.h:292
Definition: Common.h:103
T AddPct(T &base, U pct)
Definition: Util.h:98
Definition: SpellMgr.h:321
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
uint8_t uint8
Definition: Define.h:152
Definition: SpellAuraDefines.h:306

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ModSpellDurationTime ( SpellInfo const spellProto,
int32 castTime,
Spell spell = NULL 
)
11068 {
11069  if (!spellInfo || duration < 0)
11070  return;
11071 
11072  if (spellInfo->IsChanneled() && !spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))
11073  return;
11074 
11075  // called from caster
11076  if (Player* modOwner = GetSpellModOwner())
11077  modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, duration, spell);
11078 
11079  if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) &&
11080  ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT))
11081  duration = int32(float(duration) * GetFloatValue(UNIT_MOD_CAST_SPEED));
11082  else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG))
11083  duration = int32(float(duration) * m_modAttackSpeedPct[RANGED_ATTACK]);
11084 }
Definition: SharedDefines.h:549
Definition: Unit.h:619
Definition: SharedDefines.h:360
Definition: ObjectGuid.h:32
Definition: UpdateFields.h:129
Definition: SharedDefines.h:361
Definition: Unit.h:96
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:433
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
float m_modAttackSpeedPct[3]
Definition: Unit.h:1945
Definition: SharedDefines.h:493
Definition: ObjectGuid.h:33
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:357

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::MonsterMoveWithSpeed ( float  x,
float  y,
float  z,
float  speed,
bool  generatePath = false,
bool  forceDestination = false 
)
427 {
428  Movement::MoveSplineInit init(this);
429  init.MoveTo(x, y, z, generatePath, forceDestination);
430  init.SetVelocity(speed);
431  init.Launch();
432 }
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
Definition: MoveSplineInit.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Mount ( uint32  mount,
uint32  vehicleId = 0,
uint32  creatureEntry = 0 
)
9696 {
9697  if (mount)
9699 
9701 
9702  if (Player* player = ToPlayer())
9703  {
9704  // mount as a vehicle
9705  if (VehicleId)
9706  {
9707  if (CreateVehicleKit(VehicleId, creatureEntry))
9708  {
9709  player->SendOnCancelExpectedVehicleRideAura();
9710 
9711  // mounts can also have accessories
9713  }
9714  }
9715 
9716  // unsummon pet
9717  Pet* pet = player->GetPet();
9718  if (pet)
9719  {
9720  Battleground* bg = ToPlayer()->GetBattleground();
9721  // don't unsummon pet in arena but SetFlag UNIT_FLAG_STUNNED to disable pet's interface
9722  if (bg && bg->isArena())
9724  else
9725  player->UnsummonPetTemporaryIfAny();
9726  }
9727 
9728  player->SendMovementSetCollisionHeight(player->GetCollisionHeight(true));
9729  }
9730 
9732 }
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
void InstallAllAccessories(bool evading)
Definition: Vehicle.cpp:88
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
Player * ToPlayer()
Definition: Object.h:191
bool isArena() const
Definition: Battleground.h:326
bool CreateVehicleKit(uint32 id, uint32 creatureEntry, bool loading=false)
Definition: Unit.cpp:14302
Definition: Unit.h:700
Definition: UpdateFields.h:109
Definition: Unit.h:691
Definition: Battleground.h:235
Definition: UpdateFields.h:119
Definition: Pet.h:46
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165
Definition: Unit.h:71

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::MustReacquireTarget ( )
inline
1373 { m_shouldReacquireTarget = true; } // flags the Unit for forced target reacquisition in the next ::Attack call
bool m_shouldReacquireTarget
Definition: Unit.h:2257

+ Here is the caller graph for this function:

void Unit::NearTeleportTo ( float  x,
float  y,
float  z,
float  orientation,
bool  casting = false 
)
15408 {
15409  DisableSpline();
15410  if (GetTypeId() == TYPEID_PLAYER)
15411  ToPlayer()->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0));
15412  else
15413  {
15414  Position pos = {x, y, z, orientation};
15415  SendTeleportPacket(pos);
15416  UpdatePosition(x, y, z, orientation, true);
15418  }
15419 }
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:14630
void SendTeleportPacket(Position &pos)
Definition: Unit.cpp:15421
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
uint32 GetMapId() const
Definition: Position.h:254
Definition: ObjectGuid.h:33
void DisableSpline()
Definition: Unit.cpp:475
Definition: Position.h:27
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport=false)
Definition: Unit.cpp:15454
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::OutDebugInfo ( ) const
15626 {
15627  TC_LOG_ERROR("entities.unit", "Unit::OutDebugInfo");
15628  TC_LOG_DEBUG("entities.unit", "%s name %s", GetGUID().ToString().c_str(), GetName().c_str());
15629  TC_LOG_DEBUG("entities.unit", "Owner %s, Minion %s, Charmer %s, Charmed %s", GetOwnerGUID().ToString().c_str(), GetMinionGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), GetCharmGUID().ToString().c_str());
15630  TC_LOG_DEBUG("entities.unit", "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask);
15631  if (IsInWorld())
15632  TC_LOG_DEBUG("entities.unit", "Mapid %u", GetMapId());
15633 
15634  std::ostringstream o;
15635  o << "Summon Slot: ";
15636  for (uint32 i = 0; i < MAX_SUMMON_SLOT; ++i)
15637  o << m_SummonSlot[i].ToString() << ", ";
15638 
15639  TC_LOG_DEBUG("entities.unit", "%s", o.str().c_str());
15640  o.str("");
15641 
15642  o << "Controlled List: ";
15643  for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
15644  o << (*itr)->GetGUID().ToString() << ", ";
15645  TC_LOG_DEBUG("entities.unit", "%s", o.str().c_str());
15646  o.str("");
15647 
15648  o << "Aura List: ";
15649  for (AuraApplicationMap::const_iterator itr = m_appliedAuras.begin(); itr != m_appliedAuras.end(); ++itr)
15650  o << itr->first << ", ";
15651  TC_LOG_DEBUG("entities.unit", "%s", o.str().c_str());
15652  o.str("");
15653 
15654  if (IsVehicle())
15655  {
15656  o << "Passenger List: ";
15657  for (SeatMap::iterator itr = GetVehicleKit()->Seats.begin(); itr != GetVehicleKit()->Seats.end(); ++itr)
15658  if (Unit* passenger = ObjectAccessor::GetUnit(*GetVehicleBase(), itr->second.Passenger.Guid))
15659  o << passenger->GetGUID().ToString() << ", ";
15660  TC_LOG_DEBUG("entities.unit", "%s", o.str().c_str());
15661  }
15662 
15663  if (GetVehicle())
15664  TC_LOG_DEBUG("entities.unit", "On vehicle %u.", GetVehicleBase()->GetEntry());
15665 }
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1706
bool IsVehicle() const
Definition: Unit.h:1406
std::string const & GetName() const
Definition: Object.h:479
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
ObjectGuid GetMinionGUID() const
Definition: Unit.h:1702
Seats
Definition: boss_grand_champions.cpp:78
std::string ToString() const
Definition: Position.cpp:160
uint32_t uint32
Definition: Define.h:150
uint32 GetMapId() const
Definition: Position.h:254
ControlList m_Controlled
Definition: Unit.h:1738
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Vehicle * GetVehicle() const
Definition: Unit.h:2166
uint32 m_unitTypeMask
Definition: Unit.h:2307
#define MAX_SUMMON_SLOT
Definition: Unit.h:1285
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool IsInWorld() const
Definition: Object.h:100
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
Definition: Unit.h:1305
SeatMap Seats
The collection of all seats on the vehicle. Including vacant ones.
Definition: Vehicle.h:68
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::PlayOneShotAnimKitId ( uint16  animKitId)
13452 {
13453  if (!sAnimKitStore.LookupEntry(animKitId))
13454  {
13455  TC_LOG_ERROR("entities.unit", "Unit::PlayOneShotAnimKitId using invalid AnimKit ID: %u", animKitId);
13456  return;
13457  }
13458 
13460  data.Unit = GetGUID();
13461  data.AnimKitID = animKitId;
13462  SendMessageToSet(data.Write(), true);
13463 }
uint16 AnimKitID
Definition: MiscPackets.h:677
ObjectGuid Unit
Definition: MiscPackets.h:676
Definition: MiscPackets.h:669
ObjectGuid const & GetGUID() const
Definition: Object.h:105
DBCStorage< AnimKitEntry > sAnimKitStore(AnimKitfmt)
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
WorldPacket const * Write() override
Definition: MiscPackets.cpp:527

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ProcDamageAndSpell ( Unit victim,
uint32  procAttacker,
uint32  procVictim,
uint32  procEx,
uint32  amount,
WeaponAttackType  attType = BASE_ATTACK,
SpellInfo const procSpell = NULL,
SpellInfo const procAura = NULL 
)
4861 {
4862  // Not much to do if no flags are set.
4863  if (procAttacker)
4864  ProcDamageAndSpellFor(false, victim, procAttacker, procExtra, attType, procSpell, amount, procAura);
4865  // Now go on with a victim's events'n'auras
4866  // Not much to do if no flags are set or there is no victim
4867  if (victim && victim->IsAlive() && procVictim)
4868  victim->ProcDamageAndSpellFor(true, this, procVictim, procExtra, attType, procSpell, amount, procAura);
4869 }
void ProcDamageAndSpellFor(bool isVictim, Unit *target, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellInfo const *procSpell, uint32 damage, SpellInfo const *procAura=NULL)
Definition: Unit.cpp:12232
bool IsAlive() const
Definition: Unit.h:1692

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ProcDamageAndSpellFor ( bool  isVictim,
Unit target,
uint32  procFlag,
uint32  procExtra,
WeaponAttackType  attType,
SpellInfo const procSpell,
uint32  damage,
SpellInfo const procAura = NULL 
)
12233 {
12234  // Player is loaded now - do not allow passive spell casts to proc
12235  if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetSession()->PlayerLoading())
12236  return;
12237  // For melee/ranged based attack need update skills and set some Aura states if victim present
12238  if (procFlag & MELEE_BASED_TRIGGER_MASK && target)
12239  {
12240  // If exist crit/parry/dodge/block need update aura state (for victim and attacker)
12242  {
12243  // for victim
12244  if (isVictim)
12245  {
12246  // if victim and dodge attack
12247  if (procExtra & PROC_EX_DODGE)
12248  {
12249  // Update AURA_STATE on dodge
12250  if (getClass() != CLASS_ROGUE) // skip Rogue Riposte
12251  {
12254  }
12255  }
12256  // if victim and parry attack
12257  if (procExtra & PROC_EX_PARRY)
12258  {
12259  // For Hunters only Counterattack (skip Mongoose bite)
12260  if (getClass() == CLASS_HUNTER)
12261  {
12264  }
12265  else
12266  {
12269  }
12270  }
12271  // if and victim block attack
12272  if (procExtra & PROC_EX_BLOCK)
12273  {
12276  }
12277  }
12278  else // For attacker
12279  {
12280  // Overpower on victim dodge
12281  if (procExtra & PROC_EX_DODGE && GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR)
12282  {
12283  ToPlayer()->AddComboPoints(1);
12285  }
12286  }
12287  }
12288  }
12289 
12290  Unit* actor = isVictim ? target : this;
12291  Unit* actionTarget = !isVictim ? target : this;
12292 
12293  DamageInfo damageInfo = DamageInfo(actor, actionTarget, damage, procSpell, procSpell ? SpellSchoolMask(procSpell->SchoolMask) : SPELL_SCHOOL_MASK_NORMAL, SPELL_DIRECT_DAMAGE);
12294  HealInfo healInfo = HealInfo(actor, actionTarget, damage, procSpell, procSpell ? SpellSchoolMask(procSpell->SchoolMask) : SPELL_SCHOOL_MASK_NORMAL);
12295  ProcEventInfo eventInfo = ProcEventInfo(actor, actionTarget, target, procFlag, 0, 0, procExtra, nullptr, &damageInfo, &healInfo);
12296 
12297  ProcTriggeredList procTriggered;
12298  // Fill procTriggered list
12299  for (AuraApplicationMap::const_iterator itr = GetAppliedAuras().begin(); itr!= GetAppliedAuras().end(); ++itr)
12300  {
12301  // Do not allow auras to proc from effect triggered by itself
12302  if (procAura && procAura->Id == itr->first)
12303  continue;
12304  ProcTriggeredData triggerData(itr->second->GetBase());
12305  // Defensive procs are active on absorbs (so absorption effects are not a hindrance)
12306  bool active = damage || (procExtra & PROC_EX_BLOCK && isVictim);
12307  if (isVictim)
12308  procExtra &= ~PROC_EX_INTERNAL_REQ_FAMILY;
12309 
12310  SpellInfo const* spellProto = itr->second->GetBase()->GetSpellInfo();
12311 
12312  // only auras that has triggered spell should proc from fully absorbed damage
12313  if (procExtra & PROC_EX_ABSORB && isVictim && damage)
12314  {
12315  for (SpellEffectInfo const* effect : itr->second->GetBase()->GetSpellEffectInfos())
12316  {
12317  if (effect && effect->TriggerSpell)
12318  {
12319  active = true;
12320  break;
12321  }
12322  }
12323  }
12324  if (!IsTriggeredAtSpellProcEvent(target, triggerData.aura, procSpell, procFlag, procExtra, attType, isVictim, active, triggerData.spellProcEvent))
12325  continue;
12326 
12327  // do checks using conditions table
12328  if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL_PROC, spellProto->Id, eventInfo.GetActor(), eventInfo.GetActionTarget()))
12329  continue;
12330 
12331  // AuraScript Hook
12332  if (!triggerData.aura->CallScriptCheckProcHandlers(itr->second, eventInfo))
12333  continue;
12334 
12335  // Triggered spells not triggering additional spells
12336  bool triggered = !spellProto->HasAttribute(SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED) ?
12337  (procExtra & PROC_EX_INTERNAL_TRIGGERED && !(procFlag & PROC_FLAG_DONE_TRAP_ACTIVATION)) : false;
12338 
12339  for (AuraEffect const* aurEff : itr->second->GetBase()->GetAuraEffects())
12340  {
12341  if (aurEff)
12342  {
12343  // Skip this auras
12344  if (isNonTriggerAura[aurEff->GetAuraType()])
12345  continue;
12346  // If not trigger by default and spellProcEvent == NULL - skip
12347  if (!isTriggerAura[aurEff->GetAuraType()] && triggerData.spellProcEvent == NULL)
12348  continue;
12349  // Some spells must always trigger
12350  if (!triggered || isAlwaysTriggeredAura[aurEff->GetAuraType()])
12351  triggerData.effMask |= 1 << aurEff->GetEffIndex();
12352  }
12353  }
12354  if (triggerData.effMask)
12355  procTriggered.push_front(triggerData);
12356  }
12357 
12358  // Nothing found
12359  if (procTriggered.empty())
12360  return;
12361 
12362  // Note: must SetCantProc(false) before return
12364  SetCantProc(true);
12365 
12366  // Handle effects proceed this time
12367  for (ProcTriggeredList::const_iterator i = procTriggered.begin(); i != procTriggered.end(); ++i)
12368  {
12369  // look for aura in auras list, it may be removed while proc event processing
12370  if (i->aura->IsRemoved())
12371  continue;
12372 
12373  bool useCharges = i->aura->IsUsingCharges();
12374  // no more charges to use, prevent proc
12375  if (useCharges && !i->aura->GetCharges())
12376  continue;
12377 
12378  bool takeCharges = false;
12379  SpellInfo const* spellInfo = i->aura->GetSpellInfo();
12380  uint32 Id = i->aura->GetId();
12381 
12382  AuraApplication* aurApp = i->aura->GetApplicationOfTarget(GetGUID());
12383  ASSERT(aurApp);
12384 
12385  bool prepare = i->aura->CallScriptPrepareProcHandlers(aurApp, eventInfo);
12386 
12387  // For players set spell cooldown if need
12388  uint32 cooldown = 0;
12389  if (prepare && GetTypeId() == TYPEID_PLAYER && i->spellProcEvent && i->spellProcEvent->cooldown)
12390  cooldown = i->spellProcEvent->cooldown;
12391 
12392  // Note: must SetCantProc(false) before return
12393  if (spellInfo->HasAttribute(SPELL_ATTR3_DISABLE_PROC))
12394  SetCantProc(true);
12395 
12396  bool handled = i->aura->CallScriptProcHandlers(aurApp, eventInfo);
12397 
12398  // "handled" is needed as long as proc can be handled in multiple places
12399  if (!handled && HandleAuraProc(target, damage, i->aura, procSpell, procFlag, procExtra, cooldown, &handled))
12400  {
12401  TC_LOG_DEBUG("spells", "ProcDamageAndSpell: casting spell %u (triggered with value by %s aura of spell %u)", spellInfo->Id, (isVictim?"a victim's":"an attacker's"), Id);
12402  takeCharges = true;
12403  }
12404 
12405  if (!handled)
12406  {
12407  for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
12408  {
12409  if (!(i->effMask & (1<<effIndex)))
12410  continue;
12411 
12412  AuraEffect* triggeredByAura = i->aura->GetEffect(effIndex);
12413  ASSERT(triggeredByAura);
12414 
12415  bool prevented = i->aura->CallScriptEffectProcHandlers(triggeredByAura, aurApp, eventInfo);
12416  if (prevented)
12417  {
12418  takeCharges = true;
12419  continue;
12420  }
12421 
12422  switch (triggeredByAura->GetAuraType())
12423  {
12425  {
12426  TC_LOG_DEBUG("spells", "ProcDamageAndSpell: casting spell %u (triggered by %s aura of spell %u)", spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
12427  // Don`t drop charge or add cooldown for not started trigger
12428  if (HandleProcTriggerSpell(target, damage, triggeredByAura, procSpell, procFlag, procExtra, cooldown))
12429  takeCharges = true;
12430  break;
12431  }
12433  {
12434  // target has to be valid
12435  if (!eventInfo.GetProcTarget())
12436  break;
12437 
12438  triggeredByAura->HandleProcTriggerDamageAuraProc(aurApp, eventInfo); // this function is part of the new proc system
12439  takeCharges = true;
12440  break;
12441  }
12443  case SPELL_AURA_DUMMY:
12444  {
12445  TC_LOG_DEBUG("spells", "ProcDamageAndSpell: casting spell id %u (triggered by %s dummy aura of spell %u)", spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
12446  if (HandleDummyAuraProc(target, damage, triggeredByAura, procSpell, procFlag, procExtra, cooldown))
12447  takeCharges = true;
12448  break;
12449  }
12451  {
12452  triggeredByAura->HandleProcTriggerSpellOnPowerAmountAuraProc(aurApp, eventInfo);
12453  takeCharges = true;
12454  break;
12455  }
12462  TC_LOG_DEBUG("spells", "ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", spellInfo->Id, isVictim ? "a victim's" : "an attacker's", triggeredByAura->GetId());
12463  takeCharges = true;
12464  break;
12466  {
12467  TC_LOG_DEBUG("spells", "ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
12468  if (HandleOverrideClassScriptAuraProc(target, damage, triggeredByAura, procSpell, cooldown))
12469  takeCharges = true;
12470  break;
12471  }
12473  {
12474  TC_LOG_DEBUG("spells", "ProcDamageAndSpell: casting mending (triggered by %s dummy aura of spell %u)",
12475  (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
12476 
12477  HandleAuraRaidProcFromChargeWithValue(triggeredByAura);
12478  takeCharges = true;
12479  break;
12480  }
12482  {
12483  TC_LOG_DEBUG("spells", "ProcDamageAndSpell: casting mending (triggered by %s dummy aura of spell %u)",
12484  (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
12485 
12486  HandleAuraRaidProcFromCharge(triggeredByAura);
12487  takeCharges = true;
12488  break;
12489  }
12491  {
12492  TC_LOG_DEBUG("spells", "ProcDamageAndSpell: casting spell %u (triggered with value by %s aura of spell %u)", spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
12493 
12494  if (HandleProcTriggerSpell(target, damage, triggeredByAura, procSpell, procFlag, procExtra, cooldown))
12495  takeCharges = true;
12496  break;
12497  }
12499  // Skip melee hits or instant cast spells
12500  if (procSpell && procSpell->CalcCastTime(getLevel()) > 0)
12501  takeCharges = true;
12502  break;
12504  // Skip Melee hits and spells ws wrong school
12505  if (procSpell && (triggeredByAura->GetMiscValue() & procSpell->SchoolMask)) // School check
12506  takeCharges = true;
12507  break;
12509  // Skip Melee hits and targets with magnet aura
12510  if (procSpell && (triggeredByAura->GetBase()->GetUnitOwner()->ToUnit() == ToUnit())) // Magnet
12511  takeCharges = true;
12512  break;
12515  // Skip melee hits and spells ws wrong school or zero cost
12516  if (procSpell && (triggeredByAura->GetMiscValue() & procSpell->SchoolMask)) // School check
12517  {
12518  std::vector<SpellInfo::CostData> costs = procSpell->CalcPowerCost(this, procSpell->GetSchoolMask());
12519  auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Amount > 0; });
12520  if (m != costs.end())
12521  takeCharges = true;
12522  }
12523  break;
12525  // Compare mechanic
12526  if (procSpell && procSpell->Mechanic == uint32(triggeredByAura->GetMiscValue()))
12527  takeCharges = true;
12528  break;
12530  // Compare mechanic
12531  if (procSpell && procSpell->Mechanic == uint32(triggeredByAura->GetMiscValue()))
12532  takeCharges = true;
12533  break;
12535  // Compare casters
12536  if (triggeredByAura->GetCasterGUID() == target->GetGUID())
12537  takeCharges = true;
12538  break;
12539  // CC Auras which use their amount amount to drop
12540  // Are there any more auras which need this?
12542  case SPELL_AURA_MOD_FEAR:
12543  case SPELL_AURA_MOD_STUN:
12544  case SPELL_AURA_MOD_ROOT:
12545  case SPELL_AURA_TRANSFORM:
12546  {
12547  // chargeable mods are breaking on hit
12548  if (useCharges)
12549  takeCharges = true;
12550  else
12551  {
12552  // Spell own direct damage at apply wont break the CC
12553  if (procSpell && (procSpell->Id == triggeredByAura->GetId()))
12554  {
12555  Aura* aura = triggeredByAura->GetBase();
12556  // called from spellcast, should not have ticked yet
12557  if (aura->GetDuration() == aura->GetMaxDuration())
12558  break;
12559  }
12560  int32 damageLeft = triggeredByAura->GetAmount();
12561  // No damage left
12562  if (damageLeft < int32(damage))
12563  i->aura->Remove();
12564  else
12565  triggeredByAura->SetAmount(damageLeft - damage);
12566  }
12567  break;
12568  }
12569  //case SPELL_AURA_ADD_FLAT_MODIFIER:
12570  //case SPELL_AURA_ADD_PCT_MODIFIER:
12571  // HandleSpellModAuraProc
12572  //break;
12573  default:
12574  // nothing do, just charges counter
12575  takeCharges = true;
12576  break;
12577  } // switch (triggeredByAura->GetAuraType())
12578  i->aura->CallScriptAfterEffectProcHandlers(triggeredByAura, aurApp, eventInfo);
12579  } // for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
12580  } // if (!handled)
12581 
12582  // Remove charge (aura can be removed by triggers)
12583  if (prepare && useCharges && takeCharges)
12584  {
12585  // Set charge drop delay (only for missiles)
12586  if ((procExtra & PROC_EX_REFLECT) && target && procSpell && procSpell->Speed > 0.0f)
12587  {
12588  // Set up missile speed based delay (from Spell.cpp: Spell::AddUnitTarget()::L2237)
12589  uint32 delay = uint32(std::floor(std::max<float>(target->GetDistance(this), 5.0f) / procSpell->Speed * 1000.0f));
12590  // Schedule charge drop
12591  i->aura->DropChargeDelayed(delay);
12592  }
12593  else
12594  i->aura->DropCharge();
12595  }
12596 
12597  i->aura->CallScriptAfterProcHandlers(aurApp, eventInfo);
12598 
12599  if (spellInfo->HasAttribute(SPELL_ATTR3_DISABLE_PROC))
12600  SetCantProc(false);
12601  }
12602 
12603  // Cleanup proc requirements
12605  SetCantProc(false);
12606 }
Definition: SpellMgr.h:200
Definition: SpellAuraEffects.h:30
Definition: SharedDefines.h:170
void ModifyAuraState(AuraStateType flag, bool apply)
Definition: Unit.cpp:7422
void HandleProcTriggerDamageAuraProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuraEffects.cpp:6498
Definition: SpellAuraDefines.h:379
uint32 Id
Definition: SpellInfo.h:329
Definition: SharedDefines.h:490
Definition: SpellMgr.h:205
bool HandleProcTriggerSpell(Unit *victim, uint32 damage, AuraEffect *triggeredByAura, SpellInfo const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
Definition: Unit.cpp:6415
ObjectGuid GetCasterGUID() const
Definition: SpellAuraEffects.h:40
Definition: SpellAuraDefines.h:331
Definition: SpellAuraDefines.h:147
Definition: SpellAuraDefines.h:72
int32 GetMiscValue() const
Definition: SpellAuraEffects.h:53
int32 GetMaxDuration() const
Definition: SpellAuras.h:159
Definition: SpellMgr.h:204
SpellSchoolMask
Definition: SharedDefines.h:285
Definition: SpellAuraDefines.h:285
Definition: SpellInfo.h:326
uint32 GetId() const
Definition: SpellAuraEffects.h:47
Definition: SpellAuraDefines.h:132
Definition: SpellAuraDefines.h:388
static bool isAlwaysTriggeredAura[TOTAL_AURAS]
Definition: Unit.cpp:108
Definition: SharedDefines.h:483
static Vector3int16 floor(const Vector3 &v)
bool HandleDummyAuraProc(Unit *victim, uint32 damage, AuraEffect *triggeredByAura, SpellInfo const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
Definition: Unit.cpp:4966
Definition: SpellAuras.h:50
Definition: SpellAuraDefines.h:67
Unit * GetUnitOwner() const
Definition: SpellAuras.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:1758
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
Definition: SpellAuraDefines.h:133
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Unit.h:955
bool HandleAuraRaidProcFromCharge(AuraEffect *triggeredByAura)
Definition: Unit.cpp:13392
Definition: SpellAuraDefines.h:283
Unit * GetActionTarget() const
Definition: Unit.h:992
Definition: SpellInfo.h:553
Definition: SpellAuraDefines.h:86
Definition: ConditionMgr.h:151
AuraType GetAuraType() const
Definition: SpellAuraEffects.h:54
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
Definition: SpellAuraDefines.h:116
Definition: SpellAuraDefines.h:170
bool IsTriggeredAtSpellProcEvent(Unit *victim, Aura *aura, SpellInfo const *procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const *&spellProcEvent)
Definition: Unit.cpp:13246
Definition: SharedDefines.h:167
std::list< ProcTriggeredData > ProcTriggeredList
Definition: Unit.cpp:12125
Definition: SpellAuraDefines.h:291
bool HandleOverrideClassScriptAuraProc(Unit *victim, uint32 damage, AuraEffect *triggeredByAura, SpellInfo const *procSpell, uint32 cooldown)
Definition: Unit.cpp:6916
AuraEffectVector GetAuraEffects() const
Definition: SpellAuras.h:288
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:984
static bool isTriggerAura[TOTAL_AURAS]
Definition: Unit.cpp:104
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
Definition: SpellAuraDefines.h:172
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
Definition: SharedDefines.h:288
Definition: SpellMgr.h:209
bool HandleAuraRaidProcFromChargeWithValue(AuraEffect *triggeredByAura)
Definition: Unit.cpp:13350
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SpellMgr.h:220
Definition: SpellAuraDefines.h:117
Definition: SpellMgr.h:142
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
Definition: SpellInfo.h:238
Definition: Unit.h:1274
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: Unit.h:1275
#define sConditionMgr
Definition: ConditionMgr.h:307
Definition: SpellMgr.h:203
Definition: SpellMgr.h:223
Definition: SpellAuraDefines.h:137
Definition: SpellMgr.h:210
int32 GetDuration() const
Definition: SpellAuras.h:163
Definition: SpellAuraDefines.h:157
bool HandleAuraProc(Unit *victim, uint32 damage, Aura *triggeredByAura, SpellInfo const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown, bool *handled)
Definition: Unit.cpp:6232
#define MELEE_BASED_TRIGGER_MASK
Definition: SpellMgr.h:187
Unit * GetProcTarget() const
Definition: Unit.h:993
Unit * GetActor()
Definition: Unit.h:991
Definition: SharedDefines.h:1764
Definition: SpellAuraDefines.h:81
Definition: SpellAuraDefines.h:125
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SpellAuraDefines.h:156
static bool isNonTriggerAura[TOTAL_AURAS]
Definition: Unit.cpp:106
Definition: ObjectGuid.h:33
void SetAmount(int32 amount)
Definition: SpellAuraEffects.h:56
Definition: SpellAuraDefines.h:102
void StartReactiveTimer(ReactiveType reactive)
Definition: Unit.h:2134
Definition: SharedDefines.h:169
Definition: SpellMgr.h:224
int32_t int32
Definition: g3dmath.h:167
uint8 getClass() const
Definition: Unit.h:1413
Definition: SpellAuraDefines.h:64
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
Definition: SpellAuraDefines.h:134
void HandleProcTriggerSpellOnPowerAmountAuraProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuraEffects.cpp:6601
void SetCantProc(bool apply)
Definition: Unit.cpp:13079
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:663
Definition: SpellAuraDefines.h:177
Definition: SpellAuras.h:116
Definition: Unit.h:1305
Definition: SpellAuraDefines.h:65
Definition: SpellAuraDefines.h:198
Unit * ToUnit()
Definition: Object.h:197
Definition: Unit.h:1276
Definition: SpellAuraDefines.h:103
Definition: Unit.h:921
Definition: Unit.cpp:12112

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::propagateSpeedChange ( )
inline

-------—End of Pet responses methods-------—

MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void propagateSpeedChange()
Definition: MotionMaster.cpp:649

+ Here is the caller graph for this function:

void Unit::RemoveAllAttackers ( )
7410 {
7411  while (!m_attackers.empty())
7412  {
7413  AttackerSet::iterator iter = m_attackers.begin();
7414  if (!(*iter)->AttackStop())
7415  {
7416  TC_LOG_ERROR("entities.unit", "WORLD: Unit has an attacker that isn't attacking it!");
7417  m_attackers.erase(iter);
7418  }
7419  }
7420 }
AttackerSet m_attackers
Definition: Unit.h:2255
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the caller graph for this function:

void Unit::RemoveAllAuras ( )
3921 {
3922  // this may be a dead loop if some events on aura remove will continiously apply aura on remove
3923  // we want to have all auras removed, so use your brain when linking events
3924  while (!m_appliedAuras.empty() || !m_ownedAuras.empty())
3925  {
3926  AuraApplicationMap::iterator aurAppIter;
3927  for (aurAppIter = m_appliedAuras.begin(); aurAppIter != m_appliedAuras.end();)
3928  _UnapplyAura(aurAppIter, AURA_REMOVE_BY_DEFAULT);
3929 
3930  AuraMap::iterator aurIter;
3931  for (aurIter = m_ownedAuras.begin(); aurIter != m_ownedAuras.end();)
3932  RemoveOwnedAura(aurIter);
3933  }
3934 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
Definition: Unit.h:451
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:3217

+ Here is the call graph for this function:

void Unit::RemoveAllAurasExceptType ( AuraType  type)
3998 {
3999  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
4000  {
4001  Aura const* aura = iter->second->GetBase();
4002  if (aura->GetSpellInfo()->HasAura(GetMap()->GetDifficultyID(), type))
4003  ++iter;
4004  else
4006  }
4007 
4008  for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
4009  {
4010  Aura* aura = iter->second;
4011  if (aura->GetSpellInfo()->HasAura(GetMap()->GetDifficultyID(), type))
4012  ++iter;
4013  else
4015  }
4016 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
AuraMap m_ownedAuras
Definition: Unit.h:2273
Map * GetMap() const
Definition: Object.h:543
bool HasAura(uint32 difficulty, AuraType aura) const
Definition: SpellInfo.cpp:1193
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
Definition: SpellAuras.h:116
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
Definition: Unit.h:451
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:3217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAllAurasExceptType ( AuraType  type1,
AuraType  type2 
)
4019 {
4020  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
4021  {
4022  Aura const* aura = iter->second->GetBase();
4023  if (aura->GetSpellInfo()->HasAura(GetMap()->GetDifficultyID(), type1) || aura->GetSpellInfo()->HasAura(GetMap()->GetDifficultyID(), type2))
4024  ++iter;
4025  else
4027  }
4028 
4029  for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
4030  {
4031  Aura* aura = iter->second;
4032  if (aura->GetSpellInfo()->HasAura(GetMap()->GetDifficultyID(), type1) || aura->GetSpellInfo()->HasAura(GetMap()->GetDifficultyID(), type2))
4033  ++iter;
4034  else
4036  }
4037 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
AuraMap m_ownedAuras
Definition: Unit.h:2273
Map * GetMap() const
Definition: Object.h:543
bool HasAura(uint32 difficulty, AuraType aura) const
Definition: SpellInfo.cpp:1193
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
Definition: SpellAuras.h:116
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
Definition: Unit.h:451
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:3217

+ Here is the call graph for this function:

void Unit::RemoveAllAurasOnDeath ( )
3954 {
3955  // used just after dieing to remove all visible auras
3956  // and disable the mods for the passive ones
3957  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
3958  {
3959  Aura const* aura = iter->second->GetBase();
3960  if (!aura->IsPassive() && !aura->IsDeathPersistent())
3962  else
3963  ++iter;
3964  }
3965 
3966  for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
3967  {
3968  Aura* aura = iter->second;
3969  if (!aura->IsPassive() && !aura->IsDeathPersistent())
3971  else
3972  ++iter;
3973  }
3974 }
bool IsPassive() const
Definition: SpellAuras.cpp:1026
bool IsDeathPersistent() const
Definition: SpellAuras.cpp:1031
AuraMap m_ownedAuras
Definition: Unit.h:2273
Definition: Unit.h:455
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
Definition: SpellAuras.h:116
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:3217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAllAurasRequiringDeadTarget ( )
3977 {
3978  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
3979  {
3980  Aura const* aura = iter->second->GetBase();
3981  if (!aura->IsPassive() && aura->GetSpellInfo()->IsRequiringDeadTarget())
3983  else
3984  ++iter;
3985  }
3986 
3987  for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
3988  {
3989  Aura* aura = iter->second;
3990  if (!aura->IsPassive() && aura->GetSpellInfo()->IsRequiringDeadTarget())
3992  else
3993  ++iter;
3994  }
3995 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool IsPassive() const
Definition: SpellAuras.cpp:1026
AuraMap m_ownedAuras
Definition: Unit.h:2273
bool IsRequiringDeadTarget() const
Definition: SpellInfo.cpp:1480
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
Definition: SpellAuras.h:116
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
Definition: Unit.h:451
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:3217

+ Here is the call graph for this function:

void Unit::RemoveAllControlled ( )
7999 {
8000  // possessed pet and vehicle
8001  if (GetTypeId() == TYPEID_PLAYER)
8002  ToPlayer()->StopCastingCharm();
8003 
8004  while (!m_Controlled.empty())
8005  {
8006  Unit* target = *m_Controlled.begin();
8007  m_Controlled.erase(m_Controlled.begin());
8008  if (target->GetCharmerGUID() == GetGUID())
8009  target->RemoveCharmAuras();
8010  else if (target->GetOwnerGUID() == GetGUID() && target->IsSummon())
8011  target->ToTempSummon()->UnSummon();
8012  else
8013  TC_LOG_ERROR("entities.unit", "Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
8014  }
8015  if (!GetPetGUID().IsEmpty())
8016  TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its pet %s", GetEntry(), GetPetGUID().ToString().c_str());
8017  if (!GetMinionGUID().IsEmpty())
8018  TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its minion %s", GetEntry(), GetMinionGUID().ToString().c_str());
8019  if (!GetCharmGUID().IsEmpty())
8020  TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its charm %s", GetEntry(), GetCharmGUID().ToString().c_str());
8021 }
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1706
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
ObjectGuid GetMinionGUID() const
Definition: Unit.h:1702
ObjectGuid GetPetGUID() const
Definition: Unit.h:1708
Player * ToPlayer()
Definition: Object.h:191
TempSummon * ToTempSummon()
Definition: Unit.h:2206
virtual void UnSummon(uint32 msTime=0)
Definition: TemporarySummon.cpp:237
TypeID GetTypeId() const
Definition: Object.h:113
ControlList m_Controlled
Definition: Unit.h:1738
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void RemoveCharmAuras()
Definition: Unit.cpp:8119
Definition: ObjectGuid.h:33
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:210
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
bool IsSummon() const
Definition: Unit.h:1401
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAllDynObjects ( )
4733 {
4734  while (!m_dynObj.empty())
4735  m_dynObj.front()->Remove();
4736 }
DynObjectList m_dynObj
Definition: Unit.h:2264

+ Here is the caller graph for this function:

void Unit::RemoveAllGameObjects ( )
4827 {
4828  // remove references to unit
4829  while (!m_gameObj.empty())
4830  {
4831  GameObjectList::iterator i = m_gameObj.begin();
4832  (*i)->SetOwnerGUID(ObjectGuid::Empty);
4833  (*i)->SetRespawnTime(0);
4834  (*i)->Delete();
4835  m_gameObj.erase(i);
4836  }
4837 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
GameObjectList m_gameObj
Definition: Unit.h:2267

+ Here is the caller graph for this function:

void Unit::RemoveAllMinionsByEntry ( uint32  entry)
7803 {
7804  for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();)
7805  {
7806  Unit* unit = *itr;
7807  ++itr;
7808  if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
7809  && unit->ToCreature()->IsSummon()) // minion, actually
7810  unit->ToTempSummon()->UnSummon();
7811  // i think this is safe because i have never heard that a despawned minion will trigger a same minion
7812  }
7813 }
Definition: ObjectGuid.h:32
TempSummon * ToTempSummon()
Definition: Unit.h:2206
virtual void UnSummon(uint32 msTime=0)
Definition: TemporarySummon.cpp:237
TypeID GetTypeId() const
Definition: Object.h:113
ControlList m_Controlled
Definition: Unit.h:1738
Creature * ToCreature()
Definition: Object.h:194
uint32 GetEntry() const
Definition: Object.h:107
bool IsSummon() const
Definition: Unit.h:1401
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAppliedAuras ( std::function< bool(AuraApplication const *)> const check)
3516 {
3517  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
3518  {
3519  if (check(iter->second))
3520  {
3521  RemoveAura(iter);
3522  continue;
3523  }
3524  ++iter;
3525  }
3526 }
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
T check(T value)
Definition: format.h:305
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

void Unit::RemoveAppliedAuras ( uint32  spellId,
std::function< bool(AuraApplication const *)> const check 
)
3542 {
3543  for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);)
3544  {
3545  if (check(iter->second))
3546  {
3547  RemoveAura(iter);
3548  continue;
3549  }
3550  ++iter;
3551  }
3552 }
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
T check(T value)
Definition: format.h:305
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

void Unit::RemoveAreaAurasDueToLeaveWorld ( )
3888 {
3889  // make sure that all area auras not applied on self are removed - prevent access to deleted pointer later
3890  for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
3891  {
3892  Aura* aura = iter->second;
3893  ++iter;
3894  Aura::ApplicationMap const& appMap = aura->GetApplicationMap();
3895  for (Aura::ApplicationMap::const_iterator itr = appMap.begin(); itr!= appMap.end();)
3896  {
3897  AuraApplication * aurApp = itr->second;
3898  ++itr;
3899  Unit* target = aurApp->GetTarget();
3900  if (target == this)
3901  continue;
3902  target->RemoveAura(aurApp);
3903  // things linked on aura remove may apply new area aura - so start from the beginning
3904  iter = m_ownedAuras.begin();
3905  }
3906  }
3907 
3908  // remove area auras owned by others
3909  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
3910  {
3911  if (iter->second->GetBase()->GetOwner() != this)
3912  {
3913  RemoveAura(iter);
3914  }
3915  else
3916  ++iter;
3917  }
3918 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
Unit * GetTarget() const
Definition: SpellAuras.h:74
Definition: SpellAuras.h:50
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
ApplicationMap const & GetApplicationMap()
Definition: SpellAuras.h:231
std::map< ObjectGuid, AuraApplication * > ApplicationMap
Definition: SpellAuras.h:120
Definition: SpellAuras.h:116
Definition: Unit.h:1305
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveArenaAuras ( )
3937 {
3938  // in join, remove positive buffs, on end, remove negative
3939  // used to remove positive visible auras in arenas
3940  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
3941  {
3942  AuraApplication const* aurApp = iter->second;
3943  Aura const* aura = aurApp->GetBase();
3944  if (!(aura->GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_UNK21) // don't remove stances, shadowform, pally/hunter auras
3945  && !aura->IsPassive() // don't remove passive auras
3946  && (aurApp->IsPositive() || !(aura->GetSpellInfo()->AttributesEx3 & SPELL_ATTR3_DEATH_PERSISTENT))) // not negative death persistent auras
3947  RemoveAura(iter);
3948  else
3949  ++iter;
3950  }
3951 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool IsPassive() const
Definition: SpellAuras.cpp:1026
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
uint32 AttributesEx3
Definition: SpellInfo.h:336
bool IsPositive() const
Definition: SpellAuras.h:81
Definition: SharedDefines.h:521
Definition: SharedDefines.h:484
Definition: SpellAuras.h:116
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
uint32 AttributesEx4
Definition: SpellInfo.h:337

+ Here is the call graph for this function:

void Unit::RemoveAura ( AuraApplicationMap::iterator &  i,
AuraRemoveMode  mode = AURA_REMOVE_BY_DEFAULT 
)
3443 {
3444  AuraApplication * aurApp = i->second;
3445  // Do not remove aura which is already being removed
3446  if (aurApp->GetRemoveMode())
3447  return;
3448  Aura* aura = aurApp->GetBase();
3449  _UnapplyAura(i, mode);
3450  // Remove aura - for Area and Target auras
3451  if (aura->GetOwner() == this)
3452  aura->Remove(mode);
3453 }
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
WorldObject * GetOwner() const
Definition: SpellAuras.h:137
Definition: SpellAuras.h:116
AuraRemoveMode GetRemoveMode() const
Definition: SpellAuras.h:86
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:3217

+ Here is the call graph for this function:

void Unit::RemoveAura ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)
3456 {
3457  AuraApplicationMapBoundsNonConst range = m_appliedAuras.equal_range(spellId);
3458  for (AuraApplicationMap::iterator iter = range.first; iter != range.second;)
3459  {
3460  Aura const* aura = iter->second->GetBase();
3461  if (((aura->GetEffectMask() & reqEffMask) == reqEffMask)
3462  && (!caster || aura->GetCasterGUID() == caster))
3463  {
3464  RemoveAura(iter, removeMode);
3465  return;
3466  }
3467  else
3468  ++iter;
3469  }
3470 }
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
std::pair< AuraApplicationMap::iterator, AuraApplicationMap::iterator > AuraApplicationMapBoundsNonConst
Definition: Unit.h:1317
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
uint32 GetEffectMask() const
Definition: SpellAuras.cpp:1213

+ Here is the call graph for this function:

void Unit::RemoveAura ( AuraApplication aurApp,
AuraRemoveMode  mode = AURA_REMOVE_BY_DEFAULT 
)
3473 {
3474  // we've special situation here, RemoveAura called while during aura removal
3475  // this kind of call is needed only when aura effect removal handler
3476  // or event triggered by it expects to remove
3477  // not yet removed effects of an aura
3478  if (aurApp->GetRemoveMode())
3479  {
3480  // remove remaining effects of an aura
3481  for (uint8 itr = 0; itr < MAX_SPELL_EFFECTS; ++itr)
3482  {
3483  if (aurApp->HasEffect(itr))
3484  aurApp->_HandleEffect(itr, false);
3485  }
3486  return;
3487  }
3488  // no need to remove
3489  if (aurApp->GetBase()->GetApplicationOfTarget(GetGUID()) != aurApp || aurApp->GetBase()->IsRemoved())
3490  return;
3491 
3492  uint32 spellId = aurApp->GetBase()->GetId();
3493  AuraApplicationMapBoundsNonConst range = m_appliedAuras.equal_range(spellId);
3494 
3495  for (AuraApplicationMap::iterator iter = range.first; iter != range.second;)
3496  {
3497  if (aurApp == iter->second)
3498  {
3499  RemoveAura(iter, mode);
3500  return;
3501  }
3502  else
3503  ++iter;
3504  }
3505 }
Aura * GetBase() const
Definition: SpellAuras.h:75
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
void _HandleEffect(uint8 effIndex, bool apply)
Definition: SpellAuras.cpp:161
bool HasEffect(uint8 effect) const
Definition: SpellAuras.h:80
bool IsRemoved() const
Definition: SpellAuras.h:201
uint32_t uint32
Definition: Define.h:150
std::pair< AuraApplicationMap::iterator, AuraApplicationMap::iterator > AuraApplicationMapBoundsNonConst
Definition: Unit.h:1317
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint8_t uint8
Definition: Define.h:152
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
AuraRemoveMode GetRemoveMode() const
Definition: SpellAuras.h:86
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
uint32 GetId() const
Definition: SpellAuras.h:131

+ Here is the call graph for this function:

void Unit::RemoveAura ( Aura aur,
AuraRemoveMode  mode = AURA_REMOVE_BY_DEFAULT 
)
3508 {
3509  if (aura->IsRemoved())
3510  return;
3511  if (AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID()))
3512  RemoveAura(aurApp, mode);
3513 }
Definition: SpellAuras.h:50
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
ObjectGuid const & GetGUID() const
Definition: Object.h:105

+ Here is the call graph for this function:

void Unit::RemoveAuraFromStack ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)
3603 {
3604  AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId);
3605  for (AuraMap::iterator iter = range.first; iter != range.second;)
3606  {
3607  Aura* aura = iter->second;
3608  if ((aura->GetType() == UNIT_AURA_TYPE)
3609  && (!casterGUID || aura->GetCasterGUID() == casterGUID))
3610  {
3611  aura->ModStackAmount(-1, removeMode);
3612  return;
3613  }
3614  else
3615  ++iter;
3616  }
3617 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
std::pair< AuraMap::iterator, AuraMap::iterator > AuraMapBoundsNonConst
Definition: Unit.h:1313
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:956
Definition: SpellAuraDefines.h:548
AuraObjectType GetType() const
Definition: SpellAuras.cpp:456
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAurasByType ( AuraType  auraType,
std::function< bool(AuraApplication const *)> const check 
)
3568 {
3569  for (AuraEffectList::iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();)
3570  {
3571  Aura* aura = (*iter)->GetBase();
3572  AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID());
3573  ASSERT(aurApp);
3574 
3575  ++iter;
3576  if (check(aurApp))
3577  {
3578  uint32 removedAuras = m_removedAurasCount;
3579  RemoveAura(aurApp);
3580  if (m_removedAurasCount > removedAuras + 1)
3581  iter = m_modAuras[auraType].begin();
3582  }
3583  }
3584 }
uint32 m_removedAurasCount
Definition: Unit.h:2277
AuraEffectList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2279
Definition: SpellAuras.h:50
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
uint32_t uint32
Definition: Define.h:150
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
T check(T value)
Definition: format.h:305
Definition: SpellAuras.h:116

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAurasByType ( AuraType  auraType,
ObjectGuid  casterGUID = ObjectGuid::Empty,
Aura except = NULL,
bool  negative = true,
bool  positive = true 
)
3738 {
3739  for (AuraEffectList::iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();)
3740  {
3741  Aura* aura = (*iter)->GetBase();
3742  AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID());
3743  ASSERT(aurApp);
3744 
3745  ++iter;
3746  if (aura != except && (!casterGUID || aura->GetCasterGUID() == casterGUID)
3747  && ((negative && !aurApp->IsPositive()) || (positive && aurApp->IsPositive())))
3748  {
3749  uint32 removedAuras = m_removedAurasCount;
3750  RemoveAura(aurApp);
3751  if (m_removedAurasCount > removedAuras + 1)
3752  iter = m_modAuras[auraType].begin();
3753  }
3754  }
3755 }
uint32 m_removedAurasCount
Definition: Unit.h:2277
AuraEffectList m_modAuras[TOTAL_AURAS]
Definition: Unit.h:2279
Definition: SpellAuras.h:50
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
bool IsPositive() const
Definition: SpellAuras.h:81
uint32_t uint32
Definition: Define.h:150
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135

+ Here is the call graph for this function:

void Unit::RemoveAurasDueToItemSpell ( uint32  spellId,
ObjectGuid  castItemGuid 
)
3724 {
3725  for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);)
3726  {
3727  if (iter->second->GetBase()->GetCastItemGUID() == castItemGuid)
3728  {
3729  RemoveAura(iter);
3730  iter = m_appliedAuras.lower_bound(spellId);
3731  }
3732  else
3733  ++iter;
3734  }
3735 }
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

void Unit::RemoveAurasDueToSpell ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)
3587 {
3588  for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);)
3589  {
3590  Aura const* aura = iter->second->GetBase();
3591  if (((aura->GetEffectMask() & reqEffMask) == reqEffMask)
3592  && (!casterGUID || aura->GetCasterGUID() == casterGUID))
3593  {
3594  RemoveAura(iter, removeMode);
3595  iter = m_appliedAuras.lower_bound(spellId);
3596  }
3597  else
3598  ++iter;
3599  }
3600 }
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
uint32 GetEffectMask() const
Definition: SpellAuras.cpp:1213

+ Here is the call graph for this function:

void Unit::RemoveAurasDueToSpellByDispel ( uint32  spellId,
uint32  dispellerSpellId,
ObjectGuid  casterGUID,
Unit dispeller,
uint8  chargesRemoved = 1 
)
3620 {
3621  AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId);
3622  for (AuraMap::iterator iter = range.first; iter != range.second;)
3623  {
3624  Aura* aura = iter->second;
3625  if (aura->GetCasterGUID() == casterGUID)
3626  {
3627  DispelInfo dispelInfo(dispeller, dispellerSpellId, chargesRemoved);
3628 
3629  // Call OnDispel hook on AuraScript
3630  aura->CallScriptDispel(&dispelInfo);
3631 
3633  aura->ModCharges(-dispelInfo.GetRemovedCharges(), AURA_REMOVE_BY_ENEMY_SPELL);
3634  else
3635  aura->ModStackAmount(-dispelInfo.GetRemovedCharges(), AURA_REMOVE_BY_ENEMY_SPELL);
3636 
3637  // Call AfterDispel hook on AuraScript
3638  aura->CallScriptAfterDispel(&dispelInfo);
3639 
3640  return;
3641  }
3642  else
3643  ++iter;
3644  }
3645 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
AuraMap m_ownedAuras
Definition: Unit.h:2273
std::pair< AuraMap::iterator, AuraMap::iterator > AuraMapBoundsNonConst
Definition: Unit.h:1313
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:956
uint32 AttributesEx7
Definition: SpellInfo.h:340
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:887
Definition: Unit.h:453
Definition: Unit.h:888
void CallScriptAfterDispel(DispelInfo *dispelInfo)
Definition: SpellAuras.cpp:1992
void CallScriptDispel(DispelInfo *dispelInfo)
Definition: SpellAuras.cpp:1979
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
Definition: SharedDefines.h:618

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAurasDueToSpellBySteal ( uint32  spellId,
ObjectGuid  casterGUID,
Unit stealer 
)
3648 {
3649  AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId);
3650  for (AuraMap::iterator iter = range.first; iter != range.second;)
3651  {
3652  Aura* aura = iter->second;
3653  if (aura->GetCasterGUID() == casterGUID)
3654  {
3655  int32 damage[MAX_SPELL_EFFECTS];
3656  int32 baseDamage[MAX_SPELL_EFFECTS];
3657  uint8 effMask = 0;
3658  uint8 recalculateMask = 0;
3659  Unit* caster = aura->GetCaster();
3660  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3661  {
3662  if (aura->GetEffect(i))
3663  {
3664  baseDamage[i] = aura->GetEffect(i)->GetBaseAmount();
3665  damage[i] = aura->GetEffect(i)->GetAmount();
3666  effMask |= (1<<i);
3667  if (aura->GetEffect(i)->CanBeRecalculated())
3668  recalculateMask |= (1<<i);
3669  }
3670  else
3671  {
3672  baseDamage[i] = 0;
3673  damage[i] = 0;
3674  }
3675  }
3676 
3677  bool stealCharge = (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) != 0;
3678  // Cast duration to unsigned to prevent permanent aura's such as Righteous Fury being permanently added to caster
3679  uint32 dur = std::min(2u * MINUTE * IN_MILLISECONDS, uint32(aura->GetDuration()));
3680 
3681  if (Aura* oldAura = stealer->GetAura(aura->GetId(), aura->GetCasterGUID()))
3682  {
3683  if (stealCharge)
3684  oldAura->ModCharges(1);
3685  else
3686  oldAura->ModStackAmount(1);
3687  oldAura->SetDuration(int32(dur));
3688  }
3689  else
3690  {
3691  // single target state must be removed before aura creation to preserve existing single target aura
3692  if (aura->IsSingleTarget())
3693  aura->UnregisterSingleTarget();
3694 
3695  if (Aura* newAura = Aura::TryRefreshStackOrCreate(aura->GetSpellInfo(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID()))
3696  {
3697  // created aura must not be single target aura,, so stealer won't loose it on recast
3698  if (newAura->IsSingleTarget())
3699  {
3700  newAura->UnregisterSingleTarget();
3701  // bring back single target aura status to the old aura
3702  aura->SetIsSingleTarget(true);
3703  caster->GetSingleCastAuras().push_back(aura);
3704  }
3705  // FIXME: using aura->GetMaxDuration() maybe not blizzlike but it fixes stealing of spells like Innervate
3706  newAura->SetLoadedState(aura->GetMaxDuration(), int32(dur), stealCharge ? 1 : aura->GetCharges(), 1, recalculateMask, &damage[0]);
3707  newAura->ApplyForTargets();
3708  }
3709  }
3710 
3711  if (stealCharge)
3713  else
3715 
3716  return;
3717  }
3718  else
3719  ++iter;
3720  }
3721 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool CanBeRecalculated() const
Definition: SpellAuraEffects.h:67
AuraMap m_ownedAuras
Definition: Unit.h:2273
Unit * GetCaster() const
Definition: SpellAuras.cpp:438
int32 GetMaxDuration() const
Definition: SpellAuras.h:159
void SetIsSingleTarget(bool val)
Definition: SpellAuras.h:206
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4151
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsSingleTarget() const
Definition: SpellAuras.h:204
std::pair< AuraMap::iterator, AuraMap::iterator > AuraMapBoundsNonConst
Definition: Unit.h:1313
Definition: Common.h:97
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:956
uint32 AttributesEx7
Definition: SpellInfo.h:340
int32 GetBaseAmount() const
Definition: SpellAuraEffects.h:49
T min(const T &x, const T &y)
Definition: g3dmath.h:305
AuraEffect * GetEffect(uint32 index) const
Definition: SpellAuras.cpp:448
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
AuraList & GetSingleCastAuras()
Definition: Unit.h:1833
int32 GetDuration() const
Definition: SpellAuras.h:163
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:887
void UnregisterSingleTarget()
Definition: SpellAuras.cpp:1115
static Aura * TryRefreshStackOrCreate(SpellInfo const *spellproto, uint32 tryEffMask, WorldObject *owner, Unit *caster, int32 *baseAmount=NULL, Item *castItem=NULL, ObjectGuid casterGUID=ObjectGuid::Empty, bool *refresh=NULL, int32 castItemLevel=-1)
Definition: SpellAuras.cpp:282
Definition: Unit.h:453
Definition: Common.h:103
int32_t int32
Definition: g3dmath.h:167
uint8 GetCharges() const
Definition: SpellAuras.h:170
uint8_t uint8
Definition: Define.h:152
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
Definition: Unit.h:1305
uint32 GetId() const
Definition: SpellAuras.h:131
Definition: SharedDefines.h:618

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAurasWithAttribute ( uint32  flags)
3758 {
3759  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
3760  {
3761  SpellInfo const* spell = iter->second->GetBase()->GetSpellInfo();
3762  if (spell->Attributes & flags)
3763  RemoveAura(iter);
3764  else
3765  ++iter;
3766  }
3767 }
Definition: SpellInfo.h:326
uint32 Attributes
Definition: SpellInfo.h:333
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
uint8 flags
Definition: DisableMgr.cpp:44
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

void Unit::RemoveAurasWithFamily ( SpellFamilyNames  family,
flag128 const familyFlag,
ObjectGuid  casterGUID 
)
3848 {
3849  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
3850  {
3851  Aura const* aura = iter->second->GetBase();
3852  if (!casterGUID || aura->GetCasterGUID() == casterGUID)
3853  {
3854  SpellInfo const* spell = aura->GetSpellInfo();
3855  if (spell->SpellFamilyName == uint32(family) && spell->SpellFamilyFlags & familyFlag)
3856  {
3857  RemoveAura(iter);
3858  continue;
3859  }
3860  }
3861  ++iter;
3862  }
3863 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
Definition: SpellInfo.h:326
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
uint32 SpellFamilyName
Definition: SpellInfo.h:396
uint32_t uint32
Definition: Define.h:150
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAurasWithInterruptFlags ( uint32  flag,
uint32  except = 0 
)
3817 {
3818  if (!(m_interruptMask & flag))
3819  return;
3820 
3821  // interrupt auras
3822  for (AuraApplicationList::iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end();)
3823  {
3824  Aura* aura = (*iter)->GetBase();
3825  ++iter;
3826  if ((aura->GetSpellInfo()->AuraInterruptFlags & flag) && (!except || aura->GetId() != except)
3828  {
3829  uint32 removedAuras = m_removedAurasCount;
3830  RemoveAura(aura);
3831  if (m_removedAurasCount > removedAuras + 1)
3832  iter = m_interruptableAuras.begin();
3833  }
3834  }
3835 
3836  // interrupt channeled spell
3838  if (spell->getState() == SPELL_STATE_CASTING
3839  && (spell->m_spellInfo->ChannelInterruptFlags & flag)
3840  && spell->m_spellInfo->Id != except
3842  InterruptNonMeleeSpells(false);
3843 
3845 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
uint32 m_removedAurasCount
Definition: Unit.h:2277
Definition: Unit.h:57
void UpdateInterruptMask()
Definition: Unit.cpp:557
Definition: Unit.h:1110
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
uint32 AuraInterruptFlags
Definition: SpellInfo.h:368
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition: Unit.cpp:4270
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
AuraApplicationList m_interruptableAuras
Definition: Unit.h:2281
uint32_t uint32
Definition: Define.h:150
Definition: Spell.h:278
Definition: SpellAuraDefines.h:390
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
uint32 m_interruptMask
Definition: Unit.h:2283
Definition: SpellAuras.h:116
uint32 GetId() const
Definition: SpellAuras.h:131
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveAurasWithMechanic ( uint32  mechanic_mask,
AuraRemoveMode  removemode = AURA_REMOVE_BY_DEFAULT,
uint32  except = 0 
)
3871 {
3872  for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
3873  {
3874  Aura const* aura = iter->second->GetBase();
3875  if (!except || aura->GetId() != except)
3876  {
3877  if (aura->GetSpellInfo()->GetAllEffectsMechanicMask() & mechanic_mask)
3878  {
3879  RemoveAura(iter, removemode);
3880  continue;
3881  }
3882  }
3883  ++iter;
3884  }
3885 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
uint32 GetAllEffectsMechanicMask() const
Definition: SpellInfo.cpp:2136
Definition: SpellAuras.h:116
AuraApplicationMap m_appliedAuras
Definition: Unit.h:2274
uint32 GetId() const
Definition: SpellAuras.h:131

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveBindSightAuras ( )
8115 {
8117 }
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
Definition: SpellAuraDefines.h:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveCharmAuras ( )
8120 {
8125 }
Definition: SpellAuraDefines.h:188
Definition: SpellAuraDefines.h:66
Definition: SpellAuraDefines.h:62
Definition: SpellAuraDefines.h:237
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveCharmedBy ( Unit charmer)
Todo:
CombatStop(true) may cause crash (interrupt spells)
14173 {
14174  if (!IsCharmed())
14175  return;
14176 
14177  if (!charmer)
14178  charmer = GetCharmer();
14179  if (charmer != GetCharmer()) // one aura overrides another?
14180  {
14181 // TC_LOG_FATAL("entities.unit", "Unit::RemoveCharmedBy: this: " UI64FMTD " true charmer: " UI64FMTD " false charmer: " UI64FMTD,
14182 // GetGUID(), GetCharmerGUID(), charmer->GetGUID());
14183 // ABORT();
14184  return;
14185  }
14186 
14187  CharmType type;
14189  type = CHARM_TYPE_POSSESS;
14190  else if (charmer && charmer->IsOnVehicle(this))
14191  type = CHARM_TYPE_VEHICLE;
14192  else
14193  type = CHARM_TYPE_CHARM;
14194 
14195  CastStop();
14196  CombatStop();
14198  DeleteThreatList();
14199 
14200  if (_oldFactionId)
14201  {
14203  _oldFactionId = 0;
14204  }
14205  else
14206  RestoreFaction();
14207 
14209 
14210  if (Creature* creature = ToCreature())
14211  {
14212  // Creature will restore its old AI on next update
14213  if (creature->AI())
14214  creature->AI()->OnCharmed(false);
14215 
14216  // Vehicle should not attack its passenger after he exists the seat
14217  if (type != CHARM_TYPE_VEHICLE)
14218  LastCharmerGUID = ASSERT_NOTNULL(charmer)->GetGUID();
14219  }
14220 
14221  // If charmer still exists
14222  if (!charmer)
14223  return;
14224 
14225  ASSERT(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER);
14226  ASSERT(type != CHARM_TYPE_VEHICLE || (GetTypeId() == TYPEID_UNIT && IsVehicle()));
14227 
14228  charmer->SetCharm(this, false);
14229 
14230  Player* playerCharmer = charmer->ToPlayer();
14231 
14232  if (playerCharmer)
14233  {
14234  switch (type)
14235  {
14236  case CHARM_TYPE_VEHICLE:
14237  playerCharmer->SetClientControl(this, false);
14238  playerCharmer->SetClientControl(charmer, true);
14240  break;
14241  case CHARM_TYPE_POSSESS:
14242  playerCharmer->SetClientControl(this, false);
14243  playerCharmer->SetClientControl(charmer, true);
14247  break;
14248  case CHARM_TYPE_CHARM:
14249  if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
14250  {
14251  CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate();
14252  if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
14253  {
14255  if (GetCharmInfo())
14256  GetCharmInfo()->SetPetNumber(0, true);
14257  else
14258  TC_LOG_ERROR("entities.unit", "Aura::HandleModCharm: %s has a charm aura but no charm info!", GetGUID().ToString().c_str());
14259  }
14260  }
14261  break;
14262  case CHARM_TYPE_CONVERT:
14263  break;
14264  }
14265  }
14266 
14267  if (Player* player = ToPlayer())
14268  player->SetClientControl(this, true);
14269 
14270  // a guardian should always have charminfo
14271  if (playerCharmer && this != charmer->GetFirstControlled())
14272  playerCharmer->SendRemoveControlBar();
14273  else if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && !IsGuardian()))
14274  DeleteCharmInfo();
14275 }
Unit * GetCharmer() const
Definition: Unit.cpp:7551
bool IsOnVehicle(const Unit *vehicle) const
Definition: Unit.cpp:14336
T * ASSERT_NOTNULL(T *pointer)
Definition: Errors.h:58
void SetPetNumber(uint32 petnumber, bool statwindow)
Definition: Unit.cpp:12048
bool IsVehicle() const
Definition: Unit.h:1406
Definition: UpdateFields.h:96
Definition: SharedDefines.h:3556
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
Definition: ObjectGuid.h:32
Definition: Unit.h:1185
Definition: Unit.h:675
Definition: Creature.h:467
void CastStop(uint32 except_spellid=0)
Definition: Unit.cpp:862
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
Unit * GetFirstControlled() const
Definition: Unit.cpp:7984
Definition: Unit.h:233
uint32 _oldFactionId
faction before charm
Definition: Unit.h:2355
Player * ToPlayer()
Definition: Object.h:191
void InitDefault()
Definition: MotionMaster.cpp:54
void setFaction(uint32 faction)
Definition: Unit.h:1467
CharmType
Definition: Unit.h:1181
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
bool IsGuardian() const
Definition: Unit.h:1402
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
void RestoreFaction()
Definition: Unit.cpp:14277
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080
std::string ToString() const
Definition: Position.cpp:160
Definition: Unit.h:566
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
Definition: Unit.h:1183
void DeleteCharmInfo()
Definition: Unit.cpp:11844
uint8_t uint8
Definition: g3dmath.h:164
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: Unit.h:1184
void DeleteThreatList()
Definition: Unit.cpp:10700
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:1186
uint8 getClass() const
Definition: Unit.h:1413
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
#define ASSERT
Definition: Errors.h:55
void deleteReferences()
Definition: HostileRefManager.cpp:114
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SharedDefines.h:175
Definition: Unit.h:697
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
uint32 unit_class
Definition: Creature.h:108
Definition: Creature.h:79
uint32 type
Definition: Creature.h:116
bool IsCharmed() const
Definition: Unit.h:1742
ObjectGuid LastCharmerGUID
Definition: Unit.h:2162
void SetCharm(Unit *target, bool apply)
Definition: Unit.cpp:7815

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveDynObject ( uint32  spellId)
4716 {
4717  if (m_dynObj.empty())
4718  return;
4719  for (DynObjectList::iterator i = m_dynObj.begin(); i != m_dynObj.end();)
4720  {
4721  DynamicObject* dynObj = *i;
4722  if (dynObj->GetSpellId() == spellId)
4723  {
4724  dynObj->Remove();
4725  i = m_dynObj.begin();
4726  }
4727  else
4728  ++i;
4729  }
4730 }
uint32 GetSpellId() const
Definition: DynamicObject.h:57
Definition: DynamicObject.h:35
void Remove()
Definition: DynamicObject.cpp:161
DynObjectList m_dynObj
Definition: Unit.h:2264

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveExtraUnitMovementFlag ( uint16  f)
inline
MovementInfo m_movementInfo
Definition: Object.h:612
void RemoveExtraMovementFlag(uint16 flag)
Definition: Object.h:335
void Unit::removeFollower ( FollowerReference )
inline
2099 { /* nothing to do yet */ }

+ Here is the caller graph for this function:

void Unit::RemoveFromWorld ( )
overridevirtual

Reimplemented from WorldObject.

11734 {
11735  // cleanup
11736  ASSERT(GetGUID());
11737 
11738  if (IsInWorld())
11739  {
11740  m_duringRemoveFromWorld = true;
11741  if (IsVehicle())
11742  RemoveVehicleKit(true);
11743 
11744  RemoveCharmAuras();
11747 
11750 
11751  ExitVehicle(); // Remove applied auras with SPELL_AURA_CONTROL_VEHICLE
11754 
11756 
11757  if (!GetCharmerGUID().IsEmpty())
11758  {
11759  TC_LOG_FATAL("entities.unit", "Unit %u has charmer guid when removed from world", GetEntry());
11760  ABORT();
11761  }
11762 
11763  if (Unit* owner = GetOwner())
11764  {
11765  if (owner->m_Controlled.find(this) != owner->m_Controlled.end())
11766  {
11767  TC_LOG_FATAL("entities.unit", "Unit %u is in controlled list of %u when removed from world", GetEntry(), owner->GetEntry());
11768  ABORT();
11769  }
11770  }
11771 
11773  m_duringRemoveFromWorld = false;
11774  }
11775 }
bool IsVehicle() const
Definition: Unit.h:1406
void RemoveVehicleKit(bool onRemoveFromWorld=false)
Definition: Unit.cpp:14318
void UnsummonAllTotems()
Definition: Unit.cpp:8127
bool m_duringRemoveFromWorld
Definition: Unit.h:2353
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
void RemoveBindSightAuras()
Definition: Unit.cpp:8114
void ExitVehicle(Position const *exitPosition=NULL)
Definition: Unit.cpp:15321
virtual void RemoveFromWorld() override
Definition: Object.cpp:1515
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void RemoveCharmAuras()
Definition: Unit.cpp:8119
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:210
Unit * GetOwner() const
Definition: Unit.cpp:7542
void RemoveAllControlled()
Definition: Unit.cpp:7998
#define ABORT
Definition: Errors.h:56
#define ASSERT
Definition: Errors.h:55
void RemoveAreaAurasDueToLeaveWorld()
Definition: Unit.cpp:3887
void RemoveAllGameObjects()
Definition: Unit.cpp:4826
uint32 GetEntry() const
Definition: Object.h:107
void RemoveNotOwnSingleTargetAuras(uint32 newPhase=0x0, bool phaseid=false)
Definition: Unit.cpp:3769
bool IsInWorld() const
Definition: Object.h:100
Definition: Unit.h:1305
void RemoveAllDynObjects()
Definition: Unit.cpp:4732

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveGameObject ( GameObject gameObj,
bool  del 
)
4766 {
4767  if (!gameObj || gameObj->GetOwnerGUID() != GetGUID())
4768  return;
4769 
4770  gameObj->SetOwnerGUID(ObjectGuid::Empty);
4771 
4772  for (uint8 i = 0; i < MAX_GAMEOBJECT_SLOT; ++i)
4773  {
4774  if (m_ObjectSlot[i] == gameObj->GetGUID())
4775  {
4776  m_ObjectSlot[i].Clear();
4777  break;
4778  }
4779  }
4780 
4781  // GO created by some spell
4782  if (uint32 spellid = gameObj->GetSpellId())
4783  {
4784  RemoveAurasDueToSpell(spellid);
4785 
4786  SpellInfo const* createBySpell = sSpellMgr->GetSpellInfo(spellid);
4787  // Need activate spell use for owner
4788  if (createBySpell && createBySpell->IsCooldownStartedOnEvent())
4789  // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases)
4790  GetSpellHistory()->SendCooldownEvent(createBySpell);
4791  }
4792 
4793  m_gameObj.remove(gameObj);
4794 
4795  if (del)
4796  {
4797  gameObj->SetRespawnTime(0);
4798  gameObj->Delete();
4799  }
4800 }
#define MAX_GAMEOBJECT_SLOT
Definition: Unit.h:1287
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: SpellInfo.h:326
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool startCooldown=true)
Definition: SpellHistory.cpp:487
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
GameObjectList m_gameObj
Definition: Unit.h:2267
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
void Clear()
Definition: ObjectGuid.h:215
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3586
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT]
Definition: Unit.h:1930
uint8_t uint8
Definition: Define.h:152
uint32 GetSpellId() const
Definition: GameObject.h:933
void SetOwnerGUID(ObjectGuid owner)
Definition: GameObject.h:915
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1470
void Delete()
Definition: GameObject.cpp:726

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveGameObject ( uint32  spellid,
bool  del 
)
4803 {
4804  if (m_gameObj.empty())
4805  return;
4806  GameObjectList::iterator i, next;
4807  for (i = m_gameObj.begin(); i != m_gameObj.end(); i = next)
4808  {
4809  next = i;
4810  if (spellid == 0 || (*i)->GetSpellId() == spellid)
4811  {
4812  (*i)->SetOwnerGUID(ObjectGuid::Empty);
4813  if (del)
4814  {
4815  (*i)->SetRespawnTime(0);
4816  (*i)->Delete();
4817  }
4818 
4819  next = m_gameObj.erase(i);
4820  }
4821  else
4822  ++next;
4823  }
4824 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
int next(int i, int n)
Definition: RecastContour.cpp:469
GameObjectList m_gameObj
Definition: Unit.h:2267

+ Here is the call graph for this function:

void Unit::removeHatedBy ( HostileReference )
inline
2000 { /* nothing to do yet */ }

+ Here is the caller graph for this function:

void Unit::RemoveMovementImpairingAuras ( )
3866 {
3868 }
Definition: SharedDefines.h:1801
Definition: SharedDefines.h:1797
void RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveMode removemode=AURA_REMOVE_BY_DEFAULT, uint32 except=0)
Definition: Unit.cpp:3870

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveNotOwnSingleTargetAuras ( uint32  newPhase = 0x0,
bool  phaseid = false 
)
3770 {
3771  // single target auras from other casters
3772  // Iterate m_ownedAuras - aura is marked as single target in Unit::AddAura (and pushed to m_ownedAuras).
3773  // m_appliedAuras will NOT contain the aura before first Unit::Update after adding it to m_ownedAuras.
3774  // Quickly removing such an aura will lead to it not being unregistered from caster's single cast auras container
3775  // leading to assertion failures if the aura was cast on a player that can
3776  // (and is changing map at the point where this function is called).
3777  // Such situation occurs when player is logging in inside an instance and fails the entry check for any reason.
3778  // The aura that was loaded from db (indirectly, via linked casts) gets removed before it has a chance
3779  // to register in m_appliedAuras
3780  for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
3781  {
3782  Aura const* aura = iter->second;
3783 
3784  if (aura->GetCasterGUID() != GetGUID() && aura->IsSingleTarget())
3785  {
3786  if (!newPhase && !phaseid)
3787  RemoveOwnedAura(iter);
3788  else
3789  {
3790  Unit* caster = aura->GetCaster();
3791  if (!caster || (newPhase && !caster->IsInPhase(newPhase)) || (!newPhase && !caster->IsInPhase(this)))
3792  RemoveOwnedAura(iter);
3793  else
3794  ++iter;
3795  }
3796  }
3797  else
3798  ++iter;
3799  }
3800 
3801  // single target auras at other targets
3802  AuraList& scAuras = GetSingleCastAuras();
3803  for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();)
3804  {
3805  Aura* aura = *iter;
3806  if (aura->GetUnitOwner() != this && !aura->GetUnitOwner()->IsInPhase(newPhase))
3807  {
3808  aura->Remove();
3809  iter = scAuras.begin();
3810  }
3811  else
3812  ++iter;
3813  }
3814 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
Unit * GetCaster() const
Definition: SpellAuras.cpp:438
Unit * GetUnitOwner() const
Definition: SpellAuras.h:138
std::list< Aura * > AuraList
Definition: Unit.h:1323
bool IsSingleTarget() const
Definition: SpellAuras.h:204
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
AuraList & GetSingleCastAuras()
Definition: Unit.h:1833
bool IsInPhase(uint32 phase) const
Definition: Object.h:462
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveOwnedAura ( AuraMap::iterator &  i,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)
3366 {
3367  Aura* aura = i->second;
3368  ASSERT(!aura->IsRemoved());
3369 
3370  // if unit currently update aura list then make safe update iterator shift to next
3371  if (m_auraUpdateIterator == i)
3373 
3374  m_ownedAuras.erase(i);
3375  m_removedAuras.push_back(aura);
3376 
3377  // Unregister single target aura
3378  if (aura->IsSingleTarget())
3379  aura->UnregisterSingleTarget();
3380 
3381  aura->_Remove(removeMode);
3382 
3383  i = m_ownedAuras.begin();
3384 }
AuraList m_removedAuras
Definition: Unit.h:2275
AuraMap m_ownedAuras
Definition: Unit.h:2273
bool IsSingleTarget() const
Definition: SpellAuras.h:204
bool IsRemoved() const
Definition: SpellAuras.h:201
void _Remove(AuraRemoveMode removeMode)
Definition: SpellAuras.cpp:511
void UnregisterSingleTarget()
Definition: SpellAuras.cpp:1115
AuraMap::iterator m_auraUpdateIterator
Definition: Unit.h:2276
#define ASSERT
Definition: Errors.h:55
Definition: SpellAuras.h:116

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveOwnedAura ( uint32  spellId,
ObjectGuid  casterGUID = ObjectGuid::Empty,
uint32  reqEffMask = 0,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)
3387 {
3388  for (AuraMap::iterator itr = m_ownedAuras.lower_bound(spellId); itr != m_ownedAuras.upper_bound(spellId);)
3389  if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || itr->second->GetCasterGUID() == casterGUID))
3390  {
3391  RemoveOwnedAura(itr, removeMode);
3392  itr = m_ownedAuras.lower_bound(spellId);
3393  }
3394  else
3395  ++itr;
3396 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365

+ Here is the call graph for this function:

void Unit::RemoveOwnedAura ( Aura aura,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)
3399 {
3400  if (aura->IsRemoved())
3401  return;
3402 
3403  ASSERT(aura->GetOwner() == this);
3404 
3405  if (removeMode == AURA_REMOVE_NONE)
3406  {
3407  TC_LOG_ERROR("spells", "Unit::RemoveOwnedAura() called with unallowed removeMode AURA_REMOVE_NONE, spellId %u", aura->GetId());
3408  return;
3409  }
3410 
3411  uint32 spellId = aura->GetId();
3412  AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId);
3413 
3414  for (AuraMap::iterator itr = range.first; itr != range.second; ++itr)
3415  {
3416  if (itr->second == aura)
3417  {
3418  RemoveOwnedAura(itr, removeMode);
3419  return;
3420  }
3421  }
3422 
3423  ABORT();
3424 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
Definition: Unit.h:450
std::pair< AuraMap::iterator, AuraMap::iterator > AuraMapBoundsNonConst
Definition: Unit.h:1313
bool IsRemoved() const
Definition: SpellAuras.h:201
WorldObject * GetOwner() const
Definition: SpellAuras.h:137
uint32_t uint32
Definition: Define.h:150
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
#define ABORT
Definition: Errors.h:56
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 GetId() const
Definition: SpellAuras.h:131

+ Here is the call graph for this function:

void Unit::RemoveOwnedAuras ( std::function< bool(Aura const *)> const check)
3529 {
3530  for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
3531  {
3532  if (check(iter->second))
3533  {
3534  RemoveOwnedAura(iter);
3535  continue;
3536  }
3537  ++iter;
3538  }
3539 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
T check(T value)
Definition: format.h:305

+ Here is the call graph for this function:

void Unit::RemoveOwnedAuras ( uint32  spellId,
std::function< bool(Aura const *)> const check 
)
3555 {
3556  for (AuraMap::iterator iter = m_ownedAuras.lower_bound(spellId); iter != m_ownedAuras.upper_bound(spellId);)
3557  {
3558  if (check(iter->second))
3559  {
3560  RemoveOwnedAura(iter);
3561  continue;
3562  }
3563  ++iter;
3564  }
3565 }
AuraMap m_ownedAuras
Definition: Unit.h:2273
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
T check(T value)
Definition: format.h:305

+ Here is the call graph for this function:

void Unit::RemovePetAura ( PetAura const petSpell)
13172 {
13173  if (GetTypeId() != TYPEID_PLAYER)
13174  return;
13175 
13176  m_petAuras.erase(petSpell);
13177  if (Pet* pet = ToPlayer()->GetPet())
13178  pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry()));
13179 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:33
PetAuraSet m_petAuras
Definition: Unit.h:2146
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemovePlayerFromVision ( Player player)
8105 {
8106  m_sharedVision.remove(player);
8107  if (m_sharedVision.empty())
8108  {
8109  setActive(false);
8110  SetWorldObject(false);
8111  }
8112 }
void setActive(bool isActiveObject)
Definition: Object.cpp:1473
SharedVisionList m_sharedVision
Definition: Unit.h:2293
void SetWorldObject(bool apply)
Definition: Object.cpp:1454

+ Here is the call graph for this function:

void Unit::RemoveStandFlags ( uint8  flags)
inline
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:1271
Definition: UpdateFields.h:124
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveUnitMovementFlag ( uint32  f)
inline
void RemoveMovementFlag(uint32 flag)
Definition: Object.h:329
MovementInfo m_movementInfo
Definition: Object.h:612

+ Here is the caller graph for this function:

void Unit::RemoveVehicleKit ( bool  onRemoveFromWorld = false)
14319 {
14320  if (!m_vehicleKit)
14321  return;
14322 
14323  if (!onRemoveFromWorld)
14325 
14327  delete m_vehicleKit;
14328 
14329  m_vehicleKit = NULL;
14330 
14334 }
void SendSetVehicleRecId(uint32 vehicleId)
Definition: Unit.cpp:16106
Definition: Unit.h:759
void Uninstall()
Removes all passengers and sets status to STATUS_UNINSTALLING. No new passengers can be added to the ...
Definition: Vehicle.cpp:112
Definition: Unit.h:863
Vehicle * m_vehicleKit
Definition: Unit.h:2305
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Unit.h:760
Definition: UpdateData.h:44
uint32 m_unitTypeMask
Definition: Unit.h:2307
Definition: UpdateFields.h:135
void RemoveFlag64(uint16 index, uint64 oldFlag)
Definition: Object.cpp:1312
uint32 m_updateFlag
Definition: Object.h:230

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RemoveVisibleAura ( uint8  slot)
552 {
553  m_visibleAuras.erase(slot);
554  UpdateAuraForGroup(slot);
555 }
VisibleAuraMap m_visibleAuras
Definition: Unit.h:2288
void UpdateAuraForGroup(uint8 slot)
Definition: Unit.cpp:13062

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::resetAttackTimer ( WeaponAttackType  type = BASE_ATTACK)
482 {
483  m_attackTimer[type] = uint32(GetAttackTime(type) * m_modAttackSpeedPct[type]);
484 }
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.cpp:10326
float m_modAttackSpeedPct[3]
Definition: Unit.h:1945
uint32_t uint32
Definition: g3dmath.h:168
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2251

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::ResetRedirectThreat ( )
inline
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void SetRedirectThreat(ObjectGuid guid, uint32 pct)
Definition: Unit.h:2154

+ Here is the caller graph for this function:

void Unit::RestoreDisplayId ( )
12808 {
12809  AuraEffect* handledAura = NULL;
12810  // try to receive model from transform auras
12812  if (!transforms.empty())
12813  {
12814  // iterate over already applied transform auras - from newest to oldest
12815  for (Unit::AuraEffectList::const_reverse_iterator i = transforms.rbegin(); i != transforms.rend(); ++i)
12816  {
12817  if (AuraApplication const* aurApp = (*i)->GetBase()->GetApplicationOfTarget(GetGUID()))
12818  {
12819  if (!handledAura)
12820  handledAura = (*i);
12821  // prefer negative auras
12822  if (!aurApp->IsPositive())
12823  {
12824  handledAura = (*i);
12825  break;
12826  }
12827  }
12828  }
12829  }
12830  // transform aura was found
12831  if (handledAura)
12832  handledAura->HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true);
12833  // we've found shapeshift
12834  else if (uint32 modelId = GetModelForForm(GetShapeshiftForm()))
12835  SetDisplayId(modelId);
12836  // no auras found - set modelid to default
12837  else
12839 }
Definition: SpellAuraEffects.h:30
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SpellAuraDefines.h:40
void HandleEffect(AuraApplication *aurApp, uint8 mode, bool apply)
Definition: SpellAuraEffects.cpp:861
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:1932
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
Definition: SpellAuraDefines.h:116
uint32 GetModelForForm(ShapeshiftForm form) const
Definition: Unit.cpp:14696
virtual void SetDisplayId(uint32 modelId)
Definition: Unit.cpp:12799
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetNativeDisplayId() const
Definition: Unit.h:2014

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RestoreFaction ( )
14278 {
14279  if (GetTypeId() == TYPEID_PLAYER)
14280  ToPlayer()->setFactionForRace(getRace());
14281  else
14282  {
14284  {
14285  if (Unit* owner = GetOwner())
14286  {
14287  setFaction(owner->getFaction());
14288  return;
14289  }
14290  }
14291 
14292  if (CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate()) // normal creature
14293  setFaction(cinfo->faction);
14294  }
14295 }
Definition: Unit.h:859
Player * ToPlayer()
Definition: Object.h:191
void setFaction(uint32 faction)
Definition: Unit.h:1467
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
uint8 getRace() const
Definition: Unit.h:1411
Definition: ObjectGuid.h:33
Unit * GetOwner() const
Definition: Unit.cpp:7542
Creature * ToCreature()
Definition: Object.h:194
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
Definition: Unit.h:1305
Definition: Creature.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::RewardRage ( uint32  baseRage,
bool  attacker 
)

ToDo: Check formula

15567 {
15568  float addRage;
15569 
15570  if (attacker)
15571  {
15572  addRage = baseRage;
15573  // talent who gave more rage on attack
15575  }
15576  else
15577  {
15578  // Calculate rage from health and damage taken
15580  addRage = floor(0.5f + (25.7f * baseRage / GetMaxHealth()));
15581  // Berserker Rage effect
15582  if (HasAura(18499))
15583  addRage *= 2.0f;
15584  }
15585 
15586  addRage *= sWorld->getRate(RATE_POWER_RAGE_INCOME);
15587 
15588  ModifyPower(POWER_RAGE, uint32(addRage * 10));
15589 }
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:10285
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
uint32 GetMaxHealth() const
Definition: Unit.h:1427
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: World.h:385
static Vector3int16 floor(const Vector3 &v)
Definition: SharedDefines.h:249
#define sWorld
Definition: World.h:887
T AddPct(T &base, U pct)
Definition: Util.h:98
Definition: SpellAuraDefines.h:273
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MeleeHitOutcome Unit::RollMeleeOutcomeAgainst ( Unit const victim,
WeaponAttackType  attType 
) const
1928 {
1929  if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode())
1930  return MELEE_HIT_EVADE;
1931 
1932  // Miss chance based on melee
1933  //float miss_chance = MeleeMissChanceCalc(victim, attType);
1934  int32 miss_chance = int32(MeleeSpellMissChance(victim, attType, 0) * 100);
1935 
1936  // Critical hit chance
1937  int32 crit_chance = int32(GetUnitCriticalChance(attType, victim) * 100);
1938 
1939  // stunned target cannot dodge and this is check in GetUnitDodgeChance() (returned 0 in this case)
1940  int32 dodge_chance = int32(victim->GetUnitDodgeChanceAgainst(this) * 100);
1941  int32 block_chance = int32(victim->GetUnitBlockChanceAgainst(this) * 100);
1942  int32 parry_chance = int32(victim->GetUnitParryChanceAgainst(this) * 100);
1943 
1944  int32 sum = 0, tmp = 0;
1945  int32 roll = urand (0, 10000);
1946 
1947  int32 attackerLevel = getLevelForTarget(victim);
1948  int32 victimLevel = getLevelForTarget(this);
1949 
1950  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: rolled %d, miss %d, dodge %d, parry %d, block %d, crit %d",
1951  roll, miss_chance, dodge_chance, parry_chance, block_chance, crit_chance);
1952 
1953  tmp = miss_chance;
1954 
1955  if (tmp > 0 && roll < (sum += tmp))
1956  {
1957  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: MISS");
1958  return MELEE_HIT_MISS;
1959  }
1960 
1961  // always crit against a sitting target (except 0 crit chance)
1962  if (victim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !victim->IsStandState())
1963  {
1964  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT (sitting victim)");
1965  return MELEE_HIT_CRIT;
1966  }
1967 
1968  // Dodge chance
1969 
1970  // only players can't dodge if attacker is behind
1971  if (victim->GetTypeId() == TYPEID_PLAYER && !victim->HasInArc(float(M_PI), this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
1972  {
1973  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: attack came from behind and victim was a player.");
1974  }
1975  else
1976  {
1977  // Reduce dodge chance by attacker expertise rating
1978  if (GetTypeId() == TYPEID_PLAYER)
1979  dodge_chance -= int32(ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100);
1980  else
1981  dodge_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
1982 
1983  // Modify dodge chance by attacker SPELL_AURA_MOD_COMBAT_RESULT_CHANCE
1985  dodge_chance = int32(float(dodge_chance) * GetTotalAuraMultiplier(SPELL_AURA_MOD_ENEMY_DODGE));
1986 
1987  tmp = dodge_chance;
1988  if ((tmp > 0) // check if unit _can_ dodge
1989  && roll < (sum += tmp))
1990  {
1991  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: DODGE <%d, %d)", sum - tmp, sum);
1992  return MELEE_HIT_DODGE;
1993  }
1994  }
1995 
1996  // parry & block chances
1997 
1998  // check if attack comes from behind, nobody can parry or block if attacker is behind
1999  if (!victim->HasInArc(float(M_PI), this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
2000  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: attack came from behind.");
2001  else
2002  {
2003  // Reduce parry chance by attacker expertise rating
2004  if (GetTypeId() == TYPEID_PLAYER)
2005  parry_chance -= int32(ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100);
2006  else
2007  parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
2008 
2009  if (victim->GetTypeId() == TYPEID_PLAYER || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY))
2010  {
2011  int32 tmp2 = int32(parry_chance);
2012  if (tmp2 > 0 // check if unit _can_ parry
2013  && roll < (sum += tmp2))
2014  {
2015  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp2, sum);
2016  return MELEE_HIT_PARRY;
2017  }
2018  }
2019 
2020  if (victim->GetTypeId() == TYPEID_PLAYER || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK))
2021  {
2022  tmp = block_chance;
2023  if (tmp > 0 // check if unit _can_ block
2024  && roll < (sum += tmp))
2025  {
2026  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: BLOCK <%d, %d)", sum-tmp, sum);
2027  return MELEE_HIT_BLOCK;
2028  }
2029  }
2030  }
2031 
2032  // Critical chance
2033  tmp = crit_chance;
2034 
2035  if (tmp > 0 && roll < (sum += tmp))
2036  {
2037  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum);
2038  if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT))
2039  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT DISABLED)");
2040  else
2041  return MELEE_HIT_CRIT;
2042  }
2043 
2044  // Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon)
2045  if (attType != RANGED_ATTACK &&
2046  (GetTypeId() == TYPEID_PLAYER || IsPet()) &&
2047  victim->GetTypeId() != TYPEID_PLAYER && !victim->IsPet() &&
2048  attackerLevel + 3 < victimLevel)
2049  {
2050  // cap possible value (with bonuses > max skill)
2051  tmp = (10 + 10 * (victimLevel - attackerLevel)) * 100;
2052  if (roll < (sum += tmp))
2053  {
2054  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: GLANCING <%d, %d)", sum-4000, sum);
2055  return MELEE_HIT_GLANCING;
2056  }
2057  }
2058 
2059  // mobs can score crushing blows if they're 4 or more levels above victim
2060  if (attackerLevel >= victimLevel + 4 &&
2061  // can be from by creature (if can) or from controlled player that considered as creature
2062  !IsControlledByPlayer() &&
2063  !(GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH))
2064  {
2065  // add 2% chance per level, min. is 15%
2066  tmp = attackerLevel - victimLevel * 1000 - 1500;
2067  if (roll < (sum += tmp))
2068  {
2069  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRUSHING <%d, %d)", sum-tmp, sum);
2070  return MELEE_HIT_CRUSHING;
2071  }
2072  }
2073 
2074  TC_LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: NORMAL");
2075  return MELEE_HIT_NORMAL;
2076 }
float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *victim) const
Definition: Unit.cpp:2625
Definition: SpellAuraDefines.h:300
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:4521
Definition: SpellAuraDefines.h:311
uint8 getLevelForTarget(WorldObject const *) const override
Definition: Unit.h:1409
Definition: Unit.h:885
bool IsControlledByPlayer() const
Definition: Unit.h:1712
#define M_PI
Definition: Common.h:163
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: Unit.h:619
Definition: ObjectGuid.h:32
float MeleeSpellMissChance(Unit const *victim, WeaponAttackType attType, uint32 spellId) const
Definition: Unit.cpp:14545
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:47
Definition: Unit.h:884
Player * ToPlayer()
Definition: Object.h:191
Definition: Creature.h:44
Definition: Unit.h:885
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Creature.h:46
Definition: Unit.h:337
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
int32_t int32
Definition: Define.h:146
Definition: Unit.h:884
Definition: Creature.h:53
Definition: Unit.h:884
Definition: Unit.h:884
Definition: SpellAuraDefines.h:348
bool IsPet() const
Definition: Unit.h:1403
Definition: ObjectGuid.h:33
Definition: Unit.h:884
Creature * ToCreature()
Definition: Object.h:194
int32_t int32
Definition: g3dmath.h:167
Definition: Unit.h:885
Definition: SpellAuraDefines.h:308
Definition: Unit.h:885
float GetTotalAuraMultiplier(AuraType auratype) const
Definition: Unit.cpp:4415

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Say ( std::string const text,
Language  language,
WorldObject const target = nullptr 
)
virtual
16394 {
16395  Talk(text, CHAT_MSG_MONSTER_SAY, language, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), target);
16396 }
Definition: World.h:190
virtual void Talk(std::string const &text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
Definition: Unit.cpp:16385
#define sWorld
Definition: World.h:887
Definition: SharedDefines.h:4243

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Say ( uint32  textId,
WorldObject const target = nullptr 
)
16451 {
16452  Talk(textId, CHAT_MSG_MONSTER_SAY, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), target);
16453 }
Definition: World.h:190
virtual void Talk(std::string const &text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
Definition: Unit.cpp:16385
#define sWorld
Definition: World.h:887
Definition: SharedDefines.h:4243

+ Here is the call graph for this function:

Unit * Unit::SelectNearbyTarget ( Unit exclude = NULL,
float  dist = NOMINAL_MELEE_RANGE 
) const
12891 {
12892  std::list<Unit*> targets;
12893  Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist);
12895  VisitNearbyObject(dist, searcher);
12896 
12897  // remove current target
12898  if (GetVictim())
12899  targets.remove(GetVictim());
12900 
12901  if (exclude)
12902  targets.remove(exclude);
12903 
12904  // remove not LoS targets
12905  for (std::list<Unit*>::iterator tIter = targets.begin(); tIter != targets.end();)
12906  {
12907  if (!IsWithinLOSInMap(*tIter) || (*tIter)->IsTotem() || (*tIter)->IsSpiritService() || (*tIter)->IsCritter())
12908  targets.erase(tIter++);
12909  else
12910  ++tIter;
12911  }
12912 
12913  // no appropriate targets
12914  if (targets.empty())
12915  return NULL;
12916 
12917  // select random
12919 }
C::value_type const & SelectRandomContainerElement(C const &container)
Definition: Containers.h:68
bool IsWithinLOSInMap(WorldObject const *obj) const
Definition: Object.cpp:1584
arena_t NULL
Definition: jemalloc_internal.h:624
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:587
Definition: GridNotifiers.h:410
Unit * GetVictim() const
Definition: Unit.h:1379
Definition: GridNotifiers.h:797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendAttackStateUpdate ( CalcDamageInfo damageInfo)
4926 {
4928  packet.HitInfo = damageInfo->HitInfo;
4929  packet.AttackerGUID = damageInfo->attacker->GetGUID();
4930  packet.VictimGUID = damageInfo->target->GetGUID();
4931  packet.Damage = damageInfo->damage;
4932  int32 overkill = damageInfo->damage - damageInfo->target->GetHealth();
4933  packet.OverDamage = (overkill < 0 ? -1 : overkill);
4934 
4935  packet.SubDmg = boost::in_place();
4936  packet.SubDmg->SchoolMask = damageInfo->damageSchoolMask; // School of sub damage
4937  packet.SubDmg->FDamage = damageInfo->damage; // sub damage
4938  packet.SubDmg->Damage = damageInfo->damage; // Sub Damage
4939  packet.SubDmg->Absorbed = damageInfo->absorb;
4940  packet.SubDmg->Resisted = damageInfo->resist;
4941 
4942  packet.VictimState = damageInfo->TargetState;
4943  packet.BlockAmount = damageInfo->blocked_amount;
4944 
4945  packet.LogData.Initialize(damageInfo->attacker);
4946 
4947  SendCombatLogMessage(&packet);
4948 }
Optional< SubDamage > SubDmg
Definition: CombatLogPackets.h:357
void Initialize(Unit const *unit)
Definition: SpellPackets.cpp:91
Unit * attacker
Definition: Unit.h:1023
uint32 blocked_amount
Definition: Unit.h:1029
uint32 HitInfo
Definition: Unit.h:1030
uint32 resist
Definition: Unit.h:1028
int32 BlockAmount
Definition: CombatLogPackets.h:361
Definition: CombatLogPackets.h:345
ObjectGuid AttackerGUID
Definition: CombatLogPackets.h:353
int32 OverDamage
Definition: CombatLogPackets.h:356
Spells::SpellCastLogData LogData
Definition: CombatLogPackets.h:38
int32_t int32
Definition: Define.h:146
uint32 absorb
Definition: Unit.h:1027
uint32 TargetState
Definition: Unit.h:1031
uint32 damageSchoolMask
Definition: Unit.h:1025
ObjectGuid VictimGUID
Definition: CombatLogPackets.h:354
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint8 VictimState
Definition: CombatLogPackets.h:358
Unit * target
Definition: Unit.h:1024
uint32 HitInfo
Definition: CombatLogPackets.h:352
void SendCombatLogMessage(WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
Definition: Unit.cpp:16597
uint32 damage
Definition: Unit.h:1026
int32 Damage
Definition: CombatLogPackets.h:355
uint32 GetHealth() const
Definition: Unit.h:1426

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendAttackStateUpdate ( uint32  HitInfo,
Unit target,
uint8  SwingType,
SpellSchoolMask  damageSchoolMask,
uint32  Damage,
uint32  AbsorbDamage,
uint32  Resist,
VictimState  TargetState,
uint32  BlockedAmount 
)
4951 {
4952  CalcDamageInfo dmgInfo;
4953  dmgInfo.HitInfo = HitInfo;
4954  dmgInfo.attacker = this;
4955  dmgInfo.target = target;
4956  dmgInfo.damage = Damage - AbsorbDamage - Resist - BlockedAmount;
4957  dmgInfo.damageSchoolMask = damageSchoolMask;
4958  dmgInfo.absorb = AbsorbDamage;
4959  dmgInfo.resist = Resist;
4960  dmgInfo.TargetState = TargetState;
4961  dmgInfo.blocked_amount = BlockedAmount;
4962  SendAttackStateUpdate(&dmgInfo);
4963 }
Unit * attacker
Definition: Unit.h:1023
uint32 blocked_amount
Definition: Unit.h:1029
uint32 HitInfo
Definition: Unit.h:1030
uint32 resist
Definition: Unit.h:1028
Definition: Unit.h:1021
uint32 absorb
Definition: Unit.h:1027
uint32 TargetState
Definition: Unit.h:1031
uint32 damageSchoolMask
Definition: Unit.h:1025
void SendAttackStateUpdate(CalcDamageInfo *damageInfo)
Definition: Unit.cpp:4925
Unit * target
Definition: Unit.h:1024
HitInfo
Definition: Unit.h:346
uint32 damage
Definition: Unit.h:1026

+ Here is the call graph for this function:

void Unit::SendChangeCurrentVictimOpcode ( HostileReference pHostileReference)
15531 {
15532  if (!getThreatManager().isThreatListEmpty())
15533  {
15535  packet.UnitGUID = GetGUID();
15536  packet.HighestThreatGUID = pHostileReference->getUnitGuid();
15538  packet.ThreatList.reserve(tlist.size());
15539  for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr)
15540  {
15542  info.UnitGUID = (*itr)->getUnitGuid();
15543  info.Threat = int32((*itr)->getThreat() * 100);
15544  packet.ThreatList.push_back(info);
15545  }
15546  SendMessageToSet(packet.Write(), false);
15547  }
15548 }
WorldPacket const * Write() override
Definition: CombatPackets.cpp:67
Definition: CombatPackets.h:82
ThreatContainer::StorageType const & getThreatList() const
Definition: ThreatManager.h:263
std::vector< ThreatInfo > ThreatList
Definition: CombatPackets.h:107
ObjectGuid getUnitGuid() const
Definition: ThreatManager.h:107
ObjectGuid UnitGUID
Definition: CombatPackets.h:84
int32 Threat
Definition: CombatPackets.h:85
Definition: CombatPackets.h:99
ObjectGuid HighestThreatGUID
Definition: CombatPackets.h:108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
std::list< HostileReference * > StorageType
Definition: ThreatManager.h:149
ThreatManager & getThreatManager()
Definition: Unit.h:1998
ObjectGuid UnitGUID
Definition: CombatPackets.h:106
int32_t int32
Definition: g3dmath.h:167
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendClearTarget ( )
15683 {
15685  breakTarget.UnitGUID = GetGUID();
15686  SendMessageToSet(breakTarget.Write(), false);
15687 }
WorldPacket const * Write() override
Definition: CombatPackets.cpp:153
ObjectGuid UnitGUID
Definition: CombatPackets.h:221
Definition: CombatPackets.h:214
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendClearThreatListOpcode ( )
15551 {
15553  packet.UnitGUID = GetGUID();
15554  SendMessageToSet(packet.Write(), false);
15555 }
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
ObjectGuid UnitGUID
Definition: CombatPackets.h:199
Definition: CombatPackets.h:192
WorldPacket const * Write() override
Definition: CombatPackets.cpp:138

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendCombatLogMessage ( WorldPackets::CombatLog::CombatLogServerPacket combatLog) const
16598 {
16599  CombatLogSender notifier(this, combatLog, GetVisibilityRange());
16601 }
void VisitNearbyWorldObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:589
float GetVisibilityRange() const
Definition: Object.cpp:1912
Definition: Unit.cpp:16501

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendDurabilityLoss ( Player receiver,
uint32  percent 
)
13445 {
13447  packet.Percent = percent;
13448  receiver->GetSession()->SendPacket(packet.Write());
13449 }
Definition: MiscPackets.h:571
int32 Percent
Definition: MiscPackets.h:578
WorldPacket const * Write() override
Definition: MiscPackets.cpp:421

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendEnergizeSpellLog ( Unit victim,
uint32  spellID,
int32  damage,
Powers  powertype 
)
8191 {
8193  data.CasterGUID = GetGUID();
8194  data.TargetGUID = victim->GetGUID();
8195  data.SpellID = spellId;
8196  data.Type = powerType;
8197  data.Amount = damage;
8198  data.LogData.Initialize(victim);
8199  SendCombatLogMessage(&data);
8200 }
ObjectGuid CasterGUID
Definition: CombatLogPackets.h:231
void Initialize(Unit const *unit)
Definition: SpellPackets.cpp:91
int32 SpellID
Definition: CombatLogPackets.h:233
int32 Type
Definition: CombatLogPackets.h:234
ObjectGuid TargetGUID
Definition: CombatLogPackets.h:232
Spells::SpellCastLogData LogData
Definition: CombatLogPackets.h:38
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void SendCombatLogMessage(WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
Definition: Unit.cpp:16597
int32 Amount
Definition: CombatLogPackets.h:235
Definition: CombatLogPackets.h:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendHealSpellLog ( Unit victim,
uint32  spellID,
uint32  health,
uint32  overHeal,
uint32  absorbed,
bool  crit = false 
)
Todo:
: 6.x Has to be implemented
8141 {
8143 
8144  TC_LOG_DEBUG("spells", "HealSpellLog -- SpellId: %u Caster: %s Target: %s (Health: %u OverHeal: %u Absorbed: %u Crit: %d)", spellID, GetGUID().ToString().c_str(), victim->GetGUID().ToString().c_str(),
8145  health, overHeal, absorbed, crit);
8146 
8147  spellHealLog.TargetGUID = victim->GetGUID();
8148  spellHealLog.CasterGUID = GetGUID();
8149 
8150  spellHealLog.SpellID = spellID;
8151  spellHealLog.Health = health;
8152  spellHealLog.OverHeal = overHeal;
8153  spellHealLog.Absorbed = absorbed;
8154 
8155  spellHealLog.Crit = crit;
8156 
8158  /*
8159  packet.ReadBit("Multistrike");
8160 
8161  var hasCritRollMade = packet.ReadBit("HasCritRollMade");
8162  var hasCritRollNeeded = packet.ReadBit("HasCritRollNeeded");
8163  var hasLogData = packet.ReadBit("HasLogData");
8164 
8165  if (hasCritRollMade)
8166  packet.ReadSingle("CritRollMade");
8167 
8168  if (hasCritRollNeeded)
8169  packet.ReadSingle("CritRollNeeded");
8170 
8171  if (hasLogData)
8172  SpellParsers.ReadSpellCastLogData(packet);
8173  */
8174 
8175  spellHealLog.LogData.Initialize(victim);
8176  SendCombatLogMessage(&spellHealLog);
8177 }
int32 Absorbed
Definition: CombatLogPackets.h:149
void Initialize(Unit const *unit)
Definition: SpellPackets.cpp:91
ObjectGuid TargetGUID
Definition: CombatLogPackets.h:145
ObjectGuid CasterGUID
Definition: CombatLogPackets.h:144
bool Crit
Definition: CombatLogPackets.h:150
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
int32 Health
Definition: CombatLogPackets.h:147
Definition: CombatLogPackets.h:137
Spells::SpellCastLogData LogData
Definition: CombatLogPackets.h:38
std::string ToString() const
Definition: Position.cpp:160
ObjectGuid const & GetGUID() const
Definition: Object.h:105
int32 SpellID
Definition: CombatLogPackets.h:146
int32 OverHeal
Definition: CombatLogPackets.h:148
void SendCombatLogMessage(WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
Definition: Unit.cpp:16597
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendMeleeAttackStart ( Unit victim)
2135 {
2137  packet.Attacker = GetGUID();
2138  packet.Victim = victim->GetGUID();
2139  SendMessageToSet(packet.Write(), true);
2140 }
ObjectGuid Victim
Definition: CombatPackets.h:66
Definition: CombatPackets.h:58
WorldPacket const * Write() override
Definition: CombatPackets.cpp:26
ObjectGuid Attacker
Definition: CombatPackets.h:65
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendMeleeAttackStop ( Unit victim = NULL)
2143 {
2144  SendMessageToSet(WorldPackets::Combat::SAttackStop(this, victim).Write(), true);
2145 
2146  if (victim)
2147  TC_LOG_DEBUG("entities.unit", "%s stopped attacking %s", GetGUID().ToString().c_str(), victim->GetGUID().ToString().c_str());
2148  else
2149  TC_LOG_DEBUG("entities.unit", "%s stopped attacking", GetGUID().ToString().c_str());
2150 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::string ToString() const
Definition: Position.cpp:160
Definition: CombatPackets.h:69
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendMoveKnockBack ( Player player,
float  speedXY,
float  speedZ,
float  vcos,
float  vsin 
)
14644 {
14646  moveKnockBack.MoverGUID = GetGUID();
14647  moveKnockBack.SequenceIndex = m_movementCounter++;
14648  moveKnockBack.HorzSpeed = speedXY;
14649  moveKnockBack.VertSpeed = speedZ;
14650  moveKnockBack.Direction.x = vcos;
14651  moveKnockBack.Direction.y = vsin;
14652  player->GetSession()->SendPacket(moveKnockBack.Write());
14653 }
ObjectGuid MoverGUID
Definition: MovementPackets.h:344
uint32 SequenceIndex
Definition: MovementPackets.h:347
Definition: MovementPackets.h:337
float y
Definition: Vector2.h:50
WorldPacket const * Write() override
Definition: MovementPackets.cpp:633
G3D::Vector2 Direction
Definition: MovementPackets.h:345
float x
Definition: Vector2.h:49
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
ObjectGuid const & GetGUID() const
Definition: Object.h:105
float HorzSpeed
Definition: MovementPackets.h:346
float VertSpeed
Definition: MovementPackets.h:348

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendPeriodicAuraLog ( SpellPeriodicAuraLogInfo pInfo)
Todo:
: should send more logs in one packet when multistrike
Todo:
: implement debug info
4872 {
4873  AuraEffect const* aura = info->auraEff;
4875  data.TargetGUID = GetGUID();
4876  data.CasterGUID = aura->GetCasterGUID();
4877  data.SpellID = aura->GetId();
4878  data.LogData.Initialize(this);
4879 
4882  spellLogEffect.Effect = aura->GetAuraType();
4883  spellLogEffect.Amount = info->damage;
4884  spellLogEffect.OverHealOrKill = info->overDamage;
4885  spellLogEffect.SchoolMaskOrPower = aura->GetSpellInfo()->GetSchoolMask();
4886  spellLogEffect.AbsorbedOrAmplitude = info->absorb;
4887  spellLogEffect.Resisted = info->resist;
4888  spellLogEffect.Crit = info->critical;
4889  spellLogEffect.Multistrike = false; // NYI
4891 
4892  data.Effects.push_back(spellLogEffect);
4893 
4894  SendCombatLogMessage(&data);
4895 }
Definition: SpellAuraEffects.h:30
int32 Resisted
Definition: CombatLogPackets.h:172
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:46
void Initialize(Unit const *unit)
Definition: SpellPackets.cpp:91
ObjectGuid GetCasterGUID() const
Definition: SpellAuraEffects.h:40
int32 SchoolMaskOrPower
Definition: CombatLogPackets.h:170
uint32 GetId() const
Definition: SpellAuraEffects.h:47
std::vector< SpellLogEffect > Effects
Definition: CombatLogPackets.h:185
Definition: CombatLogPackets.h:156
AuraType GetAuraType() const
Definition: SpellAuraEffects.h:54
bool Multistrike
Definition: CombatLogPackets.h:174
int32 OverHealOrKill
Definition: CombatLogPackets.h:169
Spells::SpellCastLogData LogData
Definition: CombatLogPackets.h:38
int32 Amount
Definition: CombatLogPackets.h:168
ObjectGuid CasterGUID
Definition: CombatLogPackets.h:183
int32 AbsorbedOrAmplitude
Definition: CombatLogPackets.h:171
ObjectGuid const & GetGUID() const
Definition: Object.h:105
int32 Effect
Definition: CombatLogPackets.h:167
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
void SendCombatLogMessage(WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
Definition: Unit.cpp:16597
int32 SpellID
Definition: CombatLogPackets.h:184
ObjectGuid TargetGUID
Definition: CombatLogPackets.h:182

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendPetActionFeedback ( uint8  msg)

-------—Pet responses methods--------------—

12707 {
12708  Unit* owner = GetOwner();
12709  if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
12710  return;
12711 
12713  data << uint8(msg);
12714  owner->ToPlayer()->GetSession()->SendPacket(&data);
12715 }
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
uint8_t uint8
Definition: g3dmath.h:164
Definition: ObjectGuid.h:33
Definition: Opcodes.h:1333
Unit * GetOwner() const
Definition: Unit.cpp:7542
Definition: Unit.h:1305
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendPetAIReaction ( ObjectGuid  guid)
12730 {
12731  Unit* owner = GetOwner();
12732  if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
12733  return;
12734 
12736  packet.UnitGUID = guid;
12737  packet.Reaction = AI_REACTION_HOSTILE;
12738  owner->ToPlayer()->SendDirectMessage(packet.Write());
12739 }
WorldPacket const * Write() override
Definition: CombatPackets.cpp:89
ObjectGuid UnitGUID
Definition: CombatPackets.h:129
uint32 Reaction
Definition: CombatPackets.h:130
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:4355
Definition: ObjectGuid.h:33
Unit * GetOwner() const
Definition: Unit.cpp:7542
Definition: CombatPackets.h:122
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendPetTalk ( uint32  pettalk)
12718 {
12719  Unit* owner = GetOwner();
12720  if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
12721  return;
12722 
12723  WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4);
12724  data << GetGUID();
12725  data << uint32(pettalk);
12726  owner->ToPlayer()->GetSession()->SendPacket(&data);
12727 }
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Unit * GetOwner() const
Definition: Unit.cpp:7542
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:1305
Definition: WorldPacket.h:26
Definition: Opcodes.h:1334

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendPlaySpellVisualKit ( uint32  id,
uint32  type 
)
14512 {
14513  WorldPackets::Spells::PlaySpellVisualKit playSpellVisualKit;
14514  playSpellVisualKit.Unit = GetGUID();
14515  playSpellVisualKit.KitRecID = id;
14516  playSpellVisualKit.KitType = type;
14517  playSpellVisualKit.Duration = 0;
14518  SendMessageToSet(playSpellVisualKit.Write(), true);
14519 }
Definition: SpellPackets.h:641
uint32 Duration
Definition: SpellPackets.h:651
int32 KitType
Definition: SpellPackets.h:650
ObjectGuid Unit
Definition: SpellPackets.h:648
int32 KitRecID
Definition: SpellPackets.h:649
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
WorldPacket const * Write() override
Definition: SpellPackets.cpp:656

+ Here is the call graph for this function:

void Unit::SendRemoveFromThreatListOpcode ( HostileReference pHostileReference)
15558 {
15560  packet.UnitGUID = GetGUID();
15561  packet.AboutGUID = pHostileReference->getUnitGuid();
15562  SendMessageToSet(packet.Write(), false);
15563 }
ObjectGuid UnitGUID
Definition: CombatPackets.h:119
ObjectGuid getUnitGuid() const
Definition: ThreatManager.h:107
Definition: CombatPackets.h:111
ObjectGuid AboutGUID
Definition: CombatPackets.h:118
WorldPacket const * Write() override
Definition: CombatPackets.cpp:81
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendSetPlayHoverAnim ( bool  enable)
16124 {
16126  data.UnitGUID = GetGUID();
16127  data.PlayHoverAnim = enable;
16128 
16129  SendMessageToSet(data.Write(), true);
16130 }
Definition: MiscPackets.h:713
bool PlayHoverAnim
Definition: MiscPackets.h:721
ObjectGuid UnitGUID
Definition: MiscPackets.h:720
ObjectGuid const & GetGUID() const
Definition: Object.h:105
WorldPacket const * Write() override
Definition: MiscPackets.cpp:559
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

void Unit::SendSetVehicleRecId ( uint32  vehicleId)
16107 {
16108  if (Player* player = ToPlayer())
16109  {
16111  moveSetVehicleRec.MoverGUID = GetGUID();
16112  moveSetVehicleRec.SequenceIndex = m_movementCounter++;
16113  moveSetVehicleRec.VehicleRecID = vehicleId;
16114  player->SendDirectMessage(moveSetVehicleRec.Write());
16115  }
16116 
16118  setVehicleRec.VehicleGUID = GetGUID();
16119  setVehicleRec.VehicleRecID = vehicleId;
16120  SendMessageToSet(setVehicleRec.Write(), true);
16121 }
ObjectGuid MoverGUID
Definition: VehiclePackets.h:35
WorldPacket const * Write() override
Definition: VehiclePackets.cpp:35
Definition: VehiclePackets.h:51
ObjectGuid VehicleGUID
Definition: VehiclePackets.h:58
Player * ToPlayer()
Definition: Object.h:191
WorldPacket const * Write() override
Definition: VehiclePackets.cpp:20
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
int32 VehicleRecID
Definition: VehiclePackets.h:59
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 SequenceIndex
Definition: VehiclePackets.h:36
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: VehiclePackets.h:28
int32 VehicleRecID
Definition: VehiclePackets.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendSpellDamageImmune ( Unit target,
uint32  spellId,
bool  isPeriodic 
)
4916 {
4918  spellOrDamageImmune.CasterGUID = GetGUID();
4919  spellOrDamageImmune.VictimGUID = target->GetGUID();
4920  spellOrDamageImmune.SpellID = spellId;
4921  spellOrDamageImmune.IsPeriodic = isPeriodic;
4922  SendMessageToSet(spellOrDamageImmune.Write(), true);
4923 }
ObjectGuid VictimGUID
Definition: CombatLogPackets.h:299
WorldPacket const * Write() override
Definition: CombatLogPackets.cpp:253
Definition: CombatLogPackets.h:291
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid CasterGUID
Definition: CombatLogPackets.h:298
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
uint32 SpellID
Definition: CombatLogPackets.h:300
bool IsPeriodic
Definition: CombatLogPackets.h:301

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendSpellDamageResist ( Unit target,
uint32  spellId 
)
4907 {
4909  procResist.Caster = GetGUID();
4910  procResist.SpellID = spellId;
4911  procResist.Target = target->GetGUID();
4912  SendMessageToSet(procResist.Write(), true);
4913 }
int32 SpellID
Definition: CombatLogPackets.h:286
Definition: CombatLogPackets.h:277
ObjectGuid Caster
Definition: CombatLogPackets.h:284
WorldPacket const * Write() override
Definition: CombatLogPackets.cpp:235
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid Target
Definition: CombatLogPackets.h:285
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

void Unit::SendSpellMiss ( Unit target,
uint32  spellID,
SpellMissInfo  missInfo 
)
4898 {
4900  spellMissLog.SpellID = spellID;
4901  spellMissLog.Caster = GetGUID();
4902  spellMissLog.Entries.emplace_back(target->GetGUID(), missInfo);
4903  SendMessageToSet(spellMissLog.Write(), true);
4904 }
WorldPacket const * Write() override
Definition: CombatLogPackets.cpp:224
Definition: CombatLogPackets.h:265
std::vector< SpellLogMissEntry > Entries
Definition: CombatLogPackets.h:274
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
ObjectGuid Caster
Definition: CombatLogPackets.h:273
int32 SpellID
Definition: CombatLogPackets.h:272

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendSpellNonMeleeDamageLog ( SpellNonMeleeDamage const log)
4840 {
4842  packet.Me = log->target->GetGUID();
4843  packet.CasterGUID = log->attacker->GetGUID();
4844  packet.SpellID = log->SpellID;
4845  packet.Damage = log->damage;
4846  if (log->damage > log->preHitHealth)
4847  packet.Overkill = log->damage - log->preHitHealth;
4848  else
4849  packet.Overkill = 0;
4850 
4851  packet.SchoolMask = log->schoolMask;
4852  packet.ShieldBlock = log->blocked;
4853  packet.Resisted = log->resist;
4854  packet.Absorbed = log->absorb;
4855  packet.Periodic = log->periodicLog;
4856  packet.Flags = log->HitInfo;
4857  SendCombatLogMessage(&packet);
4858 }
ObjectGuid CasterGUID
Definition: CombatLogPackets.h:92
int32 Resisted
Definition: CombatLogPackets.h:89
int32 SpellID
Definition: CombatLogPackets.h:88
int32 Absorbed
Definition: CombatLogPackets.h:85
bool Periodic
Definition: CombatLogPackets.h:90
TC_SHARED_API::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions,::google::protobuf::internal::EnumTypeTraits< ::bgs::protocol::LogOption,::bgs::protocol::LogOption_IsValid >, 14, false > log
ObjectGuid Me
Definition: CombatLogPackets.h:87
int32 Overkill
Definition: CombatLogPackets.h:96
uint8 SchoolMask
Definition: CombatLogPackets.h:91
int32 Damage
Definition: CombatLogPackets.h:93
int32 Flags
Definition: CombatLogPackets.h:95
int32 ShieldBlock
Definition: CombatLogPackets.h:86
void SendCombatLogMessage(WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
Definition: Unit.cpp:16597
Definition: CombatLogPackets.h:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendTeleportPacket ( Position pos)
15422 {
15423  // SMSG_MOVE_UPDATE_TELEPORT is sent to nearby players to signal the teleport
15424  // SMSG_MOVE_TELEPORT is sent to self in order to trigger CMSG_MOVE_TELEPORT_ACK and update the position server side
15425 
15426  WorldPackets::Movement::MoveUpdateTeleport moveUpdateTeleport;
15427  moveUpdateTeleport.movementInfo = &m_movementInfo;
15428 
15429  if (GetTypeId() == TYPEID_PLAYER)
15430  {
15432  moveTeleport.MoverGUID = GetGUID();
15433  moveTeleport.Pos.Relocate(pos);
15434  if (TransportBase* transportBase = GetDirectTransport())
15435  transportBase->CalculatePassengerOffset(moveTeleport.Pos.m_positionX, moveTeleport.Pos.m_positionY, moveTeleport.Pos.m_positionZ);
15436  moveTeleport.TransportGUID = GetTransGUID();
15437  moveTeleport.Facing = pos.GetOrientation();
15438  moveTeleport.SequenceIndex = m_movementCounter++;
15439  ToPlayer()->SendDirectMessage(moveTeleport.Write());
15440  }
15441  else
15442  {
15443  // This is the only packet sent for creatures which contains MovementInfo structure
15444  // we do not update m_movementInfo for creatures so it needs to be done manually here
15445  moveUpdateTeleport.movementInfo->guid = GetGUID();
15446  moveUpdateTeleport.movementInfo->pos.Relocate(pos);
15447  moveUpdateTeleport.movementInfo->time = getMSTime();
15448  }
15449 
15450  // Broadcast the packet to everyone except self.
15451  SendMessageToSet(moveUpdateTeleport.Write(), false);
15452 }
Definition: MovementPackets.h:233
Position Pos
Definition: MovementPackets.h:240
float Facing
Definition: MovementPackets.h:245
ObjectGuid GetTransGUID() const override
Definition: Unit.cpp:14355
WorldPacket const * Write() override
Definition: MovementPackets.cpp:513
WorldPacket const * Write() override
Definition: MovementPackets.cpp:538
uint32 SequenceIndex
Definition: MovementPackets.h:242
float m_positionY
Definition: Position.h:53
MovementInfo m_movementInfo
Definition: Object.h:612
ObjectGuid MoverGUID
Definition: MovementPackets.h:243
uint32 getMSTime()
Definition: Timer.h:24
Definition: MovementPackets.h:258
float m_positionX
Definition: Position.h:52
Position pos
Definition: Object.h:273
Player * ToPlayer()
Definition: Object.h:191
Definition: VehicleDefines.h:119
uint32 time
Definition: Object.h:274
TypeID GetTypeId() const
Definition: Object.h:113
float GetOrientation() const
Definition: Position.h:107
void Relocate(float x, float y)
Definition: Position.h:67
Optional< ObjectGuid > TransportGUID
Definition: MovementPackets.h:244
TransportBase * GetDirectTransport() const
Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) ...
Definition: Unit.cpp:14365
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
float m_positionZ
Definition: Position.h:54
ObjectGuid guid
Definition: Object.h:270
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
MovementInfo * movementInfo
Definition: MovementPackets.h:265

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SendThreatListUpdate ( )
15512 {
15513  if (!getThreatManager().isThreatListEmpty())
15514  {
15516  packet.UnitGUID = GetGUID();
15518  packet.ThreatList.reserve(tlist.size());
15519  for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr)
15520  {
15522  info.UnitGUID = (*itr)->getUnitGuid();
15523  info.Threat = (*itr)->getThreat() * 100;
15524  packet.ThreatList.push_back(info);
15525  }
15526  SendMessageToSet(packet.Write(), false);
15527  }
15528 }
ObjectGuid UnitGUID
Definition: CombatPackets.h:95
Definition: CombatPackets.h:82
ThreatContainer::StorageType const & getThreatList() const
Definition: ThreatManager.h:263
ObjectGuid UnitGUID
Definition: CombatPackets.h:84
int32 Threat
Definition: CombatPackets.h:85
WorldPacket const * Write() override
Definition: CombatPackets.cpp:54
std::vector< ThreatInfo > ThreatList
Definition: CombatPackets.h:96
ObjectGuid const & GetGUID() const
Definition: Object.h:105
std::list< HostileReference * > StorageType
Definition: ThreatManager.h:149
ThreatManager & getThreatManager()
Definition: Unit.h:1998
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: CombatPackets.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetAI ( UnitAI newAI)
inline
1332 { i_AI = newAI; }
UnitAI * i_AI
Definition: Unit.h:2242

+ Here is the caller graph for this function:

void Unit::SetAIAnimKitId ( uint16  animKitId)
13466 {
13467  if (_aiAnimKitId == animKitId)
13468  return;
13469 
13470  if (animKitId && !sAnimKitStore.LookupEntry(animKitId))
13471  return;
13472 
13473  _aiAnimKitId = animKitId;
13474 
13476  data.Unit = GetGUID();
13477  data.AnimKitID = animKitId;
13478  SendMessageToSet(data.Write(), true);
13479 }
uint16 AnimKitID
Definition: MiscPackets.h:688
WorldPacket const * Write() override
Definition: MiscPackets.cpp:535
Definition: MiscPackets.h:680
uint16 _aiAnimKitId
Definition: Unit.h:2358
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid Unit
Definition: MiscPackets.h:687
DBCStorage< AnimKitEntry > sAnimKitStore(AnimKitfmt)
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

void Unit::SetArmor ( int32  val)
inline
void SetResistance(SpellSchools school, int32 val)
Definition: Unit.h:1424
Definition: SharedDefines.h:274

+ Here is the caller graph for this function:

void Unit::SetAttackTime ( WeaponAttackType  att,
uint32  val 
)
inline
Definition: UpdateFields.h:113
float m_modAttackSpeedPct[3]
Definition: Unit.h:1945
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:1067

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::setAttackTimer ( WeaponAttackType  type,
uint32  time 
)
inline
1354 { m_attackTimer[type] = time; }
uint32 m_attackTimer[MAX_ATTACK]
Definition: Unit.h:2251

+ Here is the caller graph for this function:

void Unit::SetAuraStack ( uint32  spellId,
Unit target,
uint32  stack 
)
14503 {
14504  Aura* aura = target->GetAura(spellId, GetGUID());
14505  if (!aura)
14506  aura = AddAura(spellId, target);
14507  if (aura && stack)
14508  aura->SetStackAmount(stack);
14509 }
void SetStackAmount(uint8 num)
Definition: SpellAuras.cpp:930
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4151
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:14463
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SpellAuras.h:116

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetBaseWeaponDamage ( WeaponAttackType  attType,
WeaponDamageRange  damageRange,
float  value 
)
inline
1972 { m_weaponDamage[attType][damageRange] = value; }
const FieldDescriptor value
Definition: descriptor.h:1522
float m_weaponDamage[MAX_ATTACK][2]
Definition: Unit.h:2286

+ Here is the caller graph for this function:

virtual void Unit::SetCanDualWield ( bool  value)
inlinevirtual

Reimplemented in Creature.

1360 { m_canDualWield = value; }
bool m_canDualWield
Definition: Unit.h:1367
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

bool Unit::SetCanFly ( bool  enable)
15900 {
15902  return false;
15903 
15904  if (enable)
15905  {
15908  SetFall(false);
15909  }
15910  else
15911  {
15913  if (!IsLevitating())
15914  SetFall(true);
15915  }
15916 
15917  static OpcodeServer const flyOpcodeTable[2][2] =
15918  {
15921  };
15922 
15923  bool player = GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER;
15924 
15925  if (player)
15926  {
15927  WorldPackets::Movement::MoveSetFlag packet(flyOpcodeTable[enable][1]);
15928  packet.MoverGUID = GetGUID();
15929  packet.SequenceIndex = m_movementCounter++;
15930  SendMessageToSet(packet.Write(), true);
15931  }
15932  else
15933  {
15934  WorldPackets::Movement::MoveSplineSetFlag packet(flyOpcodeTable[enable][0]);
15935  packet.MoverGUID = GetGUID();
15936  SendMessageToSet(packet.Write(), true);
15937  }
15938 
15939  return true;
15940 }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
Definition: Opcodes.h:1282
Definition: Opcodes.h:1236
Definition: Unit.h:799
bool IsLevitating() const
Definition: Unit.h:1667
Definition: Unit.h:801
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
OpcodeServer
Definition: Opcodes.h:725
Definition: Unit.h:796
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
Definition: MovementPackets.h:165
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Opcodes.h:1265
Definition: ObjectGuid.h:33
Definition: MovementPackets.h:155
Definition: Unit.h:816
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
bool SetFall(bool enable)
Definition: Unit.cpp:15864
Definition: Opcodes.h:1286

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetCanModifyStats ( bool  modifyStats)
inline
1960 { m_canModifyStats = modifyStats; }
bool m_canModifyStats
Definition: Unit.h:2287

+ Here is the caller graph for this function:

void Unit::SetCantProc ( bool  apply)
13080 {
13081  if (apply)
13082  ++m_procDeep;
13083  else
13084  {
13085  ASSERT(m_procDeep);
13086  --m_procDeep;
13087  }
13088 }
void apply(T *val)
Definition: ByteConverter.h:41
int32 m_procDeep
Definition: Unit.h:2261
#define ASSERT
Definition: Errors.h:55

+ Here is the caller graph for this function:

void Unit::SetChannelObjectGuid ( ObjectGuid  guid)
inline
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
Definition: UpdateFields.h:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetCharm ( Unit target,
bool  apply 
)
Todo:
maybe we can use this flag to check if controlled by player
7816 {
7817  if (apply)
7818  {
7819  if (GetTypeId() == TYPEID_PLAYER)
7820  {
7821  if (!AddGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()))
7822  TC_LOG_FATAL("entities.unit", "Player %s is trying to charm unit %u, but it already has a charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmGUID().ToString().c_str());
7823 
7824  charm->m_ControlledByPlayer = true;
7826  charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
7827  }
7828  else
7829  charm->m_ControlledByPlayer = false;
7830 
7831  // PvP, FFAPvP
7832  charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1));
7833 
7834  if (!charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()))
7835  TC_LOG_FATAL("entities.unit", "Unit %u is being charmed, but it already has a charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str());
7836 
7837  _isWalkingBeforeCharm = charm->IsWalking();
7839  charm->SetWalk(false);
7840 
7841  m_Controlled.insert(charm);
7842  }
7843  else
7844  {
7845  if (GetTypeId() == TYPEID_PLAYER)
7846  {
7847  if (!RemoveGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()))
7848  TC_LOG_FATAL("entities.unit", "Player %s is trying to uncharm unit %u, but it has another charmed unit %s", GetName().c_str(), charm->GetEntry(), GetCharmGUID().ToString().c_str());
7849  }
7850 
7851  if (!charm->RemoveGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()))
7852  TC_LOG_FATAL("entities.unit", "Unit %u is being uncharmed, but it has another charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str());
7853 
7854  if (charm->GetTypeId() == TYPEID_PLAYER)
7855  {
7856  charm->m_ControlledByPlayer = true;
7857  charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
7858  charm->ToPlayer()->UpdatePvPState();
7859  }
7860  else if (Player* player = charm->GetCharmerOrOwnerPlayerOrPlayerItself())
7861  {
7862  charm->m_ControlledByPlayer = true;
7863  charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
7864  charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, player->GetByteValue(UNIT_FIELD_BYTES_2, 1));
7865  }
7866  else
7867  {
7868  charm->m_ControlledByPlayer = false;
7869  charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
7870  charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0);
7871  }
7872 
7873  if (charm->IsWalking() != _isWalkingBeforeCharm)
7874  charm->SetWalk(_isWalkingBeforeCharm);
7875 
7876  if (charm->GetTypeId() == TYPEID_PLAYER
7877  || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION)
7878  || charm->GetOwnerGUID() != GetGUID())
7879  {
7880  m_Controlled.erase(charm);
7881  }
7882  }
7883 }
Definition: UpdateFields.h:146
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1706
std::string const & GetName() const
Definition: Object.h:479
Definition: UpdateFields.h:85
Definition: UpdateFields.h:82
void apply(T *val)
Definition: ByteConverter.h:41
Definition: Unit.h:859
TypeID GetTypeId() const
Definition: Object.h:113
bool _isWalkingBeforeCharm
Are we walking before we were charmed?
Definition: Unit.h:2356
bool AddGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1031
bool RemoveGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1049
ControlList m_Controlled
Definition: Unit.h:1738
Definition: Unit.h:676
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:210
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::SetCharmedBy ( Unit charmer,
CharmType  type,
AuraApplication const aurApp = NULL 
)
Todo:
CombatStop(true) may cause crash (interrupt spells)
14025 {
14026  if (!charmer)
14027  return false;
14028 
14029  // dismount players when charmed
14030  if (GetTypeId() == TYPEID_PLAYER)
14032 
14033  if (charmer->GetTypeId() == TYPEID_PLAYER)
14035 
14036  ASSERT(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER);
14037  ASSERT((type == CHARM_TYPE_VEHICLE) == IsVehicle());
14038 
14039  TC_LOG_DEBUG("entities.unit", "SetCharmedBy: charmer %u (%s), charmed %u (%s), type %u.", charmer->GetEntry(), charmer->GetGUID().ToString().c_str(), GetEntry(), GetGUID().ToString().c_str(), uint32(type));
14040 
14041  if (this == charmer)
14042  {
14043  TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Unit %u (%s) is trying to charm itself!", GetEntry(), GetGUID().ToString().c_str());
14044  return false;
14045  }
14046 
14047  //if (HasUnitState(UNIT_STATE_UNATTACKABLE))
14048  // return false;
14049 
14050  if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetTransport())
14051  {
14052  TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Player on transport is trying to charm %u (%s)", GetEntry(), GetGUID().ToString().c_str());
14053  return false;
14054  }
14055 
14056  // Already charmed
14057  if (!GetCharmerGUID().IsEmpty())
14058  {
14059  TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (%s) has already been charmed but %u (%s) is trying to charm it!", GetEntry(), GetGUID().ToString().c_str(), charmer->GetEntry(), charmer->GetGUID().ToString().c_str());
14060  return false;
14061  }
14062 
14063  CastStop();
14064  CombatStop();
14065  DeleteThreatList();
14066 
14067  Player* playerCharmer = charmer->ToPlayer();
14068 
14069  // Charmer stop charming
14070  if (playerCharmer)
14071  {
14072  playerCharmer->StopCastingCharm();
14073  playerCharmer->StopCastingBindSight();
14074  }
14075 
14076  // Charmed stop charming
14077  if (GetTypeId() == TYPEID_PLAYER)
14078  {
14079  ToPlayer()->StopCastingCharm();
14080  ToPlayer()->StopCastingBindSight();
14081  }
14082 
14083  // StopCastingCharm may remove a possessed pet?
14084  if (!IsInWorld())
14085  {
14086  TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (%s) is not in world but %u (%s) is trying to charm it!", GetEntry(), GetGUID().ToString().c_str(), charmer->GetEntry(), charmer->GetGUID().ToString().c_str());
14087  return false;
14088  }
14089 
14090  // charm is set by aura, and aura effect remove handler was called during apply handler execution
14091  // prevent undefined behaviour
14092  if (aurApp && aurApp->GetRemoveMode())
14093  return false;
14094 
14096  setFaction(charmer->getFaction());
14097 
14098  // Set charmed
14099  charmer->SetCharm(this, true);
14100 
14101  if (GetTypeId() == TYPEID_UNIT)
14102  {
14103  ToCreature()->AI()->OnCharmed(true);
14105  }
14106  else
14107  {
14108  Player* player = ToPlayer();
14109  if (player->isAFK())
14110  player->ToggleAFK();
14111  player->SetClientControl(this, false);
14112  }
14113 
14114  // charm is set by aura, and aura effect remove handler was called during apply handler execution
14115  // prevent undefined behaviour
14116  if (aurApp && aurApp->GetRemoveMode())
14117  return false;
14118 
14119  // Pets already have a properly initialized CharmInfo, don't overwrite it.
14120  if (type != CHARM_TYPE_VEHICLE && !GetCharmInfo())
14121  {
14122  InitCharmInfo();
14123  if (type == CHARM_TYPE_POSSESS)
14125  else
14127  }
14128 
14129  if (playerCharmer)
14130  {
14131  switch (type)
14132  {
14133  case CHARM_TYPE_VEHICLE:
14135  playerCharmer->SetClientControl(this, true);
14136  playerCharmer->VehicleSpellInitialize();
14137  break;
14138  case CHARM_TYPE_POSSESS:
14142  playerCharmer->SetClientControl(this, true);
14143  playerCharmer->PossessSpellInitialize();
14144  break;
14145  case CHARM_TYPE_CHARM:
14146  if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
14147  {
14148  CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate();
14149  if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
14150  {
14151  // to prevent client crash
14153 
14154  // just to enable stat window
14155  if (GetCharmInfo())
14156  GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
14157 
14158  // if charmed two demons the same session, the 2nd gets the 1st one's name
14159  SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped
14160  }
14161  }
14162  playerCharmer->CharmSpellInitialize();
14163  break;
14164  default:
14165  case CHARM_TYPE_CONVERT:
14166  break;
14167  }
14168  }
14169  return true;
14170 }
void SetPetNumber(uint32 petnumber, bool statwindow)
Definition: Unit.cpp:12048
void MoveIdle()
Definition: MotionMaster.cpp:185
bool IsVehicle() const
Definition: Unit.h:1406
void InitPossessCreateSpells()
Definition: Unit.cpp:11902
Definition: UpdateFields.h:96
void InitCharmCreateSpells()
Definition: Unit.cpp:11937
uint32 getFaction() const
Definition: Unit.h:1466
Definition: SharedDefines.h:3556
void AddUnitState(uint32 f)
Definition: Unit.h:1394
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void OnCharmed(bool apply) override
Definition: CreatureAI.cpp:32
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
Definition: Unit.h:1185
Definition: Unit.h:675
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void CastStop(uint32 except_spellid=0)
Definition: Unit.cpp:862
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
#define sObjectMgr
Definition: ObjectMgr.h:1567
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
Definition: Unit.h:233
uint32 _oldFactionId
faction before charm
Definition: Unit.h:2355
Player * ToPlayer()
Definition: Object.h:191
void setFaction(uint32 faction)
Definition: Unit.h:1467
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: UpdateFields.h:126
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080
std::string ToString() const
Definition: Position.cpp:160
CreatureAI * AI() const
Definition: Creature.h:525
Definition: Unit.h:566
Definition: SharedDefines.h:174
Definition: Unit.h:1183
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Transport * GetTransport() const
Definition: Object.h:602
Definition: ObjectGuid.h:33
Definition: Unit.h:1184
void DeleteThreatList()
Definition: Unit.cpp:10700
Definition: UpdateFields.h:109
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:210
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:1186
uint8 getClass() const
Definition: Unit.h:1413
CharmInfo * InitCharmInfo()
Definition: Unit.cpp:11836
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
uint32 GetEntry() const
Definition: Object.h:107
uint32_t uint32
Definition: g3dmath.h:168
bool IsInWorld() const
Definition: Object.h:100
Definition: SharedDefines.h:175
Definition: Unit.h:697
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
Definition: Creature.h:79
uint32 type
Definition: Creature.h:116
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: SpellAuraDefines.h:138
void SetCharm(Unit *target, bool apply)
Definition: Unit.cpp:7815

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetCharmerGUID ( ObjectGuid  owner)
inline
Definition: UpdateFields.h:85
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120

+ Here is the call graph for this function:

bool Unit::SetCollision ( bool  disable)
16072 {
16074  return false;
16075 
16076  if (disable)
16078  else
16080 
16081  static OpcodeServer const collisionOpcodeTable[2][2] =
16082  {
16085  };
16086 
16087  bool player = GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER;
16088 
16089  if (player)
16090  {
16091  WorldPackets::Movement::MoveSetFlag packet(collisionOpcodeTable[disable][1]);
16092  packet.MoverGUID = GetGUID();
16093  packet.SequenceIndex = m_movementCounter++;
16094  SendMessageToSet(packet.Write(), true);
16095  }
16096  else
16097  {
16098  WorldPackets::Movement::MoveSplineSetFlag packet(collisionOpcodeTable[disable][0]);
16099  packet.MoverGUID = GetGUID();
16100  SendMessageToSet(packet.Write(), true);
16101  }
16102 
16103  return true;
16104 }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
Definition: Opcodes.h:1229
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
OpcodeServer
Definition: Opcodes.h:725
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
Definition: MovementPackets.h:165
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
Definition: Opcodes.h:1257
Definition: Unit.h:805
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: MovementPackets.h:155
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: Opcodes.h:1259
Definition: Opcodes.h:1226

+ Here is the call graph for this function:

void Unit::SetConfused ( bool  apply)
protected
14002 {
14003  if (apply)
14004  {
14007  }
14008  else
14009  {
14010  if (IsAlive())
14011  {
14012  if (GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE)
14014  if (GetVictim())
14016  }
14017  }
14018 
14019  if (Player* player = ToPlayer())
14020  if (!player->HasUnitState(UNIT_STATE_POSSESSED))
14021  player->SetClientControl(this, !apply);
14022 }
Unit * EnsureVictim() const
Definition: Unit.h:1381
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:191
void MoveConfused()
Definition: MotionMaster.cpp:226
bool IsAlive() const
Definition: Unit.h:1692
Unit * GetVictim() const
Definition: Unit.h:1379
Definition: Unit.h:566
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SetTarget(ObjectGuid const &)=0
Definition: MotionMaster.h:42
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:151

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetContestedPvP ( Player attackedPlayer = NULL)
13139 {
13141 
13142  if (!player || (attackedPlayer && (attackedPlayer == player || (player->duel && player->duel->opponent == attackedPlayer))))
13143  return;
13144 
13145  player->SetContestedPvPTimer(30000);
13146  if (!player->HasUnitState(UNIT_STATE_ATTACK_PLAYER))
13147  {
13148  player->AddUnitState(UNIT_STATE_ATTACK_PLAYER);
13149  player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
13150  // call MoveInLineOfSight for nearby contested guards
13152  }
13154  {
13156  // call MoveInLineOfSight for nearby contested guards
13158  }
13159 }
Definition: Player.h:525
Definition: Unit.h:564
void AddUnitState(uint32 f)
Definition: Unit.h:1394
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:14630
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
Definition: UpdateFields.h:191
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetControlled ( bool  apply,
UnitState  state 
)
13809 {
13810  if (apply)
13811  {
13812  if (HasUnitState(state))
13813  return;
13814 
13815  AddUnitState(state);
13816  switch (state)
13817  {
13818  case UNIT_STATE_STUNNED:
13819  SetStunned(true);
13820  CastStop();
13821  break;
13822  case UNIT_STATE_ROOT:
13824  SetRooted(true);
13825  break;
13826  case UNIT_STATE_CONFUSED:
13828  {
13831  // SendAutoRepeatCancel ?
13832  SetConfused(true);
13833  CastStop();
13834  }
13835  break;
13836  case UNIT_STATE_FLEEING:
13838  {
13841  // SendAutoRepeatCancel ?
13842  SetFeared(true);
13843  CastStop();
13844  }
13845  break;
13846  default:
13847  break;
13848  }
13849  }
13850  else
13851  {
13852  switch (state)
13853  {
13854  case UNIT_STATE_STUNNED:
13856  return;
13857 
13858  SetStunned(false);
13859  break;
13860  case UNIT_STATE_ROOT:
13862  return;
13863 
13865  SetRooted(false);
13866  break;
13867  case UNIT_STATE_CONFUSED:
13869  return;
13870 
13871  SetConfused(false);
13872  break;
13873  case UNIT_STATE_FLEEING:
13875  return;
13876 
13877  SetFeared(false);
13878  break;
13879  default:
13880  return;
13881  }
13882 
13883  ClearUnitState(state);
13884 
13885  // Unit States might have been already cleared but auras still present. I need to check with HasAuraType
13887  SetStunned(true);
13888  else
13889  {
13891  SetRooted(true);
13892 
13894  SetConfused(true);
13895  else if (HasAuraType(SPELL_AURA_MOD_FEAR))
13896  SetFeared(true);
13897  }
13898  }
13899 }
void SetFeared(bool apply)
Definition: Unit.cpp:13971
void SetStunned(bool apply)
Definition: Unit.cpp:13901
Definition: SpellAuraDefines.h:72
void SendMeleeAttackStop(Unit *victim=NULL)
Definition: Unit.cpp:2142
void AddUnitState(uint32 f)
Definition: Unit.h:1394
Definition: SpellAuraDefines.h:67
Definition: Unit.h:561
void CastStop(uint32 except_spellid=0)
Definition: Unit.cpp:862
Definition: Unit.h:557
Definition: SpellAuraDefines.h:86
void apply(T *val)
Definition: ByteConverter.h:41
void SetConfused(bool apply)
Definition: Unit.cpp:14001
Definition: Unit.h:551
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
Definition: Unit.h:553
void SetRooted(bool apply, bool packetOnly=false)
Definition: Unit.cpp:13932
Vehicle * GetVehicle() const
Definition: Unit.h:2166
Definition: Unit.h:560
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247
Definition: SpellAuraDefines.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetCreateHealth ( uint32  val)
inline
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: UpdateFields.h:145

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetCreateMana ( uint32  val)
inline
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: UpdateFields.h:144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetCreateStat ( Stats  stat,
float  val 
)
inline
1893 { m_createStats[stat] = val; }
float m_createStats[MAX_STATS]
Definition: Unit.h:2253

+ Here is the caller graph for this function:

void Unit::SetCreatorGUID ( ObjectGuid  creator)
inline
1701 { SetGuidValue(UNIT_FIELD_CREATEDBY, creator); }
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
Definition: UpdateFields.h:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetCritterGUID ( ObjectGuid  guid)
inline
1709 { SetGuidValue(UNIT_FIELD_CRITTER, guid); }
Definition: UpdateFields.h:84
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetCurrentCastSpell ( Spell pSpell)
2774 {
2775  ASSERT(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells
2776 
2777  CurrentSpellTypes CSpellType = pSpell->GetCurrentContainer();
2778 
2779  if (pSpell == m_currentSpells[CSpellType]) // avoid breaking self
2780  return;
2781 
2782  // break same type spell if it is not delayed
2783  InterruptSpell(CSpellType, false);
2784 
2785  // special breakage effects:
2786  switch (CSpellType)
2787  {
2788  case CURRENT_GENERIC_SPELL:
2789  {
2790  // generic spells always break channeled not delayed spells
2792 
2793  // autorepeat breaking
2795  {
2796  // break autorepeat if not Auto Shot
2797  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellInfo()->Id != 75)
2798  InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
2799  m_AutoRepeatFirstCast = true;
2800  }
2801  if (pSpell->GetCastTime() > 0)
2803 
2804  break;
2805  }
2807  {
2808  // channel spells always break generic non-delayed and any channeled spells
2811 
2812  // it also does break autorepeat if not Auto Shot
2813  if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] &&
2814  m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellInfo()->Id != 75)
2815  InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
2817 
2818  break;
2819  }
2820  case CURRENT_AUTOREPEAT_SPELL:
2821  {
2822  // only Auto Shoot does not break anything
2823  if (pSpell->GetSpellInfo()->Id != 75)
2824  {
2825  // generic autorepeats break generic non-delayed and channeled non-delayed spells
2828  }
2829  // special action: set first cast flag
2830  m_AutoRepeatFirstCast = true;
2831 
2832  break;
2833  }
2834  default:
2835  break; // other spell types don't break anything now
2836  }
2837 
2838  // current spell (if it is still here) may be safely deleted now
2839  if (m_currentSpells[CSpellType])
2840  m_currentSpells[CSpellType]->SetReferencedFromCurrent(false);
2841 
2842  // set new current spell
2843  m_currentSpells[CSpellType] = pSpell;
2844  pSpell->SetReferencedFromCurrent(true);
2845 
2846  pSpell->m_selfContainer = &(m_currentSpells[pSpell->GetCurrentContainer()]);
2847 }
Definition: Unit.h:1109
uint32 Id
Definition: SpellInfo.h:329
Definition: Unit.h:565
CurrentSpellTypes
Definition: Unit.h:1106
void AddUnitState(uint32 f)
Definition: Unit.h:1394
Definition: Unit.h:1110
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
bool m_AutoRepeatFirstCast
Definition: Unit.h:2249
Definition: Unit.h:1111
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:2849
CurrentSpellTypes GetCurrentContainer() const
Definition: Spell.cpp:6566
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:614
#define ASSERT
Definition: Errors.h:55
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:601
Spell ** m_selfContainer
Definition: Spell.h:634
int32 GetCastTime() const
Definition: Spell.h:590

+ Here is the call graph for this function:

void Unit::setDeathState ( DeathState  s)
virtual

Reimplemented in Creature, and Pet.

10594 {
10595  // Death state needs to be updated before RemoveAllAurasOnDeath() is called, to prevent entering combat
10596  m_deathState = s;
10597 
10598  if (s != ALIVE && s != JUST_RESPAWNED)
10599  {
10600  CombatStop();
10601  DeleteThreatList();
10603 
10604  if (IsNonMeleeSpellCast(false))
10605  InterruptNonMeleeSpells(false);
10606 
10607  ExitVehicle(); // Exit vehicle before calling RemoveAllControlled
10608  // vehicles use special type of charm that is not removed by the next function
10609  // triggering an assert
10613  }
10614 
10615  if (s == JUST_DIED)
10616  {
10619  // remove aurastates allowing special moves
10622  if (IsInWorld())
10623  {
10624  // Only clear MotionMaster for entities that exists in world
10625  // Avoids crashes in the following conditions :
10626  // * Using 'call pet' on dead pets
10627  // * Using 'call stabled pet'
10628  // * Logging in with dead pets
10629  GetMotionMaster()->Clear(false);
10631  }
10632  StopMoving();
10633  DisableSpline();
10634  // without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
10635  // do not why since in IncreaseMaxHealth currenthealth is checked
10636  SetHealth(0);
10637  SetPower(getPowerType(), 0);
10638 
10639  // players in instance don't have ZoneScript, but they have InstanceScript
10640  if (ZoneScript* zoneScript = GetZoneScript() ? GetZoneScript() : GetInstanceScript())
10641  zoneScript->OnUnitDeath(this);
10642  }
10643  else if (s == JUST_RESPAWNED)
10644  RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground)
10645 }
void ModifyAuraState(AuraStateType flag, bool apply)
Definition: Unit.cpp:7422
void ClearAllReactives()
Definition: Unit.cpp:12841
void MoveIdle()
Definition: MotionMaster.cpp:185
Definition: Unit.h:699
void UnsummonAllTotems()
Definition: Unit.cpp:8127
void Clear(bool reset=true)
Definition: MotionMaster.h:138
Definition: Unit.h:542
InstanceScript * GetInstanceScript()
Definition: Object.cpp:1540
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
Definition: Unit.h:541
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
void ExitVehicle(Position const *exitPosition=NULL)
Definition: Unit.cpp:15321
Powers getPowerType() const
Definition: Unit.h:1444
Definition: SharedDefines.h:1771
Definition: ZoneScript.h:26
Definition: Unit.h:545
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
DeathState m_deathState
Definition: Unit.h:2259
void ClearDiminishings()
Definition: Unit.h:1346
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
void SetPower(Powers power, int32 val)
Definition: Unit.cpp:11607
Definition: SharedDefines.h:1759
void DeleteThreatList()
Definition: Unit.cpp:10700
Definition: UpdateFields.h:109
void RemoveAllControlled()
Definition: Unit.cpp:7998
ZoneScript * GetZoneScript() const
Definition: Object.h:551
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
void DisableSpline()
Definition: Unit.cpp:475
void deleteReferences()
Definition: HostileRefManager.cpp:114
void SetHealth(uint32 val)
Definition: Unit.cpp:11537
bool IsInWorld() const
Definition: Object.h:100
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743
void RemoveAllAurasOnDeath()
Definition: Unit.cpp:3953

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::SetDisableGravity ( bool  disable,
bool  packetOnly = false 
)
15819 {
15820  if (!packetOnly)
15821  {
15822  if (disable == IsLevitating())
15823  return false;
15824 
15825  if (disable)
15826  {
15829  SetFall(false);
15830  }
15831  else
15832  {
15835  SetFall(true);
15836  }
15837  }
15838 
15839  static OpcodeServer const gravityOpcodeTable[2][2] =
15840  {
15843  };
15844 
15845  bool player = GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER;
15846 
15847  if (player)
15848  {
15849  WorldPackets::Movement::MoveSetFlag packet(gravityOpcodeTable[disable][1]);
15850  packet.MoverGUID = GetGUID();
15851  packet.SequenceIndex = m_movementCounter++;
15852  SendMessageToSet(packet.Write(), true);
15853  }
15854  else
15855  {
15856  WorldPackets::Movement::MoveSplineSetFlag packet(gravityOpcodeTable[disable][0]);
15857  packet.MoverGUID = GetGUID();
15858  SendMessageToSet(packet.Write(), true);
15859  }
15860 
15861  return true;
15862 }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
Definition: Opcodes.h:1258
Definition: Unit.h:799
bool IsLevitating() const
Definition: Unit.h:1667
Definition: Unit.h:801
Definition: Opcodes.h:1260
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Opcodes.h:1230
OpcodeServer
Definition: Opcodes.h:725
Definition: Unit.h:796
Definition: Unit.h:785
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
Definition: MovementPackets.h:165
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: Opcodes.h:1227
Definition: MovementPackets.h:155
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
bool SetFall(bool enable)
Definition: Unit.cpp:15864

+ Here is the call graph for this function:

void Unit::SetDisplayId ( uint32  modelId)
virtual

Reimplemented in Creature, and Pet.

12800 {
12802  // Set Gender by modelId
12803  if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
12805 }
Definition: Unit.h:234
Definition: UpdateFields.h:96
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Creature.h:317
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080
Definition: UpdateFields.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetExtraUnitMovementFlags ( uint16  f)
inline
MovementInfo m_movementInfo
Definition: Object.h:612
void SetExtraMovementFlags(uint16 flag)
Definition: Object.h:333

+ Here is the caller graph for this function:

void Unit::SetFacingTo ( float  ori)
15778 {
15779  Movement::MoveSplineInit init(this);
15780  init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZMinusOffset(), false);
15781  if (GetTransport())
15782  init.DisableTransportPathTransformations(); // It makes no sense to target global orientation
15783  init.SetFacing(ori);
15784  init.Launch();
15785 }
float GetPositionY() const
Definition: Position.h:105
Transport * GetTransport() const
Definition: Object.h:602
Definition: MoveSplineInit.h:52
float GetPositionX() const
Definition: Position.h:104
float GetPositionZMinusOffset() const
Definition: Unit.cpp:13799

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetFacingToObject ( WorldObject const object)
Todo:
figure out under what conditions creature will move towards object instead of facing it where it currently is.
15788 {
15789  // never face when already moving
15790  if (!IsStopped())
15791  return;
15792 
15794  Movement::MoveSplineInit init(this);
15795  init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZMinusOffset());
15796  init.SetFacing(GetAngle(object)); // when on transport, GetAngle will still return global coordinates (and angle) that needs transforming
15797  init.Launch();
15798 }
bool IsStopped() const
Definition: Unit.h:2104
float GetPositionY() const
Definition: Position.h:105
float GetAngle(Position const *pos) const
Definition: Position.cpp:63
Definition: MoveSplineInit.h:52
float GetPositionX() const
Definition: Position.h:104
float GetPositionZMinusOffset() const
Definition: Unit.cpp:13799

+ Here is the call graph for this function:

void Unit::setFaction ( uint32  faction)
inline
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: UpdateFields.h:107

+ Here is the call graph for this function:

bool Unit::SetFall ( bool  enable)
15865 {
15867  return false;
15868 
15869  if (enable)
15870  {
15873  }
15874  else
15876 
15877  return true;
15878 }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:787
void SetFallTime(uint32 fallTime)
Definition: Object.h:339
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
Definition: Unit.h:788

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetFeared ( bool  apply)
protected
13972 {
13973  if (apply)
13974  {
13976 
13977  Unit* caster = NULL;
13979  if (!fearAuras.empty())
13980  caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
13981  if (!caster)
13982  caster = getAttackerForHelper();
13983  GetMotionMaster()->MoveFleeing(caster, fearAuras.empty() ? sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY) : 0); // caster == NULL processed in MoveFleeing
13984  }
13985  else
13986  {
13987  if (IsAlive())
13988  {
13991  if (GetVictim())
13993  }
13994  }
13995 
13996  if (Player* player = ToPlayer())
13997  if (!player->HasUnitState(UNIT_STATE_POSSESSED))
13998  player->SetClientControl(this, !apply);
13999 }
Unit * EnsureVictim() const
Definition: Unit.h:1381
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
void MoveFleeing(Unit *enemy, uint32 time=0)
Definition: MotionMaster.cpp:526
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SpellAuraDefines.h:67
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:663
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: MotionMaster.h:47
#define sWorld
Definition: World.h:887
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:191
Definition: World.h:283
bool IsAlive() const
Definition: Unit.h:1692
Unit * GetVictim() const
Definition: Unit.h:1379
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: Unit.h:566
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SetTarget(ObjectGuid const &)=0
Unit * getAttackerForHelper() const
Definition: Unit.cpp:7211
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:151
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::SetFeatherFall ( bool  enable,
bool  packetOnly = false 
)
15981 {
15982  if (!packetOnly)
15983  {
15985  return false;
15986 
15987  if (enable)
15989  else
15991  }
15992 
15993  static OpcodeServer const featherFallOpcodeTable[2][2] =
15994  {
15997  };
15998 
15999  bool player = GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER;
16000 
16001  if (player)
16002  {
16003  WorldPackets::Movement::MoveSetFlag packet(featherFallOpcodeTable[enable][1]);
16004  packet.MoverGUID = GetGUID();
16005  packet.SequenceIndex = m_movementCounter++;
16006  SendMessageToSet(packet.Write(), true);
16007  }
16008  else
16009  {
16010  WorldPackets::Movement::MoveSplineSetFlag packet(featherFallOpcodeTable[enable][0]);
16011  packet.MoverGUID = GetGUID();
16012  SendMessageToSet(packet.Write(), true);
16013  }
16014 
16015  return true;
16016 }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Opcodes.h:1268
OpcodeServer
Definition: Opcodes.h:725
Definition: Opcodes.h:1246
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
Definition: MovementPackets.h:165
Definition: Unit.h:803
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: Opcodes.h:1240
Definition: MovementPackets.h:155
Definition: Opcodes.h:1262
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetFullHealth ( )
inline
1440 { SetHealth(GetMaxHealth()); }
uint32 GetMaxHealth() const
Definition: Unit.h:1427
void SetHealth(uint32 val)
Definition: Unit.cpp:11537

+ Here is the caller graph for this function:

void Unit::SetHealth ( uint32  val)
11538 {
11539  if (getDeathState() == JUST_DIED)
11540  val = 0;
11541  else if (GetTypeId() == TYPEID_PLAYER && getDeathState() == DEAD)
11542  val = 1;
11543  else
11544  {
11545  uint32 maxHealth = GetMaxHealth();
11546  if (maxHealth < val)
11547  val = maxHealth;
11548  }
11549 
11551 
11552  // group update
11553  if (Player* player = ToPlayer())
11554  {
11555  if (player->GetGroup())
11556  player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP);
11557  }
11558  else if (Pet* pet = ToCreature()->ToPet())
11559  {
11560  if (pet->isControlled())
11561  pet->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP);
11562  }
11563 }
Definition: Unit.h:544
uint32 GetMaxHealth() const
Definition: Unit.h:1427
Definition: Unit.h:542
Pet * ToPet()
Definition: Unit.h:2200
Definition: Group.h:107
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: UpdateFields.h:99
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
Definition: Group.h:136
Definition: Pet.h:46
DeathState getDeathState() const
Definition: Unit.h:1695

+ Here is the call graph for this function:

bool Unit::SetHover ( bool  enable,
bool  packetOnly = false 
)

No need to check height on ascent

16019 {
16020  if (!packetOnly)
16021  {
16022  if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
16023  return false;
16024 
16025  float hoverHeight = GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
16026 
16027  if (enable)
16028  {
16031  if (hoverHeight)
16032  UpdateHeight(GetPositionZ() + hoverHeight);
16033  }
16034  else
16035  {
16037  if (hoverHeight)
16038  {
16039  float newZ = GetPositionZ() - hoverHeight;
16041  UpdateHeight(newZ);
16042  }
16043  }
16044  }
16045 
16046  static OpcodeServer const hoverOpcodeTable[2][2] =
16047  {
16050  };
16051 
16052  bool player = GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER;
16053 
16054  if (player)
16055  {
16056  WorldPackets::Movement::MoveSetFlag packet(hoverOpcodeTable[enable][1]);
16057  packet.MoverGUID = GetGUID();
16058  packet.SequenceIndex = m_movementCounter++;
16059  SendMessageToSet(packet.Write(), true);
16060  }
16061  else
16062  {
16063  WorldPackets::Movement::MoveSplineSetFlag packet(hoverOpcodeTable[enable][0]);
16064  packet.MoverGUID = GetGUID();
16065  SendMessageToSet(packet.Write(), true);
16066  }
16067 
16068  return true;
16069 }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
void UpdateAllowedPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1834
Definition: Opcodes.h:1288
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Player * ToPlayer()
Definition: Object.h:191
Definition: UpdateFields.h:160
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:804
OpcodeServer
Definition: Opcodes.h:725
float GetPositionY() const
Definition: Position.h:105
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
float GetPositionZ() const
Definition: Position.h:106
Definition: Opcodes.h:1266
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
Definition: MovementPackets.h:165
void UpdateHeight(float newZ)
Only server-side height update, does not broadcast to client.
Definition: Unit.cpp:15504
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: MovementPackets.h:155
Definition: Opcodes.h:1283
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
float GetPositionX() const
Definition: Position.h:104
Definition: Opcodes.h:1243

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetInCombatState ( bool  PvP,
Unit enemy = NULL 
)
9896 {
9897  // only alive units can be in combat
9898  if (!IsAlive())
9899  return;
9900 
9901  if (PvP)
9902  m_CombatTimer = 5000;
9903 
9905  return;
9906 
9908 
9909  if (Creature* creature = ToCreature())
9910  {
9911  // Set home position at place of engaging combat for escorted creatures
9912  if ((IsAIEnabled && creature->AI()->IsEscorted()) ||
9915  creature->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
9916 
9917  if (enemy)
9918  {
9919  if (IsAIEnabled)
9920  {
9921  creature->AI()->EnterCombat(enemy);
9922  RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); // unit has engaged in combat, remove immunity so players can fight back
9923  }
9924  if (creature->GetFormation())
9925  creature->GetFormation()->MemberAttackStart(creature, enemy);
9926  }
9927 
9928  if (IsPet())
9929  {
9930  UpdateSpeed(MOVE_RUN, true);
9931  UpdateSpeed(MOVE_SWIM, true);
9932  UpdateSpeed(MOVE_FLIGHT, true);
9933  }
9934 
9935  if (!(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT))
9936  Dismount();
9937  }
9938 
9939  for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
9940  {
9941  (*itr)->SetInCombatState(PvP, enemy);
9942  (*itr)->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
9943  }
9944 }
Definition: Unit.h:605
void Dismount()
Definition: Unit.cpp:9734
void UpdateSpeed(UnitMoveType mtype, bool forced)
Definition: Unit.cpp:10378
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool IsInCombat() const
Definition: Unit.h:1584
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:663
Definition: Creature.h:467
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
bool IsAIEnabled
Definition: Unit.h:2161
Definition: Unit.h:681
Definition: Unit.h:602
Definition: Unit.h:692
float GetOrientation() const
Definition: Position.h:107
Definition: SharedDefines.h:3667
bool IsAlive() const
Definition: Unit.h:1692
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
Definition: Unit.h:571
ControlList m_Controlled
Definition: Unit.h:1738
bool IsPet() const
Definition: Unit.h:1403
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
Definition: Unit.h:600
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
uint32 m_CombatTimer
Definition: Unit.h:2341
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
Definition: Unit.h:684
float GetPositionX() const
Definition: Position.h:104
Definition: MotionMaster.h:39
Definition: MotionMaster.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetInCombatWith ( Unit enemy)
9841 {
9842  Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf();
9843  if (eOwner->IsPvP() || eOwner->IsFFAPvP())
9844  {
9845  SetInCombatState(true, enemy);
9846  return;
9847  }
9848 
9849  // check for duel
9850  if (eOwner->GetTypeId() == TYPEID_PLAYER && eOwner->ToPlayer()->duel)
9851  {
9852  Unit const* myOwner = GetCharmerOrOwnerOrSelf();
9853  if (((Player const*)eOwner)->duel->opponent == myOwner)
9854  {
9855  SetInCombatState(true, enemy);
9856  return;
9857  }
9858  }
9859  SetInCombatState(false, enemy);
9860 }
bool IsPvP() const
Definition: Unit.h:1481
void SetInCombatState(bool PvP, Unit *enemy=NULL)
Definition: Unit.cpp:9895
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:33
bool IsFFAPvP() const
Definition: Unit.h:1482
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Unit.cpp:7632
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetInFront ( WorldObject const target)
15772 {
15774  SetOrientation(GetAngle(target));
15775 }
void SetOrientation(float orientation)
Definition: Position.h:99
Definition: Unit.h:591
float GetAngle(Position const *pos) const
Definition: Position.cpp:63
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::SetInPhase ( uint32  id,
bool  update,
bool  apply 
)
overridevirtual

Reimplemented from WorldObject.

14579 {
14580  bool res = WorldObject::SetInPhase(id, update, apply);
14581 
14582  if (!IsInWorld())
14583  return res;
14584 
14585  if (GetTypeId() == TYPEID_UNIT || (!ToPlayer()->IsGameMaster() && !ToPlayer()->GetSession()->PlayerLogout()))
14586  {
14587  HostileRefManager& refManager = getHostileRefManager();
14588  HostileReference* ref = refManager.getFirst();
14589 
14590  while (ref)
14591  {
14592  if (Unit* unit = ref->GetSource()->GetOwner())
14593  if (Creature* creature = unit->ToCreature())
14594  refManager.setOnlineOfflineState(creature, creature->IsInPhase(this));
14595 
14596  ref = ref->next();
14597  }
14598 
14599  // modify threat lists for new phasemask
14600  if (GetTypeId() != TYPEID_PLAYER)
14601  {
14602  std::list<HostileReference*> threatList = getThreatManager().getThreatList();
14603  std::list<HostileReference*> offlineThreatList = getThreatManager().getOfflineThreatList();
14604 
14605  // merge expects sorted lists
14606  threatList.sort();
14607  offlineThreatList.sort();
14608  threatList.merge(offlineThreatList);
14609 
14610  for (std::list<HostileReference*>::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
14611  if (Unit* unit = (*itr)->getTarget())
14612  unit->getHostileRefManager().setOnlineOfflineState(ToCreature(), unit->IsInPhase(this));
14613  }
14614  }
14615 
14616  for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
14617  if ((*itr)->GetTypeId() == TYPEID_UNIT)
14618  (*itr)->SetInPhase(id, true, apply);
14619 
14620  for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
14621  if (!m_SummonSlot[i].IsEmpty())
14622  if (Creature* summon = GetMap()->GetCreature(m_SummonSlot[i]))
14623  summon->SetInPhase(id, true, apply);
14624 
14626 
14627  return res;
14628 }
Map * GetMap() const
Definition: Object.h:543
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
Definition: ObjectGuid.h:32
ThreatContainer::StorageType const & getThreatList() const
Definition: ThreatManager.h:263
Definition: Creature.h:467
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
virtual bool SetInPhase(uint32 id, bool update, bool apply)
Definition: Object.cpp:2879
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
ThreatContainer::StorageType const & getOfflineThreatList() const
Definition: ThreatManager.h:264
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
bool IsInPhase(uint32 phase) const
Definition: Object.h:462
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
ControlList m_Controlled
Definition: Unit.h:1738
HostileReference * getFirst()
Definition: HostileRefManager.h:58
Definition: ObjectGuid.h:33
FROM * GetSource() const
Definition: Reference.h:96
Creature * ToCreature()
Definition: Object.h:194
ThreatManager & getThreatManager()
Definition: Unit.h:1998
#define MAX_SUMMON_SLOT
Definition: Unit.h:1285
uint8_t uint8
Definition: Define.h:152
Unit * GetOwner() const
Definition: ThreatManager.h:228
void RemoveNotOwnSingleTargetAuras(uint32 newPhase=0x0, bool phaseid=false)
Definition: Unit.cpp:3769
bool IsInWorld() const
Definition: Object.h:100
Definition: Unit.h:1305
Definition: HostileRefManager.h:32
void setOnlineOfflineState(bool isOnline)
Definition: HostileRefManager.cpp:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetLastDamagedTime ( time_t  val)
inline
2217 { _lastDamagedTime = val; }
time_t _lastDamagedTime
Definition: Unit.h:2362

+ Here is the caller graph for this function:

void Unit::SetLevel ( uint8  lvl)
11524 {
11526 
11527  if (Player* player = ToPlayer())
11528  {
11529  // group update
11530  if (player->GetGroup())
11531  player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
11532 
11533  sWorld->UpdateCharacterInfoLevel(GetGUID(), lvl);
11534  }
11535 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
#define sWorld
Definition: World.h:887
Definition: UpdateFields.h:105
Player * ToPlayer()
Definition: Object.h:191
Definition: Group.h:111
ObjectGuid const & GetGUID() const
Definition: Object.h:105

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetMaxHealth ( uint32  val)
11566 {
11567  if (!val)
11568  val = 1;
11569 
11570  uint32 health = GetHealth();
11572 
11573  // group update
11574  if (GetTypeId() == TYPEID_PLAYER)
11575  {
11576  if (ToPlayer()->GetGroup())
11577  ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_HP);
11578  }
11579  else if (Pet* pet = ToCreature()->ToPet())
11580  {
11581  if (pet->isControlled())
11582  pet->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP);
11583  }
11584 
11585  if (val < health)
11586  SetHealth(val);
11587 }
Pet * ToPet()
Definition: Unit.h:2200
Definition: UpdateFields.h:101
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Group.h:108
Definition: Group.h:137
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
void SetHealth(uint32 val)
Definition: Unit.cpp:11537
uint32 GetHealth() const
Definition: Unit.h:1426
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetMaxPower ( Powers  power,
int32  val 
)
11642 {
11643  uint32 powerIndex = GetPowerIndex(power);
11644  if (powerIndex == MAX_POWERS || powerIndex >= MAX_POWERS_PER_CLASS)
11645  return;
11646 
11647  int32 cur_power = GetPower(power);
11648  SetInt32Value(UNIT_FIELD_MAXPOWER + powerIndex, val);
11649 
11650  // group update
11651  if (GetTypeId() == TYPEID_PLAYER)
11652  {
11653  if (ToPlayer()->GetGroup())
11654  ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER);
11655  }
11656  /*else if (Pet* pet = ToCreature()->ToPet()) TODO 6.x
11657  {
11658  if (pet->isControlled())
11659  pet->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER);
11660  }*/
11661 
11662  if (val < cur_power)
11663  SetPower(power, val);
11664 }
void SetInt32Value(uint16 index, int32 value)
Definition: Object.cpp:983
int32 GetPower(Powers power) const
Definition: Unit.cpp:11589
Player * ToPlayer()
Definition: Object.h:191
#define MAX_POWERS_PER_CLASS
Definition: SharedDefines.h:270
TypeID GetTypeId() const
Definition: Object.h:113
Definition: UpdateFields.h:102
Definition: Group.h:110
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
void SetPower(Powers power, int32 val)
Definition: Unit.cpp:11607
Definition: ObjectGuid.h:33
uint32 GetPowerIndex(uint32 powerType) const
Definition: Unit.cpp:11666
Definition: SharedDefines.h:265

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetMeleeAnimKitId ( uint16  animKitId)
13498 {
13499  if (_meleeAnimKitId == animKitId)
13500  return;
13501 
13502  if (animKitId && !sAnimKitStore.LookupEntry(animKitId))
13503  return;
13504 
13505  _meleeAnimKitId = animKitId;
13506 
13508  data.Unit = GetGUID();
13509  data.AnimKitID = animKitId;
13510  SendMessageToSet(data.Write(), true);
13511 }
uint16 _meleeAnimKitId
Definition: Unit.h:2360
WorldPacket const * Write() override
Definition: MiscPackets.cpp:551
Definition: MiscPackets.h:702
ObjectGuid Unit
Definition: MiscPackets.h:709
ObjectGuid const & GetGUID() const
Definition: Object.h:105
DBCStorage< AnimKitEntry > sAnimKitStore(AnimKitfmt)
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
uint16 AnimKitID
Definition: MiscPackets.h:710

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetMinion ( Minion minion,
bool  apply 
)
7641 {
7642  TC_LOG_DEBUG("entities.unit", "SetMinion %u for %u, apply %u", minion->GetEntry(), GetEntry(), apply);
7643 
7644  if (apply)
7645  {
7646  if (!minion->GetOwnerGUID().IsEmpty())
7647  {
7648  TC_LOG_FATAL("entities.unit", "SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry());
7649  return;
7650  }
7651 
7652  minion->SetOwnerGUID(GetGUID());
7653 
7654  m_Controlled.insert(minion);
7655 
7656  if (GetTypeId() == TYPEID_PLAYER)
7657  {
7658  minion->m_ControlledByPlayer = true;
7660  }
7661 
7662  // Can only have one pet. If a new one is summoned, dismiss the old one.
7663  if (minion->IsGuardianPet())
7664  {
7665  if (Guardian* oldPet = GetGuardianPet())
7666  {
7667  if (oldPet != minion && (oldPet->IsPet() || minion->IsPet() || oldPet->GetEntry() != minion->GetEntry()))
7668  {
7669  // remove existing minion pet
7670  if (oldPet->IsPet())
7671  ((Pet*)oldPet)->Remove(PET_SAVE_AS_CURRENT);
7672  else
7673  oldPet->UnSummon();
7674  SetPetGUID(minion->GetGUID());
7676  }
7677  }
7678  else
7679  {
7680  SetPetGUID(minion->GetGUID());
7682  }
7683  }
7684 
7686  {
7687  if (AddGuidValue(UNIT_FIELD_SUMMON, minion->GetGUID()))
7688  {
7689  }
7690  }
7691 
7692  if (minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
7693  SetCritterGUID(minion->GetGUID());
7694 
7695  // PvP, FFAPvP
7697 
7698  // FIXME: hack, speed must be set only at follow
7699  if (GetTypeId() == TYPEID_PLAYER && minion->IsPet())
7700  for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
7701  minion->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
7702 
7703  // Ghoul pets have energy instead of mana (is anywhere better place for this code?)
7704  if (minion->IsPetGhoul())
7705  minion->setPowerType(POWER_ENERGY);
7706 
7707  // Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again
7708  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
7709 
7710  if (spellInfo && (spellInfo->IsCooldownStartedOnEvent()))
7711  GetSpellHistory()->StartCooldown(spellInfo, 0, nullptr, true);
7712  }
7713  else
7714  {
7715  if (minion->GetOwnerGUID() != GetGUID())
7716  {
7717  TC_LOG_FATAL("entities.unit", "SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry());
7718  return;
7719  }
7720 
7721  m_Controlled.erase(minion);
7722 
7723  if (minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
7724  if (GetCritterGUID() == minion->GetGUID())
7726 
7727  if (minion->IsGuardianPet())
7728  {
7729  if (GetPetGUID() == minion->GetGUID())
7731  }
7732  else if (minion->IsTotem())
7733  {
7734  // All summoned by totem minions must disappear when it is removed.
7735  if (SpellInfo const* spInfo = sSpellMgr->GetSpellInfo(minion->ToTotem()->GetSpell()))
7736  for (SpellEffectInfo const* effect : spInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
7737  {
7738  if (!effect || effect->Effect != SPELL_EFFECT_SUMMON)
7739  continue;
7740 
7741  RemoveAllMinionsByEntry(effect->MiscValue);
7742  }
7743  }
7744 
7745  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
7746  // Remove infinity cooldown
7747  if (spellInfo && (spellInfo->IsCooldownStartedOnEvent()))
7748  GetSpellHistory()->SendCooldownEvent(spellInfo);
7749 
7750  //if (minion->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
7751  {
7752  if (RemoveGuidValue(UNIT_FIELD_SUMMON, minion->GetGUID()))
7753  {
7754  // Check if there is another minion
7755  for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
7756  {
7757  // do not use this check, creature do not have charm guid
7758  //if (GetCharmGUID() == (*itr)->GetGUID())
7759  if (GetGUID() == (*itr)->GetCharmerGUID())
7760  continue;
7761 
7762  //ASSERT((*itr)->GetOwnerGUID() == GetGUID());
7763  if ((*itr)->GetOwnerGUID() != GetGUID())
7764  {
7765  OutDebugInfo();
7766  (*itr)->OutDebugInfo();
7767  ABORT();
7768  }
7769  ASSERT((*itr)->GetTypeId() == TYPEID_UNIT);
7770 
7771  if (!(*itr)->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
7772  continue;
7773 
7774  if (AddGuidValue(UNIT_FIELD_SUMMON, (*itr)->GetGUID()))
7775  {
7776  // show another pet bar if there is no charm bar
7777  if (GetTypeId() == TYPEID_PLAYER && !GetCharmGUID())
7778  {
7779  if ((*itr)->IsPet())
7780  ToPlayer()->PetSpellInitialize();
7781  else
7782  ToPlayer()->CharmSpellInitialize();
7783  }
7784  }
7785  break;
7786  }
7787  }
7788  }
7789  }
7790 }
bool Remove(ContainerUnorderedMap< SPECIFIC_TYPE, KEY_TYPE > &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *)
Definition: TypeContainerFunctions.h:104
UnitMoveType
Definition: Unit.h:597
void RemoveAllMinionsByEntry(uint32 entry)
Definition: Unit.cpp:7802
Definition: DBCEnums.h:404
Definition: TemporarySummon.h:83
void OutDebugInfo() const
Definition: Unit.cpp:15625
bool IsPetGhoul() const
Definition: TemporarySummon.h:75
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Guardian * GetGuardianPet() const
Definition: Unit.cpp:7596
#define MAX_MOVE_TYPE
Definition: Unit.h:610
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
uint32 GetSpell(uint8 slot=0) const
Definition: Totem.h:47
bool m_ControlledByPlayer
Definition: Unit.h:2175
Definition: UpdateFields.h:146
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1706
Definition: SharedDefines.h:4400
void SetMinionGUID(ObjectGuid guid)
Definition: Unit.h:1703
Definition: SpellInfo.h:326
Definition: UpdateFields.h:134
Definition: ObjectGuid.h:32
Definition: SharedDefines.h:1038
float m_speed_rate[MAX_MOVE_TYPE]
Definition: Unit.h:2290
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool startCooldown=true)
Definition: SpellHistory.cpp:487
ObjectGuid GetPetGUID() const
Definition: Unit.h:1708
void apply(T *val)
Definition: ByteConverter.h:41
Definition: Unit.h:866
void setPowerType(Powers power)
Definition: Unit.cpp:6977
Player * ToPlayer()
Definition: Object.h:191
Definition: PetDefines.h:35
TypeID GetTypeId() const
Definition: Object.h:113
Totem * ToTotem()
Definition: Unit.h:2203
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
bool AddGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1031
const SummonPropertiesEntry *const m_Properties
Definition: TemporarySummon.h:58
bool RemoveGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1049
void SetOwnerGUID(ObjectGuid owner)
Definition: Unit.cpp:7517
void SetCritterGUID(ObjectGuid guid)
Definition: Unit.h:1709
bool IsGuardianPet() const
Definition: TemporarySummon.cpp:319
ControlList m_Controlled
Definition: Unit.h:1738
Definition: Unit.h:676
bool IsPet() const
Definition: Unit.h:1403
uint32 Type
Definition: DBCStructure.h:1247
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
void StartCooldown(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool onHold=false)
Definition: SpellHistory.cpp:386
Definition: UpdateFields.h:109
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:210
bool IsTotem() const
Definition: Unit.h:1405
Definition: SharedDefines.h:251
#define ABORT
Definition: Errors.h:56
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:10531
uint32 GetEntry() const
Definition: Object.h:107
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
ObjectGuid GetCritterGUID() const
Definition: Unit.h:1710
Definition: UpdateFields.h:83
void SetPetGUID(ObjectGuid guid)
Definition: Unit.h:1707
bool IsEmpty() const
Definition: ObjectGuid.h:242
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318
Definition: Pet.h:46
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1470

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetMinionGUID ( ObjectGuid  guid)
inline
1703 { SetGuidValue(UNIT_FIELD_SUMMON, guid); }
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
Definition: UpdateFields.h:83

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetModifierValue ( UnitMods  unitMod,
UnitModifierType  modifierType,
float  value 
)
inline
1952 { m_auraModifiersGroup[unitMod][modifierType] = value; }
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2285
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

void Unit::SetMovementAnimKitId ( uint16  animKitId)
13482 {
13483  if (_movementAnimKitId == animKitId)
13484  return;
13485 
13486  if (animKitId && !sAnimKitStore.LookupEntry(animKitId))
13487  return;
13488 
13489  _movementAnimKitId = animKitId;
13490 
13492  data.Unit = GetGUID();
13493  data.AnimKitID = animKitId;
13494  SendMessageToSet(data.Write(), true);
13495 }
uint16 AnimKitID
Definition: MiscPackets.h:699
Definition: MiscPackets.h:691
ObjectGuid Unit
Definition: MiscPackets.h:698
WorldPacket const * Write() override
Definition: MiscPackets.cpp:543
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint16 _movementAnimKitId
Definition: Unit.h:2359
DBCStorage< AnimKitEntry > sAnimKitStore(AnimKitfmt)
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

void Unit::SetNativeDisplayId ( uint32  modelId)
inline
Definition: UpdateFields.h:118
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetOwnerGUID ( ObjectGuid  owner)
7518 {
7519  if (GetOwnerGUID() == owner)
7520  return;
7521 
7523  if (!owner)
7524  return;
7525 
7526  // Update owner dependent fields
7527  Player* player = ObjectAccessor::GetPlayer(*this, owner);
7528  if (!player || !player->HaveAtClient(this)) // if player cannot see this unit yet, he will receive needed data with create object
7529  return;
7530 
7532 
7533  UpdateData udata(GetMapId());
7534  WorldPacket packet;
7535  BuildValuesUpdateBlockForPlayer(&udata, player);
7536  udata.BuildPacket(&packet);
7537  player->SendDirectMessage(&packet);
7538 
7540 }
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) const
Definition: Object.cpp:265
void RemoveFieldNotifyFlag(uint16 flag)
Definition: Object.h:186
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
Definition: UpdateData.h:59
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
void SetFieldNotifyFlag(uint16 flag)
Definition: Object.h:185
uint32 GetMapId() const
Definition: Position.h:254
Definition: UpdateFieldFlags.h:29
Definition: UpdateFields.h:86
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetPetGUID ( ObjectGuid  guid)
inline
1707 { m_SummonSlot[SUMMON_SLOT_PET] = guid; }
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
#define SUMMON_SLOT_PET
Definition: Unit.h:1280

+ Here is the caller graph for this function:

void Unit::SetPower ( Powers  power,
int32  val 
)
Todo:
: Support multiple counts ?
11608 {
11609  uint32 powerIndex = GetPowerIndex(power);
11610  if (powerIndex == MAX_POWERS || powerIndex >= MAX_POWERS_PER_CLASS)
11611  return;
11612 
11613  int32 maxPower = int32(GetMaxPower(power));
11614  if (maxPower < val)
11615  val = maxPower;
11616 
11617  SetInt32Value(UNIT_FIELD_POWER + powerIndex, val);
11618 
11619  if (IsInWorld())
11620  {
11622  packet.Guid = GetGUID();
11624  packet.Powers.emplace_back(val, powerIndex);
11626  }
11627 
11628  // group update
11629  if (Player* player = ToPlayer())
11630  {
11631  if (player->GetGroup())
11632  player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER);
11633  }
11634  /*else if (Pet* pet = ToCreature()->ToPet()) TODO 6.x
11635  {
11636  if (pet->isControlled())
11637  pet->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER);
11638  }*/
11639 }
Definition: CombatPackets.h:149
ObjectGuid Guid
Definition: CombatPackets.h:156
void SetInt32Value(uint16 index, int32 value)
Definition: Object.cpp:983
Player * ToPlayer()
Definition: Object.h:191
#define MAX_POWERS_PER_CLASS
Definition: SharedDefines.h:270
Definition: UpdateFields.h:100
TypeID GetTypeId() const
Definition: Object.h:113
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: Group.h:109
uint32 GetPowerIndex(uint32 powerType) const
Definition: Unit.cpp:11666
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:265
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
bool IsInWorld() const
Definition: Object.h:100
std::vector< PowerUpdatePower > Powers
Definition: CombatPackets.h:157
WorldPacket const * Write() override
Definition: CombatPackets.cpp:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::setPowerType ( Powers  power)
6978 {
6979  if (getPowerType() == new_powertype)
6980  return;
6981 
6982  SetUInt32Value(UNIT_FIELD_DISPLAY_POWER, new_powertype);
6983 
6984  if (GetTypeId() == TYPEID_PLAYER)
6985  {
6986  if (ToPlayer()->GetGroup())
6987  ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POWER_TYPE);
6988  }
6989  /*else if (Pet* pet = ToCreature()->ToPet()) TODO 6.x
6990  {
6991  if (pet->isControlled())
6992  pet->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_POWER_TYPE);
6993  }*/
6994 
6995  float powerMultiplier = 1.0f;
6996  if (!IsPet())
6997  if (Creature* creature = ToCreature())
6998  powerMultiplier = creature->GetCreatureTemplate()->ModMana;
6999 
7000  switch (new_powertype)
7001  {
7002  default:
7003  case POWER_MANA:
7004  break;
7005  case POWER_RAGE:
7007  SetPower(POWER_RAGE, 0);
7008  break;
7009  case POWER_FOCUS:
7012  break;
7013  case POWER_ENERGY:
7015  break;
7016  }
7017 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: SharedDefines.h:249
Definition: UpdateFields.h:97
Definition: Creature.h:467
Definition: SharedDefines.h:250
Player * ToPlayer()
Definition: Object.h:191
Powers getPowerType() const
Definition: Unit.h:1444
TypeID GetTypeId() const
Definition: Object.h:113
bool IsPet() const
Definition: Unit.h:1403
void SetPower(Powers power, int32 val)
Definition: Unit.cpp:11607
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:251
Creature * ToCreature()
Definition: Object.h:194
int32 GetCreatePowers(Powers power) const
Definition: Unit.cpp:11679
void SetMaxPower(Powers power, int32 val)
Definition: Unit.cpp:11641
Definition: Group.h:105
uint32_t uint32
Definition: g3dmath.h:168
static Vector3int16 ceil(const Vector3 &v)
Definition: Vector3int16.cpp:55
Definition: SharedDefines.h:248

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetPvP ( bool  state)
virtual
14456 {
14457  if (state)
14459  else
14461 }
Definition: UpdateFields.h:146
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:1252
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:1271
Definition: Unit.h:308

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetRedirectThreat ( ObjectGuid  guid,
uint32  pct 
)
inline
2154 { _redirectThreadInfo.Set(guid, pct); }
void Set(ObjectGuid guid, uint32 pct)
Definition: Unit.h:1086
RedirectThreatInfo _redirectThreadInfo
Definition: Unit.h:2350

+ Here is the caller graph for this function:

void Unit::SetResistance ( SpellSchools  school,
int32  val 
)
inline
1424 { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); }
void SetStatInt32Value(uint16 index, int32 value)
Definition: Object.cpp:1143
Definition: UpdateFields.h:140

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetResistanceBuffMods ( SpellSchools  school,
bool  positive,
float  val 
)
4659 {
4661 }
Definition: UpdateFields.h:142
Definition: UpdateFields.h:141
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:1067

+ Here is the call graph for this function:

void Unit::SetRooted ( bool  apply,
bool  packetOnly = false 
)
protected
13933 {
13934  if (!packetOnly)
13935  {
13936  if (apply)
13937  {
13938  // MOVEMENTFLAG_ROOT cannot be used in conjunction with MOVEMENTFLAG_MASK_MOVING (tested 3.3.5a)
13939  // this will freeze clients. That's why we remove MOVEMENTFLAG_MASK_MOVING before
13940  // setting MOVEMENTFLAG_ROOT
13943  StopMoving();
13944  }
13945  else
13947  }
13948 
13949 
13950  static OpcodeServer const rootOpcodeTable[2][2] =
13951  {
13954  };
13955 
13956  if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER)
13957  {
13958  WorldPackets::Movement::MoveSetFlag packet(rootOpcodeTable[apply][1]);
13959  packet.MoverGUID = GetGUID();
13960  packet.SequenceIndex = m_movementCounter++;
13961  SendMessageToSet(packet.Write(), true);
13962  }
13963  else
13964  {
13965  WorldPackets::Movement::MoveSplineSetFlag packet(rootOpcodeTable[apply][0]);
13966  packet.MoverGUID = GetGUID();
13967  SendMessageToSet(packet.Write(), true);
13968  }
13969 }
Definition: Opcodes.h:1261
Definition: Unit.h:808
void apply(T *val)
Definition: ByteConverter.h:41
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Player * ToPlayer()
Definition: Object.h:191
Definition: Opcodes.h:1285
TypeID GetTypeId() const
Definition: Object.h:113
OpcodeServer
Definition: Opcodes.h:725
Definition: Opcodes.h:1234
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
Definition: MovementPackets.h:165
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: MovementPackets.h:155
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: Opcodes.h:1281
Definition: Unit.h:786
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetShapeshiftForm ( ShapeshiftForm  form)
11270 {
11271  SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
11272 }
Definition: UpdateFields.h:146
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Unit::SetSheath ( SheathState  sheathed)
inlinevirtual
1463 { SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); }
Definition: UpdateFields.h:146
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetSpeed ( UnitMoveType  mtype,
float  rate,
bool  forced = false 
)
10532 {
10533  if (rate < 0)
10534  rate = 0.0f;
10535 
10536  // Update speed only on change
10537  if (m_speed_rate[mtype] == rate)
10538  return;
10539 
10540  m_speed_rate[mtype] = rate;
10541 
10543 
10544  // Spline packets are for creatures and move_update are for players
10545  static OpcodeServer const moveTypeToOpcode[MAX_MOVE_TYPE][3] =
10546  {
10556  };
10557 
10558  if (GetTypeId() == TYPEID_PLAYER)
10559  {
10560  // register forced speed changes for WorldSession::HandleForceSpeedChangeAck
10561  // and do it only for real sent packets and use run for run/mounted as client expected
10562  ++ToPlayer()->m_forced_speed_changes[mtype];
10563 
10564  if (!IsInCombat())
10565  if (Pet* pet = ToPlayer()->GetPet())
10566  pet->SetSpeed(mtype, m_speed_rate[mtype], forced);
10567  }
10568 
10569  if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER)
10570  {
10571  // Send notification to self
10572  WorldPackets::Movement::MoveSetSpeed selfpacket(moveTypeToOpcode[mtype][1]);
10573  selfpacket.MoverGUID = GetGUID();
10574  selfpacket.SequenceIndex = m_movementCounter++;
10575  selfpacket.Speed = GetSpeed(mtype);
10576  ToPlayer()->GetSession()->SendPacket(selfpacket.Write());
10577 
10578  // Send notification to other players
10579  WorldPackets::Movement::MoveUpdateSpeed packet(moveTypeToOpcode[mtype][2]);
10580  packet.movementInfo = &m_movementInfo;
10581  packet.Speed = GetSpeed(mtype);
10582  SendMessageToSet(packet.Write(), false);
10583  }
10584  else
10585  {
10586  WorldPackets::Movement::MoveSplineSetSpeed packet(moveTypeToOpcode[mtype][0]);
10587  packet.MoverGUID = GetGUID();
10588  packet.Speed = GetSpeed(mtype);
10589  SendMessageToSet(packet.Write(), true);
10590  }
10591 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
Definition: Opcodes.h:1248
Definition: Opcodes.h:1242
#define MAX_MOVE_TYPE
Definition: Unit.h:610
Definition: Opcodes.h:1294
Definition: Opcodes.h:1300
float GetSpeed(UnitMoveType mtype) const
Definition: Unit.cpp:10526
Definition: Opcodes.h:1304
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Opcodes.h:1263
Definition: Opcodes.h:1298
bool IsInCombat() const
Definition: Unit.h:1584
Definition: Opcodes.h:1247
Definition: Opcodes.h:1293
float m_speed_rate[MAX_MOVE_TYPE]
Definition: Unit.h:2290
Definition: Opcodes.h:1301
Definition: Opcodes.h:1277
Definition: Opcodes.h:1303
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Opcodes.h:1299
OpcodeServer
Definition: Opcodes.h:725
Definition: Opcodes.h:1241
Definition: Opcodes.h:1254
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
Definition: Opcodes.h:1275
Definition: Opcodes.h:1272
Definition: Opcodes.h:1251
Definition: MovementPackets.h:121
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: Opcodes.h:1270
Definition: Opcodes.h:1273
Definition: Opcodes.h:1250
Definition: Opcodes.h:1274
Definition: Opcodes.h:1296
void propagateSpeedChange()
-------—End of Pet responses methods-------—
Definition: Unit.h:2130
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: MovementPackets.h:132
Definition: Opcodes.h:1264
Definition: MovementPackets.h:144
Definition: Opcodes.h:1269
Definition: Opcodes.h:1252
Definition: Opcodes.h:1249
Definition: Pet.h:46

+ Here is the call graph for this function:

void Unit::SetStandFlags ( uint8  flags)
inline
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:1252
Definition: UpdateFields.h:124
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetStandState ( UnitStandStateType  state,
uint32  animKitID = 0 
)
12773 {
12775 
12776  if (IsStandState())
12778 
12779  if (GetTypeId() == TYPEID_PLAYER)
12780  {
12781  WorldPackets::Misc::StandStateUpdate packet(state, animKitID);
12782  ToPlayer()->GetSession()->SendPacket(packet.Write());
12783  }
12784 }
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:72
Definition: MiscPackets.h:423
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080
uint8_t uint8
Definition: g3dmath.h:164
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:124
bool IsStandState() const
Definition: Unit.cpp:12766

+ Here is the call graph for this function:

void Unit::SetStat ( Stats  stat,
int32  val 
)
inline
1418 { SetStatInt32Value(UNIT_FIELD_STAT+stat, val); }
void SetStatInt32Value(uint16 index, int32 value)
Definition: Object.cpp:1143
Definition: UpdateFields.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetStunned ( bool  apply)
protected
13902 {
13903  if (apply)
13904  {
13907 
13908  StopMoving();
13909 
13910  if (GetTypeId() == TYPEID_PLAYER)
13912 
13913  SetRooted(true);
13914 
13915  CastStop();
13916  }
13917  else
13918  {
13919  if (IsAlive() && GetVictim())
13921 
13922  // don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface)
13923  Unit* owner = GetOwner();
13924  if (!owner || (owner->GetTypeId() == TYPEID_PLAYER && !owner->ToPlayer()->IsMounted()))
13926 
13927  if (!HasUnitState(UNIT_STATE_ROOT)) // prevent moving if it also has root effect
13928  SetRooted(false);
13929  }
13930 }
Definition: Unit.h:207
Unit * EnsureVictim() const
Definition: Unit.h:1381
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void CastStop(uint32 except_spellid=0)
Definition: Unit.cpp:862
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
void apply(T *val)
Definition: ByteConverter.h:41
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
void SetRooted(bool apply, bool packetOnly=false)
Definition: Unit.cpp:13932
bool IsAlive() const
Definition: Unit.h:1692
Unit * GetVictim() const
Definition: Unit.h:1379
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
Unit * GetOwner() const
Definition: Unit.cpp:7542
Definition: Unit.h:560
virtual void SetTarget(ObjectGuid const &)=0
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:12772
Definition: Unit.h:691
Definition: Unit.h:1305
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::SetSwim ( bool  enable)
15881 {
15883  return false;
15884 
15885  if (enable)
15887  else
15889 
15890  static OpcodeServer const swimOpcodeTable[2] = { SMSG_MOVE_SPLINE_STOP_SWIM, SMSG_MOVE_SPLINE_START_SWIM};
15891 
15892  WorldPackets::Movement::MoveSplineSetFlag packet(swimOpcodeTable[enable]);
15893  packet.MoverGUID = GetGUID();
15894  SendMessageToSet(packet.Write(), true);
15895 
15896  return true;
15897 }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Definition: Opcodes.h:1280
OpcodeServer
Definition: Opcodes.h:725
Definition: Unit.h:796
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: MovementPackets.h:155
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: Opcodes.h:1279

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Unit::SetTarget ( ObjectGuid const )
pure virtual

Implemented in Creature.

+ Here is the caller graph for this function:

void Unit::setTransForm ( uint32  spellid)
inline
2017 { m_transform = spellid;}
uint32 m_transform
Definition: Unit.h:2269

+ Here is the caller graph for this function:

void Unit::SetUnitMovementFlags ( uint32  f)
inline
MovementInfo m_movementInfo
Definition: Object.h:612
void SetMovementFlags(uint32 flag)
Definition: Object.h:327

+ Here is the caller graph for this function:

void Unit::SetVehicle ( Vehicle vehicle)
inline
2167 { m_vehicle = vehicle; }
Vehicle * m_vehicle
Definition: Unit.h:2304

+ Here is the caller graph for this function:

void Unit::SetVirtualItem ( uint32  slot,
uint32  itemId,
uint16  appearanceModId = 0 
)
16428 {
16429  if (slot >= MAX_EQUIPMENT_ITEMS)
16430  return;
16431 
16432  SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot * 2, itemId);
16433  SetUInt16Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot * 2 + 1, 0, appearanceModId);
16434 }
Definition: UpdateFields.h:108
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
void SetUInt16Value(uint16 index, uint8 offset, uint16 value)
Definition: Object.cpp:1100
#define MAX_EQUIPMENT_ITEMS
Definition: Unit.h:1297

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::SetVisible ( bool  x)
10369 {
10370  if (!x)
10372  else
10374 
10376 }
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:538
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:383
Definition: Common.h:108
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:14630
Definition: SharedDefines.h:1741
Definition: Common.h:110
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

void Unit::SetVisibleAura ( uint8  slot,
AuraApplication aur 
)
546 {
547  m_visibleAuras[slot]=aur;
548  UpdateAuraForGroup(slot);
549 }
VisibleAuraMap m_visibleAuras
Definition: Unit.h:2288
void UpdateAuraForGroup(uint8 slot)
Definition: Unit.cpp:13062

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::SetWalk ( bool  enable)
15801 {
15802  if (enable == IsWalking())
15803  return false;
15804 
15805  if (enable)
15807  else
15809 
15810  static OpcodeServer const walkModeTable[2] = { SMSG_MOVE_SPLINE_SET_RUN_MODE, SMSG_MOVE_SPLINE_SET_WALK_MODE };
15811 
15812  WorldPackets::Movement::MoveSplineSetFlag packet(walkModeTable[enable]);
15813  packet.MoverGUID = GetGUID();
15814  SendMessageToSet(packet.Write(), true);
15815  return true;
15816 }
Definition: Unit.h:784
Definition: Opcodes.h:1271
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Definition: Opcodes.h:1276
bool IsWalking() const
Definition: Unit.h:1668
OpcodeServer
Definition: Opcodes.h:725
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: MovementPackets.h:155
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

bool Unit::SetWaterWalking ( bool  enable,
bool  packetOnly = false 
)
15943 {
15944  if (!packetOnly)
15945  {
15947  return false;
15948 
15949  if (enable)
15951  else
15953  }
15954 
15955  static OpcodeServer const waterWalkingOpcodeTable[2][2] =
15956  {
15959  };
15960 
15961  bool player = GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER;
15962 
15963  if (player)
15964  {
15965  WorldPackets::Movement::MoveSetFlag packet(waterWalkingOpcodeTable[enable][1]);
15966  packet.MoverGUID = GetGUID();
15967  packet.SequenceIndex = m_movementCounter++;
15968  SendMessageToSet(packet.Write(), true);
15969  }
15970  else
15971  {
15972  WorldPackets::Movement::MoveSplineSetFlag packet(waterWalkingOpcodeTable[enable][0]);
15973  packet.MoverGUID = GetGUID();
15974  SendMessageToSet(packet.Write(), true);
15975  }
15976 
15977  return true;
15978 }
Definition: Opcodes.h:1245
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
Definition: Unit.h:802
Definition: Opcodes.h:1278
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2107
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Opcodes.h:1267
OpcodeServer
Definition: Opcodes.h:725
uint32 m_movementCounter
Incrementing counter used in movement packets.
Definition: Unit.h:2336
Definition: MovementPackets.h:165
void RemoveUnitMovementFlag(uint32 f)
Definition: Unit.h:2108
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: MovementPackets.h:155
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: Opcodes.h:1255

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::SpellBaseDamageBonusDone ( SpellSchoolMask  schoolMask) const
8582 {
8583  if (GetTypeId() == TYPEID_PLAYER)
8584  {
8586  if (overrideSP > 0.0f)
8587  return int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), overrideSP) + 0.5f);
8588  }
8589 
8590  int32 DoneAdvertisedBenefit = 0;
8591 
8593  for (AuraEffectList::const_iterator i = mDamageDone.begin(); i != mDamageDone.end(); ++i)
8594  if (((*i)->GetMiscValue() & schoolMask) != 0 &&
8595  (*i)->GetSpellInfo()->EquippedItemClass == -1 &&
8596  // -1 == any item class (not wand then)
8597  (*i)->GetSpellInfo()->EquippedItemInventoryTypeMask == 0)
8598  // 0 == any inventory type (not wand then)
8599  DoneAdvertisedBenefit += (*i)->GetAmount();
8600 
8601  if (GetTypeId() == TYPEID_PLAYER)
8602  {
8603  // Base value
8604  DoneAdvertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus();
8605 
8606  // Check if we are ever using mana - PaperDollFrame.lua
8608  DoneAdvertisedBenefit += std::max(0, int32(GetStat(STAT_INTELLECT))); // spellpower from intellect
8609 
8610  // Damage bonus from stats
8612  for (AuraEffectList::const_iterator i = mDamageDoneOfStatPercent.begin(); i != mDamageDoneOfStatPercent.end(); ++i)
8613  {
8614  if ((*i)->GetMiscValue() & schoolMask)
8615  {
8616  // stat used stored in miscValueB for this aura
8617  Stats usedStat = Stats((*i)->GetMiscValueB());
8618  DoneAdvertisedBenefit += int32(CalculatePct(GetStat(usedStat), (*i)->GetAmount()));
8619  }
8620  }
8621  // ... and attack power
8623  for (AuraEffectList::const_iterator i =mDamageDonebyAP.begin(); i != mDamageDonebyAP.end(); ++i)
8624  if ((*i)->GetMiscValue() & schoolMask)
8625  DoneAdvertisedBenefit += int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), (*i)->GetAmount()));
8626 
8627  }
8628  return DoneAdvertisedBenefit;
8629 }
Definition: SpellAuraDefines.h:297
Definition: UpdateFields.h:262
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Stats
Definition: SharedDefines.h:235
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:240
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SpellAuraDefines.h:234
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: SpellAuraDefines.h:73
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: ObjectGuid.h:33
uint32 GetPowerIndex(uint32 powerType) const
Definition: Unit.cpp:11666
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:265
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition: Unit.cpp:11491
float GetStat(Stats stat) const
Definition: Unit.h:1417
Definition: Unit.h:617
Definition: SharedDefines.h:248

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::SpellBaseDamageBonusTaken ( SpellSchoolMask  schoolMask) const
8632 {
8633  int32 TakenAdvertisedBenefit = 0;
8634 
8636  for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
8637  if (((*i)->GetMiscValue() & schoolMask) != 0)
8638  TakenAdvertisedBenefit += (*i)->GetAmount();
8639 
8640  return TakenAdvertisedBenefit;
8641 }
Definition: SpellAuraDefines.h:74
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::SpellBaseHealingBonusDone ( SpellSchoolMask  schoolMask) const
9159 {
9160  if (GetTypeId() == TYPEID_PLAYER)
9161  {
9163  if (overrideSP > 0.0f)
9164  return int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), overrideSP) + 0.5f);
9165  }
9166 
9167  int32 advertisedBenefit = 0;
9168 
9170  for (AuraEffectList::const_iterator i = mHealingDone.begin(); i != mHealingDone.end(); ++i)
9171  if (!(*i)->GetMiscValue() || ((*i)->GetMiscValue() & schoolMask) != 0)
9172  advertisedBenefit += (*i)->GetAmount();
9173 
9174  // Healing bonus of spirit, intellect and strength
9175  if (GetTypeId() == TYPEID_PLAYER)
9176  {
9177  // Base value
9178  advertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus();
9179 
9180  // Check if we are ever using mana - PaperDollFrame.lua
9182  advertisedBenefit += std::max(0, int32(GetStat(STAT_INTELLECT))); // spellpower from intellect
9183 
9184  // Healing bonus from stats
9186  for (AuraEffectList::const_iterator i = mHealingDoneOfStatPercent.begin(); i != mHealingDoneOfStatPercent.end(); ++i)
9187  {
9188  // stat used dependent from misc value (stat index)
9189  Stats usedStat = Stats((*i)->GetSpellEffectInfo()->MiscValue);
9190  advertisedBenefit += int32(CalculatePct(GetStat(usedStat), (*i)->GetAmount()));
9191  }
9192 
9193  // ... and attack power
9195  for (AuraEffectList::const_iterator i = mHealingDonebyAP.begin(); i != mHealingDonebyAP.end(); ++i)
9196  if ((*i)->GetMiscValue() & schoolMask)
9197  advertisedBenefit += int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), (*i)->GetAmount()));
9198  }
9199  return advertisedBenefit;
9200 }
Definition: UpdateFields.h:262
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Stats
Definition: SharedDefines.h:235
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:240
TypeID GetTypeId() const
Definition: Object.h:113
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: SpellAuraDefines.h:195
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: SpellAuraDefines.h:298
Definition: ObjectGuid.h:33
uint32 GetPowerIndex(uint32 powerType) const
Definition: Unit.cpp:11666
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:265
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition: Unit.cpp:11491
Definition: SpellAuraDefines.h:235
float GetStat(Stats stat) const
Definition: Unit.h:1417
Definition: Unit.h:617
Definition: SharedDefines.h:248

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Unit::SpellBaseHealingBonusTaken ( SpellSchoolMask  schoolMask) const
9203 {
9204  int32 advertisedBenefit = 0;
9205 
9207  for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
9208  if (((*i)->GetMiscValue() & schoolMask) != 0)
9209  advertisedBenefit += (*i)->GetAmount();
9210 
9211  return advertisedBenefit;
9212 }
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: SpellAuraDefines.h:175

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::SpellCriticalDamageBonus ( SpellInfo const spellProto,
uint32  damage,
Unit victim 
)
Todo:
write here full calculation for melee/ranged spells
8838 {
8839  // Calculate critical bonus
8840  int32 crit_bonus = damage;
8841  float crit_mod = 0.0f;
8842 
8843  switch (spellProto->DmgClass)
8844  {
8845  case SPELL_DAMAGE_CLASS_MELEE: // for melee based spells is 100%
8848  crit_bonus += damage;
8849  break;
8850  default:
8851  crit_bonus += damage / 2; // for spells is 50%
8852  break;
8853  }
8854 
8855  crit_mod += (GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, spellProto->GetSchoolMask()) - 1.0f) * 100;
8856 
8857  if (crit_bonus != 0)
8858  AddPct(crit_bonus, crit_mod);
8859 
8860  crit_bonus -= damage;
8861 
8862  if (damage > uint32(crit_bonus))
8863  {
8864  // adds additional damage to critBonus (from talents)
8865  if (Player* modOwner = GetSpellModOwner())
8866  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
8867  }
8868 
8869  crit_bonus += damage;
8870 
8871  return crit_bonus;
8872 }
Definition: SharedDefines.h:2052
Definition: SpellAuraDefines.h:223
Definition: Unit.h:101
int32_t int32
Definition: Define.h:146
float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4470
Definition: SharedDefines.h:2051
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
T AddPct(T &base, U pct)
Definition: Util.h:98
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::SpellCriticalHealingBonus ( SpellInfo const spellProto,
uint32  damage,
Unit victim 
)
8875 {
8876  // Calculate critical bonus
8877  int32 crit_bonus = damage;
8878 
8879  damage += crit_bonus;
8880 
8882 
8883  return damage;
8884 }
int32_t int32
Definition: Define.h:146
Definition: SpellAuraDefines.h:110
int32_t int32
Definition: g3dmath.h:167
float GetTotalAuraMultiplier(AuraType auratype) const
Definition: Unit.cpp:4415

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::SpellDamageBonusDone ( Unit victim,
SpellInfo const spellProto,
uint32  pdamage,
DamageEffectType  damagetype,
SpellEffectInfo const effect,
uint32  stack = 1 
) const
8213 {
8214  if (!spellProto || !victim || damagetype == DIRECT_DAMAGE)
8215  return pdamage;
8216 
8217  // Some spells don't benefit from done mods
8218  if (spellProto->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS))
8219  return pdamage;
8220 
8221  // For totems get damage bonus from owner
8222  if (GetTypeId() == TYPEID_UNIT && IsTotem())
8223  if (Unit* owner = GetOwner())
8224  return owner->SpellDamageBonusDone(victim, spellProto, pdamage, damagetype, effect, stack);
8225 
8226  float ApCoeffMod = 1.0f;
8227  int32 DoneTotal = 0;
8228 
8229  // done scripted mod (take it from owner)
8230  Unit const* owner = GetOwner() ? GetOwner() : this;
8231  AuraEffectList const& mOverrideClassScript = owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
8232  for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
8233  {
8234  if (!(*i)->IsAffectingSpell(spellProto))
8235  continue;
8236 
8237  switch ((*i)->GetMiscValue())
8238  {
8239  case 4418: // Increased Shock Damage
8240  case 4554: // Increased Lightning Damage
8241  case 4555: // Improved Moonfire
8242  case 5142: // Increased Lightning Damage
8243  case 5147: // Improved Consecration / Libram of Resurgence
8244  case 5148: // Idol of the Shooting Star
8245  case 6008: // Increased Lightning Damage
8246  case 8627: // Totem of Hex
8247  {
8248  DoneTotal += (*i)->GetAmount();
8249  break;
8250  }
8251  }
8252  }
8253 
8254  // Custom scripted damage
8255  /*switch (spellProto->SpellFamilyName)
8256  {
8257  case SPELLFAMILY_DEATHKNIGHT:
8258  break;
8259  }*/
8260 
8261  // Done fixed damage bonus auras
8262  int32 DoneAdvertisedBenefit = SpellBaseDamageBonusDone(spellProto->GetSchoolMask());
8263  // Pets just add their bonus damage to their spell damage
8264  // note that their spell damage is just gain of their own auras
8266  DoneAdvertisedBenefit += ((Guardian*)this)->GetBonusDamage();
8267 
8268  // Check for table values
8269  float coeff = effect->BonusCoefficient;
8270  if (effect->BonusCoefficientFromAP > 0)
8271  {
8272  WeaponAttackType attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK;
8274  APbonus += GetTotalAttackPowerValue(attType);
8275  DoneTotal += int32(effect->BonusCoefficientFromAP * stack * ApCoeffMod * APbonus);
8276  }
8277 
8278  // Default calculation
8279  if (DoneAdvertisedBenefit)
8280  {
8281  float factorMod = CalculateLevelPenalty(spellProto) * stack;
8282 
8283  if (Player* modOwner = GetSpellModOwner())
8284  {
8285  coeff *= 100.0f;
8286  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff);
8287  coeff /= 100.0f;
8288  }
8289  DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod);
8290  }
8291 
8292  // Done Percentage for DOT is already calculated, no need to do it again. The percentage mod is applied in Aura::HandleAuraSpecificMods.
8293  float tmpDamage = (int32(pdamage) + DoneTotal) * (damagetype == DOT ? 1.0f : SpellDamagePctDone(victim, spellProto, damagetype));
8294  // apply spellmod to Done damage (flat and pct)
8295  if (Player* modOwner = GetSpellModOwner())
8296  modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage);
8297 
8298  return uint32(std::max(tmpDamage, 0.0f));
8299 }
Definition: TemporarySummon.h:83
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const
Definition: Unit.cpp:8581
Definition: Unit.h:860
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: Unit.h:619
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
Definition: Unit.h:664
T max(const T &x, const T &y)
Definition: g3dmath.h:320
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:108
Definition: SpellAuraDefines.h:172
Definition: Unit.h:110
Definition: SpellAuraDefines.h:225
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: Unit.h:86
float CalculateLevelPenalty(SpellInfo const *spellProto) const
Definition: Unit.cpp:2118
Definition: SharedDefines.h:493
Definition: SharedDefines.h:2051
Definition: SpellAuraDefines.h:187
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
bool IsTotem() const
Definition: Unit.h:1405
Unit * GetOwner() const
Definition: Unit.cpp:7542
int32_t int32
Definition: g3dmath.h:167
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
Definition: Unit.h:662
uint32_t uint32
Definition: g3dmath.h:168
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition: Unit.cpp:11491
WeaponAttackType
Definition: Unit.h:615
Definition: Unit.h:1305
float SpellDamagePctDone(Unit *victim, SpellInfo const *spellProto, DamageEffectType damagetype) const
Definition: Unit.cpp:8301
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::SpellDamageBonusTaken ( Unit caster,
SpellInfo const spellProto,
uint32  pdamage,
DamageEffectType  damagetype,
SpellEffectInfo const effect,
uint32  stack = 1 
) const
8494 {
8495  if (!spellProto || damagetype == DIRECT_DAMAGE)
8496  return pdamage;
8497 
8498  int32 TakenTotal = 0;
8499  float TakenTotalMod = 1.0f;
8500  float TakenTotalCasterMod = 0.0f;
8501 
8502  // Mod damage from spell mechanic
8503  if (uint32 mechanicMask = spellProto->GetAllEffectsMechanicMask())
8504  {
8506  for (AuraEffectList::const_iterator i = mDamageDoneMechanic.begin(); i != mDamageDoneMechanic.end(); ++i)
8507  if (mechanicMask & uint32(1 << ((*i)->GetMiscValue())))
8508  AddPct(TakenTotalMod, (*i)->GetAmount());
8509  }
8510 
8511  //.. taken pct: dummy auras
8513  for (AuraEffectList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i)
8514  {
8515  switch ((*i)->GetSpellInfo()->SpellIconID)
8516  {
8517  // Cheat Death
8518  case 2109:
8519  if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
8520  AddPct(TakenTotalMod, (*i)->GetAmount());
8521  break;
8522  }
8523  }
8524  // Spells with SPELL_ATTR4_FIXED_DAMAGE should only benefit from mechanic damage mod auras.
8525  if (!spellProto->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
8526  {
8527  // get all auras from caster that allow the spell to ignore resistance (sanctified wrath)
8528  AuraEffectList const& IgnoreResistAuras = caster->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
8529  for (AuraEffectList::const_iterator i = IgnoreResistAuras.begin(); i != IgnoreResistAuras.end(); ++i)
8530  {
8531  if ((*i)->GetMiscValue() & spellProto->GetSchoolMask())
8532  TakenTotalCasterMod += (float((*i)->GetAmount()));
8533  }
8534 
8535  // From caster spells
8537  for (AuraEffectList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i)
8538  if ((*i)->GetCasterGUID() == caster->GetGUID() && (*i)->IsAffectingSpell(spellProto))
8539  AddPct(TakenTotalMod, (*i)->GetAmount());
8540 
8541  int32 TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(spellProto->GetSchoolMask());
8542 
8543  // Check for table values
8544  float coeff = effect->BonusCoefficient;
8545 
8546  // Default calculation
8547  if (TakenAdvertisedBenefit)
8548  {
8549  float factorMod = CalculateLevelPenalty(spellProto) * stack;
8550  // level penalty still applied on Taken bonus - is it blizzlike?
8551  if (Player* modOwner = GetSpellModOwner())
8552  {
8553  coeff *= 100.0f;
8554  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff);
8555  coeff /= 100.0f;
8556  }
8557  TakenTotal += int32(TakenAdvertisedBenefit * coeff * factorMod);
8558  }
8559  }
8560 
8561  float tmpDamage = 0.0f;
8562 
8563  if (TakenTotalCasterMod)
8564  {
8565  if (TakenTotal < 0)
8566  {
8567  if (TakenTotalMod < 1)
8568  tmpDamage = ((float(CalculatePct(pdamage, TakenTotalCasterMod) + TakenTotal) * TakenTotalMod) + CalculatePct(pdamage, TakenTotalCasterMod));
8569  else
8570  tmpDamage = ((float(CalculatePct(pdamage, TakenTotalCasterMod) + TakenTotal) + CalculatePct(pdamage, TakenTotalCasterMod)) * TakenTotalMod);
8571  }
8572  else if (TakenTotalMod < 1)
8573  tmpDamage = ((CalculatePct(float(pdamage) + TakenTotal, TakenTotalCasterMod) * TakenTotalMod) + CalculatePct(float(pdamage) + TakenTotal, TakenTotalCasterMod));
8574  }
8575  if (!tmpDamage)
8576  tmpDamage = (float(pdamage) + TakenTotal) * TakenTotalMod;
8577 
8578  return uint32(std::max(tmpDamage, 0.0f));
8579 }
Definition: SpellAuraDefines.h:331
int32 SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const
Definition: Unit.cpp:8631
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SpellAuraDefines.h:329
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Definition: Unit.h:110
Definition: SharedDefines.h:288
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
float CalculateLevelPenalty(SpellInfo const *spellProto) const
Definition: Unit.cpp:2118
Definition: SpellAuraDefines.h:315
T CalculatePct(T base, U pct)
Definition: Util.h:92
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
Definition: SpellAuraDefines.h:64
Definition: Unit.h:662
uint32_t uint32
Definition: g3dmath.h:168
Definition: SharedDefines.h:508

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::SpellDamagePctDone ( Unit victim,
SpellInfo const spellProto,
DamageEffectType  damagetype 
) const
8302 {
8303  if (!spellProto || !victim || damagetype == DIRECT_DAMAGE)
8304  return 1.0f;
8305 
8306  // Some spells don't benefit from pct done mods
8307  if (spellProto->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS))
8308  return 1.0f;
8309 
8310  // For totems pct done mods are calculated when its calculation is run on the player in SpellDamageBonusDone.
8311  if (GetTypeId() == TYPEID_UNIT && IsTotem())
8312  return 1.0f;
8313 
8314  // Done total percent damage auras
8315  float DoneTotalMod = 1.0f;
8316 
8317  // Pet damage?
8318  if (GetTypeId() == TYPEID_UNIT && !IsPet())
8319  DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank);
8320 
8322  for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
8323  {
8324  if (spellProto->EquippedItemClass == -1 && (*i)->GetSpellInfo()->EquippedItemClass != -1) //prevent apply mods from weapon specific case to non weapon specific spells (Example: thunder clap and two-handed weapon specialization)
8325  continue;
8326 
8327  if ((*i)->GetMiscValue() & spellProto->GetSchoolMask())
8328  {
8329  if ((*i)->GetSpellInfo()->EquippedItemClass == -1)
8330  AddPct(DoneTotalMod, (*i)->GetAmount());
8331  else if (!((*i)->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0))
8332  AddPct(DoneTotalMod, (*i)->GetAmount());
8333  else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo()))
8334  AddPct(DoneTotalMod, (*i)->GetAmount());
8335  }
8336  }
8337 
8338  uint32 creatureTypeMask = victim->GetCreatureTypeMask();
8339 
8341  for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
8342  if (creatureTypeMask & uint32((*i)->GetMiscValue()))
8343  AddPct(DoneTotalMod, (*i)->GetAmount());
8344 
8345  // bonus against aurastate
8347  for (AuraEffectList::const_iterator i = mDamageDoneVersusAurastate.begin(); i != mDamageDoneVersusAurastate.end(); ++i)
8348  if (victim->HasAuraState(AuraStateType((*i)->GetMiscValue())))
8349  AddPct(DoneTotalMod, (*i)->GetAmount());
8350 
8351  // Add SPELL_AURA_MOD_DAMAGE_DONE_FOR_MECHANIC percent bonus
8353 
8354  // done scripted mod (take it from owner)
8355  Unit const* owner = GetOwner() ? GetOwner() : this;
8356  AuraEffectList const& mOverrideClassScript = owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
8357  for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
8358  {
8359  if (!(*i)->IsAffectingSpell(spellProto))
8360  continue;
8361 
8362  switch ((*i)->GetMiscValue())
8363  {
8364  case 4920: // Molten Fury
8365  case 4919:
8366  {
8367  if (victim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
8368  AddPct(DoneTotalMod, (*i)->GetAmount());
8369  break;
8370  }
8371  case 6917: // Death's Embrace damage effect
8372  case 6926:
8373  case 6928:
8374  {
8375  // Health at 25% or less (25% stored at effect 2 of the spell)
8376  if (victim->HealthBelowPct(CalculateSpellDamage(this, (*i)->GetSpellInfo(), EFFECT_2)))
8377  AddPct(DoneTotalMod, (*i)->GetAmount());
8378  break;
8379  }
8380  case 6916: // Death's Embrace heal effect
8381  case 6925:
8382  case 6927:
8383  if (HealthBelowPct(CalculateSpellDamage(this, (*i)->GetSpellInfo(), EFFECT_2)))
8384  AddPct(DoneTotalMod, (*i)->GetAmount());
8385  break;
8386  // Soul Siphon
8387  case 4992:
8388  case 4993:
8389  {
8390  // effect 1 m_amount
8391  int32 maxPercent = (*i)->GetAmount();
8392  // effect 0 m_amount
8393  int32 stepPercent = CalculateSpellDamage(this, (*i)->GetSpellInfo(), 0);
8394  // count affliction effects and calc additional damage in percentage
8395  int32 modPercent = 0;
8396  AuraApplicationMap const& victimAuras = victim->GetAppliedAuras();
8397  for (AuraApplicationMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr)
8398  {
8399  Aura const* aura = itr->second->GetBase();
8400  SpellInfo const* spell = aura->GetSpellInfo();
8401  if (spell->SpellFamilyName != SPELLFAMILY_WARLOCK || !(spell->SpellFamilyFlags[1] & 0x0004071B || spell->SpellFamilyFlags[0] & 0x8044C402))
8402  continue;
8403  modPercent += stepPercent * aura->GetStackAmount();
8404  if (modPercent >= maxPercent)
8405  {
8406  modPercent = maxPercent;
8407  break;
8408  }
8409  }
8410  AddPct(DoneTotalMod, modPercent);
8411  break;
8412  }
8413  case 5481: // Starfire Bonus
8414  {
8415  if (victim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, flag128(0x200002, 0, 0)))
8416  AddPct(DoneTotalMod, (*i)->GetAmount());
8417  break;
8418  }
8419  }
8420  }
8421 
8422  // Custom scripted damage
8423  switch (spellProto->SpellFamilyName)
8424  {
8425  case SPELLFAMILY_MAGE:
8426  // Ice Lance
8427  if (spellProto->SpellIconID == 186)
8428  if (victim->HasAuraState(AURA_STATE_FROZEN, spellProto, this))
8429  DoneTotalMod *= 2.0f;
8430 
8431  // Torment the weak
8432  if (spellProto->GetSchoolMask() & SPELL_SCHOOL_MASK_ARCANE)
8433  {
8435  {
8437  for (AuraEffectList::const_iterator i = mDumyAuras.begin(); i != mDumyAuras.end(); ++i)
8438  {
8439  if ((*i)->GetSpellInfo()->SpellIconID == 2215)
8440  {
8441  AddPct(DoneTotalMod, (*i)->GetAmount());
8442  break;
8443  }
8444  }
8445  }
8446  }
8447  break;
8448  case SPELLFAMILY_PRIEST:
8449  // Smite
8450  if (spellProto->SpellFamilyFlags[0] & 0x80)
8451  {
8452  // Glyph of Smite
8453  if (AuraEffect* aurEff = GetAuraEffect(55692, 0))
8455  AddPct(DoneTotalMod, aurEff->GetAmount());
8456  }
8457  break;
8458  case SPELLFAMILY_WARLOCK:
8459  // Fire and Brimstone
8460  if (spellProto->SpellFamilyFlags[1] & 0x00020040)
8461  if (victim->HasAuraState(AURA_STATE_CONFLAGRATE))
8462  {
8464  for (AuraEffectList::const_iterator i = mDumyAuras.begin(); i != mDumyAuras.end(); ++i)
8465  if ((*i)->GetSpellInfo()->SpellIconID == 3173)
8466  {
8467  AddPct(DoneTotalMod, (*i)->GetAmount());
8468  break;
8469  }
8470  }
8471 
8472  // Shadow Bite (30% increase from each dot)
8473  if (spellProto->SpellFamilyFlags[1] & 0x00400000 && IsPet())
8474  if (uint8 count = victim->GetDoTsByCaster(GetOwnerGUID()))
8475  AddPct(DoneTotalMod, 30 * count);
8476 
8477  // Drain Soul - increased damage for targets under 25 % HP
8478  if (spellProto->SpellFamilyFlags[0] & 0x00004000)
8479  if (HasAura(100001))
8480  DoneTotalMod *= 2;
8481  break;
8483  // Sigil of the Vengeful Heart
8484  if (spellProto->SpellFamilyFlags[0] & 0x2000)
8485  if (AuraEffect* aurEff = GetAuraEffect(64962, EFFECT_1))
8486  DoneTotalMod += aurEff->GetAmount();
8487  break;
8488  }
8489 
8490  return DoneTotalMod;
8491 }
uint32 GetCreatureTypeMask() const
Definition: Unit.cpp:11263
Definition: SpellAuraEffects.h:30
Definition: SpellAuraDefines.h:63
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
float GetSpellDamageMod(int32 Rank) const
Definition: Creature.cpp:1264
Definition: SharedDefines.h:1772
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:4521
Definition: SharedDefines.h:29
Definition: SharedDefines.h:1798
Definition: SpellInfo.h:326
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
AuraStateType
Definition: SharedDefines.h:1754
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
Definition: SharedDefines.h:4638
Definition: SharedDefines.h:552
Definition: SharedDefines.h:1801
Definition: SharedDefines.h:4628
Definition: SharedDefines.h:1761
Player * ToPlayer()
Definition: Object.h:191
Definition: SpellAuraDefines.h:228
Definition: SpellAuraDefines.h:336
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:1771
Definition: SpellAuraDefines.h:139
Definition: SharedDefines.h:4626
Definition: SharedDefines.h:601
Definition: SpellAuraDefines.h:172
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
Definition: SpellAuraDefines.h:363
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Definition: SharedDefines.h:4629
bool HealthBelowPct(int32 pct) const
Definition: Unit.h:1430
Definition: Util.h:362
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
int32 CalculateSpellDamage(Unit const *target, SpellInfo const *spellProto, uint8 effect_index, int32 const *basePoints=nullptr, float *variance=nullptr, int32 itemLevel=-1) const
Definition: Unit.cpp:10930
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:4630
bool IsPet() const
Definition: Unit.h:1403
bool HasAuraWithMechanic(uint32 mechanicMask) const
Definition: Unit.cpp:4311
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetDoTsByCaster(ObjectGuid casterGUID) const
Definition: Unit.cpp:4373
bool IsTotem() const
Definition: Unit.h:1405
Unit * GetOwner() const
Definition: Unit.cpp:7542
Creature * ToCreature()
Definition: Object.h:194
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
T AddPct(T &base, U pct)
Definition: Util.h:98
Definition: SpellAuraDefines.h:64
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
uint8_t uint8
Definition: Define.h:152
Definition: Unit.h:662
Definition: SharedDefines.h:294
uint32_t uint32
Definition: g3dmath.h:168
Definition: SharedDefines.h:30
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
Definition: SpellAuras.h:116
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::SpellHealingBonusDone ( Unit victim,
SpellInfo const spellProto,
uint32  healamount,
DamageEffectType  damagetype,
SpellEffectInfo const effect,
uint32  stack = 1 
) const
8887 {
8888  // For totems get healing bonus from owner (statue isn't totem in fact)
8889  if (GetTypeId() == TYPEID_UNIT && IsTotem())
8890  if (Unit* owner = GetOwner())
8891  return owner->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, spellEffect, stack);
8892 
8893  // No bonus healing for potion spells
8894  if (spellProto->SpellFamilyName == SPELLFAMILY_POTION)
8895  return healamount;
8896 
8897  int32 DoneTotal = 0;
8898 
8899  // done scripted mod (take it from owner)
8900  Unit const* owner = GetOwner() ? GetOwner() : this;
8901  AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
8902  for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
8903  {
8904  if (!(*i)->IsAffectingSpell(spellProto))
8905  continue;
8906  switch ((*i)->GetMiscValue())
8907  {
8908  case 4415: // Increased Rejuvenation Healing
8909  case 4953:
8910  case 3736: // Hateful Totem of the Third Wind / Increased Lesser Healing Wave / LK Arena (4/5/6) Totem of the Third Wind / Savage Totem of the Third Wind
8911  DoneTotal += (*i)->GetAmount();
8912  break;
8913  case 21: // Test of Faith
8914  case 6935:
8915  case 6918:
8916  if (victim->HealthBelowPct(50))
8917  AddPct(DoneTotal, (*i)->GetAmount());
8918  break;
8919  case 8477: // Nourish Heal Boost
8920  {
8921  int32 stepPercent = (*i)->GetAmount();
8922  int32 modPercent = 0;
8923  AuraApplicationMap const& victimAuras = victim->GetAppliedAuras();
8924  for (AuraApplicationMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr)
8925  {
8926  Aura const* aura = itr->second->GetBase();
8927  if (aura->GetCasterGUID() != GetGUID())
8928  continue;
8929  SpellInfo const* m_spell = aura->GetSpellInfo();
8930  if (m_spell->SpellFamilyName != SPELLFAMILY_DRUID ||
8931  !(m_spell->SpellFamilyFlags[1] & 0x00000010 || m_spell->SpellFamilyFlags[0] & 0x50))
8932  continue;
8933  modPercent += stepPercent * aura->GetStackAmount();
8934  }
8935  AddPct(DoneTotal, modPercent);
8936  break;
8937  }
8938  default:
8939  break;
8940  }
8941  }
8942 
8943  // Done fixed damage bonus auras
8944  int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(spellProto->GetSchoolMask());
8945 
8946  // Check for table values
8947  float coeff = spellEffect->BonusCoefficient;
8948  float factorMod = 1.0f;
8949  if (spellEffect->BonusCoefficientFromAP > 0.0f)
8950  {
8951  DoneTotal += int32(spellEffect->BonusCoefficientFromAP * stack * GetTotalAttackPowerValue(
8952  (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK));
8953  }
8954  else if (coeff <= 0.0f)
8955  {
8956  // No bonus healing for SPELL_DAMAGE_CLASS_NONE class spells by default
8957  if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
8958  return healamount;
8959  }
8960 
8961  // Default calculation
8962  if (DoneAdvertisedBenefit)
8963  {
8964  factorMod *= CalculateLevelPenalty(spellProto) * stack;
8965 
8966  if (Player* modOwner = GetSpellModOwner())
8967  {
8968  coeff *= 100.0f;
8969  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff);
8970  coeff /= 100.0f;
8971  }
8972 
8973  DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod);
8974  }
8975 
8976  for (SpellEffectInfo const* effect : spellProto->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
8977  {
8978  if (!effect)
8979  continue;
8980  switch (effect->ApplyAuraName)
8981  {
8982  // Bonus healing does not apply to these spells
8985  DoneTotal = 0;
8986  break;
8987  }
8988  if (effect->Effect == SPELL_EFFECT_HEALTH_LEECH)
8989  DoneTotal = 0;
8990  }
8991 
8992  // Done Percentage for DOT is already calculated, no need to do it again. The percentage mod is applied in Aura::HandleAuraSpecificMods.
8993  float heal = float(int32(healamount) + DoneTotal) * (damagetype == DOT ? 1.0f : SpellHealingPctDone(victim, spellProto));
8994  // apply spellmod to Done amount
8995  if (Player* modOwner = GetSpellModOwner())
8996  modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal);
8997 
8998  return uint32(std::max(heal, 0.0f));
8999 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const
Definition: Unit.cpp:9158
Map * GetMap() const
Definition: Object.h:543
float SpellHealingPctDone(Unit *victim, SpellInfo const *spellProto) const
Definition: Unit.cpp:9001
Definition: SpellInfo.h:326
Definition: SharedDefines.h:1019
Definition: Unit.h:619
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
Definition: SharedDefines.h:4636
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
Definition: Unit.h:664
Definition: SharedDefines.h:2049
T max(const T &x, const T &y)
Definition: g3dmath.h:320
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:108
Definition: SpellAuraDefines.h:172
Definition: Unit.h:110
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
uint32 SpellFamilyName
Definition: SpellInfo.h:396
bool HealthBelowPct(int32 pct) const
Definition: Unit.h:1430
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: Unit.h:86
float CalculateLevelPenalty(SpellInfo const *spellProto) const
Definition: Unit.cpp:2118
Definition: SharedDefines.h:4630
Definition: SharedDefines.h:2051
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
bool IsTotem() const
Definition: Unit.h:1405
Unit * GetOwner() const
Definition: Unit.cpp:7542
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
uint32_t uint32
Definition: g3dmath.h:168
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
Definition: SpellAuraDefines.h:113
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition: Unit.cpp:11491
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
Definition: Unit.h:1305
Definition: SpellAuraDefines.h:122
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Unit::SpellHealingBonusTaken ( Unit caster,
SpellInfo const spellProto,
uint32  healamount,
DamageEffectType  damagetype,
SpellEffectInfo const effect,
uint32  stack = 1 
) const
9074 {
9075  float TakenTotalMod = 1.0f;
9076 
9077  // Healing taken percent
9079  if (minval)
9080  AddPct(TakenTotalMod, minval);
9081 
9083  if (maxval)
9084  AddPct(TakenTotalMod, maxval);
9085 
9086  // Tenacity increase healing % taken
9087  if (AuraEffect const* Tenacity = GetAuraEffect(58549, 0))
9088  AddPct(TakenTotalMod, Tenacity->GetAmount());
9089 
9090  // Healing Done
9091  int32 TakenTotal = 0;
9092 
9093  // Taken fixed damage bonus auras
9094  int32 TakenAdvertisedBenefit = SpellBaseHealingBonusTaken(spellProto->GetSchoolMask());
9095 
9096  // Nourish cast
9097  if (spellProto->SpellFamilyName == SPELLFAMILY_DRUID && spellProto->SpellFamilyFlags[1] & 0x2000000)
9098  {
9099  // Rejuvenation, Regrowth, Lifebloom, or Wild Growth
9101  // increase healing by 20%
9102  TakenTotalMod *= 1.2f;
9103  }
9104 
9105  // Check for table values
9106  float coeff = spellEffect->BonusCoefficient;
9107  float factorMod = 1.0f;
9108  if (coeff <= 0.0f)
9109  {
9110  // No bonus healing for SPELL_DAMAGE_CLASS_NONE class spells by default
9111  if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
9112  {
9113  healamount = uint32(std::max((float(healamount) * TakenTotalMod), 0.0f));
9114  return healamount;
9115  }
9116  }
9117 
9118  // Default calculation
9119  if (TakenAdvertisedBenefit)
9120  {
9121  factorMod *= CalculateLevelPenalty(spellProto) * int32(stack);
9122  if (Player* modOwner = GetSpellModOwner())
9123  {
9124  coeff *= 100.0f;
9125  modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff);
9126  coeff /= 100.0f;
9127  }
9128 
9129  TakenTotal += int32(TakenAdvertisedBenefit * coeff * factorMod);
9130  }
9131 
9133  for (AuraEffectList::const_iterator i = mHealingGet.begin(); i != mHealingGet.end(); ++i)
9134  if (caster->GetGUID() == (*i)->GetCasterGUID() && (*i)->IsAffectingSpell(spellProto))
9135  AddPct(TakenTotalMod, (*i)->GetAmount());
9136 
9137  for (SpellEffectInfo const* effect : spellProto->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
9138  {
9139  if (!effect)
9140  continue;
9141  switch (effect->ApplyAuraName)
9142  {
9143  // Bonus healing does not apply to these spells
9146  TakenTotal = 0;
9147  break;
9148  }
9149  if (effect->Effect == SPELL_EFFECT_HEALTH_LEECH)
9150  TakenTotal = 0;
9151  }
9152 
9153  float heal = float(int32(healamount) + TakenTotal) * TakenTotalMod;
9154 
9155  return uint32(std::max(heal, 0.0f));
9156 }
Definition: SpellAuraDefines.h:68
Definition: SpellAuraEffects.h:30
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:1019
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
int32 GetMaxNegativeAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4440
Definition: SharedDefines.h:2049
T max(const T &x, const T &y)
Definition: g3dmath.h:320
int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const
Definition: Unit.cpp:9202
Definition: Unit.h:110
Definition: Util.h:362
Definition: SpellInfo.h:238
Definition: SpellAuraDefines.h:343
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
float CalculateLevelPenalty(SpellInfo const *spellProto) const
Definition: Unit.cpp:2118
Definition: SharedDefines.h:4630
int32 GetMaxPositiveAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4426
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellAuraDefines.h:113
Definition: SpellAuraDefines.h:178
Definition: SpellAuraDefines.h:122

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Unit::SpellHealingPctDone ( Unit victim,
SpellInfo const spellProto 
) const
9002 {
9003  // For totems pct done mods are calculated when its calculation is run on the player in SpellHealingBonusDone.
9004  if (GetTypeId() == TYPEID_UNIT && IsTotem())
9005  return 1.0f;
9006 
9007  // No bonus healing for potion spells
9008  if (spellProto->SpellFamilyName == SPELLFAMILY_POTION)
9009  return 1.0f;
9010 
9011  float DoneTotalMod = 1.0f;
9012 
9013  // Healing done percent
9015  for (AuraEffectList::const_iterator i = mHealingDonePct.begin(); i != mHealingDonePct.end(); ++i)
9016  AddPct(DoneTotalMod, (*i)->GetAmount());
9017 
9018  // done scripted mod (take it from owner)
9019  Unit const* owner = GetOwner() ? GetOwner() : this;
9020  AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
9021  for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
9022  {
9023  if (!(*i)->IsAffectingSpell(spellProto))
9024  continue;
9025 
9026  switch ((*i)->GetMiscValue())
9027  {
9028  case 21: // Test of Faith
9029  case 6935:
9030  case 6918:
9031  if (victim->HealthBelowPct(50))
9032  AddPct(DoneTotalMod, (*i)->GetAmount());
9033  break;
9034  case 7798: // Glyph of Regrowth
9035  {
9037  AddPct(DoneTotalMod, (*i)->GetAmount());
9038  break;
9039  }
9040  case 8477: // Nourish Heal Boost
9041  {
9042  int32 stepPercent = (*i)->GetAmount();
9043  int32 modPercent = 0;
9044  AuraApplicationMap const& victimAuras = victim->GetAppliedAuras();
9045  for (AuraApplicationMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr)
9046  {
9047  Aura const* aura = itr->second->GetBase();
9048  if (aura->GetCasterGUID() != GetGUID())
9049  continue;
9050  SpellInfo const* m_spell = aura->GetSpellInfo();
9051  if (m_spell->SpellFamilyName != SPELLFAMILY_DRUID ||
9052  !(m_spell->SpellFamilyFlags[1] & 0x00000010 || m_spell->SpellFamilyFlags[0] & 0x50))
9053  continue;
9054  modPercent += stepPercent * aura->GetStackAmount();
9055  }
9056  AddPct(DoneTotalMod, modPercent);
9057  break;
9058  }
9059  case 7871: // Glyph of Lesser Healing Wave
9060  {
9061  if (victim->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, flag128(0, 0x00000400, 0), GetGUID()))
9062  AddPct(DoneTotalMod, (*i)->GetAmount());
9063  break;
9064  }
9065  default:
9066  break;
9067  }
9068  }
9069 
9070  return DoneTotalMod;
9071 }
Definition: SpellAuraDefines.h:68
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
Definition: SpellInfo.h:326
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
Definition: SharedDefines.h:4636
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SpellAuraDefines.h:172
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Definition: SharedDefines.h:4634
bool HealthBelowPct(int32 pct) const
Definition: Unit.h:1430
Definition: Util.h:362
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
Definition: SharedDefines.h:4630
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool IsTotem() const
Definition: Unit.h:1405
Unit * GetOwner() const
Definition: Unit.cpp:7542
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
T AddPct(T &base, U pct)
Definition: Util.h:98
Definition: SpellAuraDefines.h:64
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
Definition: SpellAuraDefines.h:196
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellMissInfo Unit::SpellHitResult ( Unit victim,
SpellInfo const spellInfo,
bool  canReflect = false 
)
Todo:
client not show miss log for this spells - so need find info for this in dbc and use it!
2478 {
2479  // Check for immune
2480  if (victim->IsImmunedToSpell(spellInfo))
2481  return SPELL_MISS_IMMUNE;
2482 
2483  // All positive spells can`t miss
2485  if (spellInfo->IsPositive() && !IsHostileTo(victim)) // prevent from affecting enemy by "positive" spell
2486  return SPELL_MISS_NONE;
2487 
2488  // Check for immune
2489  if (victim->IsImmunedToDamage(spellInfo))
2490  return SPELL_MISS_IMMUNE;
2491 
2492  if (this == victim)
2493  return SPELL_MISS_NONE;
2494 
2495  // Return evade for units in evade mode
2496  if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode())
2497  return SPELL_MISS_EVADE;
2498 
2499  // Try victim reflect spell
2500  if (CanReflect)
2501  {
2502  int32 reflectchance = victim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS);
2503  Unit::AuraEffectList const& mReflectSpellsSchool = victim->GetAuraEffectsByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL);
2504  for (Unit::AuraEffectList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i)
2505  if ((*i)->GetMiscValue() & spellInfo->GetSchoolMask())
2506  reflectchance += (*i)->GetAmount();
2507  if (reflectchance > 0 && roll_chance_i(reflectchance))
2508  {
2509  // Start triggers for remove charges if need (trigger only for victim, and mark as active spell)
2511  return SPELL_MISS_REFLECT;
2512  }
2513  }
2514 
2515  switch (spellInfo->DmgClass)
2516  {
2519  return MeleeSpellHitResult(victim, spellInfo);
2521  return SPELL_MISS_NONE;
2523  return MagicSpellHitResult(victim, spellInfo);
2524  }
2525  return SPELL_MISS_NONE;
2526 }
Definition: SharedDefines.h:2028
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
virtual bool IsImmunedToSpell(SpellInfo const *spellInfo) const
Definition: Unit.cpp:9255
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
Definition: SharedDefines.h:2052
bool IsInEvadeMode() const
Definition: Creature.h:520
Definition: SharedDefines.h:2021
Definition: SpellAuraDefines.h:88
Definition: SharedDefines.h:2049
Definition: SpellMgr.h:109
Definition: SharedDefines.h:2027
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const
Definition: Unit.cpp:9214
TypeID GetTypeId() const
Definition: Object.h:113
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
bool roll_chance_i(int chance)
Definition: Random.h:53
Definition: SpellMgr.h:210
Definition: SharedDefines.h:2051
Definition: SharedDefines.h:2050
SpellMissInfo MeleeSpellHitResult(Unit *victim, SpellInfo const *spellInfo)
Definition: Unit.cpp:2216
Definition: SharedDefines.h:2032
SpellMissInfo MagicSpellHitResult(Unit *victim, SpellInfo const *spellInfo)
Definition: Unit.cpp:2390
void ProcDamageAndSpell(Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellInfo const *procSpell=NULL, SpellInfo const *procAura=NULL)
Definition: Unit.cpp:4860
Creature * ToCreature()
Definition: Object.h:194
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7165
Definition: SpellAuraDefines.h:134
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::StartReactiveTimer ( ReactiveType  reactive)
inline
2134 { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;}
uint32 m_reactiveTimer[MAX_REACTIVE]
Definition: Unit.h:2299
#define REACTIVE_TIMER_START
Definition: Unit.h:1270

+ Here is the caller graph for this function:

void Unit::StopAttackFaction ( uint32  faction_id)
15592 {
15593  if (Unit* victim = GetVictim())
15594  {
15595  if (victim->GetFactionTemplateEntry()->Faction == faction_id)
15596  {
15597  AttackStop();
15598  if (IsNonMeleeSpellCast(false))
15599  InterruptNonMeleeSpells(false);
15600 
15601  // melee and ranged forced attack cancel
15602  if (GetTypeId() == TYPEID_PLAYER)
15603  ToPlayer()->SendAttackSwingCancelAttack();
15604  }
15605  }
15606 
15607  AttackerSet const& attackers = getAttackers();
15608  for (AttackerSet::const_iterator itr = attackers.begin(); itr != attackers.end();)
15609  {
15610  if ((*itr)->GetFactionTemplateEntry()->Faction == faction_id)
15611  {
15612  (*itr)->AttackStop();
15613  itr = attackers.begin();
15614  }
15615  else
15616  ++itr;
15617  }
15618 
15620 
15621  for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
15622  (*itr)->StopAttackFaction(faction_id);
15623 }
bool AttackStop()
Definition: Unit.cpp:7337
void deleteReferencesForFaction(uint32 faction)
Definition: HostileRefManager.cpp:129
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
AttackerSet const & getAttackers() const
Definition: Unit.h:1377
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
std::set< Unit * > AttackerSet
Definition: Unit.h:1308
Unit * GetVictim() const
Definition: Unit.h:1379
ControlList m_Controlled
Definition: Unit.h:1738
Definition: ObjectGuid.h:33
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
Definition: Unit.h:1305

+ Here is the call graph for this function:

void Unit::StopMoving ( )

-------—End of Pet responses methods-------—

12744 {
12746 
12747  // not need send any packets if not in world or not moving
12748  if (!IsInWorld() || movespline->Finalized())
12749  return;
12750 
12751  // Update position now since Stop does not start a new movement that can be updated later
12753  Movement::MoveSplineInit init(this);
12754  init.Stop();
12755 }
Definition: Unit.h:586
Movement::MoveSpline * movespline
Definition: Unit.h:2213
void UpdateSplinePosition()
Definition: Unit.cpp:450
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
bool Finalized() const
Definition: MoveSpline.h:129
bool IsInWorld() const
Definition: Object.h:100
Definition: MoveSplineInit.h:52

+ Here is the call graph for this function:

void Unit::Talk ( std::string const text,
ChatMsg  msgType,
Language  language,
float  textRange,
WorldObject const target 
)
virtual
16386 {
16387  Trinity::CustomChatTextBuilder builder(this, msgType, text, language, target);
16390  VisitNearbyWorldObject(textRange, worker);
16391 }
Definition: GridNotifiers.h:560
void VisitNearbyWorldObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:589
Definition: ChatTextBuilder.h:49
Definition: GridNotifiers.h:1400

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Talk ( uint32  textId,
ChatMsg  msgType,
float  textRange,
WorldObject const target 
)
16437 {
16438  if (!sBroadcastTextStore.LookupEntry(textId))
16439  {
16440  TC_LOG_ERROR("entities.unit", "WorldObject::MonsterText: `broadcast_text` was not %u found", textId);
16441  return;
16442  }
16443 
16444  Trinity::BroadcastTextBuilder builder(this, msgType, textId, target);
16447  VisitNearbyWorldObject(textRange, worker);
16448 }
DB2Storage< BroadcastTextEntry > sBroadcastTextStore("BroadcastText.db2", BroadcastTextFormat, HOTFIX_SEL_BROADCAST_TEXT)
Definition: GridNotifiers.h:560
void VisitNearbyWorldObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:589
Definition: GridNotifiers.h:1400
Definition: ChatTextBuilder.h:27
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

void Unit::TauntApply ( Unit victim)
10710 {
10712 
10713  if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && taunter->ToPlayer()->IsGameMaster()))
10714  return;
10715 
10716  if (!CanHaveThreatList())
10717  return;
10718 
10719  Creature* creature = ToCreature();
10720 
10721  if (creature->HasReactState(REACT_PASSIVE))
10722  return;
10723 
10724  Unit* target = GetVictim();
10725  if (target && target == taunter)
10726  return;
10727 
10728  SetInFront(taunter);
10729  if (creature->IsAIEnabled)
10730  creature->AI()->AttackStart(taunter);
10731 
10732  //m_ThreatManager.tauntApply(taunter);
10733 }
Definition: Unit.h:1129
Definition: ObjectGuid.h:32
bool HasReactState(ReactStates state) const
Definition: Creature.h:504
Definition: Creature.h:467
bool IsAIEnabled
Definition: Unit.h:2161
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition: Unit.cpp:10652
TypeID GetTypeId() const
Definition: Object.h:113
Unit * GetVictim() const
Definition: Unit.h:1379
CreatureAI * AI() const
Definition: Creature.h:525
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
#define ASSERT
Definition: Errors.h:55
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:15771
Definition: Unit.h:1305
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::TauntFadeOut ( Unit taunter)
10738 {
10740 
10741  if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && taunter->ToPlayer()->IsGameMaster()))
10742  return;
10743 
10744  if (!CanHaveThreatList())
10745  return;
10746 
10747  Creature* creature = ToCreature();
10748 
10749  if (creature->HasReactState(REACT_PASSIVE))
10750  return;
10751 
10752  Unit* target = GetVictim();
10753  if (!target || target != taunter)
10754  return;
10755 
10757  {
10758  if (creature->IsAIEnabled)
10760  return;
10761  }
10762 
10763  target = creature->SelectVictim(); // might have more taunt auras remaining
10764 
10765  if (target && target != taunter)
10766  {
10767  SetInFront(target);
10768  if (creature->IsAIEnabled)
10769  creature->AI()->AttackStart(target);
10770  }
10771 }
Definition: Unit.h:1129
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
Definition: CreatureAI.cpp:168
Definition: ObjectGuid.h:32
bool HasReactState(ReactStates state) const
Definition: Creature.h:504
Definition: Creature.h:467
bool isThreatListEmpty() const
Definition: ThreatManager.h:220
bool IsAIEnabled
Definition: Unit.h:2161
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition: Unit.cpp:10652
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Unit * GetVictim() const
Definition: Unit.h:1379
CreatureAI * AI() const
Definition: Creature.h:525
Definition: CreatureAI.h:87
ThreatManager m_ThreatManager
Definition: Unit.h:2302
Definition: ObjectGuid.h:33
Unit * SelectVictim()
Definition: Unit.cpp:10775
Creature * ToCreature()
Definition: Object.h:194
#define ASSERT
Definition: Errors.h:55
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:15771
Definition: Unit.h:1305
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::TextEmote ( std::string const text,
WorldObject const target = nullptr,
bool  isBossEmote = false 
)
virtual
16404 {
16406 }
Definition: SharedDefines.h:961
virtual void Talk(std::string const &text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
Definition: Unit.cpp:16385
#define sWorld
Definition: World.h:887
Definition: SharedDefines.h:4247
Definition: World.h:191
Definition: SharedDefines.h:4272

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::TextEmote ( uint32  textId,
WorldObject const target = nullptr,
bool  isBossEmote = false 
)
16461 {
16462  Talk(textId, isBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target);
16463 }
virtual void Talk(std::string const &text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
Definition: Unit.cpp:16385
#define sWorld
Definition: World.h:887
Definition: SharedDefines.h:4247
Definition: World.h:191
Definition: SharedDefines.h:4272

+ Here is the call graph for this function:

Pet* Unit::ToPet ( )
inline
2200 { if (IsPet()) return reinterpret_cast<Pet*>(this); else return NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsPet() const
Definition: Unit.h:1403
Definition: Pet.h:46

+ Here is the caller graph for this function:

Pet const* Unit::ToPet ( ) const
inline
2201 { if (IsPet()) return reinterpret_cast<Pet const*>(this); else return NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsPet() const
Definition: Unit.h:1403
#define const
Definition: zconf.h:217
Definition: Pet.h:46
TempSummon* Unit::ToTempSummon ( )
inline
2206 { if (IsSummon()) return reinterpret_cast<TempSummon*>(this); else return NULL; }
Definition: TemporarySummon.h:40
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsSummon() const
Definition: Unit.h:1401

+ Here is the caller graph for this function:

TempSummon const* Unit::ToTempSummon ( ) const
inline
2207 { if (IsSummon()) return reinterpret_cast<TempSummon const*>(this); else return NULL; }
Definition: TemporarySummon.h:40
arena_t NULL
Definition: jemalloc_internal.h:624
#define const
Definition: zconf.h:217
bool IsSummon() const
Definition: Unit.h:1401
Totem* Unit::ToTotem ( )
inline
2203 { if (IsTotem()) return reinterpret_cast<Totem*>(this); else return NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Totem.h:38
bool IsTotem() const
Definition: Unit.h:1405

+ Here is the caller graph for this function:

Totem const* Unit::ToTotem ( ) const
inline
2204 { if (IsTotem()) return reinterpret_cast<Totem const*>(this); else return NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Totem.h:38
bool IsTotem() const
Definition: Unit.h:1405
#define const
Definition: zconf.h:217
void Unit::TriggerAurasProcOnEvent ( CalcDamageInfo damageInfo)
12639 {
12640  DamageInfo dmgInfo = DamageInfo(damageInfo);
12641  TriggerAurasProcOnEvent(NULL, NULL, damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, 0, 0, damageInfo.procEx, NULL, &dmgInfo, NULL);
12642 }
uint32 procAttacker
Definition: Unit.h:1034
uint32 procVictim
Definition: Unit.h:1035
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 procEx
Definition: Unit.h:1036
Unit * target
Definition: Unit.h:1024
void TriggerAurasProcOnEvent(CalcDamageInfo &damageInfo)
Definition: Unit.cpp:12638
Definition: Unit.h:921

+ Here is the caller graph for this function:

void Unit::TriggerAurasProcOnEvent ( AuraApplicationList myProcAuras,
AuraApplicationList targetProcAuras,
Unit actionTarget,
uint32  typeMaskActor,
uint32  typeMaskActionTarget,
uint32  spellTypeMask,
uint32  spellPhaseMask,
uint32  hitMask,
Spell spell,
DamageInfo damageInfo,
HealInfo healInfo 
)
12645 {
12646  // prepare data for self trigger
12647  ProcEventInfo myProcEventInfo = ProcEventInfo(this, actionTarget, actionTarget, typeMaskActor, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo);
12648  std::list<AuraApplication*> myAurasTriggeringProc;
12649  GetProcAurasTriggeredOnEvent(myAurasTriggeringProc, myProcAuras, myProcEventInfo);
12650 
12651  // prepare data for target trigger
12652  ProcEventInfo targetProcEventInfo = ProcEventInfo(this, actionTarget, this, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo);
12653  std::list<AuraApplication*> targetAurasTriggeringProc;
12654  if (typeMaskActionTarget)
12655  GetProcAurasTriggeredOnEvent(targetAurasTriggeringProc, targetProcAuras, targetProcEventInfo);
12656 
12657  TriggerAurasProcOnEvent(myProcEventInfo, myAurasTriggeringProc);
12658 
12659  if (typeMaskActionTarget)
12660  TriggerAurasProcOnEvent(targetProcEventInfo, targetAurasTriggeringProc);
12661 }
Definition: Unit.h:984
void GetProcAurasTriggeredOnEvent(AuraApplicationList &aurasTriggeringProc, AuraApplicationList *procAuras, ProcEventInfo eventInfo)
Definition: Unit.cpp:12608
void TriggerAurasProcOnEvent(CalcDamageInfo &damageInfo)
Definition: Unit.cpp:12638

+ Here is the call graph for this function:

void Unit::TriggerAurasProcOnEvent ( ProcEventInfo eventInfo,
AuraApplicationList procAuras 
)
12664 {
12665  for (std::list<AuraApplication*>::iterator itr = aurasTriggeringProc.begin(); itr != aurasTriggeringProc.end(); ++itr)
12666  {
12667  if (!(*itr)->GetRemoveMode())
12668  (*itr)->GetBase()->TriggerProcOnEvent(*itr, eventInfo);
12669  }
12670 }
void Unit::UnsummonAllTotems ( )
8128 {
8129  for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
8130  {
8131  if (!m_SummonSlot[i])
8132  continue;
8133 
8134  if (Creature* OldTotem = GetMap()->GetCreature(m_SummonSlot[i]))
8135  if (OldTotem->IsSummon())
8136  OldTotem->ToTempSummon()->UnSummon();
8137  }
8138 }
Map * GetMap() const
Definition: Object.h:543
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
Definition: Creature.h:467
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
#define MAX_SUMMON_SLOT
Definition: Unit.h:1285
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Update ( uint32  time)
overridevirtual

Reimplemented from WorldObject.

Reimplemented in Creature, Puppet, Pet, TempSummon, and Totem.

362 {
363  // WARNING! Order of execution here is important, do not change.
364  // Spells must be processed with event system BEFORE they go to _UpdateSpells.
365  // Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
366  m_Events.Update(p_time);
367 
368  if (!IsInWorld())
369  return;
370 
371  _UpdateSpells(p_time);
372 
373  // If this is set during update SetCantProc(false) call is missing somewhere in the code
374  // Having this would prevent spells from being proced, so let's crash
375  ASSERT(!m_procDeep);
376 
377  if (CanHaveThreatList() && getThreatManager().isNeedUpdateToClient(p_time))
379 
380  // update combat timer only for players and pets (only pets with PetAI)
381  if (IsInCombat() && (GetTypeId() == TYPEID_PLAYER || (IsPet() && IsControlledByPlayer())))
382  {
383  // Check UNIT_STATE_MELEE_ATTACKING or UNIT_STATE_CHASE (without UNIT_STATE_FOLLOW in this case) so pets can reach far away
384  // targets without stopping half way there and running off.
385  // These flags are reset after target dies or another command is given.
387  {
388  // m_CombatTimer set at aura start and it will be freeze until aura removing
389  if (m_CombatTimer <= p_time)
390  ClearInCombat();
391  else
392  m_CombatTimer -= p_time;
393  }
394  }
395 
396  // not implemented before 3.0.2
397  if (uint32 base_att = getAttackTimer(BASE_ATTACK))
398  setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time));
399  if (uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
400  setAttackTimer(RANGED_ATTACK, (p_time >= ranged_att ? 0 : ranged_att - p_time));
401  if (uint32 off_att = getAttackTimer(OFF_ATTACK))
402  setAttackTimer(OFF_ATTACK, (p_time >= off_att ? 0 : off_att - p_time));
403 
404  // update abilities available only for fraction of time
405  UpdateReactives(p_time);
406 
407  if (IsAlive())
408  {
412  }
413 
414  UpdateSplineMovement(p_time);
415  i_motionMaster->UpdateMotion(p_time);
416 }
void ModifyAuraState(AuraStateType flag, bool apply)
Definition: Unit.cpp:7422
void setAttackTimer(WeaponAttackType type, uint32 time)
Definition: Unit.h:1354
EventProcessor m_Events
Definition: Unit.h:1948
void ClearInCombat()
Definition: Unit.cpp:9946
bool IsControlledByPlayer() const
Definition: Unit.h:1712
Definition: Unit.h:619
bool IsInCombat() const
Definition: Unit.h:1584
void UpdateSplineMovement(uint32 t_diff)
Definition: Unit.cpp:434
void _UpdateSpells(uint32 time)
Definition: Unit.cpp:2677
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition: Unit.cpp:10652
int32 m_procDeep
Definition: Unit.h:2261
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:1771
void UpdateMotion(uint32 diff)
Definition: MotionMaster.cpp:79
Definition: Unit.h:618
MotionMaster * i_motionMaster
Definition: Unit.h:2297
bool IsAlive() const
Definition: Unit.h:1692
void UpdateReactives(uint32 p_time)
Definition: Unit.cpp:12854
bool HealthBelowPct(int32 pct) const
Definition: Unit.h:1430
uint32_t uint32
Definition: Define.h:150
HostileRefManager m_HostileRefManager
Definition: Unit.h:2346
bool isEmpty() const
Definition: LinkedList.h:102
bool IsPet() const
Definition: Unit.h:1403
bool HealthAbovePct(int32 pct) const
Definition: Unit.h:1432
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:1759
ThreatManager & getThreatManager()
Definition: Unit.h:1998
uint32 m_CombatTimer
Definition: Unit.h:2341
#define ASSERT
Definition: Errors.h:55
void Update(uint32 p_time)
Definition: EventProcessor.cpp:32
bool IsInWorld() const
Definition: Object.h:100
Definition: SharedDefines.h:1781
Definition: Unit.h:617
uint32 getAttackTimer(WeaponAttackType type) const
Definition: Unit.h:1356
void SendThreatListUpdate()
Definition: Unit.cpp:15511

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::UpdateAllResistances ( )
virtual
55 {
56  for (uint8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
58 }
virtual void UpdateResistances(uint32 school)=0
#define MAX_SPELL_SCHOOL
Definition: SharedDefines.h:283
Definition: SharedDefines.h:274
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual bool Unit::UpdateAllStats ( )
pure virtual

Implemented in Creature, Guardian, and Totem.

virtual void Unit::UpdateArmor ( )
pure virtual

Implemented in Creature, Guardian, and Totem.

+ Here is the caller graph for this function:

virtual void Unit::UpdateAttackPowerAndDamage ( bool  ranged = false)
pure virtual

Implemented in Creature, Guardian, and Totem.

+ Here is the caller graph for this function:

void Unit::UpdateAuraForGroup ( uint8  slot)
13063 {
13064  if (slot >= MAX_AURAS) // slot not found, return
13065  return;
13066  if (Player* player = ToPlayer())
13067  {
13068  if (player->GetGroup())
13069  player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS);
13070  }
13071  else if (GetTypeId() == TYPEID_UNIT && IsPet())
13072  {
13073  Pet* pet = ((Pet*)this);
13074  if (pet->isControlled())
13076  }
13077 }
Definition: ObjectGuid.h:32
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
bool isControlled() const
Definition: Pet.h:59
bool IsPet() const
Definition: Unit.h:1403
void SetGroupUpdateFlag(uint32 flag)
Definition: Pet.cpp:1928
Definition: Group.h:138
#define MAX_AURAS
Definition: SpellAuraDefines.h:21
Definition: Group.h:118
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::UpdateCharmAI ( )
11810 {
11811  if (GetTypeId() == TYPEID_PLAYER)
11812  return;
11813 
11814  if (i_disabledAI) // disabled AI must be primary AI
11815  {
11816  if (!IsCharmed())
11817  {
11818  delete i_AI;
11819  i_AI = i_disabledAI;
11820  i_disabledAI = NULL;
11821  }
11822  }
11823  else
11824  {
11825  if (IsCharmed())
11826  {
11827  i_disabledAI = i_AI;
11828  if (isPossessed() || IsVehicle())
11829  i_AI = new PossessedAI(ToCreature());
11830  else
11831  i_AI = new PetAI(ToCreature());
11832  }
11833  }
11834 }
bool IsVehicle() const
Definition: Unit.h:1406
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: PassiveAI.h:36
UnitAI * i_AI
Definition: Unit.h:2242
UnitAI * i_disabledAI
Definition: Unit.h:2242
TypeID GetTypeId() const
Definition: Object.h:113
bool isPossessed() const
Definition: Unit.h:1743
Definition: PetAI.h:28
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
bool IsCharmed() const
Definition: Unit.h:1742

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::UpdateDamagePhysical ( WeaponAttackType  attType)
virtual

Reimplemented in Guardian, and Totem.

61 {
62  float minDamage = 0.0f;
63  float maxDamage = 0.0f;
64 
65  CalculateMinMaxDamage(attType, false, true, minDamage, maxDamage);
66 
67  switch (attType)
68  {
69  case BASE_ATTACK:
70  default:
73  break;
74  case OFF_ATTACK:
77  break;
78  case RANGED_ATTACK:
81  break;
82  }
83 }
void SetStatFloatValue(uint16 index, float value)
Definition: Object.cpp:1135
Definition: UpdateFields.h:120
Definition: UpdateFields.h:123
Definition: Unit.h:619
Definition: UpdateFields.h:121
Definition: UpdateFields.h:155
virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage)=0
Definition: Unit.h:618
Definition: UpdateFields.h:156
Definition: UpdateFields.h:122
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::UpdateHeight ( float  newZ)

Only server-side height update, does not broadcast to client.

15505 {
15506  Relocate(GetPositionX(), GetPositionY(), newZ);
15507  if (IsVehicle())
15509 }
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
Definition: Vehicle.cpp:520
bool IsVehicle() const
Definition: Unit.h:1406
void Relocate(float x, float y)
Definition: Position.h:67
float GetPositionY() const
Definition: Position.h:105
float GetPositionX() const
Definition: Position.h:104
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::UpdateInterruptMask ( )
558 {
559  m_interruptMask = 0;
560  for (AuraApplicationList::const_iterator i = m_interruptableAuras.begin(); i != m_interruptableAuras.end(); ++i)
561  m_interruptMask |= (*i)->GetBase()->GetSpellInfo()->AuraInterruptFlags;
562 
564  if (spell->getState() == SPELL_STATE_CASTING)
565  m_interruptMask |= spell->m_spellInfo->ChannelInterruptFlags;
566 }
Definition: Unit.h:1110
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2271
AuraApplicationList m_interruptableAuras
Definition: Unit.h:2281
Definition: Spell.h:278
uint32 m_interruptMask
Definition: Unit.h:2283
Definition: Spell.h:294

+ Here is the caller graph for this function:

virtual void Unit::UpdateMaxHealth ( )
pure virtual

Implemented in Creature, Guardian, and Totem.

+ Here is the caller graph for this function:

virtual void Unit::UpdateMaxPower ( Powers  power)
pure virtual

Implemented in Creature, Guardian, and Totem.

+ Here is the caller graph for this function:

void Unit::UpdateObjectVisibility ( bool  forced = true)
overridevirtual

Reimplemented from WorldObject.

14631 {
14632  if (!forced)
14634  else
14635  {
14637  // call MoveInLineOfSight for nearby creatures
14638  Trinity::AIRelocationNotifier notifier(*this);
14640  }
14641 }
Definition: Object.h:74
Definition: GridNotifiers.h:97
void AddToNotify(uint16 f)
Definition: Object.h:574
float GetVisibilityRange() const
Definition: Object.cpp:1912
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:587
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:3001

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::UpdateOrientation ( float  orientation)

Only server-side orientation update, does not broadcast to client.

15497 {
15498  SetOrientation(orientation);
15499  if (IsVehicle())
15501 }
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
Definition: Vehicle.cpp:520
bool IsVehicle() const
Definition: Unit.h:1406
void SetOrientation(float orientation)
Definition: Position.h:99
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::UpdatePosition ( float  x,
float  y,
float  z,
float  ang,
bool  teleport = false 
)
virtual
15455 {
15456  // prevent crash when a bad coord is sent by the client
15457  if (!Trinity::IsValidMapCoord(x, y, z, orientation))
15458  {
15459  TC_LOG_DEBUG("entities.unit", "Unit::UpdatePosition(%f, %f, %f) .. bad coordinates!", x, y, z);
15460  return false;
15461  }
15462 
15463  bool turn = (GetOrientation() != orientation);
15464  bool relocated = (teleport || GetPositionX() != x || GetPositionY() != y || GetPositionZ() != z);
15465 
15466  // TODO: Check if orientation transport offset changed instead of only global orientation
15467  if (turn)
15469 
15470  if (relocated)
15471  {
15472  if (!GetVehicle())
15474 
15475  // move and update visible state if need
15476  if (GetTypeId() == TYPEID_PLAYER)
15477  GetMap()->PlayerRelocation(ToPlayer(), x, y, z, orientation);
15478  else
15479  GetMap()->CreatureRelocation(ToCreature(), x, y, z, orientation);
15480  }
15481  else if (turn)
15482  UpdateOrientation(orientation);
15483 
15484  // code block for underwater state update
15486 
15487  return (relocated || turn);
15488 }
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
Definition: Map.cpp:982
Definition: Unit.h:57
Map * GetMap() const
Definition: Object.h:543
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
float GetOrientation() const
Definition: Position.h:107
bool IsValidMapCoord(float c)
Definition: GridDefines.h:218
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
virtual void UpdateUnderwaterState(Map *m, float x, float y, float z)
Definition: Unit.cpp:2974
Definition: Unit.h:58
float GetPositionZ() const
Definition: Position.h:106
G3D::int16 y
Definition: Vector2int16.h:38
void PlayerRelocation(Player *, float x, float y, float z, float orientation)
Definition: Map.cpp:950
void UpdateOrientation(float orientation)
Only server-side orientation update, does not broadcast to client.
Definition: Unit.cpp:15496
Definition: ObjectGuid.h:33
Vehicle * GetVehicle() const
Definition: Unit.h:2166
Creature * ToCreature()
Definition: Object.h:194
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Unit::UpdatePosition ( const Position pos,
bool  teleport = false 
)
virtual
15491 {
15492  return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport);
15493 }
float GetOrientation() const
Definition: Position.h:107
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport=false)
Definition: Unit.cpp:15454
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

void Unit::UpdateReactives ( uint32  p_time)
12855 {
12856  for (uint8 i = 0; i < MAX_REACTIVE; ++i)
12857  {
12858  ReactiveType reactive = ReactiveType(i);
12859 
12860  if (!m_reactiveTimer[reactive])
12861  continue;
12862 
12863  if (m_reactiveTimer[reactive] <= p_time)
12864  {
12865  m_reactiveTimer[reactive] = 0;
12866 
12867  switch (reactive)
12868  {
12869  case REACTIVE_DEFENSE:
12872  break;
12873  case REACTIVE_HUNTER_PARRY:
12876  break;
12877  case REACTIVE_OVERPOWER:
12878  if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
12879  ToPlayer()->ClearComboPoints();
12880  break;
12881  }
12882  }
12883  else
12884  {
12885  m_reactiveTimer[reactive] -= p_time;
12886  }
12887  }
12888 }
void ModifyAuraState(AuraStateType flag, bool apply)
Definition: Unit.cpp:7422
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
Definition: SharedDefines.h:1758
uint32 m_reactiveTimer[MAX_REACTIVE]
Definition: Unit.h:2299
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:167
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:1274
Definition: Unit.h:1275
ReactiveType
Definition: Unit.h:1272
#define MAX_REACTIVE
Definition: Unit.h:1279
Definition: SharedDefines.h:1764
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:169
uint8 getClass() const
Definition: Unit.h:1413
uint8_t uint8
Definition: Define.h:152
Definition: Unit.h:1276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Unit::UpdateResistances ( uint32  school)
pure virtual

Implemented in Creature, Guardian, and Totem.

+ Here is the caller graph for this function:

void Unit::UpdateSpeed ( UnitMoveType  mtype,
bool  forced 
)
Todo:
possible affect only on MOVE_RUN
10379 {
10380  int32 main_speed_mod = 0;
10381  float stack_bonus = 1.0f;
10382  float non_stack_bonus = 1.0f;
10383 
10384  switch (mtype)
10385  {
10386  // Only apply debuffs
10387  case MOVE_FLIGHT_BACK:
10388  case MOVE_RUN_BACK:
10389  case MOVE_SWIM_BACK:
10390  break;
10391  case MOVE_WALK:
10392  return;
10393  case MOVE_RUN:
10394  {
10395  if (IsMounted()) // Use on mount auras
10396  {
10400  }
10401  else
10402  {
10405  non_stack_bonus += GetMaxPositiveAuraModifier(SPELL_AURA_MOD_SPEED_NOT_STACK) / 100.0f;
10406  }
10407  break;
10408  }
10409  case MOVE_SWIM:
10410  {
10412  break;
10413  }
10414  case MOVE_FLIGHT:
10415  {
10416  if (GetTypeId() == TYPEID_UNIT && IsControlledByPlayer()) // not sure if good for pet
10417  {
10420 
10421  // for some spells this mod is applied on vehicle owner
10422  int32 owner_speed_mod = 0;
10423 
10424  if (Unit* owner = GetCharmer())
10425  owner_speed_mod = owner->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED);
10426 
10427  main_speed_mod = std::max(main_speed_mod, owner_speed_mod);
10428  }
10429  else if (IsMounted())
10430  {
10433  }
10434  else // Use not mount (shapeshift for example) auras (should stack)
10436 
10438 
10439  // Update speed for vehicle if available
10440  if (GetTypeId() == TYPEID_PLAYER && GetVehicle())
10442  break;
10443  }
10444  default:
10445  TC_LOG_ERROR("entities.unit", "Unit::UpdateSpeed: Unsupported move type (%d)", mtype);
10446  return;
10447  }
10448 
10449  // now we ready for speed calculation
10450  float speed = std::max(non_stack_bonus, stack_bonus);
10451  if (main_speed_mod)
10452  AddPct(speed, main_speed_mod);
10453 
10454  switch (mtype)
10455  {
10456  case MOVE_RUN:
10457  case MOVE_SWIM:
10458  case MOVE_FLIGHT:
10459  {
10460  // Set creature speed rate
10461  if (GetTypeId() == TYPEID_UNIT)
10462  {
10463  Unit* pOwner = GetCharmerOrOwner();
10464  if ((IsPet() || IsGuardian()) && !IsInCombat() && pOwner) // Must check for owner or crash on "Tame Beast"
10465  {
10466  // For every yard over 5, increase speed by 0.01
10467  // to help prevent pet from lagging behind and despawning
10468  float dist = GetDistance(pOwner);
10469  float base_rate = 1.00f; // base speed is 100% of owner speed
10470 
10471  if (dist < 5)
10472  dist = 5;
10473 
10474  float mult = base_rate + ((dist - 5) * 0.01f);
10475 
10476  speed *= pOwner->GetSpeedRate(mtype) * mult; // pets derive speed from owner when not in combat
10477  }
10478  else
10479  speed *= ToCreature()->GetCreatureTemplate()->speed_run; // at this point, MOVE_WALK is never reached
10480  }
10481 
10482  // Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need
10485  {
10486  if (Creature* creature = ToCreature())
10487  {
10488  uint32 immuneMask = creature->GetCreatureTemplate()->MechanicImmuneMask;
10489  if (immuneMask & (1 << MECHANIC_SNARE) || immuneMask & (1 << MECHANIC_DAZE))
10490  break;
10491  }
10492 
10493  // Use speed from aura
10494  float max_speed = normalization / (IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]);
10495  if (speed > max_speed)
10496  speed = max_speed;
10497  }
10498  break;
10499  }
10500  default:
10501  break;
10502  }
10503 
10504  // for creature case, we check explicit if mob searched for assistance
10505  if (GetTypeId() == TYPEID_UNIT)
10506  {
10508  speed *= 0.66f; // best guessed value, so this will be 33% reduction. Based off initial speed, mob can then "run", "walk fast" or "walk".
10509  }
10510 
10511  // Apply strongest slow aura mod to speed
10513  if (slow)
10514  AddPct(speed, slow);
10515 
10516  if (float minSpeedMod = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED))
10517  {
10518  float min_speed = minSpeedMod / 100.0f;
10519  if (speed < min_speed)
10520  speed = min_speed;
10521  }
10522 
10523  SetSpeed(mtype, speed, forced);
10524 }
Unit * GetCharmer() const
Definition: Unit.cpp:7551
Definition: SpellAuraDefines.h:231
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
Definition: Unit.h:605
Definition: SharedDefines.h:1817
bool IsControlledByPlayer() const
Definition: Unit.h:1712
float speed_run
Definition: Creature.h:100
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
Definition: SpellAuraDefines.h:269
void UpdateSpeed(UnitMoveType mtype, bool forced)
Definition: Unit.cpp:10378
bool IsInCombat() const
Definition: Unit.h:1584
Definition: SpellAuraDefines.h:251
Definition: SpellAuraDefines.h:118
Definition: ObjectGuid.h:32
Definition: SpellAuraDefines.h:365
bool HasSearchedAssistance() const
Definition: Creature.h:620
int32 GetMaxNegativeAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4440
Definition: Unit.h:599
Definition: Creature.h:467
Definition: SharedDefines.h:1801
Definition: Unit.h:601
T max(const T &x, const T &y)
Definition: g3dmath.h:320
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:602
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: SpellAuraDefines.h:189
Definition: SpellAuraDefines.h:232
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
bool IsGuardian() const
Definition: Unit.h:1402
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
Definition: SpellAuraDefines.h:92
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
float playerBaseMoveSpeed[MAX_MOVE_TYPE]
Definition: Unit.cpp:88
Definition: SpellAuraDefines.h:266
Definition: SpellAuraDefines.h:268
int32 GetMaxPositiveAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4426
Definition: SpellAuraDefines.h:270
bool IsPet() const
Definition: Unit.h:1403
Definition: Unit.h:600
Definition: ObjectGuid.h:33
Vehicle * GetVehicle() const
Definition: Unit.h:2166
Creature * ToCreature()
Definition: Object.h:194
T AddPct(T &base, U pct)
Definition: Util.h:98
float baseMoveSpeed[MAX_MOVE_TYPE]
Definition: Unit.cpp:75
bool IsMounted() const
Definition: Unit.h:1496
Definition: Unit.h:606
Definition: SpellAuraDefines.h:190
Definition: SpellAuraDefines.h:93
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:10531
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:603
Definition: SpellAuraDefines.h:271
Definition: SpellAuraDefines.h:267
Definition: SpellAuraDefines.h:91
Definition: Unit.h:1305
float GetTotalAuraMultiplier(AuraType auratype) const
Definition: Unit.cpp:4415
float GetSpeedRate(UnitMoveType mtype) const
Definition: Unit.h:2087

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::UpdateSplineMovement ( uint32  t_diff)
private
435 {
436  if (movespline->Finalized())
437  return;
438 
439  movespline->updateState(t_diff);
440  bool arrived = movespline->Finalized();
441 
442  if (arrived)
443  DisableSpline();
444 
445  m_movesplineTimer.Update(t_diff);
446  if (m_movesplineTimer.Passed() || arrived)
448 }
Movement::MoveSpline * movespline
Definition: Unit.h:2213
TimeTrackerSmall m_movesplineTimer
Definition: Unit.h:2342
void UpdateSplinePosition()
Definition: Unit.cpp:450
void Update(int32 diff)
Definition: Timer.h:143
bool Finalized() const
Definition: MoveSpline.h:129
void updateState(int32 difftime, UpdateHandler &handler)
Definition: MoveSpline.h:111
void DisableSpline()
Definition: Unit.cpp:475
bool Passed() const
Definition: Timer.h:148

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::UpdateSplinePosition ( )
private
451 {
452  static uint32 const positionUpdateDelay = 400;
453 
454  m_movesplineTimer.Reset(positionUpdateDelay);
456 
457  if (movespline->onTransport)
458  {
460  pos.m_positionX = loc.x;
461  pos.m_positionY = loc.y;
462  pos.m_positionZ = loc.z;
463  pos.SetOrientation(loc.orientation);
464 
465  if (TransportBase* transport = GetDirectTransport())
466  transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, &loc.orientation);
467  }
468 
470  loc.orientation = GetOrientation();
471 
472  UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
473 }
float x
Definition: Vector3.h:62
float m_positionY
Definition: Position.h:53
void SetOrientation(float orientation)
Definition: Position.h:99
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: MoveSpline.h:36
Movement::MoveSpline * movespline
Definition: Unit.h:2213
float m_positionX
Definition: Position.h:52
TimeTrackerSmall m_movesplineTimer
Definition: Unit.h:2342
float y
Definition: Vector3.h:62
struct MovementInfo::TransportInfo transport
Definition: VehicleDefines.h:119
bool onTransport
Definition: MoveSpline.h:136
Definition: Unit.h:591
float GetOrientation() const
Definition: Position.h:107
TransportBase * GetDirectTransport() const
Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) ...
Definition: Unit.cpp:14365
float orientation
Definition: MoveSpline.h:43
uint32_t uint32
Definition: Define.h:150
float m_positionZ
Definition: Position.h:54
void Reset(uint32 interval)
Definition: Timer.h:153
Position pos
Definition: Object.h:290
float z
Definition: Vector3.h:62
Location ComputePosition() const
Definition: MoveSpline.cpp:27
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
Definition: Position.h:27
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport=false)
Definition: Unit.cpp:15454

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual bool Unit::UpdateStats ( Stats  stat)
pure virtual

Implemented in Creature, Guardian, and Totem.

+ Here is the caller graph for this function:

void Unit::UpdateUnderwaterState ( Map m,
float  x,
float  y,
float  z 
)
virtual
2975 {
2976  if (IsFlying() || (!IsPet() && !IsVehicle()))
2977  return;
2978 
2979  LiquidData liquid_status;
2980  ZLiquidStatus res = m->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquid_status);
2981  if (!res)
2982  {
2985 
2987  _lastLiquid = NULL;
2988  return;
2989  }
2990 
2991  if (uint32 liqEntry = liquid_status.entry)
2992  {
2993  LiquidTypeEntry const* liquid = sLiquidTypeStore.LookupEntry(liqEntry);
2994  if (_lastLiquid && _lastLiquid->SpellID && _lastLiquid->ID != liqEntry)
2996 
2997  if (liquid && liquid->SpellID)
2998  {
3000  {
3001  if (!HasAura(liquid->SpellID))
3002  CastSpell(this, liquid->SpellID, true);
3003  }
3004  else
3005  RemoveAurasDueToSpell(liquid->SpellID);
3006  }
3007 
3009  _lastLiquid = liquid;
3010  }
3011  else if (_lastLiquid && _lastLiquid->SpellID)
3012  {
3015  _lastLiquid = NULL;
3016  }
3017 }
DBCStorage< LiquidTypeEntry > sLiquidTypeStore(LiquidTypefmt)
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
Definition: Map.h:136
bool IsFlying() const
Definition: Unit.h:2189
bool IsVehicle() const
Definition: Unit.h:1406
Definition: Map.h:151
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 ID
Definition: DBCStructure.h:791
Definition: DBCStructure.h:789
G3D::int16 z
Definition: Vector3int16.h:46
#define MAP_ALL_LIQUIDS
Definition: Map.h:146
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
ZLiquidStatus
Definition: Map.h:131
uint32 entry
Definition: Map.h:154
bool IsPet() const
Definition: Unit.h:1403
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3586
uint32 SpellID
Definition: DBCStructure.h:796
G3D::int16 x
Definition: Vector2int16.h:37
Definition: Map.h:137
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
LiquidTypeEntry const * _lastLiquid
Definition: Unit.h:2308
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=nullptr) const
Definition: Map.cpp:2497

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Whisper ( std::string const text,
Language  language,
Player target,
bool  isBossWhisper = false 
)
virtual
16409 {
16410  if (!target)
16411  return;
16412 
16413  LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex();
16414  WorldPackets::Chat::Chat packet;
16415  packet.Initialize(isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, language, this, target, text, 0, "", locale);
16416  target->SendDirectMessage(packet.Write());
16417 }
Definition: SharedDefines.h:4246
Definition: ChatPackets.h:150
WorldPacket const * Write() override
Definition: ChatPackets.cpp:162
LocaleConstant
Definition: Common.h:115
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:104
Definition: SharedDefines.h:4273

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Whisper ( uint32  textId,
Player target,
bool  isBossWhisper = false 
)
16466 {
16467  if (!target)
16468  return;
16469 
16470  BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(textId);
16471  if (!bct)
16472  {
16473  TC_LOG_ERROR("entities.unit", "WorldObject::MonsterWhisper: `broadcast_text` was not %u found", textId);
16474  return;
16475  }
16476 
16477  LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex();
16478  WorldPackets::Chat::Chat packet;
16479  packet.Initialize(isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, DB2Manager::GetBroadcastTextValue(bct, locale, getGender()), 0, "", locale);
16480  target->SendDirectMessage(packet.Write());
16481 }
Definition: SharedDefines.h:961
DB2Storage< BroadcastTextEntry > sBroadcastTextStore("BroadcastText.db2", BroadcastTextFormat, HOTFIX_SEL_BROADCAST_TEXT)
Definition: SharedDefines.h:4246
Definition: ChatPackets.h:150
static char const * GetBroadcastTextValue(BroadcastTextEntry const *broadcastText, LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false)
Definition: DB2Stores.cpp:610
Definition: DB2Structure.h:112
WorldPacket const * Write() override
Definition: ChatPackets.cpp:162
LocaleConstant
Definition: Common.h:115
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:104
Definition: SharedDefines.h:4273
uint8 getGender() const
Definition: Unit.h:1415
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

void Unit::Yell ( std::string const text,
Language  language,
WorldObject const target = nullptr 
)
virtual
16399 {
16400  Talk(text, CHAT_MSG_MONSTER_YELL, language, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), target);
16401 }
virtual void Talk(std::string const &text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
Definition: Unit.cpp:16385
#define sWorld
Definition: World.h:887
Definition: SharedDefines.h:4245
Definition: World.h:192

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Unit::Yell ( uint32  textId,
WorldObject const target = nullptr 
)
16456 {
16457  Talk(textId, CHAT_MSG_MONSTER_YELL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), target);
16458 }
virtual void Talk(std::string const &text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
Definition: Unit.cpp:16385
#define sWorld
Definition: World.h:887
Definition: SharedDefines.h:4245
Definition: World.h:192

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class VehicleJoinEvent
friend

Member Data Documentation

uint16 Unit::_aiAnimKitId
private
bool Unit::_isWalkingBeforeCharm
private

Are we walking before we were charmed?

time_t Unit::_lastDamagedTime
private
LiquidTypeEntry const* Unit::_lastLiquid
protected
uint16 Unit::_meleeAnimKitId
private
uint16 Unit::_movementAnimKitId
private
uint32 Unit::_oldFactionId
private

faction before charm

RedirectThreatInfo Unit::_redirectThreadInfo
private
SpellHistory* Unit::_spellHistory
private
UnitAI* Unit::i_AI
protected
UnitAI * Unit::i_disabledAI
protected
MotionMaster* Unit::i_motionMaster
protected
bool Unit::IsAIEnabled
ObjectGuid Unit::LastCharmerGUID
AuraApplicationMap Unit::m_appliedAuras
protected
AttackerSet Unit::m_attackers
protected
Unit* Unit::m_attacking
protected
uint32 Unit::m_attackTimer[MAX_ATTACK]
protected
float Unit::m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
protected
AuraStateAurasMap Unit::m_auraStateAuras
protected
AuraMap::iterator Unit::m_auraUpdateIterator
protected
bool Unit::m_AutoRepeatFirstCast
protected
int32 Unit::m_baseSpellCritChance
bool Unit::m_canDualWield
bool Unit::m_canModifyStats
protected
CharmInfo* Unit::m_charmInfo
protected
bool Unit::m_cleanupDone
private
uint32 Unit::m_CombatTimer
private
ControlList Unit::m_Controlled
bool Unit::m_ControlledByPlayer
float Unit::m_createStats[MAX_STATS]
protected
Spell* Unit::m_currentSpells[CURRENT_MAX_SPELL]
protected
DeathState Unit::m_deathState
protected
Diminishing Unit::m_Diminishing
private
bool Unit::m_duringRemoveFromWorld
private
DynObjectList Unit::m_dynObj
protected
EventProcessor Unit::m_Events
uint32 Unit::m_extraAttacks
FollowerRefManager Unit::m_FollowingRefManager
private
GameObjectList Unit::m_gameObj
protected
HostileRefManager Unit::m_HostileRefManager
private
AuraApplicationList Unit::m_interruptableAuras
protected
uint32 Unit::m_interruptMask
protected
uint32 Unit::m_lastSanctuaryTime
float Unit::m_modAttackSpeedPct[3]
AuraEffectList Unit::m_modAuras[TOTAL_AURAS]
protected
float Unit::m_modMeleeHitChance
float Unit::m_modRangedHitChance
float Unit::m_modSpellHitChance
Player* Unit::m_movedPlayer
uint32 Unit::m_movementCounter
protected

Incrementing counter used in movement packets.

TimeTrackerSmall Unit::m_movesplineTimer
private
ObjectGuid Unit::m_ObjectSlot[MAX_GAMEOBJECT_SLOT]
AuraMap Unit::m_ownedAuras
protected
PetAuraSet Unit::m_petAuras
int32 Unit::m_procDeep
protected
uint32 Unit::m_reactiveTimer[MAX_REACTIVE]
protected
uint32 Unit::m_regenTimer
protected
AuraList Unit::m_removedAuras
protected
uint32 Unit::m_removedAurasCount
protected
AuraList Unit::m_scAuras
protected
SharedVisionList Unit::m_sharedVision
protected
bool Unit::m_shouldReacquireTarget
protected
float Unit::m_speed_rate[MAX_MOVE_TYPE]
protected
SpellImmuneList Unit::m_spellImmune[MAX_SPELL_IMMUNITY]
uint32 Unit::m_state
private
ObjectGuid Unit::m_SummonSlot[MAX_SUMMON_SLOT]
ThreatManager Unit::m_ThreatManager
protected
float Unit::m_threatModifier[MAX_SPELL_SCHOOL]
uint32 Unit::m_transform
protected
uint32 Unit::m_unitTypeMask
protected
Vehicle* Unit::m_vehicle
protected
Vehicle* Unit::m_vehicleKit
protected
VisibleAuraMap Unit::m_visibleAuras
protected
float Unit::m_weaponDamage[MAX_ATTACK][2]
protected
Movement::MoveSpline* Unit::movespline
bool Unit::NeedChangeAI

The documentation for this class was generated from the following files: