Arma 3 introduces a module framework, which lets designer to simplify the configuration and chose how the module function will be executed (e.g., globally and for every player who joins later).
How to Create a Module
When creating a new module, follow these steps:
- Create a module addon.
- Make a folder named myTag_addonName a create a config.cpp file in it.
- Inside, declare a CfgPatches class with your addon and its modules (in the units array). Without this, the game wouldn't recognize the addon.
- Make sure the addon and all objects start with your tag, e.g. myTag
class CfgPatches
{
class myTag_addonName
{
units[] = {"myTag_ModuleNuke"};
requiredVersion = 1.0;
requiredAddons[] = {"A3_Modules_F"};
};
};
- Select a module category
- Modules are placed into basic categories which makes finding a desired module easier for an user. Use can use on of the existing categories:
class
|
displayName
|
Effects
|
Effects
|
Events
|
Events
|
Modes
|
Gameplay Modes
|
GroupModifiers
|
Group Modifiers
|
Intel
|
Intel
|
NO_CATEGORY
|
Misc
|
Multiplayer
|
Multiplayer
|
ObjectModifiers
|
Object Modifiers
|
Sites
|
Sites
|
StrategicMap
|
Strategic
|
Supports
|
Supports
|
Alternatively, you can create your own one:
class CfgFactionClasses
{
class NO_CATEGORY;
class myTag_explosions: NO_CATEGORY
{
displayName = "Explosions";
};
};
- Create config for module logic
- All in-game objects (soldiers, vehicles, buildings, logics, modules, ...) are defined in CfgVehicles class.
- All modules must inherit from Module_F parent class, either directly or through some additional sub-parent. While modules inheriting from some other class will be still displayed in the Modules menu (F7), they won't be using the module framework and all benefits tied to it.
- Modules functions are by default not executed when in Eden Editor workspace. It can be enabled using is3DEN property, but that will also change format of function params (see the section about writing a function below).
class CfgVehicles
{
class Logic;
class Module_F: Logic
{
class AttributesBase
{
class Default;
class Edit;
class Combo;
class Checkbox;
class CheckboxNumber;
class ModuleDescription;
class Units;
};
class ModuleDescription
{
class AnyBrain;
};
};
class myTag_ModuleNuke: Module_F
{
scope = 2;
displayName = "Nuclear Explosion";
icon = "\myTag_addonName\data\iconNuke_ca.paa";
category = "Effects";
function = "myTag_fnc_moduleNuke";
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 1;
isDisposable = 1;
is3DEN = 1;
curatorInfoType = "RscDisplayAttributeModuleNuke";
class Attributes: AttributesBase
{
class Units: Units
{
property = "myTag_ModuleNuke_Units";
};
class Yield: Combo
{
property = "myTag_ModuleNuke_Yield";
displayName = "Nuclear weapon yield";
description = "How strong will the explosion be";
typeName = "NUMBER";
defaultValue = "50";
class Values
{
class 50Mt {name = "50 megatons"; value = 50;};
class 100Mt {name = "100 megatons"; value = 100;};
};
};
class Name: Edit
{
displayName = "Name";
description = "Name of the nuclear device";
defaultValue = """Tsar Bomba""";
};
class ModuleDescription: ModuleDescription{};
};
class ModuleDescription: ModuleDescription
{
description = "Short module description";
sync[] = {"LocationArea_F"};
class LocationArea_F
{
description[] = {
"First line",
"Second line"
};
position = 1;
direction = 1;
optional = 1;
duplicate = 1;
synced[] = {"BLUFORunit","AnyBrain"};
};
class BLUFORunit
{
description = "Short description";
displayName = "Any BLUFOR unit";
icon = "iconMan";
side = 1;
};
};
};
};
In the game, the description is available after clicking on "Show Info" button when inserting / editing the module
- Pre-defined sync preview entities are:
- Anything - Any object - persons, vehicles, static objects, etc.
- AnyPerson - Any person. Not vehicles or static objects.
- AnyVehicle - Any vehicle. No persons or static objects.
- AnyStaticObject - Any static object. Not persons or vehicles.
- AnyBrain - Any AI or player. Not empty objects
- AnyAI - Any AI unit. Not players or empty objects
- AnyPlayer - Any player. Not AI units or empty objects
- EmptyDetector - Any trigger
- Configure a module function
class CfgFunctions
{
class myTag
{
class Effects
{
file = "\myTag_addonName\functions";
class moduleNuke{};
};
};
};
- Write the module function
- Create the functions folder within the addon folder and place *.sqf or *.fsm files there.
- Example: \myTag_addonName\functions\fn_moduleNuke.sqf
- Input parameters differ based on value of is3DEN property.
Default
_logic = param [0,objNull,[objNull]];
_units = param [1,[],[[]]];
_activated = param [2,true,[true]];
if (_activated) then {
_bombYield = _logic getVariable ["Yield",-1];
hint format ["Bomb yield is: %1", _bombYield ];
};
true
Eden Editor Compatible
When is3DEN = 1 is set in module config, different, more detailed params are passed to the function.
_mode = param [0,"",[""]];
_input = param [1,[],[[]]];
switch _mode do {
case "init": {
_logic = _input param [0,objNull,[objNull]];
_isActivated = _input param [1,true,[true]];
_isCuratorPlaced = _input param [2,false,[true]];
};
case "attributesChanged3DEN": {
_logic = _input param [0,objNull,[objNull]];
};
case "registeredToWorld3DEN": {
_logic = _input param [0,objNull,[objNull]];
};
case "unregisteredFromWorld3DEN": {
_logic = _input param [0,objNull,[objNull]];
};
case "connectionChanged3DEN": {
_logic = _input param [0,objNull,[objNull]];
};
case "dragged3DEN": {
_logic = _input param [0,objNull,[objNull]];
};
};
true