2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2021-10-14 15:49:27 +00:00
|
|
|
/*
|
2023-08-16 23:18:01 +00:00
|
|
|
* Author: tcvm
|
2021-10-14 15:49:27 +00:00
|
|
|
* Spawn cook-off effects
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Vehicle <Object>
|
|
|
|
* 1: Spawn fire jet <Boolean>
|
|
|
|
* 2: Spawn fire ring <Boolean>
|
|
|
|
* 3: How long effect will last (Max 20 seconds) <Number>
|
|
|
|
* 4: What selection will fire originate from <String>
|
2022-05-17 17:09:10 +00:00
|
|
|
* 5: Cookoff intensity value <Number>
|
2021-10-14 15:49:27 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [vehicle player, true, false, 15, "commander_turret"] call ace_cookoff_fnc_cookOffEffect
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2022-05-17 17:09:10 +00:00
|
|
|
params ["_obj", "_jet", "_ring", "_time", "_fireSelection", "_intensity"];
|
2021-10-14 15:49:27 +00:00
|
|
|
private _light = "#lightpoint" createVehicleLocal [0,0,0];
|
|
|
|
_light setLightBrightness 5;
|
|
|
|
_light setLightAmbient [0.8, 0.6, 0.2];
|
|
|
|
_light setLightColor [1, 0.5, 0.2];
|
|
|
|
_light lightAttachObject [_obj, [0,0,0]];
|
|
|
|
_time = 0 max (_time min 20);
|
|
|
|
|
|
|
|
private _sound = objNull;
|
|
|
|
if (isServer) then {
|
|
|
|
// ironically biggest performance hit is this. Creating a new sound source takes up aprox 400 milliseconds.
|
|
|
|
// I dont think there is an alternative that takes into effect distance and whatever, but if you find one please fix!
|
2022-07-01 16:20:31 +00:00
|
|
|
if (_jet || _ring) then {
|
|
|
|
private _soundName = selectRandomWeighted [QGVAR(Sound_low), 0.1, QGVAR(Sound_mid), 0.25, QGVAR(Sound_high), 0.65];
|
|
|
|
_sound = createSoundSource [_soundName, position _obj, [], 0];
|
|
|
|
};
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
if (_ring) then {
|
|
|
|
private _intensity = 6;
|
|
|
|
private _radius = 1.5 * ((boundingBoxReal _obj) select 2);
|
|
|
|
[QEGVAR(fire,addFireSource), [_obj, _radius, _intensity, _obj]] call CBA_fnc_localEvent;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
[{
|
|
|
|
params ["_args", "_pfh"];
|
2022-05-17 17:09:10 +00:00
|
|
|
_args params ["_obj", "_jet", "_ring", "_time", "_startTime", "_light", "_fireSelection", "_sound", "_intensity"];
|
2021-10-14 15:49:27 +00:00
|
|
|
private _elapsedTime = CBA_missionTime - _startTime;
|
|
|
|
if (_elapsedTime >= _time) exitWith {
|
|
|
|
deleteVehicle _light;
|
|
|
|
deleteVehicle _sound;
|
2022-05-14 00:54:09 +00:00
|
|
|
if (isServer) then {
|
|
|
|
[QEGVAR(fire,removeFireSource), [_obj]] call CBA_fnc_localEvent;
|
|
|
|
};
|
2021-10-14 15:49:27 +00:00
|
|
|
[_pfh] call CBA_fnc_removePerFrameHandler;
|
|
|
|
};
|
|
|
|
private _factor = (1 + (_elapsedTime / 2) min 2);
|
|
|
|
private _flameSize = 1.5;
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
if (_elapsedTime > (_time * (3 / 4))) then {
|
|
|
|
_factor = _factor * linearConversion [_time * (3 / 4), _time, _elapsedTime, 1, 0.5];
|
|
|
|
};
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
_light setLightBrightness 5 * (_factor / 5);
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
if (_jet) then {
|
|
|
|
private _particlePosition = (_obj selectionPosition _fireSelection) vectorAdd [-0.1 + random 0.2, -0.1 + random 0.2, 0];
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 2, 32],
|
|
|
|
"",
|
|
|
|
"Billboard",
|
|
|
|
1,
|
2021-10-30 21:42:03 +00:00
|
|
|
(0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
_particlePosition,
|
2021-10-30 21:42:03 +00:00
|
|
|
[0, 0, 15 * (_factor / 2)],
|
2021-10-14 15:49:27 +00:00
|
|
|
0,
|
|
|
|
10,
|
|
|
|
7.9,
|
2021-10-30 21:42:03 +00:00
|
|
|
0.075,
|
|
|
|
[1.25 * _factor, 2.5 * _factor],
|
|
|
|
[[1, 1, 1, -2], [1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1],
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
_obj
|
|
|
|
];
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
// make flame push object into ground to make effect seem more "alive"
|
|
|
|
if (!isGamePaused && { local _obj }) then {
|
|
|
|
private _force = [0, 0, _factor * -(0.5 min random 1.5) * (0.3 min random 1)] vectorMultiply getMass _obj;
|
|
|
|
_obj addForce [_force, vectorUpVisual _obj];
|
|
|
|
};
|
|
|
|
};
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
if (_ring) then {
|
|
|
|
private _ringOrigin = (_obj selectionPosition _fireSelection) vectorAdd [-0.1 + random 0.2, -0.1 + random 0.2, -1];
|
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal",16,2,32],
|
2021-10-30 21:42:03 +00:00
|
|
|
"", "Billboard", 1, (0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
_ringOrigin,
|
2021-10-30 21:42:03 +00:00
|
|
|
[0, 20 * (_factor / 2), 0],
|
|
|
|
0, 10, 7.9, 0.075,
|
|
|
|
[1.25 * _factor, _flameSize * _factor],
|
|
|
|
[[1, 1, 1, -2], [1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1], 1, 0, "", "", _obj
|
|
|
|
];
|
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 2, 32],
|
2021-10-30 21:42:03 +00:00
|
|
|
"", "Billboard", 1, (0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
_ringOrigin,
|
2021-10-30 21:42:03 +00:00
|
|
|
[0, -20 * (_factor / 2), 0],
|
|
|
|
0, 10, 7.9, 0.075,
|
|
|
|
[1.25 * _factor, _flameSize * _factor],
|
|
|
|
[[1, 1, 1, -2], [1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1], 1, 0, "", "", _obj
|
|
|
|
];
|
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 2, 32],
|
2021-10-30 21:42:03 +00:00
|
|
|
"", "Billboard", 1, (0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
_ringOrigin,
|
2021-10-30 21:42:03 +00:00
|
|
|
[20 * (_factor / 2), 0, 0],
|
|
|
|
0, 10, 7.9, 0.075,
|
|
|
|
[1.25 * _factor, _flameSize * _factor],
|
|
|
|
[[1, 1, 1, -2], [1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1], 1, 0, "", "", _obj
|
|
|
|
];
|
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 2, 32],
|
2021-10-30 21:42:03 +00:00
|
|
|
"", "Billboard", 1, (0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
[-0.1 + random 0.2, -0.1 + random 0.2, -1],
|
2021-10-30 21:42:03 +00:00
|
|
|
[-20 * (_factor / 2), 0, 0],
|
|
|
|
0, 10, 7.9, 0.075,
|
|
|
|
[1.25 * _factor, _flameSize * _factor],
|
|
|
|
[[1, 1, 1, -2], [1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1], 1, 0, "", "", _obj
|
|
|
|
];
|
|
|
|
|
|
|
|
private _dir = 20 * (_factor / 2);
|
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 2, 32],
|
2021-10-30 21:42:03 +00:00
|
|
|
"", "Billboard", 1, (0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
_ringOrigin,
|
2021-10-30 21:42:03 +00:00
|
|
|
[_dir, _dir, 0],
|
|
|
|
0, 10, 7.9, 0.075,
|
|
|
|
[1.25 * _factor, _flameSize * _factor],
|
|
|
|
[[1, 1, 1, -2],[1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1], 1, 0, "", "", _obj
|
|
|
|
];
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
_dir = -20 * (_factor / 2);
|
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 2, 32],
|
2021-10-30 21:42:03 +00:00
|
|
|
"", "Billboard", 1, (0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
_ringOrigin,
|
2021-10-30 21:42:03 +00:00
|
|
|
[_dir, _dir, 0],
|
|
|
|
0, 10, 7.9, 0.075,
|
|
|
|
[1.25 * _factor, _flameSize * _factor],
|
|
|
|
[[1, 1, 1, -2],[1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1], 1, 0, "", "", _obj
|
|
|
|
];
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
_dir = 20 * (_factor / 2);
|
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal",16,2,32],
|
2021-10-30 21:42:03 +00:00
|
|
|
"", "Billboard", 1, (0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
_ringOrigin,
|
2021-10-30 21:42:03 +00:00
|
|
|
[_dir, -_dir, 0],
|
|
|
|
0, 10, 7.9, 0.075,
|
|
|
|
[1.25 * _factor, _flameSize * _factor],
|
|
|
|
[[1, 1, 1, -2], [1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1], 1, 0, "", "", _obj
|
|
|
|
];
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
_dir = 20 * (_factor / 2);
|
|
|
|
drop [
|
|
|
|
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 2, 32],
|
2021-10-30 21:42:03 +00:00
|
|
|
"", "Billboard", 1, (0.1 + (random 0.2)) * _factor,
|
2021-10-14 15:49:27 +00:00
|
|
|
_ringOrigin,
|
2021-10-30 21:42:03 +00:00
|
|
|
[-_dir, _dir, 0],
|
|
|
|
0, 10, 7.9, 0.075,
|
|
|
|
[1.25 * _factor, _flameSize * _factor],
|
|
|
|
[[1, 1, 1, -2], [1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]],
|
2021-10-14 15:49:27 +00:00
|
|
|
[2 + random 1], 1, 0, "", "", _obj
|
|
|
|
];
|
|
|
|
};
|
2022-05-17 17:09:10 +00:00
|
|
|
|
|
|
|
(getVehicleTIPars _obj) params ["_tiEngine", "_tiWheels", "_tiWeapon"];
|
|
|
|
_obj setVehicleTIPars [
|
|
|
|
// formula is designed to have the temperature ramp up quickly and then level out
|
|
|
|
(_tiEngine + (_intensity * 0.01))/1.005,
|
|
|
|
(_tiWheels + (_intensity * 0.004))/1.002, // wheels//tracks are further away from burning parts
|
|
|
|
(_tiWeapon + (_intensity * 0.01))/1.005
|
|
|
|
];
|
|
|
|
|
|
|
|
}, 0, [_obj, _jet, _ring, _time, CBA_missionTime, _light, _fireSelection, _sound, _intensity]] call CBA_fnc_addPerFrameHandler;
|
2021-10-14 15:49:27 +00:00
|
|
|
|