Skip to content

Commit

Permalink
Vehicle Damage - Add turret tossing again (#9989)
Browse files Browse the repository at this point in the history
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
  • Loading branch information
johnb432 and rautamiekka authored Jun 22, 2024
1 parent f45dff8 commit 56016a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
24 changes: 6 additions & 18 deletions addons/vehicle_damage/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions addons/vehicle_damage/functions/fnc_blowOffTurret.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Blow off turret effect.
*
* Arguments:
* 0: Vehicle <Object>
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
Expand All @@ -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 {};

Expand All @@ -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;

0 comments on commit 56016a4

Please sign in to comment.