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
72 lines
2.8 KiB
Plaintext
72 lines
2.8 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: PabstMirror (based on repack from commy2, esteldunedain, Ruthberg)
|
|
* Starts repacking a specific magazine classname.
|
|
* If room in inventory, unload magazine from weapon to be repacked.
|
|
* Precalcs all the event timings and starts the progressBar.
|
|
*
|
|
* Arguments:
|
|
* 0: Target <OBJECT>
|
|
* 1: Player <OBJECT>
|
|
* 2: Magazine Classname <STRING>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [player, player, "30Rnd_65x39_caseless_mag"] call ace_magazinerepack_fnc_startRepackingMagazine
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_target", "_player", "_magazineClassname"];
|
|
|
|
if (isNil "_magazineClassname" || {_magazineClassname == ""}) exitWith {ERROR("Bad Mag Classname");};
|
|
private _magazineCfg = configFile >> "CfgMagazines" >> _magazineClassname;
|
|
// Calculate actual ammo to transfer during repack
|
|
private _fullMagazineCount = getNumber (_magazineCfg >> "count");
|
|
//Is linked belt magazine:
|
|
private _isBelt = isNumber (_magazineCfg >> "ACE_isBelt") && {(getNumber (_magazineCfg >> "ACE_isBelt")) == 1};
|
|
|
|
//Check canInteractWith:
|
|
if !([_player, objNull, ["isNotInside", "isNotSwimming", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {};
|
|
|
|
[_player] call EFUNC(common,goKneeling);
|
|
|
|
private _startingAmmoCounts = [];
|
|
{
|
|
_x params ["_xClassname", "_xCount", "_xLoaded", "_xType"];
|
|
if (_xClassname == _magazineClassname && {_xCount != _fullMagazineCount && {_xCount > 0}}) then {
|
|
if (_xLoaded) then {
|
|
//Try to Remove from weapon and add to inventory, otherwise ignore
|
|
if (_player canAdd _magazineClassname) then {
|
|
switch (_xType) do {
|
|
case (1): {_player removePrimaryWeaponItem _magazineClassname};
|
|
case (2): {_player removeHandgunItem _magazineClassname};
|
|
case (4): {_player removeSecondaryWeaponItem _magazineClassname};
|
|
default {ERROR("Loaded Location Invalid");};
|
|
};
|
|
_player addMagazine [_magazineClassname, _xCount];
|
|
_startingAmmoCounts pushBack _xCount;
|
|
};
|
|
} else {
|
|
_startingAmmoCounts pushBack _xCount;
|
|
};
|
|
};
|
|
} forEach (magazinesAmmoFull _player);
|
|
|
|
if (count _startingAmmoCounts < 2) exitWith {ERROR("Not Enough Mags to Repack");};
|
|
|
|
private _simEvents = [_fullMagazineCount, _startingAmmoCounts, _isBelt] call FUNC(simulateRepackEvents);
|
|
private _totalTime = _simEvents select (count _simEvents - 1) select 0;
|
|
|
|
[
|
|
_totalTime,
|
|
[_magazineClassname, _startingAmmoCounts, _simEvents],
|
|
{_this call FUNC(magazineRepackFinish)},
|
|
{_this call FUNC(magazineRepackFinish)},
|
|
(localize LSTRING(RepackingMagazine)),
|
|
{_this call FUNC(magazineRepackProgress)},
|
|
["isNotInside", "isNotSwimming", "isNotSitting"]
|
|
] call EFUNC(common,progressBar);
|