HoS_PRC8/_mod/_module/nss/timelimit_hb.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

118 lines
3.4 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// timelimit_hb - to handle game time limit stuff
// By Deva Bryson Winblood. 03/06/2005
////////////////////////////////////////////////////////////////////////////////
#include "antistuck_h"
void fnDoHolocaust();
void main()
{
object oMod=GetModule();
int nLimit=GetLocalInt(oMod,"nTimeLimitDays");
int nDay=GetLocalInt(oMod,"nTLLastDay");
int nHour=GetLocalInt(oMod,"nTLLastHour");
int nHolocaustCD=GetLocalInt(oMod,"nTLHolocaustCountdown");
int bHolocaustMode=GetLocalInt(oMod,"bHolocaustEnabled");
int bHolocaustActive=GetLocalInt(oMod,"bHolocaustActive");
int nCHour=GetTimeHour();
int nCDay=GetCalendarDay();
int nHoursLeft=GetLocalInt(oMod,"nTLHoloHoursLeft");
if (nDay==0) { nDay=1; SetLocalInt(oMod,"nTLLastDay",1); }
if (bHolocaustActive)
{ // holocaust mode
if (nHour!=nCHour)
{ // hour changed
nHoursLeft=nHoursLeft-1;
SetLocalInt(oMod,"nTLHoloHoursLeft",nHoursLeft);
if (nHoursLeft==0) ExecuteScript("rts_end_game",OBJECT_SELF);
else { fnDoHolocaust(); }
} // hour changed
} // holocaust mode
else
{ // normal mode
if (nCDay!=nDay)
{ // day has changed
SetLocalInt(oMod,"nTLLastDay",nCDay);
nLimit=nLimit-1;
SetLocalInt(oMod,"nTimeLimitDays",nLimit);
if (nLimit<1)
{ // time limit reached
if (bHolocaustMode)
{ // activate holocaust
SetLocalInt(oMod,"bHolocaustActive",TRUE);
SetLocalInt(oMod,"nTLHoloHoursLeft",15);
} // activate holocaust
else
{ // end game
ExecuteScript("rts_end_game",OBJECT_SELF);
} // end game
} // time limit reached
} // day has changed
} // normal mode
}
void fnBehavior()
{ // PURPOSE: move the AI
object oMe=OBJECT_SELF;
object oDest;
int nR;
if (!GetIsInCombat(oMe)&&!IsInConversation(oMe))
{ // choose action
nR=d4();
if (nR==1)
{ // move
oDest=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,d20());
AssignCommand(oMe,ASActionMoveToObject(oDest,FALSE,1.0));
} // move
} // choose action
DelayCommand(12.0,fnBehavior());
} // fnBehavior()
string fnGetResRef()
{ // PURPOSE: give a planar resref
string sRet;
int nR=d100();
if (nR<16) sRet="githyankiwarrior";
else if (nR<21) sRet="githyankigith";
else if (nR<31) sRet="movanicdeva";
else if (nR<36) sRet="astraldeva";
else if (nR<51) sRet="bonedevil";
else if (nR<56) sRet="gelugon";
else if (nR<61) sRet="devil002";
else if (nR<71) sRet="dmsucubus001";
else if (nR<76) sRet="dmvrock001";
else if (nR<81) sRet="demon001";
else if (nR<91) sRet="slaadred001";
else if (nR<93) sRet="nightwalker";
else if (nR<95) sRet="slaadgrn001";
else if (nR<97) sRet="slaaddeth001";
else if (nR<100) sRet="slaadwhite002";
else if (nR==100) sRet="slaadblack002";
return sRet;
} // fnGetResRef()
void fnDoHolocaust()
{ // PURPOSE: spawn creatures
object oWP;
int nR;
object oCreature;
string sResRef;
int nN;
int nC;
nN=1;
while(nN<12)
{ // spawn 12 creatures
sResRef=fnGetResRef();
nR=d100();
oWP=GetWaypointByTag("RL_"+IntToString(nR));
oCreature=CreateObject(OBJECT_TYPE_CREATURE,sResRef,GetLocation(oWP));
if (oCreature!=OBJECT_INVALID) DelayCommand(1.0,AssignCommand(oCreature,fnBehavior()));
nN++;
} // spawn 12 creatures
} // fnDoHolocaust()