54 lines
1.5 KiB
Plaintext
54 lines
1.5 KiB
Plaintext
|
void SetTimeStamp(object oWho,string sPref)
|
||
|
{
|
||
|
SetLocalInt(oWho,sPref+"_s",GetTimeSecond());
|
||
|
SetLocalInt(oWho,sPref+"_m",GetTimeMinute());
|
||
|
SetLocalInt(oWho,sPref+"_h",GetTimeHour());
|
||
|
SetLocalInt(oWho,sPref+"_d",GetCalendarDay());
|
||
|
SetLocalInt(oWho,sPref+"_mm",GetCalendarMonth());
|
||
|
SetLocalInt(oWho,sPref+"_y",GetCalendarYear());
|
||
|
}
|
||
|
|
||
|
int SecondsPassed(object oWho,string sPref)
|
||
|
{
|
||
|
int iPassed;
|
||
|
|
||
|
iPassed = GetTimeSecond() - GetLocalInt(oWho,sPref+"_s");
|
||
|
iPassed += (GetTimeMinute() - GetLocalInt(oWho,sPref+"_m")) * 60;
|
||
|
iPassed += (GetTimeHour() - GetLocalInt(oWho,sPref+"_h")) * 3600;
|
||
|
iPassed += (GetCalendarDay() - GetLocalInt(oWho,sPref+"_d")) * 86400;
|
||
|
iPassed += (GetCalendarMonth() - GetLocalInt(oWho,sPref+"_mm")) * 2678400;
|
||
|
iPassed += (GetCalendarYear() - GetLocalInt(oWho,sPref+"_y")) * 32140800;
|
||
|
|
||
|
return iPassed;
|
||
|
}
|
||
|
|
||
|
void SetLocalDecay(object oWho,string sVarname,int iValue,int iDecPerHour)
|
||
|
{
|
||
|
SetTimeStamp(oWho,sVarname);
|
||
|
SetLocalInt(oWho,sVarname+"_val",iValue);
|
||
|
SetLocalInt(oWho,sVarname+"_dec",iDecPerHour);
|
||
|
}
|
||
|
|
||
|
int GetLocalDecay(object oWho,string sVarname)
|
||
|
{
|
||
|
int iSet, iDec, iActual, iPassed;
|
||
|
|
||
|
if(!GetLocalInt(oWho,sVarname+"_y")) return 0;
|
||
|
|
||
|
iPassed = SecondsPassed(oWho,sVarname);
|
||
|
|
||
|
iSet = GetLocalInt(oWho,sVarname+"_val");
|
||
|
iDec = GetLocalInt(oWho,sVarname+"_dec");
|
||
|
|
||
|
iActual = iSet - (iPassed * iDec) / 3600;
|
||
|
if(iActual < 0) iActual = 0;
|
||
|
return iActual;
|
||
|
}
|
||
|
|
||
|
int GetLocalDecrate(object oWho,string sVarname)
|
||
|
{
|
||
|
return GetLocalInt(oWho,sVarname+"_dec");
|
||
|
}
|
||
|
|
||
|
|