Jump to content
Sign in to follow this  
commanderx

Create random waypoints on roads?

Recommended Posts

Hi,

I use DAC to create AI. I would like to give all AI Units randomly created waypoints which are only on roads. Any suggestion how to achieve that?

Best regards

Kai

Share this post


Link to post
Share on other sites

I am probably too stupid to use that script. Don´t have a clue how to put in the variables??

Share this post


Link to post
Share on other sites

Got it, thank you :-)

_marker = getmarkerpos "marker";
_list = _marker nearRoads 10500;
//_mcount = 1;
/*{ 
_pos = getpos _x;
_Xpos = _pos select 0;
_Ypos = _pos select 1;
m_name = format["name%1",_mcount];
_markerstr = createMarker [m_name,[_Xpos,_Ypos]];
_markerstr setMarkerShape "ICON"; 
_markerstr setMarkerType "hd_dot";
//sleep 2;
//silenthint format ["%1 Strassen gefunden",m_name ];
_mcount = _mcount + 1;} forEach _list;

*/
hintSilent format ["%1 Strassen gefunden",_list ];

_count = 1;
while {_count < 50} do {
_road = _list call BIS_fnc_selectRandom;
_posroad = getPos _road;
_Xpos = _posroad select 0;
_Ypos = _posroad select 1;
m_name = format["name%1",_count];
_markerstr = createMarker [m_name,[_Xpos,_Ypos]];
_markerstr setMarkerShape "ICON"; 
_markerstr setMarkerType "hd_dot";	

_count = _count +1;
};

Share this post


Link to post
Share on other sites

I am unable to adapt the above code in my convoy mission.

 

spawnconvoy.sqf (and give them random destination far off with 5 + random 3 way points only being on roads and then cycle back to the first waypoint):

_sidepos = getMarkerPos "m1";

// Spawn enemy officer
_grp = createGroup west;
_vehlist = ["B_MRAP_01_hmg_F", "B_MRAP_01_gmg_F", "B_APC_Wheeled_01_cannon_F"];
_trklist = ["B_Truck_01_box_F", "rhsusf_m998_w_2dr", "B_G_Van_01_transport_F"];

sleep 0.5;

_newPos = [_sidepos, 0, 25, 1, 0, 200, 0, []] call BIS_fnc_findSafePos;
_vehtype = (count _vehlist )-1;
_type = _vehlist select (round random _vehtype);
_vehicle1 = [_newpos, 0, _type, _grp] call BIS_fnc_spawnvehicle;
sleep 1.5;

_newPos = [_sidepos, 0, 25, 1, 0, 200, 0, []] call BIS_fnc_findSafePos;
_trktype = (count _trklist )-1;
_type2 = _trklist select (round random _trktype);
_vehicle2 = [_newpos, 0, _type2, _grp] call BIS_fnc_spawnvehicle;
sleep 1.5;

_newPos = [_sidepos, 0, 25, 1, 0, 200, 0, []] call BIS_fnc_findSafePos;
_trktype = (count _trklist )-1;
_type2 = _trklist select (round random _trktype);
_vehicle3 = [_newpos, 0, _type2, _grp] call BIS_fnc_spawnvehicle;
sleep 1.5;

_newPos = [_sidepos, 0, 25, 1, 0, 200, 0, []] call BIS_fnc_findSafePos;
_vehtype = (count _vehlist )-1;
_type = _vehlist select (round random _vehtype);
_vehicle4 = [_newpos, 0, _type, _grp] call BIS_fnc_spawnvehicle;
sleep 1.5;
_list = _sidepos nearRoads 500;
_count = 1;


while {_count < 10} do {

	_road = _list call BIS_fnc_selectRandom;
	_posroad = getPos _road;
	_count = _count +1;
	};

for "_i" from 0 to (5 + (floor (random 3))) do {
	_wp = _grp addWaypoint [(count _posroad) -1, 0];
	_wp setWaypointType "MOVE";
	_wp setWaypointSpeed "LIMITED";
	_wp setWaypointBehaviour "SAFE";
	_wp setWaypointFormation "COLUMN";//"STAG COLUMN"

sleep 3;
	_wp = _grp addWaypoint [_sidepos, 0];
	_wp setWaypointType "CYCLE";
	_wp setWaypointCompletionRadius 20;
	true;
};
 

Please correct me.

Share this post


Link to post
Share on other sites

Considering your convoy is on a road, what do you mean by a random waypoint?

 

If the road is 5,000 meters long then the random waypoints would fall where?   It seems to me the waypoints would all be somewhere on the 5,000 meters.

 

.

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  

×