Jump to content
Sign in to follow this  
Vegatry

Make a cycling waypoint of a spawned group.

Recommended Posts

this is the PHP code

opp01 = [markerPos "opspawn1", EAST, ["O_Soldier_SL_F", "O_Soldier_AR_F", "O_Soldier_AR_F", "O_Soldier_F", "O_Soldier_F", "O_Soldier_F"]] call BIS_fnc_spawnGroup; 
{_x setskill ["general", 0]; _x allowFleeing 0.1;} forEach units opp01;

_wp = opp01 addWaypoint [[25295,21919,85], 0];
 _wp setWaypointCombatMode "YELLOW";
 _wp setWaypointBehaviour "AWARE";
 _wp setWaypointSpeed "FULL";
 _wp setWaypointFormation "COLUM";
[opp01, 0] setWaypointType "MOVE";

_wp1 = opp01 addWaypoint [[25381,21882,70], 0];
 _wp1 setWaypointCombatMode "YELLOW";
 _wp1 setWaypointBehaviour "AWARE";
 _wp1 setWaypointSpeed "FULL";
 _wp1 setWaypointFormation "COLUM";
[opp01, 0] setWaypointType "MOVE";

_wp2 = opp01 addWaypoint [[ 25332,21782,78], 0];
 _wp2 setWaypointCombatMode "YELLOW";
 _wp2 setWaypointBehaviour "AWARE";
 _wp2 setWaypointSpeed "FULL";
 _wp2 setWaypointFormation "COLUM";
[opp01, 0] setWaypointType "MOVE";

_wp3 = opp01 addWaypoint [[25295,21919,85], 0];
 _wp3 setWaypointCombatMode "YELLOW";
 _wp3 setWaypointBehaviour "AWARE";
 _wp3 setWaypointSpeed "FULL";
 _wp3 setWaypointFormation "COLUM";
[opp01, 0] setWaypointType "CYCLE";

I spawn them via trigger " Blufor present, _nul = execVM "scripts\opspawn.sqf";

wp, wp1 and wp2 have no problems. However on wp3, the AI seem to ignore type 'cycle' and when they reach the end of the waypoint they stopped instead of recycle the waypoint again.".

Share this post


Link to post
Share on other sites

this part, [opp01, 0] setWaypointType "CYCLE"; , change to

_wp3 setWaypointType "CYCLE";

As a matter of fact, change every part with [opp01, 0] to _wp# setWaypointType "<something>" where # is your wp number

Share this post


Link to post
Share on other sites

Yeah I made that same mistake too not long ago. The documentation on the wiki is slightly confusing in that regard.

You can end up with the following error if not careful:

Cycle as first waypoint has no sense

Share this post


Link to post
Share on other sites

I'd noticed the annoying "Cycle as first waypoint has no sense" popping up in my rpt from a few scripts I have which assign waypoints to cars, civs and boats. Basically each script assigns 15 waypoints to a given unit, and then makes the 15th one a cycle waypoint.

So in the below code _sqname is the name of the group, tpw_car_waypoints = is the number of waypoints (15), and tpw_car_roadlist is an array of potential road segments to use as waypoints

for "_i" from 1 to tpw_car_waypoints do
	{
	_road = tpw_car_roadlist select (floor (random (count tpw_car_roadlist)));
	_wppos = getposasl _road; 
	_wp = _sqname addWaypoint [_wppos, 0];
	if (_i == tpw_car_waypoints) then 
		{
		_wp setwaypointtype "CYCLE";
		};
	};

I can include code to show that waypoints 0-14 are "MOVE" and waypoint 15 is "CYCLE", and the cars happily cycle through the waypoints, but that bloody error keeps popping up. Any ideas?

Share this post


Link to post
Share on other sites

I'm not sure - I thought I'd got rid of my "Cycle as first waypoint has no sense" errors, but they still pop up.

I think I've nailed it down to when it happens (this is just a summation of what's going on).

I set 4 "move" waypoints and like you, set an additional one to be "cycle".

Then, if the group is attacked and behaviour changes to "combat", then I run the following little function:

horde_fnc_remove_waypoints = 
{
private ["_grp"];

_grp = _this select 0;

while {count (waypoints _grp) > 0} do
{
	deleteWaypoint ((waypoints _grp) select 0);
};		
};

And then assign some more waypoints while the group are in combat.

It's when I run the function above that I get the "cycle as blah blah" error. I think what is happening is that for some reason the "cycle" waypoint is either not deleted or becomes the active waypoint as the code is busy munching up the previous "move" waypoints. Maybe I should try deleting them in reverse order...

I'm not sure and will have to do some more debugging, but it's really tedious as it involves restarting the mission and letting it run for a couple of minutes etc.

I was doing some googling on this and saw some historic threads on this, but unfortunately, the authors didn't go into detail as to what's going on to cause this. For example: https://dev-heaven.net/issues/20619

Will check back on this tomorrow after I get some sleep.

---------- Post added at 05:48 AM ---------- Previous post was at 05:23 AM ----------

Ok, couldn't sleep on it so just tried deleting the last waypoint first (the "cycle" one) and got no errors.

Just a little modification here:

horde_fnc_remove_waypoints = 
{
private ["_grp","_index"];

_grp = _this select 0;

_index = count (waypoints _grp);
while {_index > 0} do
{
	deleteWaypoint ((waypoints _grp) select (_index - 1));
	_index = count (waypoints _grp);
};		
};

Hope that helps/gives you a clue.

Now, all I'm getting in the rpt is this solitary error:

O Bravo 1-3:4: moving in direct condition failed, dist 2.0405

Not sure what that is (failed wp I guess), but it only happened once out of about 16 squads (and probably 100 waypoints assigned and deleted).

Share this post


Link to post
Share on other sites

You're a clever chap Das, I pretty much had the exact kju based waypoint removal function in my scripts, replaced it with your revised code and sayonara waypoint errors. Taking your point about the cycle waypoint into consideration, I tried deleting the waypoints in reverse order and that has the desired effect also

_grp = _this select 0;
for "_i" from count (waypoints _grp) to 1 step -1 do
{
deleteWaypoint ((waypoints _grp) select _i);
};

Now I've just to work out a way to stop filling up the rpt with No speaker given for Greek Name errors.

Share this post


Link to post
Share on other sites

Cool - glad that worked for you. I didn't know you could "count down" using step - just always assumed the step had to be positive so thanks for that tip. :)

Not sure about your Greek Name errors though - I'm struggling with setFace on the AI at the mo!

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  

×