diff --git a/addons/overheating/ACE_Settings.hpp b/addons/overheating/ACE_Settings.hpp index 6cff3268ff..abf08c9874 100644 --- a/addons/overheating/ACE_Settings.hpp +++ b/addons/overheating/ACE_Settings.hpp @@ -38,4 +38,10 @@ class ACE_Settings { displayName = CSTRING(unJamFailChance_displayName); description = CSTRING(unJamFailChance_description); }; + class GVAR(enabled) { + typeName = "BOOL"; + value = 1; + displayName = CSTRING(enabled_displayName); + description = CSTRING(enabled_description); + }; }; diff --git a/addons/overheating/CfgEventHandlers.hpp b/addons/overheating/CfgEventHandlers.hpp index 492230513f..5da5fd0dc2 100644 --- a/addons/overheating/CfgEventHandlers.hpp +++ b/addons/overheating/CfgEventHandlers.hpp @@ -16,11 +16,3 @@ class Extended_PostInit_EventHandlers { init = QUOTE( call COMPILE_FILE(XEH_postInit) ); }; }; - -class Extended_Take_EventHandlers { - class CAManBase { - class GVAR(UnjamReload) { - clientTake = QUOTE( _this call FUNC(handleTakeEH) ); - }; - }; -}; diff --git a/addons/overheating/CfgVehicles.hpp b/addons/overheating/CfgVehicles.hpp index 0a86535231..23a2b613f5 100644 --- a/addons/overheating/CfgVehicles.hpp +++ b/addons/overheating/CfgVehicles.hpp @@ -6,7 +6,7 @@ class CfgVehicles { class ACE_Equipment { class GVAR(UnJam) { displayName = CSTRING(UnjamWeapon); - condition = QUOTE( [_player] call FUNC(canUnjam) ); + condition = QUOTE( GVAR(enabled) && {[_player] call FUNC(canUnjam)} ); exceptions[] = {"isNotInside", "isNotSitting"}; statement = QUOTE( [ARR_2(_player, currentMuzzle _player)] call FUNC(clearJam); ); showDisabled = 0; @@ -15,7 +15,7 @@ class CfgVehicles { }; class GVAR(SwapBarrel) { displayName = CSTRING(SwapBarrel); - condition = QUOTE( 'ACE_SpareBarrel' in magazines _player && {getNumber (configFile >> 'CfgWeapons' >> currentWeapon _player >> 'ACE_Overheating_allowSwapBarrel') == 1} ); + condition = QUOTE( GVAR(enabled) && {'ACE_SpareBarrel' in magazines _player} && {getNumber (configFile >> 'CfgWeapons' >> currentWeapon _player >> 'ACE_Overheating_allowSwapBarrel') == 1} ); statement = QUOTE( [ARR_3(_player, _player, currentWeapon _player)] call FUNC(swapBarrel); ); showDisabled = 0; priority = 3; @@ -23,7 +23,7 @@ class CfgVehicles { }; class GVAR(CheckTemperature) { displayName = CSTRING(CheckTemperatureShort); - condition = "switch (currentWeapon _player) do {case (''): {false}; case (primaryWeapon _player); case (handgunWeapon _player): {true}; default {false}}"; + condition = "ace_overheating_enabled && {switch (currentWeapon _player) do {case (''): {false}; case (primaryWeapon _player); case (handgunWeapon _player): {true}; default {false}}}"; exceptions[] = {"isNotInside", "isNotSitting"}; statement = QUOTE( [ARR_3(_player, _player, currentWeapon _player)] call FUNC(checkTemperature); ); showDisabled = 0; @@ -32,7 +32,7 @@ class CfgVehicles { }; class GVAR(CheckTemperatureSpareBarrels) { displayName = CSTRING(CheckTemperatureSpareBarrelsShort); - condition = QUOTE( 'ACE_SpareBarrel' in magazines _player); + condition = QUOTE( GVAR(enabled) && {'ACE_SpareBarrel' in magazines _player}); exceptions[] = {"isNotInside", "isNotSitting"}; statement = QUOTE( [_player] call FUNC(checkSpareBarrelsTemperatures); ); showDisabled = 0; @@ -46,13 +46,13 @@ class CfgVehicles { class ACE_Weapon { class GVAR(SwapBarrel) { displayName = CSTRING(SwapBarrel); - condition = QUOTE( 'ACE_SpareBarrel' in magazines _player && {getNumber (configFile >> 'CfgWeapons' >> currentWeapon _target >> 'ACE_Overheating_allowSwapBarrel') == 1} ); + condition = QUOTE( GVAR(enabled) && {'ACE_SpareBarrel' in magazines _player} && {getNumber (configFile >> 'CfgWeapons' >> currentWeapon _target >> 'ACE_Overheating_allowSwapBarrel') == 1} ); statement = QUOTE([ARR_3(_player, _target, currentWeapon _target)] call FUNC(swapBarrelAssistant);); icon = QUOTE(PATHTOF(UI\spare_barrel_ca.paa)); }; class GVAR(CheckTemperature) { displayName = CSTRING(CheckTemperatureShort); - condition = "switch (currentWeapon _target) do {case (''): {false}; case (primaryWeapon _target); case (handgunWeapon _target): {true}; default {false}}"; + condition = "ace_overheating_enabled && {switch (currentWeapon _target) do {case (''): {false}; case (primaryWeapon _target); case (handgunWeapon _target): {true}; default {false}}}"; exceptions[] = {"isNotInside", "isNotSitting"}; statement = QUOTE( [ARR_3(_player, _target, currentWeapon _target)] call FUNC(checkTemperature); ); icon = QUOTE(PATHTOF(UI\temp_ca.paa)); diff --git a/addons/overheating/XEH_postInit.sqf b/addons/overheating/XEH_postInit.sqf index 96d518ac9f..e4935b8831 100644 --- a/addons/overheating/XEH_postInit.sqf +++ b/addons/overheating/XEH_postInit.sqf @@ -1,62 +1,69 @@ // by esteldunedain #include "script_component.hpp" -if (isServer) then { - GVAR(pseudoRandomList) = []; - // Construct a list of pseudo random 2D vectors - for "_i" from 0 to 30 do { - GVAR(pseudoRandomList) pushBack [-1 + random 2, -1 + random 2]; - }; - publicVariable QGVAR(pseudoRandomList); +if (hasInterface) then { + // Add keybinds + ["ACE3 Weapons", QGVAR(unjamWeapon), localize LSTRING(UnjamWeapon), + { + // Conditions: canInteract + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; + // Conditions: specific - // Keep track of the temperature of stored spare barrels - GVAR(storedSpareBarrels) = [] call CBA_fnc_hashCreate; + if !(GVAR(enabled) && {[ACE_player] call FUNC(canUnjam)}) exitWith {false}; - // Install event handlers for spare barrels - ["spareBarrelsSendTemperatureHint", FUNC(sendSpareBarrelsTemperaturesHint)] call EFUNC(common,addEventHandler); - ["spareBarrelsLoadCoolest", FUNC(loadCoolestSpareBarrel)] call EFUNC(common,addEventHandler); - - // Schedule cool down calculation of stored spare barrels - [] call FUNC(updateSpareBarrelsTemperaturesThread); + // Statement + [ACE_player, currentMuzzle ACE_player, false] call FUNC(clearJam); + true + }, + {false}, + [19, [true, false, false]], false] call CBA_fnc_addKeybind; //SHIFT + R Key }; - -if !(hasInterface) exitWith {}; - -GVAR(cacheWeaponData) = call CBA_fnc_createNamespace; -GVAR(cacheAmmoData) = call CBA_fnc_createNamespace; -GVAR(cacheSilencerData) = call CBA_fnc_createNamespace; - -// Add keybinds -["ACE3 Weapons", QGVAR(unjamWeapon), localize LSTRING(UnjamWeapon), -{ - // Conditions: canInteract - if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; - // Conditions: specific - - if !([ACE_player] call FUNC(canUnjam)) exitWith {false}; - - // Statement - [ACE_player, currentMuzzle ACE_player, false] call FUNC(clearJam); - true -}, -{false}, -[19, [true, false, false]], false] call CBA_fnc_addKeybind; //SHIFT + R Key - - -// Schedule cool down calculation of player weapons at (infrequent) regular intervals -[] call FUNC(updateTemperatureThread); - ["SettingsInitialized", { + TRACE_1("SettingsInitialized eh", GVAR(enabled)); + if (!GVAR(enabled)) exitWith {}; + + if (isServer) then { + GVAR(pseudoRandomList) = []; + // Construct a list of pseudo random 2D vectors + for "_i" from 0 to 30 do { + GVAR(pseudoRandomList) pushBack [-1 + random 2, -1 + random 2]; + }; + publicVariable QGVAR(pseudoRandomList); + + // Keep track of the temperature of stored spare barrels + GVAR(storedSpareBarrels) = [] call CBA_fnc_hashCreate; + + // Install event handlers for spare barrels + ["spareBarrelsSendTemperatureHint", FUNC(sendSpareBarrelsTemperaturesHint)] call EFUNC(common,addEventHandler); + ["spareBarrelsLoadCoolest", FUNC(loadCoolestSpareBarrel)] call EFUNC(common,addEventHandler); + + // Schedule cool down calculation of stored spare barrels + [] call FUNC(updateSpareBarrelsTemperaturesThread); + }; + + if !(hasInterface) exitWith {}; + + GVAR(cacheWeaponData) = call CBA_fnc_createNamespace; + GVAR(cacheAmmoData) = call CBA_fnc_createNamespace; + GVAR(cacheSilencerData) = call CBA_fnc_createNamespace; + + //Add Take EH (for reload) + ["CAManBase", "Take", {_this call FUNC(handleTakeEH);}] call CBA_fnc_addClassEventHandler; + // Register fire event handler ["firedPlayer", DFUNC(firedEH)] call EFUNC(common,addEventHandler); // Only add eh to non local players if dispersion is enabled if (GVAR(overheatingDispersion)) then { ["firedPlayerNonLocal", DFUNC(firedEH)] call EFUNC(common,addEventHandler); }; -}] call EFUNC(common,addEventHandler); -// Install event handler to display temp when a barrel was swapped -["showWeaponTemperature", DFUNC(displayTemperature)] call EFUNC(common,addEventHandler); -// Install event handler to initiate an assisted barrel swap -["initiateSwapBarrelAssisted", DFUNC(swapBarrel)] call EFUNC(common,addEventHandler); + // Schedule cool down calculation of player weapons at (infrequent) regular intervals + [] call FUNC(updateTemperatureThread); + + // Install event handler to display temp when a barrel was swapped + ["showWeaponTemperature", DFUNC(displayTemperature)] call EFUNC(common,addEventHandler); + // Install event handler to initiate an assisted barrel swap + ["initiateSwapBarrelAssisted", DFUNC(swapBarrel)] call EFUNC(common,addEventHandler); + +}] call EFUNC(common,addEventHandler); diff --git a/addons/overheating/functions/fnc_swapBarrelCallback.sqf b/addons/overheating/functions/fnc_swapBarrelCallback.sqf index 339b6627b1..403989deca 100644 --- a/addons/overheating/functions/fnc_swapBarrelCallback.sqf +++ b/addons/overheating/functions/fnc_swapBarrelCallback.sqf @@ -15,7 +15,7 @@ * * Public: No */ -#define DEBUG_MODE_FULL +// #define DEBUG_MODE_FULL #include "script_component.hpp" params ["_assistant", "_gunner", "_weapon"]; diff --git a/addons/overheating/functions/fnc_updateSpareBarrelsTemperaturesThread.sqf b/addons/overheating/functions/fnc_updateSpareBarrelsTemperaturesThread.sqf index 852cb1c580..d6b74f6769 100644 --- a/addons/overheating/functions/fnc_updateSpareBarrelsTemperaturesThread.sqf +++ b/addons/overheating/functions/fnc_updateSpareBarrelsTemperaturesThread.sqf @@ -13,7 +13,7 @@ * * Public: No */ -#define DEBUG_MODE_FULL +// #define DEBUG_MODE_FULL #include "script_component.hpp" private _pairs = []; diff --git a/addons/overheating/stringtable.xml b/addons/overheating/stringtable.xml index 3eb67701de..e49ad433fc 100644 --- a/addons/overheating/stringtable.xml +++ b/addons/overheating/stringtable.xml @@ -282,7 +282,15 @@ Very Hot Spare Barrel/s - Extremele Hot Spare Barrel/s + Extremely Hot Spare Barrel/s + + + Overheating Enabled + Überhitzen Aktiviert + Activada Sobrecalentamiento + + + Master enable for the overheating/jamming module \ No newline at end of file