Jump to content
Sign in to follow this  
wiggum2

Question about BIS fnc taskpatrol

Recommended Posts

Hi,

i would like to know something about "BIS fnc taskpatrol".

http://community.bistudio.com/wiki/BIS_fnc_taskpatrol

Create a random patrol of several waypoints around a given position.
position - the position on which to base the patrol

distance - the maximum distance between waypoints

nul=[group this, position this, 100] call BIS_fnc_taskPatrol;

Now, this would mean that the group will patrol at the position (this) of the waypoint and the max distance between waypoints is 100m.

I would like to know how large is the area they patrol with taskpatrol ?

Is it 200x200 or something ?

Would be good to know this...

Share this post


Link to post
Share on other sites
Would be good to know this...

So, what's stopping you from reading fn_taskPatrol.sqf which may be found in modules.pbo? :rolleyes:

Come on you guys! Go and depbo at least modules.pbo and read some code. :yay:

Here it is:

scriptName "Functions\spawning\fn_taskPatrol.sqf";
/*
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

You may need to read fn_findSafePos.sqf aswell, but basically it will return a position that is guaranteed to be no further away than the given max. distance, which is the third parameter you pass to fn_taskPatrol.sqf.

As you can see, you do not define an operation area around the initial position, but instead the script generates a waypoint-chain, where the next position may be _maxDist further away from the last (or initial) waypoint position. Thus, the effective maximum distance possible is the number of waypoints generated times _maxDist. But the group could aswell go in circles.

The number of waypoints is random (at least 3 and 5 at max). So the maximum distance the group will travel away from the initial position is 5 times _maxDist.

But since the last waypoint is of type "CYCLE", they will always come back to the initial position...

It's pretty simple/straight forward. So maybe you need to copy and adapt this one or go write your own patrol script to get the desired outcome.

Share this post


Link to post
Share on other sites

This is a great script and I've used it hundreds of times. Now, sort of suddenly, I'm getting a weird phenomena: the units I put the BIN_TaskPatrol.sqf script on all start heading southeast...around 140 degrees, it seems. They just start parading off in that direction. All of them, different groups, from different start points.

Two notes:

A) I have a Function module placed.

B) I have tried using the "create one waypoint" method as suggested here.

But nothing seems to change it.

Any suggestions?

EDIT: I've started using Wollfy.au and ArmAIIholic's updated versions of the script (1.3 and 1.4), and now I'm not getting this bug.

Edited by Lucky44

Share this post


Link to post
Share on other sites

There are no defined patrol areas for BIS_fnc_taskpatrol. I've seen groups on patrol head out of the area of operations and move farther and farther away from their start position. Pretty ridiculous.

The improved one might be a little better, but the last version I tried was very buggy. Lots of errors, and same behaviour as above - groups would sometimes set their waypoints to the other side of the island.

UPSMON is a very good script for creating randomized patrols. It seems daunting at first but it's pretty easy to use. Highly recommended.

Share this post


Link to post
Share on other sites

I've had a similar problem with a map where the enemy started near the edge of the map. Perhaps the scipt SafePos rejects locations near the edge of the map, thus pushing units towards the middle...?

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  

×