using System;
using Server.Network;
using Server;
using Server.Gumps;
namespace Server.Misc
{
public class FoodDecayTimer : Timer
{
// keep player from dying from hunger?
public static bool KeepAlive { get { return true; } }
// if true, staff hunger/thirst will not decay below 20.
public static bool StaffImmune { get { return true; } }
public static void Initialize()
{
new FoodDecayTimer().Start();
}
public FoodDecayTimer() : base( TimeSpan.FromMinutes( 60 ), TimeSpan.FromMinutes( 60 ) )
{
this.Priority = TimerPriority.OneMinute;
}
protected override void OnTick()
{
FoodDecay();
}
public static void FoodDecay()
{
foreach ( NetState state in NetState.Instances )
{
if ( state.Mobile != null && state.Mobile.AccessLevel == AccessLevel.Player ) // Check if player
{
HungerDecay( state.Mobile );
ThirstDecay( state.Mobile );
}
}
}
public static void HungerDecay( Mobile m )
{
if ( m != null )
{
// new additions
bool keepAlive = KeepAlive; // keep player from dying from this
// bool staffImmune = StaffImmune;
if (StaffImmune && (m.AccessLevel > AccessLevel.Player) && (m.Hunger < 20))
m.Hunger = 20;
if ( m.Hunger >= 1 )
{
m.Hunger -= 1;
if (m.Hunger < 0)
{
m.SendMessage("You are starving to death.");
}
else if (m.Hunger < 5)
{
m.SendMessage("You are extremely hungry.");
}
else if (m.Hunger < 10)
{
m.SendMessage("You are getting very hungry.");
}
else if (m.Hunger < 15)
{
m.SendMessage("You are slightly hungry.");
}
}
else
{
if (m.Hits > 5)
{
m.Hits -= 2;
m.SendMessage("You are starving to death! You desperately need food.");
}
}
}
}
public static void ThirstDecay( Mobile m )
{
if ( m != null )
{
// new additions:
bool keepAlive = KeepAlive; // keep player from dying from this
// bool staffImmune = StaffImmune;
if (StaffImmune && (m.AccessLevel > AccessLevel.Player) && (m.Thirst < 20))
m.Thirst = 20;
if ( m.Thirst >= 1 )
{
m.Thirst -= 1;
if (m.Thirst < 0)
{
m.SendMessage("You are exhausted from thirst.");
}
else if (m.Thirst < 5)
{
m.SendMessage("You are extremely thirsty.");
}
else if (m.Thirst < 10)
{
m.SendMessage("You are getting thirsty.");;
}
else if (m.Thirst < 15)
{
m.SendMessage("You are slightly thirsty.");
}
}
else
{
if (m.Stam > 5)
{
m.Stam -= 2;
m.SendMessage("You are exhausted from thirst! You desperately need something to drink.");
}
}
}
}
}
}