Alangara_PRC8/_module/nss/eds_include.nss
Jaysyn904 86feb9ca6f Initial commit
Initial commit.
2024-06-05 21:21:06 -04:00

76 lines
3.0 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name: eds_include
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
ENHANCED DELAY SYSTEM -
Version: 1.0
This system was developed, in part, to allow
for long delays without the lag and CPU
usage associated with the DelayCommand
function. Basically, this script creates
a timestamp of the current time of the
delay, plus the delay itself. Then, when
the check delay function is called, it
computes the current time with when the
delay should end. If the current time >=
to the original timestamp, the delay has
passed.
Note: This is a check-based system, and is
not real-time. The normal DelayCommand
function will perform actions as soon
as the delay is finished. With this
system, actions are performed after a
check has been made to see if the delay
has finished. This system is not meant
to completely replace the DelayCommand,
only where it's use is not needed.
For a clear example on how to implement this
system, refer to the test module included
in the download package.
The following variable needs to be defined to
properly calculate delays using this system.
Module Properties -> Advanced -> Minutes/Hour
value.
*/
//:://////////////////////////////////////////////
//:: Created By: Adam Walenga
//:: Created On: September 9th, 2004
//:://////////////////////////////////////////////
#include "farm_config"
//EDS_SetDelay -
//Sets a new delay for the specified object.
// oObject: This is the object used to store the delay.
// sVar: This is the variable name to refer to the delay with.
// fDelay: This is the delay to apply.
void EDS_SetDelay (object oObject, string sVar, float fDelay)
{
//=========================== CALCULATE TIME =========================\\
int iTotal = (GetCalendarMonth() * 2592000) + (GetCalendarDay() * 86400) +
(GetTimeHour() * (MINUTES_PER_HOUR * 60)) + (GetTimeMinute() * 60) +
GetTimeSecond() + FloatToInt (fDelay);
//======================= STORE TIME VARIABLES =======================\\
SetLocalInt (oObject, sVar + "_Year", GetCalendarYear());
SetLocalInt (oObject, sVar + "_Time", iTotal);
}
//EDS_CheckDelay -
//Checks the current delay, and returns TRUE or FALSE based on whether or not
//the delay time has passed.
// oObject: This is the object with the stored delay saved to it.
// sVar: This is the variable name for the specific delay.
int EDS_CheckDelay (object oObject, string sVar)
{
//=========================== CALCULATE TIME =========================\\
int iTotal = ((GetCalendarYear() - GetLocalInt (oObject, sVar + "_Year")) *
31104000) + (GetCalendarMonth() * 2592000) + (GetCalendarDay() *
86400) + (GetTimeHour() * (MINUTES_PER_HOUR * 60)) + (GetTimeMinute() * 60) + GetTimeSecond();
return (iTotal >= GetLocalInt (oObject, sVar + "_Time"));
}