Cookoff - Delay full vehicle destruction (#9061)

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
This commit is contained in:
JonBons 2024-05-24 18:06:33 -05:00 committed by GitHub
parent d7c1984a5a
commit be77ef233e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
@ -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;