swwmgz_m/zscript/kbase/swwm_kbase_priv.zsc
Marisa the Magician 2aa0ea4680 More work towards Legacy of Rust support (with caveats).
As of this commit, do not consider the experience when playing that new
expansion to be complete. I've only partially written some of the mission texts
and rudimentarily enhanced some boss fights.

Currently there is one major limitation in that the intermission texts cannot
be replaced, as they're hardcoded inside the UMAPINFO. I don't know if I can
work around that.
2025-08-20 16:47:24 +02:00

190 lines
3.7 KiB
Text

// kbase private functions
extend Class DemolitionistMenu
{
// initialize the crime clock
static void SetClock( int &c_year, int &c_month, int &c_day, int &c_hour, int &c_minute, String &c_tz )
{
// use mission log clock if available
let mlog = SWWMMissionLog.Get();
if ( mlog && mlog.clockset )
{
c_year = mlog.year;
c_month = mlog.month;
c_day = mlog.day;
c_hour = mlog.hour;
c_minute = mlog.minute;
c_tz = mlog.tz;
}
else if ( gameinfo.gametype&GAME_Heretic )
{
// April 10th 2171, 17:34 JST
// Epoch: 6351554040
c_year = 2171;
c_month = 3;
c_day = 9;
c_hour = 17;
c_minute = 34;
c_tz = "JST";
}
else if ( gameinfo.gametype&GAME_Hexen )
{
// May 25th 2171, 16:41 JST
// Epoch: 6355438860
c_year = 2171;
c_month = 4;
c_day = 24;
c_hour = 16;
c_minute = 41;
c_tz = "JST";
if ( SWWMUtility.IsDeathkings() )
{
// deathkings happen the day after
c_day = 25;
c_hour = 10;
c_minute = 28;
}
}
else if ( SWWMUtility.IsEviternity() )
{
// June 10th 2150, 20:09 +09
// (June 10th 2150, 20:09 JST)
// Epoch: 5694145740
c_year = 2150;
c_month = 5;
c_day = 9;
c_hour = 20;
c_minute = 9;
c_tz = "+09";
}
else if ( SWWMUtility.IsEviternityTwo() )
{
// June 11th 2150, 04:09 +09
// (June 11th 2150, 04:09 JST)
// Epoch: 5694174540
c_year = 2150;
c_month = 5;
c_day = 10;
c_hour = 4;
c_minute = 9;
c_tz = "+09";
}
else if ( SWWMUtility.IsLegacyOfRust() )
{
// August 8th 2150, 02:31 EDT
// (August 8th 2150, 11:31 JST)
c_year = 2150;
c_month = 7;
c_day = 7;
c_hour = 2;
c_minute = 31;
c_tz = "EDT";
}
else // Doom
{
// June 6th 2148, 18:37 EDT
// (June 7th 2148, 07:37 JST)
// Epoch: 5630769420
c_year = 2148;
c_month = 5;
c_day = 5;
c_hour = 18;
c_minute = 37;
c_tz = "EDT";
if ( SWWMUtility.IsKnownMap() && (level.cluster == 11) )
{
// NRFTL just happens the next day after
c_day = 6;
c_hour = 15;
c_minute = 48;
}
}
}
// please don't look at this
static String CrimeTime( int c_year, int c_month, int c_day, int c_hour, int c_minute, String c_tz, bool shortform = false )
{
// we have to do things this way because dates in this mod go beyond 32-bit unix time
static const int days_in_month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool leap_year;
int y = c_year, m = c_month, d = c_day, h = c_hour, mn = c_minute;
int addtime = level.totaltime/GameTicRate;
while ( addtime > 0 )
{
leap_year = (!(y%4) && ((y%100) || !(y%400)));
if ( addtime >= 86400 )
{
addtime -= 86400;
d++;
int md = days_in_month[m];
if ( leap_year && (m == 1) ) md++;
if ( d >= md )
{
d = 0;
m++;
if ( m > 11 )
{
m = 0;
y++;
}
}
}
else if ( addtime >= 3600 )
{
addtime -= 3600;
h++;
if ( h > 23 )
{
h = 0;
d++;
int md = days_in_month[m];
if ( leap_year && (m == 1) ) md++;
if ( d >= md )
{
d = 0;
m++;
if ( m > 11 )
{
m = 0;
y++;
}
}
}
}
else if ( addtime >= 60 )
{
addtime -= 60;
mn++;
if ( mn > 59 )
{
mn = 0;
h++;
if ( h > 23 )
{
h = 0;
d++;
int md = days_in_month[m];
if ( leap_year && (m == 1) ) md++;
if ( d >= md )
{
d = 0;
m++;
if ( m > 11 )
{
m = 0;
y++;
}
}
}
}
}
else
{
// we finished counting
addtime = 0;
}
}
if ( shortform ) return String.Format("%02d:%02d",h,mn);
return String.Format("%04d-%02d-%02d %02d:%02d %s",y,m+1,d+1,h,mn,c_tz);
}
}