Home   Help Search Login Register  

Author Topic: nearestobjects question  (Read 2277 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
nearestobjects question
« 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?

Code: [Select]
_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]
« Last Edit: 17 Jul 2007, 17:53:34 by Blanco »
Search or search or search before you ask.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: nearestobjects question
« Reply #1 on: 17 Jul 2007, 17:40:42 »
dead units side is civilian.

Offline Blanco

  • Former Staff
  • ****
Re: nearestobjects question
« Reply #2 on: 17 Jul 2007, 17:53:00 »
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:

Code: [Select]
?((side _m == CIV) OR (side _m == side player)): _list = _list - [_m]

« Last Edit: 17 Jul 2007, 18:13:48 by Blanco »
Search or search or search before you ask.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: nearestobjects question
« Reply #3 on: 17 Jul 2007, 18:31:16 »
civilian side is civilian, not CIV

Offline Blanco

  • Former Staff
  • ****
Re: nearestobjects question
« Reply #4 on: 17 Jul 2007, 19:25:51 »
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.

Code: [Select]
_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.
Search or search or search before you ask.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: nearestobjects question
« Reply #5 on: 17 Jul 2007, 19:33:18 »
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
« Last Edit: 17 Jul 2007, 19:34:55 by Mr.Peanut »
urp!