Game Master: Context Action Creation – Arma Reforger

From Bohemia Interactive Community
Jump to navigation Jump to search
m (cat)
m (Fix method names)
Line 7: Line 7:
== Script Creation ==
== Script Creation ==


To create a context action you will need to create a new class inheriting from [enfusion://ScriptEditor/scripts/Game/Editor/Containers/Actions/SCR_GeneralContextAction.c SCR_GeneralContextAction].
To create a context action you will need to create a new class inheriting from {{Link|enfusion://ScriptEditor/scripts/Game/Editor/Containers/Actions/SCR_GeneralContextAction.c|SCR_GeneralContextAction}}.


There are three main methods you will be using:
There are three main methods you will be using:
Line 35: Line 35:
! Description
! Description
|-
|-
| [enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/TempEdit.conf TempEdit.conf]
| {{Link|enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/TempEdit.conf|TempEdit.conf}}
| Edit mode config
| Edit mode config
|-
|-
| [enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/TempAdmin.conf TempAdmin.conf]
| {{Link|enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/TempAdmin.conf|TempAdmin.conf}}
| Admin mode config
| Admin mode config
|-
|-
| [enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/TempPhoto.conf TempPhoto.conf]
| {{Link|enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/TempPhoto.conf|TempPhoto.conf}}
| Photo mode config
| Photo mode config
|-
|-
| [enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/Shared.conf Shared.conf]
| {{Link|enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/Shared.conf|Shared.conf}}
| All modes config
| All modes config
|-
|-
| [enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/Tasks.conf Tasks.conf]
| {{Link|enfusion://ResourceManager/~ArmaReforger:Configs/Editor/ActionLists/Context/Tasks.conf|Tasks.conf}}
| Player tasks config
| Player tasks config
|}
|}
Line 77: Line 77:
The base class has some additional variables.
The base class has some additional variables.
{{Feature|informative|
{{Feature|informative|
More advanced classes, located in {{hl|Data\scripts\Game\Editor\Containers\Actions\ContextActions\}} (like [enfusion://ScriptEditor/scripts/Game/Editor/Containers/Actions/ContextActions/SCR_DoubleClickAction.c SCR_DoubleClickAction]) exist that may offer more options than the default ones listed here but these will not be covered.
More advanced classes, located in {{hl|Data\scripts\Game\Editor\Containers\Actions\ContextActions\}} (like {{Link|enfusion://ScriptEditor/scripts/Game/Editor/Containers/Actions/ContextActions/SCR_DoubleClickAction.c|SCR_DoubleClickAction}}) exist that may offer more options than the default ones listed here but these will not be covered.
}}
}}


Line 100: Line 100:
|-
|-
| Shortcut
| Shortcut
| Add an Input action name (defined in {{Link|enfusion://ResourceManager/~ArmaReforger:Configs/System/chimeraInputCommon.conf|chimeraInputCommon.conf}}, e.g {{hl|ManualCameraTeleportPlayer}}) if you want the action also to be executed via shortcut. Note that {{hl|CanPerform}} will still be checked.
| Add an Input action name (defined in {{Link|enfusion://ResourceManager/~ArmaReforger:Configs/System/chimeraInputCommon.conf|chimeraInputCommon.conf}}, e.g {{hl|ManualCameraTeleportPlayer}}) if you want the action also to be executed via shortcut. Note that <enforce inline>CanBePerformed()</enforce> will still be checked.
|-
|-
| Enable Shortcut Logics
| Enable Shortcut Logics
Line 115: Line 115:
|-
|-
| IsServer
| IsServer
| The action is performed on the server if this is true, otherwise it is performed locally. Note that {{hl|CanShow}} and {{hl|CanPerform}} are still checked locally.
| The action is performed on the server if this is true, otherwise it is performed locally. Note that <enforce inline>CanBeShown()</enforce> and <enforce inline>CanBePerformed()</enforce> are still checked locally.
|-
|-
| Hide On Hover
| Hide On Hover

Revision as of 16:57, 4 January 2023

Context actions are actions the Game Master can do by opening the context menu such as Cast lighting, Delete entity, etc. Context actions change depending on if the Game Master is focusing on an entity and on the type of entities. The following is a guide about how to create new context actions.


Script Creation

To create a context action you will need to create a new class inheriting from SCR_GeneralContextAction.

There are three main methods you will be using:

Method Description
CanBeShown() Whether or not the context action will be shown in the menu. Check here if the hovered/selected entities are the ones your action requires. The action cannot be performed (not even with the shortcut) if it is not shown.
CanBePerformed() Whether or not the action can be performed. The action will be shown but locked. By the time of writing only gamepad shows locked actions. This will also be checked for Shortcuts.
Perform() Here you actually execute the action. Write the code to perform the action here


Config Modding

Context actions are (generally) mode-specific so decide in which mode(s) the player can execute the action. Context actions configs are located in \Data\Configs\Editor\ActionLists\Context.

Config Description
TempEdit.conf Edit mode config
TempAdmin.conf Admin mode config
TempPhoto.conf Photo mode config
Shared.conf All modes config
Tasks.conf Player tasks config

Next, locate the config you want and press the + icon to add your own context action.

UI Info

Now that the action is added you will have to fill in the variables. We will start with the Info. Press the Set Class button and select SCR_UIInfo from the list.

This will get you the following UI Info variables to fill in:

Variable Description
Name Action's display name
Description Tooltip description when focusing on the action
Icon Action's icon

Additional Variables

The base class has some additional variables.

More advanced classes, located in Data\scripts\Game\Editor\Containers\Actions\ContextActions\ (like SCR_DoubleClickAction) exist that may offer more options than the default ones listed here but these will not be covered.
Variable Description
Enabled Simply if this config action is to be considered or not. Useful for debug/development purpose.
Info See UI Info above.
Action Type Purely visible and only used in tool bars. Keep on ACTION for context actions.
Action Group Makes sure actions are group together. Keep NONE for context actions.
Order This dictates the order of the action. The higher the number the higher the action is in the list. Actions with the same order are ordered the same as in the config array.
Shortcut Add an Input action name (defined in chimeraInputCommon.conf, e.g ManualCameraTeleportPlayer) if you want the action also to be executed via shortcut. Note that CanBePerformed() will still be checked.
Enable Shortcut Logics Will allow the "Shortcut" to work if true. You might want to execute the shortcut action from a different location. So "Shortcut" is purely informative.
Effects Array of effects when the action is performed such as sound, particle, UI effects.
Cooldown Time Cooldown to prevent spamming of action. Leave zero or less to ignore, duration is in seconds.
Show On Cooldown Notification If true will show notification if trying to perform the action if the cooldown is active.
IsServer The action is performed on the server if this is true, otherwise it is performed locally. Note that CanBeShown() and CanBePerformed() are still checked locally.
Hide On Hover The action is hidden when the cursor is hovering above an entity.
Hide On Selected The action is hidden if any entity is selected.
It is possible to make shortcut-only context actions (that do not show up in the context menu) by not filling in the UIInfo but still filling in the Shortcut and having Enable Shortcut Logics ticked.