Jump to content
The Dark Mod Forums

Springloaded Spike Trap


Springheel

Recommended Posts

So the next trap I'm looking into is one I've tried to use before in A Score to Settle, though not exactly with the results I wanted. Hopefully we can come up with a better method by sharing ideas.

Description: This trap triggers a thrusting weapon that hits the player from an unseen location, like a spike or spear that thrusts out from a wall. It does not use projectiles, so it has a limited range.

Components:

1. The weapon needs to move rapidly when the trap is triggered. Ideally, the weapon should retract after being triggered.

2. The weapon needs to cause damage to the player (and AI) if it hits him when triggered. It should not cause damage if the player simply touches it.


In my experiences trying to make these kinds of traps, I've run into the following hurdles:


I've tried putting Damage Stims on the spike, but they affect only the player, not AI. Also, I can't figure out how to make a damage stim only fire once when the spike thrusts forward.

trigger_hurt entities send a damage stim every X seconds. I've tried binding one to the head of the spike, but as above, I don't know how to turn them on and off. They will continue to damage the player as long as they stand touching the spike. If there was a way to spawn the trigger_hurt, let it fire once, and then remove it, that would be great, but that would have to happen each time the trap is triggered.

I thought about trying to tie the damage to velocity, so the spike could damage the player on first thrust but not if the player just touches it afterwards. But as far as I can tell only projectiles have a minVelocity property. (Actually, that must not be true--we have code that handles movables that have to reach a certain velocity before causing damage. But I don't know how that is handled or whether it could be applied here.)



Anyone else have other ideas or experience with the above?

 

 

edit: final video and link to prefab here: http://forums.thedarkmod.com/topic/19586-springloaded-spike-trap/?p=425869

post-9-0-61287300-1533758521_thumb.jpg

  • Like 2
Link to comment
Share on other sites

Movers/Doors should work. They only move a certain range, they can be set to close automatically and to not stop when blocked and should cause damage if the latter is set. Never tested it, though.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Movers/Doors should work. They only move a certain range, they can be set to close automatically and to not stop when blocked and should cause damage if the latter is set. Never tested it, though.

 

I'm using a door for the spike currently...how do you set a door to do damage though?

 

Currently I'm trying to experiment with making a projectile with 0 velocity that could be bound to the tip of a spike.

Link to comment
Share on other sites

Not that I've tried to do this before, but I'll try to supply some ideas again:

 

Concept A: moving door with S/R spearhead

1) you could add a damage stim emitter to the tip of the spike, make it start inactive, use a response effect to activate the stim emitter when the trap is set off. You can set the stim to only be active for i.e. 0.5 seconds.

2) You can manually add a damage response to the AIs so that this is no longer player-unique, using the spawnargs from your double damage stim thread.

 

Concept B: moving door with a func_shooter that fires off a custom projectile that's invisible and short-ranged.

-> This one is probably more robust because it can never hit more than once at a time, which is something that might happen sometimes in the S/R system.

Edited by Dragofer
Link to comment
Share on other sites

Springheel loaded spike trap! I like it!

 

Howsabout trigger_shooter? Shooters hurt everybody, right? Just fire an invisible bullet that does the damage you want?

 

Or make it to be springloaded spike SHOOTER trap, where you shoot a spike at the victim.

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

At the moment I'm experimenting with binding a func_shooter to the tip of the spike. I've created a projectile with no velocity, so it stays in place but delivers damage. It seems promising.

 

The trick now is how to fire the func_shooter each time the the spike is triggered, but not in between. If the trap only fired once, I could just give the func_shooter limited ammo. But I want it to be able to fire every time it's triggered.

Link to comment
Share on other sites

Doors will damage the player if the damage spawnarg is set to a value greater then zero. Note that this will only work if the door is blocked by the player, so you have to make sure that push_player is set to zero (that's the default value). In addition, stop_when_blocked needs to be set to true (that's also the default) or otherwise the continuos attempt of the door trying to open itself will kill the player over time. The downside of the first one is that you don't get any pushing back of the player (you'll have to take care of that seperately if you are aiming for that) and of the latter one that the spike will not fully move out (more an aesthetical thing and maybe even what you want to have).

 

