From a3367076238b6bf8142c08370a5918363da0aa62 Mon Sep 17 00:00:00 2001 From: VKing Date: Sat, 19 Dec 2015 16:30:01 +0100 Subject: [PATCH] Fixed initialization, added exclude variable to prevent initialization of individual guns (for e.g. AI mortars) --- addons/mk6mortar/XEH_initPost.sqf | 11 ++++++++--- addons/mk6mortar/cfgMagazines.hpp | 5 +++++ addons/mk6mortar/functions/fnc_handleFired.sqf | 11 +++++++++-- addons/mk6mortar/functions/fnc_mortarInit.sqf | 5 ++--- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/addons/mk6mortar/XEH_initPost.sqf b/addons/mk6mortar/XEH_initPost.sqf index 4f6fd7b44d..e1430ed7cc 100644 --- a/addons/mk6mortar/XEH_initPost.sqf +++ b/addons/mk6mortar/XEH_initPost.sqf @@ -1,5 +1,10 @@ #include "script_component.hpp" -// if (GVAR(useAmmoHandling)) then { - _this call FUNC(mortarInit); -// }; +if (!EGVAR(common,settingsInitFinished)) exitWith { + EGVAR(common,runAtSettingsInitialized) pushBack [{ + if (GVAR(useAmmoHandling)) then { + _this call FUNC(mortarInit) + }; + }, _this]; +}; +_this call FUNC(mortarInit); diff --git a/addons/mk6mortar/cfgMagazines.hpp b/addons/mk6mortar/cfgMagazines.hpp index 08a06e7d3c..7cda00a1c2 100644 --- a/addons/mk6mortar/cfgMagazines.hpp +++ b/addons/mk6mortar/cfgMagazines.hpp @@ -6,6 +6,7 @@ class cfgMagazines { scopeCurator = 2; author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_HE_displayName); + displayNameShort = ""; descriptionShort = CSTRING(magazine_HE_descriptionShort); model = PATHTOF(data\l16_ammo_he.p3d) picture = PATHTOF(UI\w_l16_ammo_he_ca.paa); @@ -18,6 +19,7 @@ class cfgMagazines { scopeCurator = 2; author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_Smoke_displayName); + displayNameShort = ""; descriptionShort = CSTRING(magazine_Smoke_descriptionShort); model = PATHTOF(data\l16_ammo_smk_white.p3d) picture = PATHTOF(UI\w_l16_ammo_smk_white_ca.paa); @@ -30,6 +32,7 @@ class cfgMagazines { scopeCurator = 2; author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_Illum_displayName); + displayNameShort = ""; descriptionShort = CSTRING(magazine_Illum_descriptionShort); model = PATHTOF(data\l16_ammo_illum.p3d) picture = PATHTOF(UI\w_l16_ammo_illum_ca.paa); @@ -42,6 +45,7 @@ class cfgMagazines { scopeCurator = 2; author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_HE_Guided_displayName); + displayNameShort = ""; descriptionShort = CSTRING(magazine_HE_Guided_descriptionShort); model = PATHTOF(data\l16_ammo_he.p3d) picture = PATHTOF(UI\w_l16_ammo_he_ca.paa); @@ -54,6 +58,7 @@ class cfgMagazines { scopeCurator = 2; author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_HE_LaserGuided_displayName); + displayNameShort = ""; descriptionShort = CSTRING(magazine_HE_LaserGuided_descriptionShort); model = PATHTOF(data\l16_ammo_he.p3d) picture = PATHTOF(UI\w_l16_ammo_he_ca.paa); diff --git a/addons/mk6mortar/functions/fnc_handleFired.sqf b/addons/mk6mortar/functions/fnc_handleFired.sqf index d22b0efa47..b212b04fc6 100644 --- a/addons/mk6mortar/functions/fnc_handleFired.sqf +++ b/addons/mk6mortar/functions/fnc_handleFired.sqf @@ -21,10 +21,17 @@ */ #include "script_component.hpp" -if (!GVAR(airResistanceEnabled)) exitWith {}; - PARAMS_7(_vehicle,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +if (GVAR(useAmmoHandling)) then { + if !(_vehicle getVariable [QGVAR(exclude),false]) then { + _vehicle removeMagazineGlobal (_vehicle magazinesTurret [0] select 0); + TRACE_1("",_vehicle magazinesTurret [0]); + }; +}; + +if (!GVAR(airResistanceEnabled)) exitWith {}; + private ["_shooterMan", "_temperature", "_newMuzzleVelocityCoefficent", "_bulletVelocity", "_bulletSpeed"]; // Large enough distance to not simulate any wind deflection diff --git a/addons/mk6mortar/functions/fnc_mortarInit.sqf b/addons/mk6mortar/functions/fnc_mortarInit.sqf index d1d4f6ea04..26ad0525fb 100644 --- a/addons/mk6mortar/functions/fnc_mortarInit.sqf +++ b/addons/mk6mortar/functions/fnc_mortarInit.sqf @@ -13,12 +13,11 @@ * * Public: No */ -#define DEBUG_MODE_FULL #include "script_component.hpp" -PARAMS_1(_mortar); +params ["_mortar"]; -if (_mortar getVariable [QGVAR(initialized),false]) exitWith {}; +if (_mortar getVariable [QGVAR(initialized),false] || _mortar getVariable [QGVAR(exclude),false]) exitWith {}; // Remove all magazines if (count magazines _mortar > 0) then {