From 6657bde9210f66657f00e3fed7d7fffbb052d369 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 13 Jun 2016 12:18:56 +0200 Subject: [PATCH] Change basic medical to use advanced medical injury system --- addons/medical/ACE_Medical_Treatments.hpp | 14 ++- addons/medical/XEH_postInit.sqf | 21 ++-- .../medical/functions/fnc_adjustPainLevel.sqf | 2 - .../fnc_displayPatientInformation.sqf | 102 +++++++----------- addons/medical/functions/fnc_getBloodLoss.sqf | 38 +++---- .../functions/fnc_handleDamage_caching.sqf | 17 ++- .../functions/fnc_handleUnitVitals.sqf | 59 +++------- .../functions/fnc_isInStableCondition.sqf | 10 +- .../functions/fnc_modifyMedicalAction.sqf | 28 +++-- .../fnc_treatmentAdvanced_bandage.sqf | 4 - .../fnc_treatmentAdvanced_bandageLocal.sqf | 10 +- .../functions/fnc_treatment_success.sqf | 26 ++--- 12 files changed, 117 insertions(+), 214 deletions(-) diff --git a/addons/medical/ACE_Medical_Treatments.hpp b/addons/medical/ACE_Medical_Treatments.hpp index 059a5d3605..c2a22d36f5 100644 --- a/addons/medical/ACE_Medical_Treatments.hpp +++ b/addons/medical/ACE_Medical_Treatments.hpp @@ -16,7 +16,8 @@ class ACE_Medical_Actions { patientStateCondition = 0; itemConsumed = 1; - callbackSuccess = QUOTE(DFUNC(treatmentBasic_bandage)); + //callbackSuccess = QUOTE(DFUNC(treatmentBasic_bandage)); + callbackSuccess = QUOTE(DFUNC(treatmentAdvanced_bandage)); callbackFailure = ""; callbackProgress = ""; @@ -67,7 +68,8 @@ class ACE_Medical_Actions { requiredMedic = 1; treatmentTime = 20; items[] = {"ACE_bloodIV"}; - callbackSuccess = QUOTE(DFUNC(treatmentBasic_bloodbag)); + // callbackSuccess = QUOTE(DFUNC(treatmentBasic_bloodbag)); + callbackSuccess = QUOTE(DFUNC(treatmentIV)); animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; litter[] = {}; }; @@ -689,6 +691,12 @@ class ACE_Medical_Advanced { // packing bandage is average treatment, higher reopen change, longer reopening delay // elastic bandage is higher treatment, higher reopen change, shorter reopen delay // quickclot is lower treatment, lower reopen change, longer reopening delay + class Bandage { // basic bandage + effectiveness = 5; + reopeningChance = 0; + reopeningMinDelay = 0; + reopeningMaxDelay = 0; + }; class FieldDressing { // How effect is the bandage for treating one wounds type injury @@ -1231,7 +1239,7 @@ class ACE_Medical_Advanced { }; }; }; - + class Medication { // How much does the pain get reduced? painReduce = 0; diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 194292de27..7e40f09693 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -156,6 +156,7 @@ GVAR(effectTimeBlood) = CBA_missionTime; // Blood Volume Effect _blood = (ACE_player getVariable [QGVAR(bloodVolume), 100]) / 100; + // TODO scale up to 200% if (_blood > 0.99) then { GVAR(effectBloodVolumeCC) ppEffectEnable false; } else { @@ -266,25 +267,15 @@ GVAR(lastHeartBeatSound) = CBA_missionTime; // Networked litter (need to wait for GVAR(litterCleanUpDelay) to be set) [QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler); - if (GVAR(level) == 2) exitWith { - [ - {(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 65)}, - {(((_this select 0) getVariable [QGVAR(pain), 0]) - ((_this select 0) getVariable [QGVAR(painSuppress), 0])) > 0.9}, - {(([_this select 0] call FUNC(getBloodLoss)) > 0.25)}, - {((_this select 0) getVariable [QGVAR(inReviveState), false])}, - {((_this select 0) getVariable [QGVAR(inCardiacArrest), false])}, - {((_this select 0) getVariable ["ACE_isDead", false])}, - {(((_this select 0) getVariable [QGVAR(airwayStatus), 100]) < 80)} - ] call FUNC(addUnconsciousCondition); - }; - [ - {(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 40)}, - {(((_this select 0) getVariable [QGVAR(pain), 0]) - ((_this select 0) getVariable [QGVAR(painSuppress), 0])) > 0.6}, - {(([_this select 0] call FUNC(getBloodLoss)) > 0.1)}, + {(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 65)}, + {(((_this select 0) getVariable [QGVAR(pain), 0]) - ((_this select 0) getVariable [QGVAR(painSuppress), 0])) > 0.9}, + {(([_this select 0] call FUNC(getBloodLoss)) > 0.25)}, {((_this select 0) getVariable [QGVAR(inReviveState), false])}, + {((_this select 0) getVariable [QGVAR(inCardiacArrest), false])}, {((_this select 0) getVariable ["ACE_isDead", false])} ] call FUNC(addUnconsciousCondition); + }] call CBA_fnc_addEventHandler; // Prevent all types of interaction while unconscious diff --git a/addons/medical/functions/fnc_adjustPainLevel.sqf b/addons/medical/functions/fnc_adjustPainLevel.sqf index b78ee3d4f7..e37972d0ef 100644 --- a/addons/medical/functions/fnc_adjustPainLevel.sqf +++ b/addons/medical/functions/fnc_adjustPainLevel.sqf @@ -28,8 +28,6 @@ if (GVAR(level) == 0) exitWith {}; private _pain = ((_unit getVariable [QGVAR(pain), 0]) + _addedPain) max 0; -if (GVAR(level) == 1) then {_pain = _pain min 1;}; //for basic, cap at 1 - _unit setVariable [QGVAR(pain), _pain]; //Start up the vital watching (if not already running) diff --git a/addons/medical/functions/fnc_displayPatientInformation.sqf b/addons/medical/functions/fnc_displayPatientInformation.sqf index 0f44ea5699..11bcc3b093 100644 --- a/addons/medical/functions/fnc_displayPatientInformation.sqf +++ b/addons/medical/functions/fnc_displayPatientInformation.sqf @@ -54,10 +54,8 @@ if (_show) then { private _allInjuryTexts = []; private _genericMessages = []; - if (GVAR(level) >= 2 && {([_unit] call FUNC(hasMedicalEnabled))}) then { - private _partText = [LSTRING(Head), LSTRING(Torso), LSTRING(LeftArm) ,LSTRING(RightArm) ,LSTRING(LeftLeg), LSTRING(RightLeg)] select _selectionN; - _genericMessages pushback [localize _partText, [1, 1, 1, 1]]; - }; + private _partText = [LSTRING(Head), LSTRING(Torso), LSTRING(LeftArm) ,LSTRING(RightArm) ,LSTRING(LeftLeg), LSTRING(RightLeg)] select _selectionN; + _genericMessages pushback [localize _partText, [1, 1, 1, 1]]; if (_target getVariable[QGVAR(isBleeding), false]) then { _genericMessages pushback [localize LSTRING(Status_Bleeding), [1, 0.1, 0.1, 1]]; @@ -80,81 +78,57 @@ if (_show) then { _totalIvVolume = _totalIvVolume + (_target getVariable [_x, 0]); }; } foreach GVAR(IVBags); + if (_totalIvVolume >= 1) then { _genericMessages pushback [format[localize LSTRING(receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]]; }; private _damaged = [false, false, false, false, false, false]; private _selectionBloodLoss = [0,0,0,0,0,0]; - if (GVAR(level) >= 2 && {([_target] call FUNC(hasMedicalEnabled))}) then { - private _openWounds = _target getVariable [QGVAR(openWounds), []]; - { - _x params ["", "_x1", "_selectionX", "_amountOf", "_x4"]; - // Find how much this bodypart is bleeding - if (_amountOf > 0) then { - _damaged set [_selectionX, true]; - _selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))]; - if (_selectionN == _selectionX) then { - // Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this] - if (_amountOf >= 1) then { - // TODO localization - _allInjuryTexts pushback [format["%2x %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6, ceil _amountOf], [1,1,1,1]]; - } else { - // TODO localization - _allInjuryTexts pushback [format["Partial %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6], [1,1,1,1]]; - }; - }; - }; - } foreach _openWounds; + private _openWounds = _target getVariable [QGVAR(openWounds), []]; + { + _x params ["", "_x1", "_selectionX", "_amountOf", "_x4"]; + // Find how much this bodypart is bleeding + if (_amountOf > 0) then { + _damaged set [_selectionX, true]; + _selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))]; - private _bandagedwounds = _target getVariable [QGVAR(bandagedWounds), []]; - { - _x params ["", "", "_selectionX", "_amountOf", "_x4"]; - // Find how much this bodypart is bleeding - if !(_damaged select _selectionX) then { - _selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))]; - }; if (_selectionN == _selectionX) then { - // Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this] - if (_amountOf > 0) then { - if (_amountOf >= 1) then { - // TODO localization - _allInjuryTexts pushback [format["[B] %2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, ceil _amountOf], [0.88,0.7,0.65,1]]; - } else { - // TODO localization - _allInjuryTexts pushback [format["[B] Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6], [0.88,0.7,0.65,1]]; - }; + // Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this] + if (_amountOf >= 1) then { + // TODO localization + _allInjuryTexts pushback [format["%2x %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6, ceil _amountOf], [1,1,1,1]]; + } else { + // TODO localization + _allInjuryTexts pushback [format["Partial %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6], [1,1,1,1]]; }; }; - } foreach _bandagedwounds; - } else { - private _damaged = [true, true, true, true, true, true]; - { - private _hitPoint = [_target, _x, true] call FUNC(translateSelections); - _selectionBloodLoss set [_forEachIndex, _target getHitPointDamage _hitPoint]; - if (_target getHitPointDamage _hitPoint > 0 && {_forEachIndex == _selectionN}) then { - private _pointDamage = _target getHitPointDamage _hitPoint; - private _severity = switch (true) do { - case (_pointDamage > 0.5): {localize LSTRING(HeavilyWounded)}; - case (_pointDamage > 0.1): {localize LSTRING(LightlyWounded)}; - default {localize LSTRING(VeryLightlyWounded)}; + }; + } foreach _openWounds; + + private _bandagedwounds = _target getVariable [QGVAR(bandagedWounds), []]; + { + _x params ["", "", "_selectionX", "_amountOf", "_x4"]; + // Find how much this bodypart is bleeding + if !(_damaged select _selectionX) then { + _selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))]; + }; + if (_selectionN == _selectionX) then { + // Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this] + if (_amountOf > 0) then { + if (_amountOf >= 1) then { + // TODO localization + _allInjuryTexts pushback [format["[B] %2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, ceil _amountOf], [0.88,0.7,0.65,1]]; + } else { + // TODO localization + _allInjuryTexts pushback [format["[B] Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6], [0.88,0.7,0.65,1]]; }; - private _part = localize ([ - LSTRING(Head), - LSTRING(Torso), - LSTRING(LeftArm), - LSTRING(RightArm), - LSTRING(LeftLeg), - LSTRING(RightLeg) - ] select _forEachIndex); - _allInjuryTexts pushBack [format ["%1 %2", _severity, toLower _part], [1,1,1,1]]; }; - } forEach GVAR(SELECTIONS); - }; + }; + } foreach _bandagedwounds; // Handle the body image coloring - private _availableSelections = [50,51,52,53,54,55]; { private _total = _x; diff --git a/addons/medical/functions/fnc_getBloodLoss.sqf b/addons/medical/functions/fnc_getBloodLoss.sqf index 26727d3d8e..8f2f968e99 100644 --- a/addons/medical/functions/fnc_getBloodLoss.sqf +++ b/addons/medical/functions/fnc_getBloodLoss.sqf @@ -15,35 +15,21 @@ #define BLOODLOSSRATE_BASIC 0.2 -private ["_totalBloodLoss","_tourniquets","_openWounds", "_cardiacOutput", "_internalWounds"]; // TODO Only use this calculation if medium or higher, otherwise use vanilla calculations (for basic medical). params ["_unit"]; -_totalBloodLoss = 0; -// Advanced medical bloodloss handling -if (GVAR(level) >= 2) then { - _tourniquets = _unit getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; - _openWounds = _unit getVariable [QGVAR(openWounds), []]; - //_cardiacOutput = [_unit] call FUNC(getCardiacOutput); - - { - if ((_tourniquets select (_x select 2)) == 0) then { - // total bleeding ratio * percentage of injury left - _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); - - // (((BLOODLOSS_SMALL_WOUNDS * (_x select 0))) + ((BLOODLOSS_MEDIUM_WOUNDS * (_x select 1))) + ((BLOODLOSS_LARGE_WOUNDS * (_x select 2))) * (_cardiacOutput / DEFAULT_CARDIAC_OUTPUT)); - }; - } forEach _openWounds; - - _internalWounds = _unit getVariable [QGVAR(internalWounds), []]; - { +private _totalBloodLoss = 0; +private _tourniquets = _unit getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; +{ + if ((_tourniquets select (_x select 2)) == 0) then { + // total bleeding ratio * percentage of injury left _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); - } forEach _internalWounds; + // (((BLOODLOSS_SMALL_WOUNDS * (_x select 0))) + ((BLOODLOSS_MEDIUM_WOUNDS * (_x select 1))) + ((BLOODLOSS_LARGE_WOUNDS * (_x select 2))) * (_cardiacOutput / DEFAULT_CARDIAC_OUTPUT)); + }; +} forEach (_unit getVariable [QGVAR(openWounds), []]); + +{ + _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); +} forEach (_unit getVariable [QGVAR(internalWounds), []]); - // cap the blood loss to be no greater as the current cardiac output - //(_totalBloodLoss min _cardiacOutput); -} else { - { _totalBloodLoss = _totalBloodLoss + _x } forEach (_unit getVariable [QGVAR(bodyPartStatus), []]); - _totalBloodLoss = (_totalBloodLoss / 6) * BLOODLOSSRATE_BASIC; -}; _totalBloodLoss * ((_unit getVariable [QGVAR(bleedingCoefficient), GVAR(bleedingCoefficient)]) max 0); diff --git a/addons/medical/functions/fnc_handleDamage_caching.sqf b/addons/medical/functions/fnc_handleDamage_caching.sqf index 970a573374..ec245b5b06 100644 --- a/addons/medical/functions/fnc_handleDamage_caching.sqf +++ b/addons/medical/functions/fnc_handleDamage_caching.sqf @@ -82,17 +82,12 @@ if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) t _args params ["_unit", "_frameno"]; if (diag_frameno >= _frameno + 2) then { _unit setDamage 0; - - if (GVAR(level) < 2 || {!([_unit] call FUNC(hasMedicalEnabled))}) then { - [_unit] call FUNC(handleDamage_basic); - } else { - private _cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []]; - private _cache_damages = _unit getVariable QGVAR(cachedDamages); - { - (_x + [_cache_damages select _forEachIndex]) call FUNC(handleDamage_advanced); - } forEach _cache_params; - [_unit] call FUNC(handleDamage_advancedSetDamage); - }; + private _cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []]; + private _cache_damages = _unit getVariable QGVAR(cachedDamages); + { + (_x + [_cache_damages select _forEachIndex]) call FUNC(handleDamage_advanced); + } forEach _cache_params; + [_unit] call FUNC(handleDamage_advancedSetDamage); [_idPFH] call CBA_fnc_removePerFrameHandler; }; }, 0, [_unit, diag_frameno] ] call CBA_fnc_addPerFrameHandler; diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 8cbc38e63a..96fecef035 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -31,8 +31,8 @@ _unit setVariable [QGVAR(bloodVolume), _bloodVolume, _syncValues]; TRACE_3("ACE_DEBUG",_bloodVolume,_syncValues,_unit); // Set variables for synchronizing information across the net if (_bloodVolume < 100) then { - if ((_bloodVolume < 90 && (GVAR(level) == 2)) || _bloodVolume <= 45) then { - TRACE_4("ACE_DEBUG_ADVANCED",_bloodVolume,_unit getVariable QGVAR(hasLostBlood),_syncValues,_unit); + if (_bloodVolume < 90) then { + TRACE_4("ACE_DEBUG",_bloodVolume,_unit getVariable QGVAR(hasLostBlood),_syncValues,_unit); if (_unit getVariable [QGVAR(hasLostBlood), 0] != 2) then { _unit setVariable [QGVAR(hasLostBlood), 2, true]; }; @@ -41,7 +41,7 @@ if (_bloodVolume < 100) then { if (_unit getVariable [QGVAR(hasLostBlood), 0] != 1) then { _unit setVariable [QGVAR(hasLostBlood), 1, true]; }; - } + }; } else { TRACE_4("ACE_DEBUG",_bloodVolume,_unit getVariable QGVAR(hasLostBlood),_syncValues,_unit); if (_unit getVariable [QGVAR(hasLostBlood), 0] != 0) then { @@ -72,6 +72,18 @@ if (_painStatus > (_unit getVariable [QGVAR(painSuppress), 0])) then { }; }; +if (_bloodVolume < 30) exitWith { + [_unit] call FUNC(setDead); +}; + +if ([_unit] call EFUNC(common,isAwake)) then { + if (_bloodVolume < 60) then { + if (random(1) > 0.9) then { + [_unit, true, 15 + random(20)] call FUNC(setUnconscious); + }; + }; +}; + if (GVAR(level) == 1) then { TRACE_5("ACE_DEBUG_BASIC_VITALS",_painStatus,_unit getVariable QGVAR(hasPain),_unit getVariable QGVAR(morphine),_syncValues,_unit); // reduce pain @@ -83,30 +95,11 @@ if (GVAR(level) == 1) then { if (_unit getVariable [QGVAR(morphine), 0] > 0) then { _unit setVariable [QGVAR(morphine), ((_unit getVariable [QGVAR(morphine), 0]) - 0.0015 * _interval) max 0, _syncValues]; }; - - // bleeding - if (_bloodVolume <= 35 and !(_unit getVariable ["ACE_isUnconscious", false])) then { - [_unit, true] call FUNC(setUnconscious); - }; - if (_bloodVolume == 0) then { - [_unit] call FUNC(setDead); - }; }; // handle advanced medical, with vitals if (GVAR(level) >= 2) then { TRACE_6("ACE_DEBUG_ADVANCED_VITALS",_painStatus,_bloodVolume, _unit getVariable QGVAR(hasPain),_unit getVariable QGVAR(morphine),_syncValues,_unit); - if (_bloodVolume < 30) exitWith { - [_unit] call FUNC(setDead); - }; - - if ([_unit] call EFUNC(common,isAwake)) then { - if (_bloodVolume < 60) then { - if (random(1) > 0.9) then { - [_unit, true, 15 + random(20)] call FUNC(setUnconscious); - }; - }; - }; // Handle pain due tourniquets, that have been applied more than 120 s ago private _oldTourniquets = (_unit getVariable [QGVAR(tourniquets), []]) select {_x > 0 && {CBA_missionTime - _x > 120}}; @@ -126,28 +119,6 @@ if (GVAR(level) >= 2) then { _unit setVariable [QGVAR(pain), (_painStatus - _painReduce * _interval) max 0, _syncValues]; TRACE_8("ACE_DEBUG_ADVANCED_VITALS",_painStatus,_painReduce,_heartRate,_bloodVolume,_bloodPressure,_interval,_syncValues,_unit); - // TODO Disabled until implemented fully - // Handle airway - /*if (GVAR(setting_allowAirwayInjuries)) then { - private _airwayStatus = _unit getVariable [QGVAR(airwayStatus), 100]; - if (((_unit getVariable [QGVAR(airwayOccluded), false]) || (_unit getVariable [QGVAR(airwayCollapsed), false])) && !((_unit getVariable [QGVAR(airwaySecured), false]))) then { - if (_airwayStatus >= 0.5) then { - _unit setVariable [QGVAR(airwayStatus), _airwayStatus - 0.5 * _interval, _syncValues]; - }; - } else { - if !((_unit getVariable [QGVAR(airwayOccluded), false]) || (_unit getVariable [QGVAR(airwayCollapsed), false])) then { - if (_airwayStatus < 100) then { - _unit setVariable [QGVAR(airwayStatus), (_airwayStatus + 1.5 * _interval) min 100, _syncValues]; - }; - }; - }; - if (_airwayStatus < 80) then { - [_unit] call FUNC(setUnconscious); - if (_airwayStatus <= 0) then { - [_unit, true] call FUNC(setDead); - }; - }; - };*/ // Check vitals for medical status // TODO check for in revive state instead of variable diff --git a/addons/medical/functions/fnc_isInStableCondition.sqf b/addons/medical/functions/fnc_isInStableCondition.sqf index e0298ed054..a11e40dd31 100644 --- a/addons/medical/functions/fnc_isInStableCondition.sqf +++ b/addons/medical/functions/fnc_isInStableCondition.sqf @@ -13,18 +13,12 @@ #include "script_component.hpp" -private ["_openWounds", "_openWounds"]; params ["_unit"]; -if (GVAR(level) <= 1) exitWith { - ([_unit] call FUNC(getBloodloss)) == 0; -}; - -_totalBloodLoss = 0; -_openWounds = _unit getVariable [QGVAR(openWounds), []]; +private _totalBloodLoss = 0; { // total bleeding ratio * percentage of injury left _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); -} forEach _openWounds; +} forEach (_unit getVariable [QGVAR(openWounds), []]); (_totalBloodLoss == 0); diff --git a/addons/medical/functions/fnc_modifyMedicalAction.sqf b/addons/medical/functions/fnc_modifyMedicalAction.sqf index 8c8e64d465..0081529c5a 100644 --- a/addons/medical/functions/fnc_modifyMedicalAction.sqf +++ b/addons/medical/functions/fnc_modifyMedicalAction.sqf @@ -17,23 +17,21 @@ #include "script_component.hpp" -params ["_target", "_player", "_selectionN", "_actionData"]; +params ["_target", "_player", "_partNumber", "_actionData"]; -if (GVAR(level) < 2 || {!([_target] call FUNC(hasMedicalEnabled))}) exitWith { - private _pointDamage = (_target getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]) select _selectionN; - - if (_pointDamage >= 0.8) exitWith { - _actionData set [2, QPATHTOF(UI\icons\medical_crossRed.paa)]; +private _bloodLossOnSelection = 0; +// Add all bleeding from wounds on selection +{ + _x params ["", "", "_selectionX", "_amountOf", "_percentageOpen"]; + if (_selectionX == _partNumber) then { + _bloodLossOnSelection = _bloodLossOnSelection + (_amountOf * _percentageOpen); }; - if (_pointDamage > 0) exitWith { +} forEach (_target getvariable [QGVAR(openWounds), []]); + +if (_bloodLossOnSelection >=1 ) then { + _actionData set [2, QPATHTOF(UI\icons\medical_crossRed.paa)]; +} else { + if (_bloodLossOnSelection > 0 ) then { _actionData set [2, QPATHTOF(UI\icons\medical_crossYellow.paa)]; }; }; - -private _openWounds = _target getVariable [QGVAR(openWounds), []]; -{ - _x params ["", "", "_selectionX", "_amountOf", "_x4"]; - if (_amountOf > 0 && {(_selectionN == _selectionX)} && {_x4 > 0}) exitWith { - _actionData set [2, QPATHTOF(UI\icons\medical_crossRed.paa)]; - }; -} forEach _openWounds; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf b/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf index e3b94700d2..0db3e641b3 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf @@ -23,10 +23,6 @@ params ["_caller", "_target", "_selectionName", "_className", "_items", "", ["_s [_target, "activity", LSTRING(Activity_bandagedPatient), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); [_target, "activity_view", LSTRING(Activity_bandagedPatient), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message -if !([_target] call FUNC(hasMedicalEnabled)) exitWith { - _this call FUNC(treatmentBasic_bandage); -}; - if (local _target) then { [QGVAR(treatmentAdvanced_bandageLocal), [_target, _className, _selectionName, _specificSpot]] call CBA_fnc_localEvent; } else { diff --git a/addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf index 39ebc6878c..0ad6d854f5 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf @@ -34,6 +34,7 @@ if (isClass (_config >> _bandage)) then { }; // Figure out which injury for this bodypart is the best choice to bandage +// TODO also use up the remainder on left over injuries private _mostEffectiveSpot = 0; private _effectivenessFound = -1; private _mostEffectiveInjury = _openWounds select 0; @@ -86,13 +87,10 @@ private _impact = if ((_mostEffectiveInjury select 3) >= _effectivenessFound) th _mostEffectiveInjury set [ 3, ((_mostEffectiveInjury select 3) - _impact) max 0]; _openWounds set [_mostEffectiveSpot, _mostEffectiveInjury]; -_target setVariable [QGVAR(openWounds), _openWounds, !USE_WOUND_EVENT_SYNC]; +_target setVariable [QGVAR(openWounds), _openWounds, true]; -if (USE_WOUND_EVENT_SYNC) then { - ["ace_medical_propagateWound", [_target, _mostEffectiveInjury]] call CBA_fnc_globalEvent; -}; // Handle the reopening of bandaged wounds -if (_impact > 0 && {GVAR(enableAdvancedWounds)}) then { +if (_impact > 0 && {GVAR(level) >= 2} && {GVAR(enableAdvancedWounds)}) then { [_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening); }; @@ -100,7 +98,7 @@ if (_impact > 0 && {GVAR(enableAdvancedWounds)}) then { // so that the body part functions normally and blood is removed from the uniform. // Arma combines left and right arms into a single body part (HitHands), same with left and right legs (HitLegs). // Arms are actually hands. -if (GVAR(healHitPointAfterAdvBandage)) then { +if (GVAR(healHitPointAfterAdvBandage) || {GVAR(level) < 2}) then { // Get the list of the wounds the target is currently suffering from. private _currentWounds = _target getVariable [QGVAR(openWounds), []]; diff --git a/addons/medical/functions/fnc_treatment_success.sqf b/addons/medical/functions/fnc_treatment_success.sqf index 98befeab04..f0f6ecf015 100644 --- a/addons/medical/functions/fnc_treatment_success.sqf +++ b/addons/medical/functions/fnc_treatment_success.sqf @@ -69,22 +69,16 @@ if (!(_callback isEqualType {})) then {_callback = {TRACE_1("callback was NOT co //Get current blood loose on limb (for "bloody" litter) private _bloodLossOnSelection = 0; private _partNumber = ([_selectionName] call FUNC(selectionNameToNumber)) max 0; -if ((GVAR(level) >= 2) && {([_target] call FUNC(hasMedicalEnabled))}) then { - //Advanced Medical - Add all bleeding from wounds on selection - private _openWounds = _target getvariable [QGVAR(openWounds), []]; - { - _x params ["", "", "_selectionX", "_amountOf", "_bleedingRatio"]; - if (_selectionX == _partNumber) then { - _bloodLossOnSelection = _bloodLossOnSelection + (_amountOf * _bleedingRatio); - }; - } forEach _openWounds; - TRACE_1("advanced",_bloodLossOnSelection); -} else { - //Basic Medical (just use blodyPartStatus): - private _damageBodyParts = _target getvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]; - _bloodLossOnSelection = _damageBodyParts select _partNumber; - TRACE_1("basic",_bloodLossOnSelection); -}; + +// Add all bleeding from wounds on selection +private _openWounds = _target getvariable [QGVAR(openWounds), []]; +{ + _x params ["", "", "_selectionX", "_amountOf", "_percentageOpen"]; + if (_selectionX == _partNumber) then { + _bloodLossOnSelection = _bloodLossOnSelection + (_amountOf * _percentageOpen); + }; +} forEach _openWounds; +TRACE_1("advanced",_bloodLossOnSelection); _args call _callback; _args pushBack _bloodLossOnSelection;