Skip to content

Reinforcements

Mike-MF edited this page Dec 30, 2022 · 31 revisions

This page will explain the usage of the Reinforcements function.


/*
 * Author: Jonpas, Mike
 * Sets visibility of units, simulation and AI behaviour of a group along with any vehicles manned by the group.
 * Call from init.sqf
 *
 * Arguments:
 * 0: Group <GROUP>
 * 1: Disable <BOOL>
 * 2: Distance <NUMBER> (default: 0)
 * 3: Move to Nearest Player <BOOL> (default: false)
 * 4: Distance to search for player <NUMBER> (default: 1000)
 *
 * Return Value:
 * None
 *
 * Example:
 * [Test_Group_1, true] call MFUNC(reinforcements)
 * [Test_Group_1, false] call MFUNC(reinforcements)
 * [Test_Group_1, false, 50] call MFUNC(reinforcements)
 * [Test_Group_1, false, 0, true, 2000] call MFUNC(reinforcements)
 */

Usage

This function will hide or unhide a group of units for use later, preserving behaviour, loadouts and waypoints. Will also do the same to vehicles provided a group member is inside one.

Upon unhiding units you can add a "distance" check for nearby players, if they are closer than the number specified they will not be unhidden. The distance check parameter should never be used for hiding units on mission start, only unhiding them.

When unhiding units you can also immediately have them "hunt" for players instead of relying on waypoints.

Call from trigger with Server check or initServer.sqf

Examples:

[My_Group, true] call MFUNC(reinforcements); // Will hide units.

if (isServer) then {
    [My_Group, false] call TAC_Mission_fnc_reinforcements; // Will unhide units.
};

Multiple Groups

// Hiding Units
{
    [_x, true] call MFUNC(reinforcements);
} forEach [My_Group_One, My_Group_Two, My_Group_Three];

// Unhiding Units
if (isServer) then {
    {
         [_x, false] call TAC_Mission_fnc_reinforcements;
    } forEach [My_Group_One, My_Group_Two, My_Group_Three];
};

Staggered unhiding

if (isServer) then {
    {
        [_x, false] call TAC_Mission_fnc_reinforcements;
    } forEach [Example_Group_1, Example_Group_2];

    [{
        {
            [_x, false] call TAC_Mission_fnc_reinforcements;
        } forEach [Example_Group_3, Example_Group_4];
    }, [], 10] call CBA_fnc_waitAndExecute;

    [{
        {
            [_x, false] call TAC_Mission_fnc_reinforcements;
        } forEach [Example_Group_5, Example_Group_6];
    }, [], 20] call CBA_fnc_waitAndExecute;
};

Distance Checking

if (isServer) then {
    [Example_Group_1, false, 500] call TAC_Mission_fnc_reinforcements;
};

Hunting
This codeblock will "look" for players within a 1000m radius and hunt the nearest ones.

if (isServer) then {
    [Example_Group_1, false, 100, true, 2000 call TAC_Mission_fnc_reinforcements;
};
Clone this wiki locally