Arma 3
Trying to get a position from arrays of nearestObjects
As the title suggest i am trying to get some position from arrays of the command "nearestObjects". I want the "nearestObjects" to look for a certain amount of house, so i can identify a village or town with the script and then use the average of all the listed house in the array. That way the position i am after will not be heavily affected by one or two houses caught in the calclated radius.

_Center = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition");
_mapsize = (_Center select 0)*2;
_RandomStartPos = [_Center, (_mapsize*0.77), (_mapsize*0.78), 3, 1, 20, 0] call BIS_fnc_findSafePos;
sleep 1;
player moveInCargo [_heli,5];

_enemySpawnPos = [_RandomStartPos, (_mapsize*0.7), _mapsize*0.71, 3, 0, 20, 0] call BIS_fnc_findSafePos;
createMarker ["marker2",_enemySpawnPos];
"marker2" setMarkerShape "ELLIPSE";
"marker2" setMarkerSize [500,500];
"marker2" setMarkerText "Enemy resupply line";
"marker2" setMarkerAlpha 0.5;

_findhouses = nearestObjects [_enemySpawnPos, "house"", (_mapsize*0.2)]; //small problems on this line
_divide = count _findhouses;
_fortifiedpos = _findhouses/_divide; //The bigger problem
createMarker ["marker3",_fortifiedpos];
"marker3" setMarkerShape "ELLIPSE";
"marker3" setMarkerSize [500,500];
"marker3" setMarkerText "Enemy resupply line";
"marker3" setMarkerAlpha 0.5;


I not really sure how should proceed, because i dont think the line "_fortifiedpos" will work, the problem above prevents it from execute. "nearestObjects" contains arrays of the houses and the houses also have arrays, if there isnt a command that would merge the arrays.
If anyone have any input that would be nice, arrays are some a bit new to me so this is kind of over my head.
< >
Showing 1-2 of 2 comments
MrMessy187 Dec 24, 2016 @ 7:13am 
_divide = count _findhouses;
_fortifiedpos = _findhouses/_divide; //The bigger problem
createMarker ["marker3",_fortifiedpos];

the _fortifiedpos var is Array / number // you cant do a calc on array / number.
the marker position isnt a position its the same array of houses // _fortifiedpos array of houses

i think you will want to loop each house in the array..

if (count _findhouses > 0) then {
{

//some code to do something to each house in the array.

} foreach _findhouses;
};

the array in each house is an array of positions within the house.. for spawning things inside houses etc..

Domino
FederalRazer89 Dec 25, 2016 @ 11:33am 
Thanks for the input.

Thought of a way that might be easier to code, but i am not sure how or which commands to use.

If i search for a random house in the chosen radius then test for a house that have more house around them. But i am not sure how to make i so it will do it untill it find a house that meats the critera.
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: Dec 22, 2016 @ 7:36pm
Posts: 2