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

@ -1,124 +1,126 @@
using System;
using Server.Mobiles;
using Server.Spells.Ninjitsu;
namespace Server.Misc
{
public enum DFAlgorithm
{
Standard,
PainSpike
}
public enum DFAlgorithm
{
Standard,
PainSpike
}
public class WeightOverloading
{
public static void Initialize()
{
EventSink.Movement += EventSink_Movement;
}
public class WeightOverloading
{
public const int OverloadAllowance = 4; // We can be four stones overweight without getting fatigued
public static DFAlgorithm DFA { get; set; }
public static DFAlgorithm DFA{ get; set; }
public static void FatigueOnDamage( Mobile m, int damage )
{
double fatigue = 0.0;
public static void Initialize()
{
EventSink.Movement += EventSink_Movement;
}
switch ( DFA )
{
case DFAlgorithm.Standard:
{
fatigue = (damage * (100.0 / m.Hits) * ((double)m.Stam / 100)) - 5.0;
break;
}
case DFAlgorithm.PainSpike:
{
fatigue = (damage * ((100.0 / m.Hits) + ((50.0 + m.Stam) / 100) - 1.0)) - 5.0;
break;
}
}
public static void FatigueOnDamage(Mobile m, int damage)
{
double fatigue = 0.0;
if ( fatigue > 0 )
m.Stam -= (int)fatigue;
}
switch (DFA)
{
case DFAlgorithm.Standard:
{
fatigue = damage * (100.0 / m.Hits) * ((double)m.Stam / 100) - 5.0;
break;
}
case DFAlgorithm.PainSpike:
{
fatigue = damage * (100.0 / m.Hits + (50.0 + m.Stam) / 100 - 1.0) - 5.0;
break;
}
}
public const int OverloadAllowance = 4; // We can be four stones overweight without getting fatigued
if (fatigue > 0)
m.Stam -= (int)fatigue;
}
public static int GetMaxWeight( Mobile m )
{
//return ((( Core.ML && m.Race == Race.Human) ? 100 : 40 ) + (int)(3.5 * m.Str));
//Moved to core virtual method for use there
public static int GetMaxWeight(Mobile m)
{
//return ((( Core.ML && m.Race == Race.Human) ? 100 : 40 ) + (int)(3.5 * m.Str));
//Moved to core virtual method for use there
return m.MaxWeight;
}
return m.MaxWeight;
}
public static void EventSink_Movement( MovementEventArgs e )
{
Mobile from = e.Mobile;
public static void EventSink_Movement(MovementEventArgs e)
{
Mobile from = e.Mobile;
if ( !from.Alive || from.AccessLevel > AccessLevel.Player )
return;
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
return;
if ( !from.Player )
{
// Else it won't work on monsters.
Spells.Ninjitsu.DeathStrike.AddStep( from );
return;
}
if (!from.Player)
{
// Else it won't work on monsters.
DeathStrike.AddStep(from);
return;
}
int maxWeight = GetMaxWeight( from ) + OverloadAllowance;
int overWeight = (Mobile.BodyWeight + from.TotalWeight) - maxWeight;
int maxWeight = GetMaxWeight(from) + OverloadAllowance;
int overWeight = Mobile.BodyWeight + from.TotalWeight - maxWeight;
if ( overWeight > 0 )
{
from.Stam -= GetStamLoss( from, overWeight, (e.Direction & Direction.Running) != 0 );
if (overWeight > 0)
{
from.Stam -= GetStamLoss(from, overWeight, (e.Direction & Direction.Running) != 0);
if ( from.Stam == 0 )
{
from.SendLocalizedMessage( 500109 ); // You are too fatigued to move, because you are carrying too much weight!
e.Blocked = true;
return;
}
}
if (from.Stam == 0)
{
from.SendLocalizedMessage(
500109); // You are too fatigued to move, because you are carrying too much weight!
e.Blocked = true;
return;
}
}
if ( ((from.Stam * 100) / Math.Max( from.StamMax, 1 )) < 10 )
--from.Stam;
if (from.Stam * 100 / Math.Max(from.StamMax, 1) < 10)
--from.Stam;
if ( from.Stam == 0 )
{
from.SendLocalizedMessage( 500110 ); // You are too fatigued to move.
e.Blocked = true;
return;
}
if (from.Stam == 0)
{
from.SendLocalizedMessage(500110); // You are too fatigued to move.
e.Blocked = true;
return;
}
if ( from is PlayerMobile pm )
{
int amt = ( pm.Mounted ? 48 : 16 );
if (from is PlayerMobile pm)
{
int amt = pm.Mounted ? 48 : 16;
if ( (++pm.StepsTaken % amt) == 0 )
--pm.Stam;
}
if (++pm.StepsTaken % amt == 0)
--pm.Stam;
}
Spells.Ninjitsu.DeathStrike.AddStep( from );
}
DeathStrike.AddStep(from);
}
public static int GetStamLoss( Mobile from, int overWeight, bool running )
{
int loss = 5 + (overWeight / 25);
public static int GetStamLoss(Mobile from, int overWeight, bool running)
{
int loss = 5 + overWeight / 25;
if ( from.Mounted )
loss /= 3;
if (from.Mounted)
loss /= 3;
if ( running )
loss *= 2;
if (running)
loss *= 2;
return loss;
}
return loss;
}
public static bool IsOverloaded( Mobile m )
{
if ( !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player )
return false;
public static bool IsOverloaded(Mobile m)
{
if (!m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player)
return false;
return ( (Mobile.BodyWeight + m.TotalWeight) > (GetMaxWeight( m ) + OverloadAllowance) );
}
}
}
return Mobile.BodyWeight + m.TotalWeight > GetMaxWeight(m) + OverloadAllowance;
}
}
}