Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicle Damage - Add turret tossing again #9989

Merged
merged 5 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions addons/vehicle_damage/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,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;
Loading