ACE3/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf

53 lines
1.3 KiB
Plaintext
Raw Normal View History

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:
2016-04-28 03:58:47 +00:00
* 1: Target (Object)
* 0: Player (Object)
2015-03-22 13:05:31 +00:00
*
2016-06-18 09:50:41 +00:00
* Return Value:
2015-03-22 13:05:31 +00:00
* Children actions (Array)
*
2016-04-28 03:58:47 +00:00
* Public: No
*
2015-03-22 13:05:31 +00:00
*/
#include "script_component.hpp"
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", "_displayName", "_statement", "_condition", "_action"];
_name = format [QGVAR(Missile_%1), _x];
2015-05-28 19:59:04 +00:00
_displayName = format [localize LSTRING(LoadMagazine), getText (configFile >> "CfgMagazines" >> _x >> "displayName")];
2015-03-22 13:05:31 +00:00
_statement = {
(_this select 2) call DFUNC(load);
};
_condition = {
(_this select 2) call DFUNC(canLoad)
};
_action = [_name, _displayName, "", _statement, _condition, {}, [_unit, _target, _weapon, _x], "", 4] call EFUNC(interact_menu,createAction);
_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