Jump to content
badguy360th

A LoadoutFramework for Arma 3

Recommended Posts

Hello Community,

I'm visiting this forum very often and I like to the informative threads here. Now I want to give something back to the community. It is a loadout framework for Arma 3:

LoadoutFramework

The LoadoutFramework simplifies the creation of unit loadouts in Arma 3.

This script based approach uses config class definitions as loadout definitions. Due to this technique, class inheritance is possible and simplifies the mission editors life.

Usage

Setup

  1. Copy the loadoutFramework folder to your mission folder
  2. Edit your description.ext and include following:
#include "loadoutFramework\base.hpp"
class CfgFunctions {
    #include "loadoutFramework\cfgFunctions.hpp"
};

Create Loadouts

Every user created loadout is described in loadoutFramework/cfgLoadouts.hpp. In this file, only classes inherited from the Collection-class should be inserted.

 

The Collection-class

The Collection-class is the base class for all classes defined in the framework. This class describes the basic loadout-slots used in the framework.

class Collection {
    uniform[] = {}; // Uniform. e.g. {'U_B_CombatUniform_mcam'}
    vest[] = {}; // Vest
    headgear[] = {}; // Headgear like helmets
    goggle[] = {}; // Goggles
    backpack[] = {}; // Backpack
    primaryWeapon[] = {}; //primary Weapon
    primaryWeaponOptic[]={}; // Scope for primary Weapon
    primaryWeaponMuzzle[]={}; // Muzzle Attachment for prim. Weapon
    primaryWeaponBarrel[] = {}; // Barrel Attachment for prim Weapon
    primaryWeaponResting[] = {}; // Weapon Resting Attachment like bi-pods
    primaryWeaponLoadedMagazine[] = {}; // the loaded magazine
    secondaryWeapon[] = {}; // secondary Weapon
    secondaryWeaponOptic[]={}; // same like primaryWeaponOptic see above
    secondaryWeaponMuzzle[]={};
    secondaryWeaponBarrel[] = {};
    secondaryWeaponResting[] = {};
    secondaryWeaponLoadedMagazine[] = {};
    handgun[] = {}; // handgun
    handgunOptic[]={}; // same like primaryWeaponOptic see above
    handgunMuzzle[]={};
    handgunBarrel[] = {};
    handgunResting[] = {};
    handgunLoadedMagazine[] = {};
    binocular[] = {}; // Binocular Item
    magazines[] = {}; // all magazines which can be stored in uniform, vest or backpack depending on space. E.g. {{"30Rnd_65x39_caseless_mag_Tracer",3},{"30Rnd_65x39_caseless_mag",6}}; for 3x 30 Rnd 6.5x39mm caseless Tracer and 6x 30 Rnd 6.5x39mm caseless magazines
    items[] = {}; // all other items (magazines are also possible) which can be stored in uniform, vest or backpack depending on space. Same definition like magazines[].
    itemsUniform[] = {}; // all items (magazines are also possible) which have to be stored in uniform. Same definition like magazines[].
    itemsVest[]={}; // all items (magazines are also possible) which have to be stored in vest. Same definition like magazines[].
    itemsBackpack[] = {}; // all items (magazines are also possible) which have to be stored in backpack. Same definition like magazines[].
    linkedItems[]={};// all items which are linked to a special slot (NVG, Map, Watch etc.). E.g. {"ItemWatch","ItemCompass","ItemMap","NVGoggles"};
    script[]={};// A script which is executed after applying loadout.
};

Every property is defined as an array. This allows the user to define multiple e.g. uniforms. The system chooses then one uniform randomly.

 

Custom Loadout

By inheriting the Collection-class (class MyLoadout : Collection), you can define your custom loadout by filling the properties. As class inheritance is possible, you can define additional loadouts based on other loadouts.

Additional, you are able to aggregate sub-collections. Maybe you want to have a medical backpack and some weapons with a predefined magazine loadout, you can create some sub-collections which can be added to your unit-loadout.

