diff --git a/addons/medical/functions/fnc_init.sqf b/addons/medical/functions/fnc_init.sqf index 90516668f1..516879ad31 100644 --- a/addons/medical/functions/fnc_init.sqf +++ b/addons/medical/functions/fnc_init.sqf @@ -14,6 +14,10 @@ params ["_unit"]; +if (damage _unit > 0) then { + _unit setDamage 0; +}; + _unit setVariable [QGVAR(pain), 0, true]; _unit setVariable [QGVAR(bloodVolume), 100, true]; _unit setVariable ["ACE_isUnconscious", false, true]; // TODO this is done based on state diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index fe7f5f9952..958f7475b9 100644 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandler.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Unit That Was Hit - * 1: Name Of Hit Selection + * 1: Name Of Body Part * 2: Amount Of Damage * 3: Shooter or source of the damage * 4: Type of the damage done @@ -59,6 +59,8 @@ call compile _extensionOutput; _unit setVariable [QEGVAR(medical,openWounds), _openWounds, true]; +[_unit, _bodyPart] call EFUNC(medical_engine,updateBodyPartVisuals); + // Only update if new wounds have been created if (count _woundsCreated > 0) then { _unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true]; diff --git a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf index 7e11f09864..dfb4f96293 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Unit That Was Hit - * 1: Name Of Hit Selection + * 1: Name Of Body Part * 2: Amount Of Damage * 3: Shooter or source of the damage * 4: Type of the damage done @@ -128,6 +128,8 @@ private _woundsCreated = []; _unit setVariable [QEGVAR(medical,openWounds), _openWounds, true]; +[_unit, _bodyPart] call EFUNC(medical_engine,updateBodyPartVisuals); + // Only update if new wounds have been created if (count _woundsCreated > 0) then { _unit setVariable [QGVAR(lastUniqueWoundID), _woundID, true]; diff --git a/addons/medical_engine/XEH_PREP.hpp b/addons/medical_engine/XEH_PREP.hpp index 9e0032e118..441a95014c 100644 --- a/addons/medical_engine/XEH_PREP.hpp +++ b/addons/medical_engine/XEH_PREP.hpp @@ -2,6 +2,7 @@ PREP(handleDamage); PREP(playInjuredSound); PREP(damageBodyPart); +PREP(updateBodyPartVisuals); PREP(setLimping); PREP(setStructuralDamage); PREP(setUnconsciousAnim); diff --git a/addons/medical_engine/functions/fnc_updateBodyPartVisuals.sqf b/addons/medical_engine/functions/fnc_updateBodyPartVisuals.sqf new file mode 100644 index 0000000000..6511bddc6a --- /dev/null +++ b/addons/medical_engine/functions/fnc_updateBodyPartVisuals.sqf @@ -0,0 +1,70 @@ +/* + * Author: commy2 + * Damages a body part of a local unit. Does not kill the unit. + * + * Arguments: + * 0: Unit + * 1: Body part, can be "Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg" or "All" + * + * Return Value: + * None + * + * Example: + * [player, "HEAD"] call ace_medical_engine_fnc_updateBodyPartVisuals + * + * Public: No + */ +#include "script_component.hpp" + +params [["_unit", objNull, [objNull]], ["_bodyPart", "", [""]]]; + +if (!local _unit) exitWith { + ERROR("Unit not local or null"); +}; + +if (_bodyPart == "All") exitWith { + [_unit, "Head"] call FUNC(updateBodyPartVisuals); + [_unit, "Body"] call FUNC(updateBodyPartVisuals); + [_unit, "LeftArm"] call FUNC(updateBodyPartVisuals); + [_unit, "RightArm"] call FUNC(updateBodyPartVisuals); + [_unit, "LeftLeg"] call FUNC(updateBodyPartVisuals); + [_unit, "RightLeg"] call FUNC(updateBodyPartVisuals); +}; + +private _affectedBodyParts = [_bodyPart]; + +switch (toLower _bodyPart) do { + case "leftarm"; + case "rightarm": { + _bodyPart = "Arms"; + _affectedBodyParts = ["LeftArm", "RightArm"]; + }; + + case "leftleg"; + case "rightleg": { + _bodyPart = "Legs"; + _affectedBodyParts = ["LeftLeg", "RightLeg"]; + }; +}; + +private _openWounds = _unit getVariable QEGVAR(medical,openWounds); +private _bloodLossOnAffectedBodyParts = 0; + +{ + private _partIndex = ALL_BODY_PARTS find toLower _x; + + private _bloodLossOnBodyPart = 0; + + { + _x params ["", "", "_bodyPartN", "_amountOf", "_percentageOpen"]; + + if (_bodyPartN isEqualTo _partIndex) then { + _bloodLossOnBodyPart = _bloodLossOnBodyPart + (_amountOf * _percentageOpen); + }; + } forEach _openWounds; + + // report maximum of both legs or arms + _bloodLossOnAffectedBodyParts = _bloodLossOnAffectedBodyParts max _bloodLossOnBodyPart; +} forEach _affectedBodyParts; + +[_unit, _bodyPart, _bloodLossOnAffectedBodyParts >= 0.15] call FUNC(damageBodyPart); diff --git a/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf index 7c2814f5d5..bbeded81df 100644 --- a/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: The patient - * 1: Treatment classname + * 1: Treatment class name * 2: Body part * * Return Value: @@ -102,6 +102,8 @@ _openWounds set [_mostEffectiveSpot, _mostEffectiveInjury]; _target setVariable [QEGVAR(medical,openWounds), _openWounds, true]; +[_target, _bodyPart] call EFUNC(medical_engine,updateBodyPartVisuals); + // Handle the reopening of bandaged wounds if (_impact > 0 && {EGVAR(medical,level) >= 2} && {EGVAR(medical,enableAdvancedWounds)}) then { [_target, _impact, _partIndex, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening); @@ -189,7 +191,7 @@ if (EGVAR(medical,healHitPointAfterAdvBandage) || {EGVAR(medical,level) < 2}) th _target setVariable [QEGVAR(medical,bodyPartStatus), _bodyStatus, true]; - [_target] call EFUNC(medical_damage,setDamage); + //[_target] call EFUNC(medical_damage,setDamage); }; true diff --git a/addons/medical_treatment/functions/fnc_treatment_success.sqf b/addons/medical_treatment/functions/fnc_treatment_success.sqf index a7d6278f1e..e3c4df8dcc 100644 --- a/addons/medical_treatment/functions/fnc_treatment_success.sqf +++ b/addons/medical_treatment/functions/fnc_treatment_success.sqf @@ -53,7 +53,7 @@ private _bloodLossOnSelection = 0; private _partNumber = (ALL_BODY_PARTS find toLower _bodyPart) max 0; // Add all bleeding from wounds on selection -private _openWounds = _target getvariable [QEGVAR(medical,openWounds), []]; +private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []]; { _x params ["", "", "_selectionX", "_amountOf", "_percentageOpen"]; if (_selectionX == _partNumber) then {