Author: johnnyboy
Author Website:

Requirements: No addons required

Version: 1.0

Short description: Here's a random patrol script for boats. It should work well for ambient boats.

Date: 2017-02-03 10:11

Comments: (0)


JBOY Boat Random Patrol

johnnyboy 23961

Here's a random patrol script for boats. It should work well for ambient boats. It is currently not geared for combat boats, as combat AI would compete with the scripted move commands. However it could be easily modified for a boat to exit this script if their behaviour changes to COMBAT. The screenshots below show the random paths that 5 boats took during various time frames. The last one ran 4 hours, so I think the script is pretty well tested now.

Challenges overcome:
1. Boats would run into the ground if move to pos too close to shore. Solved by insuring moveTo pos had enough water in front and 90 degrees right, and 90 degrees left to execute a turn.
2. Boats still occasionally run aground or into a deep water piling or pier. Solved by flipping boat 180 degrees when this occurs. This is bad for immersion but better than a stuck boat. May replace this someday with a slow rotation of boat 180 degrees that looks better.
3. AI simply stops responding to commandMove commands. Sovled by deleting AI and replacing with new fresh AI driver if not responding for 30 seconds or more. Downside, is new unit does not have same gear as unit replaced. This is ok for ambient boats, but ultimately replacement units should be loaded with all same gear as unit being replaced. Feel free to plug in your favorite gear replacement script here (send me a an integrated solution and I will credit you...but I'm not into doing this myself).
4. Scripts would die after awhile giving no error, and no longer logging diag_log messages per loop execution. Solved by ending script, and spawning new script on same boat after 500 loop evolutions.

Installation / Usage:
For usage instructions and information of how to use the JBOY Boat Random Patrol please refer to the included documentation and/or example mission.

In the editor, put this in a boat's init box:
dummy = [this, "ColorBlue",true,2000] execVM "Scripts\JBOY_boatRandomPatrol.sqf";

The parameters are:
boat object
color of marker to track boat path
show markers boolean (true to show markers, false to not show markers)
Radius: Calculated positions to move must be within this radius, where center of radius is boat's starting position. This prevents boats from cruising a zillion kilometers away from the island.

Credits & Thanks:
Hat tip to @fn_Quiksilver for suggesting the getTerrainHeightASL for getting water depth.


Forum topic:
- BI forums

Enable javascript to be able to download from Armaholic please!

Tags: Ambient,   Boat,   Patrol,   Scripts