2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-03-18 19:17:53 +00:00
|
|
|
/*
|
2023-08-28 18:14:45 +00:00
|
|
|
* Author: commy2, johnb43
|
2023-08-28 20:20:53 +00:00
|
|
|
* 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:
|
2023-08-28 20:20:53 +00:00
|
|
|
* 0: Unit wanting to execute the reload <OBJECT>
|
2023-08-28 17:27:01 +00:00
|
|
|
* 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:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2023-08-28 17:27:01 +00:00
|
|
|
* [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
|
|
|
|
2023-08-28 17:27:01 +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};
|
2017-08-22 18:30:56 +00:00
|
|
|
if !([_unit, _target, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
2015-03-18 19:17:53 +00:00
|
|
|
|
2023-08-28 18:14:45 +00:00
|
|
|
// Target must not be captive
|
|
|
|
if (_target getVariable [QEGVAR(captives,isHandcuffed), false] || {_target getVariable [QEGVAR(captives,isSurrendering), false]}) exitWith {false};
|
|
|
|
|
2023-08-28 17:27:01 +00:00
|
|
|
// Check if the launcher is compatible
|
|
|
|
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false};
|
2015-03-18 19:17:53 +00:00
|
|
|
|
2023-08-28 17:27:01 +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
|
|
|
|
2023-08-28 17:27:01 +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
|
|
|
|
2023-08-28 17:27:01 +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))
|