OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Wildebeest on 02 Oct 2005, 11:10:57
-
Hi!
First, take a look at my trigger and script. Any guy from side EAST gets within 5 meters of any guy in GRP1. I now want the guy from GRP1 to die (he will only die for test purposes now. I'm gonna make other stuff happen to him in the real mission).
Now, as you can see, the EAST guy activates the script and becomes "_killer (select 0)" who I then can check the distance to from "_X" in GRP1. But how can I make the guys from GRP1 execute the script as well and become "select 1"? Because now I can't determine who in GRP1 that has been close to the EAST guy. I would like "_X" to die when he's 5 meters away from "_killer".
TRIGGER:
Activated by EAST
Con: this
Act: "[_x] exec {VC\kill1.sqs}" forEach thislist
;kill1.sqs
_killer = _this select 0
@"_x distance _killer < 5" count units grp1 > 0
Thanks :)
-
I am not sure what you mean by units in grp also executing the script? Are they also East, if so they will already, and be the killer.
Anyway, is this what you want to do:
;kill1.sqs
_killer = _this select 0
_units = units grp1
#mainloop
_i=0
#loop
_unit = _units select _i
if (_killer distance _unit <5) then {goto"foundhim"}
_i = _i + 1
if (_i < count _units) then {goto"loop"}
goto"mainloop"
#foundhim
.
.
.
_unit will then be one of the guys that is < 5 from _killer.
-
Yes! That worked exactly the way I wanted it to. Thanks THobson. GRP1 is a west group btw.
Thanks again! :)
-
if your topic is solved press the solve button bottom of your page
-
i'm pretty sure you don't need a loop to do it
;kill1.sqs
_killer = _this select 0
"?_x distance _killer <= 5:_x setdammage 1" foreach units grp1
or if you needed to use them later...
;kill1.sqs
_killer = _this select 0
_found = []
"?_x distance _killer < 5:_found = _found + [_x]" foreach units grp1
blah blah blah...
use _found to do stuff to all of the found people
-
That second one is neat. It will find all the units < 5, the loop will only find the first one it comes to.
-
Except that it will only run once. What is needed is for it to wait until one or more of the units in grp1 is < 5. So a loop is needed:
;kill1.sqs
_killer = _this select 0
_found = []
#loop
{if (x distance _killer < 5) then {_found = _found + [_x]} foreach units grp1
if (count _found < 1) then {goto"loop"}
-
What is needed is for it to wait until one or more of the units in grp1 is < 5
where does it say that?
nvm misread
anyway, i can do that without a loop as well ;D
;kill1.sqs
_killer = _this select 0
_found = []
;the only change made
@"_x distance _killer <5" count units grp1 >= 1
"?_x distance _killer < 5:_found = _found + [_x]" foreach units grp1
blah blah blah...
use _found to do stuff to all of the found people
-
Neat