From 5d68969b639d8510675681c5911147a97201e301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 6 Mar 2015 01:34:38 -0300 Subject: [PATCH] Added action for checking ammo on others MG's belts and on Static Weapons --- addons/reload/CfgVehicles.hpp | 20 +++++++++++ addons/reload/XEH_preInit.sqf | 1 + addons/reload/functions/fnc_canCheckAmmo.sqf | 35 +++++++++++++++++++ .../reload/functions/fnc_startLinkingBelt.sqf | 1 + 4 files changed, 57 insertions(+) create mode 100644 addons/reload/functions/fnc_canCheckAmmo.sqf diff --git a/addons/reload/CfgVehicles.hpp b/addons/reload/CfgVehicles.hpp index 8b7a287097..84333a1a09 100644 --- a/addons/reload/CfgVehicles.hpp +++ b/addons/reload/CfgVehicles.hpp @@ -9,6 +9,26 @@ class CfgVehicles { condition = QUOTE([ARR_2(_player, _target)] call FUNC(canLinkBelt)); statement = QUOTE([ARR_2(_player, _target)] call FUNC(startLinkingBelt)); }; + class ACE_CheckAmmo { + displayName = "$STR_ACE_Reload_checkAmmo"; + distance = 2.0; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo)); + statement = QUOTE([ARR_2(_player, _target)] call FUNC(checkAmmo)); + }; + }; + }; + }; + + class LandVehicle; + class StaticWeapon: LandVehicle { + class ACE_Actions { + class ACE_MainActions { + class ACE_CheckAmmo { + displayName = "$STR_ACE_Reload_checkAmmo"; + distance = 2.0; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo)); + statement = QUOTE([ARR_2(_player, _target)] call FUNC(checkAmmo)); + }; }; }; }; diff --git a/addons/reload/XEH_preInit.sqf b/addons/reload/XEH_preInit.sqf index 7f22161a77..278abf7bd2 100644 --- a/addons/reload/XEH_preInit.sqf +++ b/addons/reload/XEH_preInit.sqf @@ -2,6 +2,7 @@ ADDON = false; +PREP(canCheckAmmo); PREP(canLinkBelt); PREP(checkAmmo); PREP(displayAmmo); diff --git a/addons/reload/functions/fnc_canCheckAmmo.sqf b/addons/reload/functions/fnc_canCheckAmmo.sqf new file mode 100644 index 0000000000..3e83281b43 --- /dev/null +++ b/addons/reload/functions/fnc_canCheckAmmo.sqf @@ -0,0 +1,35 @@ +/* + * Author: CAA-Picard + * Check if the player can check the ammo of the target. + * + * Argument: + * 0: Player + * 1: Target + * + * Return value: + * Can link belt + */ +#include "script_component.hpp" + +EXPLODE_2_PVT(_this,_player,_target); + +// Return true for static weapons if they have been fired once +if (_target isKindOf "StaticWeapon") exitWith { + (currentMagazine _target) != "" +}; + +// Return false for all other vehicles +if !(_target isKindOf "CAManBase") exitWith {false}; + +// For men +if (currentWeapon _target == "") exitWith {false}; + +// Check if their current magazine is a belt +_magazineType = currentMagazine _target; +_magazineCfg = configFile >> "CfgMagazines" >> _magazineType; +if (getNumber (_magazineCfg >> "ACE_isBelt") == 1) exitWith {true}; + +// Check for rocket launchers +if (currentWeapon _target == secondaryWeapon _target) exitWith {true}; + +false diff --git a/addons/reload/functions/fnc_startLinkingBelt.sqf b/addons/reload/functions/fnc_startLinkingBelt.sqf index 142f38b7b5..3b35a5a72a 100644 --- a/addons/reload/functions/fnc_startLinkingBelt.sqf +++ b/addons/reload/functions/fnc_startLinkingBelt.sqf @@ -38,6 +38,7 @@ _maxAmmo = 0; if (_maxAmmo == 0) exitWith {}; + // Condition to call each frame _condition = { EXPLODE_2_PVT((_this select 0),_player,_target);