From f2dfc6dc0e3147208f39613f442594586cd14b48 Mon Sep 17 00:00:00 2001
From: commy2 <commy-2@gmx.de>
Date: Thu, 13 Oct 2016 20:17:21 +0200
Subject: [PATCH] fixes, tweaks

---
 addons/medical/functions/fnc_setDead.sqf                 | 7 ++-----
 addons/medical_engine/functions/fnc_playInjuredSound.sqf | 6 ++++--
 addons/medical_treatment/functions/fnc_treatment.sqf     | 4 +++-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/addons/medical/functions/fnc_setDead.sqf b/addons/medical/functions/fnc_setDead.sqf
index 6ffaddfc4d..4bf2c6aa57 100644
--- a/addons/medical/functions/fnc_setDead.sqf
+++ b/addons/medical/functions/fnc_setDead.sqf
@@ -18,11 +18,8 @@
 
 params ["_unit", ["_reason", "unknown"]];
 
-// kill
-_unit setDamage 1;
-
-// reset textures
-[_unit, "All"] call EFUNC(medical_engine,updateBodyPartVisuals);
+// wait a frame to escape handleDamage
+[EFUNC(medical_engine,setStructuralDamage), [_unit, 1]] call CBA_fnc_execNextFrame;
 
 private _lastShooter = _unit getVariable [QEGVAR(medical_engine,lastShooter), objNull];
 private _lastInstigator = _unit getVariable [QEGVAR(medical_engine,lastInstigator), objNull];
diff --git a/addons/medical_engine/functions/fnc_playInjuredSound.sqf b/addons/medical_engine/functions/fnc_playInjuredSound.sqf
index ed64947325..53e092da2f 100644
--- a/addons/medical_engine/functions/fnc_playInjuredSound.sqf
+++ b/addons/medical_engine/functions/fnc_playInjuredSound.sqf
@@ -28,11 +28,13 @@ if (!local _unit) exitWith {
     ERROR("Unit not local or null");
 };
 
+if !(_unit call EFUNC(common,isAwake)) exitWith {};
+
 private _timeOut = [TIME_OUT_HIT, TIME_OUT_MOAN] select (_type == "moan");
 
 // Handle timeout
-if (_unit getVariable [QGVAR(soundTimeout), -1] > CBA_missionTime) exitWith {};
-_unit setVariable [QGVAR(soundTimeout), CBA_missionTime + _timeOut];
+if (_unit getVariable [QGVAR(soundTimeout) + _type, -1] > CBA_missionTime) exitWith {};
+_unit setVariable [QGVAR(soundTimeout) + _type, CBA_missionTime + _timeOut];
 
 // Get sounds
 private _soundsNamespace = NAMESPACE_NULL;
diff --git a/addons/medical_treatment/functions/fnc_treatment.sqf b/addons/medical_treatment/functions/fnc_treatment.sqf
index 6554d86ad9..67b9e4ea9b 100644
--- a/addons/medical_treatment/functions/fnc_treatment.sqf
+++ b/addons/medical_treatment/functions/fnc_treatment.sqf
@@ -104,7 +104,9 @@ if (weaponLowered _caller) then {
     _animDuration = _animDuration + 0.5;
 
     // fix problems with lowered weapon transitions by raising the weapon first
-    _caller action ["WeaponInHand", _caller];
+    if (currentWeapon _caller != "" && {_callerAnim != ""}) then {
+        _caller action ["WeaponInHand", _caller];
+    };
 };
 
 if (binocular _caller != "" && {binocular _caller == currentWeapon _caller}) then {