From 0be1959934e8b5e6e8da189ffee928c728f52dc1 Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 18 Mar 2015 18:25:53 +0100 Subject: [PATCH 1/5] add reloadable launcher --- addons/reloadlaunchers/$PBOPREFIX$ | 1 + addons/reloadlaunchers/CfgEventHandlers.hpp | 6 ++++++ addons/reloadlaunchers/XEH_preInit.sqf | 7 +++++++ addons/reloadlaunchers/config.cpp | 15 +++++++++++++++ addons/reloadlaunchers/functions/fnc_empty.sqf | 3 +++ .../functions/script_component.hpp | 1 + addons/reloadlaunchers/script_component.hpp | 12 ++++++++++++ 7 files changed, 45 insertions(+) create mode 100644 addons/reloadlaunchers/$PBOPREFIX$ create mode 100644 addons/reloadlaunchers/CfgEventHandlers.hpp create mode 100644 addons/reloadlaunchers/XEH_preInit.sqf create mode 100644 addons/reloadlaunchers/config.cpp create mode 100644 addons/reloadlaunchers/functions/fnc_empty.sqf create mode 100644 addons/reloadlaunchers/functions/script_component.hpp create mode 100644 addons/reloadlaunchers/script_component.hpp diff --git a/addons/reloadlaunchers/$PBOPREFIX$ b/addons/reloadlaunchers/$PBOPREFIX$ new file mode 100644 index 0000000000..3425681cde --- /dev/null +++ b/addons/reloadlaunchers/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\reloadlaunchers \ No newline at end of file diff --git a/addons/reloadlaunchers/CfgEventHandlers.hpp b/addons/reloadlaunchers/CfgEventHandlers.hpp new file mode 100644 index 0000000000..f0a9f14d91 --- /dev/null +++ b/addons/reloadlaunchers/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/reloadlaunchers/XEH_preInit.sqf b/addons/reloadlaunchers/XEH_preInit.sqf new file mode 100644 index 0000000000..69abb46fa9 --- /dev/null +++ b/addons/reloadlaunchers/XEH_preInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(empty); + +ADDON = true; diff --git a/addons/reloadlaunchers/config.cpp b/addons/reloadlaunchers/config.cpp new file mode 100644 index 0000000000..a7b7bae6df --- /dev/null +++ b/addons/reloadlaunchers/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {""}; + authorUrl = ""; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/reloadlaunchers/functions/fnc_empty.sqf b/addons/reloadlaunchers/functions/fnc_empty.sqf new file mode 100644 index 0000000000..c60a82b2d8 --- /dev/null +++ b/addons/reloadlaunchers/functions/fnc_empty.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +diag_log text format["This is here as an example!!!"]; diff --git a/addons/reloadlaunchers/functions/script_component.hpp b/addons/reloadlaunchers/functions/script_component.hpp new file mode 100644 index 0000000000..9c129f36b1 --- /dev/null +++ b/addons/reloadlaunchers/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\reloadlaunchers\script_component.hpp" \ No newline at end of file diff --git a/addons/reloadlaunchers/script_component.hpp b/addons/reloadlaunchers/script_component.hpp new file mode 100644 index 0000000000..bc6b7f6e6c --- /dev/null +++ b/addons/reloadlaunchers/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT reloadlaunchers +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_RELOADLAUNCHERS + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_ENABLED_RELOADLAUNCHERS + #define DEBUG_SETTINGS DEBUG_ENABLED_RELOADLAUNCHERS +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file From 40eed0e12fd86c55e276a36f5ec818d12c5ebb9d Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 18 Mar 2015 20:17:53 +0100 Subject: [PATCH 2/5] reload event, some basic functions --- addons/reloadlaunchers/CfgEventHandlers.hpp | 6 ++ addons/reloadlaunchers/CfgWeapons.hpp | 11 ++++ addons/reloadlaunchers/XEH_postInit.sqf | 4 ++ addons/reloadlaunchers/XEH_preInit.sqf | 4 +- addons/reloadlaunchers/config.cpp | 1 + .../reloadlaunchers/functions/fnc_canLoad.sqf | 56 +++++++++++++++++++ .../reloadlaunchers/functions/fnc_empty.sqf | 3 - addons/reloadlaunchers/functions/fnc_load.sqf | 29 ++++++++++ .../functions/fnc_reloadLauncher.sqf | 28 ++++++++++ 9 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 addons/reloadlaunchers/CfgWeapons.hpp create mode 100644 addons/reloadlaunchers/XEH_postInit.sqf create mode 100644 addons/reloadlaunchers/functions/fnc_canLoad.sqf delete mode 100644 addons/reloadlaunchers/functions/fnc_empty.sqf create mode 100644 addons/reloadlaunchers/functions/fnc_load.sqf create mode 100644 addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf diff --git a/addons/reloadlaunchers/CfgEventHandlers.hpp b/addons/reloadlaunchers/CfgEventHandlers.hpp index f0a9f14d91..0cd959a047 100644 --- a/addons/reloadlaunchers/CfgEventHandlers.hpp +++ b/addons/reloadlaunchers/CfgEventHandlers.hpp @@ -4,3 +4,9 @@ class Extended_PreInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/reloadlaunchers/CfgWeapons.hpp b/addons/reloadlaunchers/CfgWeapons.hpp new file mode 100644 index 0000000000..08fbdb76b0 --- /dev/null +++ b/addons/reloadlaunchers/CfgWeapons.hpp @@ -0,0 +1,11 @@ + +class CfgWeapons { + class Launcher_Base_F; + class launch_Titan_base: Launcher_Base_F { + GVAR(enabled) = 1; + }; + + class launch_RPG32_F: Launcher_Base_F { + GVAR(enabled) = 1; + }; +}; diff --git a/addons/reloadlaunchers/XEH_postInit.sqf b/addons/reloadlaunchers/XEH_postInit.sqf new file mode 100644 index 0000000000..437927602a --- /dev/null +++ b/addons/reloadlaunchers/XEH_postInit.sqf @@ -0,0 +1,4 @@ +// by commy2 +#include "script_component.hpp" + +["reloadLauncher", {_this call DFUNC(reloadLauncher)}] call EFUNC(common,addEventhandler); diff --git a/addons/reloadlaunchers/XEH_preInit.sqf b/addons/reloadlaunchers/XEH_preInit.sqf index 69abb46fa9..d4c36fc948 100644 --- a/addons/reloadlaunchers/XEH_preInit.sqf +++ b/addons/reloadlaunchers/XEH_preInit.sqf @@ -2,6 +2,8 @@ ADDON = false; -PREP(empty); +PREP(canLoad); +PREP(load); +PREP(reloadLauncher); ADDON = true; diff --git a/addons/reloadlaunchers/config.cpp b/addons/reloadlaunchers/config.cpp index a7b7bae6df..09aee548bf 100644 --- a/addons/reloadlaunchers/config.cpp +++ b/addons/reloadlaunchers/config.cpp @@ -13,3 +13,4 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" +#include "CfgWeapons.hpp" diff --git a/addons/reloadlaunchers/functions/fnc_canLoad.sqf b/addons/reloadlaunchers/functions/fnc_canLoad.sqf new file mode 100644 index 0000000000..b318e162ef --- /dev/null +++ b/addons/reloadlaunchers/functions/fnc_canLoad.sqf @@ -0,0 +1,56 @@ +/* + * Author: commy2 + * + * Check of the unit can reload the launcher of target unit. + * + * Argument: + * 0: Unit to to the reload (Object) + * 1: Unit eqipped with launcher (Object) + * + * Return value: + * NONE + */ +#include "script_component.hpp" + +private ["_unit", "_target"]; + +_unit = _this select 0; +_target = _this select 1; + +if (!alive _target) exitWith {false}; +if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; + +private "_weapon"; +_weapon = secondaryWeapon _unit; + +// has secondary weapon equipped +if (_weapon == "" || {currentWeapon _target != _weapon}) exitWith {false}; + +// check if the target really needs to be reloaded +if (currentMagazine _target != "") exitWith {false}; + +// check if the launcher is compatible +private "_config"; +_config = configFile >> "CfgWeapons" >> _weapon; + +if (getNumber (_config >> QGVAR(enabled)) == 0) exitWith {false}; + +// get magazine of reloader +private "_magazines"; +_magazines = magazines _unit; + +{ + _magazines deleteAt (_magazines find _x); +} forEach secondaryWeaponMagazine _unit; + +// check if the reloader has a magazine compatible with targets launcher +private "_hasMagazine"; +_hasMagazine = false; + +{ + if (_x in _magazines) exitWith { + _hasMagazine = true; + }; +} forEach getArray (_config >> "magazines"); + +_hasMagazine diff --git a/addons/reloadlaunchers/functions/fnc_empty.sqf b/addons/reloadlaunchers/functions/fnc_empty.sqf deleted file mode 100644 index c60a82b2d8..0000000000 --- a/addons/reloadlaunchers/functions/fnc_empty.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "script_component.hpp" - -diag_log text format["This is here as an example!!!"]; diff --git a/addons/reloadlaunchers/functions/fnc_load.sqf b/addons/reloadlaunchers/functions/fnc_load.sqf new file mode 100644 index 0000000000..6a795fd0a6 --- /dev/null +++ b/addons/reloadlaunchers/functions/fnc_load.sqf @@ -0,0 +1,29 @@ +/* + * Author: commy2 + * + * Reload a launcher + * + * Argument: + * 0: Unit with magazine (Object) + * 1: Unit with launcher (Object) + * 2: weapon name (String) + * 3: missile name (String) + * + * Return value: + * NONE + */ +#include "script_component.hpp" + +private ["_unit", "_target", "_weapon", "_magazine"]; + +_unit = _this select 0; +_target = _this select 1; +_weapon = _this select 2; +_magazine = _this select 3; + +//do stuff + +/**/ + +// reload launcher on remote machine +["reloadLauncher", _target, [_target, _weapon, _magazine]] call EFUNC(common,targetEvent); diff --git a/addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf b/addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf new file mode 100644 index 0000000000..763e88dc3d --- /dev/null +++ b/addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf @@ -0,0 +1,28 @@ +/* + * Author: commy2 + * + * Reload a launcher + * + * Argument: + * 0: Unit to reload (Object) + * 1: weapon name (String) + * 2: missile name (String) + * + * Return value: + * NONE + */ +#include "script_component.hpp" + +private ["_unit", "_weapon", "_magazine"]; + +_unit = _this select 0; +_weapon = _this select 1; +_magazine = _this select 2; + +_unit selectWeapon _weapon; + +if (currentWeapon _unit != _weapon) exitWith {}; +if (currentMagazine _unit != "") exitWith {}; + +// command is wip, reload time for launchers is not intended. +_unit addWeaponItem [_weapon, _magazine]; From 43defaee06062907711724346a143ef4726e3d6a Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 18 Mar 2015 21:33:00 +0100 Subject: [PATCH 3/5] get compatible missiles fnc --- addons/reloadlaunchers/XEH_preInit.sqf | 1 + .../reloadlaunchers/functions/fnc_canLoad.sqf | 26 ++--------------- .../functions/fnc_getLoadableMissiles.sqf | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf diff --git a/addons/reloadlaunchers/XEH_preInit.sqf b/addons/reloadlaunchers/XEH_preInit.sqf index d4c36fc948..2b937b8284 100644 --- a/addons/reloadlaunchers/XEH_preInit.sqf +++ b/addons/reloadlaunchers/XEH_preInit.sqf @@ -3,6 +3,7 @@ ADDON = false; PREP(canLoad); +PREP(getLoadableMissiles); PREP(load); PREP(reloadLauncher); diff --git a/addons/reloadlaunchers/functions/fnc_canLoad.sqf b/addons/reloadlaunchers/functions/fnc_canLoad.sqf index b318e162ef..d2a4828038 100644 --- a/addons/reloadlaunchers/functions/fnc_canLoad.sqf +++ b/addons/reloadlaunchers/functions/fnc_canLoad.sqf @@ -4,7 +4,7 @@ * Check of the unit can reload the launcher of target unit. * * Argument: - * 0: Unit to to the reload (Object) + * 0: Unit to do the reloading (Object) * 1: Unit eqipped with launcher (Object) * * Return value: @@ -30,27 +30,7 @@ if (_weapon == "" || {currentWeapon _target != _weapon}) exitWith {false}; if (currentMagazine _target != "") exitWith {false}; // check if the launcher is compatible -private "_config"; -_config = configFile >> "CfgWeapons" >> _weapon; - -if (getNumber (_config >> QGVAR(enabled)) == 0) exitWith {false}; - -// get magazine of reloader -private "_magazines"; -_magazines = magazines _unit; - -{ - _magazines deleteAt (_magazines find _x); -} forEach secondaryWeaponMagazine _unit; +if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false}; // check if the reloader has a magazine compatible with targets launcher -private "_hasMagazine"; -_hasMagazine = false; - -{ - if (_x in _magazines) exitWith { - _hasMagazine = true; - }; -} forEach getArray (_config >> "magazines"); - -_hasMagazine +count ([_unit, _weapon] call FUNC(getLoadableMissiles)) > 0 diff --git a/addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf b/addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf new file mode 100644 index 0000000000..9b083a04c6 --- /dev/null +++ b/addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf @@ -0,0 +1,28 @@ +/* + * Author: commy2 + * + * Return all magazine types from reloaders inventory that are compatible with given weapon. + * + * Argument: + * 0: Unit to to the reload (Object) + * 1: A launcher (String) + * + * Return value: + * Reloable magazines (Array) + */ +#include "script_component.hpp" + +private ["_unit", "_weapon"]; + +_unit = _this select 0; +_weapon = _this select 1; + +// get available magazines of reloader, Note: "magazines" does not include currently loaded magazines +private "_magazines"; +_magazines = magazines _unit; + +// case sensitvity +_magazines = [_magazines, {toLower _this}] call EFUNC(common,map); + +// get reloaders magazine types compatible with targets launcher. No duplicates. +[getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"), {toLower _this in _magazines}] call EFUNC(common,filter) From f734aeee95737dfc8573096061811f73a76de703 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 22 Mar 2015 14:05:31 +0100 Subject: [PATCH 4/5] reload launcher mag progress bar --- addons/common/functions/fnc_progressBar.sqf | 1 + addons/reloadlaunchers/CfgVehicles.hpp | 15 ++++++ addons/reloadlaunchers/XEH_preInit.sqf | 1 + addons/reloadlaunchers/config.cpp | 4 +- .../functions/fnc_addMissileReloadActions.sqf | 53 +++++++++++++++++++ .../reloadlaunchers/functions/fnc_canLoad.sqf | 19 ++++--- addons/reloadlaunchers/functions/fnc_load.sqf | 27 ++++++++-- .../functions/fnc_reloadLauncher.sqf | 20 +++---- 8 files changed, 119 insertions(+), 21 deletions(-) create mode 100644 addons/reloadlaunchers/CfgVehicles.hpp create mode 100644 addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf diff --git a/addons/common/functions/fnc_progressBar.sqf b/addons/common/functions/fnc_progressBar.sqf index 69b91237e6..3191a57d72 100644 --- a/addons/common/functions/fnc_progressBar.sqf +++ b/addons/common/functions/fnc_progressBar.sqf @@ -53,6 +53,7 @@ _perFrameFunction = { _elapsedTime = time - _startTime; _errorCode = -1; + // this does not check: target fell unconscious, target died, target moved inside vehicle / left vehicle, target moved outside of players range, target moves at all. if (isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then { _errorCode = 1; } else { diff --git a/addons/reloadlaunchers/CfgVehicles.hpp b/addons/reloadlaunchers/CfgVehicles.hpp new file mode 100644 index 0000000000..6cdf2b1cfc --- /dev/null +++ b/addons/reloadlaunchers/CfgVehicles.hpp @@ -0,0 +1,15 @@ + +class CfgVehicles { + class Man; + class CAManBase: Man { + class ACE_Actions { + class GVAR(ReloadLauncher) { + displayName = "RELOAD LAUNCHERS"; + selection = "launcher"; + distance = 4; + condition = ""; + insertChildren = QUOTE(_this call FUNC(addMissileReloadActions)); + }; + }; + }; +}; diff --git a/addons/reloadlaunchers/XEH_preInit.sqf b/addons/reloadlaunchers/XEH_preInit.sqf index 2b937b8284..3b60f99b8e 100644 --- a/addons/reloadlaunchers/XEH_preInit.sqf +++ b/addons/reloadlaunchers/XEH_preInit.sqf @@ -2,6 +2,7 @@ ADDON = false; +PREP(addMissileReloadActions); PREP(canLoad); PREP(getLoadableMissiles); PREP(load); diff --git a/addons/reloadlaunchers/config.cpp b/addons/reloadlaunchers/config.cpp index 09aee548bf..a039ef87c4 100644 --- a/addons/reloadlaunchers/config.cpp +++ b/addons/reloadlaunchers/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; + requiredAddons[] = {"ace_common","ace_interaction","ace_interact_menu"}; author[] = {""}; authorUrl = ""; VERSION_CONFIG; @@ -13,4 +13,6 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" + +#include "CfgVehicles.hpp" #include "CfgWeapons.hpp" diff --git a/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf b/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf new file mode 100644 index 0000000000..71cc72e839 --- /dev/null +++ b/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf @@ -0,0 +1,53 @@ +/* + * Author: commy2 + * Create one action per reloadable missile + * + * Argument: + * 1: Player (Object) + * 0: Target (Object) + * 2: Parameters ??? (Array) + * + * Return value: + * Children actions (Array) + * + */ +#include "script_component.hpp" + +private ["_unit", "_target", "_parameters"]; + +_unit = _this select 1; +_target = _this select 0; +_parameters = _this select 2; // ??? + +private ["_actions", "_weapon", "_loadableMissiles"]; + +_actions = []; + +_weapon = secondaryWeapon _target; +_loadableMissiles = [_unit, _weapon] call FUNC(getLoadableMissiles); + +{ + private ["_name", "_displayName", "_statement", "_condition", "_action"]; + +/* +getText (configFile >> "CfgWeapons" >> _weapon >> "displayName") +getText (configFile >> "CfgMagazines" >> _x >> "displayName") +*/ + + _name = format [QGVAR(Missile_%1), _x]; + _displayName = format ["RELOAD %1", _x]; + + _statement = { + (_this select 2) call DFUNC(load); + }; + + _condition = { + (_this select 2) call DFUNC(canLoad) + }; + + _action = [_name, _displayName, "", _statement, _condition, {}, [_unit, _target, _weapon, _x], "", 4] call EFUNC(interact_menu,createAction); + + _actions pushBack [_action, [], _unit]; +} forEach _loadableMissiles; + +_actions diff --git a/addons/reloadlaunchers/functions/fnc_canLoad.sqf b/addons/reloadlaunchers/functions/fnc_canLoad.sqf index d2a4828038..5bbfe4dd87 100644 --- a/addons/reloadlaunchers/functions/fnc_canLoad.sqf +++ b/addons/reloadlaunchers/functions/fnc_canLoad.sqf @@ -6,31 +6,36 @@ * Argument: * 0: Unit to do the reloading (Object) * 1: Unit eqipped with launcher (Object) + * 2: weapon name (String) + * 3: missile name (String) * * Return value: * NONE */ #include "script_component.hpp" -private ["_unit", "_target"]; +private ["_unit", "_target", "_weapon", "_magazine"]; _unit = _this select 0; _target = _this select 1; +_weapon = _this select 2; +_magazine = _this select 3; if (!alive _target) exitWith {false}; +if (vehicle _target != _target) exitWith {false}; if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; -private "_weapon"; -_weapon = secondaryWeapon _unit; +// target is awake +if (_target getVariable ["ACE_isUnconscious", false]) exitWith {false}; // has secondary weapon equipped -if (_weapon == "" || {currentWeapon _target != _weapon}) exitWith {false}; +if !(_weapon in weapons _target) exitWith {false}; // check if the target really needs to be reloaded -if (currentMagazine _target != "") exitWith {false}; +if (count secondaryWeaponMagazine _target > 0) exitWith {false}; // check if the launcher is compatible if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false}; -// check if the reloader has a magazine compatible with targets launcher -count ([_unit, _weapon] call FUNC(getLoadableMissiles)) > 0 +// check if the magazine compatible with targets launcher +_magazine in ([_unit, _weapon] call FUNC(getLoadableMissiles)) diff --git a/addons/reloadlaunchers/functions/fnc_load.sqf b/addons/reloadlaunchers/functions/fnc_load.sqf index 6a795fd0a6..8806d835d6 100644 --- a/addons/reloadlaunchers/functions/fnc_load.sqf +++ b/addons/reloadlaunchers/functions/fnc_load.sqf @@ -21,9 +21,28 @@ _target = _this select 1; _weapon = _this select 2; _magazine = _this select 3; -//do stuff +private "_reloadTime"; +_reloadTime = getNumber (configFile >> "CfgWeapons" >> _weapon >> "magazineReloadTime"); -/**/ +// do animation +[_unit] call EFUNC(common,goKneeling); -// reload launcher on remote machine -["reloadLauncher", _target, [_target, _weapon, _magazine]] call EFUNC(common,targetEvent); +// show progress bar +private ["_onSuccess", "_onFailure", "_condition"]; + +_onSuccess = { + (_this select 0 select 0) removeMagazine (_this select 0 select 3); + ["reloadLauncher", _this select 0 select 0, _this select 0] call DEFUNC(common,targetEvent); + + ["WEAPON RELOADED"] call DEFUNC(common,displayTextStructured); +}; + +_onFailure = { + ["WEAPON NOT RELOADED"] call DEFUNC(common,displayTextStructured); +}; + +_condition = { + (_this select 0) call DFUNC(canLoad) && {(_this select 0 select 0) distance (_this select 0 select 1) < 4} +}; + +[_reloadTime, [_unit, _target, _weapon, _magazine], _onSuccess, _onFailure, "RELOADING WEAPON", _condition] call EFUNC(common,progressBar); diff --git a/addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf b/addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf index 763e88dc3d..36772f9dfd 100644 --- a/addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf +++ b/addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf @@ -4,9 +4,10 @@ * Reload a launcher * * Argument: - * 0: Unit to reload (Object) - * 1: weapon name (String) - * 2: missile name (String) + * 0: Unit to do the reloading (Object) + * 1: Target to rload (Object) + * 2: weapon name (String) + * 3: missile name (String) * * Return value: * NONE @@ -16,13 +17,14 @@ private ["_unit", "_weapon", "_magazine"]; _unit = _this select 0; -_weapon = _this select 1; -_magazine = _this select 2; +_target = _this select 1; +_weapon = _this select 2; +_magazine = _this select 3; -_unit selectWeapon _weapon; +_target selectWeapon _weapon; -if (currentWeapon _unit != _weapon) exitWith {}; -if (currentMagazine _unit != "") exitWith {}; +if (currentWeapon _target != _weapon) exitWith {}; +if (currentMagazine _target != "") exitWith {}; // command is wip, reload time for launchers is not intended. -_unit addWeaponItem [_weapon, _magazine]; +_target addWeaponItem [_weapon, _magazine]; From 4607fd860576518f2925a0dd84bc625f444d8344 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 22 Mar 2015 14:42:47 +0100 Subject: [PATCH 5/5] localization --- addons/reloadlaunchers/CfgVehicles.hpp | 2 +- .../functions/fnc_addMissileReloadActions.sqf | 7 +----- addons/reloadlaunchers/functions/fnc_load.sqf | 6 ++--- addons/reloadlaunchers/stringtable.xml | 24 +++++++++++++++++++ 4 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 addons/reloadlaunchers/stringtable.xml diff --git a/addons/reloadlaunchers/CfgVehicles.hpp b/addons/reloadlaunchers/CfgVehicles.hpp index 6cdf2b1cfc..617aa26b5c 100644 --- a/addons/reloadlaunchers/CfgVehicles.hpp +++ b/addons/reloadlaunchers/CfgVehicles.hpp @@ -4,7 +4,7 @@ class CfgVehicles { class CAManBase: Man { class ACE_Actions { class GVAR(ReloadLauncher) { - displayName = "RELOAD LAUNCHERS"; + displayName = "$STR_ACE_ReloadLaunchers_LoadLauncher"; selection = "launcher"; distance = 4; condition = ""; diff --git a/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf b/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf index 71cc72e839..58cd53699e 100644 --- a/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf +++ b/addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf @@ -29,13 +29,8 @@ _loadableMissiles = [_unit, _weapon] call FUNC(getLoadableMissiles); { private ["_name", "_displayName", "_statement", "_condition", "_action"]; -/* -getText (configFile >> "CfgWeapons" >> _weapon >> "displayName") -getText (configFile >> "CfgMagazines" >> _x >> "displayName") -*/ - _name = format [QGVAR(Missile_%1), _x]; - _displayName = format ["RELOAD %1", _x]; + _displayName = format [localize "STR_ACE_ReloadLaunchers_LoadMagazine", getText (configFile >> "CfgMagazines" >> _x >> "displayName")]; _statement = { (_this select 2) call DFUNC(load); diff --git a/addons/reloadlaunchers/functions/fnc_load.sqf b/addons/reloadlaunchers/functions/fnc_load.sqf index 8806d835d6..f6ad07e357 100644 --- a/addons/reloadlaunchers/functions/fnc_load.sqf +++ b/addons/reloadlaunchers/functions/fnc_load.sqf @@ -34,15 +34,15 @@ _onSuccess = { (_this select 0 select 0) removeMagazine (_this select 0 select 3); ["reloadLauncher", _this select 0 select 0, _this select 0] call DEFUNC(common,targetEvent); - ["WEAPON RELOADED"] call DEFUNC(common,displayTextStructured); + [localize "STR_ACE_ReloadLaunchers_LauncherLoaded"] call DEFUNC(common,displayTextStructured); }; _onFailure = { - ["WEAPON NOT RELOADED"] call DEFUNC(common,displayTextStructured); + [localize "STR_ACE_Common_ActionAborted"] call DEFUNC(common,displayTextStructured); }; _condition = { (_this select 0) call DFUNC(canLoad) && {(_this select 0 select 0) distance (_this select 0 select 1) < 4} }; -[_reloadTime, [_unit, _target, _weapon, _magazine], _onSuccess, _onFailure, "RELOADING WEAPON", _condition] call EFUNC(common,progressBar); +[_reloadTime, [_unit, _target, _weapon, _magazine], _onSuccess, _onFailure, localize "STR_ACE_ReloadLaunchers_LoadingLauncher", _condition] call EFUNC(common,progressBar); diff --git a/addons/reloadlaunchers/stringtable.xml b/addons/reloadlaunchers/stringtable.xml new file mode 100644 index 0000000000..6677153419 --- /dev/null +++ b/addons/reloadlaunchers/stringtable.xml @@ -0,0 +1,24 @@ + + + + + + Load launcher + Panzerabwehr laden + + + Loading launcher ... + Panzerabwehr wird geladen ... + + + Launcher loaded + Panzerabwehr geladen + + + + Load %1 + Lade %1 + + + +