mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Rearm - Add enable setting (#8067)
* Add enable setting * Update test * Optimize eden macro * Fix bad command name in eden * Apply suggestions from code review Co-authored-by: jonpas <jonpas33@gmail.com> * Cleanup unused argument * Handle RHS config * Optimize init function a little * Improve macro Co-authored-by: jonpas <jonpas33@gmail.com> * compats and leftovers * function header (sorry jonpas) * add enabled check to initSupplyVehicle * use toString * fix validate * inheritance cleanup --------- Co-authored-by: jonpas <jonpas33@gmail.com> Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
This commit is contained in:
parent
93520bdc9d
commit
0321545098
@ -1,6 +1,6 @@
|
||||
#define VANILLA_REARMCARGO (if (getAmmoCargo _this > 0) then {getAmmoCargo _this} else {-1})
|
||||
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
|
||||
#define DEFAULT_REARMCARGO GET_NUMBER(configOf _this >> QQGVAR(defaultSupply),-1)
|
||||
|
||||
#define DEFAULT_REARMCARGO GET_NUMBER(configOf _this >> 'GVAR(defaultSupply)',VANILLA_REARMCARGO)
|
||||
|
||||
class Cfg3DEN {
|
||||
class Object {
|
||||
|
@ -102,66 +102,51 @@ class CfgVehicles {
|
||||
|
||||
class Truck_03_base_F;
|
||||
class O_Truck_03_ammo_F: Truck_03_base_F {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class Truck_02_base_F;
|
||||
class Truck_02_Ammo_base_F: Truck_02_base_F {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class B_Truck_01_mover_F;
|
||||
class B_Truck_01_ammo_F: B_Truck_01_mover_F {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class B_APC_Tracked_01_base_F;
|
||||
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class Heli_Transport_04_base_F;
|
||||
class O_Heli_Transport_04_ammo_F: Heli_Transport_04_base_F {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class Pod_Heli_Transport_04_base_F;
|
||||
class Land_Pod_Heli_Transport_04_ammo_F: Pod_Heli_Transport_04_base_F {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class Slingload_01_Base_F;
|
||||
class B_Slingload_01_Ammo_F: Slingload_01_Base_F {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class ReammoBox_F;
|
||||
class NATO_Box_Base: ReammoBox_F {};
|
||||
class NATO_Box_Base;
|
||||
class Box_NATO_AmmoVeh_F: NATO_Box_Base {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
class EAST_Box_Base: ReammoBox_F {};
|
||||
class EAST_Box_Base;
|
||||
class Box_East_AmmoVeh_F: EAST_Box_Base {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
class IND_Box_Base: ReammoBox_F {};
|
||||
class IND_Box_Base;
|
||||
class Box_IND_AmmoVeh_F: IND_Box_Base {
|
||||
transportAmmo = 0;
|
||||
GVAR(defaultSupply) = 1200;
|
||||
};
|
||||
class Box_IND_AmmoOrd_F;
|
||||
class Box_IDAP_AmmoOrd_F: Box_IND_AmmoOrd_F {
|
||||
transportAmmo = 0; // not sure why this one has 240
|
||||
};
|
||||
|
||||
// Dummy Vehicles
|
||||
class ThingX;
|
||||
|
@ -1,18 +1,38 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
GVAR(hardpointGroupsCache) = [] call CBA_fnc_createNamespace;
|
||||
GVAR(configTypesAdded) = [];
|
||||
["CBA_settingsInitialized", {
|
||||
TRACE_2("settingsInit",GVAR(level),GVAR(supply));
|
||||
["LandVehicle", "Init", {_this call FUNC(initSupplyVehicle)}, true, ["StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
|
||||
["ReammoBox_F", "Init", {_this call FUNC(initSupplyVehicle)}, true, [], true] call CBA_fnc_addClassEventHandler;
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
GVAR(magazineNameCache) = [] call CBA_fnc_createNamespace;
|
||||
GVAR(originalMagazineNames) = [];
|
||||
|
||||
["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(initSupplyVehicle), {
|
||||
TRACE_1("initSupplyVehicle EH",_this); // Warning: this can run before settings are init
|
||||
[FUNC(initSupplyVehicle), _this] call EFUNC(common,runAfterSettingsInit);
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
["CBA_settingsInitialized", {
|
||||
TRACE_3("settingsInit",GVAR(enabled),GVAR(level),GVAR(supply));
|
||||
|
||||
// need these events before enabled check for zeus rearm
|
||||
[QGVAR(rearmEntireVehicleSuccessEH), LINKFUNC(rearmEntireVehicleSuccess)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(rearmEntireVehicleSuccessLocalEH), LINKFUNC(rearmEntireVehicleSuccessLocal)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(makeDummyEH), LINKFUNC(makeDummy)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(rearmSuccessEH), LINKFUNC(rearmSuccess)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(rearmSuccessLocalEH), LINKFUNC(rearmSuccessLocal)] call CBA_fnc_addEventHandler;
|
||||
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
|
||||
["AllVehicles", "Init", LINKFUNC(initSupplyVehicle), true, ["Man", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
|
||||
["ReammoBox_F", "Init", LINKFUNC(initSupplyVehicle), true, [], true] call CBA_fnc_addClassEventHandler;
|
||||
["House", "Init", LINKFUNC(initSupplyVehicle), true, [], true] call CBA_fnc_addClassEventHandler;
|
||||
|
||||
// placed in editor static objects don't trigger init
|
||||
{
|
||||
_x call FUNC(initSupplyVehicle);
|
||||
} forEach allMissionObjects "Static";
|
||||
|
||||
["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
|
||||
|
||||
["vehicle", {
|
||||
params ["_unit"];
|
||||
[_unit] call FUNC(dropAmmo);
|
||||
@ -22,12 +42,4 @@ if (isServer) then {
|
||||
addMissionEventHandler ["HandleDisconnect", {params ["_unit"]; [_unit] call FUNC(dropAmmo)}];
|
||||
};
|
||||
|
||||
[QGVAR(makeDummyEH), LINKFUNC(makeDummy)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(rearmEntireVehicleSuccessEH), LINKFUNC(rearmEntireVehicleSuccess)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(rearmEntireVehicleSuccessLocalEH), LINKFUNC(rearmEntireVehicleSuccessLocal)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(rearmSuccessEH), LINKFUNC(rearmSuccess)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(rearmSuccessLocalEH), LINKFUNC(rearmSuccessLocal)] call CBA_fnc_addEventHandler;
|
||||
|
||||
|
||||
GVAR(magazineNameCache) = [] call CBA_fnc_createNamespace;
|
||||
GVAR(originalMagazineNames) = [];
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
@ -5,10 +5,17 @@
|
||||
|
||||
private _testPass = true;
|
||||
|
||||
INFO("Showing CfgVehicles with vanilla transportAmmo");
|
||||
INFO("Showing CfgVehicles with vanilla transportAmmo and without XEH");
|
||||
|
||||
private _badCfgVehicles = toString {
|
||||
getNumber (_x >> "scope") == 2
|
||||
&& {getNumber (_x >> "transportAmmo") > 0}
|
||||
&& {!isText (_x >> "EventHandlers" >> "CBA_Extended_EventHandlers" >> "init")}
|
||||
};
|
||||
|
||||
{
|
||||
WARNING_2("Type [%1] needs config [transportAmmo: %2]", configName _x, getNumber (_x >> 'transportAmmo'));
|
||||
diag_log text format ["Class %1: %2 [%3] needs XEH", configName _x, configName inheritsFrom _x, configSourceMod _x];
|
||||
_testPass = false;
|
||||
} forEach (configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(getNumber (_x >> 'transportAmmo')) > 0}", true]);
|
||||
} forEach (_badCfgVehicles configClasses (configFile >> "CfgVehicles"));
|
||||
|
||||
_testPass
|
||||
|
@ -15,16 +15,26 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
if (!hasInterface) exitWith {}; // For now we just add actions, so no need non-clients
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
|
||||
params ["_vehicle"];
|
||||
|
||||
private _typeOf = typeOf _vehicle;
|
||||
private _configOf = configOf _vehicle;
|
||||
TRACE_2("initSupplyVehicle",_vehicle,_typeOf);
|
||||
|
||||
if (local _vehicle && {getAmmoCargo _vehicle > 0}) then {
|
||||
_vehicle setAmmoCargo 0;
|
||||
};
|
||||
|
||||
if (!hasInterface) exitWith {}; // For now we just add actions, so no need non-clients
|
||||
|
||||
if (!alive _vehicle) exitWith {};
|
||||
|
||||
private _configSupply = getNumber (_configOf >> QGVAR(defaultSupply));
|
||||
if (_configSupply == 0) then {
|
||||
_configSupply = getNumber (_config >> "transportAmmo");
|
||||
};
|
||||
private _isSupplyVehicle = _vehicle getVariable [QGVAR(isSupplyVehicle), false];
|
||||
private _oldRearmConfig = isClass (_configOf >> "ACE_Actions" >> "ACE_MainActions" >> QGVAR(takeAmmo));
|
||||
TRACE_3("",_configSupply,_isSupplyVehicle,_oldRearmConfig);
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Returns if vehicle or object is a rearm source.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: target <OBJECT>
|
||||
* 1: check for vanilla rearm vehicle <BOOL> (default: false)
|
||||
* 0: Target <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -15,10 +14,7 @@
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
params [
|
||||
["_target", objNull, [objNull]],
|
||||
["_testVanillaRearm", false, [false]]
|
||||
];
|
||||
params [["_target", objNull, [objNull]]];
|
||||
|
||||
if ((_target getVariable [QGVAR(currentSupply), 0]) < 0) exitWith {false};
|
||||
|
||||
@ -27,4 +23,4 @@ private _vanillaCargoConfig = getNumber (_vehCfg >> "transportAmmo");
|
||||
private _rearmCargoConfig = getNumber (_vehCfg >> QGVAR(defaultSupply));
|
||||
private _supplyVehicle = _target getVariable [QGVAR(isSupplyVehicle), false];
|
||||
|
||||
_rearmCargoConfig > 0 || {_supplyVehicle} || {_testVanillaRearm && _vanillaCargoConfig > 0}
|
||||
_rearmCargoConfig > 0 || {_supplyVehicle} || {_vanillaCargoConfig > 0}
|
||||
|
@ -41,7 +41,11 @@ private _currentSupply = if (_addToCurrent) then {
|
||||
|
||||
_source setVariable [QGVAR(currentSupply), _currentSupply + _rearmCargo, true];
|
||||
|
||||
private _rearmCargoConfig = getNumber (configOf _source >> QGVAR(defaultSupply));
|
||||
private _config = configOf _source;
|
||||
private _rearmCargoConfig = getNumber (_config >> QGVAR(defaultSupply));
|
||||
if (_rearmCargoConfig == 0) then {
|
||||
_rearmCargoConfig = getNumber (_config >> "transportAmmo");
|
||||
};
|
||||
|
||||
// initialize if it's not a config rearm vehicle
|
||||
if (!(_rearmCargoConfig > 0 && _source getVariable [QGVAR(isSupplyVehicle), false])) then {
|
||||
|
@ -1,7 +1,19 @@
|
||||
private _category = [LELSTRING(OptionsMenu,CategoryLogistics), LLSTRING(DisplayName)];
|
||||
|
||||
[
|
||||
QGVAR(enabled), "CHECKBOX",
|
||||
ELSTRING(common,Enabled),
|
||||
_category,
|
||||
true,
|
||||
true,
|
||||
{[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
|
||||
true
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
QGVAR(level), "LIST",
|
||||
[LSTRING(RearmSettings_level_DisplayName), LSTRING(RearmSettings_level_Description)],
|
||||
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize LSTRING(DisplayName)],
|
||||
_category,
|
||||
[[0,1,2],[LSTRING(RearmSettings_vehicle), LSTRING(RearmSettings_magazine), LSTRING(RearmSettings_caliber)],0], // [values, titles, defaultIndex]
|
||||
true, // isGlobal
|
||||
{[QGVAR(level), _this] call EFUNC(common,cbaSettings_settingChanged)}
|
||||
@ -10,7 +22,7 @@
|
||||
[
|
||||
QGVAR(supply), "LIST",
|
||||
[LSTRING(RearmSettings_supply_DisplayName), LSTRING(RearmSettings_supply_Description)],
|
||||
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize LSTRING(DisplayName)],
|
||||
_category,
|
||||
[[0,1,2],[LSTRING(RearmSettings_unlimited), LSTRING(RearmSettings_limited), LSTRING(RearmSettings_magazineSupply)],0], // [values, titles, defaultIndex]
|
||||
true, // isGlobal
|
||||
{[QGVAR(supply), _this] call EFUNC(common,cbaSettings_settingChanged)}
|
||||
@ -18,8 +30,8 @@
|
||||
|
||||
[
|
||||
QGVAR(distance), "SLIDER",
|
||||
[localize LSTRING(RearmSettings_distance_DisplayName), localize LSTRING(RearmSettings_distance_Description)],
|
||||
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize LSTRING(DisplayName)],
|
||||
[LLSTRING(RearmSettings_distance_DisplayName), LLSTRING(RearmSettings_distance_Description)],
|
||||
_category,
|
||||
[10, 50, 20, 0],
|
||||
true, // isGlobal
|
||||
{[QGVAR(supply), _this] call EFUNC(common,cbaSettings_settingChanged)}
|
||||
|
@ -160,7 +160,6 @@ class CfgVehicles {
|
||||
};
|
||||
|
||||
class gm_ural4320_reammo_base: gm_ural4320_base {
|
||||
transportAmmo = 0;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@ class CfgPatches {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_csw", "ace_explosives", "ace_rearm", "ace_refuel", "ace_repair", "gm_core"};
|
||||
requiredAddons[] = {"ace_csw", "ace_explosives", "ace_refuel", "ace_repair", "gm_core"};
|
||||
author = ECSTRING(common,ACETeam);
|
||||
authors[] = {"sancron", "nomisum"};
|
||||
url = ECSTRING(main,URL);
|
||||
|
@ -161,8 +161,7 @@ class CfgVehicles {
|
||||
EGVAR(repair,canRepair) = 1;
|
||||
};
|
||||
class RHS_Ural_Ammo_Base: RHS_Ural_Base {
|
||||
transportAmmo = 0;
|
||||
ace_rearm_defaultSupply = 1200;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class rhs_kraz255b1_base;
|
||||
@ -183,14 +182,12 @@ class CfgVehicles {
|
||||
};
|
||||
|
||||
class rhs_gaz66_ammo_base: rhs_gaz66_vmf {
|
||||
transportAmmo = 0;
|
||||
ace_rearm_defaultSupply = 1200;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class rhs_kamaz5350;
|
||||
class rhs_kamaz5350_ammo_base: rhs_kamaz5350 {
|
||||
transportAmmo = 0;
|
||||
ace_rearm_defaultSupply = 1200;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class MRAP_02_base_F;
|
||||
|
@ -7,7 +7,7 @@ class CfgPatches {
|
||||
units[] = {};
|
||||
weapons[] = {QGVAR(2b14_carry), QGVAR(nsv_carry), QGVAR(kord_carry), QGVAR(ags30_carry), QGVAR(spg9_carry), QGVAR(spg9m_carry), QGVAR(metis_carry), QGVAR(kornet_carry)};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_explosives", "ace_csw", "ace_rearm", "ace_refuel", "ace_repair", "rhs_main_loadorder"};
|
||||
requiredAddons[] = {"ace_explosives", "ace_csw", "ace_refuel", "ace_repair", "rhs_main_loadorder"};
|
||||
author = ECSTRING(common,ACETeam);
|
||||
authors[] = {"Ruthberg", "GitHawk", "BaerMitUmlaut", "commy2", "Skengman2"};
|
||||
url = ECSTRING(main,URL);
|
||||
|
@ -198,7 +198,6 @@ class CfgVehicles {
|
||||
};
|
||||
class rhsusf_M1078A1P2_B_M2_fmtv_usarmy;
|
||||
class rhsusf_M1078A1R_SOV_M2_D_fmtv_socom: rhsusf_M1078A1P2_B_M2_fmtv_usarmy {
|
||||
transportAmmo = 0;
|
||||
EGVAR(rearm,defaultSupply) = 800;
|
||||
transportFuel = 0;
|
||||
EGVAR(refuel,hooks)[] = {{1.1,0.9,-1.2}};
|
||||
@ -210,19 +209,16 @@ class CfgVehicles {
|
||||
class rhsusf_HEMTT_A4_base: Truck_01_base_F {};
|
||||
class rhsusf_M977A4_usarmy_wd: rhsusf_HEMTT_A4_base {};
|
||||
class rhsusf_M977A4_AMMO_usarmy_wd: rhsusf_M977A4_usarmy_wd {
|
||||
transportAmmo = 0;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class rhsusf_M977A4_BKIT_usarmy_wd: rhsusf_M977A4_usarmy_wd {};
|
||||
class rhsusf_M977A4_AMMO_BKIT_usarmy_wd: rhsusf_M977A4_BKIT_usarmy_wd {
|
||||
transportAmmo = 0;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
class rhsusf_M977A4_BKIT_M2_usarmy_wd: rhsusf_M977A4_usarmy_wd {};
|
||||
class rhsusf_M977A4_AMMO_BKIT_M2_usarmy_wd: rhsusf_M977A4_BKIT_M2_usarmy_wd {
|
||||
transportAmmo = 0;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
@ -268,7 +264,6 @@ class CfgVehicles {
|
||||
|
||||
class rhsusf_m113_usarmy: rhsusf_m113tank_base {};
|
||||
class rhsusf_m113_usarmy_supply: rhsusf_m113_usarmy {
|
||||
transportAmmo = 0;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@ class CfgPatches {
|
||||
units[] = {};
|
||||
weapons[] = {QGVAR(m252_carry), QGVAR(m2_carry), QGVAR(mk19_carry), QGVAR(tow_carry)};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_explosives", "ace_javelin", "ace_rearm", "ace_refuel", "ace_repair", "ace_csw", "rhsusf_main_loadorder"};
|
||||
requiredAddons[] = {"ace_explosives", "ace_javelin", "ace_refuel", "ace_repair", "ace_csw", "rhsusf_main_loadorder"};
|
||||
author = ECSTRING(common,ACETeam);
|
||||
authors[] = {"Ruthberg", "GitHawk", "BaerMitUmlaut", "Fyuran"};
|
||||
url = ECSTRING(main,URL);
|
||||
@ -23,4 +23,3 @@ class CfgPatches {
|
||||
#include "CfgVehicles.hpp"
|
||||
#include "CfgGlasses.hpp"
|
||||
#include "CfgMagazineGroups.hpp"
|
||||
|
||||
|
@ -16,7 +16,6 @@ class vn_wheeled_m54_repair_base: vn_wheeled_m54_03_base {
|
||||
};
|
||||
class vn_wheeled_m54_01_base;
|
||||
class vn_wheeled_m54_ammo_base: vn_wheeled_m54_01_base {
|
||||
transportAmmo = 0;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
@ -41,7 +40,6 @@ class vn_wheeled_z157_repair_base: vn_wheeled_z157_base {
|
||||
};
|
||||
class vn_wheeled_z157_01_base;
|
||||
class vn_wheeled_z157_ammo_base: vn_wheeled_z157_01_base {
|
||||
transportAmmo = 0;
|
||||
EGVAR(rearm,defaultSupply) = 1200;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user