Author Topic: Simple Respawning Traps  (Read 293 times)

Legacy_WoC_Builder

  • Sr. Member
  • ****
  • Posts: 425
  • Karma: +0/-0
Simple Respawning Traps
« on: February 16, 2013, 07:04:50 am »


               A method I came up with to respawn traps, without having to script an entire system.  The application was a unique area, so this suited our need.  Posting here just in case anyone else finds it useful.  '<img'>

/*
t_ent_trap_wrapr

A script to use as a wrapper for permanent traps, enabling them to be disabled
for a set period of time, then turned back on, so multiple entries by PC's
don't spam trap triggering.  Implementation is create trap that is NOT Disarmable,
NOT detectable, and NOT single shot.  Draw a generic trigger (with this script in
the on_enter handle) closely around the trap trigger.  Make sure that the closest
(trap) trigger is the one you are trying to control (e.g. watch your spacing).

A default time of 10 minutes (600 seconds) is preprogrammed into the script.
To change the delay setting, set a LocalFloat named "Delay" to whatever value you wish.

The net effect is to have individually re-spawning traps.  :)
*/

// Put this script OnEnter.
void main()
{
    // Get the creature who triggered this event.
    object oPC     = GetEnteringObject();
    object oTrap   = GetNearestObject(OBJECT_TYPE_TRIGGER);

    // Only fire for (real) PCs.
    if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )
        return;

    // If the wrapper has not been entered yet, set a varaible on the wrapper to
    // keep subsequent entries from triggerig the trap
    if (GetLocalInt(OBJECT_SELF, "TRAP_ACTIVE") == 0)//0 means yes, it is active
    {
        if (GetLocalFloat(OBJECT_SELF, "Delay") == 0.0)
            {
            SetLocalFloat(OBJECT_SELF, "Delay", 600.0);
            }

    SetLocalInt(OBJECT_SELF, "TRAP_ACTIVE", 1);
    DelayCommand(GetLocalFloat(OBJECT_SELF, "Delay"), SetLocalInt(OBJECT_SELF, "TRAP_ACTIVE", 0));
    }

    else
    {
    // Set it to inactive
    SetTrapActive (oTrap, FALSE);
    DelayCommand (GetLocalFloat(OBJECT_SELF, "Delay"), SetTrapActive (oTrap, TRUE));
    }
}

               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Simple Respawning Traps
« Reply #1 on: February 16, 2013, 07:19:20 am »


               You used similar technique as I did with my respawning traps with the same shape.

Your solution suffers with many issues:
- when the trap is set to inactive its still visible for players, setting the trap to active itself does not make the trap visible, nor detectable
- if the trap is nondisarmable it will not be possible to disarm so whats the point

I suggest to look into my script where I solved all issues and makke it work with one-shot and recoverable as well.
               
               

               
            

Legacy_WoC_Builder

  • Sr. Member
  • ****
  • Posts: 425
  • Karma: +0/-0
Simple Respawning Traps
« Reply #2 on: February 16, 2013, 03:00:03 pm »


               

ShaDoOoW wrote...

You used similar technique as I did with my respawning traps with the same shape.

Your solution suffers with many issues:
- when the trap is set to inactive its still visible for players, setting the trap to active itself does not make the trap visible, nor detectable
- if the trap is nondisarmable it will not be possible to disarm so whats the point

I suggest to look into my script where I solved all issues and makke it work with one-shot and recoverable as well.


So, setting the trap to un-detectable still results in a visible trap? 

And the point is I wanted a trap that the first entry triggers the trap, but not immediate subsequent entries.  However, 10 minutes goes by and the trap is active again.  '<img'>

And, in our case, I am using the trap to signify another event, such as where the PC is stepping, and the placeable they walked through is something to avoid.  It is not representing a classic trap being placed per se.  '<img'>
               
               

               


                     Modifié par WoC_Builder, 16 février 2013 - 05:14 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Simple Respawning Traps
« Reply #3 on: February 16, 2013, 03:12:02 pm »


               Thanks ShaDoOoW. Link to the aforementioned trap script:
http://nwvault.ign.c...d=51805&id=3870
               
               

               


                     Modifié par ffbj, 16 février 2013 - 03:14 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Simple Respawning Traps
« Reply #4 on: February 17, 2013, 08:40:35 am »


               

WoC_Builder wrote...

So, setting the trap to un-detectable still results in a visible trap?

Eh, no sorry. Undetectable trap is not visible. The issue I pointed is that when the trap is detectedd once by the PC, the only way to hide it again is by settrapvisible but the trap will still behave as detected for that PC so he wont reinitiate search check later.

And, in our case, I am using the trap to signify another event, such as where the PC is stepping, and the placeable they walked through is something to avoid.  It is not representing a classic trap being placed per se.  '<img'>

I see, well you didnt told this to us. I thought that this trap should be visible, if this works only with placeable then I guess its working. Though its a bit weird there is no way to find out the trap is active by the PC.
               
               

               


                     Modifié par ShaDoOoW, 17 février 2013 - 08:43 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Simple Respawning Traps
« Reply #5 on: February 17, 2013, 03:12:33 pm »


               Why? Placeables glow red if they are trapped and that is detected by the PC, but perhaps I misunderstand.
               
               

               


                     Modifié par ffbj, 17 février 2013 - 03:13 .
                     
                  


            

Legacy_WoC_Builder

  • Sr. Member
  • ****
  • Posts: 425
  • Karma: +0/-0
Simple Respawning Traps
« Reply #6 on: February 17, 2013, 05:09:31 pm »


               lol...okay, what we have is a dungeon where bats roost.  On the ground I use the snow placeable to signify guano deposits.  If the PC walks through the guano, it releases pent up gas; imagine breaking through a crust.  I tried it another way (via scripting) but then came up with this trap method..

I don't want the pc to have any other visual clue that the guano is something to be avoided, other than the placeable itself.

Does this make more sense?

lol...I just put this out there in case anyone else wanted to use it.  I didn't think I would have to justify why I wrote the code I did.  My bad.  '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Simple Respawning Traps
« Reply #7 on: February 17, 2013, 05:18:26 pm »


               

WoC_Builder wrote...

lol...I just put this out there in case anyone else wanted to use it.  I didn't think I would have to justify why I wrote the code I did.  My bad.  '<img'>

Sorry but you presented this as a simple respawning trap script while you actually using a trigger. Yes you do use trap, but for a purpose that a generic trigger would handle the same way.

A generic builder had no chance to figure out the purpose of your script and how to use, until you clarified it now.
               
               

               


                     Modifié par ShaDoOoW, 17 février 2013 - 05:21 .
                     
                  


            

Legacy_WoC_Builder

  • Sr. Member
  • ****
  • Posts: 425
  • Karma: +0/-0
Simple Respawning Traps
« Reply #8 on: February 17, 2013, 07:43:47 pm »


               Like I said, my bad.  And while I am sure that those of a higher order of scripting ability will look at my offering and say that technically I should have/could have done otherwise, I thought I would simply present a solution I found to an issue I found to the community that has given me far more than I have given it.

Perhaps my definition is off, calling this a respawning trap.  But to me that is what the trigger did, respawned a trap that was encapsulated by the trigger.  But I am a simple scripter, so forgive me.

I'm done here.
               
               

               


                     Modifié par WoC_Builder, 17 février 2013 - 08:12 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Simple Respawning Traps
« Reply #9 on: February 17, 2013, 11:49:46 pm »


               Yeah I get it.  I did something like that with a cheval de frise. The spiky pointing things.  If you get to close to them they do damage. So I suppose 'trap like' would be the best definition for something like that.  It's a useful concept for sure.