ARMA 3 - Adding custom Attributes

My goal was to only add attributes to particular objects (in this case targets).
After spending several hours figuring out how to add custom attributes, I thought this was a perfect opportunity to write an article.
So here is my result on how to add custom attributes to an object in the Eden Editor.

Small disclaimer:

I'm keeping this mostly for myself here, so if you notice any mistakes here, feel free to let me know.

The beginning

For this to be possible at all an addon must be created. A short tutorial can be found here: https://community.bistudio.com/wiki/Arma_3:_Creating_an_Addon

Config.cpp

Changes are only necessary for this file and this is how it has to look for this to work:


class CfgVehicles {

	...

	class All;
	class Static: All
	{
	class Attributes;
	};

	class TargetBase: Static
	{
	class Attributes: Attributes
	{
	
		// Attribute class, can be anything
		class shiny_CQBCourseAddSeconds
		{
			//--- Mandatory properties
			displayName = "Seconds"; // Name assigned to UI control class Title
			tooltip = "Seconds to add, when target is Hit. Set a number above 0 to give a penalty, when this target is hit. Use negative numbers to give bonus seconds."; // Tooltip assigned to UI control class Title
			property = "shiny_CQBCourseAddSeconds"; // Unique config property name saved in SQM
			control = "Edit"; // UI control base class displayed in Edit Attributes window, points to Cfg3DEN >> Attributes

			// Expression called when applying the attribute in Eden and at the scenario start
			// The expression is called twice - first for data validation, and second for actual saving
			// Entity is passed as _this, value is passed as _value
			// %s is replaced by attribute config name. It can be used only once in the expression
			// In MP scenario, the expression is called only on server.
			expression = "_this setVariable ['%s',_value];";

			// Expression called when custom property is undefined yet (i.e., when setting the attribute for the first time)
			// Entity (unit, group, marker, comment etc.) is passed as _this
			// Returned value is the default value
			// Used when no value is returned, or when it is of other type than NUMBER, STRING or ARRAY
			// Custom attributes of logic entities (e.g., modules) are saved always, even when they have default value
			defaultValue = "0";

			//--- Optional properties
			unique = 0; // When 1, only one entity of the type can have the value in the mission (used for example for variable names or player control)
			validate = "number"; // Validate the value before saving. If the value is not of given type e.g. "number", the default value will be set. Can be "none", "expression", "condition", "number" or "variable"
			condition = "(1 - objectBrain) * (1 - objectVehicle)"; // Condition for attribute to appear (see the table below)
			typeName = "NUMBER"; // Defines data type of saved value, can be STRING, NUMBER or BOOL. Used only when control is "Combo", "Edit" or their variants
		};
		class shiny_CQBCourseIsStarter
		{
			//--- Mandatory properties
			displayName = "Is Starter"; // Name assigned to UI control class Title
			tooltip = "Should hitting this target start the course?"; // Tooltip assigned to UI control class Title
			property = "shiny_CQBCourseIsStarter"; // Unique config property name saved in SQM
			control = "Checkbox"; // UI control base class displayed in Edit Attributes window, points to Cfg3DEN >> Attributes

			// Expression called when applying the attribute in Eden and at the scenario start
			// The expression is called twice - first for data validation, and second for actual saving
			// Entity is passed as _this, value is passed as _value
			// %s is replaced by attribute config name. It can be used only once in the expression
			// In MP scenario, the expression is called only on server.
			expression = "_this setVariable [""shiny_CQBCourseIsStarter"",_value,true)];";

			// Expression called when custom property is undefined yet (i.e., when setting the attribute for the first time)
			// Entity (unit, group, marker, comment etc.) is passed as _this
			// Returned value is the default value
			// Used when no value is returned, or when it is of other type than NUMBER, STRING or ARRAY
			// Custom attributes of logic entities (e.g., modules) are saved always, even when they have default value
			defaultValue = "0";

			//--- Optional properties
			unique = 0; // When 1, only one entity of the type can have the value in the mission (used for example for variable names or player control)
			validate = "number"; // Validate the value before saving. If the value is not of given type e.g. "number", the default value will be set. Can be "none", "expression", "condition", "number" or "variable"
			condition = "(1 - objectBrain) * (1 - objectVehicle)"; // Condition for attribute to appear (see the table below)
			typeName = "BOOL"; // Defines data type of saved value, can be STRING, NUMBER or BOOL. Used only when control is "Combo", "Edit" or their variants
		};
	};
	};

};

As far as I have seen now, an own category is not possible this way.

... class B_Soldier_F; class MyEntity: B_Soldier_F // Your entity class. { class Attributes // Entity attributes have no categories, they are all defined directly in class Attributes ...

To add your own category you have to set another config. The disadvantage is that this can not use on the inherited classes but on prefabricated conditions.

You can find detailed instructions here: https://community.bistudio.com/wiki/Eden_Editor:_Configuring_Attributes

For my example it would look like this:
config.cpp


class Cfg3DEN
{
	// Configuration of all objects
	class Object
	{
		// Categories collapsible in "Edit Attributes" window
		class AttributeCategories
		{
			// Category class, can be anything
			class MyCustomCategory
			{
				displayName = "Category Name"; // Category name visible in Edit Attributes window
				collapsed = 0; // When 1, the category is collapsed by default
				class Attributes
				{
					// Attribute class, can be anything
					class MyCustomAttribute
					{
						//--- Mandatory properties
						displayName = "My Name"; // Name assigned to UI control class Title
						tooltip = "My Explenation"; // Tooltip assigned to UI control class Title
						property = "UniqueId"; // Unique config property name saved in SQM
						control = "Edit"; // UI control base class displayed in Edit Attributes window, points to Cfg3DEN >> Attributes

						// Expression called when applying the attribute in Eden and at the scenario start
						// The expression is called twice - first for data validation, and second for actual saving
						// Entity is passed as _this, value is passed as _value
						// %s is replaced by attribute config name. It can be used only once in the expression
						// In MP scenario, the expression is called only on server.
						expression = "_this setVariable ['%s',_value];";

						// Expression called when custom property is undefined yet (i.e., when setting the attribute for the first time)
						// Entity (unit, group, marker, comment etc.) is passed as _this
						// Returned value is the default value
						// Used when no value is returned, or when it is of other type than NUMBER, STRING or ARRAY
						// Custom attributes of logic entities (e.g., modules) are saved always, even when they have default value
						defaultValue = "0";

						//--- Optional properties
						unique = 0; // When 1, only one entity of the type can have the value in the mission (used for example for variable names or player control)
						validate = "number"; // Validate the value before saving. If the value is not of given type e.g. "number", the default value will be set. Can be "none", "expression", "condition", "number" or "variable"
						condition = "(1 - objectBrain) * (1 - objectVehicle)"; // Only objects CREDITS: ACE TEAM
						typeName = "NUMBER"; // Defines data type of saved value, can be STRING, NUMBER or BOOL. Used only when control is "Combo", "Edit" or their variants
					};
				};
			};
		};
	};
};

Subscribe to Eduard Schwarzkopf

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe