I am essentially trying to add a chance to lessen fire-based spell damage for characters wearing barbed armor, not with the AoS resistances, but rather using the old school system. I want to add a percentage of damage reduction for each piece of barbed armor worn, and to apply that to the final scaled spell damage for fire-based spells. It should total to a max 15% damage reduction.
I tried this previously, and Lokai pointed out that my math was wrong, and that it would be better to add all checks in one place, to the DamageScalar in Spell.cs. I tried to follow hs advice, and was hoping maybe someone could take a quick look and see if this is going to do what I think it is, or if it needs modifications.
I hope to expand this to other armors and damage types as well, once I am sure it works. Thanks in advance for any help!
I added this method to Spell.cs
I modified GetDamageScalar in Spell.cs. I have indicated the change I made in the below code.
I tried this previously, and Lokai pointed out that my math was wrong, and that it would be better to add all checks in one place, to the DamageScalar in Spell.cs. I tried to follow hs advice, and was hoping maybe someone could take a quick look and see if this is going to do what I think it is, or if it needs modifications.
I hope to expand this to other armors and damage types as well, once I am sure it works. Thanks in advance for any help!
I added this method to Spell.cs
Code:
public virtual double BarbedFireResist( Mobile target )
{
double resfire;
resfire = 0;
Item chest = target.FindItemOnLayer( Layer.MiddleTorso );
Item chesttwo = target.FindItemOnLayer( Layer.InnerTorso );
Item arms = target.FindItemOnLayer( Layer.Arms );
Item legs = target.FindItemOnLayer( Layer.Pants );
Item helm = target.FindItemOnLayer( Layer.Helm );
Item gloves = target.FindItemOnLayer( Layer.Gloves );
Item gorget = target.FindItemOnLayer( Layer.Neck );
if ( chest != null && chest is BarbedLeatherChest )
{
resfire += 0.03;
}
if ( chesttwo != null && chesttwo is BarbedFemaleLeatherChest )
{
resfire += 0.03;
}
if ( arms != null && arms is BarbedLeatherArms )
{
resfire += 0.03;
}
if ( legs != null && (legs is BarbedLeatherLegs || legs is BarbedLeatherSkirt ) )
{
resfire += 0.03;
}
if ( helm != null && helm is BarbedLeatherCap )
{
resfire += 0.01;
}
if ( gloves != null && gloves is BarbedLeatherGloves )
{
resfire += 0.03;
}
if ( gorget != null && gorget is BarbedLeatherGorget )
{
resfire += 0.02;
}
return resfire;
}
I modified GetDamageScalar in Spell.cs. I have indicated the change I made in the below code.
Code:
public virtual double GetDamageScalar( Mobile target )
{
double scalar = 1.0;
if( !Core.AOS ) //EvalInt stuff for AoS is handled elsewhere
{
double casterEI = m_Caster.Skills[DamageSkill].Value;
double targetRS = target.Skills[SkillName.MagicResist].Value;
/*
if( Core.AOS )
targetRS = 0;
*/
//m_Caster.CheckSkill( DamageSkill, 0.0, 120.0 );
if( casterEI > targetRS )
scalar = (1.0 + ((casterEI - targetRS) / 500.0));
else
scalar = (1.0 + ((casterEI - targetRS) / 200.0));
// magery damage bonus, -25% at 0 skill, +0% at 100 skill, +5% at 120 skill
scalar += (m_Caster.Skills[CastSkill].Value - 100.0) / 400.0;
if( !target.Player && !target.Body.IsHuman /*&& !Core.AOS*/ )
scalar *= 2.0; // Double magery damage to monsters/animals if not AOS
}
if ( target is BaseCreature )
((BaseCreature)target).AlterDamageScalarFrom( m_Caster, ref scalar );
if ( m_Caster is BaseCreature )
((BaseCreature)m_Caster).AlterDamageScalarTo( target, ref scalar );
if( Core.SE )
scalar *= GetSlayerDamageScalar( target );
target.Region.SpellDamageScalar( m_Caster, target, ref scalar );
if( Evasion.CheckSpellEvasion( target ) ) //Only single target spells an be evaded
scalar = 0;
/////////////////////// MY ADDITION //////////////////////////
if ( target.Body.IsHuman && ( this is MagicArrowSpell || this is FireballSpell || this is FlameStrikeSpell ) )
{
double fireres = BarbedFireResist ( target );
scalar = scalar - ( scalar * fireres );
}
////////////////////////////////////////////////////////////////////////
return scalar;
}