2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-02-08 23:35:21 +00:00
|
|
|
/*
|
2015-02-09 04:44:23 +00:00
|
|
|
* Author: PabstMirror (based on repack from commy2, esteldunedain, Ruthberg)
|
2015-02-08 23:35:21 +00:00
|
|
|
* Simulates repacking a set of magazines.
|
|
|
|
* Returns the timing and magazines counts at every stage.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Arguments [classname,lastAmmoStatus,events] <ARRAY>
|
|
|
|
* 1: Elapsed Time <NUMBER>
|
|
|
|
* 2: Total Time Repacking Will Take <NUMBER>
|
|
|
|
* 3: Error Code <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-15 22:30:24 +00:00
|
|
|
* None
|
2015-02-08 23:35:21 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* (args from progressBar) call ace_magazinerepack_fnc_magazineRepackFinish
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-08-15 22:30:24 +00:00
|
|
|
params ["_args", "_elapsedTime", "_totalTime", "_errorCode"];
|
|
|
|
_args params ["_magazineClassname", "_lastAmmoCount"];
|
|
|
|
|
2016-06-04 18:40:55 +00:00
|
|
|
private _fullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _magazineClassname >> "count");
|
2015-02-08 23:35:21 +00:00
|
|
|
|
2016-06-04 18:40:55 +00:00
|
|
|
// Don't show anything if player can't interact
|
2024-06-18 14:08:03 +00:00
|
|
|
if !([ACE_player, objNull, ["isNotInside", "isNotSitting", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {};
|
2015-02-08 23:35:21 +00:00
|
|
|
|
2016-06-04 18:40:55 +00:00
|
|
|
// Count mags
|
|
|
|
private _fullMags = 0;
|
|
|
|
private _partialMags = 0;
|
2017-09-21 18:42:01 +00:00
|
|
|
private _bulletsLeft = 0;
|
2016-06-04 18:40:55 +00:00
|
|
|
{
|
|
|
|
_x params ["_classname", "_count"];
|
|
|
|
|
|
|
|
if (_classname == _magazineClassname && {_count > 0}) then {
|
|
|
|
if (_count == _fullMagazineCount) then {
|
|
|
|
_fullMags = _fullMags + 1;
|
|
|
|
} else {
|
|
|
|
_partialMags = _partialMags + 1;
|
2017-09-21 18:42:01 +00:00
|
|
|
_bulletsLeft = _count;
|
2016-06-04 18:40:55 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach (magazinesAmmoFull ACE_player);
|
|
|
|
|
|
|
|
private _structuredOutputText = if (_errorCode == 0) then {
|
2017-09-21 18:42:01 +00:00
|
|
|
private _repackedMagsText = format [localize LSTRING(RepackedMagazinesDetail), _fullMags, _bulletsLeft];
|
2016-06-04 18:40:55 +00:00
|
|
|
format ["<t align='center'>%1</t><br/>%2", localize LSTRING(RepackComplete), _repackedMagsText];
|
2015-02-08 23:35:21 +00:00
|
|
|
} else {
|
2017-09-21 18:42:01 +00:00
|
|
|
private _repackedMagsText = format [localize LSTRING(RepackedMagazinesCount), _fullMags, _partialMags];
|
2016-06-04 18:40:55 +00:00
|
|
|
format ["<t align='center'>%1</t><br/>%2", localize LSTRING(RepackInterrupted), _repackedMagsText];
|
2015-02-08 23:35:21 +00:00
|
|
|
};
|
|
|
|
|
2016-06-04 18:40:55 +00:00
|
|
|
private _picture = getText (configFile >> "CfgMagazines" >> _magazineClassname >> "picture");
|
|
|
|
[_structuredOutputText, _picture, nil, nil, 2.5] call EFUNC(common,displayTextPicture);
|