ACE3/addons/fire/functions/fnc_burn.sqf

59 lines
1.8 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
2024-02-05 12:17:33 +00:00
* Author: johnb43
* Makes a unit catch fire. Only call from targeted events, is applied globally.
*
* Arguments:
2024-02-05 12:17:33 +00:00
* 0: Unit <OBJECT>
* 1: Intensity of fire <NUMBER>
* 2: Instigator of fire <OBJECT> (default: objNull)
*
* Return Value:
* None
*
* Example:
* [player, 4] call ace_fire_fnc_burn
*
* Public: No
*/
2024-02-03 21:25:15 +00:00
if (!EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [LINKFUNC(burn), _this];
2024-01-26 17:38:26 +00:00
};
if (!GVAR(enabled)) exitWith {};
2024-01-26 17:38:26 +00:00
params ["_unit", "_intensity", ["_instigator", objNull]];
2024-02-05 12:17:33 +00:00
if (BURN_MIN_INTENSITY > _intensity) exitWith {};
2024-01-26 17:38:26 +00:00
// Check if unit is remote (objNull is remote)
if (!local _unit) exitWith {};
2024-01-26 17:38:26 +00:00
// Check if the unit can burn (takes care of spectators and curators)
2024-02-05 12:17:33 +00:00
if (getNumber (configOf _unit >> "isPlayableLogic") == 1 || {!(_unit isKindOf "CAManBase")}) exitWith {};
2024-02-05 12:17:33 +00:00
// If unit is invulnerable, don't burn the unit
2024-01-26 17:38:26 +00:00
if !(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), true]}) exitWith {};
2024-02-13 00:13:45 +00:00
private _eyePos = eyePos _unit;
2024-02-05 12:17:33 +00:00
2024-02-13 00:13:45 +00:00
// Check if unit is mostly submerged in water
if (surfaceIsWater _eyePos && {(_eyePos select 2) < 0.1}) exitWith {};
2024-02-05 12:17:33 +00:00
// If unit is already burning, update intensity, but don't add another PFH
if (_unit call FUNC(isBurning)) exitWith {
_unit setVariable [QGVAR(intensity), _intensity, true];
};
2024-01-26 17:38:26 +00:00
_unit setVariable [QGVAR(intensity), _intensity, true];
2024-02-05 12:17:33 +00:00
// Fire simulation (objects are handled differently)
[QGVAR(burnSimulation), [_unit, _instigator], _unit] call CBA_fnc_targetEvent;
2024-01-26 17:38:26 +00:00
// Spawn effects for unit
2024-02-05 12:17:33 +00:00
private _burnEffectsJipID = [QGVAR(burnEffects), _unit] call CBA_fnc_globalEventJIP;
2024-01-26 17:38:26 +00:00
[_burnEffectsJipID, _unit] call CBA_fnc_removeGlobalEventJIP;
_unit setVariable [QGVAR(jipID), _burnEffectsJipID, true];