Scripting & API¶
Mission makers and modders can react to the actions, prevent a tent from being packed up, add their own tents, and use the shared functions.
Events¶
Every action raises a CBA event once what it does is complete. They are raised with CBA_fnc_globalEvent, so they run on every machine, use isServer or hasInterface in the handler as needed. They are not raised when an object is changed with scripts (animateSource, ...) or in the editor.
The animation and antenna events are raised from the machine where the object is local, once the animation has got there: avo_animations_changed when every source has reached its phase, avo_antennas_activated as soon as the terminal or mast starts to open (it is active from then on), avo_antennas_deactivated once it is closed again (up to 15 seconds for a Rugged terminal). A change that is interrupted by another one raises nothing, the other one raises its own event. avo_antennas_activated and avo_antennas_deactivated are only raised when the state really changes.
| Event | Payload | Raised when |
|---|---|---|
avo_animations_changed |
[object, control, changes, unit] |
An animation action is used, see below |
avo_antennas_activated |
[terminal, unit] |
A Rugged terminal is activated, or an antenna mast extended |
avo_antennas_deactivated |
[terminal, unit] |
A Rugged terminal is deactivated, or an antenna mast retracted, once it is closed |
avo_antennas_connected |
[antenna, radioId, unit] |
A radio is connected to one of the antennas or terminals (needs avo_antennas_acre) |
avo_antennas_disconnected |
[antenna, unit, radioId] |
A radio is disconnected from one of them. radioId is "" when ACRE does not tell it |
avo_tents_setUp |
[tent, unit, item] |
A tent is set up from a tent item |
avo_tents_packedUp |
[classname, posASL, [vectorDir, vectorUp], unit, item] |
A tent is packed up. The tent is deleted by then, its class and place are given instead |
avo_tents_inventoryOpened |
[tent, unit] |
The inventory of a tent is opened |
avo_weather_read |
[object, unit, windOnly] |
Weather data is read at a weather station, or the wind at a windsock (windOnly is true) |
avo_antennas_connected and avo_antennas_disconnected are raised by avo_antennas_acre, relayed from ACRE's ground spike antenna events (acre_sys_gsa_connectGsa and acre_sys_gsa_disconnectGsa), only for the antennas of AVO; they are not raised at all without that addon. With TFAR (optional addon avo_antennas_tfar), avo_antennas_activated/avo_antennas_deactivated (raised by the comms-agnostic avo_antennas) are what register or remove the TFAR radio tower instead; TFAR has no per-radio connection to relay.
There are no "before" events, actions cannot be cancelled.
["avo_tents_setUp", {
params ["_tent", "_unit", "_item"];
if (isServer) then {
systemChat format ["%1 set up %2", name _unit, typeOf _tent];
};
}] call CBA_fnc_addEventHandler;
avo_animations_changed¶
control is the id of the control that was used, changes are the animation sources and the phases they were set to, [["Door_1_Hide", 1]].
| Objects | Controls |
|---|---|
| Cabinets, office table | drawer1 to drawer6 |
| Coffin (drawer) | drawer |
| Wooden coffin, decon and connector tents | door1 to door4 |
| Medical tent, fridge | door |
| Laptop, CBRN container, bucket | lid |
| Multi-screen computer | screens |
| Portable server | rack (server rack), leds (LED lights) |
| Solar panels | yaw, pitch1, pitch2. The phase is the angle in degrees |
| Transfer switch | position1, position0, position2, lamp |
| Data terminal | antenna |
| Flag pole | flag |
["avo_animations_changed", {
params ["_object", "_control", "_changes", "_unit"];
if (isServer && {_control == "flag"}) then {
systemChat format ["%1 moved the flag on %2", name _unit, typeOf _object];
};
}] call CBA_fnc_addEventHandler;
Variables¶
| Variable | Object | Description |
|---|---|---|
avo_tents_canPackUp |
Placed tent | Set to false to prevent packing up this tent. Default true |
avo_tents_container |
Placed tent | The invisible container that is the inventory of the tent, objNull until the inventory has been opened for the first time. Read only, a tent cannot be packed up while it has items in it |
The container is not deleted with the tent when a script or Zeus deletes it, only when the tent is packed up. Delete it as well:
Adding tents¶
The tents addon scans CfgWeapons for classes with an avo_tents_object property, so another addon only needs a config item to add a tent. It is set up with the 3D placement and packed up again like the tents of AVO. Derive it from avo_tents_base:
class CfgWeapons {
class avo_tents_base;
class MYTAG_myTent: avo_tents_base {
scope = 2;
displayName = "My Tent";
avo_tents_object = "MyTentObjectClass";
};
};
The addon has to require avo_tents. The item is only used when the object class exists.
Functions¶
The avo_common addon has functions for other addons that add actions to objects.
avo_common_fnc_addClassActions¶
Adds an ACE interaction to a class and every class derived from it. Does the same as ace_interact_menu_fnc_addActionToClass with inheritance, but adds the action to each class by name. ACE's inheritance only reaches objects that run CBA's extended event handlers, and classes that define their own EventHandlers class do not, so they never get the action. Call it in postInit.
| Argument | Type | Description |
|---|---|---|
| 0 | STRING |
Base class in CfgVehicles |
| 1 | ARRAY |
Parent path of the action, [] for the top level |
| 2 | ARRAY |
Action from ace_interact_menu_fnc_createAction |
| 3 | ARRAY of STRING |
Classes that are left out, with everything derived from them (default []) |
Returns nothing.
Local: the action is only added on the machine that calls it, like ace_interact_menu_fnc_addActionToClass. Call it on every machine with an interface (hasInterface) in postInit, once per action.
private _action = ["MYTAG_hello", "Say Hello", "", {systemChat "Hello"}, {true}] call ace_interact_menu_fnc_createAction;
["Land_Fridge_01_F", [], _action] call avo_common_fnc_addClassActions;
avo_common_fnc_interactionPosition¶
The point for an ACE interaction on an object, for the position code of ace_interact_menu_fnc_createAction. It depends on the size of the object, see Where the action is.
| Argument | Type | Description |
|---|---|---|
| 0 | OBJECT |
Object |
| 1 | ARRAY of STRING |
Names of selections or memory points where the change happens, the first one the model has is used, for big objects (default []) |
Returns the position in model space of the object.
Local: runs on any machine, but for big objects without one of the selections the point depends on the local player (ACE_player), so it is meant for the position code of an action. It runs every frame while the action is in range, the result of the selection lookup is kept for each class.
{[_target] call avo_common_fnc_interactionPosition}
{[_target, ["Door_1"]] call avo_common_fnc_interactionPosition}
avo_common_fnc_topPosition¶
The position of the top centre of an object's bounding box, in ASL. Follows the object's orientation.
| Argument | Type | Description |
|---|---|---|
| 0 | OBJECT |
Object |
| 1 | NUMBER |
Offset above the top, in model space (default 0) |
Returns the position in ASL.
Local: runs on any machine, the result is the same everywhere.
Config¶
| Property | Class | Description |
|---|---|---|
avo_antennas_activeSources[] |
CfgVehicles |
Animation sources that switch an antenna object on, used by the Rugged communications terminals and the antenna masts of the GM shelters. The first one marks the state and has to be above 0 |
avo_antennas_activePhase |
CfgVehicles |
Phase the active sources go to when the antenna is switched on (default 100) |
avo_antennas_requiredSources[] |
CfgVehicles |
Animation sources that show the antenna of an object where it is an option. The object has no antenna actions while one of them is 0 |
AcreComponents |
CfgVehicles |
ACRE ground spike antenna component, set by avo_antennas_acre/avo_antennas_gm_acre together with acre_antennaPosFnc |
avo_tents_object |
CfgWeapons |
Tent object class an item sets up, see Adding tents |