mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Move carry mag getting code to function (#8888)
This commit is contained in:
parent
70641c39a1
commit
54c13c5f42
@ -19,6 +19,7 @@ PREP(assemble_pickupWeapon);
|
||||
PREP(canGetIn);
|
||||
PREP(getIn);
|
||||
|
||||
PREP(getCarryMagazine);
|
||||
PREP(proxyWeapon);
|
||||
|
||||
PREP(reload_actionsLoad);
|
||||
|
@ -31,13 +31,7 @@ private _allCarryMags = [];
|
||||
private _weapon = _x;
|
||||
{
|
||||
private _xMag = _x;
|
||||
private _carryMag = GVAR(vehicleMagCache) get _xMag;
|
||||
if (isNil "_carryMag") then {
|
||||
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
|
||||
_carryMag = configName (_groups param [0, configNull]);
|
||||
GVAR(vehicleMagCache) set [_x, _carryMag];
|
||||
TRACE_2("setting cache",_xMag,_carryMag);
|
||||
};
|
||||
private _carryMag = _xMag call FUNC(getCarryMagazine);
|
||||
if (_carryMag != "") then {
|
||||
_turretMagsCSW pushBackUnique _xMag;
|
||||
_allCarryMags pushBackUnique _carryMag;
|
||||
|
@ -41,13 +41,7 @@
|
||||
{
|
||||
_x params ["_xMag", "", "_xAmmo"];
|
||||
|
||||
private _carryMag = GVAR(vehicleMagCache) get _xMag;
|
||||
if (isNil "_carryMag") then {
|
||||
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
|
||||
_carryMag = configName (_groups param [0, configNull]);
|
||||
GVAR(vehicleMagCache) set [_xMag, _carryMag];
|
||||
TRACE_2("setting cache",_xMag,_carryMag);
|
||||
};
|
||||
private _carryMag = _xMag call FUNC(getCarryMagazine);
|
||||
if ((_xAmmo > 0) && {_carryMag != ""}) then {
|
||||
TRACE_2("Removing ammo",_xMag,_carryMag);
|
||||
[_player, _carryMag, _xAmmo] call FUNC(reload_handleReturnAmmo);
|
||||
|
28
addons/csw/functions/fnc_getCarryMagazine.sqf
Normal file
28
addons/csw/functions/fnc_getCarryMagazine.sqf
Normal file
@ -0,0 +1,28 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror, Dystopian
|
||||
* Gets magazine that the player can carry, suitable to vehicle magazine
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Vehicle Magazine <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Carry Magazine <STRING>
|
||||
*
|
||||
* Example:
|
||||
* "1Rnd_GAT_missiles" call ace_csw_fnc_getCarryMagazine
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_vehicleMag"];
|
||||
|
||||
private _carryMag = GVAR(vehicleMagCache) get _vehicleMag;
|
||||
if (isNil "_carryMag") then {
|
||||
private _groups = "getNumber (_x >> _vehicleMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
|
||||
_carryMag = configName (_groups param [0, configNull]);
|
||||
GVAR(vehicleMagCache) set [_vehicleMag, _carryMag];
|
||||
TRACE_2("setting cache",_vehicleMag,_carryMag);
|
||||
};
|
||||
|
||||
_carryMag
|
@ -60,14 +60,7 @@ private _cfgMagazines = configFile >> "CfgMagazines";
|
||||
|
||||
if ((_xAmmo > 0) && {!(_xMag in _handeledMagTypes)}) then {
|
||||
_handeledMagTypes pushBack _xMag;
|
||||
private _carryMag = GVAR(vehicleMagCache) get _xMag;
|
||||
|
||||
if (isNil "_carryMag") then {
|
||||
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
|
||||
_carryMag = configName (_groups param [0, configNull]);
|
||||
GVAR(vehicleMagCache) set [_xMag, _carryMag];
|
||||
TRACE_2("setting cache",_xMag,_carryMag);
|
||||
};
|
||||
private _carryMag = _xMag call FUNC(getCarryMagazine);
|
||||
if (_carryMag == "") exitWith {};
|
||||
|
||||
private _displayName = getText (_cfgMagazines >> _carryMag >> "displayName");
|
||||
|
@ -36,13 +36,7 @@ private _containerMagazineCount = [];
|
||||
{
|
||||
_x params ["_xMag", "_xTurret", "_xAmmo"];
|
||||
|
||||
private _carryMag = GVAR(vehicleMagCache) get _xMag;
|
||||
if (isNil "_carryMag") then {
|
||||
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
|
||||
_carryMag = configName (_groups param [0, configNull]);
|
||||
GVAR(vehicleMagCache) set [_xMag, _carryMag];
|
||||
TRACE_2("setting cache",_xMag,_carryMag);
|
||||
};
|
||||
private _carryMag = _xMag call FUNC(getCarryMagazine);
|
||||
if (_carryMag != "") then {
|
||||
if ((_desiredAmmo > 0) && {_loadedMagazineInfo isEqualTo []}) then {
|
||||
private _loadedMagAmmo = _desiredAmmo min _xAmmo;
|
||||
|
Loading…
Reference in New Issue
Block a user