From 2cb3dac0bee03ecbdf36682ecb6660fcdca2dd87 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Thu, 10 Nov 2016 15:51:36 -0500 Subject: [PATCH] Fix vehicle damage handler bug Fixes vehicle appearing to repair itself on first hit. SetDamage 0 was running if no parts were damaged because "totalDmg" is not a hitpoint. Vanilla commit: https://github.com/DayZMod/DayZ/commit/92ab8fe2d4dbb592a5f2624c762d0ee6d94a0315 --- SQF/dayz_code/compile/veh_handleDam.sqf | 13 ++++++++----- SQF/dayz_server/compile/server_updateObject.sqf | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/SQF/dayz_code/compile/veh_handleDam.sqf b/SQF/dayz_code/compile/veh_handleDam.sqf index 8813406c5..377f3507e 100644 --- a/SQF/dayz_code/compile/veh_handleDam.sqf +++ b/SQF/dayz_code/compile/veh_handleDam.sqf @@ -14,7 +14,7 @@ or by zombie_attack - return : updated damage for that part broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local. ************************************************************/ -private["_unit","_selection","_strH","_total","_damage","_needUpdate"]; +private["_unit","_selection","_strH","_total","_damage","_needUpdate","_totalDmg"]; _unit = _this select 0; _selection = _this select 1; @@ -22,8 +22,10 @@ _total = _this select 2; if (_selection != "") then { _strH = "hit_" + _selection; + _totalDmg = false; } else { _strH = "totalDmg"; + _totalDmg = true; }; if (_total >= 0.98) then { @@ -32,15 +34,16 @@ if (_total >= 0.98) then { if (local _unit) then { if (_total > 0) then { - - _unit setVariable [_strH, _total, true]; + if (!_totalDmg) then { + _unit setVariable [_strH, _total, true]; + }; _unit setHit [_selection, _total]; + PVDZ_veh_Save = [_unit,"damage",false,_totalDmg]; if (!isServer) then { - PVDZ_veh_Save = [_unit,"damage"]; publicVariableServer "PVDZ_veh_Save"; } else { - [_unit, "damage"] call server_updateObject; + PVDZ_veh_Save call server_updateObject; }; }; } else { diff --git a/SQF/dayz_server/compile/server_updateObject.sqf b/SQF/dayz_server/compile/server_updateObject.sqf index 08a41d210..561ac7238 100644 --- a/SQF/dayz_server/compile/server_updateObject.sqf +++ b/SQF/dayz_server/compile/server_updateObject.sqf @@ -1,13 +1,14 @@ // [_object,_type] spawn server_updateObject; #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp" if (isNil "sm_done") exitWith {}; -private ["_objectID","_objectUID","_object_position","_isNotOk","_object","_type","_recorddmg","_forced","_lastUpdate","_needUpdate","_object_inventory","_object_damage","_objWallDamage","_object_killed","_object_maintenance","_object_variables"]; +private ["_objectID","_objectUID","_object_position","_isNotOk","_object","_type","_recorddmg","_forced","_lastUpdate","_needUpdate","_object_inventory","_object_damage","_objWallDamage","_object_killed","_object_maintenance","_object_variables","_totalDmg"]; _object = _this select 0; _type = _this select 1; _recorddmg = false; _isNotOk = false; _forced = if (count _this > 2) then {_this select 2} else {false}; +_totalDmg = if (count _this > 3) then {_this select 3} else {false}; _objectID = "0"; _objectUID = "0"; @@ -127,7 +128,7 @@ _object_damage = { }; } forEach _hitpoints; - if (_allFixed) then {_object setDamage 0;}; + if (_allFixed && !_totalDmg) then {_object setDamage 0;}; if (_forced) then { if (_object in needUpdate_objects) then {needUpdate_objects = needUpdate_objects - [_object];};