-
Notifications
You must be signed in to change notification settings - Fork 749
Expand file tree
/
Copy pathfnc_getLoadActions.sqf
More file actions
58 lines (48 loc) · 1.78 KB
/
fnc_getLoadActions.sqf
File metadata and controls
58 lines (48 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Gets sub actions for what the player can load into the CSW.
*
* Arguments:
* 0: CSW <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Actions <ARRAY>
*
* Example:
* [cursorObject, player] call ace_csw_fnc_getLoadActions
*
* Public: No
*/
params ["_vehicle", "_unit"];
private _loadableMagazines = [_vehicle, _unit] call FUNC(reload_getLoadableMagazines);
if (_loadableMagazines isEqualTo []) exitWith {[]};
private _statement = {
params ["_target", "_player", "_args"];
_args params ["_carryMag", "_turretPath", "", "_magSource"];
[_target, _turretPath, _carryMag, _magSource, _player] call FUNC(reload_loadMagazine);
};
private _condition = {
params ["_target", "_player", "_args"];
_args params ["_carryMag", "_turretPath", "", "_magSource"];
[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew) &&
{([_target, _turretPath, _carryMag, _magSource] call FUNC(reload_canLoadMagazine)) select 0}
};
private _cfgMagazines = configFile >> "CfgMagazines"; // Micro-optimization
private _actions = [];
{
_x params ["_carryMag", "", "_loadInfo"];
_loadInfo params ["", "", "", "_isBeltLinking"];
private _displayName = getText (_cfgMagazines >> _carryMag >> "displayName");
private _picture = getText (_cfgMagazines >> _carryMag >> "picture");
private _text = if (_isBeltLinking) then {
format [LLSTRING(actionLink), _displayName];
} else {
format [LLSTRING(loadX), _displayName];
};
private _action = [format ["load_%1", _forEachIndex], _text, _picture, _statement, _condition, {}, _x] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _vehicle];
} forEach _loadableMagazines;
TRACE_1("loadActions",count _actions);
_actions