setting up tripwires

Dependencies:

Actual script file:

This script was created to help automate the usage of laser tripwires. The tripwire is basically a beam emitted from a source that moves around. If the player touches the beam, then he'll take some damage, and possibly trigger other events based upon what the level designer needs to happen.

Implementing Tripwires

To implement a tripwire, they need to specifically consist of the following:

  1. Source object:
    A script_object or script_model that represents where the tripwire is emitting from.

  2. Beam object:
    A script_object, script_model, or FX that represents the beam emitting from the source.

  3. Hurt object:
    A trigger_hurt around the area where the beam object will be. This is the part that the player can walk through. Set all the damage values accordingly for how much damage you want it to do. If you would like the tripwire to trigger some event when the player touches the trigger_hurt, you can use the 'thread' keyvalue to have it execute a function in your script. Keep in mind that it will execute that function every time the player triggers the trigger_hurt, so you'll have to account for this in the function you execute from the trigger_hurt.

  4. Origin object:
    A script_origin that all entities in the group are bound to. The origin must target the first node in the path (see next item). The origin must also be in the exact same place as the first node in the path.

  5. Tripwire path possibility #1:
    A path of info_notnull entities linked CTRL+K style (target to targetname). If you do not loop the path (meaning have the last node in the path target the first node in the path), then the tripwires will automagically teleport back to the first node after they hit the last.

  6. Tripwire path possibility #2:
    A splinepath that is linked CTRL-K style (target to targetname). If you do not loop the path (meaning have the last node in the path target the first node in the path), then the tripwire will stop when it reaches the end of the path


In order for all of the objects to be properly bound together, they all have to be targetnamed properly. First, you need to think of a unique targetname to give the source object. So for example, let's give it a targetname of 'wire1'. The beam object then needs to have a targetname that begins with the unique targetname from the source object, with an '_beam' appended onto it. So in this example, the beam object would have a targetname of 'wire1_beam'.

The origin object targetname needs to follow the same convention, but with an '_origin' appended onto the end of it. So in this example, the origin object would have a targetname of 'wire1_origin'. The hurt object targetname needs to follow the save convention, but with a '_hurt' appended onto the end of it. So in this example, the hurt object would have a targetname of 'wire1_hurt'.

After giving all the objects the proper targetname, then you need to lay out a path in the editor. If you want a simplisitc path where the objects follow a straight line from one point to the next, setup a series of info_notnull's and link them together using the CTRL+K method in radiant. If you want a more complex path where the object curves and accelerates around, then setup a series of info_splinepath's and link them together using the CTRL+K method in radiant. After creating the path, use the CTRL+K method to link the origin object to the first node of the path.

In script, somewhere before you actually have the tripwire start running, you need to call the setup function on it.

The 'basename' parameter is the string value of the unique targetname you gave the source object (without the dollar sign). So with our example from earlier, this would be "wire1". The 'thespeed' parameter is how fast you want the object to travel along the path.

Starting Tripwires

When you're ready to get it running along it's path, there are two ways to do this depending upon whether you wish the tripwire to follow a path of info_notnull's, or info_splinepaths.

For info_notnull's:

Run this function in your script:

The 'basename' parameter is the string value of the unique targetname you gave the source object (without the dollar sign). So with our example from earlier, this would be "wire1". You will probably want to run this function parallel to other functions (i.e. with the 'thread' command), because this function does not return once it's executed.

For info_splinepath's:

Call the follow command directly on the origin object like this:

Stopping Tripwires

When you want the tripwires to stop, there are 2 ways to do this depending upon whether you had it following a paht of info_notnull's, or info_splinepath's.

For info_notnull's:

Run this function in your script:

The 'basename' parameter is the string value of the unique targetname you gave the source object (without the dollar sign). So with our example from earlier, this would be "wire1".

For info_splinepath's:

Call the follow command directly on the origin object like this:

In both of these instances, you have to handle the beam and trigger_hurt yourself. So you'll either have to remove them, or hide and make them notsolid.