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

90 lines
3.0 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// dr_op_random - Open Door to random houses
// By Deva B. Winblood. October 27th, 2008.
////////////////////////////////////////////////////////////////////////////////
/*
int nTypeP1 - nTypeP4 = percentage of type
string sDirection = Direction heading
*/
//////////////////////////////////////////////////////////////[ MAIN ]//////////
void main()
{
object oDoor=OBJECT_SELF;
object oPC=GetLastOpenedBy();
int nType=GetLocalInt(oDoor,"nType");
string sDirection=GetLocalString(oDoor,"sDirection");
int nStyle=GetLocalInt(oDoor,"nStyle");
object oDest;
if (nType<1)
{ // define door type
int nR=d100();
nR=nR-GetLocalInt(oDoor,"nTypeP1");
if (nR<1) nType=1;
else
{ // other types
nR=nR-GetLocalInt(oDoor,"nTypeP2");
if (nR<1) nType=2;
else
{ // other types
nR=nR-GetLocalInt(oDoor,"nTypeP3");
if (nR<1) nType=3;
else { nType=4; }
} // other types
} // other types
SetLocalInt(oDoor,"nType",nType);
nR=d100();
if (nR<21) nStyle=1;
else if (nR<36) nStyle=2;
else if (nR<51) nStyle=3;
else if (nR<61) nStyle=4;
else if (nR<64) nStyle=5;
else if (nR<66) nStyle=6;
else if (nR<68) nStyle=7;
else if (nR<69) nStyle=8;
else if (nR<72) nStyle=9;
else if (nR<74) nStyle=10;
else if (nR<79) nStyle=11;
else if (nR<82) nStyle=12;
else if (nR<84) nStyle=13;
else if (nR<89) nStyle=14;
else if (nR<94) nStyle=15;
else if (nR<96) nStyle=16;
else if (nR<98) nStyle=17;
else { nStyle=18; }
SetLocalInt(oDoor,"nStyle",nStyle);
} // define door type
oDest=GetLocalObject(oDoor,"oDest");
if (!GetIsObjectValid(oDest)) oDest=GetWaypointByTag("AREA_HOUSE"+sDirection+IntToString(nType));
if (GetIsObjectValid(oDest))
{ // defined
SetLocalObject(oDoor,"oDest",oDest);
object oExit=GetLocalObject(oDest,"oExit");
if (GetIsObjectValid(oExit)&&oExit!=oDoor)
{ // in use by other
FloatingTextStringOnCreature("** Wait a few moments and then try again. **",oPC,FALSE);
AssignCommand(oPC,ClearAllActions());
AssignCommand(oDoor,ActionCloseDoor(oDoor));
} // in use by other
else
{ // auto close
DelayCommand(10.0,AssignCommand(oDoor,ActionCloseDoor(oDoor)));
} // auto close
} // defined
else
{ // error
PrintString("ERROR: dr_op_random : Cannot find waypoint AREA_HOUSE"+sDirection+IntToString(nType));
SendMessageToPC(oPC,"ERROR: dr_op_random : Cannot find waypoint AREA_HOUSE"+sDirection+IntToString(nType));
AssignCommand(oDoor,ActionCloseDoor(oDoor));
DeleteLocalInt(oDoor,"nType");
DeleteLocalInt(oDoor,"nStyle");
} // error
}
//////////////////////////////////////////////////////////////[ MAIN ]//////////