mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
c44a1e7ea7
* Cook-off improvements * More changes * Update fnc_getVehicleAmmo.sqf * Better engine fire placement * Update fnc_detonateAmmunition.sqf * Update XEH_postInit.sqf * Update fnc_getVehicleAmmo.sqf * Update events-framework.md * Various improvements * Separate effect handling * Tweaks * Update XEH_postInit.sqf * Prevent double ammo detonation * Fixed objects not being able to cook-off again * Added incendiary rounds as source of box cookoff * Converted enable setting to bool * Fixed brackets * Update fnc_cookOff.sqf * Update CfgEden.hpp * Removed GVAR(enable), added GVAR(enableFire) back * Update initSettings.inc.sqf * Update events-framework.md * Update addons/cookoff/functions/fnc_cookOffEffect.sqf * Restructured, redid API events * Fix effect for JIP, minor optimisations * Removed `cbaSettings_settingChanged` * Renamed variables, tweaked string table entries * Update fire damage #9991 * Capitalize comments again * Fix cookoff for very short durations and fix effect removal being too quick
101 lines
4.0 KiB
Plaintext
101 lines
4.0 KiB
Plaintext
#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(engineFire)] 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
|
|
[QGVAR(cleanupEffects), {
|
|
params ["_object"];
|
|
|
|
{
|
|
deleteVehicle _x;
|
|
} forEach (_object getVariable [QGVAR(effects), []]);
|
|
|
|
_object setVariable [QGVAR(effects), nil];
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
// Ammo box damage handling
|
|
["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 {};
|
|
|
|
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;
|
|
};
|