ACE3/addons/cookoff/functions/fnc_cookOffBoxLocal.sqf

54 lines
1.6 KiB
Plaintext
Raw Normal View History

2024-01-27 08:14:10 +00:00
#include "..\script_component.hpp"
/*
* Author: KoffeinFlummi, commy2, kymckay, johnb43
2024-02-05 16:31:27 +00:00
* Spawns local cook-off effects for ammo boxes.
2024-01-27 08:14:10 +00:00
*
* Arguments:
2024-02-05 16:31:27 +00:00
* 0: Box <OBJECT>
* 1: Killer <OBJECT>
* 2: Instigator <OBJECT>
* 3: Start time of the cook-off <NUMBER>
* 4: Smoke delay <NUMBER>
2024-01-27 08:14:10 +00:00
*
* Return Value:
* None
*
* Example:
2024-02-05 16:31:27 +00:00
* [cursorObject, player, player, CBA_missionTime, 10, 60] call ace_cookoff_fnc_cookOffBoxLocal
2024-01-27 08:14:10 +00:00
*
* Public: No
*/
2024-02-05 16:31:27 +00:00
params ["", "", "", "_startTime", "_smokeDelay"];
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
[{
params ["_box", "_killer", "_instigator"];
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
// Make sure effects are cleaned up if box is deleted
[QGVAR(addCleanupHandlers), _box] call CBA_fnc_localEvent;
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
private _boxPos = ASLToAGL getPosASL _box;
private _effects = [];
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
// Box will start smoking
if (hasInterface) then {
private _smoke = createVehicleLocal ["#particlesource", _boxPos, [], 0, "CAN_COLLIDE"];
_smoke setParticleClass "AmmoSmokeParticles2";
_smoke attachTo [_box];
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
_effects pushBack _smoke;
};
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
if (isServer) then {
private _sound = createSoundSource ["Sound_Fire", _boxPos, [], 0];
_sound attachTo [_box];
2024-01-27 08:14:10 +00:00
2024-02-05 16:31:27 +00:00
_effects pushBack _sound;
2024-01-27 08:14:10 +00:00
2024-02-03 16:48:54 +00:00
// Detonate the ammunition
2024-02-05 16:31:27 +00:00
[QGVAR(detonateAmmunition), [_box, true, _killer, _instigator, random [DETONATION_DELAY / 2, DETONATION_DELAY, DETONATION_DELAY / 2 * 3]]] call CBA_fnc_localEvent;
};
_box setVariable [QGVAR(effects), _effects];
}, _this, (_startTime - CBA_missionTime + _smokeDelay) max 0] call CBA_fnc_waitAndExecute; // this delay allows for synchronisation for JIP players