DMH-Online

Dungeon Masters Helper · Est. 2005

Items Scripts

NWN Script: torch.htm

Author Sticky: Post Working Scripts Here
Tenchi Masaki Posted: Monday, 22 July 05:12AM
1. Script Name: Torches don't light themselves
Script Creator: Frank V. Schumacher

2. What it does: Has an NPC monitor the time of day and lights or puts out torches accordingly.

3. Notes: Well, I'm new at this so there should be a note that this might contain a lot of shortcomings that I don't understand.
The placeable Item in this script (the one that will be interacted with and should be a light source) should have the NWN script "nw_02_onoff" in its OnUsed script.

This script goes in the heartbeat script of an NPC. Change the tag on your object accordingly.

NWScript:
void main()
{
    object oLightSource = GetObjectByTag("StandingTorch_001");
    {
        if(GetIsDawn() == TRUE && GetPlaceableIllumination(oLightSource) == TRUE
        || GetIsDay() == TRUE && GetPlaceableIllumination(oLightSource) == TRUE)
                    {
                        if(IsInConversation(OBJECT_SELF) == FALSE
                        || GetIsInCombat(OBJECT_SELF) == FALSE)
                            {
                                ClearAllActions();
                                ActionInteractObject(oLightSource);
                                DelayCommand(4.5, ActionRandomWalk());
                            }
                    }
        else if(GetIsDusk() == TRUE && GetPlaceableIllumination(oLightSource) == FALSE
        || GetIsNight() == TRUE && GetPlaceableIllumination(oLightSource) == FALSE)
                    {
                        if(IsInConversation(OBJECT_SELF) == FALSE
                        || GetIsInCombat(OBJECT_SELF) == FALSE)
                            {
                                ClearAllActions();
                                ActionInteractObject(oLightSource);
                                DelayCommand(4.5, ActionRandomWalk());
                            }
                    }
    }
}


Well, It works for me except that the standing torches default to a glowing beacon of light. I'm working on that. Please tell me if something is wrong with this.

⌂ All Scripts ← PreviousNext → 👁 Category List

All Items Scripts

📄 aquire_time 📄 bead_of_force 📄 book_of_inf_spells 📄 clear_inventory 📄 clear_inventory_002 📄 clear_inventory_003 📄 clear_inventory_004 📄 cursed_items 📄 cursed_items_002 📄 cursed_potion 📄 give_xp 📄 glow_when_mob 📄 healing_belt 📄 helm 📄 hurled_weapons 📄 item_weight 📄 key_rental 📄 lore_items 📄 npc_owners 📄 random_magic 📄 retrieve_ammo 📄 scimitar_of_dancing 📄 scroll_creation 📄 spawn_item 📄 spawn_item_002 📄 spawn_item_004 📄 stone_of_recall 📄 stone_of_recall_002 📄 summon_creature 📄 teleport_item 📄 torch 📄 weapon_upgrade