Tutorial: Basic mod structure and config.cpp (START HERE)

Assuming you know the basics of coding, there are only a few things to make sure you know:

1. Every line of code must end with a semicolon (;)

2. Strings (words) must go in quotation marks

Mod structure:

Each mod starts in a folder labelled @MODNAME. Inside this folder is a folder labelled "Addons" in which the .pbo (compressed) files and a file called mod.cpp (mentioned later) go. The .pbo files are created using Arma 3 Tools' Addon Builder, giving it a valid folder to start from. Each folder must contain a file called config.cpp. This is the only folder necessary to create the mod config.cpp structure:

Generally, the first thing in your config.cpp file is the cfgPatches section. In all parts of your mod, settings are added by declaring the class, and then changing the parameters. Inside the cfgPatches section you declare the name of your file, and inside that, you declare a few things.

- Mod name (Optional)

- Author(s) (Optional)

- Units (All soldiers, vehicles, and backpacks created inside the .pbo)

- Weapons (All weapons created by the .pbo)

- Required version (IDK what it does, I just set it to 0.1 and it works)

- Required addons (.pbo names of all files containing assets used by the .pbo)

For example, the cfgPatches for the WWAF\_USArmy\_Infantry folder would look like this (without most of the classnames):

class cfgPatches

{

  class WWAF\_USArmy\_Inf

  {

    units[]=

    {

      "WWAF\_usarmy\_inf\_base",

...

      "WWAF\_usarmy\_inf\_w\_helic"

    };

    weapons[]=

    {

  "RH\_m4\_M68",

"RH\_m4\_RIS\_M68\_PEQ15",

...

"RH\_m110\_leu\_mk4"

    };

    requiredVersion = 0.1;

    requiredAddons[]=

    {

      "WWAF\_main"

    };

  };

};

Note that anything that has more than one value has a [ ] after it, indicating an array, and its values are defined inside { }, inside quotation marks, separated by commas. Also note the positions of the semicolons. In my mod, I have a separate file called WWAF\_main that creates the factions and vehicleClasses, and also all of the mods used by my mod, so that is why the only addon here is WWAF\_main. It is also good practice to put in lots of spaces and use indents to help keep the code readable.

If any of the fields were empty, you would just leave it empty, such as weapons[] = {};

Whenever creating a mod, it is a good idea to register a tag on the OFPEC forums, and place it at the beginning of all your names in order to avoid conflicts, and identify your work, in this case, I have registered WWAF.

The next thing you will probably want to do is create a faction in which to put your new units. This is done with the cfgFactionClasses class. Inside, you define several things:

- The name

- the author

- The flag texture (optional)

- the icon texture (optional)

- the side

