OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Cheetah on 28 May 2007, 16:58:45

Title: Returning roads with nearestObject
Post by: Cheetah on 28 May 2007, 16:58:45
Should be simply, but can't find the classnames of a road. So I don't know how to put the nearestObject(s) into action.
I'd like to use it to make a civilian run to the nearest road, dynamically.
Title: Re: Returning roads with nearestObject
Post by: Mandoble on 28 May 2007, 17:12:25
Was trying to find the types with:
road = position player nearestObject 462870; hint format["%1", typeOf road]

using different road segment ids on the map. Sadly nearestObject fails miserably with road ids  :blink:
Title: Re: Returning roads with nearestObject
Post by: Cheetah on 28 May 2007, 17:15:20
Thought that you can't use the object ID? Might explain why it's not working. Anyway, I couldn't find a list of roads / streets anywhere.
Title: Re: Returning roads with nearestObject
Post by: Mandoble on 28 May 2007, 17:19:19
Yes, you can use object ids for nearestObject command, it works with most object types, but not with roads  ???
Title: Re: Returning roads with nearestObject
Post by: Planck on 28 May 2007, 19:31:36
Hmmm.........roads don't have classnames, they are embedded into the .wrp file and don't need a classname, consequently there are no configs for roads, unless you count bridges.


Planck
Title: Re: Returning roads with nearestObject
Post by: Cheetah on 29 May 2007, 00:32:41
Hmm, I'll have to find another way to do it. Have a couple of ideas. Thanks gents.
Title: Re: Returning roads with nearestObject
Post by: Mr.Peanut on 12 Jun 2007, 19:07:39
Before doing anything use Mandoble's snippet in various locations to get the name string for various road objects, to see if they have any part of their name in common that is unique to roads. If there is then:

Code: [Select]
(nearestObjects [player,[], 50]) - ((getPos player) nearObjects 50)
Returns an array of objects within 50m of the player that have no class, including things like roads and trees.

Then use Kronzky's string functions to scan the string name of each object for the common name part.

The only problem with this is the Kronzky's string functions cause very bad resource sucking lag, and searching 50 strings for a substring would be crazy. You would have to manually insert some pauses in his functions.
Title: Re: Returning roads with nearestObject
Post by: Mandoble on 12 Jun 2007, 19:18:02
May be you can check for those returned objects which bounding box has a quite low height/width or height/length ratio. If that works, you would not need to use any string comparison.
Title: Re: Returning roads with nearestObject
Post by: Mr.Peanut on 12 Jun 2007, 20:09:19
Ah, yes! Use bounding box for the first pruning, and then string comparisons for whatever is left.