This commit is contained in:
johnb432 2024-02-06 10:32:13 +01:00
parent 51aa46c81f
commit d277fa9f67
3 changed files with 22 additions and 7 deletions

View File

@ -17,13 +17,13 @@ if (isServer) then {
{ {
deleteVehicle _x; deleteVehicle _x;
} forEach ((_this select 0) getVariable [QGVAR(vehicleEffects), []]); } forEach ((_this select 0) getVariable [QGVAR(vehicleEffects), []]);
}, nil, nil, true] call CBA_fnc_addClassEventHandler; }, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
["ReammoBox_F", "Deleted", { ["ReammoBox_F", "Deleted", {
{ {
deleteVehicle _x; deleteVehicle _x;
} forEach ((_this select 0) getVariable [QGVAR(boxEffects), []]); } forEach ((_this select 0) getVariable [QGVAR(boxEffects), []]);
}, nil, nil, true] call CBA_fnc_addClassEventHandler; }, true, [], true] call CBA_fnc_addClassEventHandler;
[QGVAR(cleanupVehicleEffects), { [QGVAR(cleanupVehicleEffects), {
params ["_object"]; params ["_object"];
@ -45,21 +45,29 @@ if (isServer) then {
_object setVariable [QGVAR(boxEffects), nil]; _object setVariable [QGVAR(boxEffects), nil];
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
// Ammo box damage handling
["ReammoBox_F", "init", { ["ReammoBox_F", "init", {
// Calling this function inside curly brackets allows the usage of "exitWith", which would be broken with "HandleDamage" otherwise // Calling this function inside curly brackets allows the usage of "exitWith", which would be broken with "HandleDamage" otherwise
(_this select 0) addEventHandler ["HandleDamage", {_this call FUNC(handleDamageBox)}]; (_this select 0) addEventHandler ["HandleDamage", {_this call FUNC(handleDamageBox)}];
}, nil, nil, true] call CBA_fnc_addClassEventHandler; }, true, [], true] call CBA_fnc_addClassEventHandler;
// Secondary explosions // Vehicle ammo cook-off (secondary explosions)
["AllVehicles", "Killed", { ["AllVehicles", "Killed", {
if (!GVAR(enableAmmoCookoff) || {GVAR(ammoCookoffDuration) == 0}) exitWith {}; if (!GVAR(enableAmmoCookoff) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};
params ["_vehicle", "", "", "_useEffects"]; params ["_vehicle", "", "", "_useEffects"];
if (_useEffects && {_vehicle getVariable [QGVAR(enableAmmoCookoff), true]}) then { if (_useEffects && {_vehicle getVariable [QGVAR(enableAmmoCookoff), true]}) then {
[QGVAR(detonateAmmunition), [_vehicle, false, objNull, objNull, (random MAX_AMMO_DETONATION_START_DELAY) max MIN_AMMO_DETONATION_START_DELAY]] call CBA_fnc_serverEvent; // We don't need to pass source and instigator, as vehicle is already dead
[QGVAR(detonateAmmunition), [
_vehicle,
false,
objNull,
objNull,
random [MIN_AMMO_DETONATION_START_DELAY, (MIN_AMMO_DETONATION_START_DELAY + MAX_AMMO_DETONATION_START_DELAY) / 2, MAX_AMMO_DETONATION_START_DELAY]
] call CBA_fnc_serverEvent;
}; };
}, nil, ["CAManBase", "StaticWeapon"]] call CBA_fnc_addClassEventHandler; }, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
if (hasInterface) then { if (hasInterface) then {
// Plays a sound locally, so that different sounds can be used for various distances // Plays a sound locally, so that different sounds can be used for various distances

View File

@ -43,8 +43,11 @@ params [
["_maxIntensity", MAX_COOKOFF_INTENSITY] ["_maxIntensity", MAX_COOKOFF_INTENSITY]
]; ];
// Make sure it's a vehicle (important, because deleted EH is assigned to AllVehicles only in postInit)
if !(_vehicle isKindOf "AllVehicles") exitWith {}; if !(_vehicle isKindOf "AllVehicles") exitWith {};
if (_vehicle isKindOf "CAManBase" || {_vehicle isKindOf "StaticWeapon"}) exitWith {};
// Check if cook-off is disabled on vehicle specifically // Check if cook-off is disabled on vehicle specifically
if !(_vehicle getVariable [QGVAR(enable), true]) exitWith {}; if !(_vehicle getVariable [QGVAR(enable), true]) exitWith {};

View File

@ -18,12 +18,16 @@
*/ */
if (!isServer) exitWith {}; if (!isServer) exitWith {};
if (!GVAR(enableAmmobox) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};
params ["_box", ["_source", objNull], ["_instigator", objNull]]; params ["_box", ["_source", objNull], ["_instigator", objNull]];
// Make sure it's a box // Make sure it's a box (important, because deleted EH is assigned to ReammoBox_F only in postInit)
if !(_box isKindOf "ReammoBox_F") exitWith {}; if !(_box isKindOf "ReammoBox_F") exitWith {};
if !(_box getVariable [QGVAR(enableAmmoCookoff), true]) exitWith {};
// Allow only 1 cook-off per box at a time
if (_box getVariable [QGVAR(isCookingOff), false]) exitWith {}; if (_box getVariable [QGVAR(isCookingOff), false]) exitWith {};
_box setVariable [QGVAR(isCookingOff), true, true]; _box setVariable [QGVAR(isCookingOff), true, true];