FederalRazer89 7 Posted April 21, 2017 Hello As the title might suggest, i am trying to find a elevated position near the objectiv. I am creating a function that will place waypoint the highest point close to the objectiv, so that i can have AI sniper group/ recon group overwatch on higher ground. The way i intended to do it was to get some locations around the position, but i dont know how i would sort the array by height. The script: _reconSort = []; for "_i" from 1 to 360 do { _testpos = [_pos, random [100,200,500], _i] call BIS_fnc_relPos; _reconSort pushBack _testpos; }; _reconSort apply {[_x distance _grp, _x] }; Any help would be appreciated. Share this post Link to post Share on other sites
sarogahtyp 1108 Posted April 21, 2017 Delete it apply. Create a second array which stores nested arrays with being the first element the absl difference of the z value between the returned position and ur origin position. The second element of the nested array should be the index of ur array _reconSort.Now u can do sort with the new array then get the stored index of the element with the highest elevation and now u know which element of _reconSort is ur desired elementsent from mobile using Tapatalk Share this post Link to post Share on other sites
sarogahtyp 1108 Posted April 21, 2017 There should be a solution without arrays using the max command but I'm not on desktop now. Maybe later...sent from mobile using Tapatalk Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted April 21, 2017 Take a look into BIS_fnc_findOverwatch. Works like a charm for me. Cheers Share this post Link to post Share on other sites
FederalRazer89 7 Posted April 21, 2017 Thanks for the respons, i will try the BIS_fnc_findOverwatch and if i can get it to work. Share this post Link to post Share on other sites
crewt 31 Posted April 24, 2017 (edited) Didn't test BIS_fnc_findOverwatch lately but I recall that It did have its limitations, later on I started using a selectBestPlaces as it pretty powerfull. private _myPlaces = selectBestPlaces [position player, 50, "(1 - forest) * (1 + hills)", 1, 5] apply {ATLToASL ((_x select 0) + [0])}; //Stupid mistake... forgot that 2D positions coudn't get converted to ASL, sorry for any inconvenience private _ret = [0,0,0]; for "_i" from 0 to count _myplaces -1 do { private _pos = _myplaces select _i; if (_ret select 2 < _pos select 2) then { _ret = +_pos; }; }; // And in the ende noone would want an position in the air ASLToATL _ret That would work (as far as I haven't made some stupid mistake), but I have no capability to test it right now :/ Edited April 25, 2017 by crewt //Stupid mistake... forgot that 2D positions coudn't get converted to ASL, sorry for any inconvenience Share this post Link to post Share on other sites
FederalRazer89 7 Posted April 24, 2017 Was working so didnt have time to test it, will try it this week. Have a lot of stuff that i need to test first, but thanks for the additional suggestions, will try those if BIS_fnc_findOverwatch dont work. Share this post Link to post Share on other sites
pierremgi 4833 Posted April 25, 2017 Just math: MGI_elevatedCheck = compileFinal " _posHigh = _this select 0; _posTest = ATLtoASL _posHigh; _radius = _this select 1; if (_radius == worldSize) then { _posTest = ASLtoATL [worldSize/2,worldSize/2,0]; _radius = worldSize /2 }; _rangeSqr = MGI_range^2; _bestHigh = _posTest select 2; _n = (round _radius) min (worldSize / 10); _c = _radius / (sqrt (_n - 1)); for '_i' from _n to 0 step -1 do { _rho = _c * sqrt (_i + 0.5); _theta = 137.508 * (_i + 0.5); _ckPos = _posTest getPos [_rho,_theta]; call { if (_ckPos distanceSqr MGI_posRef > _rangeSqr) exitWith {}; if ((getTerrainHeightASL _ckPos) > _bestHigh) exitWith { _posHigh = ASLtoATL _ckPos; _bestHigh = getTerrainHeightASL _ckPos }; }; }; _posHigh "; MGI_HighestPt = { params [["_pos",[0,0,0]],["_range",worldSize]]; MGI_posRef = _pos; MGI_range = _range; _posHigh = [_pos,_range] call MGI_elevatedCheck; _posHigh = [_posHigh,_range /10] call MGI_elevatedCheck; _posHigh }; _highestPt = [<any position here>,<radius> (optional)] call MGI_HighestPt; Share this post Link to post Share on other sites
zgmrvn 95 Posted April 25, 2017 crewt's solution is fine. 1 Share this post Link to post Share on other sites
Tankbuster 1743 Posted April 25, 2017 I use findoverwatch too. Seems to work well for finding a position high up for a small radar installation. Share this post Link to post Share on other sites
pierremgi 4833 Posted April 25, 2017 Mine is working quickly on any map (no need to have declared hill locations), any radius, without any repeated BIS function. Share this post Link to post Share on other sites
FederalRazer89 7 Posted April 29, 2017 I tried to use findoverwatch and your script pierremgi but nether of them works as i want mabye there is some more i need to do. Only need to get a position that is the highest within 700m of the position. [_pos,_grp,_mode,_side] call fn_Waypointgenerating; <-------------------- Decide which objectiv to go to. sleep 1; [_pos,700] call MGI_HighestPt; _wp1 = _grp addWaypoint [_pos,30]; _wp2 = _grp addWaypoint [_pos,30]; _wp1 setWaypointType "SAD"; _wp2 setWaypointType "SAD"; }; Share this post Link to post Share on other sites
pierremgi 4833 Posted April 29, 2017 Are you use _pos is a position (like getpos player or getMarkPos "onemarker" ? I can see you are already use _pos in your first fn_waitpointGenerating. Where _pos comes from? If possible, test that before you need it: hint format ["position tested: %1", _pos]; Share this post Link to post Share on other sites
FederalRazer89 7 Posted April 29, 2017 The _pos is just the group leaders position, but the varible _pos gets new coordinates from the fn_waitpointGenerating function. I have done several test with the fn_waitpointGenerating function and i know that it will give a new position, but i can show you the function. The function is about 100 lines long so i cut out some of the code. fn_Waypointgenerating = { _pos = _this select 0; _grp = _this select 1; _mode = _this select 2; _side = _this select 3; _MatMRK1 = getMarkerPos "MaterialsiteMRK1"; _MatMRK2 = getMarkerPos "MaterialsiteMRK2";--------------------Several markers ------------------------- _FuelMRK6 = getMarkerPos "FuelsiteMRK6"; _chosePos = _pos; _AttackerArrayNato = []; _DefenderArrayNato = []; _AttackerArrayCSAT = []; _DefenderArrayCSAT = []; -------------------------Cut ----------------------------------------- if (_mode == 3) then { if (NATO_MaterialSite1 == 0) then {_AttackerArrayNato pushBack _MatMRK1};if (CSAT_MaterialSite1 == 1) then {_AttackerArrayNato pushBack _MatMRK1}; if (NATO_MaterialSite2 == 0) then {_AttackerArrayNato pushBack _MatMRK2};if (CSAT_MaterialSite2 == 1) then {_AttackerArrayNato pushBack _MatMRK2}; if (NATO_MaterialSite3 == 0) then {_AttackerArrayNato pushBack _MatMRK3};if (CSAT_MaterialSite3 == 1) then {_AttackerArrayNato pushBack _MatMRK3}; if (NATO_MaterialSite4 == 0) then {_AttackerArrayNato pushBack _MatMRK4};if (CSAT_MaterialSite4 == 1) then {_AttackerArrayNato pushBack _MatMRK4}; if (NATO_MaterialSite5 == 0) then {_AttackerArrayNato pushBack _MatMRK5};if (CSAT_MaterialSite5 == 1) then {_AttackerArrayNato pushBack _MatMRK5}; if (NATO_MaterialSite6 == 0) then {_AttackerArrayNato pushBack _MatMRK6};if (CSAT_MaterialSite6 == 1) then {_AttackerArrayNato pushBack _MatMRK6}; if (NATO_MaterialSite7 == 0) then {_AttackerArrayNato pushBack _MatMRK7};if (CSAT_MaterialSite7 == 1) then {_AttackerArrayNato pushBack _MatMRK7}; if (NATO_MaterialSite8 == 0) then {_AttackerArrayNato pushBack _MatMRK8};if (CSAT_MaterialSite8 == 1) then {_AttackerArrayNato pushBack _MatMRK8}; if (NATO_MaterialSite9 == 0) then {_AttackerArrayNato pushBack _MatMRK9};if (CSAT_MaterialSite9 == 1) then {_AttackerArrayNato pushBack _MatMRK9}; if (NATO_MaterialSite10 == 0) then {_AttackerArrayNato pushBack _MatMRK10};if (CSAT_MaterialSite10 == 1) then {_AttackerArrayNato pushBack _MatMRK10}; if (NATO_FuelSite1 == 0) then {_AttackerArrayNato pushBack _FuelMRK1};if (CSAT_FuelSite1 == 1) then {_AttackerArrayNato pushBack _FuelMRK1}; if (NATO_FuelSite2 == 0) then {_AttackerArrayNato pushBack _FuelMRK2};if (CSAT_FuelSite2 == 1) then {_AttackerArrayNato pushBack _FuelMRK2}; if (NATO_FuelSite3 == 0) then {_AttackerArrayNato pushBack _FuelMRK3};if (CSAT_FuelSite3 == 1) then {_AttackerArrayNato pushBack _FuelMRK3}; if (NATO_FuelSite4 == 0) then {_AttackerArrayNato pushBack _FuelMRK4};if (CSAT_FuelSite4 == 1) then {_AttackerArrayNato pushBack _FuelMRK4}; if (NATO_FuelSite5 == 0) then {_AttackerArrayNato pushBack _FuelMRK5};if (CSAT_FuelSite5 == 1) then {_AttackerArrayNato pushBack _FuelMRK5}; if (NATO_FuelSite6 == 0) then {_AttackerArrayNato pushBack _FuelMRK6};if (CSAT_FuelSite6 == 1) then {_AttackerArrayNato pushBack _FuelMRK6}; }; }; if (_side == west) then { if (_mode == 1) then { _AttackerArrayNato = _AttackerArrayNato apply {[_x distance _pos, _x] }; _AttackerArrayNato sort true; _chosePos = (_AttackerArrayNato select 0) select 1; }; if (_mode == 2) then { _DefenderArrayNato = _DefenderArrayNato apply {[_x distance _pos, _x] }; _DefenderArrayNato sort true; _chosePos = (_DefenderArrayNato select 0) select 1; }; if (_mode == 3) then { _AttackerArrayNato = _AttackerArrayNato apply {[_x distance _pos, _x] }; _AttackerArrayNato sort true; _chosePos = (_AttackerArrayNato select 0) select 1; }; }; _pos = _chosePos; }; Share this post Link to post Share on other sites
pierremgi 4833 Posted April 29, 2017 (Please test the hint, it's far quicker than trying to debug this with no idea of your initial parameters.) Sorry, i didn't see that before but you need to return the results like this (no matter the variable name but keep consistency): _pos = [_pos,_grp,_mode,_side] call fn_Waypointgenerating; ..... _pos = [_pos,700] call MGI_HighestPt; Share this post Link to post Share on other sites
FederalRazer89 7 Posted April 29, 2017 My function work with out any problem, its just that when i tried to add your function to get a position on the location on the objectiv it does nothing. Not a singel error is shown or disrupted any of the script, so i not sure what to look for. But i will test some more and se if i can get it to work. Share this post Link to post Share on other sites
pierremgi 4833 Posted April 29, 2017 3 minutes ago, FederalRazer89 said: My function work with out any problem, its just that when i tried to add your function to get a position on the location on the objectiv it does nothing. Not a singel error is shown or disrupted any of the script, so i not sure what to look for. But i will test some more and se if i can get it to work. I changed my post above: return the result. Share this post Link to post Share on other sites
FederalRazer89 7 Posted April 29, 2017 will try it out Share this post Link to post Share on other sites
FederalRazer89 7 Posted April 29, 2017 pierremgi it work, Thanks. Share this post Link to post Share on other sites