Home   Help Search Login Register  

Author Topic: Attaching a trigger to an object?  (Read 724 times)

0 Members and 1 Guest are viewing this topic.

Mashed-Potatoz

  • Guest
Attaching a trigger to an object?
« on: 18 Oct 2004, 23:33:11 »
is it possible to attach a trigger to an object?  if so can someone please tell me how?  and if not, is there a way to make a squad eject out of a plane when they are close to the player?

Kammak

  • Guest
Re:Attaching a trigger to an object?
« Reply #1 on: 19 Oct 2004, 00:03:15 »
A trigger is just a funning looking script that is always running.  You can put anything in the Condition field that you would put in a script...the nice benefit is that triggers can give you an array of units in an area.

So...yes to your question.

If you want to fire a script when two items get close, use something like the following in a trigger:

Axis a/b/angle all 0
Activation: none
Type: none

Condition:
obj1 distance obj2<100

On Activation:
<put your script call or statements here>

Then, whenever the two objects are within 100 meters, in this example, whatever is in the "On Activation" field will happen.

If you something to happen when a specific unit or group enters a an area, set the trigger axis and angle to whatever you need, set the Activation to the unit/group's side, Present.  In the Condition, put

<unit name> in thislist

for a unit check, or for a group check put

"group _x==<group name>" count thislist>0


Does that help?



Kammak

  • Guest
Re:Attaching a trigger to an object?
« Reply #2 on: 19 Oct 2004, 00:12:33 »
If you want to check for an entire group and not just any member of the group, use:

("group _x==<group name>" count thislist) == ("alive _x" count units <group name>)

In this case, the trigger will only fire when *everyone* in the group is in the trigger area.

To check for just the leader of group:

(leader group <group name>) in thislist

etc...


There is a way to build these same statement graphically, by dragging a unit to a trigger, (or the other way around), but I find the code much simpler to work with than tracing little blue lines across the map.  Just personal preference.  :)


Mashed-Potatoz

  • Guest
Re:Attaching a trigger to an object?
« Reply #3 on: 19 Oct 2004, 02:37:58 »
i tryed all that and my squads dont seem to be ejecting when they fly over/by me.



that's how it should look right?

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Attaching a trigger to an object?
« Reply #4 on: 19 Oct 2004, 22:10:19 »
Well, keep in mind the distance command works in 3 dimensions.... so if the chopper were at 100 meters in altitude, it would have to be exactly right on top of you, or else it will be further than 100 meters away from you. If you want a 2d distance, you need to only use the x and y coordinates of the plane's position, and use the good ol' pythagorean theorem to find the distance:

condition:

( ((getpos plane2 select 0) - (getpos player select 0))^2 + ((getpos plane2 select 1) - (getpos player select 1))^2 ) < 10000

Now I didn't throw the square root in there because you don't really need it in this case, if you just square the distance also. Square roots are kinda hard on the cpu, so I try to avoid them.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Tomb

  • Contributing Member
  • **
  • in2 Metal? Go 2 my sig
Re:Attaching a trigger to an object?
« Reply #5 on: 20 Oct 2004, 13:50:29 »

i tryed all that and my squads dont seem to be ejecting when they fly over/by me.

(image removed)  ...that's how it should look right?



 ;) heya m8, your problem is most likely the "activation" box; see when you select
<< ALLIES >> and then set the trigger size to 50x50 then its very likely that the plane will miss that trigger. :o

What you need is either to set the trigger size to some 350x70, turn it so that the plane will fly into "a wall", so to speak,
and then ya could hit F2 and drag a grouping line from trigger to aircraft. And make it a SWITCH trigger type

 :D This way, no one else but that plane can activate the trigger. :thumbsup:

Or you could do other things (no need to mention these, this will work just fine!)  ;) ;D

later :-*


« Last Edit: 20 Oct 2004, 13:51:16 by Tomb »

Mashed-Potatoz

  • Guest
Re:Attaching a trigger to an object?
« Reply #6 on: 20 Oct 2004, 19:00:44 »
whoohoo, it works now.  thanks for the help guys.