Skip to content

Commit

Permalink
RF Compat - Extinguish vehicle cook-offs and burning units (#10604)
Browse files Browse the repository at this point in the history
* Extinguish cookoffs and burning units

* Introduce new variable to interrupt cook-off

Avoids needing to toggle the enableAmmoCookoff variable

* Moved to RF compat
  • Loading branch information
johnb432 authored Dec 27, 2024
1 parent 43a29f2 commit 3479df8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions addons/compat_rf/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};
27 changes: 27 additions & 0 deletions addons/compat_rf/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "script_component.hpp"

// Compat for ace_cookoff: Extinguish cook-off
if (["ace_cookoff"] call EFUNC(common,isModLoaded)) then {
[missionNamespace, "lxRF_water_droppedOnVehicle", {
params ["_vehicle"];

if (_vehicle getVariable [QEGVAR(cookoff,isAmmoDetonating), false]) then {
_vehicle setVariable [QEGVAR(cookoff,interruptAmmoCookoff), true, true];
};
}] call BIS_fnc_addScriptedEventHandler;
};

// Compat for ace_fire: Extinguish burning units
if (["ace_fire"] call EFUNC(common,isModLoaded)) then {
["CBA_settingsInitialized", {
if (!EGVAR(fire,enabled)) exitWith {};

[missionNamespace, "lxRF_water_droppedOnUnit", {
params ["_unit"];

if (_unit call EFUNC(fire,isBurning)) then {
_unit setVariable [QEGVAR(fire,intensity), nil, true];
};
}] call BIS_fnc_addScriptedEventHandler;
}] call CBA_fnc_addEventHandler;
};
1 change: 1 addition & 0 deletions addons/compat_rf/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class CfgPatches {
};
};

#include "CfgEventHandlers.hpp"
#include "CfgWeapons.hpp"
#include "CfgVehicles.hpp"
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ if (
{private _posASL = getPosWorld _object; surfaceIsWater _posASL && {(_posASL select 2) < 0}} || // Underwater is not very reliable, so use model center instead
{GVAR(ammoCookoffDuration) == 0} ||
{!([GVAR(enableAmmoCookoff), GVAR(enableAmmobox)] select (_object isKindOf "ReammoBox_F"))} ||
{!(_object getVariable [QGVAR(enableAmmoCookoff), true])}
{!(_object getVariable [QGVAR(enableAmmoCookoff), true])} ||
{_object getVariable [QGVAR(interruptAmmoCookoff), false]} // QGVAR(interruptAmmoCookoff) stops the current cook-off (allowing future ones), whereas QGVAR(enableAmmoCookoff) disables it entirely
) exitWith {
// Box cook-off fire ends after the ammo has detonated (vehicle cook-off fire does not depend on the ammo detonation)
if (_object isKindOf "ReammoBox_F") then {
Expand All @@ -63,6 +64,7 @@ if (
// Reset variables, so the object can detonate its ammo again
_object setVariable [QGVAR(cookoffMagazines), nil];
_object setVariable [QGVAR(virtualMagazines), nil];
_object setVariable [QGVAR(interruptAmmoCookoff), nil, true];
_object setVariable [QGVAR(isAmmoDetonating), nil, true];

// If done, destroy the object if necessary
Expand Down

0 comments on commit 3479df8

Please sign in to comment.