Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -2,176 +2,178 @@ using Server.Network;
namespace Server.Items
{
public class BaseShield : BaseArmor
{
public override ArmorMaterialType MaterialType => ArmorMaterialType.Plate;
public class BaseShield : BaseArmor
{
public BaseShield(int itemID) : base(itemID)
{
}
public BaseShield( int itemID ) : base( itemID )
{
}
public BaseShield(Serial serial) : base(serial)
{
}
public BaseShield( Serial serial ) : base(serial)
{
}
public override ArmorMaterialType MaterialType => ArmorMaterialType.Plate;
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override double ArmorRating
{
get
{
Mobile m = Parent as Mobile;
double ar = base.ArmorRating;
writer.Write( (int) 1 );//version
}
if (m != null)
return m.Skills[SkillName.Parry].Value * ar / 200.0 + 1.0;
return ar;
}
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
int version = reader.ReadInt();
writer.Write(1); //version
}
if ( version < 1 )
{
if ( this is Aegis )
return;
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
// The 15 bonus points to resistances are not applied to shields on OSI.
PhysicalBonus = 0;
FireBonus = 0;
ColdBonus = 0;
PoisonBonus = 0;
EnergyBonus = 0;
}
}
int version = reader.ReadInt();
public override double ArmorRating
{
get
{
Mobile m = Parent as Mobile;
double ar = base.ArmorRating;
if (version < 1)
{
if (this is Aegis)
return;
if ( m != null )
return ( ( m.Skills[SkillName.Parry].Value * ar ) / 200.0 ) + 1.0;
return ar;
}
}
// The 15 bonus points to resistances are not applied to shields on OSI.
PhysicalBonus = 0;
FireBonus = 0;
ColdBonus = 0;
PoisonBonus = 0;
EnergyBonus = 0;
}
}
public override int OnHit( BaseWeapon weapon, int damage )
{
if ( Core.AOS )
{
if ( ArmorAttributes.SelfRepair > Utility.Random( 10 ) )
{
HitPoints += 2;
}
else
{
double halfArmor = ArmorRating / 2.0;
int absorbed = (int)(halfArmor + (halfArmor*Utility.RandomDouble()));
public override int OnHit(BaseWeapon weapon, int damage)
{
if (Core.AOS)
{
if (ArmorAttributes.SelfRepair > Utility.Random(10))
{
HitPoints += 2;
}
else
{
double halfArmor = ArmorRating / 2.0;
int absorbed = (int)(halfArmor + halfArmor * Utility.RandomDouble());
if ( absorbed < 2 )
absorbed = 2;
if (absorbed < 2)
absorbed = 2;
int wear;
int wear;
if ( weapon.Type == WeaponType.Bashing )
wear = (absorbed / 2);
else
wear = Utility.Random( 2 );
if (weapon.Type == WeaponType.Bashing)
wear = absorbed / 2;
else
wear = Utility.Random(2);
if ( wear > 0 && MaxHitPoints > 0 )
{
if ( HitPoints >= wear )
{
HitPoints -= wear;
wear = 0;
}
else
{
wear -= HitPoints;
HitPoints = 0;
}
if (wear > 0 && MaxHitPoints > 0)
{
if (HitPoints >= wear)
{
HitPoints -= wear;
wear = 0;
}
else
{
wear -= HitPoints;
HitPoints = 0;
}
if ( wear > 0 )
{
if ( MaxHitPoints > wear )
{
MaxHitPoints -= wear;
if (wear > 0)
{
if (MaxHitPoints > wear)
{
MaxHitPoints -= wear;
if ( Parent is Mobile mobile )
mobile.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
}
else
{
Delete();
}
}
}
}
if (Parent is Mobile mobile)
mobile.LocalOverheadMessage(MessageType.Regular, 0x3B2,
1061121); // Your equipment is severely damaged.
}
else
{
Delete();
}
}
}
}
return 0;
}
return 0;
}
if ( !(Parent is Mobile owner) )
return damage;
if (!(Parent is Mobile owner))
return damage;
double ar = ArmorRating;
double chance = (owner.Skills[SkillName.Parry].Value - (ar * 2.0)) / 100.0;
double ar = ArmorRating;
double chance = (owner.Skills[SkillName.Parry].Value - ar * 2.0) / 100.0;
if ( chance < 0.01 )
chance = 0.01;
/*
FORMULA: Displayed AR = ((Parrying Skill * Base AR of Shield) <EFBFBD> 200) + 1
if (chance < 0.01)
chance = 0.01;
/*
FORMULA: Displayed AR = ((Parrying Skill * Base AR of Shield) <EFBFBD> 200) + 1
FORMULA: % Chance of Blocking = parry skill - (shieldAR * 2)
FORMULA: % Chance of Blocking = parry skill - (shieldAR * 2)
FORMULA: Melee Damage Absorbed = (AR of Shield) / 2 | Archery Damage Absorbed = AR of Shield
*/
if ( owner.CheckSkill( SkillName.Parry, chance ) )
{
if ( weapon.Skill == SkillName.Archery )
damage -= (int)ar;
else
damage -= (int)(ar / 2.0);
FORMULA: Melee Damage Absorbed = (AR of Shield) / 2 | Archery Damage Absorbed = AR of Shield
*/
if (owner.CheckSkill(SkillName.Parry, chance))
{
if (weapon.Skill == SkillName.Archery)
damage -= (int)ar;
else
damage -= (int)(ar / 2.0);
if ( damage < 0 )
damage = 0;
if (damage < 0)
damage = 0;
owner.FixedEffect( 0x37B9, 10, 16 );
owner.FixedEffect(0x37B9, 10, 16);
if ( 25 > Utility.Random( 100 ) ) // 25% chance to lower durability
{
int wear = Utility.Random( 2 );
if (25 > Utility.Random(100)) // 25% chance to lower durability
{
int wear = Utility.Random(2);
if ( wear > 0 && MaxHitPoints > 0 )
{
if ( HitPoints >= wear )
{
HitPoints -= wear;
wear = 0;
}
else
{
wear -= HitPoints;
HitPoints = 0;
}
if (wear > 0 && MaxHitPoints > 0)
{
if (HitPoints >= wear)
{
HitPoints -= wear;
wear = 0;
}
else
{
wear -= HitPoints;
HitPoints = 0;
}
if ( wear > 0 )
{
if ( MaxHitPoints > wear )
{
MaxHitPoints -= wear;
if (wear > 0)
{
if (MaxHitPoints > wear)
{
MaxHitPoints -= wear;
((Mobile)Parent).LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
}
else
{
Delete();
}
}
}
}
}
((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2,
1061121); // Your equipment is severely damaged.
}
else
{
Delete();
}
}
}
}
}
return damage;
}
}
}
return damage;
}
}
}