Skip to content

Instantly share code, notes, and snippets.

@neo-mat
Created February 28, 2012 15:51
Show Gist options
  • Save neo-mat/1933284 to your computer and use it in GitHub Desktop.
Save neo-mat/1933284 to your computer and use it in GitHub Desktop.
cut it!
diff --git a/src/arcemu-world/Object.cpp b/src/arcemu-world/Object.cpp
index 4106cfa..8bbe284 100644
--- a/src/arcemu-world/Object.cpp
+++ b/src/arcemu-world/Object.cpp
@@ -1627,12 +1627,12 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
if(spellInfo == NULL)
return;
- if(this->IsPlayer() && ! TO_PLAYER(this)->canCast(spellInfo))
+ if(this->IsPlayer() && ! TO< Player* >(this)->canCast(spellInfo))
return;
//==========================================================================================
//==============================Variables Initialization====================================
//==========================================================================================
- float res = float(damage);
+ float res = static_cast< float >(damage);
bool critical = false;
uint32 aproc = PROC_ON_ANY_HOSTILE_ACTION; /*| PROC_ON_SPELL_HIT;*/
@@ -1673,7 +1673,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
caster->RemoveAurasByInterruptFlag(AURA_INTERRUPT_ON_START_ATTACK);
- res += static_cast< float >(caster->GetSpellDmgBonus(pVictim, spellInfo, damage, false));
+ res += static_cast< float >( caster->GetSpellDmgBonus(pVictim, spellInfo, damage, false) );
if(res < 0.0f)
res = 0.0f;
@@ -1726,7 +1726,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
if( this->IsUnit() )
res += TO< Unit* >(this)->CalcSpellDamageReduction(pVictim, spellInfo, res);
//------------------------------absorption--------------------------------------------------
- uint32 ress = (uint32)res;
+ uint32 ress = static_cast< uint32 >(res);
uint32 abs_dmg = pVictim->AbsorbDamage(spellInfo->School, &ress);
uint32 ms_abs_dmg = pVictim->ManaShieldAbsorb(ress);
if(ms_abs_dmg)
@@ -1743,7 +1743,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
vproc |= PROC_ON_ABSORB;
// Incanter's Absorption
- if(pVictim->IsPlayer() && pVictim->HasAurasWithNameHash(SPELL_HASH_INCANTER_S_ABSORPTION))
+ if( pVictim->IsPlayer() && pVictim->HasAurasWithNameHash(SPELL_HASH_INCANTER_S_ABSORPTION) )
{
float pctmod = 0.0f;
Player* pl = TO< Player* >(pVictim);
@@ -1754,8 +1754,8 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
else if(pl->HasAura(44396))
pctmod = 0.15f;
- uint32 hp = static_cast<uint32>(0.05f * pl->GetUInt32Value(UNIT_FIELD_MAXHEALTH));
- uint32 spellpower = static_cast<uint32>(pctmod * pl->GetPosDamageDoneMod(SCHOOL_NORMAL));
+ uint32 hp = static_cast< uint32 >( 0.05f * pl->GetUInt32Value(UNIT_FIELD_MAXHEALTH) );
+ uint32 spellpower = static_cast< uint32 >( pctmod * pl->GetPosDamageDoneMod(SCHOOL_NORMAL) );
if(spellpower > hp)
spellpower = hp;
@@ -1773,7 +1773,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
if(ress < 0) ress = 0;
- res = (float)ress;
+ res = static_cast< float >(ress);
dealdamage dmg;
dmg.school_type = spellInfo->School;
dmg.full_damage = ress;
@@ -1789,12 +1789,12 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
if((int32)dmg.resisted_damage > dmg.full_damage)
res = 0;
else
- res = float(dmg.full_damage - dmg.resisted_damage);
+ res = static_cast< float >(dmg.full_damage - dmg.resisted_damage);
}
//------------------------------special states----------------------------------------------
if(pVictim->IsPlayer() && TO< Player* >(pVictim)->GodModeCheat == true)
{
- res = float(dmg.full_damage);
+ res = static_cast< float >(dmg.full_damage);
dmg.resisted_damage = dmg.full_damage;
}
@@ -1807,12 +1807,12 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
//==========================================================================================
//==============================Data Sending ProcHandling===================================
//==========================================================================================
- SendSpellNonMeleeDamageLog(this, pVictim, spellID, float2int32(res), static_cast<uint8>(spellInfo->School), abs_dmg, dmg.resisted_damage, false, 0, critical, IsPlayer());
- DealDamage(pVictim, float2int32(res), 2, 0, spellID);
+ SendSpellNonMeleeDamageLog(this, pVictim, spellID, static_cast< int32 >(res), static_cast< uint8 >(spellInfo->School), abs_dmg, dmg.resisted_damage, false, 0, critical, IsPlayer());
+ DealDamage(pVictim, static_cast< int32 >(res), 2, 0, spellID);
if(IsUnit())
{
- int32 dmg2 = float2int32(res);
+ int32 dmg2 = static_cast< int32 >(res);
pVictim->HandleProc(vproc, TO< Unit* >(this), spellInfo, !allowProc, dmg2, abs_dmg);
pVictim->m_procCounter = 0;
@@ -1844,7 +1844,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
Player* pl = TO< Player* >(pVictim);
uint32 maxmana = pl->GetMaxPower(POWER_TYPE_MANA);
- uint32 amount = uint32(maxmana * pl->m_RegenManaOnSpellResist);
+ uint32 amount = static_cast< uint32 >(maxmana * pl->m_RegenManaOnSpellResist);
pVictim->Energize(pVictim, 29442, amount, POWER_TYPE_MANA);
}
@@ -1861,10 +1861,10 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
//Shadow Word:Death
if(spellID == 32379 || spellID == 32996 || spellID == 48157 || spellID == 48158)
{
- uint32 damage2 = uint32(res + abs_dmg);
+ uint32 damage2 = static_cast< uint32 >(res + abs_dmg);
uint32 absorbed = TO< Unit* >(this)->AbsorbDamage(spellInfo->School, &damage2);
DealDamage(TO< Unit* >(this), damage2, 2, 0, spellID);
- SendSpellNonMeleeDamageLog(this, this, spellID, damage2, static_cast<uint8>(spellInfo->School), absorbed, 0, false, 0, false, IsPlayer());
+ SendSpellNonMeleeDamageLog(this, this, spellID, damage2, static_cast< uint8 >(spellInfo->School), absorbed, 0, false, 0, false, IsPlayer());
}
}
}
diff --git a/src/arcemu-world/SpellAuras.cpp b/src/arcemu-world/SpellAuras.cpp
index 536b8a4..9f8133a 100644
--- a/src/arcemu-world/SpellAuras.cpp
+++ b/src/arcemu-world/SpellAuras.cpp
@@ -1855,7 +1855,7 @@ void Aura::EventPeriodicDamage(uint32 amount)
}
}
- uint32 ress = (uint32)res;
+ uint32 ress = static_cast< uint32 >(res);
abs_dmg = m_target->AbsorbDamage(school, &ress);
uint32 ms_abs_dmg = m_target->ManaShieldAbsorb(ress);
if(ms_abs_dmg)
@@ -1885,7 +1885,7 @@ void Aura::EventPeriodicDamage(uint32 amount)
if((int32)dmg.resisted_damage > dmg.full_damage)
res = 0;
else
- res = float(dmg.full_damage - dmg.resisted_damage);
+ res = static_cast< float >(dmg.full_damage - dmg.resisted_damage);
}
m_target->SendPeriodicAuraLog(m_casterGuid, m_target->GetNewGUID(), GetSpellProto()->Id, school, float2int32(res), abs_dmg, dmg.resisted_damage, FLAG_PERIODIC_DAMAGE, is_critical);
@@ -1898,13 +1898,13 @@ void Aura::EventPeriodicDamage(uint32 amount)
res = (float)m_target->DoDamageSplitTarget((uint32)res, GetSpellProto()->School, false);
if(c != NULL)
- c->DealDamage(m_target, float2int32(res), 2, 0, GetSpellId());
+ c->DealDamage(m_target, static_cast< int32 >(res), 2, 0, GetSpellId());
else
- m_target->DealDamage(m_target, float2int32(res), 2, 0, GetSpellId());
+ m_target->DealDamage(m_target, static_cast< int32 >(res), 2, 0, GetSpellId());
if(m_target->GetGUID() != m_casterGuid && c != NULL) //don't use resist when cast on self-- this is some internal stuff
{
- int32 dmg = float2int32(res);
+ int32 dmg = static_cast< int32 >(res);
if(abs_dmg)
vproc |= PROC_ON_ABSORB;
diff --git a/src/arcemu-world/Unit.cpp b/src/arcemu-world/Unit.cpp
index 4a3bcca..36d12e7 100644
--- a/src/arcemu-world/Unit.cpp
+++ b/src/arcemu-world/Unit.cpp
@@ -5146,31 +5146,30 @@ int32 Unit::GetSpellDmgBonus(Unit* pVictim, SpellEntry* spellInfo, int32 base_dm
}
//------------------------------by school---------------------------------------------------
- plus_damage += caster->GetDamageDoneMod(school);
- plus_damage += static_cast< int32 >( base_dmg * (caster->GetDamageDonePctMod(school)-1) ); //value is initialized with 1
+ plus_damage += static_cast< float >( caster->GetDamageDoneMod(school) );
+ plus_damage += static_cast< float >( base_dmg * (caster->GetDamageDonePctMod(school)-1) ); //value is initialized with 1
//------------------------------by victim type----------------------------------------------
if(!pVictim->IsPlayer() && caster->IsPlayer())
- plus_damage += TO< Player* >(caster)->IncreaseDamageByType[TO_CREATURE(pVictim)->GetCreatureInfo()->Type];
+ plus_damage += static_cast< float >( TO< Player* >(caster)->IncreaseDamageByType[TO< Creature* >(pVictim)->GetCreatureInfo()->Type] );
//==========================================================================================
//==============================+Spell Damage Bonus Modifications===========================
//==========================================================================================
//------------------------------by cast duration--------------------------------------------
- float dmgdoneaffectperc = 1.0f;
// do not execute this if plus dmg is 0 or lower
if( plus_damage > 0.0f )
{
- if( spellInfo->Dspell_coef_override >= 0 && !isdot )
+ if( spellInfo->Dspell_coef_override >= 0.0f && !isdot )
plus_damage = plus_damage * spellInfo->Dspell_coef_override;
- else if( spellInfo->OTspell_coef_override >= 0 && isdot )
+ else if( spellInfo->OTspell_coef_override >= 0.0f && isdot )
plus_damage = plus_damage * spellInfo->OTspell_coef_override;
else
{
//Bonus to DD part
- if( spellInfo->fixed_dddhcoef >= 0 && !isdot )
+ if( spellInfo->fixed_dddhcoef >= 0.0f && !isdot )
plus_damage = plus_damage * spellInfo->fixed_dddhcoef;
//Bonus to DoT part
- else if( spellInfo->fixed_hotdotcoef >= 0 && isdot )
+ else if( spellInfo->fixed_hotdotcoef >= 0.0f && isdot )
{
plus_damage = plus_damage * spellInfo->fixed_hotdotcoef;
if(caster->IsPlayer())
@@ -5189,24 +5188,11 @@ int32 Unit::GetSpellDmgBonus(Unit* pVictim, SpellEntry* spellInfo, int32 base_dm
|| spellInfo->NameHash == SPELL_HASH_IMMOLATE
|| spellInfo->NameHash == SPELL_HASH_ICE_LANCE
|| spellInfo->NameHash == SPELL_HASH_PYROBLAST )
- plus_damage = plus_damage * ( 1.0f - ( ( td / 15000.0f ) / ( ( td / 15000.0f ) + dmgdoneaffectperc ) ) );
+ plus_damage = plus_damage * ( 1.0f - ( ( td / 15000.0f ) / ( ( td / 15000.0f ) ) ) );
}
}
}
- //------------------------------by downranking----------------------------------------------
- //DOT-DD (Moonfire-Immolate-IceLance-Pyroblast)(Hack Fix)
-
- if( spellInfo->baseLevel > 0 && spellInfo->maxLevel > 0 )
- {
- float downrank1 = 1.0f;
- if(spellInfo->baseLevel < 20)
- downrank1 = 1.0f - (20.0f - float(spellInfo->baseLevel)) * 0.0375f;
- float downrank2 = static_cast< float >( (spellInfo->maxLevel + 5.0f) / TO< Player* >(caster)->getLevel() );
- if(downrank2 >= 1 || downrank2 < 0)
- downrank2 = 1.0f;
- dmgdoneaffectperc *= downrank1 * downrank2;
- }
//==========================================================================================
//==============================Bonus Adding To Main Damage=================================
//==========================================================================================
@@ -5227,7 +5213,7 @@ int32 Unit::GetSpellDmgBonus(Unit* pVictim, SpellEntry* spellInfo, int32 base_dm
plus_damage += static_cast< float >( (base_dmg + bonus_damage) * dmg_bonus_pct / 100 );
}
- int32 res = static_cast< int32 >( (base_dmg * dmgdoneaffectperc) + plus_damage );
+ int32 res = static_cast< int32 >( plus_damage );
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment