Jump to content
Sign in to follow this  
redarmy

Assigning waypoints help needed

Recommended Posts

Currently im using CBA search area function,but having issues with it as in it AI are scripted to randomly search nearby houses. Problem is Arma3 AI literally get stuck pathing 80% of the time and i cant have that.

 

What CBA task function search area does do that i like,is asign 1 WP within a marker area,once squads reach it,another is created within the area,and this continues forever. This is what i need.

 

I looked around and found nothing,and i cant make sense of the assign WP function.

 

BIS task patrol/CBA task patrol are not useful to me here as they do not asign waypoints randomly after one is completed, is there any way to upon activation of a waypoint allow a group to generate random patrols in a marker i choose?

Share this post


Link to post
Share on other sites

CBA_fnc_randPosArea might be what you are looking for.

//define function:

HARZ_fnc_rndWpLoop = 
{
	params ["_group"];
	_pos = ["markerName"] call CBA_fnc_randPosArea;
	_waypoint = _group addWaypoint [_pos, 0]; 
	_waypoint setWaypointStatements ["true", "[group this] call HARZ_fnc_rndWpLoop"];
};


//create group:

_group = [<params>] call BIS_fnc_spawnGroup; 
[_group] call HARZ_fnc_rndWpLoop;

The function finds a random position within the given marker area and creates a new waypoint for the given group at that position. When the waypoint is completed, it runs the function again, in an infinite loop.

  • Like 1

Share this post


Link to post
Share on other sites
20 minutes ago, Harzach said:

CBA_fnc_randPosArea might be what you are looking for.


HARZ_fnc_rndWpLoop = 
{
	params ["_group"];
	_pos = ["markerName", true] call CBA_fnc_randPosArea;
	_waypoint = _group addWaypoint [_pos, 0]; 
	_waypoint setWaypointStatements ["true", "[group this] spawn HARZ_fnc_rndWpLoop"];
};

_group = [<params>] call BIS_fnc_spawnGroup; 
[_group] call HARZ_fnc_rndWpLoop;

The function finds a random position within the given marker area and creates a new waypoint for the given group at that position. When the waypoint is completed, it runs the function again, in an infinite loop.

Thank you

 

I WILL GIVE IT A TRY.

 

SO , how do i go about calling this? Have an idea but not sure. it cant run just from a trigger or activation rite? i need to define group names in param and call scipt on waypoint activation?

 

idealy i want,when a group hit its 1st waypoint for it to get this function asigned to them.

 

 

 

Share this post


Link to post
Share on other sites

So you have existing groups with existing first waypoints? In that case, just place this in the waypoint's On Activation field:

[group this] call HARZ_fnc_rndWpLoop;

Make sure to also actually define the function in init.sqf or wherever:

HARZ_fnc_rndWpLoop = 
{
	params ["_group"];
	_pos = ["markerName", true] call CBA_fnc_randPosArea;
	_waypoint = _group addWaypoint [_pos, 0]; 
	_waypoint setWaypointStatements ["true", "[group this] call HARZ_fnc_rndWpLoop"];
};

 

  • Thanks 1

Share this post


Link to post
Share on other sites
[group this] call HARZ_fnc_rndWpLoop"];

ERROR MISSING ;
21 minutes ago, Harzach said:

So you have existing groups with existing first waypoints? In that case, just place this in the waypoint's On Activation field:


[group this] call HARZ_fnc_rndWpLoop;

Make sure to also actually define the function in init.sqf or wherever:


HARZ_fnc_rndWpLoop = 
{
	params ["_group"];
	_pos = ["markerName", true] call CBA_fnc_randPosArea;
	_waypoint = _group addWaypoint [_pos, 0]; 
	_waypoint setWaypointStatements ["true", "[group this] call HARZ_fnc_rndWpLoop"];
};

 

Just tried it. 

 

it does sort of work as i need but im getting an error with "group this" when group reach a way point,its also setting waypoints at the extreme edges of the marker..i assume "pos,0" can be mdified somehow to set a random position from centre? like an array?

 

 

ok got the marker pos thing,set "0" to my marker size,works ok. how do i define the group correctly because its throwing an error about group this.. i have it written as u wrote

Share this post


Link to post
Share on other sites

OK when i copied the syntax there was a hidden symbol.i rewrote it and it works without errors.

 

Thanks so much,i learned sth new

 

EDIT : Still think im doing sth wrong. "pos,0" is correct? i get errors with it and they only patrol if i enter a number,but then they leave the actual marker area. i assumed they get random pos in marker only

 

EDIT: found the issue

 

_perimeter - True to return only positions on the area perimeter (optional, default: false) <BOOLEAN>

 

Share this post


Link to post
Share on other sites

You have been working with code I changed the minute after I posted it 😄

 

See my original post for fixed code.

Share this post


Link to post
Share on other sites
9 hours ago, Harzach said:

You have been working with code I changed the minute after I posted it 😄

 

See my original post for fixed code.

Im eager lol  😂

 

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
Sign in to follow this  

×