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

Open
wants to merge 10 commits into
base: unstable
Choose a base branch
from
7 changes: 7 additions & 0 deletions A3A/addons/core/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,5 +806,12 @@ class CfgFunctions
class remainingFuel {};
class rotateItem {};
};

class reload_repack_turret_magazines {
file = QPATHTOFOLDER(Scripts\RRTurretMagazines\scripts);
class postInit {};
class reloadTurret {};
class monitorMagazines {};
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this class postInit overwrite the original A3A_fnc_postInit? That would be a very critical issue

If it's going to be called by execVM then you don't actually need to define it here anyway

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any developments on this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh shit, completely forgot about it

};
};
43 changes: 32 additions & 11 deletions A3A/addons/core/Params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,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 @@ -324,6 +323,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 = 1;
};
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 @@ -576,13 +604,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 rrtm_fnc_monitorMagazines;
wersal454 marked this conversation as resolved.
Show resolved Hide resolved
*
* 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,7 @@
#include "..\..\..\script_component.hpp"

if (!hasInterface) exitWith {};

if !(RRTurretMagazines) exitwith {};

addUserActionEventHandler ["ReloadMagazine", "Activate", A3A_fnc_reloadTurret];
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 rrtm_fnc_reloadTurret;
wersal454 marked this conversation as resolved.
Show resolved Hide resolved
*
* 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));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[", ", ""]

Is this not an issue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works, so ...no? I mean, you tried this PR right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried many other pulls and they "worked", until they didn't

Literally the point of reviewing, I see a syntax issue so I point it out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc, at first it was [",", ""], I added additional space after comma so created text would look better [", ", ""]

};

_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);
[] execVM QPATHTOFOLDER(Scripts\RRTurretMagazines\scripts\fn_postInit.sqf);
[] 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
4 changes: 2 additions & 2 deletions A3A/addons/logistics/Cargo/Vanilla.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class A3_Static_F_Mark_Designator_01_Designator_01_F : TRIPLES(ADDON,Cargo,Base)
{
offset[] = {0,0,0};
offset[] = {0.1,0,0.5};
rotation[] = {1,0,0};
size = 1;
};

class A3_Static_F_Mark_Designator_02_Designator_02_F : TRIPLES(ADDON,Cargo,Base)
{
offset[] = {0,0,0};
offset[] = {0,0,0.5};
rotation[] = {1,0,0};
size = 1;
};
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 ReloadRepackTurretMagazines?</Original>
<Russian>Включить ReloadRepackTurretMagazines?</Russian>
wersal454 marked this conversation as resolved.
Show resolved Hide resolved
</Key>
<Key ID="STR_params_playerIcons">
<Original>Show 3D icons above unconscious players?</Original>
<Russian>Показывать 3D-иконки над игроками, которым требуется медицинская помощь?</Russian>
Expand Down