Aller au contenu

Photo

Simple Respawning Traps


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
WoC_Builder

WoC_Builder
  • Members
  • 225 messages
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.  :)

/*
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));
    }
}


#2
Shadooow

Shadooow
  • Members
  • 4 471 messages
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.

#3
WoC_Builder

WoC_Builder
  • Members
  • 225 messages

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.  :)

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.  :)

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


#4
ffbj

ffbj
  • Members
  • 593 messages
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 .


#5
Shadooow

Shadooow
  • Members
  • 4 471 messages

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.  :)

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 .


#6
ffbj

ffbj
  • Members
  • 593 messages
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 .


#7
WoC_Builder

WoC_Builder
  • Members
  • 225 messages
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. ;)

#8
Shadooow

Shadooow
  • Members
  • 4 471 messages

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. ;)

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 .


#9
WoC_Builder

WoC_Builder
  • Members
  • 225 messages
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 .


#10
ffbj

ffbj
  • Members
  • 593 messages
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.