Rune_PRC8/_module/nss/x0_o2_anyuniq.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

147 lines
4.9 KiB
Plaintext

//::///////////////////////////////////////////////////
//:: X0_O2_ANYUNIQ.NSS
//:: OnOpened/OnDeath script for a treasure container.
//:: Treasure type: Any, random selection from whatever is in base container
//:: Treasure level: TREASURE_TYPE_UNIQUE
//::
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 11/21/2002
//::///////////////////////////////////////////////////
#include "x0_i0_treasure"
int iLocked =GetLocalInt(OBJECT_SELF, "iLocked");
int iLockDC =GetLocalInt(OBJECT_SELF, "iLockDC");
int iLockUnlockDC =GetLocalInt(OBJECT_SELF, "iLockUnlockDC");
int iLockKeyRequired =GetLocalInt(OBJECT_SELF, "iLockKeyRequired");
int iLockLockable=GetLocalInt(OBJECT_SELF, "iLockLockable");
string sLockKeyTag =GetLocalString(OBJECT_SELF, "sLockKeyTag");
int iIsTrapped = GetLocalInt(OBJECT_SELF, "iIsTrapped");
int iTrapActive = GetLocalInt(OBJECT_SELF, "iTrapActive");
int iTrapBaseType = GetLocalInt(OBJECT_SELF, "iTrapBaseType");
int iTrapDetectable = GetLocalInt(OBJECT_SELF, "iTrapDetectable");
int iTrapDetectDC = GetLocalInt(OBJECT_SELF, "iTrapDetectDC");
int iTrapDisarmable = GetLocalInt(OBJECT_SELF, "iTrapDisarmable");
int iTrapDisarmDC = GetLocalInt(OBJECT_SELF, "iTrapDisarmDC");
string sTrapKeyTag = GetLocalString(OBJECT_SELF, "sTrapKeyTag");
int iTrapOneShot = GetLocalInt(OBJECT_SELF, "iTrapOneShot");
int iTrapRecoverable = GetLocalInt(OBJECT_SELF, "iTrapRecoverable");
void ResetLockTrapInfo(object oObject)
{
SetLocked(oObject, iLocked);
SetLockLockDC(oObject, iLockDC);
SetLockUnlockDC(oObject, iLockUnlockDC);
SetLockKeyRequired(oObject, iLockKeyRequired);
SetLockKeyTag(oObject, sLockKeyTag);
SetLockLockable(oObject, iLockLockable);
if (iIsTrapped = TRUE)CreateTrapOnObject(iTrapBaseType, oObject);
SetTrapActive(oObject, iTrapActive);
SetTrapDetectable(oObject, iTrapDetectable);
SetTrapDetectDC(oObject, iTrapDetectDC);
SetTrapDetectDC(oObject, iTrapDetectDC);
SetTrapDisarmable(oObject, iTrapDisarmable);
SetTrapDisarmDC(oObject, iTrapDisarmDC);
SetTrapKeyTag(oObject, sTrapKeyTag);
SetTrapOneShot(oObject, iTrapOneShot);
SetTrapRecoverable(oObject, iTrapRecoverable);
}
void RespawnPLC(string sResRef, location lLocation, float fdelay, object oWaypoint)
{
object oObject = CreateObject(OBJECT_TYPE_PLACEABLE, sResRef, lLocation);
int nPCsStored = GetLocalInt(oWaypoint, "nPCsStored");
SetLocalInt(oObject, "nPCsStored", nPCsStored);
int nCount = 1;
while (nCount <= nPCsStored)
{
string sVarName = "oLooter" + IntToString(nCount);
SetLocalObject(oObject, sVarName, GetLocalObject(oWaypoint, sVarName));
nCount = nCount + 1;
}
DestroyObject(oWaypoint);
ResetLockTrapInfo(oObject);
ExecuteScript("ethsetuplocktrap", oObject);
SetLocalFloat(oObject, "fRespawnRate", fdelay);
return;
}
void main()
{
int nValidLooter = TRUE;
object oObject = OBJECT_SELF;
location lObject = GetLocation(OBJECT_SELF);
string sResRefObject = GetResRef(OBJECT_SELF);
string sTagObject = GetTag(OBJECT_SELF);
float fdelay = GetLocalFloat(OBJECT_SELF, "fRespawnRate");
if (FloatToInt(fdelay) == 0) fdelay = 3600.0;
int nPCsStored = GetLocalInt(OBJECT_SELF, "nPCsStored");
object oPC;
if (GetCurrentHitPoints(OBJECT_SELF) > 0)
{
oPC = GetLastOpenedBy();
}
else
{
oPC = GetLastKiller();
}
int nCount = 1;
while (nCount <= nPCsStored)
{
object oLooter = GetLocalObject(OBJECT_SELF, "oLooter" + IntToString(nCount));
if (oLooter == oPC)
nValidLooter = FALSE;
nCount = nCount + 1;
}
if (GetCurrentHitPoints(OBJECT_SELF) > 0)
{
if (!GetLocalInt(OBJECT_SELF, "ntimecheck") == 1 && nValidLooter == TRUE)
{
DelayCommand(fdelay, CTG_SetIsTreasureGenerated(OBJECT_SELF, FALSE));
SetLocalInt(OBJECT_SELF, "ntimecheck", 1);
DelayCommand(fdelay, SetLocalInt(OBJECT_SELF, "ntimecheck", 0));
DelayCommand(fdelay, ResetLockTrapInfo(OBJECT_SELF));
}
}
else
{
object oWaypoint = CreateObject(OBJECT_TYPE_WAYPOINT, "waypoint", lObject, FALSE, "WP_" + GetTag(OBJECT_SELF));
nCount = 1;
SetLocalInt(oWaypoint, "nPCsStored", nPCsStored);
while (nCount <= nPCsStored)
{
object oLooter = GetLocalObject(OBJECT_SELF, "oLooter" + IntToString(nCount));
SetLocalObject(oWaypoint, "oLooter" + IntToString(nCount), oLooter);
nCount = nCount +1;
}
AssignCommand(GetArea(OBJECT_SELF), DelayCommand(fdelay, RespawnPLC(sResRefObject, lObject, fdelay, oWaypoint)));
}
if (nValidLooter == TRUE)
{
nPCsStored = nPCsStored + 1;
SetLocalInt(OBJECT_SELF, "nPCsStored", nPCsStored);
SetLocalObject(OBJECT_SELF, "oLooter" + IntToString(nPCsStored), oPC);
CTG_CreateTreasure(TREASURE_TYPE_UNIQUE, GetLastOpener(), OBJECT_SELF);
}
}