ACE3/addons/vehicle_damage/functions/fnc_handleCookoff.sqf
johnb432 c44a1e7ea7
Cookoff - Mini-Rewrite (#9758)
* 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
2024-06-05 12:36:39 -07:00

60 lines
2.2 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: tcvm
* Checks hitpoint damage and determines if a vehicle should cookoff.
*
* Arguments:
* 0: The vehicle <OBJECT>
* 1: Chance of fire <NUMBER>
* 2: Intensity of cookoff <NUMBER>
* 3: Person who instigated cookoff <OBJECT> (default: objNull)
* 4: Part of vehicle which got hit <STRING> (default: "")
* 5: Whether or not the vehicle can spawn ring-fire effect <BOOL> (default: false)
* 6: Can Jet <BOOL> (default: true)
*
* Return Value:
* If cooked off
*
* Example:
* [tank2, 0.1, 5] call ace_vehicle_damage_fnc_handleCookoff;
*
* Public: No
*/
params ["_vehicle", "_chanceOfFire", "_intensity", ["_injurer", objNull], ["_hitPart", ""], ["_canRing", false], ["_canJet", true]];
// Ignore if the vehicle is already cooking off
if (_vehicle getVariable [QEGVAR(cookoff,isCookingOff), false]) exitWith {true};
_chanceOfFire = _chanceOfFire * EGVAR(cookoff,probabilityCoef);
if (_chanceOfFire >= random 1) exitWith {
private _configOf = configOf _vehicle;
private _fireDetonateChance = [_configOf >> QGVAR(detonationDuringFireProb), "number", 0] call CBA_fnc_getConfigEntry;
if (_canRing) then {
_canRing = ([_configOf >> QGVAR(canHaveFireRing), "number", 0] call CBA_fnc_getConfigEntry) == 1;
};
if (_canJet) then {
_canJet = ([_configOf >> QEGVAR(cookoff,canHaveFireJet), "number", 1] call CBA_fnc_getConfigEntry) == 1;
};
private _delayWithSmoke = _chanceOfFire < random 1;
private _detonateAfterCookoff = (_fireDetonateChance / 4) > random 1;
private _source = "";
if (_hitPart == "engine") then {
_source = ["hit_engine_point", "HitPoints"];
};
[QEGVAR(cookOff,cookOffServer), [_vehicle, _intensity, _injurer, _injurer, _delayWithSmoke, _fireDetonateChance, _detonateAfterCookoff, _source, _canRing, _canJet]] call CBA_fnc_serverEvent;
LOG_4("Cooking-off [%1] with a chance-of-fire [%2] - Delayed Smoke | Detonate after cookoff [%3 | %4]",_vehicle,_chanceOfFire,_delayWithSmoke,_detonateAfterCookoff);
[_vehicle] spawn FUNC(abandon);
LOG_1("[%1] is on fire is bailing",_vehicle);
true
};
LOG_2("[%1] No Cook-off - Chance of fire [%2]",_vehicle,_chanceOfFire);
false