Jump to content
twistking

how to end cba_func_taskpatrol for AI

Recommended Posts

Hello,
i want to use the taskdefend / taskpatrol functions, but can't figure out how to end the task for the AI group. I tried a trigger with setcurrentwaypoint, but AI will continue its func_task no matter what.

I was trying with the cba flavor of the function, but vanilla arma func_task would also be okay, as long as i find a way to snap the AI out of their behaviour and go on with their waypoint by trigger.

Any ideas?
Thanks!


(the actual problem i'm trying to solve is a group randomly patroling and/or hiding in a building until the player is spotted, when the group should flee the player. when setting up the patroling/hiding manually with waypoints, i can easily trigger the AI to move with setcurrentwaypoint, but this won't work with the functions, that i would prefer for the randomization)

Share this post


Link to post
Share on other sites

Both CBA and BI patrol functions just add waypoints, with the last being a Cycle.

All you need to do is add a new waypoint and then set it as the current to bypass the cycle. I realise you say you have already done this but you must be doing something wrong.

Just try this in a mission preview with just the player...

Spoiler

_h = [] spawn {
	//Spawn group
	_group = [ player getPos[ 50, getDir player ], side player, 3 ] call BIS_fnc_spawnGroup;
	//Send on patrol
	[ _group, player getPos[ 50, getDir player ], 5 ] call BIS_fnc_taskPatrol;
	
	sleep 30;
	
	hint "ending patrol";
	//Add new wp
	_wp = _group addWaypoint[ player getPos[ -10, getDir player ], 0 ];
	_wp setWaypointStatements[ "true", "hint 'patrol finished'" ];
	
	//Set wp as current to skip patrol cycle
	_group setCurrentWaypoint _wp;
};

 

... group will go on patrol for 30 seconds, then a new wp is added where the group will travel to ( just behind the player) and will hint "patrol finished".

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, Larrow said:

Both CBA and BI patrol functions just add waypoints, with the last being a Cycle.

All you need to do is add a new waypoint and then set it as the current to bypass the cycle. I realise you say you have already done this but you must be doing something wrong.

Just try this in a mission preview with just the player...

  Hide contents


_h = [] spawn {
	//Spawn group
	_group = [ player getPos[ 50, getDir player ], side player, 3 ] call BIS_fnc_spawnGroup;
	//Send on patrol
	[ _group, player getPos[ 50, getDir player ], 5 ] call BIS_fnc_taskPatrol;
	
	sleep 30;
	
	hint "ending patrol";
	//Add new wp
	_wp = _group addWaypoint[ player getPos[ -10, getDir player ], 0 ];
	_wp setWaypointStatements[ "true", "hint 'patrol finished'" ];
	
	//Set wp as current to skip patrol cycle
	_group setCurrentWaypoint _wp;
};

 

... group will go on patrol for 30 seconds, then a new wp is added where the group will travel to ( just behind the player) and will hint "patrol finished".

 


Thanks. I will try that. Maybe i did test setcurrentwaypoint only with the defend tasks and not the patrol tasks (probably assumed that they work similarly).
Thanks again!

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

×