ACE3/addons/cookoff/functions/fnc_handleDamageBox.sqf

63 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

#include "..\script_component.hpp"
2016-07-14 14:16:53 +00:00
/*
* Author: KoffeinFlummi, commy2, johnb43
* 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:
* 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
*/
// If cookoff for boxes is disabled, exit
if (!GVAR(enableAmmobox) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};
2016-07-14 14:16:53 +00:00
params ["_box", "", "_damage", "_source", "_ammo", "", "_instigator", "_hitPoint"];
2016-07-14 14:16:53 +00:00
if (!local _box) exitWith {};
// If it's already dead, ignore
if (!alive _box) exitWith {};
2016-07-14 14:16:53 +00:00
if !(_box getVariable [QGVAR(enableAmmoCookoff), true]) exitWith {};
if !(_hitPoint == "" && {_damage > 0.5}) exitWith {}; // "" means structural damage
2016-07-14 14:16:53 +00:00
private _ammoConfig = _ammo call CBA_fnc_getObjectConfig;
2016-07-14 14:16:53 +00:00
// 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 {
[QGVAR(cookOffBoxServer), [_box, _source, _instigator]] call CBA_fnc_serverEvent;
2016-07-14 14:16:53 +00:00
} else {
// There is a small chance of cooking a box off if it's shot by tracer ammo
if (random 1 >= _damage * 0.05) exitWith {};
2016-07-14 14:16:53 +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 {
_source currentMagazineTurret (_source unitTurret _instigator)
};
Add Vehicle Damage (ACE2 port) & Enhance Cook-Off (#7565) * Initital port of ACE2 Vehicle Damage * Add fire damage and burning people * Migrate vehicle damge stuff from cookoff. Change cookoff function to enhance effect. * Minor tweaks * Add incendiary values to all applicable ammunition. Add engine fire/smoke if hit enough * Handle car damage more elegantly. * Added ability to create fire sources arbitrarily * tweaks * Add chance to detonate after cookoff * disable compile cache * Move blown-off turret config to vehicle damage. Add settings inititalized EH for initializing off settings * tabs->spaces * Various code improvements * Change to count loop for deleting effects * update addon requirements * remove vanilla config requirements * Add RHS compatability * RHS compat. Various QOL fixes/changes * Various tweaks to compats and code. * High-Explosive damage tweak * Change how penetration is calculated for parts * Fix RHS compat * Create setting for flare effect * increase burning scream sounds * swap out file name for snake_case * move incendiary values out of vehicle damage. remove medical dependency * vehicle_dammage - update all refs to snake * sqf fixes * fix fire string package caps * fix pboprefix * Default setting to on * Add variables to enable/disable ring fire to avoid goofy looking vehicles. Enhance how particles are cleaned up. Remove advanced penetration simulation. Change how fire intensity is calculated. Add setting to "disable" vehicle after cookoff * Fix bug where event handler wasn't giving the damage last. * change to snake * fix build errors * Fix UBC * Fix Order of Operations * avoid O^2 events * Make sure that no damage processing happens on dead units * Change some if statements * Keep track of player's death to stop various things * add quotes to right middle wheen * Add VD documentation * fire docs * Code quality fixes * Clarify documentation * define IDD * switch global -> server * Add newline between header and first code statement * stop the dead from suffering Its hard to tell when a unit is dead or in spectator, so check the config of the unit to determine it. * Add settings to disable cook-off effects * Delete effects if vehicle is deleted before cookoff occurs. Don't cookoff player ammo. Throw weapon better * Move fire into own PR * fix tabs and macro * Shuffle crew indices so that a random person is first on the list to be injured each time * fix effects not clearing Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2021-10-14 15:49:27 +00:00
private _configMagazine = configFile >> "CfgMagazines" >> _magazine;
// Magazine could have changed during flight time (just ignore if so)
if (getText (_configMagazine >> "ammo") == _ammo) then {
// If magazine's tracer density is high enough then low chance for cook off
private _tracers = getNumber (_configMagazine >> "tracersEvery");
if (_tracers >= 1 && {_tracers <= 4}) then {
[QGVAR(cookOffBoxServer), [_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
};
// Prevent destruction, let cook-off handle it if necessary
_damage min 0.89