class Weapon_MX : Collection { // ideally added to cfgTemplates.hpp but not necessary
    primaryWeapon[] = {"arifle_MX_F"};
    primaryWeaponOptic[]={"optic_Aco"};
    primaryWeaponLoadedMagazine[]={"30Rnd_65x39_caseless_mag"};
    primaryWeaponBarrel[] = {"acc_pointer_IR"};
    magazines[] = {{"30Rnd_65x39_caseless_mag_Tracer",3},{"30Rnd_65x39_caseless_mag",6}};
};
class AnotherClass : Collection {
...
};
class Rifleman : Collection {
    uniform[] = {"U_B_CombatUniform_mcam"};
    vest[] = {"V_PlateCarrierL_CTRG"};
    headgear[] = {"H_HelmetB_camo"};
    goggle[] = {"G_Combat"};
    backpack[] = {"B_AssaultPack_mcamo"};
    handgun[] = {"hgun_P07_F"};
    magazines[] = {{"16Rnd_9x21_Mag",2}};
    itemsBackpack[] = {{"FirstAidKit",3}};
    linkedItems[]={"ItemWatch","ItemCompass","ItemMap","NVGoggles"};
    class PrimaryWeaponClass : Weapon_MX { // Some Collections added to Rifleman Collection
      primaryWeaponOptic[]={}; // Change optic to iron sight for this collection
    };
    class AnotherSubCollaction : AnotherClass {};
};

As shown in this example, you can simply overwrite certain properties (primary weapon was changed to iron sight), if you wish to change the loadout for some loadouts.

Sub-collections which are not usable standalone, should be created in the cfgTemplates.hpp-file.

 

Applying the Loadout

The function BG_fnc_applyLoadout applies the loadout to a unit.

Syntax: 

[<unit>,<loadoutName>] call BG_fnc_applyLoadout;

Note: <unit> has to be local!

 

 

That's it. You can find this script on my GitHub account:

GitHub

Share this post


Link to post
Share on other sites

Hello BG

 

I really like your introduction on the loadoutFramework. Great Job!  :)   However, I do have a problem that the unit I defined does not change eg. "Iron sight" or the uniform I defined with the ascociated parameter change. Something seems to be still wrong. I did follow the order a described:

  1. Copy the loadoutFramework folder to your mission folder
  2. Edit your description.ext and include   ->  #include "loadoutFramework\base.hpp" class CfgFunctions {     #include "loadoutFramework\cfgFunctions.hpp" };)

I think soemthing with the applying part of the lodout to the unit might be wrong :blink:  

 

[<unit>,<loadoutName>] call BG_fnc_applyLoadout;

 

I created a unit using the editor an put the syntax to the initialize field of the unit.

 

Unit is called 'xmen' and i want to use the class 'Riflemen' defined in the cfgloadout.hpp.

Then, i created the below syntax' in the units initialization field but none of them seem to work. Also I'm not sure what does 'local' mean as explained in your introduction.

 

[this, "Rifleman"] call BG_fnc_applyLoadout;

["xmen", "Rifleman"] call BG_fnc_applyLoadout;

[xmen, Rifleman] call BG_fnc_applyLoadout;

 

How does the code look like in a .sqf file? I also tried to put these into the init.sqf of the mission created. -> no success either.

 

Can you help me ?

 

 

 

Share this post


Link to post
Share on other sites

hi boosterchen,

 

local means that the code is executed on the machine, which owns and controls the unit. If it is an enemy AI unit, this code has to be executed on the server or headless client which controls the unit. If this unit is an ai unit, which is controlled by a player, this code needs to be executed on the player client machine. And if the loadout is applied to a player, this code has to be executed on the players machine. A good explanation about locality and MP scripting you can find here: http://killzonekid.com/arma-scripting-tutorials-basic-multiplayer-coding-v2/

 

Personally I used the onPlayerRespawn.sqf script to apply the loadouts to players. With this method, i make sure that the script is only executed on the players machine. With AI you can use 

if (!local this) exitWith {};

in init line to make sure, that the code is only be executed on the correct machine.

 

Some questions/remarks to your problem:

- is xmen an AI unit?

- please try: 

if (!local this) exitWith {}; [this, "Rifleman"] call BG_fnc_applyLoadout;

in init line. Could you post your cfgLoadouts.hpp and cfgTemplates.hpp. Did you use the current github repository?

 

Hopefully some of my remarks can help you. Maybe you have found a bug. In the future I will provide an advanced example, how to use this script in mp-missions. Maybe I can provide this tomorrow.

 

