ACE3/addons/reloadlaunchers/functions/fnc_canLoad.sqf

45 lines
1.5 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-03-18 19:17:53 +00:00
/*
* Author: commy2, johnb43
* Check if the unit can reload the launcher of the target unit.
2015-03-18 19:17:53 +00:00
*
2016-06-18 09:50:41 +00:00
* Arguments:
* 0: Unit wanting to execute the reload <OBJECT>
* 1: Unit equipped with the launcher <OBJECT>
* 2: Launcher name <STRING>
* 3: Missile name <STRING>
2015-03-18 19:17:53 +00:00
*
2016-06-18 09:50:41 +00:00
* Return Value:
* None
*
* Example:
* [player, cursorTarget, "launch_RPG32_F", "RPG32_F"] call ace_reloadlaunchers_fnc_canLoad
2016-04-28 03:58:47 +00:00
*
* Public: No
2015-03-18 19:17:53 +00:00
*/
2016-04-28 03:58:47 +00:00
params ["_unit", "_target", "_weapon", "_magazine"];
TRACE_4("params",_unit,_target,_weapon,_magazine);
2015-03-18 19:17:53 +00:00
// Target must be awake
if !(_target call EFUNC(common,isAwake)) exitWith {false};
// Target must not be in a vehicle
if !(isNull objectParent _target) exitWith {false};
if !([_unit, _target, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
2015-03-18 19:17:53 +00:00
// Target must not be captive
if (_target getVariable [QEGVAR(captives,isHandcuffed), false] || {_target getVariable [QEGVAR(captives,isSurrendering), false]}) exitWith {false};
// Check if the launcher is compatible
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false};
2015-03-18 19:17:53 +00:00
// Check if target has its secondary weapon equipped
2015-03-22 13:05:31 +00:00
if !(_weapon in weapons _target) exitWith {false};
2015-03-18 19:17:53 +00:00
// Check if the target's launcher's primary muzzle really needs to be reloaded
if (_target ammo _weapon != 0) exitWith {false};
2015-03-18 19:17:53 +00:00
// Check if the magazine is compatible with target's launcher
2015-03-22 13:05:31 +00:00
_magazine in ([_unit, _weapon] call FUNC(getLoadableMissiles))