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

Add destroyed boat ejecting #6330

Merged
merged 10 commits into from
Dec 16, 2019
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
1 change: 1 addition & 0 deletions addons/cookoff/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ PREP(cookOffBox);
PREP(blowOffTurret);
PREP(detonateAmmunition);
PREP(getVehicleAmmo);
PREP(handleDamageEjectIfDestroyed);
10 changes: 10 additions & 0 deletions addons/cookoff/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,13 @@ if (isServer) then {
} forEach allCurators;
}] call CBA_fnc_addEventHandler;
};

// init eject from destroyed vehicle
{
[_x, "init", {
params ["_vehicle"];
if (!alive _vehicle) exitWith {};
TRACE_2("ejectIfDestroyed init",_vehicle,typeOf _vehicle);
_vehicle addEventHandler ["HandleDamage", {call FUNC(handleDamageEjectIfDestroyed)}];
}, true, [], true] call CBA_fnc_addClassEventHandler;
} forEach EJECT_IF_DESTROYED_VEHICLES;
33 changes: 33 additions & 0 deletions addons/cookoff/functions/fnc_handleDamageEjectIfDestroyed.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "script_component.hpp"
/*
* Author: Dystopian
* Ejects crew from destroyed vehicle.
* Should be called from HandleDamage EH.
*
* Arguments:
* HandleDamage EH <ARRAY>
*
* Return Value:
* None
*
* Example:
* _this call ace_cookoff_fnc_handleDamageEjectIfDestroyed
*
* Public: No
*/

params ["_vehicle", "", "", "", "_ammo"];

if (alive _vehicle) exitWith {};

TRACE_2("ejectIfDestroyed HDEH",typeOf _vehicle,_this);

if (!IS_EXPLOSIVE_AMMO(_ammo)) then {
{
if (alive _x) then {
moveOut _x;
};
} forEach crew _vehicle;
};

_vehicle removeEventHandler ["HandleDamage", _thisEventHandler];
2 changes: 2 additions & 0 deletions addons/cookoff/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@

// Delay between flame effect for players in a cooking off vehicle
#define FLAME_EFFECT_DELAY 0.4

#define EJECT_IF_DESTROYED_VEHICLES ["Boat_Transport_02_base_F", "Rubber_duck_base_F"]