Skip to content

Instantly share code, notes, and snippets.

@neo-mat
Created January 30, 2012 07:41
Show Gist options
  • Save neo-mat/1703083 to your computer and use it in GitHub Desktop.
Save neo-mat/1703083 to your computer and use it in GitHub Desktop.
MesoX's damage reduction patch
Index: /src/world/Object.cpp
===================================================================
--- /src/world/Object.cpp (revision 48)
+++ /src/world/Object.cpp (revision 65)
@@ -1655,5 +1658,6 @@
caster->RemoveAurasByInterruptFlag( AURA_INTERRUPT_ON_START_ATTACK );
- res += caster->GetSpellDmgBonus( pVictim, spellInfo, ( int )res, false );
+ // this calculates whole dmg with all bonuses / mods
+ res = float(caster->GetSpellDmgBonus( pVictim, spellInfo, damage, false ));
if( res < 0 )
Index: /src/world/Unit.h
===================================================================
--- /src/world/Unit.h (revision 61)
+++ /src/world/Unit.h (revision 65)
@@ -1128,5 +1128,4 @@
int32 GetDamageDoneMod(uint32 school);
float GetDamageDonePctMod(uint32 school);
- float DamageDoneModPCT[7];
int32 DamageTakenMod[7];
float DamageTakenPctMod[7];
Index: /src/world/Unit.cpp
===================================================================
--- /src/world/Unit.cpp (revision 61)
+++ /src/world/Unit.cpp (revision 65)
@@ -316,5 +316,4 @@
HealTakenPctMod[i] = 0;
DamageTakenMod[i] = 0;
- DamageDoneModPCT[i]= 0;
SchoolCastPrevent[i]= 0;
DamageTakenPctMod[i] = 0;
@@ -3553,5 +3552,4 @@
dmg.full_damage += float2int32( dmg.full_damage * pVictim->DamageTakenPctMod[ dmg.school_type ] );
- dmg.full_damage += float2int32( dmg.full_damage * DamageDoneModPCT[dmg.school_type] );
if( dmg.school_type != SCHOOL_NORMAL )
@@ -5039,5 +5037,6 @@
//------------------------------by school---------------------------------------------------
plus_damage += caster->GetDamageDoneMod(school);
- plus_damage += pVictim->DamageTakenMod[school];
+ plus_damage += float2int32(base_dmg * (caster->GetDamageDonePctMod(school)-1)); //value is initialized with 1
+
//------------------------------by victim type----------------------------------------------
if(!pVictim->IsPlayer() && caster->IsPlayer())
@@ -5048,31 +5047,36 @@
//------------------------------by cast duration--------------------------------------------
float dmgdoneaffectperc = 1.0f;
- if( spellInfo->Dspell_coef_override >= 0 && !isdot )
- plus_damage = float2int32( plus_damage * spellInfo->Dspell_coef_override );
- else if( spellInfo->OTspell_coef_override >= 0 && isdot )
- plus_damage = float2int32( plus_damage * spellInfo->OTspell_coef_override );
- else
- {
- //Bonus to DD part
- if( spellInfo->fixed_dddhcoef >= 0 && !isdot )
- plus_damage = float2int32( plus_damage * spellInfo->fixed_dddhcoef );
- //Bonus to DoT part
- else if( spellInfo->fixed_hotdotcoef >= 0 && isdot )
- {
- plus_damage = float2int32( plus_damage * spellInfo->fixed_hotdotcoef );
- if( caster->IsPlayer() )
- {
- int durmod = 0;
- SM_FIValue(caster->SM_FDur, &durmod, spellInfo->SpellGroupType);
- plus_damage += plus_damage * durmod / 15000;
- }
- }
- //In case we dont fit in previous cases do old thing
+
+ // do not execute this if plus dmg is 0 or lower
+ if( plus_damage > 0 )
+ {
+ if( spellInfo->Dspell_coef_override >= 0 && !isdot )
+ plus_damage = float2int32( plus_damage * spellInfo->Dspell_coef_override );
+ else if( spellInfo->OTspell_coef_override >= 0 && isdot )
+ plus_damage = float2int32( plus_damage * spellInfo->OTspell_coef_override );
else
{
- plus_damage = float2int32( plus_damage * spellInfo->casttime_coef );
- float td = float(GetDuration( dbcSpellDuration.LookupEntry( spellInfo->DurationIndex ) ) );
- if( spellInfo->NameHash == SPELL_HASH_MOONFIRE || spellInfo->NameHash == SPELL_HASH_IMMOLATE || spellInfo->NameHash == SPELL_HASH_ICE_LANCE || spellInfo->NameHash == SPELL_HASH_PYROBLAST )
- plus_damage = float2int32( plus_damage * ( 1.0f - ( ( td / 15000.0f ) / ( ( td / 15000.0f ) + dmgdoneaffectperc ) ) ) );
+ //Bonus to DD part
+ if( spellInfo->fixed_dddhcoef >= 0 && !isdot )
+ plus_damage = float2int32( plus_damage * spellInfo->fixed_dddhcoef );
+ //Bonus to DoT part
+ else if( spellInfo->fixed_hotdotcoef >= 0 && isdot )
+ {
+ plus_damage = float2int32( plus_damage * spellInfo->fixed_hotdotcoef );
+ if( caster->IsPlayer() )
+ {
+ int durmod = 0;
+ SM_FIValue(caster->SM_FDur, &durmod, spellInfo->SpellGroupType);
+ plus_damage += plus_damage * durmod / 15000;
+ }
+ }
+ //In case we dont fit in previous cases do old thing
+ else
+ {
+ plus_damage = float2int32( plus_damage * spellInfo->casttime_coef );
+ float td = float(GetDuration( dbcSpellDuration.LookupEntry( spellInfo->DurationIndex ) ) );
+ if( spellInfo->NameHash == SPELL_HASH_MOONFIRE || spellInfo->NameHash == SPELL_HASH_IMMOLATE || spellInfo->NameHash == SPELL_HASH_ICE_LANCE || spellInfo->NameHash == SPELL_HASH_PYROBLAST )
+ plus_damage = float2int32( plus_damage * ( 1.0f - ( ( td / 15000.0f ) / ( ( td / 15000.0f ) + dmgdoneaffectperc ) ) ) );
+ }
}
}
@@ -5094,50 +5098,30 @@
//==============================Bonus Adding To Main Damage=================================
//==========================================================================================
- int32 bonus_damage = float2int32(plus_damage * dmgdoneaffectperc);
if( ( pVictim->HasAuraWithMechanics(MECHANIC_ENSNARED) || pVictim->HasAuraWithMechanics(MECHANIC_DAZED) ) && caster->IsPlayer() )
- bonus_damage += TO_PLAYER(caster)->m_IncreaseDmgSnaredSlowed;
+ plus_damage += TO_PLAYER(caster)->m_IncreaseDmgSnaredSlowed;
if(spellInfo->SpellGroupType)
{
+ int32 bonus_damage = 0;
SM_FIValue(caster->SM_FPenalty, &bonus_damage, spellInfo->SpellGroupType);
SM_FIValue(caster->SM_FDamageBonus, &bonus_damage, spellInfo->SpellGroupType);
- int dmg_bonus_pct= 0;
+ int32 dmg_bonus_pct = 0;
SM_FIValue(caster->SM_PPenalty, &dmg_bonus_pct, spellInfo->SpellGroupType);
- SM_FIValue(caster->SM_PDamageBonus,&dmg_bonus_pct,spellInfo->SpellGroupType);
-
- bonus_damage += (base_dmg+bonus_damage)*dmg_bonus_pct/100;
- }
-//------------------------------by school----------------------------------------------
- float summaryPCTmod = caster->GetDamageDonePctMod(school)-1; //value is initialized with 1
- summaryPCTmod += pVictim->DamageTakenPctMod[school];
- summaryPCTmod += caster->DamageDoneModPCT[school]; // BURLEX FIX ME
- summaryPCTmod += pVictim->ModDamageTakenByMechPCT[spellInfo->MechanicsType];
-
- //Seals of Blood and Martyr
- if( caster->IsPlayer() )
- {
- if( spellInfo->Id == 31893 || spellInfo->Id == 53719 )
- {
- int32 selfdamage = float2int32((( bonus_damage * summaryPCTmod) + bonus_damage ) * 0.1f);
- if( caster->GetHealth() - selfdamage < 0 )
- caster->SetHealth( 1);
- else
- caster->ModHealth(-selfdamage);
- }
- else if( spellInfo->Id == 31898 || spellInfo->Id == 53726 )
- {
- int32 selfdamage = float2int32((( bonus_damage * summaryPCTmod) + bonus_damage ) * 0.33f);
- if( caster->GetHealth() - selfdamage < 0 )
- caster->SetHealth( 1);
- else
- caster->ModHealth(-selfdamage);
- }
- }
-
- int32 res = (int32)((base_dmg+bonus_damage)*summaryPCTmod + bonus_damage);
- if( res < 0 )
- res = 0;
+ SM_FIValue(caster->SM_PDamageBonus, &dmg_bonus_pct,spellInfo->SpellGroupType);
+
+ plus_damage += (base_dmg + bonus_damage) * dmg_bonus_pct / 100;
+ }
+
+ int32 res = float2int32(base_dmg * dmgdoneaffectperc) + plus_damage;
+
+ int32 reduce_damage = 0;
+ // damage taken is reduced after base dmagae is calculated
+ reduce_damage += pVictim->DamageTakenMod[school];
+ reduce_damage += float2int32(res * pVictim->DamageTakenPctMod[school]);
+ reduce_damage += float2int32(res * pVictim->ModDamageTakenByMechPCT[spellInfo->MechanicsType]);
+
+ res += reduce_damage;
return res;
Index: /src/world/AIInterface.cpp
===================================================================
--- /src/world/AIInterface.cpp (revision 58)
+++ /src/world/AIInterface.cpp (revision 65)
@@ -242,5 +242,5 @@
// dismount if mounted
- if( !(TO_CREATURE( m_Unit )->GetCreatureInfo()->Flags1 & CREATURE_FLAG1_FIGHT_MOUNTED))
+ if( m_Unit->IsCreature() && !(TO_CREATURE( m_Unit )->GetCreatureInfo()->Flags1 & CREATURE_FLAG1_FIGHT_MOUNTED))
m_Unit->SetMount(0);
Index: /src/world/ChatHandler.cpp
===================================================================
--- /src/world/ChatHandler.cpp (revision 42)
+++ /src/world/ChatHandler.cpp (revision 65)
@@ -631,7 +631,9 @@
WorldPacket data(SMSG_EMOTE, 28 + namelen);
- sHookInterface.OnEmote(_player, (EmoteType)em->textid, pUnit);
if(pUnit)
+ {
+ sHookInterface.OnEmote(_player, (EmoteType)em->textid, pUnit);
CALL_SCRIPT_EVENT(pUnit,OnEmote)(_player,(EmoteType)em->textid);
+ }
switch(em->textid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment