2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-02-27 19:31:07 +00:00
|
|
|
/*
|
|
|
|
* Author: GitHawk
|
2016-02-27 20:05:19 +00:00
|
|
|
* Get the remaining ammunition amount.
|
2016-02-27 19:31:07 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Ammo Truck <OBJECT>
|
|
|
|
* 1: Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [ammo_truck, player] call ace_rearm_fnc_readSupplyCounter
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
params ["_truck", "_unit"];
|
2017-06-08 16:47:52 +00:00
|
|
|
TRACE_2("readSupplyCounter",_truck,_unit);
|
2016-02-27 19:31:07 +00:00
|
|
|
|
2017-06-08 16:47:52 +00:00
|
|
|
if (GVAR(supply) == 0) exitWith {WARNING("Supply is unlimited");};
|
2016-02-27 19:31:07 +00:00
|
|
|
|
|
|
|
if (GVAR(supply) == 1) then {
|
|
|
|
[
|
2017-06-08 16:47:52 +00:00
|
|
|
TIME_PROGRESSBAR(5),
|
2016-02-27 20:05:19 +00:00
|
|
|
[_unit, _truck, [_truck] call FUNC(getSupplyCount)],
|
2016-02-27 19:31:07 +00:00
|
|
|
{
|
|
|
|
params ["_args"];
|
2016-02-27 20:05:19 +00:00
|
|
|
_args params [["_unit", objNull, [objNull]], ["_truck", objNull, [objNull]], ["_supplyCount", 0, [0]]];
|
2016-02-27 19:31:07 +00:00
|
|
|
if (_supplyCount > 0 ) then {
|
2017-05-18 16:13:31 +00:00
|
|
|
[[LSTRING(Hint_RemainingSupplyPoints), _supplyCount], 2, _unit] call EFUNC(common,displayTextStructured);
|
2016-02-27 19:31:07 +00:00
|
|
|
} else {
|
2017-09-30 16:14:41 +00:00
|
|
|
[LSTRING(Hint_Empty), 2, _unit] call EFUNC(common,displayTextStructured);
|
2016-02-27 19:31:07 +00:00
|
|
|
};
|
|
|
|
true
|
|
|
|
},
|
|
|
|
{true},
|
|
|
|
localize LSTRING(ReadSupplyCounterAction),
|
|
|
|
{true},
|
|
|
|
["isnotinside"]
|
|
|
|
] call EFUNC(common,progressBar);
|
|
|
|
} else {
|
|
|
|
[
|
2017-06-08 16:47:52 +00:00
|
|
|
TIME_PROGRESSBAR(5),
|
2016-02-27 20:05:19 +00:00
|
|
|
[_unit, _truck],
|
2016-02-27 19:31:07 +00:00
|
|
|
{
|
|
|
|
params ["_args"];
|
2016-02-27 20:05:19 +00:00
|
|
|
_args params [["_unit", objNull, [objNull]], ["_truck", objNull, [objNull]]];
|
2016-02-27 19:31:07 +00:00
|
|
|
private _supply = 1.5;
|
|
|
|
private _numChars = count (localize LSTRING(Hint_RemainingAmmo));
|
|
|
|
private _text = "";
|
2016-02-27 20:05:19 +00:00
|
|
|
private _magazines = _truck getVariable QGVAR(magazineSupply);
|
2020-02-11 22:44:53 +00:00
|
|
|
if (!isNil "_magazines") then {
|
2016-02-27 19:31:07 +00:00
|
|
|
{
|
|
|
|
_x params ["_magazineClass", "_rounds"];
|
2019-01-31 00:31:01 +00:00
|
|
|
private _line = format ["%1: %2", _magazineClass call FUNC(getMagazineName), _rounds];
|
2016-02-27 19:31:07 +00:00
|
|
|
_numChars = _numChars max (count _line);
|
|
|
|
_text = format ["%1<br/>%2", _text, _line];
|
|
|
|
_supply = _supply + 0.5;
|
2024-04-04 11:15:26 +00:00
|
|
|
} forEach _magazines;
|
2016-02-27 19:31:07 +00:00
|
|
|
};
|
|
|
|
if (_supply > 1.5) then {
|
2017-05-18 16:13:31 +00:00
|
|
|
[[LSTRING(Hint_RemainingAmmo), _text], _supply, _unit, (_numChars/2.9)] call EFUNC(common,displayTextStructured);
|
2016-02-27 19:31:07 +00:00
|
|
|
} else {
|
2017-05-18 16:13:31 +00:00
|
|
|
[LSTRING(Hint_Empty), 2, _unit] call EFUNC(common,displayTextStructured);
|
2016-02-27 19:31:07 +00:00
|
|
|
};
|
|
|
|
true
|
|
|
|
},
|
|
|
|
{true},
|
|
|
|
localize LSTRING(ReadSupplyCounterAction),
|
|
|
|
{true},
|
|
|
|
["isnotinside"]
|
|
|
|
] call EFUNC(common,progressBar);
|
|
|
|
};
|