ACE3/addons/rearm/functions/fnc_rearmEntireVehicleSuccessLocal.sqf

49 lines
1.8 KiB
Plaintext
Raw Normal View History

2015-08-18 16:09:37 +00:00
/*
* Author: GitHawk
* Rearm an entire turret locally.
*
* Arguments:
* 0: Vehicle <OBJECT>
2016-02-01 19:05:53 +00:00
* 1: TurretPath <ARRAY>
2015-08-18 16:09:37 +00:00
*
* Return Value:
* None
*
* Example:
* [tank, [0]] call ace_rearm_fnc_rearmEntireVehicleSuccessLocal
*
* Public: No
*/
#include "script_component.hpp"
private ["_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_maxRounds", "_currentRounds"];
2016-02-01 19:05:53 +00:00
params [["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]]];
2016-06-27 04:37:23 +00:00
TRACE_2("params",_vehicle,_turretPath);
//ToDo: Cleanup with CBA_fnc_ownerEvent in CBA 2.4.2
if (!(_vehicle turretLocal _turretPath)) exitWith {TRACE_1("not local turret",_turretPath);};
2015-08-18 16:09:37 +00:00
2016-02-01 19:05:53 +00:00
_magazines = [_vehicle, _turretPath] call FUNC(getConfigMagazines);
2015-08-18 16:09:37 +00:00
{
_magazine = _x;
_currentMagazines = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
_maxMagazines = [_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines);
_maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
_currentRounds = _vehicle magazineTurretAmmo [_magazine, _turretPath];
TRACE_7("Rearmed Turret",_vehicle,_turretPath,_currentMagazines,_maxMagazines,_currentRounds,_maxRounds,_magazine);
if (_turretPath isEqualTo [-1] && _currentMagazines == 0) then {
// On driver, the empty magazine is still there, but is not returned by magazinesTurret
_currentMagazines = _currentMagazines + 1;
};
2015-08-18 16:09:37 +00:00
if (_currentMagazines < _maxMagazines) then {
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
for "_idx" from 1 to (_maxMagazines - _currentMagazines) do {
_vehicle addMagazineTurret [_magazine, _turretPath];
};
} else {
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
2015-08-18 16:09:37 +00:00
};
} foreach _magazines;