mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
#176 - Belt Repacking
This commit is contained in:
parent
0daa029622
commit
43a9e7bfc8
@ -17,12 +17,19 @@ class CfgPatches {
|
||||
#include "CfgVehicles.hpp"
|
||||
|
||||
class ACE_Settings {
|
||||
//Time to move a round from one magazine to another
|
||||
class GVAR(TimePerAmmo) {
|
||||
value = 1.5;
|
||||
typeName = "SCALAR";
|
||||
};
|
||||
//Time to swap between magazines when repacking
|
||||
class GVAR(TimePerMagazine) {
|
||||
value = 2.0;
|
||||
typeName = "SCALAR";
|
||||
};
|
||||
//Time to relink 2 belts together
|
||||
class GVAR(TimePerBeltLink) {
|
||||
value = 8.0;
|
||||
typeName = "SCALAR";
|
||||
};
|
||||
};
|
||||
|
@ -23,9 +23,10 @@ PARAMS_4(_args,_elapsedTime,_totalTime,_errorCode);
|
||||
EXPLODE_2_PVT(_args,_magazineClassname,_lastAmmoCount);
|
||||
_fullMagazineCount = getNumber (configfile >> "CfgMagazines" >> _magazineClassname >> "count");
|
||||
|
||||
_structuredOutputText =
|
||||
//Don't show anything if player can't interact:
|
||||
if (!([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith))) exitWith {};
|
||||
|
||||
if (_errorCode == 0) then {
|
||||
_structuredOutputText = if (_errorCode == 0) then {
|
||||
format ["<t align='center'>%1</t><br/>", (localize "STR_ACE_MagazineRepack_RepackComplete")];
|
||||
} else {
|
||||
format ["<t align='center'>%1</t><br/>", (localize "STR_ACE_MagazineRepack_RepackInterrupted")];
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Array in format [time, isBullet, array of ammo counts] <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [5, [1,2,3,8]] call ace_magazinerepack_fnc_simulateRepackEvents =
|
||||
* [10, [1,2,3,8], false] call ace_magazinerepack_fnc_simulateRepackEvents =
|
||||
* [[1.5,true,[0,2,3,9]],[3.5,false,[0,2,3,9]],[5,true,[0,1,3,10]],[7,false,[0,1,3,10]],[8.5,true,[0,0,4,10]],[10.5,false,[0,0,4,10]]]
|
||||
*
|
||||
* Public: No
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
private ["_newMagFnc", "_time", "_events", "_swapAmmoFnc", "_ammoSwaped", "_lowIndex", "_highIndex", "_ammoToTransfer", "_ammoAvailable", "_ammoNeeded"];
|
||||
|
||||
PARAMS_2(_fullMagazineCount,_arrayOfAmmoCounts);
|
||||
PARAMS_3(_fullMagazineCount,_arrayOfAmmoCounts,_isBelt);
|
||||
|
||||
// Sort Ascending - Don't modify original
|
||||
_arrayOfAmmoCounts = (+_arrayOfAmmoCounts) call BIS_fnc_sortNum;
|
||||
@ -29,13 +29,23 @@ _newMagFnc = {
|
||||
_time = _time + GVAR(TimePerMagazine);
|
||||
_events pushBack [_time, false, +_arrayOfAmmoCounts];
|
||||
};
|
||||
_swapAmmoFnc = {
|
||||
for "_swapProgress" from 0 to (_ammoSwaped - 1) do {
|
||||
_time = _time + GVAR(TimePerAmmo);
|
||||
_arrayOfAmmoCounts set [_lowIndex, ((_arrayOfAmmoCounts select _lowIndex) - 1)];
|
||||
_arrayOfAmmoCounts set [_highIndex, ((_arrayOfAmmoCounts select _highIndex) + 1)];
|
||||
|
||||
_swapAmmoFnc = if (_isBelt) then {
|
||||
{
|
||||
_time = _time + GVAR(TimePerBeltLink);
|
||||
_arrayOfAmmoCounts set [_lowIndex, ((_arrayOfAmmoCounts select _lowIndex) - _ammoSwaped)];
|
||||
_arrayOfAmmoCounts set [_highIndex, ((_arrayOfAmmoCounts select _highIndex) + _ammoSwaped)];
|
||||
_events pushBack [_time, true, +_arrayOfAmmoCounts];
|
||||
};
|
||||
}
|
||||
} else {
|
||||
{
|
||||
for "_swapProgress" from 0 to (_ammoSwaped - 1) do {
|
||||
_time = _time + GVAR(TimePerAmmo);
|
||||
_arrayOfAmmoCounts set [_lowIndex, ((_arrayOfAmmoCounts select _lowIndex) - 1)];
|
||||
_arrayOfAmmoCounts set [_highIndex, ((_arrayOfAmmoCounts select _highIndex) + 1)];
|
||||
_events pushBack [_time, true, +_arrayOfAmmoCounts];
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
_lowIndex = 0;
|
||||
|
@ -17,18 +17,22 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_fullMagazineCount", "_startingAmmoCounts", "_simEvents", "_totalTime"];
|
||||
private ["_player", "_fullMagazineCount", "_startingAmmoCounts", "_simEvents", "_totalTime", "_magazineCfg"];
|
||||
|
||||
PARAMS_1(_magazineClassname);
|
||||
if (isNil "_magazineClassname" || {_magazineClassname == ""}) exitWith {ERROR("Bad Mag Classname");};
|
||||
|
||||
_unit = ACE_player;
|
||||
|
||||
[ACE_player] call EFUNC(common,goKneeling);
|
||||
call EFUNC(interaction,hideMenu);//ToDo: Self Interaction Integration
|
||||
|
||||
_magazineCfg = configfile >> "CfgMagazines" >> _magazineClassname;
|
||||
// Calculate actual ammo to transfer during repack
|
||||
_fullMagazineCount = getNumber (configfile >> "CfgMagazines" >> _magazineClassname >> "count");
|
||||
_fullMagazineCount = getNumber (_magazineCfg >> "count");
|
||||
//Is linked belt magazine:
|
||||
_isBelt = (isNumber (_magazineCfg >> "ACE_isBelt")) && {(getNumber (_magazineCfg >> "ACE_isBelt")) == 1};
|
||||
|
||||
|
||||
_player = ACE_player;
|
||||
|
||||
[_player] call EFUNC(common,goKneeling);
|
||||
|
||||
|
||||
_startingAmmoCounts = [];
|
||||
{
|
||||
@ -36,25 +40,25 @@ _startingAmmoCounts = [];
|
||||
if ((_xClassname == _magazineClassname) && {(_xCount != _fullMagazineCount) && {_xCount > 0}}) then {
|
||||
if (_xLoaded) then {
|
||||
//Try to Remove from weapon and add to inventory, otherwise ignore
|
||||
if (_unit canAdd _magazineClassname) then {
|
||||
if (_player canAdd _magazineClassname) then {
|
||||
switch (_xType) do {
|
||||
case (1): {_unit removePrimaryWeaponItem _magazineClassname;};
|
||||
case (2): {_unit removeHandgunItem _magazineClassname;};
|
||||
case (4): {_unit removeSecondaryWeaponItem _magazineClassname;};
|
||||
case (1): {_player removePrimaryWeaponItem _magazineClassname;};
|
||||
case (2): {_player removeHandgunItem _magazineClassname;};
|
||||
case (4): {_player removeSecondaryWeaponItem _magazineClassname;};
|
||||
default {ERROR("Loaded Location Invalid");};
|
||||
};
|
||||
_unit addMagazine [_magazineClassname, _xCount];
|
||||
_player addMagazine [_magazineClassname, _xCount];
|
||||
_startingAmmoCounts pushBack _xCount;
|
||||
};
|
||||
} else {
|
||||
_startingAmmoCounts pushBack _xCount;
|
||||
};
|
||||
};
|
||||
} forEach (magazinesAmmoFull _unit);
|
||||
} forEach (magazinesAmmoFull _player);
|
||||
|
||||
if ((count _startingAmmoCounts) < 2) exitwith {ERROR("Not Enough Mags to Repack");};
|
||||
|
||||
_simEvents = [_fullMagazineCount, _startingAmmoCounts] call FUNC(simulateRepackEvents);
|
||||
_simEvents = [_fullMagazineCount, _startingAmmoCounts, _isBelt] call FUNC(simulateRepackEvents);
|
||||
_totalTime = (_simEvents select ((count _simEvents) - 1) select 0);
|
||||
|
||||
[
|
||||
@ -63,5 +67,6 @@ _totalTime,
|
||||
{_this call FUNC(magazineRepackFinish)},
|
||||
{_this call FUNC(magazineRepackFinish)},
|
||||
(localize "STR_ACE_MagazineRepack_RepackingMagazine"),
|
||||
{_this call FUNC(magazineRepackProgress)}
|
||||
{_this call FUNC(magazineRepackProgress)},
|
||||
["isNotInside"]
|
||||
] call EFUNC(common,progressBar);
|
||||
|
@ -1,12 +1,11 @@
|
||||
class CfgMagazines {
|
||||
class CA_Magazine;
|
||||
class 150Rnd_762x51_Box : CA_Magazine {
|
||||
ACE_isBelt = 1;
|
||||
};
|
||||
|
||||
class CA_Magazine;
|
||||
class 150Rnd_762x51_Box : CA_Magazine {
|
||||
ACE_isBelt = 1;
|
||||
};
|
||||
|
||||
class 100Rnd_65x39_caseless_mag;
|
||||
class 200Rnd_65x39_cased_Box : 100Rnd_65x39_caseless_mag {
|
||||
ACE_isBelt = 1;
|
||||
};
|
||||
};
|
||||
class 100Rnd_65x39_caseless_mag;
|
||||
class 200Rnd_65x39_cased_Box : 100Rnd_65x39_caseless_mag {
|
||||
ACE_isBelt = 1;
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user