Cookoff - Fix enable setting (#8649)

This commit is contained in:
Filip Maciejewski 2021-10-30 00:20:02 +02:00 committed by GitHub
parent 0ddb7185c0
commit 58f43288ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,8 @@ params ["_vehicle", "_intensity", ["_instigator", objNull], ["_smokeDelayEnabled
if (GVAR(enable) == 0) exitWith {};
if !(GVAR(enableFire)) exitWith {};
if (_vehicle getVariable [QGVAR(enable), GVAR(enable)] in [0, false]) exitWith {};
if (_vehicle getVariable [QGVAR(enable), GVAR(enable)] isEqualTo 2 && {fullCrew [_vehicle, "", false] findIf {isPlayer (_x select 0)} == -1}) exitWith {};
// exit if cook-off enabled only for players and no players in vehicle crew found
if (_vehicle getVariable [QGVAR(enable), GVAR(enable)] isEqualTo 1 && {fullCrew [_vehicle, "", false] findIf {isPlayer (_x select 0)} == -1}) exitWith {};
TRACE_8("cooking off",_vehicle,_intensity,_instigator,_smokeDelayEnabled,_ammoDetonationChance,_detonateAfterCookoff,_fireSource,_canRing);
@ -39,7 +40,7 @@ if (_positions isEqualTo []) then {
if (_pos isEqualTo [0, 0, 0]) exitWith {};
_positions pushBack _x;
} forEach DEFAULT_COMMANDER_HATCHES;
if (_positions isEqualTo []) then {
_positions pushBack "#noselection";
};
@ -64,15 +65,15 @@ if (_smokeDelayEnabled) then {
[QGVAR(cleanupEffects), [_vehicle, _smokeEffects]] call CBA_fnc_globalEvent;
_vehicle setVariable [QGVAR(isCookingOff), false, true];
[_pfh] call CBA_fnc_removePerFrameHandler;
if (_detonateAfterCookoff) then {
_vehicle setDamage 1;
};
};
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
// dt >= Tnext
@ -81,39 +82,39 @@ if (_smokeDelayEnabled) then {
if (!_ring && _intensity >= 2) then {
_ring = (0.7 > random 1);
};
if !(_canRing) then {
_ring = false;
};
private _time = linearConversion [0, 10, _intensity, 3, 20] + random COOKOFF_TIME;
if (_fireSource isEqualTo "") then {
_fireSource = selectRandom _positions;
};
[QGVAR(cookOffEffect), [_vehicle, true, _ring, _time, _fireSource]] call CBA_fnc_globalEvent;
_intensity = _intensity - (0.5 max random 1);
_vehicle setVariable [QGVAR(intensity), _intensity];
_vehicle setVariable [QGVAR(lastFlame), CBA_missionTime];
_vehicle setVariable [QGVAR(nextFlame), _time + (MIN_TIME_BETWEEN_FLAMES max random MAX_TIME_BETWEEN_FLAMES)];
{
[QEGVAR(fire,burn), [_x, _intensity * 1.5, _instigator]] call CBA_fnc_globalEvent;
} forEach crew _vehicle
};
if (_ammoDetonationChance > random 1) then {
private _lastExplosiveDetonationTime = _vehicle getVariable [QGVAR(lastExplosiveDetonation), 0];
private _nextExplosiveDetonation = _vehicle getVariable [QGVAR(nextExplosiveDetonation), 0];
if ((CBA_missionTime - _lastExplosiveDetonationTime) > _nextExplosiveDetonation) then {
if (_fireSource isEqualTo "") then {
_fireSource = selectRandom _positions;
};
createVehicle ["ACE_ammoExplosionLarge", (_vehicle modelToWorld (_vehicle selectionPosition _fireSource)), [], 0 , "CAN_COLLIDE"];
_vehicle setVariable [QGVAR(lastExplosiveDetonation), CBA_missionTime];
_vehicle setVariable [QGVAR(nextExplosiveDetonation), random 60];
};