Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicle turret magazine reload port #410

Merged
Merged
7 changes: 7 additions & 0 deletions A3A/addons/core/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
};
};
};
43 changes: 32 additions & 11 deletions A3A/addons/core/Params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -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;
Expand Down Expand Up @@ -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"};
Expand Down
13 changes: 13 additions & 0 deletions A3A/addons/core/Scripts/RRTurretMagazines/AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions A3A/addons/core/Scripts/RRTurretMagazines/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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];
Original file line number Diff line number Diff line change
@@ -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));
SilenceIsFatto marked this conversation as resolved.
Show resolved Hide resolved
};

_vehicle vehicleChat _message;

{
_vehicle addMagazineTurret _x;
} forEach _magsAdd;
5 changes: 5 additions & 0 deletions A3A/addons/core/Stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5938,6 +5938,11 @@
<Korean>무기 흔들림 % (바닐라)</Korean>
<French>% de balancement de l'arme (Vanilla)</French>
</Key>
<Key ID="STR_notifiers_reload_turret">
<Original>Total: %1. Magazines: </Original>
<English>Total: %1. Magazines: </English>
<Russian>Всего: %1. Магазины: </Russian>
</Key>
</Container>
</Package>
</Project>
6 changes: 6 additions & 0 deletions A3A/addons/core/functions/init/fn_initClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
8 changes: 8 additions & 0 deletions A3A/addons/scrt/Stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4957,6 +4957,10 @@
<Korean>안티스타시 플러스 매개변수</Korean>
<French>PARAMÈTRES ANTISTASI PLUS</French>
</Key>
<Key ID="STR_params_antistasi_scripts">
<Original>SCRIPTS</Original>
<Russian>СКРИПТЫ</Russian>
</Key>
<Key ID="STR_params_timeMultiplier">
<Original>Time Multiplier</Original>
<Russian>Множитель времени</Russian>
Expand Down Expand Up @@ -5034,6 +5038,10 @@
<Korean>탄약 재포장을 활성화합니까?</Korean>
<French>Activer le reconditionnement des chargeurs?</French>
</Key>
<Key ID="STR_params_ReloadRepackTurretMagazines">
<Original>Enable Turret Magazine Repacking?</Original>
<Russian>Включить Turret Magazine Repacking?</Russian>
</Key>
<Key ID="STR_params_playerIcons">
<Original>Show 3D icons above unconscious players?</Original>
<Russian>Показывать 3D-иконки над игроками, которым требуется медицинская помощь?</Russian>
Expand Down