aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaximius <none@none>2009-11-17 23:02:37 -0800
committermaximius <none@none>2009-11-17 23:02:37 -0800
commitd5a13769d18b32da5fc57f0185778b7b570a307f (patch)
treea3362a278dbd8dc05cf0240c7fac8c478cc55ba6
parented38413906e307e93ba27aeb98f7b939ce610da4 (diff)
*Some cleanup.
--HG-- branch : trunk
-rw-r--r--src/game/Unit.cpp144
1 files changed, 69 insertions, 75 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index bd5e96c9adc..f50135bb4c8 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -576,7 +576,7 @@ void Unit::RemoveAurasWithFamily(uint32 family, uint32 familyFlag1, uint32 famil
void Unit::RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveMode removemode, uint32 except)
{
- for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); )
+ for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); =)
{
if (!except || iter->second->GetId() != except)
{
@@ -616,7 +616,7 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
{
if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())
{
- if(absorb)
+ if (absorb)
absorb += damage;
damage = 0;
return;
@@ -627,9 +627,9 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
if(pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer())
{
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
- if(area && area->IsSanctuary()) //sanctuary
+ if (area && area->IsSanctuary()) //sanctuary
{
- if(absorb)
+ if (absorb)
absorb += damage;
damage = 0;
}
@@ -1168,7 +1168,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
case SPELL_DAMAGE_CLASS_MELEE:
{
// Physical Damage
- if ( damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL )
+ if (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL)
{
// Get blocked status
blocked = isSpellBlocked(pVictim, spellInfo, attackType);
@@ -1186,7 +1186,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
damage += crit_bonus;
// Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE
- int32 critPctDamageMod=0;
+ int32 critPctDamageMod = 0;
if(attackType == RANGED_ATTACK)
critPctDamageMod += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE);
else
@@ -1197,8 +1197,8 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
// Increase crit damage from SPELL_AURA_MOD_CRIT_PERCENT_VERSUS
critPctDamageMod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, crTypeMask);
- if (critPctDamageMod!=0)
- damage = int32((damage) * float((100.0f + critPctDamageMod)/100.0f));
+ if (critPctDamageMod != 0)
+ damage = int32(damage * float((100.0f + critPctDamageMod)/100.0f));
// Resilience - reduce crit damage
if (pVictim->GetTypeId() == TYPEID_PLAYER)
@@ -1213,7 +1213,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
damageInfo->blocked+=damageInfo->blocked;
if (damage < damageInfo->blocked)
damageInfo->blocked = damage;
- damage-=damageInfo->blocked;
+ damage -= damageInfo->blocked;
}
}
break;
@@ -1234,7 +1234,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
break;
}
- if( damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL )
+ if (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL)
damage = CalcArmorReducedDamage(pVictim, damage, spellInfo, attackType);
// Calculate absorb resist
@@ -1302,9 +1302,9 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->procEx = PROC_EX_NONE;
damageInfo->hitOutCome = MELEE_HIT_EVADE;
- if(!pVictim)
+ if (!pVictim)
return;
- if(!this->isAlive() || !pVictim->isAlive())
+ if (!isAlive() || !pVictim->isAlive())
return;
// Select HitInfo/procAttacker/procVictim flag based on attack type
@@ -1335,12 +1335,12 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->HitInfo |= HITINFO_NORMALSWING;
damageInfo->TargetState = VICTIMSTATE_IS_IMMUNE;
- damageInfo->procEx |=PROC_EX_IMMUNE;
+ damageInfo->procEx |= PROC_EX_IMMUNE;
damageInfo->damage = 0;
damageInfo->cleanDamage = 0;
return;
}
- damage += CalculateDamage (damageInfo->attackType, false, true);
+ damage += CalculateDamage(damageInfo->attackType, false, true);
// Add melee damage bonus
MeleeDamageBonus(damageInfo->target, &damage, damageInfo->attackType);
// Calculate armor reduction
@@ -1356,7 +1356,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
if (damageInfo->hitOutCome == MELEE_HIT_DODGE) damageInfo->hitOutCome = MELEE_HIT_MISS;
}
- switch(damageInfo->hitOutCome)
+ switch (damageInfo->hitOutCome)
{
case MELEE_HIT_EVADE:
{
@@ -1373,8 +1373,8 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->HitInfo |= HITINFO_MISS;
damageInfo->TargetState = VICTIMSTATE_NORMAL;
- damageInfo->procEx|=PROC_EX_MISS;
- damageInfo->damage = 0;
+ damageInfo->procEx |= PROC_EX_MISS;
+ damageInfo->damage = 0;
damageInfo->cleanDamage = 0;
break;
}
@@ -1387,12 +1387,12 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->HitInfo |= HITINFO_CRITICALHIT;
damageInfo->TargetState = VICTIMSTATE_NORMAL;
- damageInfo->procEx|=PROC_EX_CRITICAL_HIT;
+ damageInfo->procEx |= PROC_EX_CRITICAL_HIT;
// Crit bonus calc
damageInfo->damage += damageInfo->damage;
- int32 mod=0;
+ int32 mod = 0;
// Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE
- if(damageInfo->attackType == RANGED_ATTACK)
+ if (damageInfo->attackType == RANGED_ATTACK)
mod += damageInfo->target->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE);
else
{
@@ -1404,7 +1404,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
// Increase crit damage from SPELL_AURA_MOD_CRIT_PERCENT_VERSUS
mod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, crTypeMask);
- if (mod!=0)
+ if (mod != 0)
damageInfo->damage = int32((damageInfo->damage) * float((100.0f + mod)/100.0f));
// Resilience - reduce crit damage
@@ -1418,22 +1418,22 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
}
case MELEE_HIT_PARRY:
damageInfo->TargetState = VICTIMSTATE_PARRY;
- damageInfo->procEx|=PROC_EX_PARRY;
+ damageInfo->procEx |= PROC_EX_PARRY;
damageInfo->cleanDamage += damageInfo->damage;
damageInfo->damage = 0;
break;
case MELEE_HIT_DODGE:
damageInfo->TargetState = VICTIMSTATE_DODGE;
- damageInfo->procEx|=PROC_EX_DODGE;
+ damageInfo->procEx |= PROC_EX_DODGE;
damageInfo->cleanDamage += damageInfo->damage;
damageInfo->damage = 0;
break;
case MELEE_HIT_BLOCK:
{
damageInfo->TargetState = VICTIMSTATE_NORMAL;
- damageInfo->HitInfo |= HITINFO_BLOCK;
- damageInfo->procEx|=PROC_EX_BLOCK;
+ damageInfo->HitInfo |= HITINFO_BLOCK;
+ damageInfo->procEx |= PROC_EX_BLOCK;
damageInfo->blocked_amount = damageInfo->target->GetShieldBlockValue();
//double blocked amount if block is critical
if (isBlockCritical())
@@ -1444,7 +1444,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->blocked_amount = damageInfo->damage;
}
else
- damageInfo->procEx |= PROC_EX_NORMAL_HIT;
+ damageInfo->procEx |= PROC_EX_NORMAL_HIT;
damageInfo->damage -= damageInfo->blocked_amount;
damageInfo->cleanDamage += damageInfo->blocked_amount;
break;
@@ -1453,25 +1453,24 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
{
damageInfo->HitInfo |= HITINFO_GLANCING;
damageInfo->TargetState = VICTIMSTATE_NORMAL;
- damageInfo->procEx|=PROC_EX_NORMAL_HIT;
+ damageInfo->procEx |= PROC_EX_NORMAL_HIT;
int32 leveldif = int32(pVictim->getLevel()) - int32(getLevel());
if (leveldif > 3) leveldif = 3;
float reducePercent = 1 - leveldif * 0.1f;
- damageInfo->cleanDamage += damageInfo->damage-uint32(reducePercent * damageInfo->damage);
- damageInfo->damage = uint32(reducePercent * damageInfo->damage);
+ damageInfo->cleanDamage += damageInfo->damage-uint32(reducePercent * damageInfo->damage);
+ damageInfo->damage = uint32(reducePercent * damageInfo->damage);
break;
}
case MELEE_HIT_CRUSHING:
{
damageInfo->HitInfo |= HITINFO_CRUSHING;
damageInfo->TargetState = VICTIMSTATE_NORMAL;
- damageInfo->procEx|=PROC_EX_NORMAL_HIT;
+ damageInfo->procEx |= PROC_EX_NORMAL_HIT;
// 150% normal damage
damageInfo->damage += (damageInfo->damage / 2);
break;
}
default:
-
break;
}
@@ -1481,15 +1480,14 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE;
// Calculate absorb & resists
CalcAbsorbResist(damageInfo->target, SpellSchoolMask(damageInfo->damageSchoolMask), DIRECT_DAMAGE, damageInfo->damage, &damageInfo->absorb, &damageInfo->resist);
- damageInfo->damage-=damageInfo->absorb + damageInfo->resist;
+ damageInfo->damage -= damageInfo->absorb + damageInfo->resist;
if (damageInfo->absorb)
{
- damageInfo->HitInfo|=HITINFO_ABSORB;
- damageInfo->procEx|=PROC_EX_ABSORB;
+ damageInfo->HitInfo |= HITINFO_ABSORB;
+ damageInfo->procEx |= PROC_EX_ABSORB;
}
if (damageInfo->resist)
- damageInfo->HitInfo|=HITINFO_RESIST;
-
+ damageInfo->HitInfo |= HITINFO_RESIST;
}
else // Impossible get negative result but....
damageInfo->damage = 0;
@@ -1497,7 +1495,8 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
{
- if (damageInfo==0) return;
+ if (!damageInfo)
+ return;
Unit *pVictim = damageInfo->target;
if(!pVictim)
@@ -1508,17 +1507,17 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
//You don't lose health from damage taken from another player while in a sanctuary
//You still see it in the combat log though
- if(pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer())
+ if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer())
{
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
- if(area && area->IsSanctuary()) // sanctuary
+ if (area && area->IsSanctuary()) // sanctuary
return;
}
// Hmmmm dont like this emotes client must by self do all animations
if (damageInfo->HitInfo&HITINFO_CRITICALHIT)
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL);
- if(damageInfo->blocked_amount && damageInfo->TargetState!=VICTIMSTATE_BLOCKS)
+ if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS)
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD);
if(damageInfo->TargetState == VICTIMSTATE_PARRY)
@@ -2247,7 +2246,7 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex
CalcDamageInfo damageInfo;
CalculateMeleeDamage(pVictim, 0, &damageInfo, attType);
// Send log damage message to client
- DealDamageMods(pVictim,damageInfo.damage,&damageInfo.absorb);
+ DealDamageMods(pVictim, damageInfo.damage, &damageInfo.absorb);
SendAttackStateUpdate(&damageInfo);
ProcDamageAndSpell(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, damageInfo.procEx, damageInfo.damage, damageInfo.attackType);
@@ -2453,7 +2452,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
return MELEE_HIT_NORMAL;
}
-uint32 Unit::CalculateDamage (WeaponAttackType attType, bool normalized, bool addTotalPct)
+uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct)
{
float min_damage, max_damage;
@@ -2915,7 +2914,7 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool
if (reflectchance > 0 && roll_chance_i(reflectchance))
{
// Start triggers for remove charges if need (trigger only for victim, and mark as active spell)
- ProcDamageAndSpell(pVictim, PROC_FLAG_NONE, PROC_FLAG_TAKEN_NEGATIVE_MAGIC_SPELL, PROC_EX_REFLECT , 1, BASE_ATTACK, spell);
+ ProcDamageAndSpell(pVictim, PROC_FLAG_NONE, PROC_FLAG_TAKEN_NEGATIVE_MAGIC_SPELL, PROC_EX_REFLECT, 1, BASE_ATTACK, spell);
return SPELL_MISS_REFLECT;
}
}
@@ -4598,11 +4597,11 @@ void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVic
{
// Not much to do if no flags are set.
if (procAttacker)
- ProcDamageAndSpellFor(false,pVictim,procAttacker, procExtra,attType, procSpell, amount, procAura);
+ ProcDamageAndSpellFor(false, pVictim,procAttacker, procExtra,attType, procSpell, amount, procAura);
// Now go on with a victim's events'n'auras
// Not much to do if no flags are set or there is no victim
if(pVictim && pVictim->isAlive() && procVictim)
- pVictim->ProcDamageAndSpellFor(true,this,procVictim, procExtra, attType, procSpell, amount, procAura);
+ pVictim->ProcDamageAndSpellFor(true, this, procVictim, procExtra, attType, procSpell, amount, procAura);
}
void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo)
@@ -4766,7 +4765,7 @@ bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
case 33735:
{
target = SelectNearbyTarget();
- if(!target || target == pVictim)
+ if (!target || target == pVictim)
return false;
basepoints0 = damage;
triggered_spell_id = 22482;
@@ -4778,30 +4777,30 @@ bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
}
// processed charge only counting case
- if(!triggered_spell_id)
+ if (!triggered_spell_id)
return true;
SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id);
- if(!triggerEntry)
+ if (!triggerEntry)
{
sLog.outError("Unit::HandleHasteAuraProc: Spell %u have not existed triggered spell %u",hasteSpell->Id,triggered_spell_id);
return false;
}
// default case
- if((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target!=this && !target->isAlive()))
+ if ((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target!=this && !target->isAlive()))
return false;
- if( cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id))
+ if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id))
return false;
- if(basepoints0)
+ if (basepoints0)
CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura);
else
CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura);
- if( cooldown && GetTypeId() == TYPEID_PLAYER )
+ if (cooldown && GetTypeId() == TYPEID_PLAYER)
((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown);
return true;
@@ -9156,21 +9155,15 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// ..done
// Pet damage
- if( GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet() )
+ if (GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet())
DoneTotalMod *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank);
AuraEffectList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
- {
- if( ((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto)) &&
- (*i)->GetSpellProto()->EquippedItemClass == -1 &&
- // -1 == any item class (not wand then)
- (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0 )
- // 0 == any inventory type (not wand then)
- {
+ if(((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto)) &&
+ (*i)->GetSpellProto()->EquippedItemClass == -1 && // -1 == any item class (not wand)
+ (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0) // 0 == any inventory type (not wand)
DoneTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f;
- }
- }
uint32 creatureTypeMask = pVictim->GetCreatureTypeMask();
// Add flat bonus from spell damage versus
@@ -9182,7 +9175,8 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// done scripted mod (take it from owner)
Unit *owner = GetOwner();
- if (!owner) owner = this;
+ if (!owner)
+ owner = this;
AuraEffectList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
{
@@ -9246,7 +9240,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
case 5148: // Idol of the Shooting Star
case 6008: // Increased Lightning Damage / Totem of Hex
{
- DoneTotal+=(*i)->GetAmount();
+ DoneTotal += (*i)->GetAmount();
break;
}
// Tundra Stalker
@@ -9441,14 +9435,14 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
{
coeff = bonus->dot_damage;
if (bonus->ap_dot_bonus > 0)
- DoneTotal+=bonus->ap_dot_bonus * stack * ApCoeffMod * GetTotalAttackPowerValue(
+ DoneTotal += bonus->ap_dot_bonus * stack * ApCoeffMod * GetTotalAttackPowerValue(
(IsRangedWeaponSpell(spellProto) && spellProto->DmgClass !=SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK);
}
else
{
coeff = bonus->direct_damage;
if (bonus->ap_bonus > 0)
- DoneTotal+=bonus->ap_bonus * stack * ApCoeffMod * GetTotalAttackPowerValue(
+ DoneTotal += bonus->ap_bonus * stack * ApCoeffMod * GetTotalAttackPowerValue(
(IsRangedWeaponSpell(spellProto) && spellProto->DmgClass !=SPELL_DAMAGE_CLASS_MELEE)? RANGED_ATTACK : BASE_ATTACK);
}
}
@@ -9523,7 +9517,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
float tmpDamage = (pdamage + DoneTotal) * DoneTotalMod;
// apply spellmod to Done damage (flat and pct)
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage);
tmpDamage = (tmpDamage + TakenTotal) * TakenTotalMod;
@@ -10280,12 +10274,12 @@ bool Unit::IsDamageToThreatSpell(SpellEntry const * spellInfo) const
return false;
}
-void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attType, SpellEntry const *spellProto)
+void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType attType, SpellEntry const *spellProto)
{
- if(!pVictim)
+ if (!pVictim)
return;
- if(*pdamage == 0)
+ if (*pdamage == 0)
return;
uint32 creatureTypeMask = pVictim->GetCreatureTypeMask();
@@ -10326,12 +10320,12 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT
APbonus += (*i)->GetAmount();
}
- if (APbonus!=0) // Can be negative
+ if (APbonus != 0) // Can be negative
{
bool normalized = false;
if(spellProto)
{
- for (uint8 i = 0; i<MAX_SPELL_EFFECTS; i++)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellProto->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
{
@@ -10465,7 +10459,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT
tmpDamage = (tmpDamage + TakenFlatBenefit)*TakenTotalMod;
// bonus result can be negative
- *pdamage = tmpDamage > 0 ? uint32(tmpDamage) : 0;
+ *pdamage = uint32(std::max(tmpDamage, 0.0f));
}
void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
@@ -12711,7 +12705,7 @@ uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missC
return procEx;
}
-void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage , SpellEntry const * procAura)
+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 && ((Player*)this)->GetSession()->PlayerLoading())
@@ -13813,7 +13807,7 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
// if talent known but not triggered (check priest class for speedup check)
bool SpiritOfRedemption = false;
- if(pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->getClass()==CLASS_PRIEST)
+ if(pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->getClass() == CLASS_PRIEST)
{
AuraEffectList const& vDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY);
for (AuraEffectList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr)