2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-03-03 02:29:57 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: esteldunedain
|
2015-03-03 02:29:57 +00:00
|
|
|
* Collect a entire tree of active actions
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-03-03 02:29:57 +00:00
|
|
|
* 0: Object <OBJECT>
|
|
|
|
* 1: Original action tree <ARRAY>
|
2015-03-20 02:32:44 +00:00
|
|
|
* 2: Parent path <ARRAY>
|
2016-01-08 04:43:37 +00:00
|
|
|
* 3: Distance to base point (will be 0 for self/zeus/in-vehicle) <NUMBER>
|
2015-03-03 02:29:57 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-03-03 02:29:57 +00:00
|
|
|
* Active children <ARRAY>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
2021-02-04 17:01:35 +00:00
|
|
|
* [bob, [array], [array], 5] call ACE_interact_menu_fnc_collectActiveActionTree
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
2015-03-03 02:29:57 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
params ["_object", "_origAction", "_parentPath", "_distanceToBasePoint"];
|
2015-08-04 22:46:57 +00:00
|
|
|
_origAction params ["_origActionData", "_origActionChildren"];
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _target = _object;
|
|
|
|
private _player = ACE_player;
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-04-17 02:53:54 +00:00
|
|
|
// Check if the function should be modified first
|
2021-02-27 17:05:05 +00:00
|
|
|
if ((_origActionData select 10) isNotEqualTo {}) then {
|
2015-04-17 02:53:54 +00:00
|
|
|
// It should, so make a copy and pass it to the modifierFunction
|
|
|
|
_origActionData = +_origActionData;
|
|
|
|
[_target, ACE_player, _origActionData select 6, _origActionData] call (_origActionData select 10);
|
|
|
|
};
|
|
|
|
|
2021-02-04 17:01:35 +00:00
|
|
|
_origActionData params [
|
|
|
|
"_actionName",
|
|
|
|
"_displayName",
|
|
|
|
"",
|
|
|
|
"_statementCode",
|
|
|
|
"_conditionCode",
|
|
|
|
"_insertChildrenCode",
|
|
|
|
"_customParams",
|
|
|
|
"_position",
|
|
|
|
"_distance"
|
|
|
|
];
|
2016-01-08 04:43:37 +00:00
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
// Return nothing if the action itself is not active
|
2016-01-08 04:43:37 +00:00
|
|
|
if !([_target, ACE_player, _customParams] call _conditionCode) exitWith {
|
2015-03-03 02:29:57 +00:00
|
|
|
[]
|
|
|
|
};
|
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
// Return nothing if the action is to far (including checking sub actions) [DISABLED FOR NOW ref #2196]
|
|
|
|
// if (_distanceToBasePoint > _distance) exitWith {
|
|
|
|
// []
|
|
|
|
// };
|
|
|
|
|
|
|
|
private _fullPath = +_parentPath;
|
|
|
|
_fullPath pushBack _actionName;
|
|
|
|
private _activeChildren = [];
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-03-19 16:00:10 +00:00
|
|
|
// If there's a statement to dynamically insert children then execute it
|
2021-02-27 17:05:05 +00:00
|
|
|
if (_insertChildrenCode isNotEqualTo {}) then {
|
2016-01-08 04:43:37 +00:00
|
|
|
private _dynamicChildren = [_target, ACE_player, _customParams] call _insertChildrenCode;
|
2015-03-19 16:00:10 +00:00
|
|
|
|
2015-03-21 01:44:25 +00:00
|
|
|
// Collect dynamic children class actions
|
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
private _action = [_x select 2, _x, _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree);
|
2015-03-21 01:44:25 +00:00
|
|
|
if ((count _action) > 0) then {
|
|
|
|
_activeChildren pushBack _action;
|
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count _dynamicChildren;
|
2015-03-21 01:44:25 +00:00
|
|
|
};
|
2015-03-20 02:32:44 +00:00
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
// Collect children class actions
|
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
private _action = [_object, _x, _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree);
|
2015-03-03 02:29:57 +00:00
|
|
|
if ((count _action) > 0) then {
|
|
|
|
_activeChildren pushBack _action;
|
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count _origActionChildren;
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
// Collect children object actions
|
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
_x params ["_actionData", "_pPath"];
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
// Check if the action is children of the original action
|
2016-01-08 04:43:37 +00:00
|
|
|
if (_pPath isEqualTo _fullPath) then {
|
|
|
|
private _action = [_object, [_actionData,[]], _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree);
|
2015-03-20 02:32:44 +00:00
|
|
|
if ((count _action) > 0) then {
|
|
|
|
_activeChildren pushBack _action;
|
2015-03-03 02:29:57 +00:00
|
|
|
};
|
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count GVAR(objectActionList);
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
// If the original action has no statement, and no children, don't display it
|
2016-01-08 04:43:37 +00:00
|
|
|
if ((_activeChildren isEqualTo []) && {_statementCode isEqualTo {}}) exitWith {
|
2015-03-03 02:29:57 +00:00
|
|
|
// @todo: Account for showDisabled?
|
|
|
|
[]
|
|
|
|
};
|
2015-03-19 17:45:05 +00:00
|
|
|
|
2021-02-04 17:01:35 +00:00
|
|
|
if (GVAR(consolidateSingleChild) && {count _activeChildren == 1} && {_statementCode isEqualTo {}}) then {
|
|
|
|
_activeChildren select 0 params ["_childActionData", "_childChildren", "_childObject"];
|
|
|
|
_childActionData params ["", "_displayNameChild", "_iconChild", "_statementChild", "", "", "_customParamsChild", "", "", "_paramsChild"];
|
|
|
|
_origActionData = [
|
|
|
|
_actionName,
|
|
|
|
format ["%1 > %2", _displayName, _displayNameChild],
|
|
|
|
_iconChild,
|
|
|
|
_statementChild,
|
|
|
|
_conditionCode,
|
|
|
|
_insertChildrenCode,
|
|
|
|
_customParamsChild,
|
|
|
|
_position,
|
|
|
|
_distance,
|
|
|
|
_paramsChild
|
|
|
|
];
|
|
|
|
_activeChildren = _childChildren;
|
|
|
|
_object = _childObject;
|
|
|
|
};
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-03-17 03:37:28 +00:00
|
|
|
[_origActionData, _activeChildren, _object]
|