Skip to content

Commit

Permalink
CSW - Use setMagazineTurretAmmo (#9912)
Browse files Browse the repository at this point in the history
Use `setMagazineTurretAmmo` in 2.18
  • Loading branch information
johnb432 authored Oct 15, 2024
1 parent 5792eb2 commit be58247
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
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

0 comments on commit be58247

Please sign in to comment.