Author Topic: Traps - what's possible?  (Read 565 times)

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Traps - what's possible?
« on: March 23, 2011, 03:04:28 am »


                 I'm looking for some guidance.  I know very little about what can be done with traps, and admittedly I haven't looked very hard.

  I am considering a widget in our PW that takes into account a player's craft trap, set trap, rogue/ranger levels, possibly some other stuff and then creates a custom trap at a target location.  Problem is, I don't think it's possible to do via scripting, but before I spend a lot of time trying or abandon the idea, I thought I'd ask.

  If I had the widget create one of the base NWN traps on the ground, is there a way to modify its properties: detect DC, disarm DC, trap DC, type of trap, damage amount, etc?

  I could envision creating a generic trigger in the palette, then having the widget create that at the target location, and have an OnEnter event that reads all the variables determined and set by the widget on the trigger, but then I don't know how to make this trigger use the trap flagging/disarm/detection/setting mechanics already setup in NWN (i.e. appearing red when a player detects it, allowing you to right-click and select disarm/flag/recover options).

Anyway.  Possible?  Insights?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Traps - what's possible?
« Reply #1 on: March 23, 2011, 03:37:46 am »


               

Terrorble wrote...

... is there a way to modify its properties: detect DC, disarm DC, trap DC, type of trap, damage amount, etc?


SetTrapDetectDC
SetTrapDisarmDC
Trap DC ??  If you mean DC to save, Would be decided by the impact script. 

You can not change the trap type.  Just create the type you want.  

CreateTrapAtLocation

CreateTrapOnObject

The amount of damage ect. will be decided by the impact script.  you can set them when you create the trap.  If you do not set them the default script for the trap will be used. 

If you wanted the traps to all use the same impact script, you could set local vars on the trap or object  to tweek what the script does when the trap goes off.

EDIT:  If you wanted to look at the standard trap script, for a guide, the impact scripts all have a prefix of  NW_T1_
               
               

               


                     Modifié par Lightfoot8, 23 mars 2011 - 03:48 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Traps - what's possible?
« Reply #2 on: March 24, 2011, 11:20:23 am »


               Trap type, disarm and detect DC are in the trap properties and you need a special script to change them.

The rest is in the trap script which you would have to adjust or you can download my community patch, there are new trap subtypes called "adjustable" where you can set:
- minimum damage
- maximum damage (or no damage)
- saving throw DC to avoid paralyse
- duration of the paralyse (or no paralyse)

This is described in the documentation. Except those there are "weak" trap subtypes designed for early levels and epic traps fot those that were missing.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Traps - what's possible?
« Reply #3 on: August 20, 2012, 03:17:08 pm »


                The NWN Wiki Trap Page mentions:

A module designer can disable the default detection routines for a particular trap and substitute a detection script. This allows for effects such as a trap that is only detectable by a particular race, and a trap that is automatically detected by the bearer of a particular item. However, most traps in most modules follow the default behavior described in this article.

I am wondering how one goes about setting up a custom detect script.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Traps - what's possible?
« Reply #4 on: August 20, 2012, 04:01:17 pm »


               

henesua wrote...

 The NWN Wiki Trap Page mentions:

A module designer can disable the default detection routines for a particular trap and substitute a detection script. This allows for effects such as a trap that is only detectable by a particular race, and a trap that is automatically detected by the bearer of a particular item. However, most traps in most modules follow the default behavior described in this article.

I am wondering how one goes about setting up a custom detect script.


  You'd place a trigger around the trap on spawning it, with the trap tag stored to it, and place your detection script in there.  I suspect it'd be similar to that gargoyle spawning script in how it was applied.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Traps - what's possible?
« Reply #5 on: August 20, 2012, 09:58:00 pm »


               Thanks for the reply.

So this is a completely custom solution without any hooks into the existing trap functionality.

A custom AOE might work for this as that would allow me to control the radius. And I could apply the AOE on spawn of the trap. I use that for my gargoyles now which I spawn as placeables via NESS.

Anyone use Elric's Trap Spawner? Have any thoughts on it?
               
               

               


                     Modifié par henesua, 20 août 2012 - 08:59 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Traps - what's possible?
« Reply #6 on: August 21, 2012, 01:44:09 am »


               I just have random sizes and dc and shade the tougher ones to the tougher characters.
