Robustcolor 31 Posted June 5, 2021 Am i doing something wrong with these waypoints? All waypoints often just center on the position without any radius. My goal was to have something like _wp = _group addWayPoint [_position,random 100,1]; but it just center aswell. _positions = getMarkerPos "Marker1"; _wp = _group addWayPoint [_position,100,1]; _wp = _group addWayPoint [_position,100,2]; _wp = _group addWayPoint [_position,100,3]; [_group,1] setWaypointSpeed "LIMITED"; [_group,3] setWayPointType "CYCLE"; Share this post Link to post Share on other sites
pierremgi 4912 Posted June 5, 2021 _position instead of _positions But that should work. The fact is too close waypoints can be completed at once, depending on assets of group. if you don't want to rely on statistics, give your waypoints a chance to be distant from 30 m between each others: _position = getMarkerPos "Marker1"; _wp = _group addWayPoint [_position,100,1]; _pos1 = waypointPosition _wp; _pos2 = [_position,0,100,0,0,0,0,[[_pos1,30]],_pos1] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_pos2,0,2]; _pos3 = [_position,0,100,0,0,0,0,[[_pos1,30],[_pos2,30]],_pos1] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_pos3,0,3]; [_group,1] setWaypointSpeed "LIMITED"; [_group,3] setWayPointType "CYCLE"; 1 Share this post Link to post Share on other sites
Robustcolor 31 Posted June 6, 2021 @pierremgi well the thing is, this is how i execute the code. 90% of the time all wayPoints just stack in one position for all groups. They're not spread out. but atleast 1 time they may work and get spread out. params = ["_pos"]; private ["_group","_unit","_wp"]; for "_i" from 1 to 5 do { _group = createGroup [east,true]; _unit = _group createUnit ["O_G_Soldier_F",_pos,[],0,"CAN_COLLIDE"]; _wp = _group addWayPoint [_pos,50,1]; _wp = _group addWayPoint [_pos,100,2]; _wp = _group addWayPoint [_pos,150,3]; [_group,1] setWaypointSpeed "LIMITED"; [_group,3] setWayPointType "CYCLE"; uiSleep 1; }; Share this post Link to post Share on other sites
beno_83au 1369 Posted June 6, 2021 That may just be because of your use of the type "CYCLE". When a waypoint type is cycle it'll send the group to the nearest waypoint. So they won't actually go to the 3rd waypoint, they'll just go to the closest waypoint to the 3rd waypoint. So if the cycle waypoint just happens to be near the 2nd waypoint, the group will just keep cycling the 2nd waypoint. You can see it's logic (I guess?) in the editor when you put down a cycle waypoint and move it near a few different ones. 1 Share this post Link to post Share on other sites
Robustcolor 31 Posted June 6, 2021 hm, i guess it has to be a conflict with the mod map. Testing it on Altis and everything works fine. On the modded map all the created waypoints stacks up in a pile. Share this post Link to post Share on other sites
Robustcolor 31 Posted June 6, 2021 This is what happens when creating the wayPoints from the above code. all wayPoints are in that pile Share this post Link to post Share on other sites
beno_83au 1369 Posted June 6, 2021 Ohh, yeah sorry I can't help with that. Maybe there's a problem with the map/config coordinates? I don't know about mapping. Share this post Link to post Share on other sites
Robustcolor 31 Posted June 8, 2021 Where can i see how BIS_fnc_taskPatrol looks like in code? This fnc seems to work even on mod maps when it comes to making waypoints. Share this post Link to post Share on other sites
beno_83au 1369 Posted June 8, 2021 Use the function viewer from within the editor. Press tilde or Alt-d (can't remember which one is vanilla shortcut), and the function viewer should be in there. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted June 9, 2021 18 hours ago, Robustcolor said: Where can i see how BIS_fnc_taskPatrol looks like in code? This fnc seems to work even on mod maps when it comes to making waypoints. /* File: taskPatrol.sqf Author: Joris-Jan van 't Land Description: Create a random patrol of several waypoints around a given position. Parameter(s): _this select 0: the group to which to assign the waypoints (Group) _this select 1: the position on which to base the patrol (Array) _this select 2: the maximum distance between waypoints (Number) _this select 3: (optional) blacklist of areas (Array) Returns: Boolean - success flag */ //Validate parameter count if ((count _this) < 3) exitWith {debugLog "Log: [taskPatrol] Function requires at least 3 parameters!"; false}; private ["_grp", "_pos", "_maxDist", "_blacklist"]; _grp = _this select 0; _pos = _this select 1; _maxDist = _this select 2; _blacklist = []; if ((count _this) > 3) then {_blacklist = _this select 3}; //Validate parameters if ((typeName _grp) != (typeName grpNull)) exitWith {debugLog "Log: [taskPatrol] Group (0) must be a Group!"; false}; if ((typeName _pos) != (typeName [])) exitWith {debugLog "Log: [taskPatrol] Position (1) must be an Array!"; false}; if ((typeName _maxDist) != (typeName 0)) exitWith {debugLog "Log: [taskPatrol] Maximum distance (2) must be a Number!"; false}; if ((typeName _blacklist) != (typeName [])) exitWith {debugLog "Log: [taskPatrol] Blacklist (3) must be an Array!"; false}; _grp setBehaviour "SAFE"; //Create a string of randomly placed waypoints. private ["_prevPos"]; _prevPos = _pos; for "_i" from 0 to (2 + (floor (random 3))) do { private ["_wp", "_newPos"]; _newPos = [_prevPos, 50, _maxDist, 1, 0, 60 * (pi / 180), 0, _blacklist] call BIS_fnc_findSafePos; _prevPos = _newPos; _wp = _grp addWaypoint [_newPos, 0]; _wp setWaypointType "MOVE"; _wp setWaypointCompletionRadius 20; //Set the group's speed and formation at the first waypoint. if (_i == 0) then { _wp setWaypointSpeed "LIMITED"; _wp setWaypointFormation "STAG COLUMN"; }; }; //Cycle back to the first position. private ["_wp"]; _wp = _grp addWaypoint [_pos, 0]; _wp setWaypointType "CYCLE"; _wp setWaypointCompletionRadius 20; true 1 Share this post Link to post Share on other sites
Robustcolor 31 Posted June 9, 2021 Thanks @sarogahtyp. As i suspected, only way to make sure the wayPoints work is with findSafePos on modded maps. Share this post Link to post Share on other sites
Robustcolor 31 Posted June 9, 2021 On 6/5/2021 at 11:57 PM, pierremgi said: _position = getMarkerPos "Marker1"; _wp = _group addWayPoint [_position,0,1]; _pos1 = waypointPosition _wp; _pos2 = [_position,0,100,0,0,0,0,[[_pos1,30]],_pos1] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_pos2,0,2]; _pos3 = [_position,0,100,0,0,0,0,[[_pos1,30],[_pos2,30]],_pos1] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_pos3,0,3]; [_group,1] setWaypointSpeed "LIMITED"; [_group,3] setWayPointType "CYCLE"; Thanks @pierremgi. Tested your code and it almost worked. The first line need to use BIS_fnc_findSafePos instead of only getMarkerPos command otherwise same issue as before. _position = [getMarkerPos "Marker1",0,100,0,0,0,0,[],getMarkerPos "Marker1"] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_position,100,1]; _pos1 = waypointPosition _wp; _pos2 = [_position,0,100,0,0,0,0,[[_pos1,30]],_pos1] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_pos2,0,2]; _pos3 = [_position,0,100,0,0,0,0,[[_pos1,30],[_pos2,30]],_pos1] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_pos3,0,3]; [_group,1] setWaypointSpeed "LIMITED"; [_group,3] setWayPointType "CYCLE"; Share this post Link to post Share on other sites
pierremgi 4912 Posted June 9, 2021 That's not the code I let. If you read: _position = getMarkerPos "Marker1"; _wp = _group addWayPoint [_position,100,1]; which is a correct way to randomize a position within 100 m. The rest of the script is made for finding a position within this 100 m, but out of 30m from previous waypoints. That's a little bit different from your code: _position = [getMarkerPos "Marker1",0,100,0,0,0,0,[],getMarkerPos "Marker1"] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_position,100,1]; finding a position up to 100m, then randomizing again this position within 100 m. That means the position can be 200 m from the reference. findSafePos (with these parameters) has no added value for randomizing the first position. The only reason I used it is that exclude areas around previous waypoints. Share this post Link to post Share on other sites
Robustcolor 31 Posted June 10, 2021 9 hours ago, pierremgi said: _position = getMarkerPos "Marker1"; _wp = _group addWayPoint [_position,100,1]; Yes, this is the correct way but the radius syntax don't work on some modded maps, it just ends up at 0. That's why i added this _position = [getMarkerPos "Marker1",0,100,0,0,0,0,[],getMarkerPos "Marker1"] call BIS_fnc_findSafePos; _wp = _group addWayPoint [_position,0,1]; I've been using taskPatrol but since it uses findSafePos also i decided to trim it down abit. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted June 10, 2021 you don't need BIS_fnc_findSafePos to get a position in a random radius. getPos does the job much faster: _position = getMarkerPos "Marker1"; _radius = 100; _rand_pos = _position getPos [ ( random _radius ), ( random 360 ) ]; _wp = _group addWayPoint [ _rand_pos, 0, 1 ]; Share this post Link to post Share on other sites
pierremgi 4912 Posted June 10, 2021 2 hours ago, Robustcolor said: Yes, this is the correct way but the radius syntax don't work on some modded maps, it just ends up at 0. Which map? Share this post Link to post Share on other sites
Robustcolor 31 Posted June 10, 2021 43 minutes ago, pierremgi said: Which map? It's the new map Cam Lao Nam. Share this post Link to post Share on other sites
pierremgi 4912 Posted June 10, 2021 Ok, I found it. the addWaypoint is too clever (like AIs) and already filter some "bad" positions like rocks and unreachable positions. You can test it on vanilla map, or else: Spoiler 0 = [] spawn { private _position = getMarkerPos "marker1"; private ["_wp","_mk"]; for "_i" from 0 to 50 do { _wp = group player addWayPoint [_position,100,1]; _mk = createMarker [str random 1, waypointPosition _wp]; _mk setMarkerType "mil_dot"; }; }; The waypoint distribution is not so randomized due to paths to waypoints. The problem is especially noticeable on Cam Lao Nam because there are a lot of unreachable areas like rice paddies (see @johnnyboy excellent topic). What does that mean? The addWaypoint is not so bad! The maps are sometimes harder than jungle and more oriented PvP than AIs ramble. Probably, no matter the workaround for your waypoints, if they are unreachable... your group will never move to them. 2 Share this post Link to post Share on other sites