ACE3/addons/cookoff/functions/fnc_handleDamageBox.sqf

73 lines
2.0 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2016-07-14 14:16:53 +00:00
/*
* Author: KoffeinFlummi, commy2
* Handles all incoming damage for boxi
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. <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
*/
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
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 {};
// 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 {
_hitpoint = toLower ((getAllHitPointsDamage _vehicle param [0, []]) select _hitIndex);
};
// get change in damage
private _oldDamage = 0;
2016-07-14 14:16:53 +00:00
if (_hitpoint isEqualTo "#structural") then {
_oldDamage = damage _vehicle;
} else {
_oldDamage = _vehicle getHitIndex _hitIndex;
};
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
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 {
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
// 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
};
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 _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);
};
};
2016-07-14 14:16:53 +00:00
};
};
// prevent destruction, let cook-off handle it if necessary
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
_damage min 0.89
} else {
_damage
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
};