Comrades in Arms Discussion Board

Full Version: Convoy script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As the first live trial of my convoy script was a success, I'll post it here incase others want to make convoy missions and live out years of frustration of waiting with your mines while trucks hump trees 10 miles away.

There are two script files
- convoy.sqf which handles the movement and 
- ambushaction.sqf which handles what individual vehicles do when under fire.

tl;dr what is needed to get a convoy running -

You need your convoy vehicles, not grouped with each other and placed on the road in the desired order. The vehicle names must be conveh_1, conveh_2, conveh_3 etc.. They don't need to be placed in the numerical order of the names.

On the convoy path, place logics conwp_1, conwp_2, conwp_3 etc... These must be in numerical order.

The easiest way to do this is place a logic conwp and then when you copy and paste it on repeat, the index numbers are automatically generated.

Consider the logics as waypoints the vehicles will drive to reasonably directly. This means you can skip directly over some spooky narrow road S shape in the middle of nowhere.

Vehicles and logics placed, then just do null = [] execVM "convoy.sqf" at your time of choice.


When the convoy comes under fire either one of these conditions has happened:
-One of the vehicles can't move
-Has received a large amount of damage
-The driver is dead

Then convoy.sqf ends and the actual convoy stops with ambushaction.sqf  executed on every vehicle. Also a variable "ambushed" is set to =1. Can be used to trigger QRF and stuff.

By doing "this setvariable ["ambush_type",-type-];" in the vehicle editor init field, you can choose what behaviour ambushaction will command:
type "tank" - seek and destroy
type "apc" - dismount infantry, then seek and destroy
type "truck" - dismount everyone (so no "Why yes, the lead tank just got taken out by an ATGM and mines are going off all around. Best to stay calmly at the wheel.)

default if the variable is not set = seek and destroy

Haven't commented or polished the script - maybe I'll do it I reach some final version I'm completely happy with. Or maybe some other professional programmers can pick up the idea do it in a correctly presented manner.
Commented liked and subscribed!!! (pinned)
Siil, you rock my world.
Variable Wrote:Commented liked and subscribed!!! (pinned)
Siil, you rock my world.

What, you don't like humping trees? Big Grin

Thanks for the script, Siil!
Thanks Siil!
I took Siil's script and added a few modifications to it.
  • It's a function module now
  • Scripts have been modified to make them reentrant, i.e. you can have more than one convoy
  • Now uses waypoints of the lead vehicle instead of game logic.
How to use:

  1. Place your convoy units as desired
  2. In the lead vehicle's init field, add the line 
    [this] call FHQ_fnc_convoyInit;

  3. Set waypoints for the lead vehicle that the convoy should follow. See below.
  4. To start the convoy, call
    [veh1, veh2, veh3, ...] spawn FHQ_fnc_convoy;
    (obviously, replace the veh1 etc with your vehicle variables)
  5. You can call 
    this setVariable ["FHQ_AmbushAction", actiontype];
    in each vehicle's init field. actionType can be "tank", "truck" or "apc". Truck in this context means a troop transporter

I switched this to waypoints for a number of reasons. One of them is that waypoints are connected with lines and thus make it easier to make sure the convoy route is on the roat. The waypoints are actually deleted in the convoyInit script, they are just for reference.

I use this in my functions library to create the functions:
Quote:class Convoy
{
    // Siil's convoy scripts, modified a bit for ease of use
    tag="FHQ";
    file="functions\fhq_ai";

    EXPORTED_FUNCTION(convoyInit, "Init Convoy Lead Vehicle")
    EXPORTED_FUNCTION(convoy, "Looks like we got us a convoy")
    EXPORTED_FUNCTION(convoyAmbushAction, "Perform Ambush Action")

};