FANDOM


Respawn Chest's

This goes in the onEnter event of a trigger. Lay it down where a player cant miss it. Since it's using the area itself to store the data it needs instead of the trigger, you can lay down several triggers, at several doors, and they'll all act as if they were the same trigger.

Oh, when you fill up the area with way points ? WP_CHEST is the one, and make sure the wide end faces where the player must stand to open it.

vCHEST = resref of a chest (no trap) vtCHEST = resref of a chest (with a trap) enter these two variables as local strings on the module itself (just go to the advacned tab and hit variables and enter them by hand) and you're all set. Regular NWN chest, custom chest, it doesn't matter.

// destroy all items with the specified
// resref in this area
//- koconnor100
void CleanArea(string sItem){
    object oObject = GetFirstObjectInArea();
    while(oObject != OBJECT_INVALID)
    {
        if(GetResRef(oObject) == sItem)
        {
            DestroyObject(oObject);
        }
        oObject = GetNextObjectInArea();
    }
}
void main()
{
   float fDelay = 600.0; // delay in seconds until rebuild
   location lChest;
   object wp  ;
   string sChest;
   string sChestUntrapped;
   string sChestTrapped;
   object oArea = GetArea(OBJECT_SELF);
   object oChest;
   object oPC = GetEnteringObject();
   string sExtraScript = GetLocalString(oArea,"ExtraScript");
   string sTrapFairy="trapfairy";
   int i = 1;
   sChestUntrapped = GetLocalString(oArea,"vCHEST");
   sChestTrapped = GetLocalString(oArea,"vtCHEST");
   int vTimer = GetLocalInt(oArea,"TIMER");
   CleanUpSecretDoors();// do this every time, despite timer
   cg_debug("Checking Timer At Begin: "+IntToString(vTimer));
   if (vTimer > 0) return; // timer is running

   //trap logic     -------------------
   //i = 1;
  // wp = GetNearestObjectByTag("WP_TRAP",OBJECT_SELF, i);
   //while (GetIsObjectValid(wp)){
    //  CreateObject( OBJECT_TYPE_CREATURE,
    //     sTrapFairy,
    //     GetLocation(wp)
    //  );
    //  i=i+1;
    //  wp = GetNearestObjectByTag("WP_TRAP",OBJECT_SELF, i);
   //}
   //end trap logic -------------------
   //cg_debug("Starting routine");
   //cg_debug("Chest ="+sChestUntrapped);
   //cg_debug("Chest ="+sChestTrapped);
   // CLEAN UP old chests ..
   CleanArea(sChestUntrapped);
   CleanArea(sChestTrapped);
   i=1;
   wp = GetNearestObjectByTag("WP_CHEST",OBJECT_SELF, i);
   while (GetIsObjectValid(wp)){
      //FloatingTextStringOnCreature("Spawning Chest",oPC);
      lChest = GetLocation(wp);
      if(d2() > 1) {   // 50% trapped
         sChest = sChestUntrapped;
      } else {
         sChest = sChestTrapped;
      }
      // create the chest
      oChest = CreateObject(OBJECT_TYPE_PLACEABLE,
        sChest, lChest
      );
      if(d2() > 1) { // 50% locked
        SetLocked(oChest,TRUE);
      } else {
        SetLocked(oChest,FALSE);
      }
      i=i+1;
      wp = GetNearestObjectByTag("WP_CHEST",OBJECT_SELF, i);
   }
   //CleanUpSecretDoors();
   //cg_debug("Ending area setup routine");
   // any extra proceedures we need to do ?
   if(sExtraScript != ""){
      ExecuteScript(sExtraScript,OBJECT_SELF);
      cg_debug("Executing "+sExtraScript );
   }
   // delay control
   //cg_debug("Setting Timer Value");
   SetLocalInt(oArea,"TIMER",1);
   vTimer = GetLocalInt(oArea,"TIMER");
   //cg_debug("Checking Timer Value:"+IntToString(vTimer));
   //ActionWait(fDelay);
   //SetLocalInt(oArea,"TIMER",0);
   DelayCommand(fDelay,SetLocalInt(oArea,"TIMER",0));
}

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.