mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
c44a1e7ea7
* Cook-off improvements * More changes * Update fnc_getVehicleAmmo.sqf * Better engine fire placement * Update fnc_detonateAmmunition.sqf * Update XEH_postInit.sqf * Update fnc_getVehicleAmmo.sqf * Update events-framework.md * Various improvements * Separate effect handling * Tweaks * Update XEH_postInit.sqf * Prevent double ammo detonation * Fixed objects not being able to cook-off again * Added incendiary rounds as source of box cookoff * Converted enable setting to bool * Fixed brackets * Update fnc_cookOff.sqf * Update CfgEden.hpp * Removed GVAR(enable), added GVAR(enableFire) back * Update initSettings.inc.sqf * Update events-framework.md * Update addons/cookoff/functions/fnc_cookOffEffect.sqf * Restructured, redid API events * Fix effect for JIP, minor optimisations * Removed `cbaSettings_settingChanged` * Renamed variables, tweaked string table entries * Update fire damage #9991 * Capitalize comments again * Fix cookoff for very short durations and fix effect removal being too quick
82 lines
2.3 KiB
Plaintext
82 lines
2.3 KiB
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: KoffeinFlummi, commy2, johnb43
|
|
* Start fire in engine block of a car.
|
|
*
|
|
* Arguments:
|
|
* 0: Vehicle <OBJECT>
|
|
* 1: End time <NUMBER>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [cursorObject, CBA_missionTime + 10] 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 {
|
|
private _hitPoints = getAllHitPointsDamage _vehicle;
|
|
|
|
// 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]
|
|
};
|
|
|
|
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;
|
|
};
|
|
|
|
// Spawn smoke
|
|
_smoke = createVehicleLocal ["#particlesource", ASLToAGL getPosASL _vehicle, [], 0, "CAN_COLLIDE"];;
|
|
_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 {};
|
|
|
|
(_this select 1) call CBA_fnc_removePerFrameHandler;
|
|
|
|
deleteVehicle _smoke;
|
|
|
|
if (!isServer || {isNull _vehicle}) exitWith {};
|
|
|
|
// Reset variable, so engine can smoke again in the future
|
|
_vehicle setVariable [QGVAR(isEngineSmoking), nil, true];
|
|
|
|
private _jipID = _vehicle getVariable QGVAR(engineFireJipID);
|
|
|
|
if (isNil "_jipID") exitWith {};
|
|
|
|
_jipID call CBA_fnc_removeGlobalEventJIP;
|
|
|
|
_vehicle setVariable [QGVAR(engineFireJipID), nil];
|
|
}, 5, [_vehicle, _smoke, _endTime]] call CBA_fnc_addPerFrameHandler;
|