OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Wildebeest on 03 Oct 2005, 20:57:44
-
Helleuo!
I want something to happen to any unit in a group when he gets too far away from the other guys in the group. How can I do this? Like something with "_X distance _runguy > 1292" foreach units grp1... blah blah, or what?
The idea is that when someone leaves the group he will be attacked by an enemy squad that surrounds him and, if they get close enough, hits him over the head :tomato: and takes him prisoner.
Can you help me? Thanks
-
Try a script with something like this:
@({_x distance leader _x > 1234} count units groupName > 0.5)
_units = []
{if (_x distance leader _x > 1234) then {_units = _units + [_x]}} forEach units groupname
_units will then be an array of all units in the group that are > 1234 from their leader
Syntax not guaranteed
-
Cool, I don't understand all of it but I guess something happens when a guy is 1234 away from the leader of the group and not from any group member, correct?
I only want something bad to happen when he is alone, like no friendlies nearby. But then again I'm not very good at scripting and as I said don't get all of it. :-\
Couldn't you check whether the guy is 1234 meters away from any west unit instead? Like you have one big trigger over the map and use "thislist" etc or something?
_X distance _westunit blah blagh?
Thanks
-
Oh, yes you could! I solved it with the help of the other nice script you made for me earlier, THobson.
In init.sqs I put "[_x]exec{runoff1.sqs}" forEach units grp1.
;runoff1.sqs
_kidnapper = _this select 0
_units = units grp1
#mainloop
_i=0
#loop
~0.1
_unit = _units select _i
if (_kidnapper distance _unit >1234) then {goto"continue1
"}
_i = _i + 1
if (_i < count _units) then {goto"loop"}
goto"mainloop"
#continue1
;stuff will happen here
If anyone in the group wanders off it goes to #continue1
Thanks a lot man!