BadGuy

Share this post


Link to post
Share on other sites

Hello BG,

 

Thanks for the proper resonse.  Yes 'xmen' is an AI unit (NATO & Rifleman) and it is executed on the players (my) machine only (I try to create a simple SP Campaign). However, at this stage I did not yet put all the misions toghether so it is just a mission currently which can changed in the editor as often as needed.

 

I used your code <if (!local this) exitWith {}; [this, "Rifleman"] call BG_fnc_applyLoadout;>  in the Units init.  Still no change  :(.

 

Yes, I downloded the original files from the GIT Hub 2 days ago.

 

my cfgLoadouts.hpp:

 

class Rifleman : Collection {
    uniform[] = {"U_BasicBody"};        ->  tried to replace the unifrom to Underware only
    vest[] = {"V_PlateCarrierL_CTRG"};
    headgear[] = {"H_HelmetB_camo"};
    goggle[] = {"G_Combat"};
    backpack[] = {"B_AssaultPack_mcamo"};
    handgun[] = {"hgun_P07_F"};
    magazines[] = {{"16Rnd_9x21_Mag",2}};
    itemsBackpack[] = {{"FirstAidKit",3}};
    linkedItems[]={"ItemWatch","ItemCompass","ItemMap","NVGoggles"};
    class PrimaryWeaponClass : Weapon_MX { // Some Collections added to Rifleman Collection
      primaryWeaponOptic[]={}; // Change optic to iron sight for this collection
    };
};

 

my cfgTemplates.hpp:

 

class Weapon_MX : Collection {
 primaryWeapon[] = {"arifle_MX_F"};
 primaryWeaponOptic[]={"optic_Aco"};
 primaryWeaponLoadedMagazine[]={"30Rnd_65x39_caseless_mag"};
 primaryWeaponBarrel[] = {"acc_pointer_IR"};
 magazines[] = {{"30Rnd_65x39_caseless_mag_Tracer",3},{"30Rnd_65x39_caseless_mag",6}};
};

 

 

 

Looking forward to hearing from you.

 

Boosterchen.

Share this post


Link to post
Share on other sites

Could you provide me a RPT-file and/or the mission itself? Does nothing change after applying the loadout?

Share this post


Link to post
Share on other sites

can do, where shall I upload it ? I think attachment is not possible here. Is it?

 

Another suggestion: Would you be able to create and test a simple mission containing one or two units and your loadout script included, which works on your machine?  I then could download it and test here. If it's not working on my client then there might be an issue with my Arma3 installation?  ....

Share this post


Link to post
Share on other sites

Hey BG

 

I have reinstalled ARMA 3 and use the same selfmade missions again.    Now, everthing works!!! :)  :D  :D  :D  

 

Must have been a bug with the app itself.

 

Thank you for your help on this.  Again great work and support!  Really appreciated.

 

Boosterchen

Share this post


Link to post
Share on other sites

Hey BG

 

What would i need to do -  if I want to offload the LoadoutFramework to a outside of the misssion folder? Let's say for a campaign that the loadoutframework function can be used by different missions.

 

The structure I'm looking for as shown below:  

 

Folder:  
   \Campaigns\DM_BST\Missions -> containing the missions like x1,x2,x3, etc.

   \Campaigns\DM_BST\LoadoutFramework  -> LoadoutFramework containing all the files apart from the classes!  The classes I would like to have in a seperate file , eg. as shown below:

   

   \Campaigns\DM_BST\cfg  -> That where I want to put the config file, called "cfgFunctions.hpp" containg the classes such as:

 

#include "loadoutFramework\base.hpp"

class CfgFunctions {     #include "loadoutFramework\cfgFunctions.hpp" };

 

and also the ones described in the File "CFGFunctions" whithin the LoadaoutFramework folder.

 

I tried several times with different options to achieve this but none of them worked. The problem start there as soon as i want to take out the classes described from de description.ext.  (Of course I changed the file pathes to it accordingly and did adapt the individual decription.ext file of the missions with the '#include'..

 

#Include "\Campaigns\DM_BST\cfg\cfgFunctions.hpp"

 

Would appreciate some help with that.
 

 

 

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×