ACE3/addons/cookoff/functions/fnc_handleDamageBox.sqf

58 lines
1.8 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2016-07-14 14:16:53 +00:00
/*
* Author: KoffeinFlummi, commy2, johnb43
2024-01-27 08:14:10 +00:00
* Handles all incoming damage for boxes.
2016-07-14 14:16:53 +00:00
*
* Arguments:
* HandleDamage EH <ARRAY>
2016-07-14 14:16:53 +00:00
*
* Return Value:
2024-01-27 08:14:10 +00:00
* Damage to be inflicted (can be nil) <NUMBER>
2016-07-14 14:16:53 +00:00
*
* Example:
* _this call ace_cookoff_fnc_handleDamageBox
2016-07-14 14:16:53 +00:00
*
* Public: No
*/
2024-02-06 00:06:30 +00:00
params ["_box", "", "_damage", "_source", "_ammo", "", "_instigator", "_hitPoint"];
2016-07-14 14:16:53 +00:00
2024-01-27 08:14:10 +00:00
if (!local _box) exitWith {};
2016-07-14 14:16:53 +00:00
2024-01-27 08:14:10 +00:00
// If it's already dead, ignore
2024-02-06 00:06:30 +00:00
if (!alive _box) exitWith {};
2024-01-27 08:14:10 +00:00
// If cookoff for boxes is disabled, exit
if (!GVAR(enableAmmobox) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};
if !(_box getVariable [QGVAR(enableAmmoCookoff), true]) exitWith {};
2024-02-06 00:06:30 +00:00
if !(_hitPoint == "" && {_damage > 0.5}) exitWith {}; // "" means structural damage
2016-07-14 14:16:53 +00:00
private _ammoConfig = _ammo call CBA_fnc_getObjectConfig;
// Catch fire when hit by an explosive or incendiary round
if ((getNumber (_ammoConfig >> "explosive") >= 0.5) || {getNumber (_ammoConfig >> QEGVAR(vehicle_damage,incendiary)) > random 1}) then {
2024-01-27 08:14:10 +00:00
[QGVAR(cookOffBox), [_box, _source, _instigator]] call CBA_fnc_serverEvent;
2016-07-14 14:16:53 +00:00
} else {
2024-01-27 08:14:10 +00:00
// There is a small chance of cooking a box off if it's shot by tracer ammo
2024-02-06 00:06:30 +00:00
if (random 1 >= _damage * 0.05) exitWith {};
2016-07-14 14:16:53 +00:00
2024-01-27 08:14:10 +00:00
// Need magazine to check for tracers
private _magazine = if (_source == _instigator) then {
currentMagazine _source
2016-07-14 14:16:53 +00:00
} else {
2024-02-06 00:06:30 +00:00
_source currentMagazineTurret (_source unitTurret _instigator)
2024-01-27 08:14:10 +00:00
};
private _configMagazine = configFile >> "CfgMagazines" >> _magazine;
// Magazine could have changed during flight time (just ignore if so)
2024-04-02 22:38:46 +00:00
if (_ammo getShotInfo 4 && {getText (_configMagazine >> "ammo") == _ammo)} then { // 4 = shownTracer
[QGVAR(cookOffBox), [_box, _source, _instigator]] call CBA_fnc_serverEvent;
2016-07-14 14:16:53 +00:00
};
Add ammo cookoff (#4376) * Add Ammo cookoff * Remove tabs * Add initial ammo box cook-off Does not include a fire effect, mostly just a proof of concept. Should probably also add further potential cook-off conditons (if hit by tracer for example). * Add burning effects to ammo box cook off - Add burning effect while ammo box is cooking off - Add setting to enable/disable ammo boxes cooking off - Clear magazine cargo while box is burning Currently the box will burn for 60 seconds hardcoded, this is to allow time for the ammunition to cook off (since boxes sink into the ground and dissapear when destroyed). Perhaps we can implement a way to burn until all ammo is expended. * Improve ammo cookoff * Integrate ammo cookoff with the incendiary grenade * Disable ammo cook off underwater * Optimize fnc_detonateAmmunition I say optimize, the only real performance optimization is using `vectorMultiply`. The rest is readability optimization though! * Improve ammo box cook off - Remove unnecessary light source (fire particles provide lighting) - Add randomness to cook off time - Cook off begins with fire effect rather than smoke * Add tracer induced ammo box cook off Due to limitations in the way arma handles tracer rounds (there's no way to check if an individual projectile is a tracer), only magazines with a high enough tracer density (at least 1 in 4) can cause cook off this way. However this is deemed an acceptable approximation since the chance of this happening should be quite low anyway. * Decrease amount of explosions from ammo cookoff * Add is local check for remote event
2016-10-06 20:37:38 +00:00
};
2024-01-27 08:14:10 +00:00
// Prevent destruction, let cook-off handle it if necessary
_damage min 0.89