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

CSW - Use setMagazineTurretAmmo #9912

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions addons/csw/functions/fnc_reload_handleAddTurretMag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,7 @@ if (_canAdd) then {
private _currentAmmo = _vehicle magazineTurretAmmo [_loadedMag, _turret];
_currentAmmo = _currentAmmo + _ammoUsed;
TRACE_2("Setting mag ammo",_loadedMag,_currentAmmo);
// _vehicle setMagazineTurretAmmo [_loadedMag, _currentAmmo, _turret];

// setMagazineTurretAmmo is broken on split locality, use setAmmo for now (this may not work for multi turret vehicles)
private _weapon = (_vehicle weaponsTurret _turret) param [0, ""];
TRACE_3("setAmmo",_vehicle,_weapon,_currentAmmo);
_vehicle setAmmo [_weapon, _currentAmmo];
private _currentAmmo = _vehicle magazineTurretAmmo [_loadedMag, _turret];
if ((_weapon == "") || {_currentAmmo != _currentAmmo}) then { ERROR_1("failed to setAmmo - %1",_this); };
_vehicle setMagazineTurretAmmo [_loadedMag, _currentAmmo, _turret];
} else {
if (_loadedMag != "") then {
TRACE_1("Removing emtpy mag",_loadedMag);
Expand Down
11 changes: 1 addition & 10 deletions addons/csw/functions/fnc_reload_handleRemoveTurretMag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,7 @@ private _ammoLeft = _ammoInFirstMag - _ammoRemoved;
if ((_magsInWeapon isEqualTo []) && {_ammoInFirstMag > _ammoRemoved}) then {
// Only one mag in gun, and we're just taking out a partial ammount (unlinking)
TRACE_2("Setting mag ammo",_ammoRemoved,_ammoLeft);
// _vehicle setMagazineTurretAmmo [_vehMag, _ammoLeft, _turretPath];

// setMagazineTurretAmmo is broken on split locality, use setAmmo for now
private _weapon = (_vehicle weaponsTurret _turretPath) param [0, ""];
TRACE_3("setAmmo",_vehicle,_weapon,_ammoLeft);
_vehicle setAmmo [_weapon, _ammoLeft];
private _currentAmmo = _vehicle magazineTurretAmmo [_vehMag, _turretPath];
if ((_weapon == "") || {_currentAmmo != _ammoLeft}) then { ERROR_1("failed to setAmmo - %1",_this); };


_vehicle setMagazineTurretAmmo [_vehMag, _ammoLeft, _turretPath];
} else {
// Because of command limitations, we need to remove mags to change their ammo
// This will cause the gun to need to be reloaded if more than one is loaded (only a problem for non-assembly mode guns)
Expand Down
Loading