I also have some npc that will lay random traps if certain conditions are met.
Not the greatest solution but it has it moments.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Traps - what's possible?
« Reply #7 on: August 21, 2012, 03:26:50 pm »


               ffbj, I don't follow. Are you saying you do all that with Elric's Trap Spawner?
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Traps - what's possible?
« Reply #8 on: August 21, 2012, 04:32:06 pm »


               No I just have my own method. It just selects a trap to spawn from a list.
So npc's carry trap kits maybe 4-8 and then depending on conditionals, like have they been in combat, or wounded, or it's night, they will get into their trap dropping mode. I developed this method for spawning random placeables earlier and once traps came around adapted it to creating traps at the location of the dropped trap, which is then destroyed. So it actually looks like the npc is setting a trap, but it is all done through scripting. Then I will get the location of the object dropped and create a trap from a list at that spot.
I have mainly use that method for creating traps too, but nothing so in depth as you suggest.

For instance:

//:://////////////////////////////////////////////
//:: Created By: ffbj
//:: Created On: a long time ago
//Give the npc a bunch of traps, does not matter which kind. ffbj
//an executable caused to fire, usually on combatrdend when the npc has lost contact
//with the PC
void main()
   {
    object oTarget;
    oTarget = OBJECT_SELF;
    ClearAllActions(TRUE);//just want to drop stuff
    object oInventory = GetFirstItemInInventory();
    object oKit;
         // Get if trap kit
        if(GetBaseItemType(oInventory) == BASE_ITEM_TRAPKIT)
        {
            oKit = oInventory;
        }
        oInventory = GetNextItemInInventory();
    // Check oKit
    if(GetIsObjectValid(oKit))
        {
        ActionPutDownItem(oKit);//set it down
        //mostly for ascetics so he looks like he is setting a trap, but also
        //a method to limit of number of traps that can be lain.
       location lLoc = GetLocation(OBJECT_SELF);
       int iHD = GetHitDice(oTarget);
       float fRange = 10.0;//make these numbers larger or smaller,
        int nMaxInteger = 8;//to make the trapper go further
        int nRandom = (nMaxInteger);
        string sTag = "trap";
       ActionMoveAwayFromObject(oKit, FALSE, fRange + nRandom);
       DestroyObject(oKit, 2.0);//destroy the evidence
          {
   //Check which trap is chosen
      switch(d4())
     {
    case 1:CreateTrapAtLocation (TRAP_BASE_TYPE_AVERAGE_ACID, lLoc, 4.0f,  sTag, STANDARD_FACTION_HOSTILE);break;
    case 2:CreateTrapAtLocation(TRAP_BASE_TYPE_AVERAGE_NEGATIVE, lLoc, 5.0f,  sTag, STANDARD_FACTION_HOSTILE);break;
    case 3:CreateTrapAtLocation(TRAP_BASE_TYPE_AVERAGE_FIRE, lLoc, 6.0f,  sTag, STANDARD_FACTION_HOSTILE);break;
    case 4:CreateTrapAtLocation(TRAP_BASE_TYPE_STRONG_FROST, lLoc, 7.0f,  sTag, STANDARD_FACTION_HOSTILE);break;
    }
    object oTrap =  GetObjectByTag(sTag);
      SetTrapDetectDC(oTrap, iHD *2 + nRandom);
      SetTrapDisarmDC (oTrap, iHD *2+ nRandom);
         }
         DelayCommand (2.0,ActionMoveAwayFromObject(oKit, TRUE, fRange + nRandom));
         if ((d100() > 70 -iHD)&& (!GetIsInCombat(OBJECT_SELF)))
         DelayCommand (10.0, ExecuteScript("_createtrap01", oTarget));
 }
}
So the atual dc's are based on the trapsetter's level plus a random number. 
For a while I had it on a while loop so say the guy had 5 traps he would drop them all in the same spot.  A couple guys bought the farm that way, until I figured out what was happening.
               
               

               


                     Modifié par ffbj, 21 août 2012 - 03:44 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Traps - what's possible?
« Reply #9 on: August 21, 2012, 05:12:20 pm »


               looks interesting. when I dig deeper into traps, I'll run this code through its paces.