Skip to content

Commit

Permalink
Cookoff - Delay full vehicle destruction (acemod#9061)
Browse files Browse the repository at this point in the history
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
  • Loading branch information
3 people authored and blake8090 committed Aug 18, 2024
1 parent 6d3ee7a commit a203092
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions addons/cookoff/functions/fnc_cookOff.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,45 @@ if (_smokeDelayEnabled) then {
[{
params ["_vehicle", "_positions", "_intensity", "_ammoDetonationChance", "_detonateAfterCookoff", "_instigator", "_fireSource", "_canRing", "_canJet"];
_vehicle setVariable [QGVAR(intensity), _intensity];
private _smokeEffects = _vehicle getVariable [QGVAR(effects), []];

[{
params ["_args", "_pfh"];
_args params ["_vehicle", "_positions", "_ammoDetonationChance", "_detonateAfterCookoff", "_instigator", "_fireSource", "_canRing", "_canJet", "_smokeEffects"];
_args params ["_vehicle", "_positions", "_ammoDetonationChance", "_detonateAfterCookoff", "_instigator", "_fireSource", "_canRing", "_canJet"];
private _intensity = _vehicle getVariable [QGVAR(intensity), 0];
private _nextFlameTime = _vehicle getVariable [QGVAR(nextFlame), 0];
if (isNull _vehicle || {_intensity <= 1}) exitWith {
[QGVAR(cleanupEffects), [_vehicle, _smokeEffects]] call CBA_fnc_globalEvent;
_vehicle setVariable [QGVAR(isCookingOff), false, true];
[_pfh] call CBA_fnc_removePerFrameHandler;

if (GVAR(destroyVehicleAfterCookoff) || _detonateAfterCookoff) then {
_vehicle setDamage [1, true];
if (isNull _vehicle) exitWith {};

if (GVAR(destroyVehicleAfterCookoff) || _detonateAfterCookoff) exitWith {
if (_fireSource isEqualTo "") then {
_fireSource = selectRandom _positions;
};

if (_nextFlameTime <= 0) then {
_nextFlameTime = MIN_TIME_BETWEEN_FLAMES max random MAX_TIME_BETWEEN_FLAMES;
};

[{
params ["_vehicle", "_fireSource"];

if (isNull _vehicle) exitWith {};

[QGVAR(cleanupEffects), _vehicle] call CBA_fnc_globalEvent;
_vehicle setVariable [QGVAR(isCookingOff), false, true];

createVehicle ["ACE_ammoExplosionLarge", (_vehicle modelToWorld (_vehicle selectionPosition _fireSource)), [], 0 , "CAN_COLLIDE"];

_vehicle setDamage [1, true];
}, [_vehicle, _fireSource], _nextFlameTime] call CBA_fnc_waitAndExecute;
};

[QGVAR(cleanupEffects), _vehicle] call CBA_fnc_globalEvent;
_vehicle setVariable [QGVAR(isCookingOff), false, true];
};

private _lastFlameTime = _vehicle getVariable [QGVAR(lastFlame), 0];
private _nextFlameTime = _vehicle getVariable [QGVAR(nextFlame), 0];

// Wait until we are ready for the next flame
// dt = Tcurrent - Tlast
Expand Down Expand Up @@ -125,5 +146,5 @@ if (_smokeDelayEnabled) then {
_vehicle setVariable [QGVAR(nextExplosiveDetonation), random 60];
};
};
}, 0.25, [_vehicle, _positions, _ammoDetonationChance, _detonateAfterCookoff, _instigator, _fireSource, _canRing, _canJet, _smokeEffects]] call CBA_fnc_addPerFrameHandler
}, 0.25, [_vehicle, _positions, _ammoDetonationChance, _detonateAfterCookoff, _instigator, _fireSource, _canRing, _canJet]] call CBA_fnc_addPerFrameHandler
}, [_vehicle, _positions, _intensity, _ammoDetonationChance, _detonateAfterCookoff, _instigator, _fireSource, _canRing, _canJet], _delay] call CBA_fnc_waitAndExecute;

0 comments on commit a203092

Please sign in to comment.