Eden Editor: Configuring Attributes
A scenario and each entity in it are defined by their attributes. An attribute is a value customizable by the user, and it has some function tied to it. For example position object attribute tells engine where to create the object, and respawn scenario attributes determines what rule set will be used when players respawn.
Each attribute is configured in the global Config.cpp. Major engine-driven attributes are already present in the default Editor and can be modified to a degree. Modders can also add completely new attributes and decide how will they appear in the attribute window and what scripted functionality will they execute in the scenario.
Attributes can be added for general entity type (e.g., shared by all objects) or for specific entity types (e.g., just for BLUFOR Rifleman). An entity type can also override default values of general attributes (e.g., story character can have customized name and rank).
Structure
Attributes are configured and presented in the following structure:
- Owner - defines what does the attribute set. Can be an entity, a scenario or editor preferences. In user interface, this is the whole attributes window.
- └ Category - thematic category. Used only for sorting in the window, has no effect on the scenario.
- └ Attribute - setting itself, represented by tailored user interface.
Configuration
Entity
General
General attributes are available for all entity classes of given type. Optional conditions can be applied to show the attribute only for limited subset of entities. For example rank attribute is shared by every object, be it a character, a vehicle or a prop. But its condition makes sure only characters have it available.
Attribute functionality is determined by its expression property. It is a code called at the scenario start, and it's purpose is to apply the attribute's value. The expression is saved to the scenario file together with value, which makes it independent on the addon which introduced the attribute. Only attributes with values different from the default are saved to the scenario file, which means only their expression will be called.
class Cfg3DEN
{
// Configuration of all objects
class Object
{
// Categories collapsible in "Edit Attributes" window
class AttributeCategories
{
// Category class, can be anything
class MyCategory
{
displayName = "Object Init"; // Category name visible in Edit Attributes window
collapsed = 1; // When 1, the category is collapsed by default
class Attributes
{
// Attribute class, can be anything
class MyAttribute
{
property = "MyAttributeUniqueID"; // Unique config property name saved in SQM
control = "Edit"; // UI control base class displayed in Edit Attributes window, points to Cfg3DEN >> Attributes
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 = "code"; // Validate the value before saving. Can be "none", "expression", "condition", "number" or "variable"
condition = "object"; // Condition for attribute to appear (see the table below)
// Expression called when applying the attribute in Eden and at the scenario start
// Entity is passed as _this, value is passed as _value, property name is passed as _property
// %s is replaced by attribute config name. It can be used only once in the expression
expression = "_this setVariable [%s,_value];";
// Expression called when custom property is undefined yet (i.e., when setting the attribute for the first time)
// Entity is passed as _this
// Returned value is the default value
// Used when no value is returned, or when it's 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 = "42";
};
};
};
};
};
};
Entity Specific
- CfgVehicles
- CfgNonAIVehicles
- CfgWaypoints
- CfgMarkers
class CfgVehicles
{
class B_Soldier_F;
class MyEntity: Soldier_F // Your entity class
{
class Attributes // Entity attributes have no categories, they are all defined directly in class Attributes
{
class MyEntityAttribute
{
// ... attribute properties, see entity attributes
};
};
};
};
Scenario
class Cfg3DEN
{
class Mission
{
class MySection // Custom section class, everything inside will be opened in one window
{
displayName = "My Attributes"; // Text visible in the window title as "Edit <displayName>"
display = "Display3DENEditAttributesPreview"; // Optional - display for attributes window. Must have the same structure and IDCs as the default Display3DENEditAttributes
class AttributeCategories
{
// The following structure is the same as the one used for entity attributes
class MyMissionCategory
{
class Attributes
{
class MyMissionAttribute
{
property = "MyMissionAttributeUniqueID";
};
};
};
};
};
};
};
edit3DENMissionAttributes "MySection";
getMissionConfigValue "MyMissionAttributeUniqueID"
set3DENMissionAttributes [["MySection","MyMissionAttributeUniqueID",42]]
_myAttributes = "MySection" get3DENMissionAttribute "MyMissionAttributeUniqueID";
Preferences
There is a special section called Preferences. Any attribute configured in it will be saved in player's profile instead of inside mission file. This is used for global editor preferences, like camera speed or autosave settings.
class Cfg3DEN
{
class Mission
{
class Preferences // Anything in this section will be displayed in Editor Preferences
{
class AttributeCategories
{
// ... Attribute categories
};
};
};
};
Presets
- CfgVehicles
- CfgNonAIVehicles
- CfgWaypoints
- CfgMarkers
class CfgNonAIVehicles
{
class MyTrigger
{
class AttributeValues
{
sizeA = 0; // Property name match the attribute name
sizeB = 0;
};
};
};
Conditions
Conditions are written as simple expressions. Example:
objectBrain * (1 - objectDestructable)
Object must be indestructible AI character (theoretical example, no such object exists in unmodded game).
Supported conditions:
Condition | For Type | Description |
---|---|---|
objectBrain | Object | Object with simulation "soldier" or "UAVpilot" |
objectControllable | Object | Object with simulation "soldier" |
objectAgent | Object | Object with non-empty agentTasks[], i.e., animals |
objectVehicle | Object | Vehicle which can be boarded |
objectSimulated | Object | Object which is simulated (e.g., falls down when in the air) |
objectDestructable | Object | Indestructible object, i.e., when destrType config property set not DestructNo |
logicModule | Logic | Logic which is a module (vehicleClass config property is "Modules") |