Difference between revisions of "CMF3: kosherArsenal Loadout"

From cluster wiki
Jump to navigation Jump to search
Tag: Reverted
Tag: Manual revert
 
Line 1: Line 1:
__TOC__
kosherArsenal is a CMF3 feature which allows mission makers to whitelist equipment for playerunits based on their roles or other factors. These whitelist, canonically known as loadouts or loadoutfiles, are separate files located in '''rsc/loadouts/'''. After installing CMF3 into a mission this directory will contain 3 template files; ''!ai_arsenal_template.sqf'', ''!arsenal_template.sqf'', ''!garage_template.sqf''. For kosherArsenal we will focus on the ''!arsenal_template.sqf''. To get started just duplicate the ''!arsenal_template.sqf'' template and name it something descriptive e.g. US_Rangers_1993 and open it up. Inside it should look something like this:
kosherArsenal is a CMF3 feature which allows mission makers to whitelist equipment for playerunits based on their roles or other factors. These whitelist, canonically known as loadouts or loadoutfiles, are separate files located in '''rsc/loadouts/'''. After installing CMF3 into a mission this directory will contain 3 template files; ''!ai_arsenal_template.sqf'', ''!arsenal_template.sqf'', ''!garage_template.sqf''. For kosherArsenal we will focus on the ''!arsenal_template.sqf''. To get started just duplicate the ''!arsenal_template.sqf'' template and name it something descriptive e.g. US_Rangers_1993 and open it up. Inside it should look something like this:
<div class="toccolours mw-collapsible mw-collapsed">
<div class="toccolours mw-collapsible mw-collapsed">

Latest revision as of 23:30, 8 February 2023

kosherArsenal is a CMF3 feature which allows mission makers to whitelist equipment for playerunits based on their roles or other factors. These whitelist, canonically known as loadouts or loadoutfiles, are separate files located in rsc/loadouts/. After installing CMF3 into a mission this directory will contain 3 template files; !ai_arsenal_template.sqf, !arsenal_template.sqf, !garage_template.sqf. For kosherArsenal we will focus on the !arsenal_template.sqf. To get started just duplicate the !arsenal_template.sqf template and name it something descriptive e.g. US_Rangers_1993 and open it up. Inside it should look something like this:

!arsenal_template.sqf
/* Get the unit's role */
private _condition = player getVariable ["cmf_common_role", "RFL"];
private ["_availableUniforms", "_availableWeapons", "_availableMagazines", "_availableVests", "_availableItems", "_availableBackpacks", "_availableHeadgear", "_availableFacewear", "_availableAttachments", "_availableGrenades"];

/* Default gear */
private _defItems = ["ACE_Canteen", "ACE_EarPlugs", "kat_guedel", "ACE_adenosine", "ACE_fieldDressing", "ACE_elasticBandage", "ACE_packingBandage", "ACE_quikclot", "ACE_epinephrine", "ACE_Flashlight_MX991", "ACE_MapTools", "ACE_morphine", "ACE_splint", "ACE_tourniquet", "ItemMap", "ItemCompass", "ItemWatch", "ACE_CableTie"];
private _defWeapons = [];
private _defAttachments = [];
private _defMagazines = [];
private _defGrenades = [];
private _defUniforms = [];
private _defVests = [];
private _defBackpacks = [];
private _defHeadgear = [];
private _defFacewear = [];

/* Rifleman */
if (_condition in ["RFL"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

/* Squad Leader and Fireteam Leader */
if (_condition in ["SL", "FTL"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

/* Medic */
if (_condition in ["MED"]) then {
	player setVariable ["ace_medical_medicclass", 2, true];
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = ["ACE_personalAidKit", "ACE_plasmaIV", "ACE_plasmaIV_250", "ACE_plasmaIV_500", "ACE_surgicalKit", "kat_chestSeal", "kat_larynx", "kat_stethoscope", "kat_amiodarone", "kat_lidocaine", "kat_IO_FAST", "kat_IV_16", "KAT_Empty_bloodIV_500", "KAT_Empty_bloodIV_250", "kat_AED", "kat_aatKit"];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

/* Autorifleman */
if (_condition in ["AR"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

/* Assistant Autorifleman */
if (_condition in ["AAR"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

/* Anti-Tank, Light */
if (_condition in ["LAT"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

/* Loadout array that's passed back to kosherArsenal */
[
	/* Loadoutfile version */
	"1.2",

	/* Allowed Equipment array */
	[
		(_availableBackpacks + _defBackpacks),
		(_availableVests + _defVests),
		(_availableUniforms + _defUniforms),
		(_availableFacewear + _defFacewear),
		(_defHeadgear + _availableHeadgear),
		(_defAttachments + _availableAttachments),
		(_availableMagazines + _defGrenades + _defMagazines + _availableGrenades),
		(_availableWeapons + _defWeapons),
		(_availableItems + _defItems)
	]
];


The format in detail

This following section is used to get the playerunit's role and to declare some variables:

/* Get the unit's role */
private _condition = player getVariable ["cmf_common_role", "RFL"];
private ["_availableUniforms", "_availableWeapons", "_availableMagazines", "_availableVests", "_availableItems", "_availableBackpacks", "_availableHeadgear", "_availableFacewear", "_availableAttachments", "_availableGrenades"]

Unless you are planning to change the factor to use as the condition you can leave this section alone

Default Gear

The next section is the default equipment, this is equipment that every playerunit receives regardless of any factors, in other words equipment defined here is universal for all units:

/* Default gear */
private _defItems = ["ACE_Canteen", "ACE_EarPlugs", "kat_guedel", "ACE_adenosine", "ACE_fieldDressing", "ACE_elasticBandage", "ACE_packingBandage", "ACE_quikclot", "ACE_epinephrine", "ACE_Flashlight_MX991", "ACE_MapTools", "ACE_morphine", "ACE_splint", "ACE_tourniquet", "ItemMap", "ItemCompass", "ItemWatch", "ACE_CableTie"];
private _defWeapons = [];
private _defAttachments = [];
private _defMagazines = [];
private _defGrenades = [];
private _defUniforms = [];
private _defVests = [];
private _defBackpacks = [];
private _defHeadgear = [];
private _defFacewear = [];

For better readability the whitelist has been split into 10 categories, they are the following:

  • _defItems: Misc Items, Nightvision Goggles, Watches, Maps and Terminals go into this slot.
  • _defWeapons: Primaries, Secondaries, launchers and Binoculars go into this slot.
  • _defAttachments: Weapon attachments go into this slot.
  • _defMagazines: Magazines and explosives go into this slot.
  • _defGrenades: Grenades go into this slot.
  • _defUniforms: Uniforms go into this slot.
  • _defVests: Vests go into this slot.
  • _defBackpacks: Backpacks go into this slot.
  • _defHeadgear: Headgear go into this slot.
  • _defFacewear: facewear go into this slot

Whitelisted Gear

The next sections are the whitelists for specific roles (or other custom factors):

/* Rifleman */
if (_condition in ["RFL"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

These sections are as mentioned above whitelists for specific roles. The role that receives the whitelist is defined on the second line inside the brackets ([ ]), here "RFL". This means that if the playerunit has the role identified by "RFL" they will receive this whitelist. Now that we know how the condition works let's take a look at the slots, much like the default slots they are seperated into 10 categories:

  • _availableUniforms: Uniforms go into this slot.
  • _availableWeapons: Primaries, Secondaries, launchers and Binoculars go into this slot.
  • _availableAttachments: Weapon attachments go into this slot.
  • _availableMagazines: Magazines and explosives go into this slot.
  • _availableVests: Vests go into this slot.
  • _availableItems: Misc Items, Nightvision Goggles, Watches, Maps and Terminals go into this slot.
  • _availableGrenades: Grenades go into this slot.
  • _availableBackpacks: Backpacks go into this slot.
  • _availableHeadgear: Headgear go into this slot.
  • _availableFacewear: facewear go into this slot

You may have also noticed that in the template the medic whitelist has an extra line:

player setVariable ["ace_medical_medicclass", 2, true];

This is because anything placed into these whitelist sections will be executed as code, the above example will set the playerunit as an ACE Medic.

Return format

The last section in the file will always be the following:

/* Loadout array that's passed back to kosherArsenal */
[
	/* Loadoutfile version */
	"1.2",

	/* Allowed Equipment array */
	[
		(_availableBackpacks + _defBackpacks),
		(_availableVests + _defVests),
		(_availableUniforms + _defUniforms),
		(_availableFacewear + _defFacewear),
		(_defHeadgear + _availableHeadgear),
		(_defAttachments + _availableAttachments),
		(_availableMagazines + _defGrenades + _defMagazines + _availableGrenades),
		(_availableWeapons + _defWeapons),
		(_availableItems + _defItems)
	]
];

The format and "Loadoutfile version" might change but there will always be an array like this at the bottom. This is how the playerunits final parsed (constructed) whitelist is passed back to the function that called this whitelist. Whitout this final section the loadoutfile will not work. It should also not be modified unless you know what you are doing.

Finding and Adding equipment

Now that we have a firm understanding of the format let's now look at how we find and add equipment to the loadoutfile. The names of the equipment has to be the classname of that equipment. The easiest way to get these classnames is by opening ACE Arsenal on a unit, find and select the equipment we want to get (don't dress up the unit but just find the piece of equipment in the arsenal and have it selected) and hit CTRL + C. This will copy the classname of the selected equipment. Now that we have the classname we need to put it into our loadoutfile. When doing this it is very important that the equipment is placed inside the square brackets ([ ]) and that it is quoted ("). If we have more than one piece of equipment it should be seperated by commas (,). If you're still unsure how to add the equipment look at the example blow:

_availableItems = ["ACE_personalAidKit", "ACE_plasmaIV", "ACE_plasmaIV_250"];

Remember what goes into the different categories (as described in the format overlook) and keep adding equipment until you are satisfied.

Adding a new role/condition

If you need a role that is not defined in the arsenal template all you need to do is make a copy of one of the existing role whitelists:

if (_condition in ["RFL"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

And change the role string (in this case "RFL") into e.g. "SNIPER"

if (_condition in ["SNIPER"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

If you want multiple roles to have the same whitelist you can do the same you do for equipment and add a comma (,) followed by the new role string:

if (_condition in ["SNIPER", "MARKSMAN"]) then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

Finally it is also possible to use completly custom conditions aswell:

if (name player isEqualTo "Eric") then {
	_availableUniforms = [];
	_availableWeapons = [];
	_availableAttachments = [];
	_availableMagazines = [];
	_availableVests = [];
	_availableItems = [];
	_availableGrenades = [];
	_availableBackpacks = [];
	_availableHeadgear = [];
	_availableFacewear = [];
};

This whitelist will apply if the playerunit's name is "Eric".

Some final words

If there is an error in the loadoutfile or it's format the error message will say it's from kosherArsenal and not the file. if you see an error from kosherArsenal it's most likely a broken loadoutfile.

If the playerunit satisfies the conditions for multiple whitelists the last satsified whitelist will be the one selected.

If a playerunit doesn't have a set role it will default to RFL (Rifleman), therefor the Rifleman whitelist should be present in every whitelist as a failsafe.

There will be some tutorial videos in the near future.