Torch burnout
From NWNWiki
[edit] Torch Burnout
[edit] Note
This script will not function on torches created by the starting inventory scripts (newbie items), and/or torches with a ResRef different from the default created torch script, which is "nw_it_torch001".
[edit] The Script
This script should be placeed in the module heartbeat. What it basically does is look to see if a PC has a torch equiped if so it increments a local variable stored in the PC when it reaches a target number it unequips and destroys the torch that is equiped. This simulates the PC using the same torch until it expires.
void main()
{
object oPC = GetFirstPC();
int iTorch = GetLocalInt(oPC,"Torch");
object oItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND ,oPC);
while (oPC != OBJECT_INVALID)
{
if (GetResRef(oItem)=="nw_it_torch001")
{
if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
iTorch = 1000;
else
iTorch = iTorch+1;
if (iTorch >= 10) //Set to 600 for 1 hour a real time game
// (must be adjusted to your time set)
{
AssignCommand(oPC,ActionUnequipItem (oItem));
DestroyObject(oItem);
SetLocalInt(oPC,"Torch",0);
}
else
SetLocalInt(oPC,"Torch",iTorch);
}
oPC = GetNextPC();
}
}
