From 56016a48165f76262231fa9a564a8da392865741 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 22 Jun 2024 20:08:43 +0200 Subject: [PATCH] Vehicle Damage - Add turret tossing again (#9989) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/vehicle_damage/XEH_postInit.sqf | 24 +++++-------------- .../functions/fnc_blowOffTurret.sqf | 15 ++++++------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/addons/vehicle_damage/XEH_postInit.sqf b/addons/vehicle_damage/XEH_postInit.sqf index 43050086d8..9784d335ed 100644 --- a/addons/vehicle_damage/XEH_postInit.sqf +++ b/addons/vehicle_damage/XEH_postInit.sqf @@ -31,26 +31,14 @@ ["Car", "init", LINKFUNC(addEventHandler), true, [], true] call CBA_fnc_addClassEventHandler; }; - // blow off turret effect - /* - Disabled temporarily due to issues with being able to repair tanks after death. Needs work - */ - /*["Tank", "killed", { - if (random 1 < 0.15) then { + // Blow off turret effect + // TODO: Add blowing-off-turret effect to vehicles that cook-off but aren't destroyed (no catastrophic explosion) + // The problem is that vehicles are repairable if they haven't been destroyed. So if the turret is gone and vehicle is repaired, how do we handle that? + ["Tank", "Killed", { + if (_this select 3 && random 1 < 0.15) then { (_this select 0) call FUNC(blowOffTurret); }; - }, true, [], true] call CBA_fnc_addClassEventHandler;*/ - - // event to add a turret to a curator if the vehicle already belonged to that curator - if (isServer) then { - [QGVAR(addTurretToEditable), { - params ["_vehicle", "_turret"]; - - { - _x addCuratorEditableObjects [[_turret], false]; - } forEach (objectCurators _vehicle); - }] call CBA_fnc_addEventHandler; - }; + }, true, [], true] call CBA_fnc_addClassEventHandler; }; // init eject from destroyed vehicle diff --git a/addons/vehicle_damage/functions/fnc_blowOffTurret.sqf b/addons/vehicle_damage/functions/fnc_blowOffTurret.sqf index a036f0045b..818fe6f6ef 100644 --- a/addons/vehicle_damage/functions/fnc_blowOffTurret.sqf +++ b/addons/vehicle_damage/functions/fnc_blowOffTurret.sqf @@ -4,7 +4,7 @@ * Blow off turret effect. * * Arguments: - * 0: Vehicle + * 0: Vehicle * * Return Value: * None @@ -15,13 +15,12 @@ * Public: No */ -// delayed so the object is spawned after the model changes to a wreck -// the sudden change in the model would cause nearby physx objects to get stuck +// Delayed so the object is spawned after the model changes to a wreck +// The sudden change in the model would cause nearby PhysX objects to get stuck [{ params ["_vehicle"]; - private _config = _vehicle call CBA_fnc_getObjectConfig; - getArray (_config >> QGVAR(turret)) params [["_model", "", [""]], ["_offset", [0,0,0], [[]], 3]]; + (getArray (configOf _vehicle >> QGVAR(turret))) params [["_model", "", [""]], ["_offset", [0, 0, 0], [[]], 3]]; if (_model isEqualTo "") exitWith {}; @@ -31,6 +30,8 @@ _turret setVectorUp [random 1, random 1, 1]; _turret setVelocity [random 7, random 7, 8 + random 5]; - // add turret to all curators that already own the wreck - [QGVAR(addTurretToEditable), [_vehicle, _turret]] call CBA_fnc_serverEvent; + // Add turret to all curators that already own the wreck + if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { + [QEGVAR(zeus,addObjects), [[_turret], objectCurators _vehicle]] call CBA_fnc_serverEvent; + }; }, _this, 1] call CBA_fnc_waitAndExecute;