2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-07-14 14:16:53 +00:00
|
|
|
/*
|
|
|
|
* Author: KoffeinFlummi, commy2
|
2021-10-17 20:01:41 +00:00
|
|
|
* Handles all incoming damage for boxi
|
2016-07-14 14:16:53 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2017-06-08 13:31:51 +00:00
|
|
|
* HandleDamage EH <ARRAY>
|
2016-07-14 14:16:53 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* Damage to be inflicted. <NUMBER>
|
2016-07-14 14:16:53 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2021-10-17 20:01:41 +00:00
|
|
|
* _this call ace_cookoff_fnc_handleDamageBox
|
2016-07-14 14:16:53 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
params ["_vehicle", "", "_damage", "_source", "_ammo", "_hitIndex", "_shooter"];
|
2016-07-14 14:16:53 +00:00
|
|
|
|
|
|
|
// it's already dead, who cares?
|
|
|
|
if (damage _vehicle >= 1) exitWith {};
|
|
|
|
|
2019-11-05 17:55:15 +00:00
|
|
|
// If cookoff is disabled exit
|
|
|
|
if (_vehicle getVariable [QGVAR(enable), GVAR(enable)] in [0, false]) exitWith {};
|
|
|
|
|
2016-07-14 14:16:53 +00:00
|
|
|
// get hitpoint name
|
|
|
|
private _hitpoint = "#structural";
|
|
|
|
|
|
|
|
if (_hitIndex != -1) then {
|
2024-03-07 21:08:13 +00:00
|
|
|
_hitpoint = toLowerANSI ((getAllHitPointsDamage _vehicle param [0, []]) select _hitIndex);
|
2016-07-14 14:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// get change in damage
|
2017-10-10 14:39:59 +00:00
|
|
|
private _oldDamage = 0;
|
2016-07-14 14:16:53 +00:00
|
|
|
|
|
|
|
if (_hitpoint isEqualTo "#structural") then {
|
|
|
|
_oldDamage = damage _vehicle;
|
|
|
|
} else {
|
|
|
|
_oldDamage = _vehicle getHitIndex _hitIndex;
|
|
|
|
};
|
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
if (_hitpoint == "#structural" && _damage > 0.5) then {
|
|
|
|
// Almost always catch fire when hit by an explosive
|
|
|
|
if (IS_EXPLOSIVE_AMMO(_ammo)) then {
|
|
|
|
_vehicle call FUNC(cookOffBox);
|
2016-07-14 14:16:53 +00:00
|
|
|
} else {
|
2021-10-14 15:49:27 +00:00
|
|
|
// Need magazine to check for tracers
|
|
|
|
private _mag = "";
|
|
|
|
if (_source == _shooter) then {
|
|
|
|
_mag = currentMagazine _source;
|
|
|
|
} else {
|
|
|
|
_mag = _source currentMagazineTurret ([_shooter] call CBA_fnc_turretPath);
|
2016-07-14 14:16:53 +00:00
|
|
|
};
|
2021-10-14 15:49:27 +00:00
|
|
|
private _magCfg = configFile >> "CfgMagazines" >> _mag;
|
|
|
|
|
|
|
|
// Magazine could have changed during flight time (just ignore if so)
|
|
|
|
if (getText (_magCfg >> "ammo") == _ammo) then {
|
|
|
|
// If magazine's tracer density is high enough then low chance for cook off
|
|
|
|
private _tracers = getNumber (_magCfg >> "tracersEvery");
|
|
|
|
if (_tracers >= 1 && {_tracers <= 4}) then {
|
|
|
|
if (random 1 < _oldDamage*0.05) then {
|
|
|
|
_vehicle call FUNC(cookOffBox);
|
|
|
|
};
|
2017-11-30 22:54:47 +00:00
|
|
|
};
|
2016-07-14 14:16:53 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// prevent destruction, let cook-off handle it if necessary
|
2021-10-14 15:49:27 +00:00
|
|
|
_damage min 0.89
|
|
|
|
} else {
|
|
|
|
_damage
|
2016-10-06 20:37:38 +00:00
|
|
|
};
|