From 579f861b8fe2ed19690aa2e3583dc40f9e4d4268 Mon Sep 17 00:00:00 2001 From: VKing Date: Thu, 17 Dec 2015 19:25:22 +0100 Subject: [PATCH] Unload to player inventory --- addons/mk6mortar/CfgVehicles.hpp | 8 ++++---- addons/mk6mortar/cfgMagazines.hpp | 2 +- .../functions/fnc_unloadMagazine.sqf | 20 +++++++++---------- addons/mk6mortar/stringtable.xml | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/addons/mk6mortar/CfgVehicles.hpp b/addons/mk6mortar/CfgVehicles.hpp index b70ddc7ae2..0d5c03d39c 100644 --- a/addons/mk6mortar/CfgVehicles.hpp +++ b/addons/mk6mortar/CfgVehicles.hpp @@ -55,14 +55,14 @@ class CfgVehicles { displayName = CSTRING(loadMagazine_HE_Guided); distance = 2; condition = QUOTE([ARR_3(_target,_player,'ACE_1Rnd_82mm_Mo_HE_Guided')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_4(_target,_player,5,'ACE_1Rnd_82mm_Mo_HE_Guided')] call FUNC(loadMagazineTimer)); + statement = QUOTE([ARR_4(_target,_player,6,'ACE_1Rnd_82mm_Mo_HE_Guided')] call FUNC(loadMagazineTimer)); icon = ""; }; class GVAR(loadMagazine_HE_LaserGuided) { displayName = CSTRING(loadMagazine_HE_LaserGuided); distance = 2; condition = QUOTE([ARR_3(_target,_player,'ACE_1Rnd_82mm_Mo_HE_LaserGuided')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_4(_target,_player,5,'ACE_1Rnd_82mm_Mo_HE_LaserGuided')] call FUNC(loadMagazineTimer)); + statement = QUOTE([ARR_4(_target,_player,6,'ACE_1Rnd_82mm_Mo_HE_LaserGuided')] call FUNC(loadMagazineTimer)); icon = ""; }; class GVAR(loadMagazine_Illum) { @@ -76,14 +76,14 @@ class CfgVehicles { displayName = CSTRING(loadMagazine_Smoke); distance = 2; condition = QUOTE([ARR_3(_target,_player,'ACE_1Rnd_82mm_Mo_Smoke')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_4(_target,_player,3,'ACE_1Rnd_82mm_Mo_Smoke')] call FUNC(loadMagazineTimer)); + statement = QUOTE([ARR_4(_target,_player,2.5,'ACE_1Rnd_82mm_Mo_Smoke')] call FUNC(loadMagazineTimer)); icon = ""; }; class GVAR(loadMagazine_HE) { displayName = CSTRING(loadMagazine_HE); distance = 2; condition = QUOTE([ARR_3(_target,_player,'ACE_1Rnd_82mm_Mo_HE')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_4(_target,_player,3,'ACE_1Rnd_82mm_Mo_HE')] call FUNC(loadMagazineTimer)); + statement = QUOTE([ARR_4(_target,_player,2.5,'ACE_1Rnd_82mm_Mo_HE')] call FUNC(loadMagazineTimer)); icon = ""; }; }; diff --git a/addons/mk6mortar/cfgMagazines.hpp b/addons/mk6mortar/cfgMagazines.hpp index 90512541fc..08a06e7d3c 100644 --- a/addons/mk6mortar/cfgMagazines.hpp +++ b/addons/mk6mortar/cfgMagazines.hpp @@ -9,7 +9,7 @@ class cfgMagazines { descriptionShort = CSTRING(magazine_HE_descriptionShort); model = PATHTOF(data\l16_ammo_he.p3d) picture = PATHTOF(UI\w_l16_ammo_he_ca.paa); - mass = 10; + mass = 10; // Temporary value; should be increased }; class 8Rnd_82mm_Mo_Smoke_white; class ACE_1Rnd_82mm_Mo_Smoke: 8Rnd_82mm_Mo_Smoke_white { diff --git a/addons/mk6mortar/functions/fnc_unloadMagazine.sqf b/addons/mk6mortar/functions/fnc_unloadMagazine.sqf index e81085d15f..537cc931d8 100644 --- a/addons/mk6mortar/functions/fnc_unloadMagazine.sqf +++ b/addons/mk6mortar/functions/fnc_unloadMagazine.sqf @@ -25,15 +25,15 @@ _currentMagazine = (magazinesAllTurrets _static) select 1; _currentMagazineClass = _currentMagazine select 0; _ammoCount = _currentMagazine select 2; -//If current magazine is empty then remove it otherwise remove it and add it to the players inventory -if (_ammoCount == 0) then { - [QGVAR(removeMagazine), [_static, _currentMagazineClass]] call EFUNC(common,globalEvent); -}else { - _pos = _unit modelToWorldVisual [0,1,0]; - // TODO: Check unit inventory space and add to inventory first, then drop - - _unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"]; - _unit addMagazineAmmoCargo [_currentMagazineClass, 1, _ammoCount]; - _unit setPosATL _pos; +// Try to add the round to player inventory, otherwise place it on the ground near the player +if (_ammoCount > 0) then { + if (_unit canAdd _currentMagazineClass) then { + _unit addMagazineGlobal _currentMagazineClass; + } else { + _pos = _unit modelToWorldVisual [0.5,0.5,0]; // Front right of player + _unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"]; + _unit addMagazineAmmoCargo [_currentMagazineClass, 1, _ammoCount]; + _unit setPosATL _pos; + }; [QGVAR(removeMagazine), [_static, _currentMagazineClass]] call EFUNC(common,globalEvent); }; diff --git a/addons/mk6mortar/stringtable.xml b/addons/mk6mortar/stringtable.xml index 3a2fa63dcf..3eb93995e2 100644 --- a/addons/mk6mortar/stringtable.xml +++ b/addons/mk6mortar/stringtable.xml @@ -136,7 +136,7 @@ Ce module permet de régler les options du mortier MK6 - Unload Round + Remove Round Load Mortar