Skip to content

Commit

Permalink
Greatly reduce idle sound proxy objects (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
diwako authored Nov 9, 2024
1 parent 1ec9d40 commit a17a89b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 43 deletions.
46 changes: 34 additions & 12 deletions addons/main/anomalyFXEvents.inc.sqf
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
DFUNC(playLocalAnomalyActivationSound) = {
params ["_trg", "_sound"];
private _proxy = _trg getVariable [QGVAR(sound), objNull];
if (isNull _proxy) then {
_proxy = "building" createVehicleLocal getPos _trg;
_proxy setPosASL ((getPosASL _trg) vectorAdd [0,0,0.5]);
_proxy enableSimulation false;
_trg setVariable [QGVAR(sound), _proxy];
};
private _time = time;
_proxy setVariable [QGVAR(time), _time];
_proxy say3D _sound;
[{
params ["_proxy", "_time"];
if (_time isEqualTo (_proxy getVariable [QGVAR(time), 0])) then {
deleteVehicle _proxy;
};
}, [_proxy, _time], 10] call CBA_fnc_waitAndExecute;
};

[QGVAR(fruitPunchEffect), {
params ["_trg"];
if (isNull _trg) exitWith {};
private _proxy = _trg getVariable QGVAR(sound);
_proxy say3D (selectRandom ["bfuzz_hit","buzz_hit"]);
[_trg, selectRandom ["bfuzz_hit","buzz_hit"]] call DFUNC(playLocalAnomalyActivationSound);
private _source = "#particlesource" createVehicleLocal getPos _trg;
_source setPosASL (getPosASL _trg);

Expand All @@ -15,8 +34,7 @@
[QGVAR(burnerEffect), {
params ["_trg"];
if (isNull _trg) exitWith {};
private _proxy = _trg getVariable QGVAR(sound);
_proxy say3D "fire2";
[_trg, "fire2"] call DFUNC(playLocalAnomalyActivationSound);

private _pos = getPos _trg;
private _source = "#particlesource" createVehicleLocal getPos _trg;
Expand All @@ -26,7 +44,7 @@
[_source, "active"] call FUNC(burnerEffect);
[_source2, "active"] call FUNC(burnerEffect);

private _light = "#lightpoint" createVehicleLocal (getPos _proxy);
private _light = "#lightpoint" createVehicleLocal ((getPos _trg) vectorAdd [0, 0, 0.5]);
_light setLightBrightness 2;
_light setLightAmbient [1, 0.6, 0.6];
_light setLightColor [1, 0.6, 0.6];
Expand All @@ -45,8 +63,7 @@
[QGVAR(springboardEffect), {
params ["_trg"];
if (isNull _trg) exitWith {};
private _proxy = _trg getVariable QGVAR(sound);
_proxy say3D format ["gravi_blowout%1", (floor random 6) + 1];
[_trg, format ["gravi_blowout%1", (floor random 6) + 1]] call DFUNC(playLocalAnomalyActivationSound);

[{
params ["_trg"];
Expand All @@ -62,10 +79,9 @@
[QGVAR(electraEffect), {
params ["_trg", "_list"];
if (isNull _trg) exitWith {};
private _proxy = _trg getVariable QGVAR(sound);
_proxy say3D format ["electra_blast%1", (floor random 2) + 1];
[_trg, format ["electra_blast%1", (floor random 2) + 1]] call DFUNC(playLocalAnomalyActivationSound);

private _light = "#lightpoint" createVehicleLocal (getPos (_trg getVariable QGVAR(sound)));
private _light = "#lightpoint" createVehicleLocal ((getPos _trg) vectorAdd [0, 0, 0.5]);
_light setLightBrightness 10;
_light setLightAmbient [0.6, 0.6, 1];
_light setLightColor [0.6, 0.6, 1];
Expand Down Expand Up @@ -123,8 +139,7 @@
[QGVAR(meatgrinderEffect), {
params ["_trg"];
if (isNull _trg) exitWith {};
private _proxy = _trg getVariable QGVAR(sound);
_proxy say3D "anomaly_mincer_blowout";
[_trg, "anomaly_mincer_blowout"] call DFUNC(playLocalAnomalyActivationSound);

[{
params ["_trg", "_stopTime", "_nextDropTime"];
Expand Down Expand Up @@ -159,3 +174,10 @@
}, _source, 1] call CBA_fnc_waitAndExecute;
}, [_trg], MEATGRINDER_MIN_COOL_DOWN] call CBA_fnc_waitAndExecute;
}] call CBA_fnc_addEventHandler;

[QGVAR(teleportEffect), {
params ["_trg", "_exit"];
if (isNull _trg || isNull _exit) exitWith {};
[_trg, format ["teleport_work_%1", (floor random 2) + 1]] call DFUNC(playLocalAnomalyActivationSound);
[_exit, format ["teleport_work_%1", (floor random 2) + 1]] call DFUNC(playLocalAnomalyActivationSound);
}] call CBA_fnc_addEventHandler;
5 changes: 1 addition & 4 deletions addons/main/functions/anomalies/fn_activateTeleport.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ if (isNil "_exit") exitWith {
_x setVariable [QGVAR(cooldown), true, true];
} forEach _teleporters;

private _proxy = _trg getVariable QGVAR(sound);
[QGVAR(say3D), [_proxy, "teleport_work_" + str((floor random 2) + 1)]] call CBA_fnc_globalEvent;
_proxy = _exit getVariable QGVAR(sound);
[QGVAR(say3D), [_proxy, "teleport_work_" + str((floor random 2) + 1)]] call CBA_fnc_globalEvent;
[QGVAR(teleportEffect), [_trg, _exit]] call CBA_fnc_globalEvent;

[{
params["_trg", "_list", "_exit", "_men"];
Expand Down
4 changes: 0 additions & 4 deletions addons/main/functions/anomalies/fn_createBurner.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ if (_varName isNotEqualTo "") then { missionNamespace setVariable [_varName, _tr
_trg setPosASL _pos;
_trg setVariable [QGVAR(cooldown), false, true];
_trg setVariable [QGVAR(anomalyType), "burner", true];
private _proxy = "building" createVehicle position _trg;
_proxy enableSimulationGlobal false;
_proxy setPos (_trg modelToWorld [0,0,0.5]);
_trg setVariable [QGVAR(sound), _proxy, true];

_trg setTriggerArea [4, 4, 0, false, 4];
_trg setTriggerActivation ["ANY", "PRESENT", true];
Expand Down
4 changes: 0 additions & 4 deletions addons/main/functions/anomalies/fn_createElectra.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ if (_varName isNotEqualTo "") then { missionNamespace setVariable [_varName, _tr
_trg setPosASL _pos;
_trg setVariable [QGVAR(cooldown), false, true];
_trg setVariable [QGVAR(anomalyType), "electra", true];
private _proxy = "building" createVehicle position _trg;
_proxy enableSimulationGlobal false;
_proxy setPos (_trg modelToWorld [0,0,0.5]);
_trg setVariable [QGVAR(sound), _proxy, true];

_trg setTriggerArea [4, 4, 0, false, 4];
_trg setTriggerActivation ["ANY", "PRESENT", true];
Expand Down
5 changes: 0 additions & 5 deletions addons/main/functions/anomalies/fn_createFruitPunch.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ _trg setTriggerArea [_radius, _radius, 0, false, 2];
_trg setTriggerActivation ["ANY", "PRESENT", true];
_trg setTriggerStatements [format ["this && {!(thisTrigger getVariable ['%1', false])}", QGVAR(cooldown)], format ["[thisTrigger, thisList] call %1", QFUNC(activateFruitPunch)], ""];

private _proxy = "building" createVehicle position _trg;
_proxy enableSimulationGlobal false;
_proxy setPos (_trg modelToWorld [0,0,0.5]);
_trg setVariable [QGVAR(sound), _proxy, true];

private _field = createSimpleObject ["BloodPool_01_Large_New_F", _pos];
_field enableSimulationGlobal false;
_field setPosASL _pos;
Expand Down
5 changes: 0 additions & 5 deletions addons/main/functions/anomalies/fn_createMeatgrinder.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ if (_varName isNotEqualTo "") then { missionNamespace setVariable [_varName, _tr
_trg setPosASL _pos;
_trg setVariable [QGVAR(cooldown), false, true];
_trg setVariable [QGVAR(anomalyType), "meatgrinder", true];
private _proxy = "building" createVehicle position _trg;
_proxy enableSimulationGlobal false;
_proxy setPos (_trg modelToWorld [0,0,0.5]);

_trg setVariable [QGVAR(sound), _proxy, true];

_trg setTriggerArea [4, 4, 0, false, 4];
_trg setTriggerActivation ["ANY", "PRESENT", true];
Expand Down
4 changes: 0 additions & 4 deletions addons/main/functions/anomalies/fn_createSpringboard.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ if (_varName isNotEqualTo "") then { missionNamespace setVariable [_varName, _tr
_trg setPosASL _pos;
_trg setVariable [QGVAR(cooldown), false, true];
_trg setVariable [QGVAR(anomalyType), "springboard", true];
private _proxy = "building" createVehicle position _trg;
_proxy enableSimulationGlobal false;
_proxy setPos (_trg modelToWorld [0,0,0.5]);
_trg setVariable [QGVAR(sound), _proxy, true];

_trg setTriggerArea [4, 4, 0, false, 4];
_trg setTriggerActivation ["ANY", "PRESENT", true];
Expand Down
4 changes: 0 additions & 4 deletions addons/main/functions/anomalies/fn_createTeleport.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ GVAR(teleportIDs) set [_id, _teleporters];
_trg setVariable [QGVAR(cooldown), false, true];
_trg setVariable [QGVAR(teleportID), _id, true];
_trg setVariable [QGVAR(anomalyType), "teleport", true];
private _proxy = "building" createVehicle position _trg;
_proxy enableSimulationGlobal false;
_proxy setPos (_trg modelToWorld [0,0,0.5]);
_trg setVariable [QGVAR(sound), _proxy, true];

_trg setTriggerArea [2, 2, 0, false, 4];
_trg setTriggerActivation ["ANY", "PRESENT", true];
Expand Down
1 change: 0 additions & 1 deletion addons/main/functions/anomalies/fn_deleteAnomalies.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ private _type = "";
deleteMarker (_x getVariable [QGVAR(debugMarker),""]);
};
[QGVAR(deleteParticleSource), [_x]] call CBA_fnc_globalEvent;
deleteVehicle (_x getVariable [QGVAR(sound), objNull]);
GVAR(holder) = GVAR(holder) - [_x];
switch (_type) do {
case "telepot":{
Expand Down

0 comments on commit a17a89b

Please sign in to comment.