Auto Equip Torch

What It Does

Guard equips / unequips a torch based on day/night check.

In the onHeartBeat event the guard (or any NPC) will do a GetIsDay () / GetIsDawn check. If day then they will unequip the torch (if they are currently using one) and reequip what they were using before the torch (if they were using something in their offhand).

Similarily if it is dark then they will unequip the item in their offhand and equip a torch and also remember what they were using in their offhand for when day break comes.


I have not figured out how to make the little scrolly window appear with the code inside yet. Will update when I figure it out.

Any probs with the script let me know. To test it (other then waiting) I created two levers: one for day and one for night.

The Script

Created By: Sean Bradbury
Created On: July 27 2002
Definition: Have guard equip and unequip a torch based on time of day.
Synopsis: The guard checks to see what the time of day is.
If nighttime then store the item in the off hand and equip a
If daytime then unequip the torch and reequip the item that
was being used before we equipped the torch.

void main()
object oItem;
object oldObject;
int noTorch = 0;
Check to see if it is day or night and the equip or unequip a torch as

if(GetIsDay() || GetIsDawn())
// Put torch away if we are holding one
if (GetLocalInt (OBJECT_SELF, "torchReady"))
ActionUnequipItem (oItem);
SetLocalInt (OBJECT_SELF, "torchReady", 0);
// Get the item we were holding in the left hand before we started
// using the torch and the equip it.
oldObject = GetLocalObject(OBJECT_SELF, "oldObject");
ActionEquipItem (oldObject, INVENTORY_SLOT_LEFTHAND);
// check to see if we already have one going
noTorch = GetLocalInt (OBJECT_SELF, "torchReady");
if (!noTorch)
oItem = CreateItemOnObject("seantorch");
if (oItem != OBJECT_INVALID)
// Get the current item in the left hand and store it for later use
oldObject = GetItemInSlot (INVENTORY_SLOT_LEFTHAND);
SetLocalObject (OBJECT_SELF,"oldObject", oldObject);
SetLocalInt (OBJECT_SELF, "torchReady", 1);
} // END TORCH routine

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.