Skip to content

Casualties Cap

NikkoJT edited this page Mar 17, 2024 · 5 revisions
File location f\casualtiesCap\f_CasualtiesCapCheck.sqf
Enabled by default? no
Enable/Disable in init.sqf
Runs on Server

The Casualties Cap component automatically senses the percentage of casualties taken by a group (or several groups), and triggers an ending when that threshold is reached. This is achieved by working closely with the Multiplayer Ending Controller component.

Usage

Open the file init.sqf and look for the code segment entitled:

// F3 - Casualties Cap 

Three different pre-configured options are provided (but you can also create your own, full instructions below):

To trigger ending #1 when all BLUFOR units in groups with playable leaders are dead, edit the following line, removing the // at the start:

// [BLUFOR,100,1] execVM "f\casualtiesCap\f_CasualtiesCapCheck.sqf";

f\casualtiesCap\f_CasualtiesCapCheck.sqf Takes the following arguments:

# name type description
0 groups or side Side Side to check.
Array Array of groupnames as strings. (e.g. ["MyGrp1","MyGrp2"])
1 percentage Number What percentage of units must be dead before the ending is triggered
2 ending Number Which ending will be executed.
Code Code to be executed.
3 onlyPlayers (optional) Boolean If only groups with a playable leader slot will be included (default is true)
4 faction (optional) Array Which faction(s) to filter for if the first variable is a side (e.g. ["blu_f"])

Examples

Sides

If you want to trigger ending 2 after 30% of OPFOR/CSAT are dead, use the following line:

[OPFOR,30,2] execVM "f\casualtiesCap\f_CasualtiesCapCheck.sqf";
Individual groups

If you want to monitor individual groups, use the following line to trigger ending 1 once at least90% of the groups MyGrp1 and MyGrp2 are dead.

[["MyGrp1","MyGrp2"],90,1] execVM "f\casualtiesCap\f_CasualtiesCapCheck.sqf";
Executing custom code

If you want to trigger a custom code instead of a pre-defined ending you can replace the number indicating the ending with any block of code.

For example, if you wanted to display a hint saying AAF has taken too many casualties instead of triggering an ending you would use:

[INDEPENDENT,100,{hint 'AAF has taken too many casualties!'}] execVM "f\casualtiesCap\f_CasualtiesCapCheck.sqf";

Note: The code will be run on all clients and the server. Note: The custom code you want to execute in place of a pre-defined ending must be enclosed within curly braces: {}

Monitor all groups with/without playable leaders from one or more faction from one side

If you are monitoring all groups on a particular side, e.g. BLUFOR, you can also filter by specific faction. You do this by adding the optional fourth and fifth parameters to the activation line.

For example, if you want ending 2 to be triggered when all groups with playable leaders on the side BLUFOR and in the faction BLU_F take 50% casualties the line would be:

[BLUFOR,50,2,true,["blu_f"]] execVM "f\casualtiesCap\f_CasualtiesCapCheck.sqf";

Tips

  • This component is very useful in Attack & Defend missions, as it can be run for more than one group (or several groups) at the same time, triggering a different ending for each.
Clone this wiki locally