OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Lone~Wolf on 14 Mar 2010, 15:25:40

Title: Radial Array?
Post by: Lone~Wolf on 14 Mar 2010, 15:25:40
A complicated problem, at least as I see it.

How would I compile an array of every object within a specified radius of a soldier?

 ???
Title: Re: Radial Array?
Post by: Planck on 14 Mar 2010, 18:27:11
Try:

_objectList = position mysoldier nearObjects <specified radius>


Planck
Title: Re: Radial Array?
Post by: Lone~Wolf on 14 Mar 2010, 20:03:13
ERROR Unknown operator nearObjects!

My line of scripting looks like this:

_targetList = position _c nearObjects 400

 :dry:

[EDIT] If someone could write me a .sqf file to do the job with minimum processing time I would be grateful.  :D
Title: Re: Radial Array?
Post by: h- on 14 Mar 2010, 21:17:28
nearObjects is a A1/A2 command so that's why it doesn't work.

The problem is a bit complicated as you said because the command nearestObject (http://www.ofpec.com/COMREF/index.php?action=details&id=229&game=All) has a 50 meter search radius limit, which means you would have to do a nested nearest object searches from positions around the soldier or something up until you reach the desired radius :dunno:
Maybe this would be of some help: improvedNearestObject.sqf (http://www.ofpec.com/ed_depot/index.php?action=details&id=120&game=OFP) :dunno:
Title: Re: Radial Array?
Post by: Lone~Wolf on 14 Mar 2010, 21:31:05
Um, no offence but what does your script actually do?  ???
I've looked over it but can't figure out:

A.  How to use it.

[EDIT] Okay, I've determined what the script does, and it does exactly the same job as pablo's closesttarget.sqf script... which is to take an array and then determine the nearest object, backwards of what I need.  :confused:

B.  Whether it does what I asked - A .sqf file to create an array that consists of every object within a 500m radius of an object.

P.S. An alternative method, albeit more tedius, would be to add nearestObject returns to the array where it checked for the nearest object repeatedly in concentric circles around the player.
Title: Re: Radial Array?
Post by: h- on 15 Mar 2010, 08:22:57
It's not my script, and didn't even check the script I linked, just thought it might have something in it that could steer you to the right direction.

I don't think what you want is possible/feasible because the only way to find objects in OFP is nearestObject, and it returns on single object per search, so you would need to do searches around the soldier for like 1 meter intervals until you have searched the whole 500 radius area which comes to hundreds, if not thousands of searches which would crash OFP in an instant.
Title: Re: Radial Array?
Post by: Raptorsaurus on 17 Mar 2010, 01:33:42
I made a function that finds multiple objects within a given distance of a given object. Actually, more than one function, one finds everything, the other finds objects of a given type. They are both attached. Instructions are in the function headers.

I do not advise using this function using a radius too large. I think that 500 m radius will probably crash OFP as h- says. You use it in a script that check smaller sections in a loop that will move the check area around until you cover the larger area. Or, if you do have a larger search radius, you could set the search increments to a large value (like 10 m), then you may be able to search a 500 m radius in one call of the function, but you would then miss many items. The largest area I have entered for the function is 150 m with a search increment of 5 m.