2015-08-16 00:18:53 +00:00
|
|
|
/*
|
|
|
|
* Author: GitHawk
|
2015-08-18 00:32:10 +00:00
|
|
|
* Rearm an entire vehicle.
|
2015-08-16 00:18:53 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-18 00:32:10 +00:00
|
|
|
* 0: Vehicle <OBJECT>
|
2015-08-16 00:18:53 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [tank] call ace_rearm_fnc_rearmEntireVehicleSuccess
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-18 00:32:10 +00:00
|
|
|
private ["_turretPath", "_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_maxRounds", "_currentRounds"];
|
2015-08-16 00:18:53 +00:00
|
|
|
params ["_vehicle"];
|
|
|
|
|
|
|
|
if !(local _vehicle) exitWith {
|
2015-08-18 00:32:10 +00:00
|
|
|
[_this, QFUNC(rearmEntireVehicleSuccess), _vehicle] call EFUNC(common,execRemoteFnc);
|
2015-08-16 00:18:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
_turretPath = _x;
|
|
|
|
_magazines = _vehicle magazinesTurret _turretPath;
|
|
|
|
{
|
|
|
|
_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];
|
2015-08-18 00:32:10 +00:00
|
|
|
|
2015-08-18 00:57:39 +00:00
|
|
|
TRACE_7("Rearmed Turret",_vehicle,_turretPath,_currentMagazines,_maxMagazines,_currentRounds,_maxRounds,_magazine);
|
|
|
|
|
2015-08-16 00:18:53 +00:00
|
|
|
if (_currentMagazines < _maxMagazines) then {
|
|
|
|
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
|
|
|
|
for "_idx" from 1 to (_maxMagazines - _currentMagazines) do {
|
|
|
|
_vehicle addMagazineTurret [_magazine, _turretPath];
|
|
|
|
};
|
|
|
|
} else {
|
2015-08-18 00:57:39 +00:00
|
|
|
if (_currentRounds > 0 || {_magazine == "SmokeLauncherMag"}) then { // When SmokeLauncherMag is empty removeMagazineTurret has no effect
|
2015-08-16 00:18:53 +00:00
|
|
|
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
|
|
|
|
} else {
|
|
|
|
_vehicle removeMagazineTurret [_magazine, _turretPath];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} foreach _magazines;
|
2015-08-18 00:32:10 +00:00
|
|
|
} foreach REARM_TURRET_PATHS;
|