From c4118463dc9f770f3a7b728bb504cb93c26938fc Mon Sep 17 00:00:00 2001 From: AirwavesMan Date: Fri, 12 Mar 2021 11:12:31 +0100 Subject: [PATCH] Add check to prevent submarine sink into the ground --- SQF/dayz_code/compile/submarine_surface.sqf | 13 +++++++++++++ SQF/dayz_code/init/compiles.sqf | 1 + SQF/dayz_code/init/veh_resetEH.sqf | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 SQF/dayz_code/compile/submarine_surface.sqf diff --git a/SQF/dayz_code/compile/submarine_surface.sqf b/SQF/dayz_code/compile/submarine_surface.sqf new file mode 100644 index 000000000..6ad903cf0 --- /dev/null +++ b/SQF/dayz_code/compile/submarine_surface.sqf @@ -0,0 +1,13 @@ +local _vehicle = _this select 0; +local _unit = _this select 2; +local _driver = driver _vehicle; + +if (!(isNull _driver) && {_driver != _unit}) exitwith {}; + +while {_vehicle isKindOf "Submarine_DZE_base"} do { + local _pos = getposATL _vehicle; + if (((_vehicle animationphase "dive") > 0.5) && {(_pos select 2) < 10}) then { + _vehicle animate ["dive", 0]; + }; + uisleep 1; +}; \ No newline at end of file diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 8162f7a44..cb0135c07 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -51,6 +51,7 @@ if (!isDedicated) then { player_regularSave = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_regularSave.sqf"; player_forceSave = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_forceSave.sqf"; vehicle_getOut = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\vehicle_getOut.sqf"; + submarine_surface = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\submarine_surface.sqf"; //Objects object_setpitchbank = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_setpitchbank.sqf"; diff --git a/SQF/dayz_code/init/veh_resetEH.sqf b/SQF/dayz_code/init/veh_resetEH.sqf index 4be4ae7be..48a13dec9 100644 --- a/SQF/dayz_code/init/veh_resetEH.sqf +++ b/SQF/dayz_code/init/veh_resetEH.sqf @@ -11,13 +11,15 @@ if (_this isKindOf "AllVehicles") then { _this addeventhandler ["HandleDamage",{ _this call fnc_veh_handleDam } ]; _this addeventhandler ["Killed",{ _this call fnc_veh_handleKilled } ]; _this addEventHandler ["GetOut", { _this call vehicle_getOut }]; + if (_this isKindOf "Submarine_DZE_base") then { + _this addEventHandler ["GetIn", { _this spawn submarine_surface }]; + }; if (isServer) then { _this removeAllEventHandlers "GetOut"; _this removeAllEventHandlers "GetIn"; _this addEventHandler ["GetOut", {[(_this select 0),"all",true] call server_updateObject;}]; _this addEventHandler ["GetIn", {[(_this select 0),"all",true] call server_updateObject; _this call server_checkIfTowed;}]; - //_this addEventHandler ["Engine", { }]; }; //diag_log(format["%1: all EH reset for %2", __FILE__, _this]);