// Global values
// values per meal or drink
// Hourly
$DRINK = 0.01389; // 1 / (3 * 24); // 72 hours , 3 days
$MEAL = 0.00595; // 1 / (7 * 24); // 168 hours , 7 days
$WARMTH= 0.033; // 1 / (3); // 3 hours ? was 0.33
// Per Minute
$THIRST = 0.000231; //$DRINK / 60;
$HUNGER = 0.000099; //$MEAL / 60;
$HEAT = $WARMTH / 60; // 0.005556;
// hard coded to reduce the floating point sizes
// default values used to determine Heat based off of time
$SUNRISE = 0.05;
$MIDDAY = 0.25;
$SUNSET = 0.48;
$MSG_DELAY = 5;// default 5s
$MSG_SIZE = 1; // default 1
// globals to keep track of scheduled tasks
//$tempCheckId = 0;
//$thirstCheckId = 0;
//$hungerCheckId = 0;
function statusHunger( %value )
{
%msg = "";
%value = %value * 100; // precentage
// determine the current state
if ( %value < 20)
{
%Status = 0; //
%msg = "";
}
else if ( %value <= 40 )
{
%Status = 1; //
%msg = "hunger pains";
}
else if ( %value <= 60)
{
%Status = 2; //
%msg = "severe hunger";
}
else if ( %value <= 80)
{
%Status = 3; //
%msg = "extreme hunger";
}
else // greater than 80
{
%Status = 4; //
%msg = "starvation";
}
return %msg;
}
function hungerCheck()
{
// give player some feedback
%oldStatus = statusHunger(Hunger.GetValue()); // ok, dehydrated, severe dehydration, extreme dehydration.
// you are feeling hungry
changeBar("HungerBar", $MEAL * $Game::speed);
%newStatus = statusHunger(Hunger.GetValue()); // ok, dehydrated, severe dehydration, extreme dehydration.
echo("Hunger " SPC %oldStatus SPC %newStatus );
if (%oldStatus !$= %newStatus)
clientCmdBottomPrint("You are suffering from " @ %newStatus,$MSG_DELAY,$MSG_SIZE);
// wait 60 second RT ~ 1 HOUR in GT
$hungerCheckId = schedule(60000,0,"hungerCheck"); // 1000 = 1 sec RT = 1 min game time
echo("+ + hungerCheckId = "@ $hungerCheckId @ " + + ");
}
function statusThirst( %value )
{
%msg = "";
%value = %value * 100;// precentage
// determine the current state
if ( %value < 25)
{
%Status = 0; //
%msg = "";
}
else if ( %value <= 50)
{
%Status = 1; //
%msg = "minor dehydration";
}
else if ( %value <= 75)
{
%Status = 1; //
%msg = "severe dehydration";
}
else // greater than 75
{
%Status = 1; //
%msg = "extreme dehydration";
}
return %msg;
}
function thirstCheck()
{
// you are feeling thirsty
// since we check every 5 minutes
// need to multiply the per minute value
%dmg = 5 * $THIRST * $Game::speed;
%orig = %dmg;
if (Heat.GetValue() >= 0.70)
{
// increase thirst factor by 25% due to increased heat & water loss
%mult = 1 - Heat.GetValue() ; // 0 to 5
%mult = 10 * (0.5 - %mult); // reverse it ... .3 = x2, 0 = x5
%dmg = %dmg * %mult; // 1.5 to 5 x
%message = "Your body is loosing more water than usual due to the excessive heat (x" @ %mult @ ")" ;
clientCmdCenterPrint(%message,3,1);
}
// give player some feedback
%oldStatus = statusThirst(Thirst.GetValue()); // ok, dehydrated, severe dehydration, extreme dehydration.
changeBar("ThirstBar", %dmg);
%newStatus = statusThirst(Thirst.GetValue()); // ok, dehydrated, severe dehydration, extreme dehydration.
echo("thirst " SPC %oldStatus SPC %newStatus );
if (%oldStatus !$= %newStatus)
clientCmdBottomPrint("You are suffering from " @ %newStatus,$MSG_DELAY,$MSG_SIZE);
// wait 5 second RT ~ 5 minute GT
$thirstCheckId = schedule(5000,0,"thirstCheck"); // 1000 = 1 sec RT = 1 min game time
echo("+ + thirstCheckId = "@ $thirstCheckId @ " + + ");
}
function statusHeat( %value )
{
%msg = "";
%value = %value * 100;// precentage
// determine the current state
if ( %value < 25)
{
%Status = 0; //
%msg = "freezing cold ... possibly frostbite";
}
else if ( %value <= 40 )
{
%Status = 1; //
%msg = "cold";
}
else if ( %value <= 60 )
{
%Status = 2; // ok
%msg = "";
}
else if ( %value <= 80)
{
%Status = 3; //
%msg = "heat";
}
else // greater than 75
{
%Status = 4; //
%msg = "heat exhaustion";
}
return %msg;
}
function heatCheck()
{
// day time, gain heat
if ((DayNightCycle
.time > $SUNRISE) && (DayNightCycle
.time < $SUNSET))
{
echo("survivalCheck() : is Daytime");
%heatFactor = $HEAT;
if ((DayNightCycle
.time > ($MIDDAY - 0.10)) && (DayNightCycle
.time < ($MIDDAY + 0.10)))
{
echo("survivalCheck() : and it is Mid-Day (hottest part of day)");
%heatFactor = $HEAT*2;
// hottest part of the day
}
}
else
{
echo("survivalCheck() : is Night");
// night time - loose heat
%heatFactor = - $HEAT;
}
// give player some feedback
%oldStatus = statusHeat(Heat.GetValue()); // ok, dehydrated, severe dehydration, extreme dehydration.
changeBar("HeatBar", %heatFactor * $Game::speed);
%newStatus = statusHeat(Heat.GetValue()); // ok, dehydrated, severe dehydration, extreme dehydration.
echo("Heat " SPC Heat.GetValue() SPC $oldStatus @ " -> " @ %newStatus );
if (%oldStatus !$= %newStatus)
clientCmdBottomPrint("You are suffering from " @ %newStatus, $MSG_DELAY,$MSG_SIZE);
// wait 1 second RT ~ 1 minute GT
$tempCheckId = schedule(1000,0,"heatCheck"); // 1000 = 1 sec RT = 1 min game time
echo("+ + tempCheckId = "@ $tempCheckId @ " + + ");
}
function survivalCheck()
{
// cancel any scheduled checks
if (IsEventPending($tempCheckId))
cancel($tempCheckId);
if (IsEventPending($thirstCheckId))
cancel($thirstCheckId);
if (IsEventPending($hungerCheckId))
cancel($hungerCheckId);
// only called once
// then respawn at thier own intervals
hungerCheck();
thirstCheck();
heatCheck();
}
//determine hourLength
function logTimeofDay()
{
echo("+ + logTimeofDay + + id("@$timeLogId@")");
%minutes
= RoundDown
(DayNightCycle
.time * 1440);
%time_hr = RoundDown(%minutes / 60);
%time_mn = %minutes % 60; // remainder after division
echo("GMT time is "@ %time_hr @ ":" @ %time_mn);
lblTime.setValue(%time_hr @ ":" @ %time_mn);
echo("Time of Day="@DayNightCycle
.time);
$timeLogId = schedule(1000,0,"logTimeofDay");
}