mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
78 lines
2.5 KiB
Plaintext
78 lines
2.5 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: PabstMirror (based on repack from commy2, esteldunedain, Ruthberg)
|
|
* Handles each frame durring the repack progressBar.
|
|
* On each event (repacked bullet or move to new mag) it plays a sound and syncs up the new magazines to the player.
|
|
*
|
|
* Arguments:
|
|
* 0: Arguments [classname,lastAmmoStatus,events] <ARRAY>
|
|
* 1: Elapsed Time <NUMBER>
|
|
* 2: Total Time Repacking Will Take <NUMBER>
|
|
*
|
|
* Return Value:
|
|
* Keep going (on missing mags return false) <BOOL>
|
|
*
|
|
* Example:
|
|
* (args from progressBar) call ace_magazinerepack_fnc_magazineRepackProgress
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_args", "_elapsedTime", "_totalTime"];
|
|
_args params ["_magazineClassname", "_lastAmmoCount", "_simEvents"];
|
|
|
|
if !((_simEvents select 0) params ["_nextEventTime", "_nextEventIsBullet", "_nextEventMags"]) exitWith { ERROR("No Event"); false };
|
|
|
|
|
|
if (_nextEventTime > _elapsedTime) exitWith { true };//waiting on next event
|
|
|
|
//Verify we aren't missing any ammo
|
|
private _currentAmmoCount = [];
|
|
{
|
|
_x params ["_xClassname", "_xCount"];
|
|
if (_xClassname == _magazineClassname) then {
|
|
_currentAmmoCount pushBack _xCount;
|
|
};
|
|
} forEach (magazinesAmmo ACE_player); //only inventory mags
|
|
|
|
//Go through mags we currently have and check off the ones we should have
|
|
private _addedMagazines = +_currentAmmoCount;
|
|
private _missingAmmo = false;
|
|
{
|
|
if (_x > 0) then {
|
|
private _index = _addedMagazines find _x;
|
|
if (_index != -1) then {
|
|
_addedMagazines deleteAt _index;
|
|
} else {
|
|
_missingAmmo = true;
|
|
};
|
|
};
|
|
} forEach _lastAmmoCount;
|
|
|
|
if (_missingAmmo) exitWith { false }; //something removed ammo that was being repacked (could be other players or scripts)
|
|
|
|
private _updateMagazinesOnPlayerFnc = {
|
|
ACE_player removeMagazines _magazineClassname; //remove inventory magazines
|
|
{
|
|
if (_x > 0) then {
|
|
ACE_player addMagazine [_magazineClassname, _x];
|
|
};
|
|
} forEach (_addedMagazines + _nextEventMags);
|
|
_args set [1, _nextEventMags]; //store the new magazine
|
|
};
|
|
|
|
if (_nextEventIsBullet) then {
|
|
playSound QGVAR(soundRoundFinished);
|
|
if ((((count _simEvents) % 3) == 0) || {(count _simEvents) == 1}) then {
|
|
//For performance - only update mags every 3 bullets (or if it's the last event)
|
|
call _updateMagazinesOnPlayerFnc;
|
|
};
|
|
} else {
|
|
playSound QGVAR(soundMagazineFinished);
|
|
call _updateMagazinesOnPlayerFnc;
|
|
};
|
|
|
|
_simEvents deleteAt 0; //pop off the event
|
|
|
|
true
|