Author Topic: How to put a friendly persistent trap on a useable door?  (Read 654 times)

Legacy_BCH

  • Full Member
  • ***
  • Posts: 160
  • Karma: +0/-0
How to put a friendly persistent trap on a useable door?
« on: February 11, 2011, 01:01:07 pm »


               I'm trying to place a door that is trapped such that PCs can use the door normally, but the trap remains and will affect any hostile creature that tries to use the door.  (This is in a virtual pen and paper game, so NPCs may be trying to use that door when no PCs are around.)

When trying to use the Trap tab of the door properties, setting the trap to a faction like Defender seems to do everything I want it to except that when a PC tries to use the door, their receive the message "you triggered a trap" - thankfully the trap does not affect them - and the trap vanishes.  Then they an click again to open the door.

If I uncheck the "single shot" box in the door > Properties > Trap tab, then the trap does not vanish when a PC triggers it, and this does not allow the PC to open the door.  Every time they click, they just get "you triggered a trap" but nothing else happens.  The door cannot be accessed while the trap is in place.

I can get around this by putting the trap on the ground in front of the door - then it works the way I want it to - but I'm curious if I'm doing something wrong with that door's properties.

Any ideas?
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
How to put a friendly persistent trap on a useable door?
« Reply #1 on: February 11, 2011, 01:02:34 pm »


               No your not as the only way I know to do it like you want is putting it in front of the door as well.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to put a friendly persistent trap on a useable door?
« Reply #2 on: February 12, 2011, 07:26:14 pm »


               You can make your own trap triggered script where you will open the door if the triggerer is PC or execute original trap script if not. Not totally clean, but should work.
               
               

               
            

Legacy_BCH

  • Full Member
  • ***
  • Posts: 160
  • Karma: +0/-0
How to put a friendly persistent trap on a useable door?
« Reply #3 on: February 12, 2011, 07:47:51 pm »


               Thanks, both!



ShaDoOoW, I've read that when a script is put in the OnTrapTriggered event, the default trap trigger script is overridden.  Do you mean you can execute the original script from within the overriding script?  If so, please tell me how, as I've never done this before.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to put a friendly persistent trap on a useable door?
« Reply #4 on: February 12, 2011, 09:31:49 pm »


               Its not so easy, I mean there is not function "RunOriginalTrapScript", but the trap script names are known so everything you need to do is to get the trap script name and then use ExecuteScript function on OBJECT_SELF
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How to put a friendly persistent trap on a useable door?
« Reply #5 on: February 12, 2011, 10:07:09 pm »


               

BCH wrote...

Thanks, both!

ShaDoOoW, I've read that when a script is put in the OnTrapTriggered event, the default trap trigger script is overridden. Do you mean you can execute the original script from within the overriding script? If so, please tell me how, as I've never done this before.


Here is what I use.



...
    string sImpactScript = GetLocalString(oTrap,"ImpactScript");
    if(sImpactScript == "")
    {
        sImpactScript=Get2DAString("traps","TrapScript",GetTrapBaseType(oTrap));
        SetLocalString( oTrap,"ImpactScript",sImpactScript);
    }
    ExecuteScript(sImpactScript,oTrap);
...


               
               

               
            

Legacy_BCH

  • Full Member
  • ***
  • Posts: 160
  • Karma: +0/-0
How to put a friendly persistent trap on a useable door?
« Reply #6 on: February 13, 2011, 08:50:50 am »


               Excellent, thank you!  I was glad to hear that the trap script names are known, but I was hesitant to ask where I can find them.



Lightfoot8, your reply could have been as short as "look in traps.2da" but the code snippet was helpful above and beyond. :-)