End condition examples - Global-Conflicts-ArmA/Olsen-Framework-Arma-3 GitHub Wiki

Description

This page contains a selection of various end conditions to assist you with creating your own ending for the mission.
End conditions can be very-very expansive and in theory can have almost anything work so long as you can program it.

Conditions

Casualty percentage

Ends the mission when a certain side has reach a casualty % of the overall team.

private _westCasualty = "USMC" call FUNC(CasualtyPercentage);
if (_westCasualty >= 50) exitWith {
    "VDV VICTORY<br />USMC has retreated due to casualties." call FUNC(EndMission);
};
  • "USMC" - Change this to the team name in serverSettings.sqf that you wish the end condition to check for.
  • _westCasualty >= 50 - Change 50 to the % of casualties you wish the team to sustain to trigger the end condition.

% of alive extracted

Ends the mission when a % of the alive players on a team reach an extraction zone.

private _aliveBlufor = units west select {_x call FUNC(isAlive)}; // we get all alive blufor
if (_aliveBlufor isNotEqualTo []) then { // if there are some alive blufor left
    private _bluforInArea = _aliveBlufor select {_x inArea "evac1"}; // we get the alive blufor in evac1 marker
    if ( _bluforInArea isNotEqualTo [] &&
        {count _bluforInArea >= count _aliveBlufor * 0.7} // we see if at least 70% of the alive blufor are in the area
    ) exitWith {
        "USMC VICTORY!<br />The platoon of US Marines managed to extract, well done!" call FUNC(EndMission);
    };
};
  • side _x == west - west is the team that is counted, can be either west, east, resistance, civilian
  • _x inArea "extract" - extract is the variable name of the area marker you placed that is the extraction zone you wish to count the players in.
  • count _resAlive * 0.2 - 0.2 is the % of ALIVE players needed in the extraction zone. Value ranges from 0.01 - 1 with 0.01 being 1% and 1 being 100%.

Is X alive

This ends the mission when a certain object, player, or vehicle is dead/destroyed.

if (!alive HVT) exitWith {
    "USMC VICTORY!<br />The USMC platoon has managed to kill the HVT, well done!" call FUNC(EndMission);
};
  • !alive HVT - Change HVT to the variable of the object, player, or vehicle you want to check for being dead/destroyed.

&& (and)

&& - This allows you to combine several end conditions together.
&& simply means "and", i.e condition A and B.
You can see an example below.

if (!alive CACHE1 && {!alive CACHE2}) exitWith {
    "USMC VICTORY!<br />The USMC platoon has managed to destroy both caches, well done!" call FUNC(EndMission);
};
  • In theory you could do a continues call with && between each condition and create a long line of conditions that ALL have to be met to trigger the end mission.

|| (either/or)

|| - This allows you to select either/or conditions.
|| simply mean "either/or", i.e Either condition A or condition B.
You can see an example below.

private _aliveBlufor = units west select {_x call FUNC(isAlive)}; // we get all alive blufor
if (_aliveBlufor isNotEqualTo []) then { // if there are some alive blufor left
    private _bluforInArea = _aliveBlufor select {_x inArea "evac1" || _x inArea "evac2"}; // we get the alive blufor in evac1 or evac2 marker
    if ( _bluforInArea isNotEqualTo [] &&
        {count _bluforInArea >= count _aliveBlufor * 0.7} // we see if at least 70% of the alive blufor are in the area
    ) exitWith {
        "USMC VICTORY!<br/>USMC have successfully extracted." call FUNC(EndMission);
    };
};

You can see we have two extraction zones here {_x inArea "evac1" || _x inArea "evac2"}, named evac1 and evac2.
This condition is checking to see if 70% or more of the alive players on WEST/BLUFOR are in either EVAC1 marker or EVAC2 marker.

Dead body/bodybag recovery

With this, you can end a mission if a dead body within an ACE body bag has returned to the chosen marker.

  1. Place the following code into the postserverinit.sqf file within the init foldeer.
 BodyBagEvent = ["ace_placedInBodyBag", 
     {
         params ["_target", "_bodyBag"];
         //hint format ["BodyBag Event Fired! targetName= %1, _target = %2, _bodyBag = %3",(name _target),_target,_bodyBag];
         if (_target isEqualTo HVT) then {
         missionNamespace setVariable ["HVT_BodyBag", _bodyBag, true];
        } else {
        if (_target isEqualTo BODY) then {
         missionNamespace setVariable ["BODY_BodyBag", _bodyBag, true];
        };
    };
}] call CBA_fnc_addEventHandler;

Change HVT to the variable name of the person/AI of your person who will be body bagged.

  1. Followed by in your end conditions:
(!(isNull HVT_BodyBag) && {HVT_BodyBag inArea "extract"}) exitWith {
    ["VICTORY<br/>main victory text here", "Soft ending text to display before the end screen<br/>A new line under the first soft end text...", 10] call FUNC(SoftEndMission);
};

Change extract to the variable name of the extraction marker.

⚠️ **GitHub.com Fallback** ⚠️