Creating an Addon – Arma 3

From Bohemia Interactive Community
Revision as of 23:48, 15 August 2021 by Leopard20 (talk | contribs)
Jump to navigation Jump to search

This page explains the steps required to create an addon (PBO file).

Prerequisites

  • An addon making tool, such as the official Arma 3 Tools, or Mikero's Tools.
  • A text editor, such as Notepad++ or Visual Studio Code.

Preparing the Addon

Place all required files (scripts, textures, fonts, models, etc.) in an empty folder, which hereafter will be referred to as the Addon folder.
It is recommended to categorize the files into separate folders to avoid clutter.

Addon Prefix

In simple terms, Addon Prefix is a virtual (in-game) path to the root of an addon. This virtual path should be unique to prevent collision with other addons. The addon prefix is added to the PBO properties by the packing tool.

The addon prefix is typically a single word:

Addon_Name


It is also possible to use a directory-like structure, which is typically used by mods that contain several addons:

Mod_Name\Addon_Name\Category\...

For example:

My_Faction_Mod\Faction_Name\Vehicles


Once the addon prefix is set, the path to addon files will become:

Addon_Prefix\Folder\File.sqf


The addon prefix can only contain English letters, numbers, underscore (_) and backslash (\). Note that spaces are not allowed!

Setting the Addon prefix

There are several ways to set the addon prefix, depending on the packing tool used. The instructions for two commonly used tools, namely Addon Builder and Mikero's Tools are explained.

Using Addon Builder

To set the addon prefix using Addon Builder, simply navigate to "Options" and modify the "Addon prefix" edit box.

Using Mikero's pboProject

To set the addon prefix using Mikero's pboProject, create a text file called $PBOPREFIX$ (no file format is required, but .txt is also possible) in the root of the addon folder, and put the addon prefix in the file.

Config.cpp

When the game loads an addon, it looks for a file called config.cpp to determine how to process the addon contents. Without such file, almost nothing will happen. In other words, config.cpp is the hub through which all of the addon contents will be applied to the game.

At the bare minimum, the config.cpp file requires a CfgPatches class. This will allow the game to determine what external addons are required by this addon, what objects/weapons are being added, as well as other information about the addon such as the author, version, etc.
All added/patched classes should be added to this added to this file in order to be recognized by the game.

Config modifications

All added/modified config classes, such as CfgVehicles, CfgWeapons, CfgAmmo, CfgFunctions, CfgCloudlets, etc. need to be added to this file.
If the class contents are too long, it is recommended to put them in external files (e.g. CfgFunctions.hpp) and #include them in the config.cpp file:

class cfgPatches {
   //....
};
#include "cfgFunctions.hpp"
#include "some_other_file.hpp"
#include "ui\gui_defines.hpp"
// etc.

Scripts

It is recommended to register your scripts as functions in the CfgFunctions class, especially if they are expected to be executed many times during the mission.

There are several ways to execute scripts, depending on the time and place where that is supposed to happen.
For example, scripts that are to be executed at mission init can be added to the CfgFunctions class with an init flag, such as preInit = 1.
Scripts that need to execute when a certain event takes place, can be executed using appropriate Event Handlers, if applicable.
Some community modifications, such as Community Based Addons 3 (CBA), add more ways to execute scripts.

Building the Addon

Folder Setup in Addon Builder

Signing the Addon

--empty--