Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 07-11-2010, 11:44 PM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default

Here is the code for spell and dot shielding separated out... Spell effect coming later.

mob.h
Code:
Index: mob.h
===================================================================
--- mob.h	(revision 1597)
+++ mob.h	(working copy)
@@ -839,7 +839,7 @@
 	inline int16	GetErrorNumber() const {return adverrorinfo;}
 
 	sint32	ReduceDamage(sint32 damage);
-	sint32  ReduceMagicalDamage(sint32 damage);
+	sint32  AffectMagicalDamage(sint32 damage, int16 spell_id, const bool iBuffTic, Mob* attacker);
 
 	virtual void DoSpecialAttackDamage(Mob *who, SkillType skill, sint32 max_damage, sint32 min_damage = 1, sint32 hate_override = -1);
     bool Flurry();
attack.cpp
Code:
Index: attack.cpp
===================================================================
--- attack.cpp	(revision 1597)
+++ attack.cpp	(working copy)
@@ -2929,13 +2929,14 @@
 	return(damage);
 }
 	
-sint32 Mob::ReduceMagicalDamage(sint32 damage) 
+sint32 Mob::AffectMagicalDamage(sint32 damage, int16 spell_id, const bool iBuffTic, Mob* attacker) 
 {
-	if(damage <= 0 || (!HasSpellRune() && !HasPartialSpellRune()))
+	if(damage <= 0)
 	{
 		return damage;
 	}
 
+	// See if we block the spell outright first
 	int slot = GetBuffSlotFromType(SE_NegateAttacks);
 	if(slot >= 0 && buffs[slot].magic_rune > 0)
 	{
@@ -2946,55 +2947,67 @@
 		}
 		return -6;
 	}
-
-	slot = GetBuffSlotFromType(SE_MitigateSpellDamage);
-	if(slot >= 0)
+	
+	// If this is a DoT, use DoT Shielding...
+	if(iBuffTic)
 	{
-		int damage_to_reduce = damage * GetPartialMagicRuneReduction(buffs[slot].spellid) / 100;
-		if(damage_to_reduce > buffs[slot].magic_rune)
+		damage -= (damage * this->itembonuses.DoTShielding / 100);
+	}
+	// This must be a DD then so lets apply Spell Shielding and runes.
+	else 
+	{
+		// Reduce damage by the Spell Shielding first so that the runes don't take the raw damage.
+		damage -= (damage * this->itembonuses.SpellDamageShield / 100);
+	
+		// Do runes now.
+		slot = GetBuffSlotFromType(SE_MitigateSpellDamage);
+		if(slot >= 0)
 		{
-			mlog(SPELLS__EFFECT_VALUES, "Mob::ReduceDamage SE_MitigateSpellDamage %d damage negated, %d"
-				" damage remaining, fading buff.", damage_to_reduce, buffs[slot].magic_rune);
-			damage -= damage_to_reduce;
-			BuffFadeBySlot(slot);
-			UpdateRuneFlags();
+			int damage_to_reduce = damage * GetPartialMagicRuneReduction(buffs[slot].spellid) / 100;
+			if(damage_to_reduce > buffs[slot].magic_rune)
+			{
+				mlog(SPELLS__EFFECT_VALUES, "Mob::ReduceDamage SE_MitigateSpellDamage %d damage negated, %d"
+					" damage remaining, fading buff.", damage_to_reduce, buffs[slot].magic_rune);
+				damage -= damage_to_reduce;
+				BuffFadeBySlot(slot);
+				UpdateRuneFlags();
+			}
+			else
+			{
+				mlog(SPELLS__EFFECT_VALUES, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d"
+					" damage remaining.", damage_to_reduce, buffs[slot].magic_rune);
+				buffs[slot].magic_rune = (buffs[slot].magic_rune - damage_to_reduce);
+				damage -= damage_to_reduce;
+			}
 		}
-		else
+
+		if(damage < 1)
 		{
-			mlog(SPELLS__EFFECT_VALUES, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d"
-				" damage remaining.", damage_to_reduce, buffs[slot].magic_rune);
-			buffs[slot].magic_rune = (buffs[slot].magic_rune - damage_to_reduce);
-			damage -= damage_to_reduce;
+			return -6;
 		}
-	}
 
-	if(damage < 1)
-	{
-		return -6;
-	}
-
-	slot = GetBuffSlotFromType(SE_AbsorbMagicAtt);
-	while(slot >= 0)
-	{
-		int16 magic_rune_left = buffs[slot].magic_rune;
-		if(magic_rune_left >= damage)
+		slot = GetBuffSlotFromType(SE_AbsorbMagicAtt);
+		while(slot >= 0)
 		{
-			magic_rune_left -= damage;
-			damage = 0;
-			buffs[slot].magic_rune = magic_rune_left;
-			break;
+			int16 magic_rune_left = buffs[slot].magic_rune;
+			if(magic_rune_left >= damage)
+			{
+				magic_rune_left -= damage;
+				damage = 0;
+				buffs[slot].magic_rune = magic_rune_left;
+				break;
+			}
+			else
+			{
+				if(magic_rune_left > 0)
+					damage -= magic_rune_left;
+				BuffFadeBySlot(slot);
+				slot = GetBuffSlotFromType(SE_AbsorbMagicAtt);
+				UpdateRuneFlags();
+			}
 		}
-		else
-		{
-			if(magic_rune_left > 0)
-				damage -= magic_rune_left;
-			BuffFadeBySlot(slot);
-			slot = GetBuffSlotFromType(SE_AbsorbMagicAtt);
-			UpdateRuneFlags();
-		}
 	}
-
-	return(damage);
+	return damage;
 }
 
 bool Mob::HasProcs() const
@@ -3159,7 +3172,7 @@
 			mlog(COMBAT__HITS, "Melee Damage reduced to %d", damage);
 		} else {
 			sint32 origdmg = damage;
-			damage = ReduceMagicalDamage(damage);
+			damage = AffectMagicalDamage(damage, spell_id, iBuffTic, attacker);
 			mlog(COMBAT__HITS, "Melee Damage reduced to %d", damage);
 			if (origdmg != damage && attacker && attacker->IsClient()) {
 				if(attacker->CastToClient()->GetFilter(FILTER_DAMAGESHIELD) != FilterHide)
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 09:23 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3