generated from Jaysyn/ModuleTemplate
Initial Commit
Initial Commit.
This commit is contained in:
51
_module/nss/torch_timer.nss
Normal file
51
_module/nss/torch_timer.nss
Normal file
@@ -0,0 +1,51 @@
|
||||
/*Original author: Elidrin, to whom I am most grateful
|
||||
My own contributions are minimal:
|
||||
Customized torch life by changing the int on line 15; added a
|
||||
warning of impending darkness when only 30 seconds remain;
|
||||
added string-check function "TorchCheck" to apply limited life
|
||||
to any item with tag containing the word "torch."
|
||||
*/
|
||||
|
||||
int TorchCheck (object oPC);
|
||||
|
||||
void main()
|
||||
{
|
||||
object oPC = GetFirstPC();
|
||||
int iTorch = GetLocalInt(oPC,"Torch");
|
||||
object oItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND ,oPC);
|
||||
int nLife = 5; //Enter the number of minutes of torch life
|
||||
while (oPC != OBJECT_INVALID)
|
||||
{
|
||||
if (TorchCheck(oPC) >= 0)
|
||||
{
|
||||
if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
|
||||
iTorch = 1000;
|
||||
else
|
||||
iTorch = iTorch+1;
|
||||
|
||||
//Send a warning at 30 seconds to go...
|
||||
if (iTorch == ((nLife * 10) - 5))
|
||||
SendMessageToPC(oPC,"Your torch is beginning to flicker and fade.");
|
||||
//Make it go out
|
||||
if (iTorch >= (nLife * 10))
|
||||
{
|
||||
AssignCommand(oPC,ActionUnequipItem(oItem));
|
||||
DestroyObject(oItem);
|
||||
SendMessageToPC(oPC,"Your torch has burned out.");
|
||||
SetLocalInt(oPC,"Torch",0);
|
||||
}
|
||||
else
|
||||
SetLocalInt(oPC,"Torch",iTorch);
|
||||
}
|
||||
oPC = GetNextPC();
|
||||
}
|
||||
}
|
||||
|
||||
int TorchCheck (object oPC)
|
||||
{
|
||||
int nTCheck;
|
||||
string sTag = GetTag(GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC));
|
||||
string sTagLow = GetStringLowerCase(sTag);
|
||||
nTCheck = FindSubString(sTagLow,"torch");
|
||||
return nTCheck;
|
||||
}
|
||||
Reference in New Issue
Block a user