-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: unstable
Are you sure you want to change the base?
Changes from 6 commits
e27dbf3
ced0193
5e0b781
07bf680
c991308
2bf4689
5f0e43e
9d4c01d
b773163
4445375
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [", ", ""] Is this not an issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it works, so ...no? I mean, you tried this PR right? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iirc, at first it was |
||
}; | ||
|
||
_vehicle vehicleChat _message; | ||
|
||
{ | ||
_vehicle addMagazineTurret _x; | ||
} forEach _magsAdd; |
There was a problem hiding this comment.
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 originalA3A_fnc_postInit
? That would be a very critical issueIf it's going to be called by
execVM
then you don't actually need to define it here anywayThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any developments on this?
There was a problem hiding this comment.
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