OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: General Barron on 26 Mar 2003, 10:46:22

Title: "nearestObject" command
Post by: General Barron on 26 Mar 2003, 10:46:22
Is there a way to refer to all objects of a certain type when using the "nearestObject" command? I.e. would you be able to find the nearest soldier of any type (grenadier, medic, officer, et.al.)? How about the nearest static object of any type (bush, ammo box, tree, et.al.)?
  It would be EXTREMELY helpfull if somebody knew how to do this. I need this for a couple scripts I'm making. One of them will make the closest soldier get up and man a specified MG when its gunner dies. Another is going to be a script that makes the AI lay suppressive fire while a man sprints forward towards cover, then he lays fire while the next man moves forward, etc.

I hope there is a simple way to do this. Right now I can only refer to a specific object, i.e. "SoldierWB", but I want to refer to all soldiers, etc. Any help would be greatly appreciated.
Thanks! :D
Title: Re:"nearestObject" command
Post by: Rubble_Maker on 26 Mar 2003, 13:07:24
Unfortunately nearestObject now works only if you specify a certain unit type to scan for. The workaround is to make a BIG array of all types of units you want to find, and pass each element to nearestObj in a loop. Not exactly a compfortable way, but at least it works.

btw. you can use the "Format" command to concat strings so OFP automatically generates the unit names. For example:

Format ["Soldier%1Saboteur",_side]

or something like that, then you don't have to replicate the whole array for EAST and WEST units.

Other than that, you could try to setpos triggers with activation ANYBODY, but I never did that; no idea if that would work.

Hope that helps.
Title: Re:"nearestObject" command
Post by: General Barron on 26 Mar 2003, 21:42:17
Thanks Rubble_Maker, that helps alot. I'll be experimenting with this now. Thanks again!