Home   Help Search Login Register  

Author Topic: Nearest object that does not include player  (Read 1597 times)

0 Members and 1 Guest are viewing this topic.

Sniperwolf572

  • Guest
Nearest object that does not include player
« on: 15 Dec 2005, 23:42:50 »
I'm trying to script something but I've ran into a problem, I'm trying to do something in condition field of UserActions in a certain config.cpp of an addon, the line goes like this:

Code: [Select]
condition="this distance (nearestObject [this, ""TEN_TestMarine""]) <2";
The code works fine, but the problem is that script detects me, because I'm the same unit class (TEN_TestMarine) and I have another unit of that class 50m away, condition triggers right away because it detects me as that class, but I want it not to detect me, but the next closest soldier of the same class.

Is there any way to do this?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Nearest object that does not include player
« Reply #1 on: 17 Dec 2005, 10:00:18 »
I can't think of a way of doing this I'm afraid.

Offline 456820

  • Contributing Member
  • **
Re:Nearest object that does not include player
« Reply #2 on: 17 Dec 2005, 10:10:34 »
if this is about a config.cpp shouldnt it be placed under Addon editing ?

anyay im not sure about an answer either

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Nearest object that does not include player
« Reply #3 on: 17 Dec 2005, 12:07:52 »
Welcome to the forum!

Well I can figure out an answer, but it's not pretty.   And I'm not sure if it will work in an addon, since I don't know about addons.

Create a gamelogic.   Run the nearest object test on the gamelogic:  test the result to see if its the player or another unit.   If its another unit stick it in an array.    Move the gamelogic to its next location and repeat.    At the end you'll have an array of candidate objects:  run distance or other tests on them to discover the one you want.

You'll need to experiment to discover the best pattern for the gamelogic's movements.  For example you might start it 10m north of the player, then 10m east, west and south.   Then 15m NE, SE, SW and NW.    Similarly at 20m out and so on.    Or something.
« Last Edit: 17 Dec 2005, 12:11:13 by macguba »
Plenty of reviewed ArmA missions for you to play

Sniperwolf572

  • Guest
Re:Nearest object that does not include player
« Reply #4 on: 03 Jan 2006, 00:24:12 »
OK, Issue solved by using:

Code: [Select]
condition="(This!=Player) And ((GetDammage This >0.7) And (GetDammage This <0.95))";
on the units, thanks to UNN for assistance.

EDIT:
@macguba:

Date Registered:     July 08, 2003, 12:22:26 AM

 :P
« Last Edit: 03 Jan 2006, 12:51:02 by Sniperwolf572 »