ACE3/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf

54 lines
1.3 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
2015-03-22 13:05:31 +00:00
/*
* Author: commy2
* Create one action per reloadable missile
*
2016-06-18 09:50:41 +00:00
* Arguments:
* 1: Target <OBJECT>
* 0: Player <OBJECT>
2015-03-22 13:05:31 +00:00
*
2016-06-18 09:50:41 +00:00
* Return Value:
* Children actions <ARRAY>
*
* Example:
* [bob, kevin] call ace_reloadlaunchers_fnc_addMissileReloadActions
2015-03-22 13:05:31 +00:00
*
2016-04-28 03:58:47 +00:00
* Public: No
*
2015-03-22 13:05:31 +00:00
*/
2016-04-28 03:58:47 +00:00
params ["_target", "_unit"];
TRACE_2("params",_target,_unit);
2015-03-22 13:05:31 +00:00
2016-04-28 03:58:47 +00:00
//Fast exit for common case:
private _weapon = secondaryWeapon _target;
if ((_weapon == "") || {(getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled))) == 0}) exitWith {
TRACE_1("weapon not supported",_weapon);
[]
};
2015-03-22 13:05:31 +00:00
2016-04-28 03:58:47 +00:00
private _actions = [];
2015-03-22 13:05:31 +00:00
2016-04-28 03:58:47 +00:00
private _loadableMissiles = [_unit, _weapon] call FUNC(getLoadableMissiles);
TRACE_2("",_weapon,_loadableMissiles);
2015-03-22 13:05:31 +00:00
{
private _name = format [QGVAR(Missile_%1), _x];
private _displayName = format [localize LSTRING(LoadMagazine), getText (configFile >> "CfgMagazines" >> _x >> "displayName")];
2015-03-22 13:05:31 +00:00
private _statement = {
2015-03-22 13:05:31 +00:00
(_this select 2) call DFUNC(load);
};
private _condition = {
2015-03-22 13:05:31 +00:00
(_this select 2) call DFUNC(canLoad)
};
private _action = [_name, _displayName, "", _statement, _condition, {}, [_unit, _target, _weapon, _x], "", 4] call EFUNC(interact_menu,createAction);
2015-03-22 13:05:31 +00:00
_actions pushBack [_action, [], _unit];
} forEach _loadableMissiles;
2016-04-28 03:58:47 +00:00
TRACE_1("return",_actions);
2015-03-22 13:05:31 +00:00
_actions