From 5b158b398a2ab7b4df1e402cfd89fad7383928b4 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Fri, 7 Oct 2016 13:42:05 -0400 Subject: [PATCH] Fix damage handling of vehicle explosions Vanilla commit: https://github.com/DayZMod/DayZ/commit/589791e9f9116e8b230e01d51fabde028298ea7a This was being falsely triggered before because the distance (3m) was far too small and it was only counting fast moving vehicles. The player can be damaged up to 25m away from the vehicle explosion. The comment was incorrect. It can be easily checked by using the included diag_log at the top of this file. --- SQF/dayz_code/compile/fn_damageHandler.sqf | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/SQF/dayz_code/compile/fn_damageHandler.sqf b/SQF/dayz_code/compile/fn_damageHandler.sqf index 661b2ae23..f96283435 100644 --- a/SQF/dayz_code/compile/fn_damageHandler.sqf +++ b/SQF/dayz_code/compile/fn_damageHandler.sqf @@ -11,6 +11,7 @@ _hit = _this select 1; _damage = _this select 2; _source = _this select 3; _ammo = _this select 4; +//diag_log format["HandleDamage: Unit:%1 Hit:%2 Damage:%3 Source:%4 Ammo:%5",_unit,_hit,_damage,_source,_ammo]; _unconscious = _unit getVariable ["NORRN_unconscious", false]; _model = typeOf player; _sourceType = typeOf _source; @@ -24,7 +25,8 @@ _falling = (((_hit == "legs") AND {(_source==_unit)}) AND {((_ammo=="") AND {(Da //Simple hack to help with a few issues from direct damage to physic based damage. ***until 2.0*** if (isNull dayz_getout) then { - _vehicleArray = nearestObjects [(getposATL (vehicle _unit)),["Car","Helicopter","Motorcycle","Ship"],3]; + _vehicleArray = nearestObjects [(getPosATL (vehicle _unit)),["Car","Air","Motorcycle","Ship","Tank"],3]; + {if (typeOf _x == "ParachuteWest") then {_vehicleArray = _vehicleArray - [_x];};} count _vehicleArray; { if ((speed _x > 10) or (speed _x < -8)) exitwith { dayz_HitBy = _x; }; } count _vehicleArray; @@ -45,16 +47,23 @@ _falling = (((_hit == "legs") AND {(_source==_unit)}) AND {((_ammo=="") AND {(Da if (_ammo == "") exitwith { _end = true; }; //If _source contains no object exit. But lets not exit if the unit returns player. Maybe its his own fault. - /*if (isNull _source) then { // in Epoch we can't use this block as is becasue too many servers use a variety of explosives - _end = true; - if !(_ammo in ["Dragged","RunOver"]) then { - // Explosion with no vehicle nearby. Possible cheat. Record to block any incoming fall damage. + if (isNull _source && !(_ammo in ["Dragged","RunOver"])) then { + _vehicleArray = nearestObjects [(getPosATL (vehicle _unit)),["Car","Air","Motorcycle","Ship","Tank"],25]; + {if (typeOf _x == "ParachuteWest") then {_vehicleArray = _vehicleArray - [_x];};} count _vehicleArray; + //Don't exit if a drivable vehicle (or drivable vehicle wreck) is nearby, because vehicle explosions register as a null source + if (count _vehicleArray == 0) then { + _end = true; + /* + Possible cheat. Record to block any incoming fall damage. + NOTE: Only vehicle explosions register a null source. Satchel charges, mines, grenades, vehicle missiles + and other explosives DO NOT register a null source. Their source is the player who placed, threw or fired them. + */ dayz_lastDamageSourceNull = true; - diag_log "dayz_lastDamageSourceNull triggered"; + diag_log "Warning: Fn_DamageHandler source isNull with no drivable vehicle (or drivable vehicle wreck) in 25m radius. Exiting with no damage."; }; - };*/ + }; } else { - if (dayz_lastDamageSourceNull) then { _end = true; }; // Block incoming fall damage. + if (dayz_lastDamageSourceNull) then { _end = true; }; // Block incoming fall damage. };