ACE3/addons/cookoff/functions/fnc_engineFireLocal.sqf

80 lines
2.2 KiB
Plaintext
Raw Normal View History

2024-01-27 08:14:10 +00:00
#include "..\script_component.hpp"
/*
* Author: KoffeinFlummi, commy2
* Start fire in engine block of a car.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* cursorObject call ace_cookoff_fnc_engineFireLocal
*
* Public: No
*/
params ["_vehicle", "_endTime"];
// For JIP players and if the time wasn't set properly
if (_endTime < CBA_missionTime) exitWith {};
private _smoke = objNull;
if (hasInterface) then {
2024-02-03 18:23:49 +00:00
private _hitPoints = getAllHitPointsDamage _vehicle;
2024-01-27 08:14:10 +00:00
2024-02-03 18:23:49 +00:00
// Get hitpoint for engine
private _index = (_hitPoints select 0) findIf {_x == "hitengine"};
// Get corresponding selection
private _position = if (_index != -1) then {
_vehicle selectionPosition [(_hitPoints select 1) select _index, "HitPoints", "AveragePoint"]
} else {
[0, 0, 0]
2024-01-27 08:14:10 +00:00
};
2024-02-03 18:23:49 +00:00
if (_position isEqualTo [0, 0, 0]) then {
// Get offset for engine smoke if there is one
private _offset = getArray (configOf _vehicle >> QGVAR(engineSmokeOffset));
if (_offset isEqualTo []) then {
_offset = [0, 0, 0];
};
_position = [
0,
(boundingBoxReal _vehicle select 1 select 1) - 2,
(boundingBoxReal _vehicle select 0 select 2) + 2
] vectorAdd _offset;
};
2024-01-27 08:14:10 +00:00
// Spawn smoke
2024-02-05 16:31:27 +00:00
_smoke = createVehicleLocal ["#particlesource", ASLToAGL getPosASL _vehicle, [], 0, "CAN_COLLIDE"];;
2024-01-27 08:14:10 +00:00
_smoke setParticleClass "ObjectDestructionSmoke1_2Smallx";
_smoke attachTo [_vehicle, _position];
};
[{
(_this select 0) params ["_vehicle", "_smoke", "_endTime"];
if (!alive _vehicle || {_vehicle getHitPointDamage "HitEngine" < 0.9} || {CBA_missionTime >= _endTime}) exitWith {
2024-02-05 16:31:27 +00:00
(_this select 1) call CBA_fnc_removePerFrameHandler;
2024-01-27 08:14:10 +00:00
deleteVehicle _smoke;
2024-02-03 18:23:49 +00:00
if (isNull _vehicle || !isServer) exitWith {};
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
_vehicle setVariable [QGVAR(isEngineSmoking), nil];
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
private _jipID = _vehicle getVariable QGVAR(engineFireJipID);
if (isNil "_jipID") exitWith {};
_jipID call CBA_fnc_removeGlobalEventJIP;
_vehicle setVariable [QGVAR(engineFireJipID), nil];
2024-01-27 08:14:10 +00:00
};
}, 5, [_vehicle, _smoke, _endTime]] call CBA_fnc_addPerFrameHandler;