So to sum it up. Use a typical door (atdm:mover_door_sliding for example) and set the damage value and you are fine (but not the player who stumbles into your trap). :)

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Note that this will only work if the door is blocked by the player, so you have to make sure that push_player is set to zero (that's the default value). In addition, stop_when_blocked needs to be set to true (that's also the default) or otherwise the continuos attempt of the door trying to open itself will kill the player over time. The downside of the first one is that you don't get any pushing back of the player (you'll have to take care of that seperately if you are aiming for that) and of the latter one that the spike will not fully move out (more an aesthetical thing and maybe even what you want to have).

 

Is there any way to call a specific damage entity? Some damage entities have a "knockback" value that would be useful here. At the moment, it's close to what I would like, but if the player happens to be standing close to the spike when the trap is triggered, the spike doesn't move at all, which could leave the player a little confused.

 

edit: Additionally, it doesn't appear to work on AI--the spike pushes them without doing any damage.

Link to comment
Share on other sites

The trick now is how to fire the func_shooter each time the the spike is triggered, but not in between.

If there's no spawnarg for that then one way would be adding a trigger_relay with 'delay' '0.1'. Let it be activated together with the trap, and let it target the function_shooter so that the shooter gets turned off after 0.1s.

Link to comment
Share on other sites

The problem is that func_shooters don't turn "off" when they run out of ammo, or even when the "max lifetime" is reached (which seems like an oversight). The second time you trigger them, they turn "off" even if they haven't been firing for ages.

 

So if you set the func_shooter to fire 1 projectile, this is what happens:

First trigger: spike moves; func_shooter is turned on and fires once (so far so good).
Second trigger: spike moves; func_shooter turns off (not good)
Third trigger: spike moves; func_shooter turns on and fires once

 

 

So this would work fine, but only every other triggering of the trap.

If there's no spawnarg for that then one way would be adding a trigger_relay with 'delay' '0.1'. Let it be activated together with the trap, and let it target the function_shooter so that the shooter gets turned off after 0.1s.

 

I'm not clear how this would work. Does the trigger_relay fire a second trigger? One trigger is needed to turn the func_shooter on. I guess a trigger chain could work?

Link to comment
Share on other sites

I'm not clear how this would work. Does the trigger_relay fire a second trigger? One trigger is needed to turn the func_shooter on. I guess a trigger chain could work?

Trigger_relay is an entity which, when triggered, triggers its targets. You can add a delay spawnarg to it.

 

In this case you would have the first trigger activating both the trap and the trigger_relay. After a short delay the trigger_relay will then send a second trigger to the trap so that the shooting stops.

  • Like 2
Link to comment
Share on other sites

In this case you would have the first trigger activating both the trap and the trigger_relay. After a short delay the trigger_relay will then send a second trigger to the trap so that the shooting stops.

 

Yep, this appears to be solving the problem of resetting the func_shooter. Now it's firing once each time it is triggered.

  • Like 1
Link to comment
Share on other sites

Hmm, I am not having much luck with binding a func_shooter to the tip of the spike. There is a timing issue that I can't overcome--if the func_shooter fires while the spike is moving, then the spike actually overtakes the projectile and hits the player first, pushing the player out of the way so they never get hit by the projectile at all.

 

I could try creating a projectile that fires at the same speed and for the same distance as the spike, but that would be really finicky and wouldn't be usable with different types of weapons, so that's not satisfactory.

 

But,

 

Dragofer's idea of the trigger_relay has given me a different idea. Trigger_hurt entities can be turned on and off. At the moment I'm getting good results from binding a trigger_hurt to the tip of the spear, turning it off to start, then using a trigger to turn it on and a trigger_relay to turn it off a second later. It does damage the moment it hits the player, and won't do damage again for at least a second (by which time it's turned off by the trigger_relay). So the player takes damage no matter where in the moving process the spear hits them. They won't take damage from it after that until the trap is reset and triggered again.

 

It does mean that the player could technically be hurt by hitting the side of the spear, but since the player can't see their body it would be easy to imagine they still got sliced by it.

 

