Skip to content

LoadoutManager

Miksuu edited this page Sep 10, 2023 · 23 revisions

Author: Miksuu

Introduction

LoadoutManager is a C# program (created by Miksuu) designed for managing various vehicle loadouts. It manages generating code for Arma 2’s SQF language for the essential files: EASA_Init.sqf & Common_BalanceInit.sqf

Additionally the program brings these changes (and any other code change excluding mission.sqm, and version.sqf files) to our modded terrains which we currently run during biweekly events that are held on weekends.

Why we created this tool

Before we started working on the The Air Balance Patch, we noticed that editing the aircraft loadouts manually to the SQF code could have become a bit tedious. To alleviate this, we developed the LoadoutManager tool. Now, providing that the weapon/ammunition type/vehicle is defined into the program, editing the loadouts became multiple times faster. Later on, I made change to the program that it automatically takes data from Chernarus and Takistan and updates every terrain that is defined in the code as its own class. This way, every time the program is run, those terrains are kept up to date too. This lightens the developer's workload, as only the Forest and Desert terrains need to be edited. Later, I will create functionality to reduce that to one terrain as we could refactor the mission structure a bit.

SqfFileGenerator.cs

SqfFileGenerator.cs is a C# utility class central to the LoadoutManager program. It specializes in generating SQF (Status Quo Script) files that are tailored to specific loadout configurations. The class serves as a vital link between the program's data models and the SQF files used in the game. One of the key methods inside the class is GenerateAircraftSpecificLoadouts(), that invokes a method: GenerateLoadoutsForTheAircraft() from the BaseAircraft.cs class. This method plays a significant role in generating aircraft-specific loadouts and leans heavily on other classes like BaseWeapon.cs and BaseAmmunition.cs to manage various types of ammunition. The class processes this data to generate the SQF files' content, providing a seamless transition from the program's internal logic to the external SQF files. By doing so, the class ensures that the generated files are compliant with the specific loadout requirements that are setup properly to create a balanced game environment. Beyond generating content, SqfFileGenerator.cs has methods for writing these configurations to files. This makes it easier to integrate them into different modded terrains. The class contains properties that store the text content for these SQF files, which can then be written to disk.

BaseVehicle.cs

BaseAircraft.cs

In the LoadoutManager program, loadouts for aircraft are primarily generated using the BaseAircraft.cs class. This class is an abstract foundation for all types of aircraft and is derived from the BaseVehicle class. It also implements the InterfaceAircraft, encapsulating common behaviors, properties, and methods that are shared across different types of aircraft. The class also contains functionalities for calculating weapon counts and managing ammunition types among other features. It accepts various parameters, such as the type of aircraft and ammunition, to generate tailored loadouts. The method processes these inputs to produce a loadout that can then be written into an SQF file by the SqfFileGenerator.cs class.

Example of a class that derives from BaseAircraft.cs (SU39.cs)

public class SU39 : BaseAircraft
{
    public SU39()
    {
        pylonAmount = 10;
        allowedAmmunitionTypesWithTheirLimitationAmount = new Dictionary<AmmunitionType, int>
        {
            { AmmunitionType.SIXROUNDFAB250, 0 },
            { AmmunitionType.FOURTYROUNDS8, 0 },
            { AmmunitionType.TWELVEROUNDSVIKHR, 4 }, // Vikhrs and Hellfires are automatically multiplied by two
            { AmmunitionType.BASECH29, 0 },
            { AmmunitionType.TWOROUNDGBU12, 8 },
            { AmmunitionType.TWOROUNDR73, 4 },
        };
    }
}

(Note: BaseVehicle components have been omitted for brevity as they have already been discussed.)

For EASA loadouts configuration, data in the allowedAmmunitionTypesWithTheirLimitationAmount Dictionary. The program automatically calculates all possible loadout combinations for a given aircraft based on this data. Note that 12 Vikhrs and 8 Hellfires will always take four pylons, and some weapons can fit many in to one pylon (for example 3 FAB250/MK82 bombs, and 20 S8 rockets per pylon!)

The price of the loadout is calculated cost per pylon basis, and each of the magazines have their own price. Each new weapon currently adds +1000$ to the cost (this may be changed later per weapon). List of these costs can be found at the Implementations folder of the Data of the Ammunition folder structure.

Here's an example how one of the loadouts, [14400,'FAB-250 (6) | S-8 (40) | Kh-29 (4) | R-73 (2)',[['AirBombLauncher','S8Launcher','Ch29Launcher_Su34','R73Launcher_2'],['4Rnd_FAB_250','2Rnd_FAB_250','40Rnd_S8T','4Rnd_Ch29','2Rnd_R73']]], is calculated: 6 FAB250s, 40 S8s, 2 R73's take two pylons each, and four Kh-29's take one each per missile. The per-pylon costs are [300, 3000, 600, 700], resulting in a total cost of 10 400. However, as mentioned before each of the new weapon types, such as AirBombLauncher for the FAB250s, adds 1000$ to the price, thus with four weapon types giving us the final price of 14400$.

Helicopters (BaseHelicopter.cs, AH1Z.cs) have modifiers of prices for missiles like the AIM-9/R-73, which makes them more expensive for that type of aircraft. If the need arises to make such missiles less accessible on helicopters, this modifier could be increased.

The complete list of all the loadouts can be found here (updated always when a new version of the mission is deployed to the server).

This system allows for easy modification of these values in the program to generate new loadouts. With this system, editing these values and exporting them to the game is very easy.

Clone this wiki locally