diff --git a/A3A/addons/core/CfgFunctions.hpp b/A3A/addons/core/CfgFunctions.hpp index 09de4d7d7f..6378c45016 100644 --- a/A3A/addons/core/CfgFunctions.hpp +++ b/A3A/addons/core/CfgFunctions.hpp @@ -807,5 +807,12 @@ class CfgFunctions class remainingFuel {}; class rotateItem {}; }; + + class reload_repack_turret_magazines { + file = QPATHTOFOLDER(Scripts\RRTurretMagazines\scripts); + //class postInit {}; + class reloadTurret {}; + class monitorMagazines {}; + }; }; }; diff --git a/A3A/addons/core/Params.hpp b/A3A/addons/core/Params.hpp index 9997642614..9eeea24cf2 100644 --- a/A3A/addons/core/Params.hpp +++ b/A3A/addons/core/Params.hpp @@ -309,17 +309,16 @@ class Params texts[] = {"0%","25%","50%","75%","100%"}; default = 100; }; - - class Spacer60 + class Spacer66 { title = ""; values[] = {""}; texts[] = {""}; default = ""; }; - class Spacer51 + class Spacer67 { - title = $STR_params_antistasi_plus; + title = $STR_params_antistasi_scripts; values[] = {""}; texts[] = {""}; default = ""; @@ -331,6 +330,35 @@ class Params texts[] = {$STR_antistasi_dialogs_generic_button_no_text,$STR_antistasi_dialogs_generic_button_yes_text}; default = 1; }; + class RRTurretMagazines + { + title = $STR_params_ReloadRepackTurretMagazines; + values[] = {0,1}; + texts[] = {$STR_antistasi_dialogs_generic_button_no_text,$STR_antistasi_dialogs_generic_button_yes_text}; + default = 0; + }; + class enableSpectrumDevice + { + title = $STR_params_enableSpectrumDevice; + values[] = {0,1}; + texts[] = {$STR_antistasi_dialogs_generic_button_no_text, $STR_antistasi_dialogs_generic_button_yes_text}; + default = 0; + }; + + class Spacer60 + { + title = ""; + values[] = {""}; + texts[] = {""}; + default = ""; + }; + class Spacer51 + { + title = $STR_params_antistasi_plus; + values[] = {""}; + texts[] = {""}; + default = ""; + }; class newCarTowing { title = $STR_params_newCarTowing; @@ -590,13 +618,6 @@ class Params texts[] = {$STR_antistasi_dialogs_generic_button_no_text, $STR_antistasi_dialogs_generic_button_yes_text}; default = 0; }; - class enableSpectrumDevice - { - title = $STR_params_enableSpectrumDevice; - values[] = {0,1}; - texts[] = {$STR_antistasi_dialogs_generic_button_no_text, $STR_antistasi_dialogs_generic_button_yes_text}; - default = 0; - }; class allowFuturisticSupports { attr[] = {"server"}; diff --git a/A3A/addons/core/Scripts/RRTurretMagazines/AUTHORS.txt b/A3A/addons/core/Scripts/RRTurretMagazines/AUTHORS.txt new file mode 100644 index 0000000000..7f97b2271c --- /dev/null +++ b/A3A/addons/core/Scripts/RRTurretMagazines/AUTHORS.txt @@ -0,0 +1,13 @@ +# CONTRIBUTOR LIST + +# CORE TEAM +Ampersand + +# CONTRIBUTORS + +"Reload Repack Turret Magazines" +"https://github.com/ampersand38/reload-repack-turret-magazines"; +author = "Ampersand" + +Steam Workshop +https://steamcommunity.com/sharedfiles/filedetails/?id=2957051994 \ No newline at end of file diff --git a/A3A/addons/core/Scripts/RRTurretMagazines/LICENSE b/A3A/addons/core/Scripts/RRTurretMagazines/LICENSE new file mode 100644 index 0000000000..8f6dfafa3c --- /dev/null +++ b/A3A/addons/core/Scripts/RRTurretMagazines/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2021 Ampersand + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/A3A/addons/core/Scripts/RRTurretMagazines/scripts/fn_monitorMagazines.sqf b/A3A/addons/core/Scripts/RRTurretMagazines/scripts/fn_monitorMagazines.sqf new file mode 100644 index 0000000000..9ffa71dc93 --- /dev/null +++ b/A3A/addons/core/Scripts/RRTurretMagazines/scripts/fn_monitorMagazines.sqf @@ -0,0 +1,30 @@ +/* + * Author: Ampersand + * Show all magazines of the current type with ammo counts. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call A3A_fnc_monitorMagazines; + * + * Public: No + */ +#include "..\..\..\script_component.hpp" + + +if !(RRTurretMagazines) exitwith {}; + +private _player = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player]; +private _vehicle = vehicle _player; +private _turretPath = _vehicle unitTurret _player; +private _mag = _vehicle currentMagazineTurret _turretPath; +private _mags = magazinesAllTurrets [_vehicle, true] select {(_x # 0) == _mag && {(_x # 1) isEqualTo _turretPath}} apply { + _x # 2 +}; +_total = 0; +_mags apply {_total = _total + _x}; +hintSilent format ["%1 = %2", _mags joinString " + ", _total]; \ No newline at end of file diff --git a/A3A/addons/core/Scripts/RRTurretMagazines/scripts/fn_reloadTurret.sqf b/A3A/addons/core/Scripts/RRTurretMagazines/scripts/fn_reloadTurret.sqf new file mode 100644 index 0000000000..00198d655d --- /dev/null +++ b/A3A/addons/core/Scripts/RRTurretMagazines/scripts/fn_reloadTurret.sqf @@ -0,0 +1,69 @@ +/* + * Author: Ampersand + * Reload and repack the current magazine type. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call A3A_fnc_reloadTurret; + * + * Public: No + */ +#include "..\..\..\script_component.hpp" + +if !(RRTurretMagazines) exitwith {}; + +private _player = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player]; +private _vehicle = vehicle _player; +if (_player == _vehicle || {}) exitWith {}; + +private _turretPath = _vehicle unitTurret _player; +weaponState [_vehicle, _turretPath] params ["_weapon"]; +if !(_weapon in (_vehicle weaponsTurret _turretPath)) exitWith {}; // FFV + +weaponState [_vehicle, _turretPath] params ["", "", "", "_currentMagazine", "_currentAmmo", "_roundReloadPhase", "_magazineReloadPhase"]; +if (_roundReloadPhase != 0 || {_magazineReloadPhase != 0}) exitWith { + //systemChat "currently reloading"; +}; + +private _cfgMagazine = configFile >> "CfgMagazines" >> _currentMagazine; + +if (getText (_cfgMagazine >> "pylonWeapon") != "") exitWith {}; + +private _fullCount = getNumber (configFile >> "CfgMagazines" >> _currentMagazine >> "count"); +if (_currentAmmo == _fullCount) exitWith { + //systemChat "current mag full"; +}; + +private _totalAmmo = 0; +private _magsCount = 0; + +{ +_x params ["_xMagazine", "_xTurretPath", "_xAmmoCount"]; +if (_xMagazine != _currentMagazine || {_xTurretPath isNotEqualTo _turretPath}) then {continue;}; + _magsCount = _magsCount + 1; + _totalAmmo = _totalAmmo + _xAmmoCount; +} forEach magazinesAllTurrets [_vehicle, true]; +if (_magsCount == 1 || {_currentAmmo == _totalAmmo}) exitWith { + //systemChat "no other ammo than in current mag"; +}; + +private _message = format [localize "STR_notifiers_reload_turret", _totalAmmo]; +private _magsAdd = []; +for "_i" from 1 to _magsCount do { + _vehicle removeMagazineTurret [_currentMagazine, _turretPath]; + private _ammoThisMag = selectMin [_fullCount, _totalAmmo]; + _magsAdd pushBack [_currentMagazine, _turretPath, _ammoThisMag]; + _totalAmmo = _totalAmmo - _ammoThisMag; + _message = _message + str _ammoThisMag + ([", ", ""] select (_i == _magsCount)); +}; + +_vehicle vehicleChat _message; + +{ + _vehicle addMagazineTurret _x; +} forEach _magsAdd; \ No newline at end of file diff --git a/A3A/addons/core/Stringtable.xml b/A3A/addons/core/Stringtable.xml index 73da795c30..34fe699cb8 100644 --- a/A3A/addons/core/Stringtable.xml +++ b/A3A/addons/core/Stringtable.xml @@ -5938,6 +5938,11 @@ 무기 흔들림 % (바닐라) % de balancement de l'arme (Vanilla) + + Total: %1. Magazines: + Total: %1. Magazines: + Всего: %1. Магазины: + diff --git a/A3A/addons/core/functions/init/fn_initClient.sqf b/A3A/addons/core/functions/init/fn_initClient.sqf index 2a90402a3e..4424dab761 100644 --- a/A3A/addons/core/functions/init/fn_initClient.sqf +++ b/A3A/addons/core/functions/init/fn_initClient.sqf @@ -116,6 +116,12 @@ if (enableSpectrumDevice) then { [] execVM QPATHTOFOLDER(Scripts\SpectumDevice\sa_ewar.sqf); }; +if (RRTurretMagazines) then { + [] execVM QPATHTOFOLDER(Scripts\RRTurretMagazines\scripts\fn_monitorMagazines.sqf); + addUserActionEventHandler ["ReloadMagazine", "Activate", A3A_fnc_reloadTurret]; + [] execVM QPATHTOFOLDER(Scripts\RRTurretMagazines\scripts\fn_reloadTurret.sqf); +}; + // Placeholders, should get replaced globally by the server player setVariable ["score",0]; player setVariable ["moneyX",0]; diff --git a/A3A/addons/scrt/Stringtable.xml b/A3A/addons/scrt/Stringtable.xml index 32c2770d88..c324a90e67 100644 --- a/A3A/addons/scrt/Stringtable.xml +++ b/A3A/addons/scrt/Stringtable.xml @@ -4957,6 +4957,10 @@ 안티스타시 플러스 매개변수 PARAMÈTRES ANTISTASI PLUS + + SCRIPTS + СКРИПТЫ + Time Multiplier Множитель времени @@ -5034,6 +5038,10 @@ 탄약 재포장을 활성화합니까? Activer le reconditionnement des chargeurs? + + Enable Turret Magazine Repacking? + Включить Turret Magazine Repacking? + Show 3D icons above unconscious players? Показывать 3D-иконки над игроками, которым требуется медицинская помощь?