edit: wait, trigger_hurt doesn't affect AI? I thought it did. Is there any entity that damages both player and AI?

Link to comment
Share on other sites

Here's an idea: make the spike nonsolid so that it doesn't interfere with the projectile. However you don't want it to pierce straight through a rock the player might've put in front of it, so here's what you can do:

 

1) duplicate your spike. Make the new one a func_static, give it 'noclipmodel' 1 and bind it to the old spike. [This will be your visual model.]

2) select your old spike and retexture it with moveable_clip. [This will be your collision model: if it gets stopped by something, then the visual spike that's bound to it stops too.]

 

IIRC moveable_clip doesn't interact with projectiles.

 

 

An alternative approach is to directly define the move_speed of the spike 'door', instead of move_time. This way you know exactly how high the projectile speed needs to be for each trap.

Edited by Dragofer
Link to comment
Share on other sites

Here's an idea: make the spike nonsolid so that it doesn't interfere with the projectile. However you don't want it to pierce straight through a rock the player might've put in front of it, so here's what you can do:

 

1) duplicate your spike. Make the new one a func_static, give it 'noclipmodel' 1 and bind it to the old spike. [This will be your visual model.]

2) select your old spike and retexture it with moveable_clip. [This will be your collision model: if it gets stopped by something, then the visual spike that's bound to it stops too.]

 

IIRC moveable_clip doesn't interact with projectiles.

 

 

An alternative approach is to directly define the move_speed of the spike 'door', instead of move_time. This way you know exactly how high the projectile speed needs to be for each trap.

 

I'm not clear how that would help in this case. The problem appears to be that the projectile does not move along with the func_shooter in a predictable way. I've given the projectile a particle effect so you can see it in the video below. You can see that the projectile fires, but does not move forward with the tip of the spear (even though the func_shooter is bound in front of the tip). So the tip of the spear hits the player, but the projectile is further back, so it does not hit the player.

 

I could try and match the forward speed of the projectile to the forward movement of the spear, but that is not a very robust solution, as it would require modification every time the trap is adjusted in any way.

 

 

On the trigger_hurt front, if I make an AI walk through a big trigger_hurt brush, he does indeed take damage. But he isn't taking damage from the one attached to the tip of the spear. Need to track down why not.

 

edit: So it appears that a trigger_hurt works if an AI collides with a stationary trigger_hurt, but it does not work if the trigger_hurt collides with a stationary AI. That's disappointing and makes trigger_hurt unusable for this kind of trap.

Link to comment
Share on other sites

you could add a damage stim emitter to the tip of the spike, make it start inactive, use a response effect to activate the stim emitter when the trap is set off. You can set the stim to only be active for i.e. 0.5 seconds.

 

 

So I've hit roadblocks with both the func_shooter and trigger_hurt methods, so I'm now back to exploring other possibilities, and have gone back to stim/response. But I can't figure out how to activate a Stim for only a short period of time. There is nothing like a trigger_relay that can turn a stim off, is there? And stims aren't affected by regular triggers as far as I can see.

 

The "duration" property on a stim seems to only time from map start.

Link to comment
Share on other sites

The way I understood it the tip of the spear was blocked by the player so that the projectile couldn't reach him. My first proposal in the last post would've let the spike pierce clean through the player and AI, so that the projectile can reach them, while still getting blocked by moveables. However, passing through humanoids wouldn't be acceptable if you wanted a blunt weapon instead of a spike. And the better solution would probably be just to make sure the projectile is in front of the spike.

 

As your post has clarified, however, the problem is that a stationary projectile doesn't reliably follow the spike's movement. It may be better, then, to use a moving projectile. It will require adjustment between variants of the trap, but you only need to set move_speed and move_time in the projectile def to be the same as on the spike.

Edited by Dragofer
Link to comment
Share on other sites

But I can't figure out how to activate a Stim for only a short period of time.

 

The "duration" property on a stim seems to only time from map start.

You can use response effects to enable or disable stims, responses or even individual effects. Regarding the second part: if duration doesn't work you might be able to use a delayed trigger_relay again, this time triggering an entity which carries a response to deactivate the stim. I'm not 100% sure whether this will work as intended however.

Link to comment
Share on other sites

It may be better, then, to use a moving projectile. It will require adjustment between variants of the trap, but you only need to set move_speed and move_time in the projectile def to be the same as on the spike.

 

 

I tried a stationary projectile over top of the spear that shoots an invisible projectile. This is currently the front-runner, but has two issues:

 

1. Matching the speed and location of the projectile to the spear is awkward and requires a temporary particle effect. Not very user friendly, especially for newer mappers.

2. The projectile seems to be rather large. The player can crouch under the spear without getting hit by it, but if they are in front of the func_shooter when crouched, they get hit. I see nowhere to change the size of the projectile, although there must be somewhere.

 

edit: it's not so much that the projectile is large...it's that it is erratic. In the video below I don't actually move, but the first time I'm not hit by the projectile, and in the next instance I am.

 

 

You can use response effects to enable or disable stims

 

 

I've been experimenting with this today, but without any luck so far. Any further experimenting is going to have to wait until tomorrow.

Link to comment
Share on other sites

Here's today's pickle.

 

I'm trying to make one of these spear traps that fires when a chest is opened.

 

Chests, however, have 'trigger_on_open' AND 'trigger_on_close' both set by default (to control the frob-blocking brush).

 

So If I target the trap from the lid, the trap fires both when the chest is opened AND when the chest is closed. I only want it to fire when the chest is opened.

 

Is there any way to isolate which target is triggered when a door is opened or closed? I want it to trigger A and B when opened, but only trigger A when closed.

 

I tried circumventing the issue by making a trigger_entity and placing it above the chest lid, but apparently that doesn't work. A frob stim would have the same problem of triggering when closed. I feel like I'm at another dead end here.

 

(Sheesh, I can see now why more people don't make traps in TDM.... <_< )

Link to comment
Share on other sites

Scripting would be my first advice.

 

Besides that, inserting a trigger_count could work. It fires after it has been triggered often enough. In your case, it should have to be triggered two times before it fires. In addition, it needs to be triggered once after the map starts.

 

So

  • The trigger_count gets triggered once after map start: count = 1, nothing happens
  • the player opens the lid triggering the trigger_count: count = 2, the trap gets triggered, count is set back to zero
  • the player closes the lid: count = 1, nothing happens
  • the player opens the lid again: count = 2, the trap gets triggered

and so one. Haven't tested that, though.

 

I would really advice to use script objects for such setups. Having several triggers all linked to each other and to the entity causing the trap to activate as well as the trap is a hard to oversee setup and very errorprone when it comes to copying/moving the whole setup around. A script object applied to the trap that controls the trap and thats behaviour can be modified with a couple of spawnargs on the trap is the better approach, imho.

 

Just my two cents.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

I accept that scripting would probably be the most effective route. I actually went looking for a scripting solution last night. I read up on all the wiki pages on scripting, including "scripting for beginners", but I understood about 10% of what I read. I didn't have the slightest clue how to begin.

 

However, as I was falling asleep last night, I remembered the existence of a "trigger_sequencer" that VanishedOne made a few years back. I used it in A New Job, but it wasn't on the wiki and I had forgotten about it. I think it will do the trick (and I've added it and trigger_random to the wiki).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
    • Ansome

      Well then, it's been about a week since I released my first FM and I must say that I was very pleasantly surprised by its reception. I had expected half as much interest in my short little FM as I received and even less when it came to positive feedback, but I am glad that the aspects of my mission that I put the most heart into were often the most appreciated. It was also delightful to read plenty of honest criticism and helpful feedback, as I've already been given plenty of useful pointers on improving my brushwork, level design, and gameplay difficulty.
      I've gotten back into the groove of chipping away at my reading and game list, as well as the endless FM catalogue here, but I may very well try my hand at the 15th anniversary contest should it materialize. That is assuming my eyes are ready for a few more months of Dark Radiant's bright interface while burning the midnight oil, of course!
      · 4 replies
×
×
  • Create New...