From bf7fde0d658b7b85afb0f109720675c0f4f22f44 Mon Sep 17 00:00:00 2001 From: commy2 Date: Thu, 7 Jul 2016 09:44:29 +0200 Subject: [PATCH] enable gunbag for all non-machinegun primary weapons --- addons/gunbag/CfgWeapons.hpp | 41 -------------------- addons/gunbag/XEH_PREP.hpp | 1 + addons/gunbag/config.cpp | 1 - addons/gunbag/functions/fnc_canInteract.sqf | 5 ++- addons/gunbag/functions/fnc_isMachineGun.sqf | 29 ++++++++++++++ 5 files changed, 33 insertions(+), 44 deletions(-) delete mode 100644 addons/gunbag/CfgWeapons.hpp create mode 100644 addons/gunbag/functions/fnc_isMachineGun.sqf diff --git a/addons/gunbag/CfgWeapons.hpp b/addons/gunbag/CfgWeapons.hpp deleted file mode 100644 index 31ffb64c79..0000000000 --- a/addons/gunbag/CfgWeapons.hpp +++ /dev/null @@ -1,41 +0,0 @@ -class CfgWeapons { - class Rifle_Long_Base_F; - - /* Long Rifles */ - - class GM6_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; - - class LRR_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; - - class DMR_06_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; - - class DMR_05_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; - - class DMR_04_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; - - class DMR_03_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; - - class DMR_02_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; - - class DMR_01_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; - - class EBR_base_F: Rifle_Long_Base_F { - GVAR(allowGunbag) = 1; - }; -}; diff --git a/addons/gunbag/XEH_PREP.hpp b/addons/gunbag/XEH_PREP.hpp index df84b594bf..d76682f986 100644 --- a/addons/gunbag/XEH_PREP.hpp +++ b/addons/gunbag/XEH_PREP.hpp @@ -7,3 +7,4 @@ PREP(status); PREP(canInteract); PREP(calculateMass); PREP(hasGunbag); +PREP(isMachineGun); diff --git a/addons/gunbag/config.cpp b/addons/gunbag/config.cpp index 87fcd84f1c..6efaceb5d6 100644 --- a/addons/gunbag/config.cpp +++ b/addons/gunbag/config.cpp @@ -16,4 +16,3 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -#include "CfgWeapons.hpp" diff --git a/addons/gunbag/functions/fnc_canInteract.sqf b/addons/gunbag/functions/fnc_canInteract.sqf index b24533f632..1ec9e38583 100644 --- a/addons/gunbag/functions/fnc_canInteract.sqf +++ b/addons/gunbag/functions/fnc_canInteract.sqf @@ -20,12 +20,13 @@ params ["_unit", "_target"]; private _result = -1; private _gunbag = backpackContainer _target; +private _weapon = primaryWeapon _unit; -if ((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo [] && {primaryWeapon _unit != ""} && {getNumber (configFile >> "CfgWeapons" >> primaryWeapon _unit >> QGVAR(allowGunbag)) == 1}) then { +if ((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo [] && {_weapon != ""} && {!(_weapon call FUNC(isMachineGun))}) then { _result = 0; }; -if (!((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo []) && {primaryWeapon _unit == ""}) then { +if (!((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo []) && {_weapon == ""}) then { _result = 1; }; diff --git a/addons/gunbag/functions/fnc_isMachineGun.sqf b/addons/gunbag/functions/fnc_isMachineGun.sqf new file mode 100644 index 0000000000..a6191c1cca --- /dev/null +++ b/addons/gunbag/functions/fnc_isMachineGun.sqf @@ -0,0 +1,29 @@ +/* + * Author: commy2 + * Reports true if a weapon is a machine gun. + * + * Arguments: + * 0: Weapon class name + * + * Return Value: + * Is machine gun + * + * Example: + * (currentWeapon player) call ace_gunbag_fnc_isMachineGun + * + * Public: No + */ +#include "script_component.hpp" + +params ["_weapon"]; + +private _config = _weapon call CBA_fnc_getItemConfig; + +// definition of a machine gun by BIS_fnc_itemType +private _cursor = getText (_config >> "cursor"); + +if (toLower _cursor in ["", "emptycursor"]) then { + _cursor = getText (_config >> "cursorAim"); +}; + +_cursor == "MG"