Creating a Simple Mission – Part 5

Random Patrols

One way to give a mission a little more re-playability is to add some random elements. The built in function BIS_fnc_taskPatrol will allow me to assign my randomly created OPFOR AI a randomly created patrol route around a location.

See previous post for instructions on setting up the Functions editor module.

To call the function I need to provide:

  1. the group to patrol
  2. position to patrol around
  3. distance between waypoints
  4. area blacklist (optional)

In my mission I’ll add the following code to my group’s waypoint in the On.Act. field:

[group this, position this, 200] call BIS_fnc_taskPatrol;

This will give my group a series of waypoints 200 meters apart, randomly centered on the waypoint.

I’ve created a little sample mission with a script that spawns a group using BIS_fnc_spawnGroup then places markers on the BIS_fnc_taskPatrol generated waypoints.

Example of BIS_fnc_taskPatrol

After running the sample mission a  few times I’ve noticed a few things.

  1. The function doesn’t generate waypoints in the water.
  2. the number of waypoints is variable.
  3. the waypoints are random, so they may not be evenly spread around my center position. In the example screen shot below all the waypoints are north east of my center at WP5.
  4. the last waypoint is created on the center position that was passed to the function.
  5. the last wayopint is a “cycle” waypoint (I’m assuming this, I haven’t actually checked yet)

I really like this function and I can see myself using it a lot.

BIS_fnc_taskPatrol example

BIS_fnc_taskPatrol example