aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortobmaps <spambot42@yandex.ru>2011-06-16 20:08:28 +0700
committertobmaps <spambot42@yandex.ru>2011-06-16 20:08:28 +0700
commit1abdb65f5aabc7a18af63240fb70ae105f6504b4 (patch)
tree1abd55be1151e69f696f07b9349be7df4b35043d /src
parenta7cb1b496346d0353bacbd77241f31eceaf12427 (diff)
Core/Misc: Cleanups, code style and typo fixes
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp9
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp1122
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuraEffects.cpp2
-rwxr-xr-xsrc/server/game/Spells/SpellScript.h2
4 files changed, 571 insertions, 564 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index af1ffc96188..a51a8c9694d 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -1254,7 +1254,7 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
else if (type == DAMAGE_SLIME)
CalcAbsorbResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist);
- damage-=absorb+resist;
+ damage -= absorb + resist;
DealDamageMods(this, damage, &absorb);
@@ -1412,7 +1412,7 @@ void Player::HandleDrowning(uint32 time_diff)
// Calculate and deal damage
// TODO: Check this formula
uint32 damage = urand(600, 700);
- if (m_MirrorTimerFlags&UNDERWATER_INLAVA)
+ if (m_MirrorTimerFlags & UNDERWATER_INLAVA)
EnvironmentalDamage(DAMAGE_LAVA, damage);
// need to skip Slime damage in Undercity,
// maybe someone can find better way to handle environmental damage
@@ -5143,8 +5143,9 @@ bool Player::FallGround(uint8 FallMode)
// Below formula for falling damage is from Player::HandleFall
if (FallMode == 2 && z_diff >= 14.57f)
{
- uint32 damage = std::min(GetMaxHealth(), (uint32)((0.018f*z_diff-0.2426f)*GetMaxHealth()*sWorld->getRate(RATE_DAMAGE_FALL)));
- if (damage > 0) EnvironmentalDamage(DAMAGE_FALL, damage);
+ uint32 damage = std::min(GetMaxHealth(), (uint32)((0.018f * z_diff - 0.2426f) * GetMaxHealth() * sWorld->getRate(RATE_DAMAGE_FALL)));
+ if (damage)
+ EnvironmentalDamage(DAMAGE_FALL, damage);
}
else if (FallMode == 0)
Unit::setDeathState(DEAD_FALLING);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 9657622a3a9..c500501e440 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -275,7 +275,7 @@ void Unit::Update(uint32 p_time)
}
}
- //not implemented before 3.0.2
+ // not implemented before 3.0.2
//if (!HasUnitState(UNIT_STAT_CASTING))
{
if (uint32 base_att = getAttackTimer(BASE_ATTACK))
@@ -299,7 +299,7 @@ void Unit::Update(uint32 p_time)
bool Unit::haveOffhandWeapon() const
{
if (GetTypeId() == TYPEID_PLAYER)
- return this->ToPlayer()->GetWeaponForAttack(OFF_ATTACK, true);
+ return ToPlayer()->GetWeaponForAttack(OFF_ATTACK, true);
else
return m_canDualWield;
}
@@ -336,7 +336,7 @@ void Unit::SetFacing(float ori, WorldObject* obj)
WorldPacket data(SMSG_MONSTER_MOVE, (1+12+4+1+(obj ? 8 : 4)+4+4+4+12+GetPackGUID().size()));
data.append(GetPackGUID());
- data << uint8(0);//unk
+ data << uint8(0); // unk
data << GetPositionX() << GetPositionY() << GetPositionZ();
data << getMSTime();
if (obj)
@@ -350,8 +350,8 @@ void Unit::SetFacing(float ori, WorldObject* obj)
data << ori;
}
data << uint32(SPLINEFLAG_NONE);
- data << uint32(0);//move time 0
- data << uint32(1);//one point
+ data << uint32(0); // move time 0
+ data << uint32(1); // one point
data << GetPositionX() << GetPositionY() << GetPositionZ();
SendMessageToSet(&data, true);
}
@@ -519,13 +519,13 @@ void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z,
{
//sLog->outError("Unit %u (Type: %u) has invalid combat_reach %f", GetGUIDLow(), GetTypeId(), combat_reach);
//if (GetTypeId() == TYPEID_UNIT)
- // sLog->outError("Creature entry %u has invalid combat_reach", this->ToCreature()->GetEntry());
+ // sLog->outError("Creature entry %u has invalid combat_reach", ToCreature()->GetEntry());
combat_reach = DEFAULT_COMBAT_REACH;
}
uint32 attacker_number = getAttackers().size();
if (attacker_number > 0)
--attacker_number;
- GetNearPoint(obj, x, y, z, obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*(float)rand_norm()
+ GetNearPoint(obj, x, y, z, obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin) * (float)rand_norm()
, 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));
}
@@ -544,9 +544,9 @@ bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint
{
if (!HasAuraType(auraType))
return false;
- AuraEffectList const &auras = GetAuraEffectsByType(auraType);
+ AuraEffectList const& auras = GetAuraEffectsByType(auraType);
for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
- if (SpellEntry const *iterSpellProto = (*itr)->GetSpellProto())
+ if (SpellEntry const* iterSpellProto = (*itr)->GetSpellProto())
if (iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags[0] & familyFlags)
return true;
return false;
@@ -556,10 +556,10 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
{
if (!pVictim->isAlive() || pVictim->HasUnitState(UNIT_STAT_IN_FLIGHT) || (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsInEvadeMode()))
{
- if (absorb)
- *absorb += damage;
- damage = 0;
- return;
+ if (absorb)
+ *absorb += damage;
+ damage = 0;
+ return;
}
uint32 originalDamage = damage;
@@ -675,7 +675,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if (GetTypeId() == TYPEID_PLAYER && this != pVictim)
{
- Player* killer = this->ToPlayer();
+ Player* killer = ToPlayer();
// in bg, count dmg if victim is also a player
if (pVictim->GetTypeId() == TYPEID_PLAYER)
@@ -706,7 +706,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
pVictim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, health);
// call before auras are removed
- if (Player* killer = this->ToPlayer()) // keep the this-> for clarity
+ if (Player* killer = ToPlayer())
killer->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, 1, 0, pVictim);
}
@@ -754,7 +754,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if (roll_chance_f(sWorld->getRate(RATE_DURABILITY_LOSS_DAMAGE)))
{
EquipmentSlots slot = EquipmentSlots(urand(0, EQUIPMENT_SLOT_END-1));
- this->ToPlayer()->DurabilityPointLossForEquipSlot(slot);
+ ToPlayer()->DurabilityPointLossForEquipSlot(slot);
}
}
@@ -793,7 +793,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if (duel_hasEnded)
{
ASSERT(pVictim->GetTypeId() == TYPEID_PLAYER);
- Player *he = pVictim->ToPlayer();
+ Player* he = pVictim->ToPlayer();
ASSERT(he->duel);
@@ -821,7 +821,7 @@ void Unit::CastStop(uint32 except_spellid)
void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, AuraEffect const* triggeredByAura, uint64 originalCaster)
{
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
{
@@ -840,7 +840,7 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered,
return;
}
- if (!originalCaster && GetTypeId() == TYPEID_UNIT && this->ToCreature()->isTotem() && IsControlledByPlayer())
+ if (!originalCaster && GetTypeId() == TYPEID_UNIT && ToCreature()->isTotem() && IsControlledByPlayer())
if (Unit* owner = GetOwner())
originalCaster=owner->GetGUID();
@@ -880,7 +880,7 @@ void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit*
void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim, bool triggered, Item *castItem, AuraEffect const* triggeredByAura, uint64 originalCaster)
{
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
{
sLog->outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
@@ -910,7 +910,7 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit*
// used for scripting
void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, AuraEffect const* triggeredByAura, uint64 originalCaster, Unit* OriginalVictim)
{
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
{
@@ -940,7 +940,7 @@ void Unit::CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castI
if (!go)
return;
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
{
@@ -971,7 +971,7 @@ void Unit::CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castI
// Obsolete func need remove, here only for comotability vs another patches
uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage)
{
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID);
SpellNonMeleeDamage damageInfo(this, pVictim, spellInfo->Id, spellInfo->SchoolMask);
damage = SpellDamageBonus(pVictim, spellInfo, damage, SPELL_DIRECT_DAMAGE);
CalculateSpellDamageTaken(&damageInfo, damage, spellInfo);
@@ -1048,7 +1048,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
if (blocked)
{
damageInfo->blocked = pVictim->GetShieldBlockValue();
- //double blocked amount if block is critical
+ // double blocked amount if block is critical
if (pVictim->isBlockCritical())
damageInfo->blocked += damageInfo->blocked;
if (damage < int32(damageInfo->blocked))
@@ -1103,7 +1103,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
if (!pVictim->isAlive() || pVictim->HasUnitState(UNIT_STAT_IN_FLIGHT) || (pVictim->HasUnitState(UNIT_STAT_ONVEHICLE) && pVictim->GetVehicleBase() != this) || (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsInEvadeMode()))
return;
- SpellEntry const *spellProto = sSpellStore.LookupEntry(damageInfo->SpellID);
+ SpellEntry const* spellProto = sSpellStore.LookupEntry(damageInfo->SpellID);
if (spellProto == NULL)
{
sLog->outDebug(LOG_FILTER_UNITS, "Unit::DealSpellDamage have wrong damageInfo->SpellID: %u", damageInfo->SpellID);
@@ -1115,7 +1115,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
DealDamage(pVictim, damageInfo->damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SpellSchoolMask(damageInfo->schoolMask), spellProto, durabilityLoss);
}
-//TODO for melee need create structure as in
+// TODO for melee need create structure as in
void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType)
{
damageInfo->attacker = this;
@@ -1254,7 +1254,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->HitInfo |= HITINFO_BLOCK;
damageInfo->procEx |= PROC_EX_BLOCK;
damageInfo->blocked_amount = damageInfo->target->GetShieldBlockValue();
- //double blocked amount if block is critical
+ // double blocked amount if block is critical
if (damageInfo->target->isBlockCritical())
damageInfo->blocked_amount+=damageInfo->blocked_amount;
if (damageInfo->blocked_amount >= damageInfo->damage)
@@ -1374,14 +1374,14 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
// If this is a creature and it attacks from behind it has a probability to daze it's victim
if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) &&
- GetTypeId() != TYPEID_PLAYER && !this->ToCreature()->IsControlledByPlayer() && !pVictim->HasInArc(M_PI, this)
+ GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !pVictim->HasInArc(M_PI, this)
&& (pVictim->GetTypeId() == TYPEID_PLAYER || !pVictim->ToCreature()->isWorldBoss()))
{
// -probability is between 0% and 40%
// 20% base chance
float Probability = 20.0f;
- //there is a newbie protection, at level 10 just 7% base chance; assuming linear function
+ // there is a newbie protection, at level 10 just 7% base chance; assuming linear function
if (pVictim->getLevel() < 30)
Probability = 0.65f * pVictim->getLevel() + 0.5f;
@@ -1408,7 +1408,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
AuraEffectList vDamageShieldsCopy(pVictim->GetAuraEffectsByType(SPELL_AURA_DAMAGE_SHIELD));
for (AuraEffectList::const_iterator dmgShieldItr = vDamageShieldsCopy.begin(); dmgShieldItr != vDamageShieldsCopy.end(); ++dmgShieldItr)
{
- SpellEntry const *i_spellProto = (*dmgShieldItr)->GetSpellProto();
+ SpellEntry const* i_spellProto = (*dmgShieldItr)->GetSpellProto();
// Damage shield can be resisted...
if (SpellMissInfo missInfo = pVictim->SpellHitResult(this, i_spellProto , false))
{
@@ -1483,7 +1483,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt
armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL);
if (spellInfo)
- if (Player *modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor);
AuraEffectList const& ResIgnoreAurasAb = GetAuraEffectsByType(SPELL_AURA_MOD_ABILITY_IGNORE_TARGET_RESIST);
@@ -1516,7 +1516,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt
// item dependent spell - check curent weapons
for (int i = 0; i < MAX_ATTACK; ++i)
{
- Item *weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true);
+ Item* weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true);
if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
{
@@ -1614,12 +1614,12 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
float damageResisted = float(damage * i / 10);
- AuraEffectList const &ResIgnoreAurasAb = GetAuraEffectsByType(SPELL_AURA_MOD_ABILITY_IGNORE_TARGET_RESIST);
+ AuraEffectList const& ResIgnoreAurasAb = GetAuraEffectsByType(SPELL_AURA_MOD_ABILITY_IGNORE_TARGET_RESIST);
for (AuraEffectList::const_iterator j = ResIgnoreAurasAb.begin(); j != ResIgnoreAurasAb.end(); ++j)
if (((*j)->GetMiscValue() & schoolMask) && (*j)->IsAffectedOnSpell(spellInfo))
AddPctN(damageResisted, -(*j)->GetAmount());
- AuraEffectList const &ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
+ AuraEffectList const& ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j)
if ((*j)->GetMiscValue() & schoolMask)
AddPctN(damageResisted, -(*j)->GetAmount());
@@ -1629,7 +1629,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
// Ignore Absorption Auras
float auraAbsorbMod = 0;
- AuraEffectList const & AbsIgnoreAurasA = GetAuraEffectsByType(SPELL_AURA_MOD_TARGET_ABSORB_SCHOOL);
+ AuraEffectList const& AbsIgnoreAurasA = GetAuraEffectsByType(SPELL_AURA_MOD_TARGET_ABSORB_SCHOOL);
for (AuraEffectList::const_iterator itr = AbsIgnoreAurasA.begin(); itr != AbsIgnoreAurasA.end(); ++itr)
{
if (!((*itr)->GetMiscValue() & schoolMask))
@@ -1639,7 +1639,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
auraAbsorbMod = float((*itr)->GetAmount());
}
- AuraEffectList const & AbsIgnoreAurasB = GetAuraEffectsByType(SPELL_AURA_MOD_TARGET_ABILITY_ABSORB_SCHOOL);
+ AuraEffectList const& AbsIgnoreAurasB = GetAuraEffectsByType(SPELL_AURA_MOD_TARGET_ABILITY_ABSORB_SCHOOL);
for (AuraEffectList::const_iterator itr = AbsIgnoreAurasB.begin(); itr != AbsIgnoreAurasB.end(); ++itr)
{
if (!((*itr)->GetMiscValue() & schoolMask))
@@ -1658,7 +1658,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
// absorb without mana cost
for (AuraEffectList::iterator itr = vSchoolAbsorbCopy.begin(); (itr != vSchoolAbsorbCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
{
- AuraEffect * absorbAurEff = (*itr);
+ AuraEffect* absorbAurEff = *itr;
// Check if aura was removed during iteration - we don't need to work on such auras
AuraApplication const* aurApp = absorbAurEff->GetBase()->GetApplicationOfTarget(pVictim->GetGUID());
if (!aurApp)
@@ -1708,7 +1708,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
AuraEffectList vManaShieldCopy(pVictim->GetAuraEffectsByType(SPELL_AURA_MANA_SHIELD));
for (AuraEffectList::const_iterator itr = vManaShieldCopy.begin(); (itr != vManaShieldCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
{
- AuraEffect * absorbAurEff = (*itr);
+ AuraEffect* absorbAurEff = *itr;
// Check if aura was removed during iteration - we don't need to work on such auras
AuraApplication const* aurApp = absorbAurEff->GetBase()->GetApplicationOfTarget(pVictim->GetGUID());
if (!aurApp)
@@ -1747,7 +1747,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
int32 manaTaken = -pVictim->ModifyPower(POWER_MANA, -manaReduction);
// take case when mana has ended up into account
- currentAbsorb = currentAbsorb ? int32(float(currentAbsorb)*(float(manaTaken) / float(manaReduction))) : 0;
+ currentAbsorb = currentAbsorb ? int32(float(currentAbsorb) * (float(manaTaken) / float(manaReduction))) : 0;
dmgInfo.AbsorbDamage(currentAbsorb);
@@ -1885,7 +1885,7 @@ void Unit::CalcHealAbsorb(Unit *pVictim, const SpellEntry *healSpell, uint32 &he
{
for (AuraEffectList::const_iterator i = vHealAbsorb.begin(); i != vHealAbsorb.end();)
{
- AuraEffect *auraEff = *i;
+ AuraEffect* auraEff = *i;
++i;
if (auraEff->GetAmount() <= 0)
{
@@ -1909,7 +1909,7 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex
if (!pVictim->isAlive())
return;
- if ((attType == BASE_ATTACK || attType == OFF_ATTACK) && !this->IsWithinLOSInMap(pVictim))
+ if ((attType == BASE_ATTACK || attType == OFF_ATTACK) && !IsWithinLOSInMap(pVictim))
return;
CombatStart(pVictim);
@@ -2027,12 +2027,12 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
{
// Reduce dodge chance by attacker expertise rating
if (GetTypeId() == TYPEID_PLAYER)
- dodge_chance -= int32(this->ToPlayer()->GetExpertiseDodgeOrParryReduction(attType)*100);
+ dodge_chance -= int32(ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100);
else
- dodge_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25;
+ dodge_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
// Modify dodge chance by attacker SPELL_AURA_MOD_COMBAT_RESULT_CHANCE
- dodge_chance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100;
+ dodge_chance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE) * 100;
dodge_chance = int32 (float (dodge_chance) * GetTotalAuraMultiplier(SPELL_AURA_MOD_ENEMY_DODGE));
tmp = dodge_chance;
@@ -2054,9 +2054,9 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
{
// Reduce parry chance by attacker expertise rating
if (GetTypeId() == TYPEID_PLAYER)
- parry_chance -= int32(this->ToPlayer()->GetExpertiseDodgeOrParryReduction(attType)*100);
+ parry_chance -= int32(ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100);
else
- parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25;
+ parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
if (pVictim->GetTypeId() == TYPEID_PLAYER || !(pVictim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY))
{
@@ -2089,7 +2089,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
if (tmp > 0 && roll < (sum += tmp))
{
sLog->outStaticDebug ("RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum);
- if (GetTypeId() == TYPEID_UNIT && (this->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT))
+ if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT))
sLog->outStaticDebug ("RollMeleeOutcomeAgainst: CRIT DISABLED)");
else
return MELEE_HIT_CRIT;
@@ -2097,7 +2097,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
// 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)
if (attType != RANGED_ATTACK &&
- (GetTypeId() == TYPEID_PLAYER || this->ToCreature()->isPet()) &&
+ (GetTypeId() == TYPEID_PLAYER || ToCreature()->isPet()) &&
pVictim->GetTypeId() != TYPEID_PLAYER && !pVictim->ToCreature()->isPet() &&
getLevel() < pVictim->getLevelForTarget(this))
{
@@ -2119,7 +2119,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
if (getLevelForTarget(pVictim) >= pVictim->getLevelForTarget(this) + 4 &&
// can be from by creature (if can) or from controlled player that considered as creature
!IsControlledByPlayer() &&
- !(GetTypeId() == TYPEID_UNIT && this->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH))
+ !(GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH))
{
// when their weapon skill is 15 or more above victim's defense skill
tmp = victimDefenseSkill;
@@ -2149,7 +2149,7 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool add
float min_damage, max_damage;
if (GetTypeId() == TYPEID_PLAYER && (normalized || !addTotalPct))
- this->ToPlayer()->CalculateMinMaxDamage(attType, normalized, addTotalPct, min_damage, max_damage);
+ ToPlayer()->CalculateMinMaxDamage(attType, normalized, addTotalPct, min_damage, max_damage);
else
{
switch (attType)
@@ -2298,7 +2298,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
uint32 roll = urand (0, 10000);
- uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell->Id)*100.0f);
+ uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell->Id) * 100.0f);
// Roll miss
uint32 tmp = missChance;
if (roll < tmp)
@@ -2331,7 +2331,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
return SPELL_MISS_NONE;
// Chance resist mechanic
- int32 resist_chance = pVictim->GetMechanicResistChance(spell)*100;
+ int32 resist_chance = pVictim->GetMechanicResistChance(spell) * 100;
tmp += resist_chance;
if (roll < tmp)
return SPELL_MISS_RESIST;
@@ -2342,7 +2342,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
// only if in front
if (pVictim->HasInArc(M_PI, this) || pVictim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
{
- int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
+ int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
tmp+=deflect_chance;
if (roll < tmp)
return SPELL_MISS_DEFLECT;
@@ -2371,7 +2371,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
canBlock = false;
}
// Ignore combat result aura
- AuraEffectList const &ignore = GetAuraEffectsByType(SPELL_AURA_IGNORE_COMBAT_RESULT);
+ AuraEffectList const& ignore = GetAuraEffectsByType(SPELL_AURA_IGNORE_COMBAT_RESULT);
for (AuraEffectList::const_iterator i = ignore.begin(); i != ignore.end(); ++i)
{
if (!(*i)->IsAffectedOnSpell(spell))
@@ -2390,15 +2390,15 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (canDodge)
{
// Roll dodge
- int32 dodgeChance = int32(pVictim->GetUnitDodgeChance()*100.0f) - skillDiff * 4;
+ int32 dodgeChance = int32(pVictim->GetUnitDodgeChance() * 100.0f) - skillDiff * 4;
// Reduce enemy dodge chance by SPELL_AURA_MOD_COMBAT_RESULT_CHANCE
- dodgeChance += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100;
+ dodgeChance += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE) * 100;
dodgeChance = int32(float(dodgeChance) * GetTotalAuraMultiplier(SPELL_AURA_MOD_ENEMY_DODGE));
// Reduce dodge chance by attacker expertise rating
if (GetTypeId() == TYPEID_PLAYER)
- dodgeChance -= int32(this->ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100.0f);
+ dodgeChance -= int32(ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100.0f);
else
- dodgeChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25;
+ dodgeChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
if (dodgeChance < 0)
dodgeChance = 0;
@@ -2409,12 +2409,12 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (canParry)
{
// Roll parry
- int32 parryChance = int32(pVictim->GetUnitParryChance()*100.0f) - skillDiff * 4;
+ int32 parryChance = int32(pVictim->GetUnitParryChance() * 100.0f) - skillDiff * 4;
// Reduce parry chance by attacker expertise rating
if (GetTypeId() == TYPEID_PLAYER)
- parryChance -= int32(this->ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100.0f);
+ parryChance -= int32(ToPlayer()->GetExpertiseDodgeOrParryReduction(attType) * 100.0f);
else
- parryChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25;
+ parryChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
if (parryChance < 0)
parryChance = 0;
@@ -2425,7 +2425,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (canBlock)
{
- int32 blockChance = int32(pVictim->GetUnitBlockChance()*100.0f) - skillDiff * 4;
+ int32 blockChance = int32(pVictim->GetUnitBlockChance() * 100.0f) - skillDiff * 4;
if (blockChance < 0)
blockChance = 0;
tmp += blockChance;
@@ -2460,7 +2460,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
modHitChance = 94 - (leveldif - 2) * lchance;
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
- if (Player *modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance);
// Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras
@@ -2558,7 +2558,7 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool
// All positive spells can`t miss
// TODO: client not show miss log for this spells - so need find info for this in dbc and use it!
if (IsPositiveSpell(spell->Id)
- &&(!IsHostileTo(pVictim))) //prevent from affecting enemy by "positive" spell
+ &&(!IsHostileTo(pVictim))) // prevent from affecting enemy by "positive" spell
return SPELL_MISS_NONE;
// Check for immune
if (pVictim->IsImmunedToDamage(spell))
@@ -2606,9 +2606,9 @@ uint32 Unit::GetDefenseSkillValue(Unit const* target) const
{
// in PvP use full skill instead current skill value
uint32 value = (target && target->GetTypeId() == TYPEID_PLAYER)
- ? this->ToPlayer()->GetMaxSkillValue(SKILL_DEFENSE)
- : this->ToPlayer()->GetSkillValue(SKILL_DEFENSE);
- value += uint32(this->ToPlayer()->GetRatingBonusValue(CR_DEFENSE_SKILL));
+ ? ToPlayer()->GetMaxSkillValue(SKILL_DEFENSE)
+ : ToPlayer()->GetSkillValue(SKILL_DEFENSE);
+ value += uint32(ToPlayer()->GetRatingBonusValue(CR_DEFENSE_SKILL));
return value;
}
else
@@ -2624,7 +2624,7 @@ float Unit::GetUnitDodgeChance() const
return GetFloatValue(PLAYER_DODGE_PERCENTAGE);
else
{
- if (((Creature const*)this)->isTotem())
+ if (ToCreature()->isTotem())
return 0.0f;
else
{
@@ -2642,12 +2642,11 @@ float Unit::GetUnitParryChance() const
float chance = 0.0f;
- if (GetTypeId() == TYPEID_PLAYER)
+ if (Player const* player = ToPlayer())
{
- Player const* player = (Player const*)this;
if (player->CanParry())
{
- Item *tmpitem = player->GetWeaponForAttack(BASE_ATTACK, true);
+ Item* tmpitem = player->GetWeaponForAttack(BASE_ATTACK, true);
if (!tmpitem)
tmpitem = player->GetWeaponForAttack(OFF_ATTACK, true);
@@ -2672,12 +2671,11 @@ float Unit::GetUnitBlockChance() const
if (IsNonMeleeSpellCasted(false) || HasUnitState(UNIT_STAT_STUNNED))
return 0.0f;
- if (GetTypeId() == TYPEID_PLAYER)
+ if (Player const* player = ToPlayer())
{
- Player const* player = (Player const*)this;
if (player->CanBlock())
{
- Item *tmpitem = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
+ Item* tmpitem = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
if (tmpitem && !tmpitem->IsBroken() && tmpitem->GetTemplate()->Block)
return GetFloatValue(PLAYER_BLOCK_PERCENTAGE);
}
@@ -2686,7 +2684,7 @@ float Unit::GetUnitBlockChance() const
}
else
{
- if (((Creature const*)this)->isTotem())
+ if (ToCreature()->isTotem())
return 0.0f;
else
{
@@ -2757,9 +2755,9 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVict
uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) const
{
uint32 value = 0;
- if (GetTypeId() == TYPEID_PLAYER)
+ if (Player const* player = ToPlayer())
{
- Item* item = this->ToPlayer()->GetWeaponForAttack(attType, true);
+ Item* item = player->GetWeaponForAttack(attType, true);
// feral or unarmed skill only for base attack
if (attType != BASE_ATTACK && !item)
@@ -2777,15 +2775,15 @@ uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target)
// in PvP use full skill instead current skill value
value = (target && target->IsControlledByPlayer())
- ? this->ToPlayer()->GetMaxSkillValue(skill)
- : this->ToPlayer()->GetSkillValue(skill);
+ ? player->GetMaxSkillValue(skill)
+ : player->GetSkillValue(skill);
// Modify value from ratings
- value += uint32(this->ToPlayer()->GetRatingBonusValue(CR_WEAPON_SKILL));
+ value += uint32(player->GetRatingBonusValue(CR_WEAPON_SKILL));
switch (attType)
{
- case BASE_ATTACK: value += uint32(this->ToPlayer()->GetRatingBonusValue(CR_WEAPON_SKILL_MAINHAND)); break;
- case OFF_ATTACK: value += uint32(this->ToPlayer()->GetRatingBonusValue(CR_WEAPON_SKILL_OFFHAND)); break;
- case RANGED_ATTACK: value += uint32(this->ToPlayer()->GetRatingBonusValue(CR_WEAPON_SKILL_RANGED)); break;
+ case BASE_ATTACK: value += uint32(player->GetRatingBonusValue(CR_WEAPON_SKILL_MAINHAND)); break;
+ case OFF_ATTACK: value += uint32(player->GetRatingBonusValue(CR_WEAPON_SKILL_OFFHAND)); break;
+ case RANGED_ATTACK: value += uint32(player->GetRatingBonusValue(CR_WEAPON_SKILL_RANGED)); break;
default: break;
}
}
@@ -2821,7 +2819,7 @@ void Unit::_UpdateSpells(uint32 time)
// m_auraUpdateIterator can be updated in indirect called code at aura remove to skip next planned to update but removed auras
for (m_auraUpdateIterator = m_ownedAuras.begin(); m_auraUpdateIterator != m_ownedAuras.end();)
{
- Aura * i_aura = m_auraUpdateIterator->second;
+ Aura* i_aura = m_auraUpdateIterator->second;
++m_auraUpdateIterator; // need shift to next for allow update if need into aura update
i_aura->UpdateOwner(time, this);
}
@@ -2861,8 +2859,8 @@ void Unit::_UpdateSpells(uint32 time)
void Unit::_UpdateAutoRepeatSpell()
{
- //check "realtime" interrupts
- if ((GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isMoving()) || IsNonMeleeSpellCasted(false, false, true, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == 75))
+ // check "realtime" interrupts
+ if ((GetTypeId() == TYPEID_PLAYER && ToPlayer()) || IsNonMeleeSpellCasted(false, false, true, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == 75))
{
// cancel wand shoot
if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != 75)
@@ -2871,12 +2869,12 @@ void Unit::_UpdateAutoRepeatSpell()
return;
}
- //apply delay (Auto Shot (spellID 75) not affected)
+ // apply delay (Auto Shot (spellID 75) not affected)
if (m_AutoRepeatFirstCast && getAttackTimer(RANGED_ATTACK) < 500 && m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != 75)
setAttackTimer(RANGED_ATTACK, 500);
m_AutoRepeatFirstCast = false;
- //castroutine
+ // castroutine
if (isAttackReady(RANGED_ATTACK))
{
// Check if able to cast
@@ -3216,7 +3214,7 @@ AuraApplication * Unit::_CreateAuraApplication(Aura * aura, uint8 effMask)
// ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load)
if (!isAlive() && !IsDeathPersistentSpell(aurSpellInfo) &&
- (GetTypeId() != TYPEID_PLAYER || !this->ToPlayer()->GetSession()->PlayerLoading()))
+ (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->GetSession()->PlayerLoading()))
return NULL;
Unit* caster = aura->GetCaster();
@@ -3253,7 +3251,7 @@ void Unit::_ApplyAuraEffect(Aura * aura, uint8 effIndex)
// should be done after registering aura in lists
void Unit::_ApplyAura(AuraApplication * aurApp, uint8 effMask)
{
- Aura * aura = aurApp->GetBase();
+ Aura* aura = aurApp->GetBase();
_RemoveNoStackAurasDueToAura(aura);
@@ -3295,7 +3293,7 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMo
ASSERT(aurApp->GetTarget() == this);
aurApp->SetRemoveMode(removeMode);
- Aura * aura = aurApp->GetBase();
+ Aura* aura = aurApp->GetBase();
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Aura %u now is remove mode %d", aura->GetId(), removeMode);
// dead loop is killing the server probably
@@ -3348,10 +3346,10 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMo
ASSERT(!aurApp->GetEffectMask());
// Remove totem at next update if totem loses its aura
- if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && this->ToCreature()->isTotem()&& this->ToTotem()->GetSummonerGUID() == aura->GetCasterGUID())
+ if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && ToCreature()->isTotem()&& ToTotem()->GetSummonerGUID() == aura->GetCasterGUID())
{
- if (this->ToTotem()->GetSpell() == aura->GetId() && this->ToTotem()->GetTotemType() == TOTEM_PASSIVE)
- this->ToTotem()->setDeathState(JUST_DIED);
+ if (ToTotem()->GetSpell() == aura->GetId() && ToTotem()->GetTotemType() == TOTEM_PASSIVE)
+ ToTotem()->setDeathState(JUST_DIED);
}
// Remove aurastates only if were not found
@@ -3503,7 +3501,7 @@ void Unit::_RegisterAuraEffect(AuraEffect * aurEff, bool apply)
// All aura base removes should go threw this function!
void Unit::RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode)
{
- Aura * aura = i->second;
+ Aura* aura = i->second;
ASSERT(!aura->IsRemoved());
// if unit currently update aura list then make safe update iterator shift to next
@@ -3565,7 +3563,7 @@ void Unit::RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode)
// Do not remove aura which is already being removed
if (aurApp->GetRemoveMode())
return;
- Aura * aura = aurApp->GetBase();
+ Aura* aura = aurApp->GetBase();
_UnapplyAura(i, mode);
// Remove aura - for Area and Target auras
if (aura->GetOwner() == this)
@@ -3648,7 +3646,7 @@ void Unit::RemoveAuraFromStack(uint32 spellId, uint64 caster, AuraRemoveMode rem
{
for (AuraMap::iterator iter = m_ownedAuras.lower_bound(spellId); iter != m_ownedAuras.upper_bound(spellId);)
{
- Aura * aura = iter->second;
+ Aura* aura = iter->second;
if ((aura->GetType() == UNIT_AURA_TYPE)
&& (!caster || aura->GetCasterGUID() == caster))
{
@@ -3664,7 +3662,7 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit
{
for (AuraMap::iterator iter = m_ownedAuras.lower_bound(spellId); iter != m_ownedAuras.upper_bound(spellId);)
{
- Aura * aura = iter->second;
+ Aura* aura = iter->second;
if (aura->GetCasterGUID() == casterGUID)
{
if (aura->GetSpellProto()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES)
@@ -3690,7 +3688,7 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit
}
case SPELLFAMILY_DRUID:
{
- //Lifebloom
+ // Lifebloom
if (aura->GetSpellProto()->SpellFamilyFlags[1] & 0x10)
{
if (AuraEffect const* aurEff = aura->GetEffect(EFFECT_1))
@@ -3757,7 +3755,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
{
for (AuraMap::iterator iter = m_ownedAuras.lower_bound(spellId); iter != m_ownedAuras.upper_bound(spellId);)
{
- Aura * aura = iter->second;
+ Aura* aura = iter->second;
if (aura->GetCasterGUID() == casterGUID)
{
int32 damage[MAX_SPELL_EFFECTS];
@@ -3785,7 +3783,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
bool stealCharge = aura->GetSpellProto()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES;
int32 dur = std::min(2*MINUTE*IN_MILLISECONDS, aura->GetDuration());
- if (Aura * newAura = stealer->GetAura(aura->GetId(), aura->GetCasterGUID()))
+ if (Aura* newAura = stealer->GetAura(aura->GetId(), aura->GetCasterGUID()))
{
if (stealCharge)
newAura->ModCharges(1);
@@ -3844,7 +3842,7 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except
{
for (AuraEffectList::iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();)
{
- Aura * aura = (*iter)->GetBase();
+ Aura* aura = (*iter)->GetBase();
AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID());
++iter;
@@ -3863,7 +3861,7 @@ void Unit::RemoveAurasWithAttribute(uint32 flags)
{
for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
{
- SpellEntry const *spell = iter->second->GetBase()->GetSpellProto();
+ SpellEntry const* spell = iter->second->GetBase()->GetSpellProto();
if (spell->Attributes & flags)
RemoveAura(iter);
else
@@ -3900,7 +3898,7 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase)
AuraList& scAuras = GetSingleCastAuras();
for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();)
{
- Aura * aura = *iter;
+ Aura* aura = *iter;
if (aura->GetUnitOwner() != this && !aura->GetUnitOwner()->InSamePhase(newPhase))
{
aura->Remove();
@@ -3919,7 +3917,7 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except)
// interrupt auras
for (AuraApplicationList::iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end();)
{
- Aura * aura = (*iter)->GetBase();
+ Aura* aura = (*iter)->GetBase();
++iter;
if ((aura->GetSpellProto()->AuraInterruptFlags & flag) && (!except || aura->GetId() != except))
{
@@ -3947,7 +3945,7 @@ void Unit::RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, ui
Aura const* aura = iter->second->GetBase();
if (!casterGUID || aura->GetCasterGUID() == casterGUID)
{
- SpellEntry const *spell = aura->GetSpellProto();
+ SpellEntry const* spell = aura->GetSpellProto();
if (spell->SpellFamilyName == uint32(family) && spell->SpellFamilyFlags.HasFlag(familyFlag1, familyFlag2, familyFlag3))
{
RemoveAura(iter);
@@ -3985,9 +3983,9 @@ void Unit::RemoveAreaAurasDueToLeaveWorld()
// make sure that all area auras not applied on self are removed - prevent access to deleted pointer later
for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
{
- Aura * aura = iter->second;
+ Aura* aura = iter->second;
++iter;
- Aura::ApplicationMap const & appMap = aura->GetApplicationMap();
+ Aura::ApplicationMap const& appMap = aura->GetApplicationMap();
for (Aura::ApplicationMap::const_iterator itr = appMap.begin(); itr!= appMap.end();)
{
AuraApplication * aurApp = itr->second;
@@ -4061,7 +4059,7 @@ void Unit::RemoveAllAurasOnDeath()
for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
{
- Aura * aura = iter->second;
+ Aura* aura = iter->second;
if (!aura->IsPassive() && !aura->IsDeathPersistent())
RemoveOwnedAura(iter, AURA_REMOVE_BY_DEATH);
else
@@ -4082,7 +4080,7 @@ void Unit::RemoveAllAurasRequiringDeadTarget()
for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
{
- Aura * aura = iter->second;
+ Aura* aura = iter->second;
if (!aura->IsPassive() && IsRequiringDeadTargetSpell(aura->GetSpellProto()))
RemoveOwnedAura(iter, AURA_REMOVE_BY_DEFAULT);
else
@@ -4115,7 +4113,7 @@ void Unit::DelayOwnedAuras(uint32 spellId, uint64 caster, int32 delaytime)
{
for (AuraMap::iterator iter = m_ownedAuras.lower_bound(spellId); iter != m_ownedAuras.upper_bound(spellId);++iter)
{
- Aura * aura = iter->second;
+ Aura* aura = iter->second;
if (!caster || aura->GetCasterGUID() == caster)
{
if (aura->GetDuration() < delaytime)
@@ -4155,7 +4153,7 @@ AuraEffect * Unit::GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, ui
uint32 rankSpell = sSpellMgr->GetFirstSpellInChain(spellId);
while (true)
{
- if (AuraEffect * aurEff = GetAuraEffect(rankSpell, effIndex, caster))
+ if (AuraEffect* aurEff = GetAuraEffect(rankSpell, effIndex, caster))
return aurEff;
SpellChainNode const* chainNode = sSpellMgr->GetSpellChainNode(rankSpell);
if (!chainNode)
@@ -4185,7 +4183,7 @@ AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 f
AuraEffectList const& auras = GetAuraEffectsByType(type);
for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i)
{
- SpellEntry const *spell = (*i)->GetSpellProto();
+ SpellEntry const* spell = (*i)->GetSpellProto();
if (spell->SpellFamilyName == uint32(family) && spell->SpellFamilyFlags.HasFlag(familyFlag1, familyFlag2, familyFlag3))
{
if (casterGUID && (*i)->GetCasterGUID() != casterGUID)
@@ -4320,7 +4318,7 @@ bool Unit::HasNegativeAuraWithAttribute(uint32 flag, uint64 guid)
{
for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter)
{
- Aura const *aura = iter->second->GetBase();
+ Aura const* aura = iter->second->GetBase();
if (!iter->second->IsPositive() && aura->GetSpellProto()->Attributes & flag && (!guid || aura->GetCasterGUID() == guid))
return true;
}
@@ -4365,7 +4363,7 @@ uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, bool remove)
SPELL_AURA_NONE
};
- uint32 diseases=0;
+ uint32 diseases = 0;
for (AuraType const* itr = &diseaseAuraTypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr)
{
for (AuraEffectList::iterator i = m_modAuras[*itr].begin(); i != m_modAuras[*itr].end();)
@@ -4398,7 +4396,7 @@ uint32 Unit::GetDoTsByCaster(uint64 casterGUID) const
SPELL_AURA_NONE
};
- uint32 dots=0;
+ uint32 dots = 0;
for (AuraType const* itr = &diseaseAuraTypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr)
{
Unit::AuraEffectList const& auras = GetAuraEffectsByType(*itr);
@@ -4689,7 +4687,7 @@ void Unit::AddGameObject(GameObject* gameObj)
// Need disable spell use for owner
if (createBySpell && createBySpell->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE)
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
- this->ToPlayer()->AddSpellAndCategoryCooldowns(createBySpell, 0, NULL, true);
+ ToPlayer()->AddSpellAndCategoryCooldowns(createBySpell, 0, NULL, true);
}
}
@@ -4719,7 +4717,7 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del)
// Need activate spell use for owner
if (createBySpell && createBySpell->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE)
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
- this->ToPlayer()->SendCooldownEvent(createBySpell);
+ ToPlayer()->SendCooldownEvent(createBySpell);
}
}
@@ -4963,10 +4961,10 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType
bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown)
{
- SpellEntry const *hasteSpell = triggeredByAura->GetSpellProto();
+ SpellEntry const* hasteSpell = triggeredByAura->GetSpellProto();
Item* castItem = triggeredByAura->GetBase()->GetCastItemGUID() && GetTypeId() == TYPEID_PLAYER
- ? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
+ ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
uint32 triggered_spell_id = 0;
Unit* target = pVictim;
@@ -5010,7 +5008,7 @@ bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
if ((!target && !sSpellMgr->IsSrcTargetSpell(triggerEntry)) || (target && target != this && !target->isAlive()))
return false;
- if (cooldown && GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->HasSpellCooldown(triggered_spell_id))
+ if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(triggered_spell_id))
return false;
if (basepoints0)
@@ -5019,17 +5017,17 @@ bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura);
if (cooldown && GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
+ ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
return true;
}
bool Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /*damage*/, AuraEffect* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown)
{
- SpellEntry const *triggeredByAuraSpell = triggeredByAura->GetSpellProto();
+ SpellEntry const* triggeredByAuraSpell = triggeredByAura->GetSpellProto();
Item* castItem = triggeredByAura->GetBase()->GetCastItemGUID() && GetTypeId() == TYPEID_PLAYER
- ? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
+ ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
uint32 triggered_spell_id = 0;
Unit* target = pVictim;
@@ -5072,7 +5070,7 @@ bool Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /*damage*/, AuraE
if (!target || (target != this && !target->isAlive()))
return false;
- if (cooldown && GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->HasSpellCooldown(triggered_spell_id))
+ if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(triggered_spell_id))
return false;
if (basepoints0)
@@ -5081,19 +5079,19 @@ bool Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /*damage*/, AuraE
CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura);
if (cooldown && GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
+ ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
return true;
}
bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
{
- SpellEntry const *dummySpell = triggeredByAura->GetSpellProto();
+ SpellEntry const* dummySpell = triggeredByAura->GetSpellProto();
uint32 effIndex = triggeredByAura->GetEffIndex();
int32 triggerAmount = triggeredByAura->GetAmount();
Item* castItem = triggeredByAura->GetBase()->GetCastItemGUID() && GetTypeId() == TYPEID_PLAYER
- ? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
+ ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
uint32 triggered_spell_id = 0;
uint32 cooldown_spell_id = 0; // for random trigger, will be one of the triggered spell to avoid repeatable triggers
@@ -5111,7 +5109,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Bloodworms Health Leech
case 50453:
{
- if (Unit *owner = this->GetOwner())
+ if (Unit* owner = GetOwner())
{
basepoints0 = int32(damage*1.50);
target = owner;
@@ -5257,7 +5255,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// 41409 Dementia: Every 5 seconds either gives you -5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin)
case 39446:
{
- if (GetTypeId() != TYPEID_PLAYER || !this->isAlive())
+ if (GetTypeId() != TYPEID_PLAYER || !isAlive())
return false;
// Select class defined buff
@@ -5290,7 +5288,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
target = this;
if (roll_chance_i(10))
- this->ToPlayer()->Say("This is Madness!", LANG_UNIVERSAL); // TODO: It should be moved to database, shouldn't it?
+ ToPlayer()->Say("This is Madness!", LANG_UNIVERSAL); // TODO: It should be moved to database, shouldn't it?
break;
}
// Sunwell Exalted Caster Neck (??? neck)
@@ -5438,7 +5436,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Shadowfiend Death (Gain mana if pet dies with Glyph of Shadowfiend)
case 57989:
{
- Unit *owner = GetOwner();
+ Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return false;
// Glyph of Shadowfiend (need cast as self cast for owner, no hidden cooldown)
@@ -5509,7 +5507,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
default:
return false;
}
- if (RandomSpells.empty()) //shouldn't happen
+ if (RandomSpells.empty()) // shouldn't happen
return false;
uint8 rand_spell = irand(0, (RandomSpells.size() - 1));
@@ -5555,7 +5553,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
default:
return false;
}
- if (RandomSpells.empty()) //shouldn't happen
+ if (RandomSpells.empty()) // shouldn't happen
return false;
uint8 rand_spell = irand(0, (RandomSpells.size() - 1));
@@ -5705,14 +5703,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
{
if (effIndex != 0)
return false;
- AuraEffect *counter = triggeredByAura->GetBase()->GetEffect(1);
+ AuraEffect* counter = triggeredByAura->GetBase()->GetEffect(1);
if (!counter)
return true;
// Count spell criticals in a row in second aura
if (procEx & PROC_EX_CRITICAL_HIT)
{
- counter->SetAmount(counter->GetAmount()*2);
+ counter->SetAmount(counter->GetAmount() * 2);
if (counter->GetAmount() < 100) // not enough
return true;
// Crititcal counted -> roll chance
@@ -5789,18 +5787,19 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Glyph of Ice Block
case 56372:
{
- if (GetTypeId() != TYPEID_PLAYER)
+ Player* plr = ToPlayer();
+ if (!plr)
return false;
- SpellCooldowns const cooldowns = this->ToPlayer()->GetSpellCooldowns();
+ SpellCooldowns const cooldowns = plr->GetSpellCooldowns();
// remove cooldowns on all ranks of Frost Nova
for (SpellCooldowns::const_iterator itr = cooldowns.begin(); itr != cooldowns.end(); ++itr)
{
SpellEntry const* cdSpell = sSpellStore.LookupEntry(itr->first);
// Frost Nova
if (cdSpell && cdSpell->SpellFamilyName == SPELLFAMILY_MAGE
- && cdSpell->SpellFamilyFlags[0] & 0x00000040)
- this->ToPlayer()->RemoveSpellCooldown(cdSpell->Id, true);
+ && cdSpell->SpellFamilyFlags[0] & 0x00000040)
+ plr->RemoveSpellCooldown(cdSpell->Id, true);
}
break;
}
@@ -6014,7 +6013,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
triggered_spell_id = 17941;
break;
}
- //Soul Leech
+ // Soul Leech
case 30293:
case 30295:
case 30296:
@@ -6105,7 +6104,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
{
// Multiple effects stack, so let's try to find this aura.
int32 bonus = 0;
- if (AuraEffect *aurEff = target->GetAuraEffect(47753, 0))
+ if (AuraEffect* aurEff = target->GetAuraEffect(47753, 0))
bonus = aurEff->GetAmount();
basepoints0 = CalculatePctN(int32(damage), triggerAmount) + bonus;
@@ -6271,7 +6270,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
case 54815:
{
// try to find spell Rip on the target
- if (AuraEffect const *AurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, 0x00800000, 0x0, 0x0, GetGUID()))
+ if (AuraEffect const* AurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, 0x00800000, 0x0, 0x0, GetGUID()))
{
// Rip's max duration, note: spells which modifies Rip's duration also counted like Glyph of Rip
uint32 CountMin = AurEff->GetBase()->GetMaxDuration();
@@ -6807,7 +6806,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
if ((procFlag & PROC_FLAG_DONE_MELEE_AUTO_ATTACK) || (procSpell && procSpell->Id == 53595))
triggered_spell_id = 31803;
// On target with 5 stacks of Holy Vengeance direct damage is done
- if (Aura * aur = pVictim->GetAura(triggered_spell_id, GetGUID()))
+ if (Aura* aur = pVictim->GetAura(triggered_spell_id, GetGUID()))
{
if (aur->GetStackAmount() == 5)
{
@@ -6832,7 +6831,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
if ((procFlag & PROC_FLAG_DONE_MELEE_AUTO_ATTACK) || (procSpell && procSpell->Id == 53595))
triggered_spell_id = 53742;
// On target with 5 stacks of Blood Corruption direct damage is done
- if (Aura * aur = pVictim->GetAura(triggered_spell_id, GetGUID()))
+ if (Aura* aur = pVictim->GetAura(triggered_spell_id, GetGUID()))
{
if (aur->GetStackAmount() == 5)
{
@@ -6999,7 +6998,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
if ((*itr)->GetEntry() != 2630)
continue;
- caster = (*itr);
+ caster = *itr;
break;
}
@@ -7058,27 +7057,28 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Windfury Weapon (Passive) 1-5 Ranks
case 33757:
{
- if (GetTypeId() != TYPEID_PLAYER || !castItem || !castItem->IsEquipped() || !pVictim || !pVictim->isAlive())
+ Player* plr = ToPlayer();
+ if (!plr || !castItem || !castItem->IsEquipped() || !pVictim || !pVictim->isAlive())
return false;
// custom cooldown processing case
- if (cooldown && ToPlayer()->HasSpellCooldown(dummySpell->Id))
+ if (cooldown && plr->HasSpellCooldown(dummySpell->Id))
return false;
if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID())
return false;
- WeaponAttackType attType = WeaponAttackType(this->ToPlayer()->GetAttackBySlot(castItem->GetSlot()));
+ WeaponAttackType attType = WeaponAttackType(plr->GetAttackBySlot(castItem->GetSlot()));
if ((attType != BASE_ATTACK && attType != OFF_ATTACK) || !isAttackReady(attType))
return false;
// Now compute real proc chance...
uint32 chance = 20;
- this->ToPlayer()->ApplySpellMod(dummySpell->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance);
+ plr->ApplySpellMod(dummySpell->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance);
- Item* addWeapon = this->ToPlayer()->GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK, true);
+ Item* addWeapon = plr->GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK, true);
uint32 enchant_id_add = addWeapon ? addWeapon->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)) : 0;
- SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id_add);
+ SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id_add);
if (pEnchant && pEnchant->spellid[0] == dummySpell->Id)
chance += 14;
@@ -7116,15 +7116,15 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
int32 extra_attack_power = CalculateSpellDamage(pVictim, windfurySpellEntry, 1);
// Value gained from additional AP
- basepoints0 = int32(extra_attack_power/14.0f * GetAttackTime(BASE_ATTACK)/1000);
+ basepoints0 = int32(extra_attack_power / 14.0f * GetAttackTime(BASE_ATTACK) / 1000);
triggered_spell_id = 25504;
// apply cooldown before cast to prevent processing itself
if (cooldown)
- ToPlayer()->AddSpellCooldown(dummySpell->Id, 0, time(NULL) + cooldown);
+ plr->AddSpellCooldown(dummySpell->Id, 0, time(NULL) + cooldown);
// Attack Twice
- for (uint32 i = 0; i<2; ++i)
+ for (uint32 i = 0; i < 2; ++i)
CastCustomSpell(pVictim, triggered_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura);
return true;
@@ -7247,11 +7247,11 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
if (procSpell->SpellIconID != 2019)
return false;
- AuraEffect * aurEffA = NULL;
+ AuraEffect* aurEffA = NULL;
AuraEffectList const& auras = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE);
for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i)
{
- SpellEntry const *spell = (*i)->GetSpellProto();
+ SpellEntry const* spell = (*i)->GetSpellProto();
if (spell->SpellFamilyName == uint32(SPELLFAMILY_SHAMAN) && spell->SpellFamilyFlags.HasFlag(0, 0x02000000, 0))
{
if ((*i)->GetCasterGUID() != GetGUID())
@@ -7266,7 +7266,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
{
int32 bp0 = 0, bp1 = 0;
bp0 = CalculatePctN(triggerAmount, aurEffA->GetAmount());
- if (AuraEffect * aurEffB = aurEffA->GetBase()->GetEffect(EFFECT_1))
+ if (AuraEffect* aurEffB = aurEffA->GetBase()->GetEffect(EFFECT_1))
bp1 = CalculatePctN(triggerAmount, aurEffB->GetAmount());
CastCustomSpell(this, 63283, &bp0, &bp1, NULL, true, NULL, triggeredByAura);
return true;
@@ -7278,7 +7278,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Frozen Power
if (dummySpell->SpellIconID == 3780)
{
- if (this->GetDistance(target) < 15.0f)
+ if (GetDistance(target) < 15.0f)
return false;
float chance = (float)triggerAmount;
if (!roll_chance_f(chance))
@@ -7340,7 +7340,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Enchant on Off-Hand and ready?
if (castItem->GetSlot() == EQUIPMENT_SLOT_OFFHAND && isAttackReady(OFF_ATTACK))
{
- float BaseWeaponSpeed = GetAttackTime(OFF_ATTACK)/1000.0f;
+ float BaseWeaponSpeed = GetAttackTime(OFF_ATTACK) / 1000.0f;
// Value1: add the tooltip damage by swingspeed + Value2: add spelldmg by swingspeed
basepoints0 = int32((fire_onhit * BaseWeaponSpeed) + (add_spellpower * BaseWeaponSpeed));
@@ -7350,7 +7350,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Enchant on Main-Hand and ready?
else if (castItem->GetSlot() == EQUIPMENT_SLOT_MAINHAND && isAttackReady(BASE_ATTACK))
{
- float BaseWeaponSpeed = GetAttackTime(BASE_ATTACK)/1000.0f;
+ float BaseWeaponSpeed = GetAttackTime(BASE_ATTACK) / 1000.0f;
// Value1: add the tooltip damage by swingspeed + Value2: add spelldmg by swingspeed
basepoints0 = int32((fire_onhit * BaseWeaponSpeed) + (add_spellpower * BaseWeaponSpeed));
@@ -7508,10 +7508,10 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
return false;
Unit* pPet = NULL;
- for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) //Find Rune Weapon
+ for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) // Find Rune Weapon
if ((*itr)->GetEntry() == 27893)
{
- pPet = (*itr);
+ pPet = *itr;
break;
}
@@ -7537,7 +7537,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
{
basepoints0 = CalculatePctN(int32(damage), triggerAmount);
// Glyph of Unholy Blight
- if (AuraEffect *glyph=GetAuraEffect(63332, 0))
+ if (AuraEffect* glyph=GetAuraEffect(63332, 0))
AddPctN(basepoints0, glyph->GetAmount());
triggered_spell_id = 50536;
@@ -7642,14 +7642,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
{
SpellChainNode const* chain = NULL;
// get highest rank of the Death Coil spell
- const PlayerSpellMap& sp_list = this->ToPlayer()->GetSpellMap();
+ PlayerSpellMap const& sp_list = ToPlayer()->GetSpellMap();
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
{
// check if shown in spell book
if (!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED)
continue;
- SpellEntry const *spellProto = sSpellStore.LookupEntry(itr->first);
+ SpellEntry const* spellProto = sSpellStore.LookupEntry(itr->first);
if (!spellProto)
continue;
@@ -7676,11 +7676,13 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// Item - Death Knight T10 Melee 4P Bonus
if (dummySpell->Id == 70656)
{
- if (!this->ToPlayer())
+ if (GetTypeId() != TYPEID_PLAYER)
return false;
+ Player* player = ToPlayer();
+
for (uint32 i = 0; i < MAX_RUNES; ++i)
- if (this->ToPlayer()->GetRuneCooldown(i) == 0)
+ if (player->GetRuneCooldown(i) == 0)
return false;
}
break;
@@ -7692,7 +7694,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
{
if (procSpell->SpellFamilyName == SPELLFAMILY_POTION)
{
- for (uint8 i=0; i<MAX_SPELL_EFFECTS; i++)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; i++)
{
if (procSpell->Effect[i] == SPELL_EFFECT_HEAL)
{
@@ -7775,12 +7777,12 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
}
bool Unit::HandleObsModEnergyAuraProc(Unit *pVictim, uint32 /*damage*/, AuraEffect* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown)
{
- SpellEntry const *dummySpell = triggeredByAura->GetSpellProto ();
+ SpellEntry const* dummySpell = triggeredByAura->GetSpellProto();
//uint32 effIndex = triggeredByAura->GetEffIndex();
//int32 triggerAmount = triggeredByAura->GetAmount();
Item* castItem = triggeredByAura->GetBase()->GetCastItemGUID() && GetTypeId() == TYPEID_PLAYER
- ? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
+ ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
uint32 triggered_spell_id = 0;
Unit* target = pVictim;
@@ -7819,7 +7821,7 @@ bool Unit::HandleObsModEnergyAuraProc(Unit *pVictim, uint32 /*damage*/, AuraEffe
if ((!target && !sSpellMgr->IsSrcTargetSpell(triggerEntry)) || (target && target != this && !target->isAlive()))
return false;
- if (cooldown && GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->HasSpellCooldown(triggered_spell_id))
+ if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(triggered_spell_id))
return false;
if (basepoints0)
CastCustomSpell(target, triggered_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura);
@@ -7827,17 +7829,17 @@ bool Unit::HandleObsModEnergyAuraProc(Unit *pVictim, uint32 /*damage*/, AuraEffe
CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura);
if (cooldown && GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
+ ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
return true;
}
bool Unit::HandleModDamagePctTakenAuraProc(Unit *pVictim, uint32 /*damage*/, AuraEffect* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown)
{
- SpellEntry const *dummySpell = triggeredByAura->GetSpellProto ();
+ SpellEntry const* dummySpell = triggeredByAura->GetSpellProto();
//uint32 effIndex = triggeredByAura->GetEffIndex();
//int32 triggerAmount = triggeredByAura->GetAmount();
Item* castItem = triggeredByAura->GetBase()->GetCastItemGUID() && GetTypeId() == TYPEID_PLAYER
- ? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
+ ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
uint32 triggered_spell_id = 0;
Unit* target = pVictim;
@@ -7876,7 +7878,7 @@ bool Unit::HandleModDamagePctTakenAuraProc(Unit *pVictim, uint32 /*damage*/, Aur
if ((!target && !sSpellMgr->IsSrcTargetSpell(triggerEntry)) || (target && target != this && !target->isAlive()))
return false;
- if (cooldown && GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->HasSpellCooldown(triggered_spell_id))
+ if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(triggered_spell_id))
return false;
if (basepoints0)
@@ -7885,7 +7887,7 @@ bool Unit::HandleModDamagePctTakenAuraProc(Unit *pVictim, uint32 /*damage*/, Aur
CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura);
if (cooldown && GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
+ ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
return true;
}
@@ -7894,7 +7896,7 @@ bool Unit::HandleModDamagePctTakenAuraProc(Unit *pVictim, uint32 /*damage*/, Aur
// All procs should be handled like this...
bool Unit::HandleAuraProc(Unit* pVictim, uint32 damage, Aura * triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 procEx, uint32 cooldown, bool * handled)
{
- SpellEntry const *dummySpell = triggeredByAura->GetSpellProto();
+ SpellEntry const* dummySpell = triggeredByAura->GetSpellProto();
switch(dummySpell->SpellFamilyName)
{
@@ -7970,7 +7972,7 @@ bool Unit::HandleAuraProc(Unit* pVictim, uint32 damage, Aura * triggeredByAura,
if (triggeredByAura->GetCasterGUID() == pVictim->GetGUID())
return false;
// Lookup base amount mana restore
- for (uint8 i=0; i<MAX_SPELL_EFFECTS; i++)
+ for (uint8 i = 0; i<MAX_SPELL_EFFECTS; i++)
{
if (procSpell->Effect[i] == SPELL_EFFECT_ENERGIZE)
{
@@ -7991,7 +7993,7 @@ bool Unit::HandleAuraProc(Unit* pVictim, uint32 damage, Aura * triggeredByAura,
case 11129:
{
*handled = true;
- Unit *caster = triggeredByAura->GetCaster();
+ Unit* caster = triggeredByAura->GetCaster();
if (!caster || !damage)
return false;
@@ -8010,12 +8012,12 @@ bool Unit::HandleAuraProc(Unit* pVictim, uint32 damage, Aura * triggeredByAura,
{
*handled = true;
- SpellEntry const *spInfo = sSpellStore.LookupEntry(67545);
+ SpellEntry const* spInfo = sSpellStore.LookupEntry(67545);
if (!spInfo)
return false;
int32 bp0 = int32(CalculatePctN(GetCreateMana(), SpellMgr::CalculateSpellEffectAmount(spInfo, 0)));
- this->CastCustomSpell(this, 67545, &bp0, NULL, NULL, true, NULL, triggeredByAura->GetEffect(0), this->GetGUID());
+ CastCustomSpell(this, 67545, &bp0, NULL, NULL, true, NULL, triggeredByAura->GetEffect(0), GetGUID());
return true;
}
}
@@ -8030,15 +8032,15 @@ bool Unit::HandleAuraProc(Unit* pVictim, uint32 damage, Aura * triggeredByAura,
{
*handled = true;
// Convert recently used Blood Rune to Death Rune
- if (GetTypeId() == TYPEID_PLAYER)
+ if (Player* plr = ToPlayer())
{
- if (this->ToPlayer()->getClass() != CLASS_DEATH_KNIGHT)
+ if (plr->getClass() != CLASS_DEATH_KNIGHT)
return false;
- RuneType rune = this->ToPlayer()->GetLastUsedRune();
+ RuneType rune = ToPlayer()->GetLastUsedRune();
// can't proc from death rune use
if (rune == RUNE_DEATH)
return false;
- AuraEffect * aurEff = triggeredByAura->GetEffect(0);
+ AuraEffect* aurEff = triggeredByAura->GetEffect(0);
if (!aurEff)
return false;
// Reset amplitude - set death rune remove timer to 30s
@@ -8050,26 +8052,26 @@ bool Unit::HandleAuraProc(Unit* pVictim, uint32 damage, Aura * triggeredByAura,
else
runesLeft = 1;
- for (uint8 i=0; i < MAX_RUNES && runesLeft; ++i)
+ for (uint8 i = 0; i < MAX_RUNES && runesLeft; ++i)
{
if (dummySpell->SpellIconID == 2622)
{
- if (((Player*)this)->GetCurrentRune(i) == RUNE_DEATH ||
- ((Player*)this)->GetBaseRune(i) == RUNE_BLOOD)
+ if (plr->GetCurrentRune(i) == RUNE_DEATH ||
+ plr->GetBaseRune(i) == RUNE_BLOOD)
continue;
}
else
{
- if (((Player*)this)->GetCurrentRune(i) == RUNE_DEATH ||
- ((Player*)this)->GetBaseRune(i) != RUNE_BLOOD)
+ if (plr->GetCurrentRune(i) == RUNE_DEATH ||
+ plr->GetBaseRune(i) != RUNE_BLOOD)
continue;
}
- if (((Player*)this)->GetRuneCooldown(i) != ((Player*)this)->GetRuneBaseCooldown(i))
+ if (plr->GetRuneCooldown(i) != plr->GetRuneBaseCooldown(i))
continue;
--runesLeft;
// Mark aura as used
- ((Player*)this)->AddRuneByAuraEffect(i, RUNE_DEATH, aurEff);
+ plr->AddRuneByAuraEffect(i, RUNE_DEATH, aurEff);
}
return true;
}
@@ -8135,7 +8137,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
basepoints0 = triggerAmount;
Item* castItem = triggeredByAura->GetBase()->GetCastItemGUID() && GetTypeId() == TYPEID_PLAYER
- ? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
+ ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
// Try handle unknown trigger spells
if (sSpellStore.LookupEntry(trigger_spell_id) == NULL)
@@ -8201,7 +8203,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
case 40336:
{
// On successful melee or ranged attack gain $29471s1 mana and if possible drain $27526s1 mana from the target.
- if (this && this->isAlive())
+ if (this && isAlive())
CastSpell(this, 29471, true, castItem, triggeredByAura);
if (pVictim && pVictim->isAlive())
CastSpell(pVictim, 27526, true, castItem, triggeredByAura);
@@ -8348,7 +8350,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
sLog->outError("Unit::HandleProcTriggerSpell: Spell %u miss posibly Piercing Shots", auraSpellInfo->Id);
return false;
}
- SpellEntry const *TriggerPS = sSpellStore.LookupEntry(trigger_spell_id);
+ SpellEntry const* TriggerPS = sSpellStore.LookupEntry(trigger_spell_id);
if (!TriggerPS)
return false;
@@ -8384,7 +8386,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
// stacking
CastSpell(this, 37658, true, NULL, triggeredByAura);
- Aura * dummy = GetAura(37658);
+ Aura* dummy = GetAura(37658);
// release at 3 aura in stack (cont contain in basepoint of trigger aura)
if (!dummy || dummy->GetStackAmount() < triggerAmount)
return false;
@@ -8403,7 +8405,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
CastSpell(this, 54842, true, NULL, triggeredByAura);
// counting
- Aura * dummy = GetAura(54842);
+ Aura* dummy = GetAura(54842);
// release at 3 aura in stack (cont contain in basepoint of trigger aura)
if (!dummy || dummy->GetStackAmount() < triggerAmount)
return false;
@@ -8421,7 +8423,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
// stacking
CastSpell(this, 67713, true, NULL, triggeredByAura);
- Aura * dummy = GetAura(67713);
+ Aura* dummy = GetAura(67713);
// release at 3 aura in stack (cont contain in basepoint of trigger aura)
if (!dummy || dummy->GetStackAmount() < triggerAmount)
return false;
@@ -8439,7 +8441,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
// stacking
CastSpell(this, 67759, true, NULL, triggeredByAura);
- Aura * dummy = GetAura(67759);
+ Aura* dummy = GetAura(67759);
// release at 3 aura in stack (cont contain in basepoint of trigger aura)
if (!dummy || dummy->GetStackAmount() < triggerAmount)
return false;
@@ -8474,7 +8476,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
return false;
}
}
- SpellEntry const *originalSpell = sSpellStore.LookupEntry(originalSpellId);
+ SpellEntry const* originalSpell = sSpellStore.LookupEntry(originalSpellId);
if (!originalSpell)
{
sLog->outError("Unit::HandleProcTriggerSpell: Spell %u unknown but selected as original in Illu", originalSpellId);
@@ -8753,7 +8755,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
return false;
// Howling Blast
- this->ToPlayer()->RemoveSpellCategoryCooldown(1248, true);
+ ToPlayer()->RemoveSpellCategoryCooldown(1248, true);
}
// Custom basepoints/target for exist spell
@@ -8778,7 +8780,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
target->CastSpell(target, trigger_spell_id, true, castItem, triggeredByAura);
if (cooldown && GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->AddSpellCooldown(trigger_spell_id, 0, time(NULL) + cooldown);
+ ToPlayer()->AddSpellCooldown(trigger_spell_id, 0, time(NULL) + cooldown);
return true;
}
// Cast positive spell on enemy target
@@ -8840,7 +8842,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
if (isPet())
if (Unit* owner = GetOwner())
{
- if (AuraEffect * aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, 3220, 0))
+ if (AuraEffect* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, 3220, 0))
{
basepoints0 = int32((aurEff->GetAmount() * owner->SpellBaseDamageBonus(SpellSchoolMask(SPELL_SCHOOL_MASK_MAGIC)) + 100.0f) / 100.0f); // TODO: Is it right?
CastCustomSpell(this, trigger_spell_id, &basepoints0, &basepoints0, NULL, true, castItem, triggeredByAura);
@@ -8854,7 +8856,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
{
// Remove cooldown on Shield Slam
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->RemoveSpellCategoryCooldown(1209, true);
+ ToPlayer()->RemoveSpellCategoryCooldown(1209, true);
break;
}
// Maelstrom Weapon
@@ -8916,7 +8918,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
{
// remove cooldown of Death Grip
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->RemoveSpellCooldown(49576, true);
+ ToPlayer()->RemoveSpellCooldown(49576, true);
return true;
}
// Savage Defense
@@ -8951,7 +8953,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
if (GetTypeId() != TYPEID_PLAYER)
return false;
- Player* player = this->ToPlayer();
+ Player* player = ToPlayer();
if (player->GetQuestStatus(24749) == QUEST_STATUS_INCOMPLETE) // Unholy Infusion
{
if (!player->HasAura(71516) || pVictim->GetEntry() != 36678) // Shadow Infusion && Professor Putricide
@@ -9009,7 +9011,7 @@ bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, uint32 /*damage*/, A
return false;
Item* castItem = triggeredByAura->GetBase()->GetCastItemGUID() && GetTypeId() == TYPEID_PLAYER
- ? this->ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
+ ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL;
uint32 triggered_spell_id = 0;
@@ -9092,13 +9094,13 @@ bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, uint32 /*damage*/, A
return false;
}
- if (cooldown && GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->HasSpellCooldown(triggered_spell_id))
+ if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->HasSpellCooldown(triggered_spell_id))
return false;
CastSpell(pVictim, triggered_spell_id, true, castItem, triggeredByAura);
if (cooldown && GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
+ ToPlayer()->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown);
return true;
}
@@ -9109,15 +9111,14 @@ void Unit::setPowerType(Powers new_powertype)
if (GetTypeId() == TYPEID_PLAYER)
{
- if (this->ToPlayer()->GetGroup())
- this->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POWER_TYPE);
+ if (ToPlayer()->GetGroup())
+ ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POWER_TYPE);
}
- else if (this->ToCreature()->isPet())
+ else if (Pet* pet = ToCreature()->ToPet())
{
- Pet *pet = ((Pet*)this);
if (pet->isControlled())
{
- Unit *owner = GetOwner();
+ Unit* owner = GetOwner();
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_POWER_TYPE);
}
@@ -9155,9 +9156,9 @@ FactionTemplateEntry const* Unit::getFactionTemplateEntry() const
if (GetGUID() != guid)
{
- if (const Player* player = ToPlayer())
+ if (Player const* player = ToPlayer())
sLog->outError("Player %s has invalid faction (faction template id) #%u", player->GetName(), getFaction());
- else if (const Creature *creature = ToCreature())
+ else if (Creature const* creature = ToCreature())
sLog->outError("Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureInfo()->Entry, getFaction());
else
sLog->outError("Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName(), uint32(GetTypeId()), getFaction());
@@ -9256,7 +9257,7 @@ bool Unit::IsHostileTo(Unit const* unit) const
// forced reaction
if (target_faction->faction)
{
- if (ReputationRank const* force =tester->ToPlayer()->GetReputationMgr().GetForcedRankIfAny(target_faction))
+ if (ReputationRank const* force = tester->ToPlayer()->GetReputationMgr().GetForcedRankIfAny(target_faction))
return *force <= REP_HOSTILE;
// if faction have reputation then hostile state for tester at 100% dependent from at_war state
@@ -9276,7 +9277,7 @@ bool Unit::IsHostileTo(Unit const* unit) const
// apply reputation state
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
- if (raw_tester_faction && raw_tester_faction->reputationListID >=0)
+ if (raw_tester_faction && raw_tester_faction->reputationListID >= 0)
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE;
}
}
@@ -9357,8 +9358,8 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
}
// faction base cases
- FactionTemplateEntry const *tester_faction = tester->getFactionTemplateEntry();
- FactionTemplateEntry const *target_faction = target->getFactionTemplateEntry();
+ FactionTemplateEntry const* tester_faction = tester->getFactionTemplateEntry();
+ FactionTemplateEntry const* target_faction = target->getFactionTemplateEntry();
if (!tester_faction || !target_faction)
return false;
@@ -9371,12 +9372,12 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
// forced reaction
if (target_faction->faction)
{
- if (ReputationRank const *force =tester->ToPlayer()->GetReputationMgr().GetForcedRankIfAny(target_faction))
+ if (ReputationRank const* force = tester->ToPlayer()->GetReputationMgr().GetForcedRankIfAny(target_faction))
return *force >= REP_FRIENDLY;
// if faction have reputation then friendly state for tester at 100% dependent from at_war state
- if (FactionEntry const *raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
- if (FactionState const *factionState = tester->ToPlayer()->GetReputationMgr().GetState(raw_target_faction))
+ if (FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
+ if (FactionState const* factionState = tester->ToPlayer()->GetReputationMgr().GetState(raw_target_faction))
return !(factionState->Flags & FACTION_FLAG_AT_WAR);
}
}
@@ -9386,11 +9387,11 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
// forced reaction
if (tester_faction->faction)
{
- if (ReputationRank const *force =target->ToPlayer()->GetReputationMgr().GetForcedRankIfAny(tester_faction))
+ if (ReputationRank const* force = target->ToPlayer()->GetReputationMgr().GetForcedRankIfAny(tester_faction))
return *force >= REP_FRIENDLY;
// apply reputation state
- if (FactionEntry const *raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
+ if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
if (raw_tester_faction->reputationListID >= 0)
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY;
}
@@ -9402,11 +9403,11 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
bool Unit::IsHostileToPlayers() const
{
- FactionTemplateEntry const *my_faction = getFactionTemplateEntry();
+ FactionTemplateEntry const* my_faction = getFactionTemplateEntry();
if (!my_faction || !my_faction->faction)
return false;
- FactionEntry const *raw_faction = sFactionStore.LookupEntry(my_faction->faction);
+ FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
if (raw_faction && raw_faction->reputationListID >= 0)
return false;
@@ -9415,11 +9416,11 @@ bool Unit::IsHostileToPlayers() const
bool Unit::IsNeutralToAll() const
{
- FactionTemplateEntry const *my_faction = getFactionTemplateEntry();
+ FactionTemplateEntry const* my_faction = getFactionTemplateEntry();
if (!my_faction || !my_faction->faction)
return true;
- FactionEntry const *raw_faction = sFactionStore.LookupEntry(my_faction->faction);
+ FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
if (raw_faction && raw_faction->reputationListID >= 0)
return false;
@@ -9478,7 +9479,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
return false;
}
- //switch target
+ // switch target
InterruptSpell(CURRENT_MELEE_SPELL);
if (!meleeAttack)
ClearUnitState(UNIT_STAT_MELEE_ATTACKING);
@@ -9498,18 +9499,18 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
// set position before any AI calls/assistance
//if (GetTypeId() == TYPEID_UNIT)
- // this->ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
+ // ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
- if (GetTypeId() == TYPEID_UNIT && !this->ToCreature()->isPet())
+ if (GetTypeId() == TYPEID_UNIT && !ToCreature()->isPet())
{
- // should not let player enter combat by right clicking target
+ // should not let player enter combat by right clicking target - doesn't helps
SetInCombatWith(victim);
if (victim->GetTypeId() == TYPEID_PLAYER)
victim->SetInCombatWith(this);
AddThreat(victim, 0.0f);
- this->ToCreature()->SendAIReaction(AI_REACTION_HOSTILE);
- this->ToCreature()->CallAssistance();
+ ToCreature()->SendAIReaction(AI_REACTION_HOSTILE);
+ ToCreature()->CallAssistance();
}
// delay offhand weapon attack to next attack time
@@ -9540,13 +9541,13 @@ bool Unit::AttackStop()
InterruptSpell(CURRENT_MELEE_SPELL);
// reset only at real combat stop
- if (GetTypeId() == TYPEID_UNIT)
+ if (Creature* creature = ToCreature())
{
- this->ToCreature()->SetNoCallAssistance(false);
+ creature->SetNoCallAssistance(false);
- if (this->ToCreature()->HasSearchedAssistance())
+ if (creature->HasSearchedAssistance())
{
- this->ToCreature()->SetNoSearchAssistance(false);
+ creature->SetNoSearchAssistance(false);
UpdateSpeed(MOVE_RUN, false);
}
}
@@ -9564,7 +9565,7 @@ void Unit::CombatStop(bool includingCast)
AttackStop();
RemoveAllAttackers();
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel
+ ToPlayer()->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel
ClearInCombat();
}
@@ -9616,24 +9617,27 @@ void Unit::ModifyAuraState(AuraState flag, bool apply)
SetFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1));
if (GetTypeId() == TYPEID_PLAYER)
{
- PlayerSpellMap const& sp_list = this->ToPlayer()->GetSpellMap();
+ PlayerSpellMap const& sp_list = ToPlayer()->GetSpellMap();
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
{
- if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled) continue;
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
- if (!spellInfo || !IsPassiveSpell(itr->first)) continue;
+ if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
+ continue;
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first);
+ if (!spellInfo || !IsPassiveSpell(itr->first))
+ continue;
if (spellInfo->CasterAuraState == uint32(flag))
CastSpell(this, itr->first, true, NULL);
}
}
- else if (this->ToCreature()->isPet())
+ else if (Pet* pet = ToCreature()->ToPet())
{
- Pet *pet = ((Pet*)this);
for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr)
{
- if (itr->second.state == PETSPELL_REMOVED) continue;
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
- if (!spellInfo || !IsPassiveSpell(itr->first)) continue;
+ if (itr->second.state == PETSPELL_REMOVED)
+ continue;
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first);
+ if (!spellInfo || !IsPassiveSpell(itr->first))
+ continue;
if (spellInfo->CasterAuraState == uint32(flag))
CastSpell(this, itr->first, true, NULL);
}
@@ -9837,9 +9841,9 @@ void Unit::SetMinion(Minion *minion, bool apply)
if (GetTypeId() == TYPEID_PLAYER)
{
// Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
if (spellInfo && (spellInfo->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE))
- this->ToPlayer()->AddSpellAndCategoryCooldowns(spellInfo, 0, NULL, true);
+ ToPlayer()->AddSpellAndCategoryCooldowns(spellInfo, 0, NULL, true);
}
}
else
@@ -9866,22 +9870,22 @@ void Unit::SetMinion(Minion *minion, bool apply)
else if (minion->isTotem())
{
// All summoned by totem minions must disappear when it is removed.
- if (const SpellEntry* spInfo = sSpellStore.LookupEntry(minion->ToTotem()->GetSpell()))
+ if (SpellEntry const* spInfo = sSpellStore.LookupEntry(minion->ToTotem()->GetSpell()))
for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spInfo->Effect[i] != SPELL_EFFECT_SUMMON)
continue;
- this->RemoveAllMinionsByEntry(spInfo->EffectMiscValue[i]);
+ RemoveAllMinionsByEntry(spInfo->EffectMiscValue[i]);
}
}
if (GetTypeId() == TYPEID_PLAYER)
{
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
// Remove infinity cooldown
if (spellInfo && (spellInfo->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE))
- this->ToPlayer()->SendCooldownEvent(spellInfo);
+ ToPlayer()->SendCooldownEvent(spellInfo);
}
//if (minion->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
@@ -9910,13 +9914,13 @@ void Unit::SetMinion(Minion *minion, bool apply)
if (AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID()))
{
- //show another pet bar if there is no charm bar
+ // show another pet bar if there is no charm bar
if (GetTypeId() == TYPEID_PLAYER && !GetCharmGUID())
{
if ((*itr)->isPet())
- this->ToPlayer()->PetSpellInitialize();
+ ToPlayer()->PetSpellInitialize();
else
- this->ToPlayer()->CharmSpellInitialize();
+ ToPlayer()->CharmSpellInitialize();
}
}
break;
@@ -9930,7 +9934,7 @@ void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry)
{
for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();)
{
- Unit *unit = *itr;
+ Unit* unit = *itr;
++itr;
if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
&& unit->ToCreature()->isSummon()) // minion, actually
@@ -9942,7 +9946,7 @@ void Unit::RemoveAllMinionsByEntry(uint32 entry)
{
for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();)
{
- Unit *unit = *itr;
+ Unit* unit = *itr;
++itr;
if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
&& unit->ToCreature()->isSummon()) // minion, actually
@@ -10033,7 +10037,7 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth)
Unit* unit = this;
- if (GetTypeId() == TYPEID_UNIT && this->ToCreature()->isTotem())
+ if (GetTypeId() == TYPEID_UNIT && ToCreature()->isTotem())
unit = GetOwner();
if (unit->GetTypeId() == TYPEID_PLAYER)
@@ -10065,7 +10069,7 @@ Unit* Unit::SelectMagnetTarget(Unit* victim, SpellEntry const *spellInfo)
// Magic case
if (spellInfo && (spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE || spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC))
{
- //I am not sure if this should be redirected.
+ // I am not sure if this should be redirected.
if (spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE)
return victim;
@@ -10097,8 +10101,8 @@ Unit* Unit::SelectMagnetTarget(Unit* victim, SpellEntry const *spellInfo)
Unit* Unit::GetFirstControlled() const
{
- //Sequence: charmed, pet, other guardians
- Unit *unit = GetCharm();
+ // Sequence: charmed, pet, other guardians
+ Unit* unit = GetCharm();
if (!unit)
if (uint64 guid = GetUInt64Value(UNIT_FIELD_SUMMON))
unit = ObjectAccessor::GetUnit(*this, guid);
@@ -10108,9 +10112,9 @@ Unit* Unit::GetFirstControlled() const
void Unit::RemoveAllControlled()
{
- //possessed pet and vehicle
+ // possessed pet and vehicle
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->StopCastingCharm();
+ ToPlayer()->StopCastingCharm();
while (!m_Controlled.empty())
{
@@ -10135,22 +10139,22 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
{
Player* player = NULL;
if (GetTypeId() == TYPEID_PLAYER)
- player = (Player*)this;
+ player = ToPlayer();
// Should we enable this also for charmed units?
- else if (GetTypeId() == TYPEID_UNIT && this->ToCreature()->isPet())
- player = (Player*)GetOwner();
+ else if (GetTypeId() == TYPEID_UNIT && ToCreature()->isPet())
+ player = GetOwner()->ToPlayer();
if (!player)
return NULL;
- Group *pGroup = player->GetGroup();
- //When there is no group check pet presence
+ Group* pGroup = player->GetGroup();
+ // When there is no group check pet presence
if (!pGroup)
{
// We are pet now, return owner
if (player != this)
return IsWithinDistInMap(player, radius) ? player : NULL;
Unit* pet = GetGuardianPet();
- //No pet, no group, nothing to return
+ // No pet, no group, nothing to return
if (!pet)
return NULL;
// We are owner now, return pet
@@ -10158,18 +10162,18 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
}
std::vector<Unit*> nearMembers;
- //reserve place for players and pets because resizing vector every unit push is unefficient (vector is reallocated then)
- nearMembers.reserve(pGroup->GetMembersCount()*2);
+ // reserve place for players and pets because resizing vector every unit push is unefficient (vector is reallocated then)
+ nearMembers.reserve(pGroup->GetMembersCount() * 2);
for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
- if (Player *Target = itr->getSource())
+ if (Player* Target = itr->getSource())
{
// IsHostileTo check duel and controlled by enemy
- if (Target !=this && Target->isAlive() && IsWithinDistInMap(Target, radius) && !IsHostileTo(Target))
+ if (Target != this && Target->isAlive() && IsWithinDistInMap(Target, radius) && !IsHostileTo(Target))
nearMembers.push_back(Target);
// Push player's pet to vector
- if (Unit *pet = Target->GetGuardianPet())
+ if (Unit* pet = Target->GetGuardianPet())
if (pet != this && pet->isAlive() && IsWithinDistInMap(pet, radius) && !IsHostileTo(pet))
nearMembers.push_back(pet);
}
@@ -10181,7 +10185,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
return nearMembers[randTarget];
}
-//only called in Player::SetSeer
+// only called in Player::SetSeer
// so move it to Player?
void Unit::AddPlayerToVision(Player* plr)
{
@@ -10193,7 +10197,7 @@ void Unit::AddPlayerToVision(Player* plr)
m_sharedVision.push_back(plr);
}
-//only called in Player::SetSeer
+// only called in Player::SetSeer
void Unit::RemovePlayerFromVision(Player* plr)
{
m_sharedVision.remove(plr);
@@ -10280,8 +10284,8 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
return pdamage;
// For totems get damage bonus from owner
- if (GetTypeId() == TYPEID_UNIT && this->ToCreature()->isTotem())
- if (Unit *owner = GetOwner())
+ if (GetTypeId() == TYPEID_UNIT && ToCreature()->isTotem())
+ if (Unit* owner = GetOwner())
return owner->SpellDamageBonus(pVictim, spellProto, pdamage, damagetype);
// Taken/Done total percent damage auras
@@ -10291,13 +10295,13 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
int32 TakenTotal = 0;
// ..done
- // Pet damage
- if (GetTypeId() == TYPEID_UNIT && !this->ToCreature()->isPet())
- DoneTotalMod *= this->ToCreature()->GetSpellDamageMod(this->ToCreature()->GetCreatureInfo()->rank);
+ // Pet damage?
+ if (GetTypeId() == TYPEID_UNIT && !ToCreature()->isPet())
+ DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureInfo()->rank);
if (spellProto)
{
- AuraEffectList const &mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
+ AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
if ((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto))
{
@@ -10320,20 +10324,20 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
uint32 creatureTypeMask = pVictim->GetCreatureTypeMask();
// Add flat bonus from spell damage versus
DoneTotal += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS, creatureTypeMask);
- AuraEffectList const &mDamageDoneVersus = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
+ AuraEffectList const& mDamageDoneVersus = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
if (creatureTypeMask & uint32((*i)->GetMiscValue()))
AddPctN(DoneTotalMod, (*i)->GetAmount());
// bonus against aurastate
- AuraEffectList const &mDamageDoneVersusAurastate = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS_AURASTATE);
+ AuraEffectList const& mDamageDoneVersusAurastate = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS_AURASTATE);
for (AuraEffectList::const_iterator i = mDamageDoneVersusAurastate.begin(); i != mDamageDoneVersusAurastate.end(); ++i)
if (pVictim->HasAuraState(AuraState((*i)->GetMiscValue())))
AddPctN(DoneTotalMod, (*i)->GetAmount());
// done scripted mod (take it from owner)
Unit* owner = GetOwner() ? GetOwner() : this;
- AuraEffectList const &mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
+ AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
{
if (!(*i)->IsAffectedOnSpell(spellProto))
@@ -10361,11 +10365,11 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
int32 stepPercent = CalculateSpellDamage(this, (*i)->GetSpellProto(), 0);
// count affliction effects and calc additional damage in percentage
int32 modPercent = 0;
- AuraApplicationMap const &victimAuras = pVictim->GetAppliedAuras();
+ AuraApplicationMap const& victimAuras = pVictim->GetAppliedAuras();
for (AuraApplicationMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr)
{
Aura const* aura = itr->second->GetBase();
- SpellEntry const *m_spell = aura->GetSpellProto();
+ SpellEntry const* m_spell = aura->GetSpellProto();
if (m_spell->SpellFamilyName != SPELLFAMILY_WARLOCK || !(m_spell->SpellFamilyFlags[1] & 0x0004071B || m_spell->SpellFamilyFlags[0] & 0x8044C402))
continue;
modPercent += stepPercent * aura->GetStackAmount();
@@ -10427,7 +10431,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
{
if (pVictim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, 0, 0x02000000, 0))
{
- if (SpellChainNode const *chain = sSpellMgr->GetSpellChainNode((*i)->GetId()))
+ if (SpellChainNode const* chain = sSpellMgr->GetSpellChainNode((*i)->GetId()))
AddPctF(DoneTotalMod, chain->rank * 2.0f);
}
break;
@@ -10488,13 +10492,13 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
if (spellProto->SpellFamilyFlags[0] & 0x800000)
{
// Glyph of Shadow Word: Pain
- if (AuraEffect * aurEff = GetAuraEffect(55687, 0))
+ if (AuraEffect* aurEff = GetAuraEffect(55687, 0))
// Increase Mind Flay damage if Shadow Word: Pain present on target
if (pVictim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, GetGUID()))
AddPctN(DoneTotalMod, aurEff->GetAmount());
// Twisted Faith - Mind Flay part
- if (AuraEffect * aurEff = GetAuraEffect(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS, SPELLFAMILY_PRIEST, 2848, 1))
+ if (AuraEffect* aurEff = GetAuraEffect(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS, SPELLFAMILY_PRIEST, 2848, 1))
// Increase Mind Flay damage if Shadow Word: Pain present on target
if (pVictim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, GetGUID()))
AddPctN(DoneTotalMod, aurEff->GetAmount());
@@ -10503,7 +10507,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
else if (spellProto->SpellFamilyFlags[0] & 0x80)
{
// Glyph of Smite
- if (AuraEffect * aurEff = GetAuraEffect(55692, 0))
+ if (AuraEffect* aurEff = GetAuraEffect(55692, 0))
if (pVictim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x100000, 0, 0, GetGUID()))
AddPctN(DoneTotalMod, aurEff->GetAmount());
}
@@ -10536,7 +10540,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
}
break;
case SPELLFAMILY_WARLOCK:
- //Fire and Brimstone
+ // Fire and Brimstone
if (spellProto->SpellFamilyFlags[1] & 0x00020040)
if (pVictim->HasAuraState(AURA_STATE_CONFLAGRATE))
{
@@ -10560,26 +10564,26 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
case SPELLFAMILY_HUNTER:
// Steady Shot
if (spellProto->SpellFamilyFlags[1] & 0x1)
- if (AuraEffect * aurEff = GetAuraEffect(56826, 0)) // Glyph of Steady Shot
+ if (AuraEffect* aurEff = GetAuraEffect(56826, 0)) // Glyph of Steady Shot
if (pVictim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_HUNTER, 0x00004000, 0, 0, GetGUID()))
AddPctN(DoneTotalMod, aurEff->GetAmount());
break;
case SPELLFAMILY_DEATHKNIGHT:
// Improved Icy Touch
if (spellProto->SpellFamilyFlags[0] & 0x2)
- if (AuraEffect * aurEff = GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2721, 0))
+ if (AuraEffect* aurEff = GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2721, 0))
AddPctN(DoneTotalMod, aurEff->GetAmount());
// Glacier Rot
if (spellProto->SpellFamilyFlags[0] & 0x2 || spellProto->SpellFamilyFlags[1] & 0x6)
- if (AuraEffect * aurEff = GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 196, 0))
+ if (AuraEffect* aurEff = GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 196, 0))
if (pVictim->GetDiseasesByCaster(owner->GetGUID()) > 0)
AddPctN(DoneTotalMod, aurEff->GetAmount());
// Impurity (dummy effect)
if (GetTypeId() == TYPEID_PLAYER)
{
- PlayerSpellMap playerSpells = this->ToPlayer()->GetSpellMap();
+ PlayerSpellMap playerSpells = ToPlayer()->GetSpellMap();
for (PlayerSpellMap::const_iterator itr = playerSpells.begin(); itr != playerSpells.end(); ++itr)
{
if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
@@ -10592,7 +10596,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
case 49636:
case 49638:
{
- if (const SpellEntry *proto=sSpellStore.LookupEntry(itr->first))
+ if (SpellEntry const* proto = sSpellStore.LookupEntry(itr->first))
AddPctN(ApCoeffMod, SpellMgr::CalculateSpellEffectAmount(proto, 0));
}
break;
@@ -10630,7 +10634,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
{
if (pVictim->GetTypeId() != TYPEID_PLAYER)
continue;
- float mod = pVictim->ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f);
+ float mod = pVictim->ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f);
if (mod < (*i)->GetAmount())
mod = (float)(*i)->GetAmount();
sumNegativeMod += int32(mod);
@@ -10674,7 +10678,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// Check for table values
float coeff = 0;
- SpellBonusEntry const *bonus = sSpellMgr->GetSpellBonusData(spellProto->Id);
+ SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id);
if (bonus)
{
if (damagetype == DOT)
@@ -10760,7 +10764,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
}
float coeff2 = CalculateLevelPenalty(spellProto) * stack;
- if (spellProto->SpellFamilyName) //TODO: fix this
+ if (spellProto->SpellFamilyName) // TODO: fix this
TakenTotal+= int32(TakenAdvertisedBenefit * coeff * coeff2);
if (Player* modOwner = GetSpellModOwner())
{
@@ -10805,7 +10809,7 @@ int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask)
if (GetTypeId() == TYPEID_PLAYER)
{
// Base value
- DoneAdvertisedBenefit +=this->ToPlayer()->GetBaseSpellPowerBonus();
+ DoneAdvertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus();
// Damage bonus from stats
AuraEffectList const& mDamageDoneOfStatPercent = GetAuraEffectsByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT);
@@ -10893,7 +10897,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM
{
if (!((*i)->IsAffectedOnSpell(spellProto)))
continue;
- int32 modChance=0;
+ int32 modChance = 0;
switch((*i)->GetMiscValue())
{
// Shatter
@@ -10993,7 +10997,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM
&& spellProto->SpellIconID == 1680
&& pVictim->HasAuraState(AURA_STATE_BLEEDING))
{
- if (AuraEffect const *rendAndTear = GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 1))
+ if (AuraEffect const* rendAndTear = GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 1))
crit_chance += rendAndTear->GetAmount();
break;
}
@@ -11098,7 +11102,7 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 dama
uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack)
{
// For totems get healing bonus from owner (statue isn't totem in fact)
- if (GetTypeId() == TYPEID_UNIT && this->ToCreature()->isTotem())
+ if (GetTypeId() == TYPEID_UNIT && ToCreature()->isTotem())
if (Unit* owner = GetOwner())
return owner->SpellHealingBonus(pVictim, spellProto, healamount, damagetype, stack);
@@ -11119,8 +11123,8 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
AddPctN(DoneTotalMod, (*i)->GetAmount());
// done scripted mod (take it from owner)
- Unit *owner = GetOwner() ? GetOwner() : this;
- AuraEffectList const &mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
+ Unit* owner = GetOwner() ? GetOwner() : this;
+ AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
{
if (!(*i)->IsAffectedOnSpell(spellProto))
@@ -11298,7 +11302,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
coeff = (CastingTime / 3500.0f) * DotFactor * 1.88f;
}
- factorMod *= CalculateLevelPenalty(spellProto)* stack;
+ factorMod *= CalculateLevelPenalty(spellProto) * stack;
TakenTotal += int32(TakenAdvertisedBenefit * coeff * factorMod);
if (Player* modOwner = GetSpellModOwner())
{
@@ -11320,7 +11324,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
{
// Rejuvenation, Regrowth, Lifebloom, or Wild Growth
if (pVictim->GetAuraEffect(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_DRUID, 0x50, 0x4000010, 0))
- //increase healing by 20%
+ // increase healing by 20%
TakenTotalMod *= 1.2f;
}
@@ -11374,7 +11378,7 @@ int32 Unit::SpellBaseHealingBonus(SpellSchoolMask schoolMask)
if (GetTypeId() == TYPEID_PLAYER)
{
// Base value
- AdvertisedBenefit +=this->ToPlayer()->GetBaseSpellPowerBonus();
+ AdvertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus();
// Healing bonus from stats
AuraEffectList const& mHealingDoneOfStatPercent = GetAuraEffectsByType(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT);
@@ -11406,13 +11410,13 @@ int32 Unit::SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVi
bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask)
{
- //If m_immuneToSchool type contain this school type, IMMUNE damage.
+ // If m_immuneToSchool type contain this school type, IMMUNE damage.
SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
if (itr->type & shoolMask)
return true;
- //If m_immuneToDamage type contain magic, IMMUNE damage.
+ // If m_immuneToDamage type contain magic, IMMUNE damage.
SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE];
for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr)
if (itr->type & shoolMask)
@@ -11429,14 +11433,14 @@ bool Unit::IsImmunedToDamage(SpellEntry const* spellInfo)
uint32 shoolMask = GetSpellSchoolMask(spellInfo);
if (spellInfo->Id != 42292 && spellInfo->Id !=59752)
{
- //If m_immuneToSchool type contain this school type, IMMUNE damage.
+ // If m_immuneToSchool type contain this school type, IMMUNE damage.
SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
if (itr->type & shoolMask && !CanSpellPierceImmuneAura(spellInfo, sSpellStore.LookupEntry(itr->spellId)))
return true;
}
- //If m_immuneToDamage type contain magic, IMMUNE damage.
+ // If m_immuneToDamage type contain magic, IMMUNE damage.
SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE];
for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr)
if (itr->type & shoolMask)
@@ -11501,7 +11505,7 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con
{
if (!spellInfo)
return false;
- //If m_immuneToEffect type contain this effect type, IMMUNE effect.
+ // If m_immuneToEffect type contain this effect type, IMMUNE effect.
uint32 effect = spellInfo->Effect[index];
SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT];
for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr)
@@ -11634,7 +11638,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
float TakenTotalMod = 1.0f;
// ..done
- AuraEffectList const &mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
+ AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
if (spellProto)
{
@@ -11678,20 +11682,20 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
AddPctN(DoneTotalMod, (*i)->GetAmount());
}
- AuraEffectList const &mDamageDoneVersus = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
+ AuraEffectList const& mDamageDoneVersus = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
if (creatureTypeMask & uint32((*i)->GetMiscValue()))
AddPctN(DoneTotalMod, (*i)->GetAmount());
// bonus against aurastate
- AuraEffectList const &mDamageDoneVersusAurastate = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS_AURASTATE);
+ AuraEffectList const& mDamageDoneVersusAurastate = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS_AURASTATE);
for (AuraEffectList::const_iterator i = mDamageDoneVersusAurastate.begin(); i != mDamageDoneVersusAurastate.end(); ++i)
if (pVictim->HasAuraState(AuraState((*i)->GetMiscValue())))
AddPctN(DoneTotalMod, (*i)->GetAmount());
// done scripted mod (take it from owner)
Unit* owner = GetOwner() ? GetOwner() : this;
- AuraEffectList const &mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
+ AuraEffectList const& mOverrideClassScript = owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
{
if (!(*i)->IsAffectedOnSpell(spellProto))
@@ -11722,7 +11726,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
case 7293:
{
if (pVictim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, 0, 0x02000000, 0))
- if (SpellChainNode const *chain = sSpellMgr->GetSpellChainNode((*i)->GetId()))
+ if (SpellChainNode const* chain = sSpellMgr->GetSpellChainNode((*i)->GetId()))
AddPctF(DoneTotalMod, chain->rank * 2.0f);
break;
}
@@ -11747,7 +11751,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
case SPELLFAMILY_DEATHKNIGHT:
// Glacier Rot
if (spellProto->SpellFamilyFlags[0] & 0x2 || spellProto->SpellFamilyFlags[1] & 0x6)
- if (AuraEffect * aurEff = GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 196, 0))
+ if (AuraEffect* aurEff = GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 196, 0))
if (pVictim->GetDiseasesByCaster(owner->GetGUID()) > 0)
AddPctN(DoneTotalMod, aurEff->GetAmount());
break;
@@ -11796,7 +11800,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
{
if (pVictim->GetTypeId() != TYPEID_PLAYER)
continue;
- float mod = pVictim->ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f);
+ float mod = pVictim->ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f);
AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
}
break;
@@ -12012,7 +12016,7 @@ void Unit::Unmount()
WorldPacket data(SMSG_PLAYER_VEHICLE_DATA, 8+4);
data.appendPackGUID(GetGUID());
data << uint32(0);
- this->ToPlayer()->SendMessageToSet(&data, true);
+ ToPlayer()->SendMessageToSet(&data, true);
// Remove vehicle from player
RemoveVehicleKit();
}
@@ -12022,15 +12026,15 @@ void Unit::Unmount()
// only resummon old pet if the player is already added to a map
// this prevents adding a pet to a not created map which would otherwise cause a crash
// (it could probably happen when logging in after a previous crash)
- if (GetTypeId() == TYPEID_PLAYER)
+ if (Player* plr = ToPlayer())
{
- if (Pet *pPet = this->ToPlayer()->GetPet())
+ if (Pet* pPet = plr->GetPet())
{
- if (pPet && pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STAT_STUNNED))
+ if (pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STAT_STUNNED))
pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
}
else
- this->ToPlayer()->ResummonPetTemporaryUnSummonedIfAny();
+ plr->ResummonPetTemporaryUnSummonedIfAny();
}
}
@@ -12072,11 +12076,11 @@ void Unit::CombatStart(Unit* target, bool initialAggro)
SetInCombatWith(target);
target->SetInCombatWith(this);
}
- Unit *who = target->GetCharmerOrOwnerOrSelf();
+ Unit* who = target->GetCharmerOrOwnerOrSelf();
if (who->GetTypeId() == TYPEID_PLAYER)
SetContestedPvP(who->ToPlayer());
- Player *me = GetCharmerOrOwnerPlayerOrPlayerItself();
+ Player* me = GetCharmerOrOwnerPlayerOrPlayerItself();
if (me && who->IsPvP()
&& (who->GetTypeId() != TYPEID_PLAYER
|| !me->duel || me->duel->opponent != who))
@@ -12100,23 +12104,23 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
- if (GetTypeId() != TYPEID_PLAYER)
+ if (Creature* creature = ToCreature())
{
// Set home position at place of engaging combat for escorted creatures
- if ((IsAIEnabled && this->ToCreature()->AI()->IsEscorted()) ||
+ if ((IsAIEnabled && creature->AI()->IsEscorted()) ||
GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE ||
GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
- this->ToCreature()->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
+ creature->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
if (enemy)
{
if (IsAIEnabled)
{
- this->ToCreature()->AI()->EnterCombat(enemy);
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);//always remove Out of Combat Non Attackable flag if we enter combat and AI is enabled
+ creature->AI()->EnterCombat(enemy);
+ RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); // always remove Out of Combat Non Attackable flag if we enter combat and AI is enabled
}
- if (this->ToCreature()->GetFormation())
- this->ToCreature()->GetFormation()->MemberAttackStart(this->ToCreature(), enemy);
+ if (creature->GetFormation())
+ creature->GetFormation()->MemberAttackStart(creature, enemy);
}
if (isPet())
@@ -12126,7 +12130,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
UpdateSpeed(MOVE_FLIGHT, true);
}
- if (!(ToCreature()->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT))
+ if (!(creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT))
Unmount();
}
@@ -12143,22 +12147,21 @@ void Unit::ClearInCombat()
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
// Player's state will be cleared in Player::UpdateContestedPvP
- if (GetTypeId() != TYPEID_PLAYER)
+ if (Creature* creature = ToCreature())
{
- Creature* creature = this->ToCreature();
if (creature->GetCreatureInfo() && creature->GetCreatureInfo()->unit_flags & UNIT_FLAG_OOC_NOT_ATTACKABLE)
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);//re-apply Out of Combat Non Attackable flag if we leave combat, can be overriden in scripts in EnterEvadeMode()
+ SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); // re-apply Out of Combat Non Attackable flag if we leave combat, can be overriden in scripts in EnterEvadeMode()
ClearUnitState(UNIT_STAT_ATTACK_PLAYER);
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED))
- SetUInt32Value(UNIT_DYNAMIC_FLAGS, ((Creature*)this)->GetCreatureInfo()->dynamicflags);
+ SetUInt32Value(UNIT_DYNAMIC_FLAGS, creature->GetCreatureInfo()->dynamicflags);
}
else
- this->ToPlayer()->UpdatePotionCooldown();
+ ToPlayer()->UpdatePotionCooldown();
- if (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet())
+ if (GetTypeId() != TYPEID_PLAYER && ToCreature()->isPet())
{
- if (Unit *owner = GetOwner())
+ if (Unit* owner = GetOwner())
for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
if (owner->GetSpeedRate(UnitMoveType(i)) > GetSpeedRate(UnitMoveType(i)))
SetSpeed(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i)), true);
@@ -12169,7 +12172,7 @@ void Unit::ClearInCombat()
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
}
-//TODO: remove this function
+// TODO: remove this function
bool Unit::isTargetableForAttack() const
{
return isAttackableByAOE() && !HasUnitState(UNIT_STAT_DIED);
@@ -12184,11 +12187,11 @@ bool Unit::canAttack(Unit const* target, bool force) const
if (IsFriendlyTo(target))
return false;
- if (GetTypeId()!=TYPEID_PLAYER)
+ if (GetTypeId() != TYPEID_PLAYER)
{
if (isPet())
{
- if (Unit *owner = GetOwner())
+ if (Unit* owner = GetOwner())
if (!(owner->canAttack(target)))
return false;
}
@@ -12450,7 +12453,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
{
// Set creature speed rate from CreatureInfo
if (GetTypeId() == TYPEID_UNIT)
- speed *= this->ToCreature()->GetCreatureInfo()->speed_walk;
+ speed *= ToCreature()->GetCreatureInfo()->speed_walk;
// Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need
// TODO: possible affect only on MOVE_RUN
@@ -12470,7 +12473,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
// for creature case, we check explicit if mob searched for assistance
if (GetTypeId() == TYPEID_UNIT)
{
- if (this->ToCreature()->HasSearchedAssistance())
+ if (ToCreature()->HasSearchedAssistance())
speed *= 0.66f; // best guessed value, so this will be 33% reduction. Based off initial speed, mob can then "run", "walk fast" or "walk".
}
@@ -12562,10 +12565,10 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
{
// register forced speed changes for WorldSession::HandleForceSpeedChangeAck
// and do it only for real sent packets and use run for run/mounted as client expected
- ++this->ToPlayer()->m_forced_speed_changes[mtype];
+ ++ToPlayer()->m_forced_speed_changes[mtype];
if (!isInCombat())
- if (Pet* pet = this->ToPlayer()->GetPet())
+ if (Pet* pet = ToPlayer()->GetPet())
pet->SetSpeed(mtype, m_speed_rate[mtype], forced);
}
@@ -12651,8 +12654,8 @@ void Unit::setDeathState(DeathState s)
GetMotionMaster()->Clear(false);
GetMotionMaster()->MoveIdle();
SendMonsterStop(true);
- //without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
- //do not why since in IncreaseMaxHealth currenthealth is checked
+ // without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
+ // do not why since in IncreaseMaxHealth currenthealth is checked
SetHealth(0);
SetPower(getPowerType(), 0);
}
@@ -12684,11 +12687,11 @@ bool Unit::CanHaveThreatList() const
return false;
// totems can not have threat list
- if (this->ToCreature()->isTotem())
+ if (ToCreature()->isTotem())
return false;
// vehicles can not have threat list
- //if (this->ToCreature()->IsVehicle())
+ //if (ToCreature()->IsVehicle())
// return false;
// summons can not have a threat list, unless they are controlled by a creature
@@ -12740,7 +12743,9 @@ void Unit::TauntApply(Unit* taunter)
if (!CanHaveThreatList())
return;
- if (this->ToCreature()->HasReactState(REACT_PASSIVE))
+ Creature* creature = ToCreature();
+
+ if (creature->HasReactState(REACT_PASSIVE))
return;
Unit* target = getVictim();
@@ -12748,8 +12753,8 @@ void Unit::TauntApply(Unit* taunter)
return;
SetInFront(taunter);
- if (this->ToCreature()->IsAIEnabled)
- this->ToCreature()->AI()->AttackStart(taunter);
+ if (creature->IsAIEnabled)
+ creature->AI()->AttackStart(taunter);
//m_ThreatManager.tauntApply(taunter);
}
@@ -12766,7 +12771,9 @@ void Unit::TauntFadeOut(Unit *taunter)
if (!CanHaveThreatList())
return;
- if (this->ToCreature()->HasReactState(REACT_PASSIVE))
+ Creature* creature = ToCreature();
+
+ if (creature->HasReactState(REACT_PASSIVE))
return;
Unit* target = getVictim();
@@ -12775,8 +12782,8 @@ void Unit::TauntFadeOut(Unit *taunter)
if (m_ThreatManager.isThreatListEmpty())
{
- if (this->ToCreature()->IsAIEnabled)
- this->ToCreature()->AI()->EnterEvadeMode();
+ if (creature->IsAIEnabled)
+ creature->AI()->EnterEvadeMode();
return;
}
@@ -12786,8 +12793,8 @@ void Unit::TauntFadeOut(Unit *taunter)
if (target && target != taunter)
{
SetInFront(target);
- if (this->ToCreature()->IsAIEnabled)
- this->ToCreature()->AI()->AttackStart(target);
+ if (creature->IsAIEnabled)
+ creature->AI()->AttackStart(target);
}
}
@@ -12795,13 +12802,13 @@ void Unit::TauntFadeOut(Unit *taunter)
Unit* Creature::SelectVictim()
{
- //function provides main threat functionality
- //next-victim-selection algorithm and evade mode are called
- //threat list sorting etc.
+ // function provides main threat functionality
+ // next-victim-selection algorithm and evade mode are called
+ // threat list sorting etc.
Unit* target = NULL;
// First checking if we have some taunt on us
- const AuraEffectList& tauntAuras = GetAuraEffectsByType(SPELL_AURA_MOD_TAUNT);
+ AuraEffectList const& tauntAuras = GetAuraEffectsByType(SPELL_AURA_MOD_TAUNT);
if (!tauntAuras.empty())
{
Unit* caster = tauntAuras.back()->GetCaster();
@@ -12820,7 +12827,7 @@ Unit* Creature::SelectVictim()
{
--aura;
caster = (*aura)->GetCaster();
- if (caster && canSeeOrDetect(caster, true) && canAttack(caster) && caster->isInAccessiblePlaceFor(this->ToCreature()))
+ if (caster && canSeeOrDetect(caster, true) && canAttack(caster) && caster->isInAccessiblePlaceFor(ToCreature()))
{
target = caster;
break;
@@ -12843,7 +12850,7 @@ Unit* Creature::SelectVictim()
target = getAttackerForHelper();
if (!target && isSummon())
{
- if (Unit* owner = this->ToTempSummon()->GetOwner())
+ if (Unit* owner = ToTempSummon()->GetOwner())
{
if (owner->isInCombat())
target = owner->getAttackerForHelper();
@@ -12854,7 +12861,8 @@ Unit* Creature::SelectVictim()
if ((*itr)->isInCombat())
{
target = (*itr)->getAttackerForHelper();
- if (target) break;
+ if (target)
+ break;
}
}
}
@@ -12964,11 +12972,11 @@ int32 Unit::CalcSpellDuration(SpellEntry const* spellProto)
int32 Unit::ModSpellDuration(SpellEntry const* spellProto, Unit const* target, int32 duration, bool positive)
{
- //don't mod permament auras duration
+ // don't mod permament auras duration
if (duration < 0)
return duration;
- //cut duration only of negative effects
+ // cut duration only of negative effects
if (!positive)
{
int32 mechanic = GetAllSpellMechanicMask(spellProto);
@@ -13016,8 +13024,8 @@ int32 Unit::ModSpellDuration(SpellEntry const* spellProto, Unit const* target, i
}
else
{
- //else positive mods here, there are no currently
- //when there will be, change GetTotalAuraModifierByMiscValue to GetTotalPositiveAuraModifierByMiscValue
+ // else positive mods here, there are no currently
+ // when there will be, change GetTotalAuraModifierByMiscValue to GetTotalPositiveAuraModifierByMiscValue
// Mixology - duration boost
if (target->GetTypeId() == TYPEID_PLAYER)
@@ -13041,7 +13049,7 @@ int32 Unit::ModSpellDuration(SpellEntry const* spellProto, Unit const* target, i
if (spellProto->SpellFamilyFlags[0] & 0x100)
{
// Glyph of Thorns
- if (AuraEffect * aurEff = GetAuraEffect(57862, 0))
+ if (AuraEffect* aurEff = GetAuraEffect(57862, 0))
duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS;
}
break;
@@ -13049,13 +13057,13 @@ int32 Unit::ModSpellDuration(SpellEntry const* spellProto, Unit const* target, i
if (spellProto->SpellFamilyFlags[0] & 0x00000002)
{
// Glyph of Blessing of Might
- if (AuraEffect * aurEff = GetAuraEffect(57958, 0))
+ if (AuraEffect* aurEff = GetAuraEffect(57958, 0))
duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS;
}
else if (spellProto->SpellFamilyFlags[0] & 0x00010000)
{
// Glyph of Blessing of Wisdom
- if (AuraEffect * aurEff = GetAuraEffect(57979, 0))
+ if (AuraEffect* aurEff = GetAuraEffect(57979, 0))
duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS;
}
break;
@@ -13145,7 +13153,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,
if (group == DIMINISHING_TAUNT)
{
- if (GetTypeId() == TYPEID_UNIT && (((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TAUNT_DIMINISH))
+ if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TAUNT_DIMINISH))
{
DiminishingLevels diminish = Level;
switch(diminish)
@@ -13162,7 +13170,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,
// Some diminishings applies to mobs too (for example, Stun)
else if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER
&& ((targetOwner ? (targetOwner->GetTypeId() == TYPEID_PLAYER) : (GetTypeId() == TYPEID_PLAYER))
- || (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH)))
+ || (GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH)))
|| GetDiminishingReturnsGroupType(group) == DRTYPE_ALL)
{
DiminishingLevels diminish = Level;
@@ -13259,7 +13267,7 @@ uint32 Unit::GetCreatureType() const
return CREATURE_TYPE_HUMANOID;
}
else
- return this->ToCreature()->GetCreatureInfo()->type;
+ return ToCreature()->GetCreatureInfo()->type;
}
/*#######################################
@@ -13467,8 +13475,8 @@ void Unit::SetLevel(uint8 lvl)
SetUInt32Value(UNIT_FIELD_LEVEL, lvl);
// group update
- if (GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->GetGroup())
- this->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
+ if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetGroup())
+ ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
}
void Unit::SetHealth(uint32 val)
@@ -13487,17 +13495,16 @@ void Unit::SetHealth(uint32 val)
SetUInt32Value(UNIT_FIELD_HEALTH, val);
// group update
- if (GetTypeId() == TYPEID_PLAYER)
+ if (Player* plr = ToPlayer())
{
- if (this->ToPlayer()->GetGroup())
- this->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP);
+ if (plr->GetGroup())
+ plr->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP);
}
- else if (this->ToCreature()->isPet())
+ else if (Pet* pet = ToCreature()->ToPet())
{
- Pet *pet = ((Pet*)this);
if (pet->isControlled())
{
- Unit *owner = GetOwner();
+ Unit* owner = GetOwner();
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP);
}
@@ -13515,15 +13522,14 @@ void Unit::SetMaxHealth(uint32 val)
// group update
if (GetTypeId() == TYPEID_PLAYER)
{
- if (this->ToPlayer()->GetGroup())
- this->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_HP);
+ if (ToPlayer()->GetGroup())
+ ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_HP);
}
- else if (this->ToCreature()->isPet())
+ else if (Pet* pet = ToCreature()->ToPet())
{
- Pet *pet = ((Pet*)this);
if (pet->isControlled())
{
- Unit *owner = GetOwner();
+ Unit* owner = GetOwner();
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP);
}
@@ -13551,17 +13557,16 @@ void Unit::SetPower(Powers power, uint32 val)
SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER ? true : false);
// group update
- if (GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = ToPlayer())
{
- if (this->ToPlayer()->GetGroup())
- this->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER);
+ if (player->GetGroup())
+ player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER);
}
- else if (this->ToCreature()->isPet())
+ else if (Pet* pet = ToCreature()->ToPet())
{
- Pet *pet = ((Pet*)this);
if (pet->isControlled())
{
- Unit *owner = GetOwner();
+ Unit* owner = GetOwner();
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER);
}
@@ -13580,15 +13585,14 @@ void Unit::SetMaxPower(Powers power, uint32 val)
// group update
if (GetTypeId() == TYPEID_PLAYER)
{
- if (this->ToPlayer()->GetGroup())
- this->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER);
+ if (ToPlayer()->GetGroup())
+ ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER);
}
- else if (this->ToCreature()->isPet())
+ else if (Pet* pet = ToCreature()->ToPet())
{
- Pet *pet = ((Pet*)this);
if (pet->isControlled())
{
- Unit *owner = GetOwner();
+ Unit* owner = GetOwner();
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER);
}
@@ -13656,7 +13660,7 @@ void Unit::RemoveFromWorld()
ASSERT(false);
}
- if (Unit *owner = GetOwner())
+ if (Unit* owner = GetOwner())
{
if (owner->m_Controlled.find(this) != owner->m_Controlled.end())
{
@@ -13680,8 +13684,8 @@ void Unit::CleanupsBeforeDelete(bool finalCleanup)
ASSERT(GetGUID());
- //A unit may be in removelist and not in world, but it is still in grid
- //and may have some references during delete
+ // A unit may be in removelist and not in world, but it is still in grid
+ // and may have some references during delete
RemoveAllAuras();
RemoveAllGameObjects();
@@ -13720,9 +13724,9 @@ void Unit::UpdateCharmAI()
{
i_disabledAI = i_AI;
if (isPossessed() || IsVehicle())
- i_AI = new PossessedAI(this->ToCreature());
+ i_AI = new PossessedAI(ToCreature());
else
- i_AI = new PetAI(this->ToCreature());
+ i_AI = new PetAI(ToCreature());
}
}
}
@@ -13803,7 +13807,7 @@ void CharmInfo::InitPossessCreateSpells()
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
{
uint32 spellId = m_unit->ToCreature()->m_spells[i];
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (spellInfo && spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)
spellId = 0;
if (IsPassiveSpell(spellId))
@@ -13827,7 +13831,7 @@ void CharmInfo::InitCharmCreateSpells()
for (uint32 x = 0; x < MAX_SPELL_CHARM; ++x)
{
uint32 spellId = m_unit->ToCreature()->m_spells[x];
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (spellInfo && spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)
spellId = 0;
@@ -13946,7 +13950,7 @@ void CharmInfo::LoadPetActionBar(const std::string& data)
Tokens tokens(data, ' ');
- if (tokens.size() != (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START)*2)
+ if (tokens.size() != (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START) * 2)
return; // non critical, will reset to default
uint8 index;
@@ -14002,8 +14006,8 @@ struct ProcTriggeredData
effMask = 0;
spellProcEvent = NULL;
}
- SpellProcEventEntry const *spellProcEvent;
- Aura * aura;
+ SpellProcEventEntry const* spellProcEvent;
+ Aura* aura;
uint32 effMask;
};
@@ -14017,7 +14021,7 @@ bool InitTriggerAuraData()
{
for (uint16 i = 0; i < TOTAL_AURAS; ++i)
{
- isTriggerAura[i]=false;
+ isTriggerAura[i] = false;
isNonTriggerAura[i] = false;
isAlwaysTriggeredAura[i] = false;
}
@@ -14050,7 +14054,7 @@ bool InitTriggerAuraData()
isTriggerAura[SPELL_AURA_MOD_MECHANIC_RESISTANCE] = true;
isTriggerAura[SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS] = true;
isTriggerAura[SPELL_AURA_MOD_MELEE_HASTE] = true;
- isTriggerAura[SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE]=true;
+ isTriggerAura[SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE] = true;
isTriggerAura[SPELL_AURA_RAID_PROC_FROM_CHARGE] = true;
isTriggerAura[SPELL_AURA_RAID_PROC_FROM_CHARGE_WITH_VALUE] = true;
isTriggerAura[SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE] = true;
@@ -14058,8 +14062,8 @@ bool InitTriggerAuraData()
isTriggerAura[SPELL_AURA_MOD_SPELL_CRIT_CHANCE] = true;
isTriggerAura[SPELL_AURA_ABILITY_IGNORE_AURASTATE] = true;
- isNonTriggerAura[SPELL_AURA_MOD_POWER_REGEN]=true;
- isNonTriggerAura[SPELL_AURA_REDUCE_PUSHBACK]=true;
+ isNonTriggerAura[SPELL_AURA_MOD_POWER_REGEN] = true;
+ isNonTriggerAura[SPELL_AURA_REDUCE_PUSHBACK] = true;
isAlwaysTriggeredAura[SPELL_AURA_OVERRIDE_CLASS_SCRIPTS] = true;
isAlwaysTriggeredAura[SPELL_AURA_MOD_FEAR] = true;
@@ -14114,7 +14118,7 @@ uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missC
void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const* procSpell, uint32 damage, SpellEntry const* procAura)
{
// Player is loaded now - do not allow passive spell casts to proc
- if (GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->GetSession()->PlayerLoading())
+ if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetSession()->PlayerLoading())
return;
// For melee/ranged based attack need update skills and set some Aura states if victim present
if (procFlag & MELEE_BASED_TRIGGER_MASK && pTarget)
@@ -14123,14 +14127,14 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
if (GetTypeId() == TYPEID_PLAYER)
{
// On melee based hit/miss/resist need update skill (for victim and attacker)
- if (procExtra&(PROC_EX_NORMAL_HIT|PROC_EX_MISS|PROC_EX_RESIST))
+ if (procExtra & (PROC_EX_NORMAL_HIT|PROC_EX_MISS|PROC_EX_RESIST))
{
if (pTarget->GetTypeId() != TYPEID_PLAYER && pTarget->GetCreatureType() != CREATURE_TYPE_CRITTER)
- this->ToPlayer()->UpdateCombatSkills(pTarget, attType, isVictim);
+ ToPlayer()->UpdateCombatSkills(pTarget, attType, isVictim);
}
// Update defence if player is victim and parry/dodge/block
- else if (isVictim && procExtra&(PROC_EX_DODGE|PROC_EX_PARRY|PROC_EX_BLOCK))
- this->ToPlayer()->UpdateCombatSkills(pTarget, attType, true);
+ else if (isVictim && procExtra & (PROC_EX_DODGE|PROC_EX_PARRY|PROC_EX_BLOCK))
+ ToPlayer()->UpdateCombatSkills(pTarget, attType, true);
}
// If exist crit/parry/dodge/block need update aura state (for victim and attacker)
if (procExtra & (PROC_EX_CRITICAL_HIT|PROC_EX_PARRY|PROC_EX_DODGE|PROC_EX_BLOCK))
@@ -14139,9 +14143,9 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
if (isVictim)
{
// if victim and dodge attack
- if (procExtra&PROC_EX_DODGE)
+ if (procExtra & PROC_EX_DODGE)
{
- //Update AURA_STATE on dodge
+ // Update AURA_STATE on dodge
if (getClass() != CLASS_ROGUE) // skip Rogue Riposte
{
ModifyAuraState(AURA_STATE_DEFENSE, true);
@@ -14170,12 +14174,12 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
StartReactiveTimer(REACTIVE_DEFENSE);
}
}
- else //For attacker
+ else // For attacker
{
// Overpower on victim dodge
- if (procExtra&PROC_EX_DODGE && GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR)
+ if (procExtra & PROC_EX_DODGE && GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR)
{
- this->ToPlayer()->AddComboPoints(pTarget, 1);
+ ToPlayer()->AddComboPoints(pTarget, 1);
StartReactiveTimer(REACTIVE_OVERPOWER);
}
}
@@ -14206,7 +14210,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
{
if (itr->second->HasEffect(i))
{
- AuraEffect * aurEff = itr->second->GetBase()->GetEffect(i);
+ AuraEffect* aurEff = itr->second->GetBase()->GetEffect(i);
// Skip this auras
if (isNonTriggerAura[aurEff->GetAuraType()])
continue;
@@ -14236,9 +14240,9 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
if (i->aura->IsRemoved())
continue;
- bool useCharges= i->aura->GetCharges()>0;
+ bool useCharges = i->aura->GetCharges() > 0;
bool takeCharges = false;
- SpellEntry const *spellInfo = i->aura->GetSpellProto();
+ SpellEntry const* spellInfo = i->aura->GetSpellProto();
uint32 Id = i->aura->GetId();
// For players set spell cooldown if need
@@ -14263,7 +14267,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
if (!(i->effMask & (1<<effIndex)))
continue;
- AuraEffect *triggeredByAura = i->aura->GetEffect(effIndex);
+ AuraEffect* triggeredByAura = i->aura->GetEffect(effIndex);
ASSERT(triggeredByAura);
switch(triggeredByAura->GetAuraType())
@@ -14400,7 +14404,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
// Spell own direct damage at apply wont break the CC
if (procSpell && (procSpell->Id == triggeredByAura->GetId()))
{
- Aura * aura = triggeredByAura->GetBase();
+ Aura* aura = triggeredByAura->GetBase();
// called from spellcast, should not have ticked yet
if (aura->GetDuration() == aura->GetMaxDuration())
break;
@@ -14446,7 +14450,7 @@ Player* Unit::GetSpellModOwner() const
{
if (GetTypeId() == TYPEID_PLAYER)
return (Player*)this;
- if (this->ToCreature()->isPet() || this->ToCreature()->isTotem())
+ if (ToCreature()->isPet() || ToCreature()->isTotem())
{
Unit* owner = GetOwner();
if (owner && owner->GetTypeId() == TYPEID_PLAYER)
@@ -14461,7 +14465,7 @@ void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg)
if (msg == SPELL_CAST_OK)
return;
- Unit *owner = GetCharmerOrOwner();
+ Unit* owner = GetCharmerOrOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return;
@@ -14559,7 +14563,7 @@ void Unit::SetStandState(uint8 state)
{
WorldPacket data(SMSG_STANDSTATE_UPDATE, 1);
data << (uint8)state;
- this->ToPlayer()->GetSession()->SendPacket(&data);
+ ToPlayer()->GetSession()->SendPacket(&data);
}
}
@@ -14569,7 +14573,7 @@ bool Unit::IsPolymorphed() const
if (!transformId)
return false;
- const SpellEntry *spellInfo=sSpellStore.LookupEntry(transformId);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(transformId);
if (!spellInfo)
return false;
@@ -14580,12 +14584,12 @@ void Unit::SetDisplayId(uint32 modelId)
{
SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId);
- if (GetTypeId() == TYPEID_UNIT && this->ToCreature()->isPet())
+ if (GetTypeId() == TYPEID_UNIT && ToCreature()->isPet())
{
- Pet *pet = ((Pet*)this);
+ Pet* pet = ToPet();
if (!pet->isControlled())
return;
- Unit *owner = GetOwner();
+ Unit* owner = GetOwner();
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID);
}
@@ -14641,7 +14645,7 @@ void Unit::ClearComboPointHolders()
void Unit::ClearAllReactives()
{
- for (uint8 i=0; i < MAX_REACTIVE; ++i)
+ for (uint8 i = 0; i < MAX_REACTIVE; ++i)
m_reactiveTimer[i] = 0;
if (HasAuraState(AURA_STATE_DEFENSE))
@@ -14649,7 +14653,7 @@ void Unit::ClearAllReactives()
if (getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY))
ModifyAuraState(AURA_STATE_HUNTER_PARRY, false);
if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->ClearComboPoints();
+ ToPlayer()->ClearComboPoints();
}
void Unit::UpdateReactives(uint32 p_time)
@@ -14677,7 +14681,7 @@ void Unit::UpdateReactives(uint32 p_time)
break;
case REACTIVE_OVERPOWER:
if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->ClearComboPoints();
+ ToPlayer()->ClearComboPoints();
break;
default:
break;
@@ -14747,7 +14751,7 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply)
uint32 Unit::GetCastingTimeForBonus(SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime)
{
// Not apply this to creature casted spells with casttime == 0
- if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !this->ToCreature()->isPet())
+ if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !ToCreature()->isPet())
return 3500;
if (CastingTime > 7000) CastingTime = 7000;
@@ -14761,7 +14765,7 @@ uint32 Unit::GetCastingTimeForBonus(SpellEntry const *spellProto, DamageEffectTy
bool DirectDamage = false;
bool AreaEffect = false;
- for (uint32 i=0; i<MAX_SPELL_EFFECTS; i++)
+ for (uint32 i = 0; i < MAX_SPELL_EFFECTS; i++)
{
switch (spellProto->Effect[i])
{
@@ -14818,7 +14822,7 @@ uint32 Unit::GetCastingTimeForBonus(SpellEntry const *spellProto, DamageEffectTy
CastingTime /= 2;
// -5% of total per any additional effect
- for (uint8 i=0; i<effects; ++i)
+ for (uint8 i = 0; i < effects; ++i)
{
if (CastingTime > 175)
{
@@ -14838,21 +14842,20 @@ void Unit::UpdateAuraForGroup(uint8 slot)
{
if (slot >= MAX_AURAS) // slot not found, return
return;
- if (GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = ToPlayer())
{
- Player* player = (Player*)this;
if (player->GetGroup())
{
player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS);
player->SetAuraUpdateMaskForRaid(slot);
}
}
- else if (GetTypeId() == TYPEID_UNIT && this->ToCreature()->isPet())
+ else if (GetTypeId() == TYPEID_UNIT && ToCreature()->isPet())
{
Pet *pet = ((Pet*)this);
if (pet->isControlled())
{
- Unit *owner = GetOwner();
+ Unit* owner = GetOwner();
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
{
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS);
@@ -14865,9 +14868,9 @@ void Unit::UpdateAuraForGroup(uint8 slot)
float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized)
{
if (!normalized || GetTypeId() != TYPEID_PLAYER)
- return float(GetAttackTime(attType))/1000.0f;
+ return float(GetAttackTime(attType)) / 1000.0f;
- Item *Weapon = this->ToPlayer()->GetWeaponForAttack(attType, true);
+ Item* Weapon = ToPlayer()->GetWeaponForAttack(attType, true);
if (!Weapon)
return 2.4f; // fist attack
@@ -14921,7 +14924,7 @@ void Unit::AddPetAura(PetAura const* petSpell)
return;
m_petAuras.insert(petSpell);
- if (Pet* pet = this->ToPlayer()->GetPet())
+ if (Pet* pet = ToPlayer()->GetPet())
pet->CastPetAura(petSpell);
}
@@ -14931,7 +14934,7 @@ void Unit::RemovePetAura(PetAura const* petSpell)
return;
m_petAuras.erase(petSpell);
- if (Pet* pet = this->ToPlayer()->GetPet())
+ if (Pet* pet = ToPlayer()->GetPet())
pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry()));
}
@@ -15000,7 +15003,7 @@ bool Unit::InitTamedPet(Pet * pet, uint8 level, uint32 spell_id)
bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const *& spellProcEvent)
{
- SpellEntry const *spellProto = aura->GetSpellProto();
+ SpellEntry const* spellProto = aura->GetSpellProto();
// Get proc Event Entry
spellProcEvent = sSpellMgr->GetSpellProcEvent(spellProto->Id);
@@ -15048,17 +15051,18 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry co
// Check if current equipment allows aura to proc
if (!isVictim && GetTypeId() == TYPEID_PLAYER)
{
+ Player* player = ToPlayer();
if (spellProto->EquippedItemClass == ITEM_CLASS_WEAPON)
{
- Item *item = NULL;
+ Item* item = NULL;
if (attType == BASE_ATTACK)
- item = this->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
+ item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
else if (attType == OFF_ATTACK)
- item = this->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
+ item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
else
- item = this->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED);
+ item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED);
- if (this->ToPlayer()->IsInFeralForm())
+ if (player->IsInFeralForm())
return false;
if (!item || item->IsBroken() || item->GetTemplate()->Class != ITEM_CLASS_WEAPON || !((1<<item->GetTemplate()->SubClass) & spellProto->EquippedItemSubClassMask))
@@ -15067,7 +15071,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry co
else if (spellProto->EquippedItemClass == ITEM_CLASS_ARMOR)
{
// Check if player is wearing shield
- Item *item = this->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
+ Item* item = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
if (!item || item->IsBroken() || item->GetTemplate()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetTemplate()->SubClass) & spellProto->EquippedItemSubClassMask))
return false;
}
@@ -15102,7 +15106,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry co
bool Unit::HandleAuraRaidProcFromChargeWithValue(AuraEffect *triggeredByAura)
{
// aura can be deleted at casts
- SpellEntry const *spellProto = triggeredByAura->GetSpellProto();
+ SpellEntry const* spellProto = triggeredByAura->GetSpellProto();
uint32 effIdx = triggeredByAura->GetEffIndex();
int32 heal = triggeredByAura->GetAmount();
uint64 caster_guid = triggeredByAura->GetCasterGUID();
@@ -15137,7 +15141,7 @@ bool Unit::HandleAuraRaidProcFromChargeWithValue(AuraEffect *triggeredByAura)
if (Unit* target = GetNextRandomRaidMemberOrPet(radius))
{
CastCustomSpell(target, spellProto->Id, &heal, NULL, NULL, true, NULL, triggeredByAura, caster_guid);
- if (Aura * aura = target->GetAura(spellProto->Id, caster->GetGUID()))
+ if (Aura* aura = target->GetAura(spellProto->Id, caster->GetGUID()))
aura->SetCharges(jumps);
}
}
@@ -15156,14 +15160,14 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura)
uint32 damageSpellId;
switch (spellProto->Id)
{
- case 57949: //shiver
+ case 57949: // shiver
damageSpellId = 57952;
//animationSpellId = 57951; dummy effects for jump spell have unknown use (see also 41637)
break;
- case 59978: //shiver
+ case 59978: // shiver
damageSpellId = 59979;
break;
- case 43593: //Cold Stare
+ case 43593: // Cold Stare
damageSpellId = 43594;
break;
default:
@@ -15197,7 +15201,7 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura)
if (Unit* target= GetNextRandomRaidMemberOrPet(radius))
{
CastSpell(target, spellProto, true, NULL, triggeredByAura, caster_guid);
- if (Aura * aura = target->GetAura(spellProto->Id, caster->GetGUID()))
+ if (Aura* aura = target->GetAura(spellProto->Id, caster->GetGUID()))
aura->SetCharges(jumps);
}
}
@@ -15215,7 +15219,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
return;
// Inform pets (if any) when player kills target)
- if (Player* plr = this->ToPlayer())
+ if (Player* plr = ToPlayer())
{
Pet* pet = plr->GetPet();
if (pet && pet->isAlive() && pet->isControlled())
@@ -15241,9 +15245,9 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
// call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop)
if (isRewardAllowed && player && player != victim)
{
- WorldPacket data(SMSG_PARTYKILLLOG, (8+8)); //send event PARTY_KILL
- data << uint64(player->GetGUID()); //player with killing blow
- data << uint64(victim->GetGUID()); //victim
+ WorldPacket data(SMSG_PARTYKILLLOG, (8+8)); // send event PARTY_KILL
+ data << uint64(player->GetGUID()); // player with killing blow
+ data << uint64(victim->GetGUID()); // victim
Player* looter = player;
@@ -15331,7 +15335,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
uint32 ressSpellId = victim->GetUInt32Value(PLAYER_SELF_RES_SPELL);
if (!ressSpellId)
ressSpellId = victim->ToPlayer()->GetResurrectionSpellId();
- //Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers)
+ // Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers)
victim->RemoveAllAurasOnDeath();
// restore for use at real death
victim->SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId);
@@ -15369,7 +15373,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
}
// Call KilledUnit for creatures
if (GetTypeId() == TYPEID_UNIT && IsAIEnabled)
- this->ToCreature()->AI()->KilledUnit(victim);
+ ToCreature()->AI()->KilledUnit(victim);
// last damage from non duel opponent or opponent controlled creature
if (plrVictim->duel)
@@ -15393,7 +15397,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
// Call KilledUnit for creatures, this needs to be called after the lootable flag is set
if (GetTypeId() == TYPEID_UNIT && IsAIEnabled)
- this->ToCreature()->AI()->KilledUnit(victim);
+ ToCreature()->AI()->KilledUnit(victim);
// Call creature just died function
if (creature->IsAIEnabled)
@@ -15433,11 +15437,11 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
// outdoor pvp things, do these after setting the death state, else the player activity notify won't work... doh...
// handle player kill only if not suicide (spirit of redemption for example)
if (player && this != victim)
- if (OutdoorPvP * pvp = player->GetOutdoorPvP())
+ if (OutdoorPvP* pvp = player->GetOutdoorPvP())
pvp->HandleKill(player, victim);
//if (pVictim->GetTypeId() == TYPEID_PLAYER)
- // if (OutdoorPvP * pvp = pVictim->ToPlayer()->GetOutdoorPvP())
+ // if (OutdoorPvP* pvp = pVictim->ToPlayer()->GetOutdoorPvP())
// pvp->HandlePlayerActivityChangedpVictim->ToPlayer();
// battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill)
@@ -15458,21 +15462,21 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
if (GetTypeId() == TYPEID_UNIT)
victim->ToPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, GetEntry());
else if (GetTypeId() == TYPEID_PLAYER && victim != this)
- victim->ToPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, this->ToPlayer()->GetTeam());
+ victim->ToPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, ToPlayer()->GetTeam());
}
- //Hook for OnPVPKill Event
+ // Hook for OnPVPKill Event
if (GetTypeId() == TYPEID_PLAYER)
{
if (victim->GetTypeId() == TYPEID_PLAYER)
{
- Player* killer = this->ToPlayer();
+ Player* killer = ToPlayer();
Player* killed = victim->ToPlayer();
sScriptMgr->OnPVPKill(killer, killed);
}
else if (victim->GetTypeId() == TYPEID_UNIT)
{
- Player* killer = this->ToPlayer();
+ Player* killer = ToPlayer();
Creature* killed = victim->ToCreature();
sScriptMgr->OnCreatureKill(killer, killed);
}
@@ -15481,7 +15485,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
{
if (victim->GetTypeId() == TYPEID_PLAYER)
{
- Creature* killer = this->ToCreature();
+ Creature* killer = ToCreature();
Player* killed = victim->ToPlayer();
sScriptMgr->OnPlayerKilledByCreature(killer, killed);
}
@@ -15570,7 +15574,7 @@ void Unit::SetStunned(bool apply)
// Creature specific
if (GetTypeId() != TYPEID_PLAYER)
- this->ToCreature()->StopMoving();
+ ToCreature()->StopMoving();
else
SetStandState(UNIT_STAND_STATE_STAND);
@@ -15587,7 +15591,7 @@ void Unit::SetStunned(bool apply)
SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
// don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface)
- Unit *pOwner = GetOwner();
+ Unit* pOwner = GetOwner();
if (!pOwner || (pOwner->GetTypeId() == TYPEID_PLAYER && !pOwner->ToPlayer()->IsMounted()))
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
@@ -15607,7 +15611,7 @@ void Unit::SetRooted(bool apply)
{
if (apply)
{
- if (m_rootTimes > 0) //blizzard internal check?
+ if (m_rootTimes > 0) // blizzard internal check?
m_rootTimes++;
// AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
@@ -15656,7 +15660,7 @@ void Unit::SetFeared(bool apply)
{
SetUInt64Value(UNIT_FIELD_TARGET, 0);
- Unit *caster = NULL;
+ Unit* caster = NULL;
Unit::AuraEffectList const& fearAuras = GetAuraEffectsByType(SPELL_AURA_MOD_FEAR);
if (!fearAuras.empty())
caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
@@ -15676,7 +15680,7 @@ void Unit::SetFeared(bool apply)
}
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->SetClientControl(this, !apply);
+ ToPlayer()->SetClientControl(this, !apply);
}
void Unit::SetConfused(bool apply)
@@ -15698,7 +15702,7 @@ void Unit::SetConfused(bool apply)
}
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->SetClientControl(this, !apply);
+ ToPlayer()->SetClientControl(this, !apply);
}
bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp)
@@ -15724,7 +15728,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
//if (HasUnitState(UNIT_STAT_UNATTACKABLE))
// return false;
- if (GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->GetTransport())
+ if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetTransport())
{
sLog->outCrash("Unit::SetCharmedBy: Player on transport is trying to charm %u (GUID %u)", GetEntry(), GetGUIDLow());
return false;
@@ -15738,7 +15742,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
}
CastStop();
- CombatStop(); //TODO: CombatStop(true) may cause crash (interrupt spells)
+ CombatStop(); // TODO: CombatStop(true) may cause crash (interrupt spells)
DeleteThreatList();
// Charmer stop charming
@@ -15751,8 +15755,8 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
// Charmed stop charming
if (GetTypeId() == TYPEID_PLAYER)
{
- this->ToPlayer()->StopCastingCharm();
- this->ToPlayer()->StopCastingBindSight();
+ ToPlayer()->StopCastingCharm();
+ ToPlayer()->StopCastingBindSight();
}
// StopCastingCharm may remove a possessed pet?
@@ -15776,14 +15780,15 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
if (GetTypeId() == TYPEID_UNIT)
{
- this->ToCreature()->AI()->OnCharmed(true);
+ ToCreature()->AI()->OnCharmed(true);
GetMotionMaster()->MoveIdle();
}
else
{
- if (this->ToPlayer()->isAFK())
- this->ToPlayer()->ToggleAFK();
- this->ToPlayer()->SetClientControl(this, 0);
+ Player* plr = ToPlayer();
+ if (plr->isAFK())
+ plr->ToggleAFK();
+ plr->SetClientControl(this, 0);
}
// charm is set by aura, and aura effect remove handler was called during apply handler execution
@@ -15822,17 +15827,17 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
case CHARM_TYPE_CHARM:
if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
{
- CreatureTemplate const *cinfo = this->ToCreature()->GetCreatureInfo();
+ CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo();
if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
{
- //to prevent client crash
+ // to prevent client crash
SetByteValue(UNIT_FIELD_BYTES_0, 1, (uint8)CLASS_MAGE);
- //just to enable stat window
+ // just to enable stat window
if (GetCharmInfo())
GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
- //if charmed two demons the same session, the 2nd gets the 1st one's name
+ // if charmed two demons the same session, the 2nd gets the 1st one's name
SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped
}
}
@@ -15870,7 +15875,7 @@ void Unit::RemoveCharmedBy(Unit *charmer)
type = CHARM_TYPE_CHARM;
CastStop();
- CombatStop(); //TODO: CombatStop(true) may cause crash (interrupt spells)
+ CombatStop(); // TODO: CombatStop(true) may cause crash (interrupt spells)
getHostileRefManager().deleteReferences();
DeleteThreatList();
Map* pMap = GetMap();
@@ -15884,20 +15889,20 @@ void Unit::RemoveCharmedBy(Unit *charmer)
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
}
- if (GetTypeId() == TYPEID_UNIT)
+ if (Creature* creature = ToCreature())
{
- this->ToCreature()->AI()->OnCharmed(false);
+ creature->AI()->OnCharmed(false);
- if (type != CHARM_TYPE_VEHICLE)//Vehicles' AI is never modified
+ if (type != CHARM_TYPE_VEHICLE) // Vehicles' AI is never modified
{
- this->ToCreature()->AIM_Initialize();
+ creature->AIM_Initialize();
- if (this->ToCreature()->AI() && charmer && charmer->isAlive())
- this->ToCreature()->AI()->AttackStart(charmer);
+ if (creature->AI() && charmer && charmer->isAlive())
+ creature->AI()->AttackStart(charmer);
}
}
else
- this->ToPlayer()->SetClientControl(this, 1);
+ ToPlayer()->SetClientControl(this, 1);
// If charmer still exists
if (!charmer)
@@ -15926,7 +15931,7 @@ void Unit::RemoveCharmedBy(Unit *charmer)
case CHARM_TYPE_CHARM:
if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
{
- CreatureTemplate const *cinfo = this->ToCreature()->GetCreatureInfo();
+ CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo();
if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
{
SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class));
@@ -15943,17 +15948,17 @@ void Unit::RemoveCharmedBy(Unit *charmer)
}
}
- //a guardian should always have charminfo
+ // a guardian should always have charminfo
if (charmer->GetTypeId() == TYPEID_PLAYER && this != charmer->GetFirstControlled())
charmer->ToPlayer()->SendRemoveControlBar();
- else if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && !this->ToCreature()->isGuardian()))
+ else if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && !ToCreature()->isGuardian()))
DeleteCharmInfo();
}
void Unit::RestoreFaction()
{
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->setFactionForRace(getRace());
+ ToPlayer()->setFactionForRace(getRace());
else
{
if (HasUnitTypeMask(UNIT_MASK_MINION))
@@ -15965,9 +15970,9 @@ void Unit::RestoreFaction()
}
}
- if (CreatureTemplate const *cinfo = this->ToCreature()->GetCreatureInfo()) // normal creature
+ if (CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo()) // normal creature
{
- FactionTemplateEntry const *faction = getFactionTemplateEntry();
+ FactionTemplateEntry const* faction = getFactionTemplateEntry();
setFaction((faction && faction->friendlyMask & 0x004) ? cinfo->faction_H : cinfo->faction_A);
}
}
@@ -15975,7 +15980,7 @@ void Unit::RestoreFaction()
bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry)
{
- VehicleEntry const *vehInfo = sVehicleStore.LookupEntry(id);
+ VehicleEntry const* vehInfo = sVehicleStore.LookupEntry(id);
if (!vehInfo)
return false;
@@ -16059,11 +16064,11 @@ bool Unit::IsInRaidWith(Unit const *unit) const
void Unit::GetRaidMember(std::list<Unit*> &nearMembers, float radius)
{
- Player *owner = GetCharmerOrOwnerPlayerOrPlayerItself();
+ Player* owner = GetCharmerOrOwnerPlayerOrPlayerItself();
if (!owner)
return;
- Group *pGroup = owner->GetGroup();
+ Group* pGroup = owner->GetGroup();
if (pGroup)
{
for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
@@ -16093,8 +16098,8 @@ void Unit::GetRaidMember(std::list<Unit*> &nearMembers, float radius)
void Unit::GetPartyMemberInDist(std::list<Unit*> &TagUnitMap, float radius)
{
- Unit *owner = GetCharmerOrOwnerOrSelf();
- Group *pGroup = NULL;
+ Unit* owner = GetCharmerOrOwnerOrSelf();
+ Group* pGroup = NULL;
if (owner->GetTypeId() == TYPEID_PLAYER)
pGroup = owner->ToPlayer()->GetGroup();
@@ -16130,8 +16135,8 @@ void Unit::GetPartyMemberInDist(std::list<Unit*> &TagUnitMap, float radius)
void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap)
{
- Unit *owner = GetCharmerOrOwnerOrSelf();
- Group *pGroup = NULL;
+ Unit* owner = GetCharmerOrOwnerOrSelf();
+ Group* pGroup = NULL;
if (owner->GetTypeId() == TYPEID_PLAYER)
pGroup = owner->ToPlayer()->GetGroup();
@@ -16170,7 +16175,7 @@ Aura * Unit::AddAura(uint32 spellId, Unit* target)
if (!target)
return NULL;
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
return NULL;
@@ -16196,7 +16201,7 @@ Aura * Unit::AddAura(SpellEntry const *spellInfo, uint8 effMask, Unit* target)
effMask &= ~(1<<i);
}
- if (Aura * aura = Aura::TryRefreshStackOrCreate(spellInfo, effMask, target, this))
+ if (Aura* aura = Aura::TryRefreshStackOrCreate(spellInfo, effMask, target, this))
{
aura->ApplyForTargets();
return aura;
@@ -16296,7 +16301,7 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType,
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
if (spellId)
{
- if (Player *modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, HitChance);
}
@@ -16618,13 +16623,13 @@ uint32 Unit::GetModelForTotem(PlayerTotemType totemType)
{
switch (totemType)
{
- case SUMMON_TYPE_TOTEM_FIRE: //fire
+ case SUMMON_TYPE_TOTEM_FIRE: // fire
return 30758;
- case SUMMON_TYPE_TOTEM_EARTH: //earth
+ case SUMMON_TYPE_TOTEM_EARTH: // earth
return 30757;
- case SUMMON_TYPE_TOTEM_WATER: //water
+ case SUMMON_TYPE_TOTEM_WATER: // water
return 30759;
- case SUMMON_TYPE_TOTEM_AIR: //air
+ case SUMMON_TYPE_TOTEM_AIR: // air
return 30756;
}
break;
@@ -16633,13 +16638,13 @@ uint32 Unit::GetModelForTotem(PlayerTotemType totemType)
{
switch (totemType)
{
- case SUMMON_TYPE_TOTEM_FIRE: //fire
+ case SUMMON_TYPE_TOTEM_FIRE: // fire
return 30754;
- case SUMMON_TYPE_TOTEM_EARTH: //earth
+ case SUMMON_TYPE_TOTEM_EARTH: // earth
return 30753;
- case SUMMON_TYPE_TOTEM_WATER: //water
+ case SUMMON_TYPE_TOTEM_WATER: // water
return 30755;
- case SUMMON_TYPE_TOTEM_AIR: //air
+ case SUMMON_TYPE_TOTEM_AIR: // air
return 30736;
}
break;
@@ -16648,13 +16653,13 @@ uint32 Unit::GetModelForTotem(PlayerTotemType totemType)
{
switch (totemType)
{
- case SUMMON_TYPE_TOTEM_FIRE: //fire
+ case SUMMON_TYPE_TOTEM_FIRE: // fire
return 30762;
- case SUMMON_TYPE_TOTEM_EARTH: //earth
+ case SUMMON_TYPE_TOTEM_EARTH: // earth
return 30761;
- case SUMMON_TYPE_TOTEM_WATER: //water
+ case SUMMON_TYPE_TOTEM_WATER: // water
return 30763;
- case SUMMON_TYPE_TOTEM_AIR: //air
+ case SUMMON_TYPE_TOTEM_AIR: // air
return 30760;
}
break;
@@ -16663,13 +16668,13 @@ uint32 Unit::GetModelForTotem(PlayerTotemType totemType)
{
switch (totemType)
{
- case SUMMON_TYPE_TOTEM_FIRE: //fire
+ case SUMMON_TYPE_TOTEM_FIRE: // fire
return 4589;
- case SUMMON_TYPE_TOTEM_EARTH: //earth
+ case SUMMON_TYPE_TOTEM_EARTH: // earth
return 4588;
- case SUMMON_TYPE_TOTEM_WATER: //water
+ case SUMMON_TYPE_TOTEM_WATER: // water
return 4587;
- case SUMMON_TYPE_TOTEM_AIR: //air
+ case SUMMON_TYPE_TOTEM_AIR: // air
return 4590;
}
break;
@@ -16678,13 +16683,13 @@ uint32 Unit::GetModelForTotem(PlayerTotemType totemType)
{
switch (totemType)
{
- case SUMMON_TYPE_TOTEM_FIRE: //fire
+ case SUMMON_TYPE_TOTEM_FIRE: // fire
return 19074;
- case SUMMON_TYPE_TOTEM_EARTH: //earth
+ case SUMMON_TYPE_TOTEM_EARTH: // earth
return 19073;
- case SUMMON_TYPE_TOTEM_WATER: //water
+ case SUMMON_TYPE_TOTEM_WATER: // water
return 19075;
- case SUMMON_TYPE_TOTEM_AIR: //air
+ case SUMMON_TYPE_TOTEM_AIR: // air
return 19071;
}
break;
@@ -16711,7 +16716,7 @@ void Unit::JumpTo(float speedXY, float speedZ, bool forward)
data << float(speedXY); // Horizontal speed
data << float(-speedZ); // Z Movement speed (vertical)
- this->ToPlayer()->GetSession()->SendPacket(&data);
+ ToPlayer()->GetSession()->SendPacket(&data);
}
}
@@ -16727,9 +16732,9 @@ bool Unit::CheckPlayerCondition(Player* pPlayer)
{
switch(GetEntry())
{
- case 35644: //Argent Warhorse
- case 36558: //Argent Battleworg
- if (!pPlayer->HasItemOrGemWithIdEquipped(46106, 1)) //Check item Argent Lance
+ case 35644: // Argent Warhorse
+ case 36558: // Argent Battleworg
+ if (!pPlayer->HasItemOrGemWithIdEquipped(46106, 1)) // Check item Argent Lance
return false;
default:
return true;
@@ -16792,8 +16797,9 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
}
}
- if (this->ToCreature() && this->ToCreature()->IsAIEnabled)
- this->ToCreature()->AI()->DoAction(EVENT_SPELLCLICK);
+ Creature* creature = ToCreature();
+ if (creature && creature->IsAIEnabled)
+ creature->AI()->DoAction(EVENT_SPELLCLICK);
return success;
}
@@ -16911,7 +16917,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
AddUnitState(UNIT_STAT_MOVE);
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->SetFallInformation(0, GetPositionZ());
+ ToPlayer()->SetFallInformation(0, GetPositionZ());
else if (HasUnitMovementFlag(MOVEMENTFLAG_ROOT))
{
WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8);
@@ -17029,7 +17035,7 @@ void Unit::SetFlying(bool apply)
void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/)
{
if (GetTypeId() == TYPEID_PLAYER)
- this->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));
+ 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));
else
{
// FIXME: this interrupts spell visual
@@ -17059,9 +17065,9 @@ bool Unit::SetPosition(float x, float y, float z, float orientation, bool telepo
// move and update visible state if need
if (GetTypeId() == TYPEID_PLAYER)
- GetMap()->PlayerRelocation((Player*)this, x, y, z, orientation);
+ GetMap()->PlayerRelocation(ToPlayer(), x, y, z, orientation);
else
- GetMap()->CreatureRelocation(this->ToCreature(), x, y, z, orientation);
+ GetMap()->CreatureRelocation(ToCreature(), x, y, z, orientation);
}
else if (turn)
SetOrientation(orientation);
@@ -17084,7 +17090,7 @@ void Unit::SendThreatListUpdate()
for (std::list<HostileReference*>::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr)
{
data.appendPackGUID((*itr)->getUnitGuid());
- data << uint32((*itr)->getThreat()*100);
+ data << uint32((*itr)->getThreat() * 100);
}
SendMessageToSet(&data, false);
}
@@ -17169,7 +17175,7 @@ void Unit::StopAttackFaction(uint32 faction_id)
// melee and ranged forced attack cancel
if (GetTypeId() == TYPEID_PLAYER)
- this->ToPlayer()->SendAttackSwingCancelAttack();
+ ToPlayer()->SendAttackSwingCancelAttack();
}
}
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 2ca01452799..f776e9e6228 100755
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -313,7 +313,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNULL, //258 SPELL_AURA_MOD_SPELL_VISUAL
&AuraEffect::HandleNoImmediateEffect, //259 SPELL_AURA_MOD_HOT_PCT implemented in Unit::SpellHealingBonus
&AuraEffect::HandleNoImmediateEffect, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
- &AuraEffect::HandlePhase, //261 SPELL_AURA_PHASE undetactable invisibility? implemented in Unit::isVisibleForOrDetect
+ &AuraEffect::HandlePhase, //261 SPELL_AURA_PHASE
&AuraEffect::HandleNoImmediateEffect, //262 SPELL_AURA_ABILITY_IGNORE_AURASTATE implemented in spell::cancast
&AuraEffect::HandleAuraAllowOnlyAbility, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
&AuraEffect::HandleUnused, //264 unused (3.2.0)
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 5428c606035..caa3d8bea72 100755
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -628,7 +628,7 @@ class AuraScript : public _SpellScript
void SetStackAmount(uint8 num);
bool ModStackAmount(int32 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
- // passive - "working in background", not saved, not removed by immonities, not seen by player
+ // passive - "working in background", not saved, not removed by immunities, not seen by player
bool IsPassive() const;
// death persistent - not removed on death
bool IsDeathPersistent() const;