diff --git a/addons/medical/functions/fnc_handleDrowningDamage.sqf b/addons/medical/functions/fnc_handleDrowningDamage.sqf index 2dc538aac9..1116d07762 100644 --- a/addons/medical/functions/fnc_handleDrowningDamage.sqf +++ b/addons/medical/functions/fnc_handleDrowningDamage.sqf @@ -1,14 +1,21 @@ -// by commy2 +/* + * Author: Glowbal + * Handle drowning damage to unit + * + * Arguments: + * 0: Unit for which the hitpoint damage will be sorted out + * 1: new damage + * + * Return Value: + * None + * + * Public: No + */ + #include "script_component.hpp" params ["_unit", "_newDamage"]; -private ["_selection", "_totalDamage"]; - -_selection = "head"; - -_totalDamage = (_unit getHit _selection) + _newDamage; - -_unit setHit [_selection, _totalDamage]; - -systemChat format ["drowning: %1", _this]; +// At the moment we will just not do anything +// We reserve this until a later stage +// A unit will automatically die once oxygen has ran out anyway diff --git a/addons/medical/functions/fnc_handleFallDamage.sqf b/addons/medical/functions/fnc_handleFallDamage.sqf index cea73b16bf..3161364f98 100644 --- a/addons/medical/functions/fnc_handleFallDamage.sqf +++ b/addons/medical/functions/fnc_handleFallDamage.sqf @@ -1,14 +1,63 @@ -// by commy2 +/* + * Author: Glowbal + * Handle fall damage to unit + * + * Arguments: + * 0: Unit for which the hitpoint damage will be sorted out + * 1: new damage + * + * Return Value: + * None + * + * Public: No + */ + #include "script_component.hpp" params ["_unit", "_newDamage"]; -private ["_totalDamageL", "_totalDamageR"]; +private _part = ["leg_l"] call FUNC(selectionNameToNumber); +private _part2 = ["leg_r"] call FUNC(selectionNameToNumber); -_totalDamageL = (_unit getHitPointDamage "HitLeftLeg") + _newDamage; -_totalDamageR = (_unit getHitPointDamage "HitRightLeg") + _newDamage; +// Store the new damage values in our damageBodyParts store +private _damageBodyParts = _unit getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]; +_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage]; +_damageBodyParts set [_part2, (_damageBodyParts select _part2) + _newDamage]; +_unit setVariable [QGVAR(bodyPartStatus), _damageBodyParts]; -_unit setHitPointDamage ["HitLeftLeg", _totalDamageL]; -_unit setHitPointDamage ["HitRightLeg", _totalDamageR]; +// our unconscious calculation for selection damages +if (alive _unit && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { + // If it reaches this, we can assume that the hit did not kill this unit, as this function is called some time after the damage has been passed. + if ([_unit, _part, _newDamage * 1.3] call FUNC(determineIfFatal)) then { + [_unit, true, 0.5+random(10)] call FUNC(setUnconscious); + } else { + if ([_unit, _part2, _newDamage * 1.3] call FUNC(determineIfFatal)) then { + [_unit, true, 0.5+random(10)] call FUNC(setUnconscious); + }; + }; +}; -systemChat format ["falling: %1", _this]; +if (GVAR(level) > 1) then { // advanced medical is enabled + [_unit, "leg_l", _newDamage, "", "falling"] call FUNC(handleDamage_assignWounds); // cover both left and right legs + [_unit, "leg_r", _newDamage, "", "falling"] call FUNC(handleDamage_assignWounds); +} else { + // New pain values + _pain = _unit getVariable [QGVAR(pain), 0]; + _pain = _pain + (_newDamage / 4) * (1 - (_unit getVariable [QGVAR(morphine), 0])); + _unit setVariable [QGVAR(pain), _pain min 1, true]; +}; + +// Store the hitpoint values so blood ends up on the unit textures +_unit setVariable [QGVAR(bodyPartStatus), _damageBodyParts, true]; +TRACE_2("ACE_DEBUG: HandleSelectionDamage Broadcast value here", _unit, _unit getVariable QGVAR(bodyPartStatus)); + +EXPLODE_6_PVT(_damageBodyParts,_headDamage,_torsoDamage,_handsDamageR,_handsDamageL,_legsDamageR,_legsDamageL); +_unit setHitPointDamage ["hitHead", _headDamage min 0.95]; +_unit setHitPointDamage ["hitBody", _torsoDamage min 0.95]; +_unit setHitPointDamage ["hitHands", (_handsDamageR + _handsDamageL) min 0.95]; +_unit setHitPointDamage ["hitLegs", (_legsDamageR + _legsDamageL) min 0.95]; + +{ + private _hitPointName = [_unit, _x, true] call FUNC(translateSelections); + _unit setHitPointDamage [_hitPointName, (_damageBodyParts select _foreachIndex) min 0.95]; +}foreach GVAR(SELECTIONS); diff --git a/addons/medical/functions/fnc_handleSelectionDamage.sqf b/addons/medical/functions/fnc_handleSelectionDamage.sqf index 247589ae03..a72f973c79 100644 --- a/addons/medical/functions/fnc_handleSelectionDamage.sqf +++ b/addons/medical/functions/fnc_handleSelectionDamage.sqf @@ -18,9 +18,6 @@ params ["_unit", "_selection", "_newDamage", "_projectile"]; -// private _totalDamage = (_unit getHit _selection) + _newDamage; -systemChat format["handleSelectionDamage: %1", _this]; - private _part = [_selection] call FUNC(selectionNameToNumber); if (_part < 0) exitwith {systemchat format["Selection name part is below 0"]}; @@ -38,7 +35,6 @@ if (alive _unit && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { }; if (GVAR(level) > 1) then { // advanced medical is enabled - systemChat format["LEVEL OF MEDICAL SYSTEM IS ADVANCED"]; _typeOfDamage = [_projectile] call FUNC(getTypeOfDamage); // Get the exact type of damage [_unit, _selection, _newDamage, _projectile, _typeOfDamage] call FUNC(handleDamage_assignWounds); @@ -53,7 +49,6 @@ if (GVAR(level) > 1) then { // advanced medical is enabled // [_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_internalInjuries); //}; } else { - systemChat format["LEVEL OF MEDICAL SYSTEM IS BASIC"]; // New pain values _pain = _unit getVariable [QGVAR(pain), 0]; _pain = _pain + (_newDamage / 4) * (1 - (_unit getVariable [QGVAR(morphine), 0]));