OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Blanco on 17 Jul 2007, 17:35:51
-
I try to create a list of all alive enemies within a 300m radius. The closest enemy should be the first one in the array.
There are a few commands I can use like neartargets, but neartargets only returns the enemies the unit knows about, so I use nearestobjects
Works fine but all units are returned, also the dead. The name is different tho, it's something like EAST 1-1-A:9,111fdc00#5168: np soldier_b.p3d.
I try to exclude these targets with a script, but still the dead guys are in my list. What is wrong? Is there a better way to do this?
_list = nearestObjects [player, ["man"], 300]
_i = 0
_c = count _list
#exclude
_m = _list select _i
?!alive _m && side _m == side player: _list = _list - [_m]
_i = _i + 1
~0.5
?_i < _c : goto "exclude"
hint format ["%1", _list]
-
dead units side is civilian.
-
Hmm, I did a quick test and it seems units keep the side when they're dead.
edit: OK, you are right but it takes some time...
It still doesn't work when I exclude civilian units. :confused:
?((side _m == CIV) OR (side _m == side player)): _list = _list - [_m]
-
civilian side is civilian, not CIV
-
Thx, but it still doesn't work very well. Sometimes the dead still got in my list and I can't get them out even when I run the code a second time. this is what got now.
_list = nearestObjects [player, ["man"], 300]
_i = 0
#exclude
_m = _list select _i
?((side _m == civilian) OR (side _m == side player)): _list = _list - [_m]
_i = _i + 1
~0.1
?_i < count _list : goto "exclude"
I think I gonna try it in another way with an exploding trigger or so.
-
Try it also based on the unit's damage i.e. (side _m == civilian) or (damage _m > 0.95) or (side _m == side player) or !alive _m