Jump to content
Zjajo

Trouble with finding objects near location

Recommended Posts

I am having trouble with a couple of locations that return 0 objects found and therefore does not create a marker, but the location does have around 150 objects. What I am trying to do is:

- search the map for locations, stored in an array

- At each location I search for objects of typeName "House_F", stored in an array

- I then create an ELLIPSE marker at each location with a radiusA/B equal to the amount of objects in the object array for that location, so for example Chapoi on Malden has ~300 objects of typeName "House_F" making the ELLIPSE marker 300x300

 

The problem is that the marker is created for most of the cities correctly, but does not create the marker for a military base near the airport and for Arudy(on Malden of course).

 

How I am testing this:

- Load Malden in the editor

- Place character down anywhere on map and select "Play as character"

- Open debug console and paste whats in the spoiler, select LocalExec

- Open map and see locations that do and do not have markers

- Check RPT to verify that locations have been logged along with the number of objects found near them

Spoiler

_locations = nearestLocations [getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition"), ["NameCityCapital","NameLocal","NameCity","NameVillage","Strategic","CityCenter","NameMarine"], 25000];
{
    _town = text _x;
    _className = className _x;
    _type = type _x;
    _list = locationPosition _x nearObjects["House_F", 250];
    //diag_log format[ "ConfigName = %1", _className ];
    _name = format["mrk_%1", _town];
    _locationCountTotal = count _list;

    _mrk = createmarker [_name, locationPosition _x];
    _mrk setMarkerShape "ELLIPSE";
    _mrk setMarkerSize [_locationCountTotal, _locationCountTotal];
    _mrk setMarkerBrush "SOLID";
    _mrk setMarkerColor "ColorRed";
    _mrk setMarkerAlpha 0.6;
    
    diag_log format["Location: %1    ....Size: %2    ....Type: %3", _town, _locationCountTotal, _type ];
}forEach _locations;

 

Does anyone know why it returns 0 objects for Arudy and the military base near the main airport, and would you know how to remedy this?

 

I am using this method because it works better than grabbing radiusA and radiusB from the config because a lot of the locations do not have an appropriate radius for the actual location size. On Malden, Faro (in the bottom left of island) only has a few buildings on a coastline yet creates a marker with a size of 574x360, which is far too big for that tiny village.

 

 

EDIT: I just tested another way by placing a character in the town of Arudy, searching for nearestLocation, searching for objects of typeName "House_F" near the location, creating the marker with a size equal to amount of objects found and it all works fine. It works if I single Arudy out and do it by itself, but not when I group it with all the other locations. Hmm...

Share this post


Link to post
Share on other sites

That's probably because some locations have the same (generic) name instead of a geographic one. I had to cope with the location position (stringed as name) for my markers. You can't have two markers with the same name.

Share this post


Link to post
Share on other sites
On 2/26/2020 at 10:17 AM, pierremgi said:

That's probably because some locations have the same (generic) name instead of a geographic one. I had to cope with the location position (stringed as name) for my markers. You can't have two markers with the same name.

This is what I ended up doing also. Thanks for the reply.

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

×