Files
HeroesStone_PRC8/_module/nss/hc_inc_timecheck.nss
Jaysyn904 1eefc84201 Initial Commit
Initial Commit.
2025-09-14 15:40:46 -04:00

82 lines
2.6 KiB
Plaintext

// ----------------------------------------------------------------------------
// hc_inc_timecheck
// ----------------------------------------------------------------------------
/*
Common function for checking the time elapsed.
HCR 3.02 - Unresolved Issues
----------------------------
There remains a BioWare bug that means that when the game time rolls round
onto a new year it will jump to first day of the sixth month instead of the
first day of the first month.
*/
// ----------------------------------------------------------------------------
/*
HCR 3.02 - 05 August 2004 - Sunjammer
- rewritten
Credits:
- Archaegeo
*/
// ----------------------------------------------------------------------------
#include "hc_inc_pwdb_func"
// ----------------------------------------------------------------------------
// PROTOTYPES
// ----------------------------------------------------------------------------
// returns the number of seconds since the module started
int HC_GetSecondsSinceStart();
// ----------------------------------------------------------------------------
// DEPRECATED
// ----------------------------------------------------------------------------
int SecondsSinceBegin()
{
// call updated function
return HC_GetSecondsSinceStart();
}
// ----------------------------------------------------------------------------
// FUNCTIONS
// ----------------------------------------------------------------------------
int HC_GetSecondsSinceStart()
{
int nElapsed;
object oMod = GetModule();
// get start date and time
int nStartYr = HCRGetPersistentInt(oMod, "YearStart");
int nStartMn = HCRGetPersistentInt(oMod, "MonthStart");
int nStartDy = HCRGetPersistentInt(oMod, "DayStart");
int nStartHr = HCRGetPersistentInt(oMod, "HourStart");
// get current date and time
int nCurYr = GetCalendarYear();
int nCurMn = GetCalendarMonth();
int nCurDy = GetCalendarDay();
int nCurHr = GetTimeHour();
int nCurMi = GetTimeMinute();
int nCurSc = GetTimeSecond();
// get the real time to game time conversion factor (TCF)
int nTCF = FloatToInt(HoursToSeconds(1));
// calculate difference between now and then
nElapsed = nCurYr - nStartYr; // years
nElapsed = (nElapsed * 12) + (nCurMn - nStartMn); // to months
nElapsed = (nElapsed * 28) + (nCurDy - nStartDy); // to days
nElapsed = (nElapsed * 24) + (nCurHr - nStartHr); // to hours
nElapsed = (nElapsed * nTCF) + (nCurMi * 60) + nCurSc; // to seconds
// return the total
return nElapsed;
}