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

83 lines
3.7 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// area_hb_randomhs - Random House
// By Deva B. Winblood. October 27th, 2008
////////////////////////////////////////////////////////////////////////////////
#include "lib_inc_randoms"
///////////////////////////////////////////////////////////[ MAIN ]/////////////
void main()
{
object oArea=OBJECT_SELF;
string sTag=GetTag(oArea);
object oWP=GetWaypointByTag("AREA_"+sTag);
object oPC=GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,oWP,1);
if (GetIsObjectValid(oPC))
{ // PC exists
DeleteLocalInt(oWP,"bReadyToReset");
} // PC exists
else
{ // No PCs
object oExit=GetLocalObject(oWP,"oExit");
if (GetIsObjectValid(oExit))
{ // exit in play
if (GetLocalInt(oWP,"bReadyToReset"))
{ // reset okay
int nStorageID=RND_GetStorageID(oExit);
DeleteLocalObject(oWP,"oExit");
DeleteLocalInt(oWP,"bReadyToReset");
DeleteLocalInt(oWP,"nStyle");
object oOb;
int nN=1;
int nCount=0;
oOb=GetNearestObject(OBJECT_TYPE_PLACEABLE,oWP,nN);
while(GetIsObjectValid(oOb))
{ // destroy placeables
DelayCommand(0.5,DestroyObject(oOb));
RND_SetStoredString(nStorageID,"sPRR_"+IntToString(nN),GetResRef(oOb));
RND_SetStoredString(nStorageID,"sPN_"+IntToString(nN),GetName(oOb));
RND_SetStoredLocation(nStorageID,"lPL_"+IntToString(nN),GetLocation(oOb));
nCount++;
nN++;
oOb=GetNearestObject(OBJECT_TYPE_PLACEABLE,oWP,nN);
} // destroy placeables
RND_SetStoredInt(nStorageID,"nPlaceables",nCount);
nN=1;
nCount=0;
oOb=GetNearestObject(OBJECT_TYPE_ITEM,oWP,nN);
while(GetIsObjectValid(oOb))
{ // destroy items
if (!GetPlotFlag(oOb)) DelayCommand(0.5,DestroyObject(oOb));
RND_SetStoredString(nStorageID,"sIRR_"+IntToString(nN),GetResRef(oOb));
RND_SetStoredString(nStorageID,"sIN_"+IntToString(nN),GetName(oOb));
RND_SetStoredLocation(nStorageID,"lIL_"+IntToString(nN),GetLocation(oOb));
nCount++;
nN++;
oOb=GetNearestObject(OBJECT_TYPE_ITEM,oWP,nN);
} // destroy items
RND_SetStoredInt(nStorageID,"nItems",nCount);
nN=1;
nCount=0;
oOb=GetNearestObject(OBJECT_TYPE_CREATURE,oWP,nN);
while(GetIsObjectValid(oOb))
{ // destroy creatures
DelayCommand(0.3,DestroyObject(oOb));
RND_SetStoredString(nStorageID,"sCRR_"+IntToString(nN),GetResRef(oOb));
RND_SetStoredString(nStorageID,"sCN_"+IntToString(nN),GetName(oOb));
RND_SetStoredLocation(nStorageID,"lCL_"+IntToString(nN),GetLocation(oOb));
nCount++;
nN++;
oOb=GetNearestObject(OBJECT_TYPE_CREATURE,oWP,nN);
} // destroy creatures
RND_SetStoredInt(nStorageID,"nCreatures",nCount);
} // reset okay
else
{ // prep for reset
SetLocalInt(oWP,"bReadyToReset",TRUE);
DelayCommand(3.0,ExecuteScript("area_hb_randomhs",oArea));
} // prep for reset
} // exit in play
} // No PCs
}
///////////////////////////////////////////////////////////[ MAIN ]/////////////