Reload Launcher - Improve various aspects (#9335)

* Add notifications to reloadLauncher

- Add notifications to reloadLauncher
- Also set _reloadTime to `magazineReloadTime min 2.5` instead of just 2.5 if there is no `buddyReloadTime` set

* Change message format

* Add setting displayStatusText for reloadLaunchers

* reloadlauncher improvements

* Comments

* Updated so it's similar to reload addon

* Added failure message

* Update addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Changed reload conditions

* Tweaked notifications

---------

Co-authored-by: Drofseh <Drofseh@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
johnb432 2023-08-28 20:14:45 +02:00 committed by GitHub
parent 59ee36560f
commit b90d0379ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 111 additions and 19 deletions

View File

@ -6,6 +6,9 @@ class CfgWeapons {
class launch_RPG32_F: Launcher_Base_F { class launch_RPG32_F: Launcher_Base_F {
GVAR(enabled) = 1; GVAR(enabled) = 1;
}; };
class launch_RPG7_F: Launcher_Base_F {
GVAR(enabled) = 1;
};
class launch_MRAWS_base_F: Launcher_Base_F { class launch_MRAWS_base_F: Launcher_Base_F {
GVAR(enabled) = 1; GVAR(enabled) = 1;
}; };

View File

@ -1,4 +1,26 @@
// by commy2 // by commy2
#include "script_component.hpp" #include "script_component.hpp"
[QGVAR(reloadStarted), {
params ["_unit", "_target"];
// Don't show notification if target is local AI
if (GVAR(displayStatusText) && {!local _unit} && {_target call EFUNC(common,isPlayer)}) then {
private _message = format [LLSTRING(LoadingStarted), _unit call EFUNC(common,getName)];
[_message] call EFUNC(common,displayTextStructured);
};
}] call CBA_fnc_addEventHandler;
[QGVAR(reloadAborted), {
params ["_unit", "_target"];
// Don't show notification if target is local AI
if (GVAR(displayStatusText) && {!local _unit} && {_target call EFUNC(common,isPlayer)}) then {
private _message = format [LLSTRING(LoadingAborted), _unit call EFUNC(common,getName)];
[_message] call EFUNC(common,displayTextStructured);
};
}] call CBA_fnc_addEventHandler;
[QGVAR(reloadLauncher), LINKFUNC(reloadLauncher)] call CBA_fnc_addEventHandler; [QGVAR(reloadLauncher), LINKFUNC(reloadLauncher)] call CBA_fnc_addEventHandler;

View File

@ -6,4 +6,6 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
PREP_RECOMPILE_END; PREP_RECOMPILE_END;
#include "initSettings.sqf"
ADDON = true; ADDON = true;

View File

@ -1,6 +1,6 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2, johnb43
* Check of the unit can reload the launcher of target unit. * Check of the unit can reload the launcher of target unit.
* *
* Arguments: * Arguments:
@ -28,6 +28,9 @@ if !(_target call EFUNC(common,isAwake)) exitWith {false};
if !(isNull objectParent _target) exitWith {false}; if !(isNull objectParent _target) exitWith {false};
if !([_unit, _target, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([_unit, _target, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Target must not be captive
if (_target getVariable [QEGVAR(captives,isHandcuffed), false] || {_target getVariable [QEGVAR(captives,isSurrendering), false]}) exitWith {false};
// Check if the launcher is compatible // Check if the launcher is compatible
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false}; if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false};

View File

@ -1,6 +1,6 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2, johnb43, drofseh
* Start reloading a launcher, reload started by the unit who has the missile. * Start reloading a launcher, reload started by the unit who has the missile.
* *
* Arguments: * Arguments:
@ -26,26 +26,56 @@ private _config = configFile >> "CfgWeapons" >> _weapon >> QGVAR(buddyReloadTime
private _reloadTime = if (isNumber _config) then { private _reloadTime = if (isNumber _config) then {
getNumber _config getNumber _config
} else { } else {
2.5 getNumber (configFile >> "CfgWeapons" >> _weapon >> "magazineReloadTime") min 2.5
}; };
// Play animation // Play animation
[_unit] call EFUNC(common,goKneeling); [_unit] call EFUNC(common,goKneeling);
// Notify unit that is being reloaded that reload has been started
[QGVAR(reloadStarted), [_unit, _target], _target] call CBA_fnc_targetEvent;
// Show progress bar // Show progress bar
private _onSuccess = { private _onSuccess = {
(_this select 0) params ["_unit", "_target", "_weapon", "_magazine"]; (_this select 0) params ["_unit", "_target", "_weapon", "_magazine"];
_unit removeMagazine _magazine; // Check if the unit has any of the same magazines and calculate max ammo
private _maxAmmo = 0;
{
_maxAmmo = _maxAmmo max (_x select 1);
} forEach (magazinesAmmo _unit select {(_x select 0) == _magazine});
// Check if the launcher can still be loaded; If possible, then try to remove magazine
if !(_maxAmmo > 0 && {[_unit, _target, _weapon, _magazine] call FUNC(canLoad)} && {[_unit, _magazine, _maxAmmo] call EFUNC(common,removeSpecificMagazine)}) exitWith {
// Notify unit that was being reloaded that reload has been stopped
[QGVAR(reloadAborted), [_unit, _target], _target] call CBA_fnc_targetEvent;
// Notify reloading unit about failure
if (GVAR(displayStatusText)) then {
[LSTRING(LauncherNotLoaded)] call EFUNC(common,displayTextStructured);
};
};
// Reload target's launcher // Reload target's launcher
[QGVAR(reloadLauncher), [_unit, _target, _weapon, _magazine], _target] call CBA_fnc_targetEvent; [QGVAR(reloadLauncher), [_unit, _target, _weapon, _magazine, _maxAmmo], _target] call CBA_fnc_targetEvent;
[LLSTRING(LauncherLoaded)] call EFUNC(common,displayTextStructured); // Notify reloading unit about success
if (GVAR(displayStatusText)) then {
[LSTRING(LauncherLoaded)] call EFUNC(common,displayTextStructured);
};
}; };
private _onFailure = { private _onFailure = {
[LELSTRING(common,ActionAborted)] call EFUNC(common,displayTextStructured); (_this select 0) params ["_unit", "_target"];
// Notify unit that was being reloaded that reload has been stopped
[QGVAR(reloadAborted), [_unit, _target], _target] call CBA_fnc_targetEvent;
// Notify reloading unit about failure
if (GVAR(displayStatusText)) then {
[LSTRING(LauncherNotLoaded)] call EFUNC(common,displayTextStructured);
};
}; };
private _condition = { private _condition = {

View File

@ -1,13 +1,15 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2, johnb43, drofseh
* Reload a launcher for the unit who has the launcher. * Reload a launcher for the unit who has the launcher.
* If the ammo argument is nil, a full magazine will be given.
* *
* Arguments: * Arguments:
* 0: Unit executing the reload <OBJECT> * 0: Unit to do the reloading <OBJECT>
* 1: Unit equipped with the launcher <OBJECT> * 1: Target to rload <OBJECT>
* 2: Launcher name <STRING> * 2: weapon name <STRING>
* 3: Missile name <STRING> * 3: missile name <STRING>
* 4: Ammo count <NUMBER>
* *
* Return Value: * Return Value:
* None * None
@ -18,12 +20,13 @@
* Public: No * Public: No
*/ */
params ["_unit", "_target", "_weapon", "_magazine"]; params ["_unit", "_target", "_weapon", "_magazine", "_ammo"];
TRACE_4("params",_unit,_target,_weapon,_magazine); TRACE_5("params",_unit,_target,_weapon,_magazine,_ammo);
_target selectWeapon _weapon; // Add magazine to launcher immediately
_target addWeaponItem [_weapon, [_magazine, _ammo], true];
if (currentWeapon _target != _weapon) exitWith {}; // Don't show notification if target is local AI
if (currentMagazine _target != "") exitWith {}; if (GVAR(displayStatusText) && {!local _unit} && {_target call EFUNC(common,isPlayer)}) then {
[LSTRING(LauncherLoaded)] call EFUNC(common,displayTextStructured);
_target addWeaponItem [_weapon, _magazine, true]; };

View File

@ -0,0 +1,8 @@
[
QGVAR(displayStatusText),
"CHECKBOX",
[LSTRING(SettingDisplayStatusTextName), LSTRING(SettingDisplayStatusTextDesc)],
ELSTRING(common,ACEKeybindCategoryWeapons),
true,
2
] call CBA_fnc_addSetting;

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project name="ACE"> <Project name="ACE">
<Package name="ReloadLaunchers"> <Package name="ReloadLaunchers">
<Key ID="STR_ACE_ReloadLaunchers_SettingDisplayStatusTextName">
<English>Display notifications for buddy loading</English>
</Key>
<Key ID="STR_ACE_ReloadLaunchers_SettingDisplayStatusTextDesc">
<English>Displays notifications when an assistant loads a gunner's launcher.</English>
</Key>
<Key ID="STR_ACE_ReloadLaunchers_LoadLauncher"> <Key ID="STR_ACE_ReloadLaunchers_LoadLauncher">
<English>Load launcher</English> <English>Load launcher</English>
<German>Panzerabwehr laden</German> <German>Panzerabwehr laden</German>
@ -18,6 +24,16 @@
<Chinese>裝載發射器</Chinese> <Chinese>裝載發射器</Chinese>
<Turkish>Fırlatıcıyı Yükle</Turkish> <Turkish>Fırlatıcıyı Yükle</Turkish>
</Key> </Key>
<Key ID="STR_ACE_ReloadLaunchers_LoadingStarted">
<English>%1 is loading your launcher</English>
<German>%1 lädt deine Panzerabwehr</German>
<French>%1 charge ton lanceur</French>
</Key>
<Key ID="STR_ACE_ReloadLaunchers_LoadingAborted">
<English>%1 stopped loading your launcher</English>
<German>%1 hat aufgehört, deine Panzerabwehr zu laden</German>
<French>%1 a arrêté de charger ton lanceur</French>
</Key>
<Key ID="STR_ACE_ReloadLaunchers_LoadingLauncher"> <Key ID="STR_ACE_ReloadLaunchers_LoadingLauncher">
<English>Loading launcher...</English> <English>Loading launcher...</English>
<French>Chargement du lanceur...</French> <French>Chargement du lanceur...</French>
@ -69,5 +85,10 @@
<Chinese>裝載%1</Chinese> <Chinese>裝載%1</Chinese>
<Turkish>%1 Yüklendi</Turkish> <Turkish>%1 Yüklendi</Turkish>
</Key> </Key>
<Key ID="STR_ACE_ReloadLaunchers_LauncherNotLoaded">
<English>Launcher could not be loaded</English>
<German>Panzerabwehr konnte nicht geladen werden</German>
<French>Lanceur n'a pas pu être chargé</French>
</Key>
</Package> </Package>
</Project> </Project>