Jump to content
Official BF Editor Forums
Harry

Creating trigger(able)s

Recommended Posts

Guess there was some animo for it and I was curious, so here we go:

The trigger system works pretty simple:

-Create a trigger

-Create a Triggerable

-Link them

-Spawn them

First we create a trigger:

ObjectTemplate.create Triggerable MyTrigger

ObjectTemplate.setNetworkableInfo BasicInfo

then we change some of the settings of the trigger so it acts as we want it to act:

First we set the physics as we want. Note you can change these but I like my trigger to float in the air and not collide w/ it so I have this:

ObjectTemplate.hasMobilePhysics 0

ObjectTemplate.hasCollisionPhysics 0

ObjectTemplate.setCollisionMesh Jeep_FAAV

ObjectTemplate.physicsType Mesh

Note my collisionmesh is jeep_FAAV. Thats just a dummy. You can probably ignore this anyway.

Triggers usually dont have a geometry but have a simpleobject added instead. I added the knife to make i show, obviously you need something that look like it can hold a trigger (the case arround a lightswitch for example)

ObjectTemplate.addTemplate KNI_KNIFE

Now for the real stuff:

ObjectTemplate.triggerId 200

This will allow you to put triggers into groups, so multiple triggers can do the same. FOr instance an elevato having 2 triggers: on top and on the bottom so you can always "call" for the elevator.

rem events are 0=none, 1=use, 2=shoot, 3=move, 4=explosion, 5=cp changed

ObjectTemplate.events 1

Set on which type of event the trigger will be triggered. The DICE comment explains it enough i'd say.

ObjectTemplate.hasPartner 1

When triggers work in groups set this flag to 1, so they will not interfere with each other. Forget to do this and dtrange things can happen. (I had a trigger on my elevator and one below. First I pressed the below and and jumped on the elevator. Then I pressed (while moving the elevator) the elevator switch and it stopped for a few secs to continue happily after, thats no good behaviour, aight?)

ObjectTemplate.minimumTimeBetweenTriggering 1

Obvious, time needed untill 2 trigger for it to respond

ObjectTemplate.radius 3.0

Radius in which the trigger will listen from its origin. There its a sphere of 6m in diameter

Now the trigger works, we add the objects it should trigger:

ObjectTemplate.addTriggerableTarget TheElevator

ObjectTemplate.addTriggerableTarget TheDoor

ObjectTemplate.addTriggerableTarget TheSwitch

as you can see, a simple add does the job.

Got the objects added, lets create them:

ObjectTemplate.create TriggerableTarget TheElevator

ObjectTemplate.setNetworkableInfo BasicInfo

then the physics stuff:

ObjectTemplate.hasMobilePhysics 1

ObjectTemplate.gravityModifier 0.0

ObjectTemplate.mass 1999999

ObjectTemplate.physicsType Platform

ObjectTemplate.hasCollisionPhysics 1

ObjectTemplate.setCollisionMesh Jeep_FAAV

Gravitymodifier is there to prevent it from being attracted by gravity, it will now just float. High mass to prevent it from being bumped etc. Physicstype set to platform, havent noticed much difference w/ Mesh but I didnt park a vehicle on it since it has the colmesh of a FAAV (another test thingey, dont have a platform at hand)

ObjectTemplate.addTemplate MyTrigger

ObjectTemplate.setPosition 0/0.5/0

this is something you cna do to make the trigger move w/ the object. Not needed, you can spawn it standalone too

ObjectTemplate.geometry KNI_KNIFE

to make it look like the knife, again for testing purposes

ObjectTemplate.movementSpeed 1.5

rem movementTypes are 0=transitional, 1=rotational

ObjectTemplate.movementType 0

here comes the fun part. Movement speed controls how fast the thing moves around. Type is 0 or 1, again explained by the comment.

ObjectTemplate.delayBeforeStart 2.000

Thats how long we have to wait before it starts to move after triggering

ObjectTemplate.cycles 0

How many times it gets repeated (?) Didnt try

Now you cna have it rotate or move, the elevator moves (translates) and the door and switch turn (rotate). Switch turns because if you do it fast enough itll look like it gets flipped.

All this stuff is usually saved in TriggerableTemplates.con in the main maps folder.

Now we place it all in the map.

These triggers need to be spawned using Triggerables.con file in the maps main folder,NOT staitcobjects as they have networkables added. This could a an example Triggerables.con:

Object.create MyTrigger

Object.absolutePosition 62/26.000/-90



Object.create MyTrigger

Object.absolutePosition 62/36.000/-90



Object.create TheElevator

Object.absolutePosition 62/26.000/-100

Object.absolutePositionSecondary 62/36.000/-100



Object.create TheDoor

Object.absolutePosition 72/26.000/-90

Object.Rotation 0/0/0

Object.RotationSecondary 0/90/0



Object.create TheSwitch

Object.absolutePosition 72/26.000/-100

Object.Rotation 0/0/0

Object.RotationSecondary 0/90/0

As you cna see I created 2 "MyTrigger"s. Thats why you have to set the partner flag and a correct triggerid.

Notice the "secondary" values. This controls how far the object will rotate/translate. As you cna see the elevator moves up and the other objects turn 90 degrees.

Thats it for this one, I hope it will help some ppl.

Share this post


Link to post
Share on other sites

It helped me and who else matters? Nice tute, thanks mate.

Share this post


Link to post
Share on other sites
rem events are 0=none, 1=use, 2=shoot, 3=move, 4=explosion, 5=cp changed

ObjectTemplate.events 1

Set on which type of event the trigger will be triggered. The DICE comment explains it enough i'd say.

Nice info harry, but have you tried using any other event other than 1 on triggerables, I tried and could only get event 1 to work, I really wanted to have the triggerable start after a switch was shot.

