Small cleanup and tweaks

This commit is contained in:
johnb432 2023-12-22 23:03:33 +01:00
parent 301489bc58
commit da210890ac
6 changed files with 20 additions and 14 deletions

View File

@ -7,16 +7,16 @@ INFO("Checking static weapons");
private _staticWeaponConfigs = configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(configName _x) isKindOf 'StaticWeapon'}", true]; private _staticWeaponConfigs = configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(configName _x) isKindOf 'StaticWeapon'}", true];
private _staticPublic = _staticWeaponConfigs select {(getNumber (_x >> "scope")) == 2}; private _staticPublic = _staticWeaponConfigs select {(getNumber (_x >> "scope")) == 2};
INFO_2("Static Weapons [%1] - CSW Enabled [%2]",count _staticPublic, {(getNumber (_x >> "ace_csw" >> "enabled")) == 1} count _staticPublic); INFO_2("Static Weapons [%1] - CSW Enabled [%2]",count _staticPublic,{(getNumber (_x >> QUOTE(ADDON) >> "enabled")) == 1} count _staticPublic);
INFO("------ Checking static weapons inheritance ------"); INFO("------ Checking static weapons inheritance ------");
private _explicitBases = []; private _explicitBases = [];
private _inherited = []; private _inherited = [];
{ {
private _config = _x; private _config = _x;
private _configEnabled = (getNumber (_config >> "ace_csw" >> "enabled")) == 1; private _configEnabled = (getNumber (_config >> QUOTE(ADDON) >> "enabled")) == 1;
if (_configEnabled) then { if (_configEnabled) then {
private _configExplicit = (count configProperties [_config, "configName _x == 'ace_csw'", false]) == 1; private _configExplicit = (count configProperties [_config, toString {configName _x == QUOTE(ADDON)}, false]) == 1;
if (_configExplicit) then { if (_configExplicit) then {
_explicitBases pushBack (configName _config); _explicitBases pushBack (configName _config);
_inherited pushBack []; _inherited pushBack [];
@ -43,8 +43,8 @@ private _inherited = [];
INFO("------ Logging static magazines with no carry version -------"); INFO("------ Logging static magazines with no carry version -------");
private _hash = createHashMap; private _hash = createHashMap;
// private _logAll = true; // logs all possible weapon magazines (even if not used in a static weapon) private _logAll = false; // logs all possible weapon magazines (even if not used in a static weapon) when set to true
private _logAll = false;
{ {
private _vehicleType = configName _x; private _vehicleType = configName _x;
private _turretConfig = [_vehicleType, [0]] call CBA_fnc_getTurret; private _turretConfig = [_vehicleType, [0]] call CBA_fnc_getTurret;
@ -69,7 +69,7 @@ private _logAll = false;
{ {
//IGNORE_PRIVATE_WARNING ["_x", "_y"]; //IGNORE_PRIVATE_WARNING ["_x", "_y"];
INFO_2("[%1] has no carry varient - Used in %2",_x,_y); INFO_2("[%1] has no carry variant - Used in %2",_x,_y);
} forEach _hash; } forEach _hash;
INFO("------ End -------"); INFO("------ End -------");

View File

@ -40,7 +40,7 @@
_cswTripod setVariable [QGVAR(secondaryWeaponMagazine), _secondaryWeaponMagazine]; _cswTripod setVariable [QGVAR(secondaryWeaponMagazine), _secondaryWeaponMagazine];
}; };
if (!GVAR(defaultAssemblyMode)) then { if (!GVAR(defaultAssemblyMode)) then {
[_cswTripod, "disableWeaponAssembly", "ace_csw", true] call EFUNC(common,statusEffect_set); [_cswTripod, "disableWeaponAssembly", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
}; };
private _posATL = _player getRelPos [2, 0]; private _posATL = _player getRelPos [2, 0];

View File

@ -7,7 +7,7 @@
* 0: CSW <OBJECT> * 0: CSW <OBJECT>
* *
* Return Value: * Return Value:
* Compatible Magazines <HashMap> * Compatible Magazines <HASHMAP>
* Magazine classname <STRING> * Magazine classname <STRING>
* Nothing * Nothing
* *
@ -23,7 +23,7 @@ if !((typeOf _csw) in GVAR(initializedStaticTypes)) exitWith {createHashMap};
// fast exit for csw with single weapon, most common scenario // fast exit for csw with single weapon, most common scenario
if (count allTurrets _csw isEqualTo 1 && {count weapons _csw isEqualTo 1}) exitWith { if (count allTurrets _csw isEqualTo 1 && {count weapons _csw isEqualTo 1}) exitWith {
GVAR(compatibleMagsCache) get ((weapons _csw) select 0) // return +(GVAR(compatibleMagsCache) get ((weapons _csw) select 0)) // return
}; };
private _weapons = []; private _weapons = [];
@ -44,4 +44,4 @@ private _carryMagazines = createHashMap; // hashmap for constant lookup
_carryMagazines merge [GVAR(compatibleMagsCache) get _weapon, true]; _carryMagazines merge [GVAR(compatibleMagsCache) get _weapon, true];
} forEach _weapons; } forEach _weapons;
_carryMagazines // return +_carryMagazines // return

View File

@ -10,7 +10,7 @@
* 3: Include CSW crew <BOOL> (default: true) * 3: Include CSW crew <BOOL> (default: true)
* *
* Return Value: * Return Value:
* Available Ammo <HashMap> * Available Ammo <HASHMAP>
* Magazine classname <STRING> * Magazine classname <STRING>
* Total Ammo <NUMBER> * Total Ammo <NUMBER>
* *

View File

@ -23,7 +23,7 @@ TRACE_4("proxyWeapon",_vehicle,_turret,_needed,_emptyWeapon);
if (_vehicle getVariable [format [QGVAR(proxyHandled_%1), _turret], false]) exitWith { TRACE_1("already handled",typeOf _vehicle); }; if (_vehicle getVariable [format [QGVAR(proxyHandled_%1), _turret], false]) exitWith { TRACE_1("already handled",typeOf _vehicle); };
private _proxyWeapon = getText (configOf _vehicle >> "ace_csw" >> "proxyWeapon"); private _proxyWeapon = getText (configOf _vehicle >> QUOTE(ADDON) >> "proxyWeapon");
TRACE_2("",typeOf _vehicle,_proxyWeapon); TRACE_2("",typeOf _vehicle,_proxyWeapon);
if (_proxyWeapon isEqualTo "") exitWith {}; if (_proxyWeapon isEqualTo "") exitWith {};

View File

@ -47,12 +47,18 @@ if (_canAdd) then {
TRACE_2("Setting mag ammo",_loadedMag,_currentAmmo); TRACE_2("Setting mag ammo",_loadedMag,_currentAmmo);
// _vehicle setMagazineTurretAmmo [_loadedMag, _currentAmmo, _turret]; // _vehicle setMagazineTurretAmmo [_loadedMag, _currentAmmo, _turret];
// setMagazineTurretAmmo is broken on split locality, use setAmmo for now (this may not work for multi turret vehicles) // setMagazineTurretAmmo is broken on split locality and if there are multiple magazines of the same class (valid 20/12/2023, Arma 2.14)
// use setAmmo for now (this may not work for multi turret vehicles)
private _weapon = (_vehicle weaponsTurret _turret) param [0, ""]; private _weapon = (_vehicle weaponsTurret _turret) param [0, ""];
TRACE_3("setAmmo",_vehicle,_weapon, _currentAmmo); TRACE_3("setAmmo",_vehicle,_weapon, _currentAmmo);
_vehicle setAmmo [_weapon, _currentAmmo]; _vehicle setAmmo [_weapon, _currentAmmo];
private _currentAmmo = _vehicle magazineTurretAmmo [_loadedMag, _turret]; private _currentAmmo = _vehicle magazineTurretAmmo [_loadedMag, _turret];
if ((_weapon == "") || {_currentAmmo != _currentAmmo}) then { ERROR_1("failed to setAmmo - %1", _this); }; if ((_weapon == "") || {_currentAmmo != _currentAmmo}) then {
// Don't remove ammo if it failed to load
_ammoRemaining = _ammoRemaining + _ammoUsed;
ERROR_1("failed to setAmmo - %1",_this);
};
} else { } else {
if (_loadedMag != "") then { if (_loadedMag != "") then {
TRACE_1("Removing emtpy mag",_loadedMag); TRACE_1("Removing emtpy mag",_loadedMag);