From e0a21ce144d37c0b7bb841ca5018dafacc1a8d54 Mon Sep 17 00:00:00 2001 From: VKing Date: Wed, 16 Dec 2015 23:47:14 +0100 Subject: [PATCH] Completed code porting and interaction --- addons/mk6mortar/CfgVehicles.hpp | 28 ++++++++-------- addons/mk6mortar/XEH_preInit.sqf | 2 ++ addons/mk6mortar/cfgMagazines.hpp | 33 +++++++++---------- .../functions/fnc_canLoadMagazine.sqf | 4 +-- .../functions/fnc_canUnloadMagazine.sqf | 4 +-- .../mk6mortar/functions/fnc_loadMagazine.sqf | 4 +-- .../functions/fnc_loadMagazineTimer.sqf | 29 ++++++++++++++++ .../functions/fnc_unloadMagazine.sqf | 4 +-- .../functions/fnc_unloadMagazineTimer.sqf | 30 +++++++++++++++++ addons/mk6mortar/stringtable.xml | 12 +++++-- 10 files changed, 107 insertions(+), 43 deletions(-) create mode 100644 addons/mk6mortar/functions/fnc_loadMagazineTimer.sqf create mode 100644 addons/mk6mortar/functions/fnc_unloadMagazineTimer.sqf diff --git a/addons/mk6mortar/CfgVehicles.hpp b/addons/mk6mortar/CfgVehicles.hpp index d09c54c1b4..f344f0c7f2 100644 --- a/addons/mk6mortar/CfgVehicles.hpp +++ b/addons/mk6mortar/CfgVehicles.hpp @@ -40,53 +40,53 @@ class CfgVehicles { }; class ACE_Actions: ACE_Actions { class GVAR(unloadMagazine) { - displayName = CSTRING(unloadMagazine); + displayName = CSTRING(unloadMortar); distance = 4; - condition = QUOTE([ARR_2(_player,_target)] call FUNC(canUnloadMagazine)); - statement = QUOTE([ARR_2(_player,_target)] call FUNC(unloadMagazine)); + condition = QUOTE(_this call FUNC(canUnloadMagazine)); + statement = QUOTE([ARR_3(_target,_player,5)] call FUNC(unloadMagazineTimer)); icon = ""; selection = "usti hlavne"; }; class GVAR(LoadActions) { displayName = CSTRING(loadMortar); distance = 4; - condition = QUOTE([ARR_2(_player,_target)] call FUNC(canLoadMagazine)); + condition = QUOTE([ARR_2(_target,_player)] call FUNC(canLoadMagazine)); statement = ""; icon = ""; selection = "usti hlavne"; class GVAR(loadMagazine_HE_Guided) { displayName = CSTRING(loadMagazine_HE_Guided); distance = 4; - condition = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_HE_Guided')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_HE_Guided')] call FUNC(loadMagazine)); + 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)); icon = ""; }; class GVAR(loadMagazine_HE_LaserGuided) { displayName = CSTRING(loadMagazine_HE_LaserGuided); distance = 4; - condition = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_HE_LaserGuided')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_HE_LaserGuided')] call FUNC(loadMagazine)); + 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)); icon = ""; }; class GVAR(loadMagazine_Illum) { displayName = CSTRING(loadMagazine_Illum); distance = 4; - condition = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_Illum')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_Illum')] call FUNC(loadMagazine)); + condition = QUOTE([ARR_3(_target,_player,'ACE_1Rnd_82mm_Mo_Illum')] call FUNC(canLoadMagazine)); + statement = QUOTE([ARR_4(_target,_player,5,'ACE_1Rnd_82mm_Mo_Illum')] call FUNC(loadMagazineTimer)); icon = ""; }; class GVAR(loadMagazine_Smoke) { displayName = CSTRING(loadMagazine_Smoke); distance = 4; - condition = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_Smoke')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_Smoke')] call FUNC(loadMagazine)); + 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)); icon = ""; }; class GVAR(loadMagazine_HE) { displayName = CSTRING(loadMagazine_HE); distance = 4; - condition = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_HE')] call FUNC(canLoadMagazine)); - statement = QUOTE([ARR_3(_player,_target,'ACE_1Rnd_82mm_Mo_HE')] call FUNC(loadMagazine)); + 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)); icon = ""; }; }; diff --git a/addons/mk6mortar/XEH_preInit.sqf b/addons/mk6mortar/XEH_preInit.sqf index b892760673..3ec031b751 100644 --- a/addons/mk6mortar/XEH_preInit.sqf +++ b/addons/mk6mortar/XEH_preInit.sqf @@ -13,6 +13,7 @@ PREP(canUnloadMagazine); PREP(handleFired); PREP(handlePlayerVehicleChanged); PREP(loadMagazine); +PREP(loadMagazineTimer); PREP(moduleInit); PREP(rangeTableCanUse); PREP(rangeTableOpen); @@ -21,5 +22,6 @@ PREP(rangeTablePreCalculatedValues); PREP(toggleMils); PREP(turretDisplayLoaded); PREP(unloadMagazine); +PREP(unloadMagazineTimer); ADDON = true; diff --git a/addons/mk6mortar/cfgMagazines.hpp b/addons/mk6mortar/cfgMagazines.hpp index 939f21c3a2..8f0f19c00d 100644 --- a/addons/mk6mortar/cfgMagazines.hpp +++ b/addons/mk6mortar/cfgMagazines.hpp @@ -1,6 +1,3 @@ - // Artificially low for testing -#DEFINE __MASS = 10 - class cfgMagazines { class 8Rnd_82mm_Mo_shells; class ACE_1Rnd_82mm_Mo_HE: 8Rnd_82mm_Mo_shells { @@ -10,9 +7,9 @@ class cfgMagazines { author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_HE_displayName); descriptionShort = CSTRING(magazine_HE_descriptionShort); - model = ""; - picture = ""; - mass = __MASS; + model = "\A3\weapons_f\launchers\RPG32\tbg32v_rocket_item.p3d"; + picture = "\A3\Weapons_F\launchers\RPG32\data\UI\gear_tbg32v_rocket_ca.paa"; + mass = 10; }; class 8Rnd_82mm_Mo_Smoke_white; class ACE_1Rnd_82mm_Mo_Smoke: 8Rnd_82mm_Mo_Smoke_white { @@ -22,9 +19,9 @@ class cfgMagazines { author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_Smoke_displayName); descriptionShort = CSTRING(magazine_Smoke_descriptionShort); - model = ""; - picture = ""; - mass = __MASS; + model = "\A3\weapons_f\launchers\RPG32\tbg32v_rocket_item.p3d"; + picture = "\A3\Weapons_F\launchers\RPG32\data\UI\gear_tbg32v_rocket_ca.paa"; + mass = 10; }; class 8Rnd_82mm_Mo_Flare_white; class ACE_1Rnd_82mm_Mo_Illum: 8Rnd_82mm_Mo_Flare_white { @@ -34,9 +31,9 @@ class cfgMagazines { author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_Illum_displayName); descriptionShort = CSTRING(magazine_Illum_descriptionShort); - model = ""; - picture = ""; - mass = __MASS; + model = "\A3\weapons_f\launchers\RPG32\tbg32v_rocket_item.p3d"; + picture = "\A3\Weapons_F\launchers\RPG32\data\UI\gear_tbg32v_rocket_ca.paa"; + mass = 10; }; class 8Rnd_82mm_Mo_guided; class ACE_1Rnd_82mm_Mo_HE_Guided: 8Rnd_82mm_Mo_guided { @@ -46,9 +43,9 @@ class cfgMagazines { author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_HE_Guided_displayName); descriptionShort = CSTRING(magazine_HE_Guided_descriptionShort); - model = ""; - picture = ""; - mass = __MASS; + model = "\A3\weapons_f\launchers\RPG32\tbg32v_rocket_item.p3d"; + picture = "\A3\Weapons_F\launchers\RPG32\data\UI\gear_tbg32v_rocket_ca.paa"; + mass = 10; }; class 8Rnd_82mm_Mo_LG; class ACE_1Rnd_82mm_Mo_HE_LaserGuided: 8Rnd_82mm_Mo_LG { @@ -58,8 +55,8 @@ class cfgMagazines { author = ECSTRING(common,ACETeam); displayName = CSTRING(magazine_HE_LaserGuided_displayName); descriptionShort = CSTRING(magazine_HE_LaserGuided_descriptionShort); - model = ""; - picture = ""; - mass = __MASS; + model = "\A3\weapons_f\launchers\RPG32\tbg32v_rocket_item.p3d"; + picture = "\A3\Weapons_F\launchers\RPG32\data\UI\gear_tbg32v_rocket_ca.paa"; + mass = 10; }; }; diff --git a/addons/mk6mortar/functions/fnc_canLoadMagazine.sqf b/addons/mk6mortar/functions/fnc_canLoadMagazine.sqf index 67aa2cdf2b..71671e9a61 100644 --- a/addons/mk6mortar/functions/fnc_canLoadMagazine.sqf +++ b/addons/mk6mortar/functions/fnc_canLoadMagazine.sqf @@ -11,14 +11,14 @@ * canLoadMagazine * * Example: - * [_target,_player,'16aa_static_magazine_1Rnd_105mm_HE'] call lsr_staticweapons_canLoadMagazine + * [_target,_player,"ACE_1Rnd_82mm_Mo_HE"] call ace_mk6mortar_fnc_canLoadMagazine * * Public: Yes */ #include "script_component.hpp" -params ["_unit","_static",["_magazineClassOptional","",[""]]]; +params ["_static","_unit",["_magazineClassOptional","",[""]]]; private ["_canLoadMagazine","_currentMagazine","_weapon","_magazines","_listOfMagNames", "_hasCompatibleMagazine","_count"]; diff --git a/addons/mk6mortar/functions/fnc_canUnloadMagazine.sqf b/addons/mk6mortar/functions/fnc_canUnloadMagazine.sqf index 9a2afac32a..99634988a0 100644 --- a/addons/mk6mortar/functions/fnc_canUnloadMagazine.sqf +++ b/addons/mk6mortar/functions/fnc_canUnloadMagazine.sqf @@ -10,13 +10,13 @@ * canUnloadMagazine * * Example: - * [_target,_player] call lsr_staticweapons_canUnloadMagazine + * [_target,_player] call ace_mk6mortar_fnc_canUnloadMagazine * * Public: Yes */ #include "script_component.hpp" -params ["_unit","_static"]; +params ["_static","_unit"]; private ["_canUnloadMagazine","_ammoCount"]; if !(alive _static) exitWith {false}; diff --git a/addons/mk6mortar/functions/fnc_loadMagazine.sqf b/addons/mk6mortar/functions/fnc_loadMagazine.sqf index d5a0436cf4..48f78255d0 100644 --- a/addons/mk6mortar/functions/fnc_loadMagazine.sqf +++ b/addons/mk6mortar/functions/fnc_loadMagazine.sqf @@ -11,13 +11,13 @@ * None * * Example: - * [_target,_player,'16aa_static_magazine_l16_illum'] call lsr_staticweapons_loadMagazine + * [_target,_player,"ACE_1Rnd_82mm_Mo_HE"] call ace_mk6mortar_fnc_loadMagazine * * Public: Yes */ #include "script_component.hpp" -params ["_unit","_static",["_magazineClassOptional","",[""]]]; +params ["_static","_unit",["_magazineClassOptional","",[""]]]; private ["_weapon","_currentMagazine","_count","_magazines","_magazineDetails","_listOfMagNames", "_magazineClass","_magazineClassDetails","_parsed","_roundsLeft","_configMortar"]; diff --git a/addons/mk6mortar/functions/fnc_loadMagazineTimer.sqf b/addons/mk6mortar/functions/fnc_loadMagazineTimer.sqf new file mode 100644 index 0000000000..09348ee92c --- /dev/null +++ b/addons/mk6mortar/functions/fnc_loadMagazineTimer.sqf @@ -0,0 +1,29 @@ +/* + * Author: Grey + * Loads Magazine into static weapon using a timer + * + * Arguments: + * 0: static + * 1: unit + * 2: time to load + * 3: magazineClassOptional + * + * Return Value: + * None + * + * Example: + * [_target,_player,"ACE_1Rnd_82mm_Mo_HE"] call ace_mk6mortar_fnc_loadMagazineTimer + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_static","_unit","_timeToLoad",["_magazineClassOptional","",[""]]]; + +private _progressText = localize LSTRING(loadingMortar); +//Move player into animation if player is standing +if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then { + [_unit, "AmovPercMstpSrasWrflDnon_diary", 1] call EFUNC(common,doAnimation); +}; + +[_timeToLoad, [_static,_unit,_magazineClassOptional], {(_this select 0) call FUNC(loadMagazine);}, {}, _progressText] call EFUNC(common,progressBar); diff --git a/addons/mk6mortar/functions/fnc_unloadMagazine.sqf b/addons/mk6mortar/functions/fnc_unloadMagazine.sqf index fba5e56c58..3db8c058da 100644 --- a/addons/mk6mortar/functions/fnc_unloadMagazine.sqf +++ b/addons/mk6mortar/functions/fnc_unloadMagazine.sqf @@ -11,13 +11,13 @@ * None * * Example: - * [_target, _player] call lsr_staticweapons_unloadMagazine + * [_target, _player] call ace_mk6mortar_fnc_unloadMagazine * * Public: Yes */ #include "script_component.hpp" -params ["_unit","_static"]; +params ["_static","_unit"]; private ["_weapon","_currentMagazine","_currentMagazineClass","_ammoCount"]; //Get weapon & magazine information about static weapon diff --git a/addons/mk6mortar/functions/fnc_unloadMagazineTimer.sqf b/addons/mk6mortar/functions/fnc_unloadMagazineTimer.sqf new file mode 100644 index 0000000000..ad2cac8c2a --- /dev/null +++ b/addons/mk6mortar/functions/fnc_unloadMagazineTimer.sqf @@ -0,0 +1,30 @@ +/* + * Author: Grey + * + * Unload current magazine from static weapon using a timer + * + * Arguments: + * 0: static + * 1: unit + * 2: time to unload + * + * Return Value: + * None + * + * Example: + * [_target, _player, 5] call ace_mk6mortar_fnc_unloadMagazineTimer + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_static","_unit","_timeToUnload"]; + +private _progressText = localize LSTRING(unloadingMortar); + +//Move player into animation if player is standing +if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then { + [_unit, "AmovPercMstpSrasWrflDnon_diary", 1] call EFUNC(common,doAnimation); +}; + +[_timeToUnload, [_static,_unit], {(_this select 0) call FUNC(unloadMagazine);}, {}, _progressText] call EFUNC(common,progressBar); diff --git a/addons/mk6mortar/stringtable.xml b/addons/mk6mortar/stringtable.xml index 49ad0016a1..4c949b701a 100644 --- a/addons/mk6mortar/stringtable.xml +++ b/addons/mk6mortar/stringtable.xml @@ -135,9 +135,18 @@ Модуль настройки миномета MK6. Ce module permet de régler les options du mortier MK6 + + Unload Round + Load Mortar + + Unloading Round + + + Preparing Round + Load HE @@ -153,9 +162,6 @@ Load Laser Guided HE - - Unload Round - 82mm HE Round