The trigger system works pretty simple:
-Create a trigger
-Create a Triggerable
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)
Now for the real stuff:
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.
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?)
Obvious, time needed untill 2 trigger for it to respond
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
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.
Thats how long we have to wait before it starts to move after triggering
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.