ACE3/addons/cookoff/functions/fnc_cookOffBoxServer.sqf
johnb432 c44a1e7ea7
Cookoff - Mini-Rewrite (#9758)
* 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
2024-06-05 12:36:39 -07:00

51 lines
1.4 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: KoffeinFlummi, commy2, kymckay, johnb43
* Start an ammo cook-off in the given ammo box.
*
* Arguments:
* 0: Ammo box <OBJECT>
* 1: Source <OBJECT> (default: objNull)
* 2: Instigator <OBJECT> (default: objNull)
*
* Return Value:
* None
*
* Example:
* cursorObject call ace_cookoff_fnc_cookOffBoxServer
*
* Public: No
*/
if (!isServer) exitWith {};
if (!GVAR(enableAmmobox) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};
params ["_box", ["_source", objNull], ["_instigator", objNull]];
// Make sure it's a box (important, because deleted EH is assigned to ReammoBox_F only in postInit)
if !(_box isKindOf "ReammoBox_F") exitWith {};
if !(_box getVariable [QGVAR(enableAmmoCookoff), true]) exitWith {};
// Allow only 1 cook-off per box at a time
if (_box getVariable [QGVAR(isCookingOff), false]) exitWith {};
_box setVariable [QGVAR(isCookingOff), true, true];
private _delay = random [SMOKE_DELAY / 2, SMOKE_DELAY, SMOKE_DELAY / 2 * 3];
// Spawn cook-off effects on all connected machines and JIP
private _jipID = [QGVAR(cookOffBoxLocal), [
_box,
_source,
_instigator,
CBA_missionTime + _delay // Generate a globally synced timestamp
]] call CBA_fnc_globalEventJIP;
[_jipID, _box] call CBA_fnc_removeGlobalEventJIP;
_box setVariable [QGVAR(cookoffBoxJipID), _jipID];
// API
[QGVAR(cookOffBox), [_box, _source, _instigator, _delay]] call CBA_fnc_globalEvent;