ACE3/addons/cookoff/XEH_postInit.sqf

101 lines
4.0 KiB
Plaintext
Raw Permalink Normal View History

2016-07-14 14:16:53 +00:00
#include "script_component.hpp"
[QGVAR(cookOffBoxLocal), LINKFUNC(cookOffBoxLocal)] call CBA_fnc_addEventHandler;
[QGVAR(cookOffLocal), LINKFUNC(cookOffLocal)] call CBA_fnc_addEventHandler;
[QGVAR(engineFireLocal), LINKFUNC(engineFireLocal)] call CBA_fnc_addEventHandler;
[QGVAR(smoke), LINKFUNC(smoke)] call CBA_fnc_addEventHandler;
if (isServer) then {
[QGVAR(cookOffBoxServer), LINKFUNC(cookOffBoxServer)] call CBA_fnc_addEventHandler;
[QGVAR(cookOffServer), LINKFUNC(cookOffServer)] call CBA_fnc_addEventHandler;
[QGVAR(detonateAmmunitionServer), LINKFUNC(detonateAmmunitionServer)] call CBA_fnc_addEventHandler;
[QGVAR(engineFireServer), LINKFUNC(engineFireServer)] call CBA_fnc_addEventHandler;
};
// Handle cleaning up effects when objects are deleted mid cook-off
["AllVehicles", "Deleted", {
{
deleteVehicle _x;
} forEach ((_this select 0) getVariable [QGVAR(effects), []]);
}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
["ReammoBox_F", "Deleted", {
{
deleteVehicle _x;
} forEach ((_this select 0) getVariable [QGVAR(effects), []]);
}, true, [], true] call CBA_fnc_addClassEventHandler;
// Raised when the flames have subsided or after the ammo of a box has finished cooking off
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
[QGVAR(cleanupEffects), {
params ["_object"];
{
deleteVehicle _x;
} forEach (_object getVariable [QGVAR(effects), []]);
_object setVariable [QGVAR(effects), nil];
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
}] call CBA_fnc_addEventHandler;
// Ammo box damage handling
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
["ReammoBox_F", "init", {
// Calling this function inside curly brackets allows the usage of "exitWith", which would be broken with "HandleDamage" otherwise
(_this select 0) addEventHandler ["HandleDamage", {_this call FUNC(handleDamageBox)}];
}, true, [], true] call CBA_fnc_addClassEventHandler;
// Vehicle ammo cook-off (secondary explosions)
["AllVehicles", "Killed", {
if (!GVAR(enableAmmoCookoff) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};
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
params ["_vehicle", "", "", "_useEffects"];
if (_useEffects && {_vehicle getVariable [QGVAR(enableAmmoCookoff), true]}) then {
// We don't need to pass source and instigator, as vehicle is already dead
[QGVAR(detonateAmmunitionServer), [
_vehicle,
false,
objNull,
objNull,
random [MIN_AMMO_DETONATION_START_DELAY, (MIN_AMMO_DETONATION_START_DELAY + MAX_AMMO_DETONATION_START_DELAY) / 2, MAX_AMMO_DETONATION_START_DELAY]
]] call CBA_fnc_serverEvent;
};
}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
if (hasInterface) then {
// Plays a sound locally, so that different sounds can be used for various distances
[QGVAR(playCookoffSound), {
params ["_object", "_sound"];
if (isNull _object) exitWith {};
private _distance = _object distance (positionCameraToWorld [0, 0, 0]);
TRACE_2("",_object,_sound);
// 3 classes of distances: close, mid and far, each having different sound files
private _classDistance = switch (true) do {
case (_distance < DISTANCE_CLOSE): {"close"};
case (_distance < DISTANCE_MID): {"mid"};
default {"far"};
};
_sound = format [QGVAR(%1_%2_%3), _sound, _classDistance, floor (random 3) + 1];
TRACE_1("",_sound);
// Allows other mods to change sounds for cook-off
_sound = getArray (configFile >> "CfgSounds" >> _sound >> "sound");
if (_sound isEqualTo []) exitWith {};
_sound params ["_sound", "_volume", "_pitch", "_maxDistance"];
if (_distance > _maxDistance) exitWith {};
// Make sure file exists, so RPT isn't spammed with non-existent entry errors
if (!fileExists _sound) exitWith {};
// Obeys speed of sound and takes doppler effects into account
playSound3D [_sound, objNull, false, getPosASL _object, _volume, _pitch + (random 0.2) - 0.1, _maxDistance, 0, true];
}] call CBA_fnc_addEventHandler;
};