FANDOM


Make default treasure chests respawn their loot and to modify the time it takes

This is just a matter of altering the script that is already there. For this example I will use the script nw_02_classlow treasure script. The same alteration can be made to all of them.

When the chest is first opened, the Local Variable on the chest called "NW_DO_ONCE" is 0. Therefore the treasure spawns. After that the Local Variable is then set to 1. Which prevents the treasure from respawning because of the "if" statement.

We simply need to add a delay time and set the int back to 0 so the treasure can spawn again. Replace the following script in the OnOpen node of the chest or placable.

Note

if you definatly want this on all chest you place, you can save this script with the same name of the default script you are replaceing. This way it will be on each chest you place down. Keep in mind that it only effects that module.

//::///////////////////////////////////////////////
//:: General Treasure Spawn Script
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Spawns in general purpose treasure, usable
    by all classes.
    Altered By Glenn J. Berden aka Jassper
    fDelay is the time in seconds before the chest
    will respawn a treasure.
    i.e. a time of 60.0 = 1 minute Real Time.
*/
//:://////////////////////////////////////////////
//:: Created By:   Brent
//:: Created On:   February 26 2001
//:://////////////////////////////////////////////
#include "NW_O2_CONINCLUDE"
void main()
{
    float fDelay = 120.0;
    if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
    {
       return;
    }
    object oLastOpener = GetLastOpener();
    GenerateLowTreasure(oLastOpener, OBJECT_SELF);
    SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
    DelayCommand(fDelay,SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",0));
    ShoutDisturbed();
}

Alter fDelay to set the time in sec before the treasure will respawn.

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.