Jump to content
Sign in to follow this  
Rydygier

How to filter out certain objects without class from all objects around?

Recommended Posts

If I use for example:

	_nObj = nearestObject _pos;

This will return nearest object regardless of its class or lack of class (building, rabbit, tank, tree, unit, dragonfly, road segment...). Great. But how to achieve returning of a tree or bush object, but not road (or even certain kind of road segment, so nearRoads is only partial solution for roads segments) or fly? How to "sift out" only chosen part/kinds of class-less objects if possible at all?

Edited by Rydygier

Share this post


Link to post
Share on other sites

The wiki page explains this.

http://community.bistudio.com/wiki/nearestObject

In the type field, you can put almost anything from the hierarchy. From as wide as "MAN" to as narrow as "HMMWV".

While we're on the subject, if you want to save a couple of CPU cycles, use nearObjects. It's as above except that it doesn't sort the result array by distance.

Share this post


Link to post
Share on other sites

Thanks, I of course have read biki's info about this command (must be nearest, cause I need nearest one only). So I know, that I can filter out only some class (or multiple classes for similar commands), also with higer hierarchy. Also I know, that without filtering by class, all objects will be considered, even class-less (and this is needed, I'm also after class-less objects here). My question is - with what code I can filter out only some of class-less objects, and keep other class-less considered. Eg. I want to know about closest to _pos fences, walls, trees or bushes but not about ponds, insects, other (so must sift out rest of class-less objects somehow...),

Edited by Rydygier

Share this post


Link to post
Share on other sites

I feared that's what you were asking. :)

AS far as I know, the type field can't be used to exclude, only include.

nearestObjects allow more than one class to be specified. Have you tested to see if nearObject does too?

I fear that the only way you can do what you want is to grab a big array of nearestObjects filtered as best you can using type and then work on the array in a second script.

Share this post


Link to post
Share on other sites

If they were important only objects with defined classes, then I would get along with filtering somehow. But what to do, when there is no defined class for some object (as ponds, plants, stuff...), that I could put into filter array one of near/nearest commands?

I'm thinking about retrieving object's .p3d file (nearestObject without any filter could return for example something like that: "244581: b_betulahumilis.p3d" and then typeOf _nObj returns empty string, means - no class for that object, that may be used as filter), then to do some string comparison to determine, what is it, but: isn't there a better way, that to construct huge array of strings for each possible .p3d?

---------- Post added at 12:46 ---------- Previous post was at 12:24 ----------

Maybe some example: currently I gonna to try this:

	_nObj = nearestObjects [_pos, [], 50];
_nObj2 = _nObj;
_nR = _pos nearRoads 50;
{if (_x in _nR) then {_nObj = _nObj - [_x]}} foreach _nObj2;
_nObj = _nObj select 0;

If it will work, then I'm able to sift out at least road segments. But to do same with other class-less objects, I would need eg nearPonds command for ponds etc...

Edited by Rydygier

Share this post


Link to post
Share on other sites

Hi,

I am allso having difficulty using this sort of command, so I will be watching this thread closely.

Please keep us informed of any progress. Thanks

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×