Modules

From Bohemia Interactive Community
Revision as of 17:06, 20 March 2019 by Lou Montana (talk | contribs) (Add module creation by script example)
Jump to: navigation, search

Template:SideTOC

Introduction

This page can be considered a hub when it comes to modules. Here you'll find everything you need to know when it comes to creating modules, available modules in Arma 3 and existing module documentation.


General Information

  • Modules are executed before initServer.sqf, initPlayerLocal.sqf and initPlayerServer.sqf (See Initialization Order)
  • Modules are very easy to set up, even for unexperienced users
  • They can easily be used to create mission templates


Spawning a Module by script

A module can be created using createUnit. Same as normal units, a Group must be created first. The variable BIS_fnc_initModules_disableAutoActivation must be set to false in its init to allow its init code to run.

Example

private _moduleGroup = createGroup sideLogic;
"ModuleSmokeWhite_F" createUnit [
	getPosATL player,
	_moduleGroup,
	"this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];"
];


Creating a Module

Arma 3 introduces a module framework which aims to simplify the configuration of modules and the way their functions are executed (Globally,JIP)

1. 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

Example

class CfgPatches
{
	class myTag_addonName
	{
		units[] = {"myTag_ModuleNuke"};
		requiredVersion = 1.0;
		requiredAddons[] = {"A3_Modules_F"};
	};
};

2. Module Category

  • Modules are placed into basic categories which makes finding a desired module easier. You can use on of the existing categories (See table to the right) or create your own category (See example below)
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

Example

class CfgFactionClasses
{
	class NO_CATEGORY;
	class myTag_explosions: NO_CATEGORY
	{
		displayName = "Explosions";
	};
};

3. Creating the Module Config

  • 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.
  • 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.

Example

2D Editor: The description is available after clicking on "Show Info" button when editing the module
Eden Editor: The description is available after opening the modules' attributes window
  • Pre-defined sync preview entities can be:
Class Descripton
Anything Any object - persons, vehicles, static objects, etc.
AnyPerson Any person. Not vehicles or static objects.
AnyVehicle Any vehicle. No persons or static objects.
GroupModifiers Group Modifiers
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

4. Configuring the Module Function

Example

5. Writing 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 Example (is3DEN = 0)

Example Eden Editor (is3DEN = 1)


Module Properties

Arma 3
If you use the Eden Editor please visit Eden Editor: System.
Property Name Description
Name The name of a module can be used to refer to the object in script code. Like all variable names, the name must not contain any spaces or reserved characters. You should try to make it something meaningful and avoid conflicts. Note that if a variable exists with an identical name, no warning will be given and the name will refer to the variable first, rather than the named unit. If you copy and paste a named entity, the duplicate will be automatically have an underscore and number appended to it's name to avoid conflicts.
Initialization Any script code placed in this box will be executed as the mission begins. Script code is extremely powerful and useful - it allows you to create many effects and change aspects of the mission that would not be possible using only the graphical interface of the mission editor. For example, to make a soldier begin the mission unarmed, add "removeAllWeapons this" (without the quotation marks) to it's initialization string. Any expressions in the initialization field must return nothing, or an error message will prevent the unit dialogue from closing.
Description The description property is not used by modules. However, it's used by some functions and it changes the tooltip in Eden Editor when hovering over the module icon.
Probability of Presence Defines how likely it is that the entity will exist each time the mission is played. This can be used to add a bit of randomness to missions. Moving the slider all the way to the right means the object will always be there, all the way to the left means the unit will never appear. Note the Condition of Presence must also return true if the entity is to appear in the mission.
Condition of Presence This is a script code condition which must return true in order for the object to appear in the mission. By default this reads "true" which means the object will appear as defined by it's Probability of Presence. For an example, if you wanted a unit to appear only if the mission is being played in Veteran mode, place "!cadetMode" (without quotation marks) in it's Condition of Presence box. A unit with a Condition of Presence that returns false will not exist in the mission, irrespective of its Probability of Presence.
Placement Radius Changes the object's starting position to a random point within a circle of this radius, in metres. This can be used to add some randomness to your mission. For grouped units, the placement radius is only used by the group leader, and group members with a special setting of None (or In Cargo for a group without suitable vehicle).

Arma 3 Modules (List)

Export Function

Module Documentation

Here you find links to modules which are documented on this wiki.

Arma 2

Arma 3

Take On Helicopters