- the priority (I usually just leave it at 1, I don't really know what it does, as factions are organized alphabetically in the editor)

The faction for the U.S. Army desert faction defined above would look like:

class cfgFactionClasses

{

  class WWAF\_usarmy\_d

  {

    displayName = "(WAF) US Army (D)";

    author = "Nightwolf";

    flag = "\a3\Data\_f\Flags\flag\_nato\_co.paa";

    icon = "\a3\Data\_f\cfgFactionClasses\_BLU\_ca.paa";

    side = 1;

    priority = 1;

  };

};

Whenever you need to point to another file, there are a couple scenarios.

1. If the file is in the same folder, you can just put the name of the file (and the extension), for example: icon = "TAG\_NAME.paa";

2. If the file is in any other .pbo file, you put the top folder first, and use backslashes to navigate, such as in the example above (Make sure to start with a backslash BEFORE the first filename!).

3. If the file is in the same .pbo, but in another folder, you put the first filename WITHOUT a backslash first, ex. icon = "Data\TAG\_NAME.paa";

The sides are defined by numbers. 0 = OPFOR, 1 = BLUFOR, 2 = INDE? and 3 = CIV?

Other things you might want to include in the base part of your config.cpp include: cfgMods and cfgEditorSubcategories cfgMods allows you to define things about your mod, such as:

- Different logos

- Color

- Whether or not to hide things

- The tooltip displayed when icon is moused over

- The displayed name of the mod

- An overview description of your mod

- A link to take people to when they press the "Website" button

For example,

class CfgMods

{

  class WWAF

  {

logo = "\WWAF\_main\Data\WWAF\_logo.paa";          //Logo displayed in bottom left of main menu

logoOver = "\WWAF\_main\Data\WWAF\_logo.paa"; //Logo displayed in the mod menu when mod icon is clicked

logoSmall = "\WWAF\_main\Data\WWAF\_logo.paa";     //Logo displayed next to all units and vehicles in the editor

dlcColor[] = {0,0,0,1}; //Something about color, just leave it like this

hideName = 0; //Hide the name of the mod

hidePicture = 0; //Hide the logo of the mod

tooltipOwned = "WWAF"; //Tooltip when mod icon is moused over in main menu

name = "Worldwide Armed Forces"; //Full name of the mod

overview = "All of the factions combined together from the fantastic mods in the ShackTactical server modset, all in one place!";

//Description of the mod displayed in the "DLC" page of the main menu

action = "http://steamcommunity.com/sharedfiles/filedetails/?id=847444271"; //Link to take people to from "Website" button

  };

};

This is only required once, preferably in the main .pbo of the mod. This content should also be placed into another file called mod.cpp to be placed in the directory under the one labelled with the @ symbol (so along with the Addons folder). Note that when you place to slashes next to each other, the line after it will be ignored by the game. This is called "commenting it out." If you wish to comment out many lines at once, start the comment with a /\* and place a \*/ in the place where you wish to pick up the code again.

cfgEditorSubcategories is another class that allows you to define the next level of organization below faction. For example, when you open up the editor, you can click the NATO dropdown menu, which gives you access to many subcategories, such as "Men" "Helicopters" etc. If you wish to use your own categories, they can be defined here. The only thing to define is the name of the category. To define a class called "APCs" would look like this:

class cfgEditorSubcategories

{

  class WWAF\_ed\_apc

  {

    displayName = "APCs";

  };

};

When creating a unit or vehicle, the classname, "WWAF\_ed\_apc" can be used to tell the game where to place the unit. This used to be done using cfgVehicleClasses, but that is now an outdated method, and editorSubcategory will override and vehicleClass given to a unit.

When all put together, these will be the basis of you config.cpp. This is by no means all that will go into it, but this is the base required to start creating soldiers.

Here is the full text of my WWAF\_main config.cpp file as an example.

class cfgPatches

{

  class WWAF\_main

  {

    author = "Nightwolf";

    versionDesc = "WAF"; //IDK what this is, I just saw it in an RHS file

    version = "0.4";

    units[]={};

    weapons[]={};

    requiredVersion=0.1;

    requiredAddons[]=

    {

      "rhsusf\_c\_troops",

...

      "rhs\_c\_a2port\_air"

    };

  };

};

class CfgMods

{

  class WWAF

  {

logo = "\WWAF\_main\Data\WWAF\_logo.paa";

logoOver = "\WWAF\_main\Data\WWAF\_logo.paa";

logoSmall = "\WWAF\_main\Data\WWAF\_logo.paa";

dlcColor[] = {0,0,0,1};

hideName = 0;

hidePicture = 0;

tooltipOwned = "WWAF";

name = "Worldwide Armed Forces";

overview = "All of the factions combined together from the fantastic mods in the ShackTactical server modset, all in one place!";

action = "http://steamcommunity.com/sharedfiles/filedetails/?id=847444271";

  };

};

class cfgEditorSubcategories

{

  class WWAF\_ed\_men

  {

    displayName = "Men";

  };

  class WWAF\_ed\_apc

  {

    displayName = "APCs";

  };

  class WWAF\_ed\_ifv

  {

    displayName = "IFVs";

  };

  class WWAF\_ed\_car

  {

    displayName = "Cars";

  };

  class WWAF\_ed\_truck

  {

    displayName = "Trucks";

  };

  class WWAF\_ed\_tank

  {

    displayName = "Tanks";

  };

  class WWAF\_ed\_static

  {

    displayName = "Turrets";

  };

  class WWAF\_ed\_arty

  {

    displayName = "Artillery";

  };

  class WWAF\_ed\_Heli

  {

    displayName = "Helicopters";

  };

  class WWAF\_ed\_MRAP

  {

    displayName = "MRAPs";

  };

  class WWAF\_ed\_AA

  {

    displayName = "Anti-Air";

  };

};

class cfgFactionClasses

{

  class WWAF\_usarmy\_d

  {

    displayName = "(WAF) US Army (D)";

    author = "Nightwolf";

    flag = "\a3\Data\_f\Flags\flag\_nato\_co.paa";

    icon = "\a3\Data\_f\cfgFactionClasses\_BLU\_ca.paa";

    side = 1;

    priority = 1;

  };

  class WWAF\_usarmy\_w

  {

    displayName = "(WAF) US Army (W)";

    author = "Nightwolf";

    flag = "\a3\Data\_f\Flags\flag\_nato\_co.paa";

    icon = "\a3\Data\_f\cfgFactionClasses\_BLU\_ca.paa";

    side = 1;

    priority = 1;

  };

  class WWAF\_meins

  {

    displayName = "(WAF) Middle Eastern Insurgents";

    author = "Nightwolf";

    side = 0;

    priority = 1;

  };

  class WWAF\_can\_d

  {

    displayName = "(WAF) Canadian Army (D)";

    author = "Nightwolf";

    side = 1;

    priority = 1;

    flag = "\a3\Data\_f\Flags\flag\_nato\_co.paa";

    icon = "\a3\Data\_f\cfgFactionClasses\_BLU\_ca.paa";

  };

  class WWAF\_can\_w

  {

    displayName = "(WAF) Canadian Army (W)";

    author = "Nightwolf";

    side = 1;

    priority = 1;

    flag = "\a3\Data\_f\Flags\flag\_nato\_co.paa";

    icon = "\a3\Data\_f\cfgFactionClasses\_BLU\_ca.paa";

  };

  class WWAF\_ukr

  {

    displayName = "(WAF) Ukrainian Army";

    author = "Nightwolf";

    side = 1;

    priority = 1;

    flag = "\a3\Data\_f\Flags\flag\_nato\_co.paa";

    icon = "\a3\Data\_f\cfgFactionClasses\_BLU\_ca.paa";

  };

};

As you can see, you can define multiple classes in each category. YOU SHOULD NOT HAVE MORE THAN ONE OF ANY CATEGORY. This will mess everything up. Also note there is nothing to signify the end of the file, the game will reach the end and know that there is nothing else required.