From 876e264e33c563472309eb663fe3023af83317a7 Mon Sep 17 00:00:00 2001 From: A Man Date: Sat, 16 Apr 2022 17:20:28 +0200 Subject: [PATCH] Fix change clothes and login over sea level This also aims for the fix that the player still gets damaged while in debug. It looks like that allowDamage gets lifted when it should not. fn_exitSwim set too early the damage true which can be a problem. Ive decided to remove the handled damage from fn_exitSwim and set allowDamage always false before we enter this function. This needs intensive testing to be sure it works without any new problems. Thx to ndavalos and iben. --- SQF/dayz_code/compile/BIS_fnc/fn_halo.sqf | 8 +++---- SQF/dayz_code/compile/fn_exitSwim.sqf | 17 ++++++++------- .../compile/player_humanityMorph.sqf | 4 ++-- SQF/dayz_code/compile/player_switchModel.sqf | 21 +++++++++++-------- SQF/dayz_code/system/player_monitor.fsm | 1 - 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/SQF/dayz_code/compile/BIS_fnc/fn_halo.sqf b/SQF/dayz_code/compile/BIS_fnc/fn_halo.sqf index 211043d4a..46de01038 100644 --- a/SQF/dayz_code/compile/BIS_fnc/fn_halo.sqf +++ b/SQF/dayz_code/compile/BIS_fnc/fn_halo.sqf @@ -235,19 +235,19 @@ if (typename _this == typename []) then { _unit = _this select 0; if (!local _unit) exitwith {}; + + _unit allowDamage false; //Prevent glitch death when opening chute //--- Free fall if (count _this == 2) exitwith { //Fresh spawn calling from player_monitor.fsm - _alt = _this select 1; - _unit call fn_exitSwim; + if (surfaceIsWater respawn_west_original) then {_unit call fn_exitSwim;}; _unit setvariable ["bis_fnc_halo_now",true]; _unit spawn bis_fnc_halo; }; //------------- _para = objnull; - _vel = []; - _unit allowDamage false; //Prevent glitch death when opening chute + _vel = []; _paraPosition1 = [_unit] call FNC_GetPos; _para = createVehicle ["ParachuteWest", _paraPosition1, [], 0, "CAN_COLLIDE"]; //_para = "BIS_Steerable_Parachute" createVehicle position _unit; diff --git a/SQF/dayz_code/compile/fn_exitSwim.sqf b/SQF/dayz_code/compile/fn_exitSwim.sqf index 137d9c13b..9e69a978b 100644 --- a/SQF/dayz_code/compile/fn_exitSwim.sqf +++ b/SQF/dayz_code/compile/fn_exitSwim.sqf @@ -1,12 +1,15 @@ //This workaround reliably exits swimming after a setPos directly from water to land or air. //"Getting out while IsMoveOutInProgress" prints to client RPT, but it's needed to complete quickly and should be harmless. -_unit = _this; -_unit allowDamage false; -_paraPosition = [_unit] call FNC_GetPos; -_para = "ParachuteWest" createVehicleLocal [0,0,0]; -_para setPos _paraPosition; +local _unit = _this; +local _paraPosition = [_unit] call FNC_GetPos; +local _para = "ParachuteWest" createVehicleLocal [0,0,0]; +_para setPos [(_paraPosition select 0),(_paraPosition select 1),(_paraPosition select 2) + 0.1]; _unit moveInDriver _para; deleteVehicle _para; -_unit setPosATL _paraPosition; -_unit allowDamage true; \ No newline at end of file + +if (surfaceiswater _paraPosition) then { + _unit setPosASL _paraPosition; +} else { + _unit setPosATL _paraPosition; +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_humanityMorph.sqf b/SQF/dayz_code/compile/player_humanityMorph.sqf index 2d81df18e..9c7169459 100644 --- a/SQF/dayz_code/compile/player_humanityMorph.sqf +++ b/SQF/dayz_code/compile/player_humanityMorph.sqf @@ -10,7 +10,7 @@ _old removeAllEventHandlers "HandleDamage"; _old removeAllEventHandlers "Killed"; _old removeAllEventHandlers "Fired"; _old allowDamage false; -_old AddEventHandler ["HandleDamage", {False}]; +_old addEventHandler ["handleDamage", {0}]; //Logout local _humanity = player getVariable ["humanity",0]; @@ -109,7 +109,7 @@ if (Z_SingleCurrency) then { call dayz_resetSelfActions; //New unit has no self actions yet. Reset variables so actions can be added back. dayz_actionInProgress = false; //Allow self actions to run now. -player removeAllEventHandlers "HandleDamage"; +player removeAllEventHandlers "handleDamage"; eh_player_killed = player addeventhandler ["FiredNear",{_this call player_weaponFiredNear;}]; [player] call fnc_usec_damageHandle; player allowDamage true; diff --git a/SQF/dayz_code/compile/player_switchModel.sqf b/SQF/dayz_code/compile/player_switchModel.sqf index 4ad0e00cd..bc1121409 100644 --- a/SQF/dayz_code/compile/player_switchModel.sqf +++ b/SQF/dayz_code/compile/player_switchModel.sqf @@ -5,10 +5,7 @@ _class = if (_isArray) then {_this select 0} else {_this}; if (gear_done) then {disableUserInput true;disableUserInput true;}; disableSerialization; -//Old location system causes issues with players getting damaged during movement. -//_position = getPosATL player; -//New system testing needed. -_position = player modeltoWorld [0,0,0]; +_position = [player] call FNC_GetPos; _dir = getDir player; _currentAnim = animationState player; _currentCamera = cameraView; @@ -70,9 +67,10 @@ _leader = (player == leader _oldGroup); //[player] joinSilent grpNull; _group = createGroup west; _newUnit = _group createUnit [_class,respawn_west_original,[],0,"NONE"]; +_newUnit allowDamage false; + if (_isArray) then { - _newUnit allowDamage false; - mydamage_eh1 = _newUnit AddEventHandler ["HandleDamage", {False}]; + mydamage_eh1 = _newUnit addEventHandler ["handleDamage", {0}]; _newUnit setVariable ["characterID",(_this select 1),true]; _newUnit setVariable ["humanity",(_this select 2),true]; _newUnit setVariable ["zombieKills",(_this select 3),true]; @@ -112,15 +110,20 @@ if (_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then { _switchUnit = { //Make New Unit Playable (1 of these 3 commands causes crashes with gear dialog open) - //_oldUnit setPosATL [_position select 0 + cos(_dir) * 2, _position select 1 + sin(_dir) * 2, _position select 2]; addSwitchableUnit _newUnit; setPlayable _newUnit; selectPlayer _newUnit; //Switch the units _rndx = floor(random 100); _rndy = floor(random 100); - _oldUnit setPosATL [(respawn_west_original select 0) + _rndx, (respawn_west_original select 1) + _rndy, 0]; - _newUnit setPosATL _position; + _oldUnit setPosATL [(respawn_west_original select 0) + _rndx, (respawn_west_original select 1) + _rndy, 0]; + + if (surfaceIsWater _position) then { + _newUnit setPosASL _position; + } else { + _newUnit setPosATL _position; + }; + if (surfaceIsWater respawn_west_original) then {_newUnit call fn_exitSwim;}; removeAllWeapons _oldUnit; {_oldUnit removeMagazine _x;} count magazines _oldUnit; diff --git a/SQF/dayz_code/system/player_monitor.fsm b/SQF/dayz_code/system/player_monitor.fsm index 8e2795c5a..30408223a 100644 --- a/SQF/dayz_code/system/player_monitor.fsm +++ b/SQF/dayz_code/system/player_monitor.fsm @@ -627,7 +627,6 @@ class FSM "" \n "_model call player_switchModel;" \n "" \n - "player allowDamage false;" \n "_lastAte = _survival select 1;" \n "_lastDrank = _survival select 2;" \n "" \n