Mind you I did the testing when SF was released, before the editor and latest patch updates.

Share this post


Link to post
Share on other sites

Hmm I tried "move" which works and "shoot", "explosion" and "cpstatuschanged" (I did put the cp within the radius, yes:P) which dont. Now this may be because of the lack of an armor component, not sure. Ill try it out sometime if nobody is ahead of me.

Share this post


Link to post
Share on other sites

i have tested the other events not sure wich one worked but one thing i know some of them work explosion work just explode c4 inside the radius and the shoot one i thing its the same shoot inside the radius

Share this post


Link to post
Share on other sites

Remember though were talking about trigerables not triggers, there's a difference. All input's work for me with triggers just not triggerables.

Share this post


Link to post
Share on other sites

BUMP:

I wanted to create a trigger so that when there was an explosion on / near a SAM site.

There would be fire and smoke coming off it for a couple of minutes indicating to everyone clearly that it had been destroyed and that it is yet to respawn.

(also so that as long as a bomb was close enough to the sam, when the explosion trigger is activated the fire would appear and burn up anyone sitting on the SAM)

I am using tweakerbar.

For testing I have placed a [move] area & attached a [bird] effect and [smoke] effect...

The bird effect works fine.

But no matter what I try I can't get the smoke to show.

PS.

In the tweaker bar for smoke there is a option [....] that opens a grid that you can plot a line on.

I have tried different lines but have no idea what it is for or how it effects it.

Can anyone point me in the right direction please ?

Share this post


Link to post
Share on other sites

Wring thread, triggerables are moving objects liek lifts etc, you are looking for effects. Try looking in the effects section of this forum.

Share this post


Link to post
Share on other sites

I have a question that's buggin' the hell out of me. I'm adding some triggerables into my map, the lift/elevator works right but when i try to rotate an object it only rotates it by the anchor in the middle of the object. So it gets the see-saw effect. I was trying to rotate a few things on their egde, like a real door. I tried many many different settings with the triggerable target tweaks but no luck. A few of the objects I was trying to rotate were the helicopterpad_01 and construct_metal_plate. Hope someone can be of assistance... would be forever greatful!!!

Share this post


Link to post
Share on other sites

You need to re-model the object and set the pivot point to the edge of the model, that is the way I know would work, failing that you could try adding to the objects code:

ObjectTemplate.setPivotPosition

Share this post


Link to post
Share on other sites

I was afraid of that... I did try the "ObjectTemplate.setPivotPosition" line in the triggerabletemplates.con after I saw your post, but i didn't see any changes. I may have found a better solution to my problem, though, by just making the doors slide vertically.

Your help is much appreciated Croupier!

Share this post


Link to post
Share on other sites

Here's a test for you Nathan, try cloning the object you wan't as the door (by renaming) then add the ObjectTemplate.setPivotPosition to the newly renamed objects tweak.

Share this post


Link to post
Share on other sites

Hrmmm... is there a way to disable a trigger if the object it rotates is also destructable? Thinking specifically of a gate door that can be opened from the inside (like the gates on Devil's Perch), but can also be blown with C4 from the outside. Or would I run into the problem of the trigger rotating the geom1_wreck geometry?

Share this post


Link to post
Share on other sites

I think it will rotate the wreck aswell, if you want to be sure id say try it out :P.

If you want that disabled you could try python if there is only one door in the map. If oyu catch the onDestroyEvent and just move the trigger to some ridiculous place or disable it the door will stay open/closed.

Share this post


Link to post
Share on other sites

Alright - I worked up an experiment - got a gate door with a switch and a pull handle and all that. Triggers work great. Handle comes down and the door swings open. Went back and added the wreck geometry and setup my cons and tweaks to be destructible with armor components and the nuts. But the door wouldnt blow. Checked the standard stuff (not placed in the terrain or another static, etc). After a bit of tinkering, I did notice that the triggerables in the Editor do have a .isDestructable flag - but setting that didnt help. The only thing I got to halfway work was to manually add an armor component to the TriggerTemplate itself (which seems like the wrong thing to do ... Im guessing that should be read in when you point to the static). It blew, but it also disappeared completely. :blink: Trigger still functioned without an error or anything funny going on. Still going to play with it a bit more, but a disappearing door might still do what I need it to.

Share this post


Link to post
Share on other sites

No, I dont think so ... there was a lot of smoke, a flash and whatnot but I think that was generated by the C4 packs themselves.

Share this post


Link to post
Share on other sites

What is the object type of your door? (That is added to the triggerable) I haven´t created any destroyable objects with a wreck other than pco´s, so I am just wondering, if it might be required to be a pco to use a wreck mesh.. If the object type is a destroyable object you should atleast be able to use the emitters in an armor effect to spit out the pieces of the broken gate.

Share this post


Link to post
Share on other sites

A destroyable static has its healthy geometry in geom0 and the wreck in geom1.

Idk if you can have a triggerable static as a destroyable but there's really no reason why it shouldn't work.

Share this post


Link to post
Share on other sites

there should be some sounds, the SF elevator uses it too

ObjectTemplate.addTemplate S_CarrierElevator_Startup

rem *** TriggerableTargets also understand "_Moving and "_Finished" as sound events.

rem ObjectTemplate.addTemplate S_CarrierElevator_Moving

rem ObjectTemplate.addTemplate S_CarrierElevator_Finished

change CarrierElevator into the name of your triggerable and it should work (provided you create/add the sounds properly, I guess it works much liek with firearms and other automated sounds)

Share this post


Link to post
Share on other sites

The sound doesnt move along? In that case idk. You could add a sound to it but I know of no way to trigger it. YOu oculd try to addtemplate that _Moving sound to it yourself see if it helps, the sound should be positional

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×