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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-09-2010, 12:49 AM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default COMMITTED: Spell & DoT Shielding

This also includes a fix for the spell rune effects(Bulwark of Alendar) as they were incorrectly also reducing the damage on DoTs.

edit... this didnt fix the problem with spell runes.
edit2... also doesnt seem to apply properly to DoTs and DD, just does the highest one to both(yay for testing at cap for both stats). its late so will fix tomorrow

code...

mob.h - alter this - line 842
Code:
sint32  ReduceMagicalDamage(sint32 damage);
to this
Code:
sint32  ReduceMagicalDamage(sint32 damage, int16 spell_id);
attack.cpp - alter this - line 3177
Code:
damage = ReduceMagicalDamage(damage);
to this
Code:
damage = ReduceMagicalDamage(damage, spell_id);
attack.cpp - alter this - line 2932
Code:
sint32 Mob::ReduceMagicalDamage(sint32 damage) 
{
	if(damage <= 0 || (!HasSpellRune() && !HasPartialSpellRune()))
	{
		return damage;
	}

	int slot = GetBuffSlotFromType(SE_NegateAttacks);
	if(slot >= 0 && buffs[slot].magic_rune > 0)
	{
		if(--buffs[slot].melee_rune == 0)
		{
			BuffFadeBySlot(slot);
			UpdateRuneFlags();
		}
		return -6;
	}

	slot = GetBuffSlotFromType(SE_MitigateSpellDamage);
	if(slot >= 0)
	{
		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;
		}
	}

	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)
		{
			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();
		}
	}

	return(damage);
}
to this
Code:
sint32 Mob::ReduceMagicalDamage(sint32 damage, int16 spell_id) 
{

	if(damage <= 0 || (!HasSpellRune() && !HasPartialSpellRune()) && this->itembonuses.SpellDamageShield == 0 && this->itembonuses.DoTShielding == 0)
	{
		return damage;
	}
	
	int slot = GetBuffSlotFromType(SE_NegateAttacks);
	if(slot >= 0 && buffs[slot].magic_rune > 0)
	{
		if(--buffs[slot].melee_rune == 0)
		{
			BuffFadeBySlot(slot);
			UpdateRuneFlags();
		}
		return -6;
	}
	
	for(int i = 0; i < EFFECT_COUNT; i++)
	{
		// Isolate the Direct Damage effects to be reduced by spell shielding and spell rune effects.
		if ((spells[spell_id].buffduration == 0 && spells[spell_id].effectid[i] == SE_CurrentHP) || (spells[spell_id].buffduration > 0 && spells[spell_id].effectid[i] == SE_CurrentHPOnce))
		{
	
			damage -= (damage * this->itembonuses.SpellDamageShield / 100);
	
			slot = GetBuffSlotFromType(SE_MitigateSpellDamage);
			if(slot >= 0)
			{
				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;
				}
			}

			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)
				{
					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();
				}
			}
			return(damage);
		}
		// Isolate the DoT effects to be reduced by DoT shielding.
		else if (spells[spell_id].buffduration > 0 && spells[spell_id].effectid[i] == SE_CurrentHP) 
		{
			damage -= (damage * this->itembonuses.DoTShielding / 100);
			return(damage);
		}
	}
	return(damage);
}
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:41 AM.


 

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