ACE3/addons/csw/functions/fnc_reload_actionsLoad.sqf
GhostIsSpooky a4ae61f1fc
CSW - Add reloading from nearSupplies (#8776)
* allow players to reload from nearSupplies

* limit reloading to friendly sides

* add handling for ai getting inside empty weapon

* configOf for lookup

* add getin handler, hammer out remaining bugs

* configOf lookup

* improve friendly/object filter

* more configOf lookups

* Capitalize settings, add ammo storage setting

* remove systemChat

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* fix TRACE

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2022-03-07 12:29:19 -06:00

58 lines
1.7 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: PabstMirror
* Gets sub actions for what the player can load into the static weapon
*
* Arguments:
* 0: Static Weapon <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* Actions <ARRAY>
*
* Example:
* [cursorObject, player] call ace_csw_fnc_reload_actionsLoad
*
* Public: No
*/
params ["_vehicle", "_player"];
private _actions = [];
private _loadableMagazines = [_vehicle, _player] call FUNC(reload_getLoadableMagazines);
private _statement = {
params ["_target", "_player", "_params"];
_params params ["_carryMag", "_turretPath", "", "_magSource"];
[_target, _turretPath, _carryMag, _magSource, _player] call FUNC(reload_loadMagazine);
};
private _condition = {
params ["_target", "_player", "_params"];
_params params ["_carryMag", "_turretPath", "", "_magSource"];
([_target, _turretPath, _carryMag, _magSource] call FUNC(reload_canLoadMagazine)) select 0
};
private _cfgMagazines = configFile >> "CfgMagazines"; // micro-optimization
{
_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 [localize LSTRING(actionLink), _displayName];
} else {
format [localize LSTRING(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