ACE3/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf

57 lines
1.4 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.
2015-03-22 13:05:31 +00:00
*
2016-06-18 09:50:41 +00:00
* Arguments:
* 0: Unit equipped with the launcher <OBJECT>
* 1: Unit wanting to execute the reload <OBJECT>
2015-03-22 13:05:31 +00:00
*
2016-06-18 09:50:41 +00:00
* Return Value:
* Children actions <ARRAY>
*
* Example:
* [cursorTarget, player] 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
// Fast exit for common cases
2016-04-28 03:58:47 +00:00
private _weapon = secondaryWeapon _target;
2016-04-28 03:58:47 +00:00
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 _cfgMagazines = configFile >> "CfgMagazines";
2015-03-22 13:05:31 +00:00
{
private _name = format [QGVAR(Missile_%1), _x];
private _displayName = format [LLSTRING(LoadMagazine), getText (_cfgMagazines >> _x >> "displayName")];
2015-03-22 13:05:31 +00:00
private _statement = {
(_this select 2) call FUNC(load);
2015-03-22 13:05:31 +00:00
};
private _condition = {
(_this select 2) call FUNC(canLoad)
2015-03-22 13:05:31 +00:00
};
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