From 792dbcd009e077d8b735f45a9d706300e0a4843c Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 13 Jun 2016 11:05:21 +0200 Subject: [PATCH 1/4] Change clean up privates in handleDamage code --- addons/medical/functions/fnc_handleDamage.sqf | 12 +++--- .../functions/fnc_handleDamage_caching.sqf | 42 +++++++++---------- .../functions/fnc_handleDamage_wounds.sqf | 21 +++++----- 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/addons/medical/functions/fnc_handleDamage.sqf b/addons/medical/functions/fnc_handleDamage.sqf index 4cf237e949..abb91ff1c3 100644 --- a/addons/medical/functions/fnc_handleDamage.sqf +++ b/addons/medical/functions/fnc_handleDamage.sqf @@ -26,8 +26,6 @@ if !(local _unit) exitWith { nil }; -private ["_damageReturn", "_typeOfDamage", "_minLethalDamage", "_newDamage", "_typeIndex", "_preventDeath"]; - // bug, assumed fixed, @todo excessive testing, if nothing happens remove if (_projectile isEqualType objNull) then { _projectile = typeOf _projectile; @@ -62,16 +60,16 @@ if !(_unit getVariable [QGVAR(allowDamage), true]) exitWith { }; // Get return damage -_damageReturn = _damage; +private _damageReturn = _damage; -_newDamage = _this call FUNC(handleDamage_caching); +private _newDamage = _this call FUNC(handleDamage_caching); // handleDamage_caching may have modified the projectile string -_typeOfDamage = [_projectile] call FUNC(getTypeOfDamage); +private _typeOfDamage = [_projectile] call FUNC(getTypeOfDamage); TRACE_3("ACE_DEBUG: HandleDamage caching new damage",_selection,_newDamage,_unit); -_typeIndex = (GVAR(allAvailableDamageTypes) find _typeOfDamage); -_minLethalDamage = if (_typeIndex >= 0) then { +private _typeIndex = (GVAR(allAvailableDamageTypes) find _typeOfDamage); +private _minLethalDamage = if (_typeIndex >= 0) then { GVAR(minLethalDamages) select _typeIndex } else { 0.01 diff --git a/addons/medical/functions/fnc_handleDamage_caching.sqf b/addons/medical/functions/fnc_handleDamage_caching.sqf index c1cf726399..970a573374 100644 --- a/addons/medical/functions/fnc_handleDamage_caching.sqf +++ b/addons/medical/functions/fnc_handleDamage_caching.sqf @@ -17,13 +17,12 @@ */ #include "script_component.hpp" -private ["_hitSelections", "_hitPoints", "_impactVelocity", "_newDamage", "_cache_hitpoints", "_cache_projectiles", "_cache_params", "_cache_damages"]; params ["_unit", "_selectionName", "_damage", "_source", "_projectile", "_hitPointIndex"]; -_hitSelections = GVAR(SELECTIONS); +private _hitSelections = GVAR(SELECTIONS); // Calculate change in damage - use getHitIndex because selection is translated (hitdiaphragm->body) -_newDamage = _damage - (damage _unit); +private _newDamage = _damage - (damage _unit); if (_hitPointIndex >= 0) then {_newDamage = _damage - (_unit getHitIndex _hitPointIndex)}; TRACE_7("ACE_DEBUG: HandleDamage_Caching Called",_unit, _selectionName, _damage, _source, _projectile,_hitPointIndex,_newDamage); @@ -40,7 +39,7 @@ if ((_vehicle != _unit) && {!(_vehicle isKindOf "StaticWeapon")} && {_source in }; // Handle falling damage -_impactVelocity = (velocity _unit) select 2; +private _impactVelocity = (velocity _unit) select 2; if (_impactVelocity < -5 && {_vehicle == _unit}) then { TRACE_1("Starting isFalling", time); _unit setVariable [QGVAR(isFalling), true]; @@ -51,6 +50,7 @@ if (_impactVelocity < -5 && {_vehicle == _unit}) then { _unit setVariable [QGVAR(isFalling), false]; }; }; + if (_unit getVariable [QGVAR(isFalling), false]) then { if !(_selectionName in ["", "leg_l", "leg_r"]) then { if (_selectionName == "body") then { @@ -86,11 +86,10 @@ if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) t if (GVAR(level) < 2 || {!([_unit] call FUNC(hasMedicalEnabled))}) then { [_unit] call FUNC(handleDamage_basic); } else { - _cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []]; - _cache_damages = _unit getVariable QGVAR(cachedDamages); + private _cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []]; + private _cache_damages = _unit getVariable QGVAR(cachedDamages); { - _params = _x + [_cache_damages select _forEachIndex]; - _params call FUNC(handleDamage_advanced); + (_x + [_cache_damages select _forEachIndex]) call FUNC(handleDamage_advanced); } forEach _cache_params; [_unit] call FUNC(handleDamage_advancedSetDamage); }; @@ -106,24 +105,23 @@ if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) t // Caching of the damage events if (_selectionName != "") then { - _cache_projectiles = _unit getVariable QGVAR(cachedProjectiles); - private ["_index","_otherDamage"]; - _index = _cache_projectiles find _projectile; + private _cache_projectiles = _unit getVariable QGVAR(cachedProjectiles); + private _index = _cache_projectiles find _projectile; + // Check if the current projectile has already been handled once if (_index >= 0 && {_projectile != "falling"}) exitWith { - _cache_damages = _unit getVariable QGVAR(cachedDamages); - // Find the previous damage this projectile has done - _otherDamage = (_cache_damages select _index); + + private _cache_damages = _unit getVariable QGVAR(cachedDamages); + private _otherDamage = (_cache_damages select _index); // Find the previous damage this projectile has done // Take the highest damage of the two if (_newDamage > _otherDamage) then { - _cache_params = _unit getVariable QGVAR(cachedHandleDamageParams); - _cache_hitpoints = _unit getVariable QGVAR(cachedHitPoints); + private _cache_params = _unit getVariable QGVAR(cachedHandleDamageParams); + private _cache_hitpoints = _unit getVariable QGVAR(cachedHitPoints); - private ["_hitPoint", "_restore"]; // Restore the damage before the previous damage was processed - _hitPoint = _cache_hitpoints select _index; - _restore = ((_unit getHitIndex _hitPoint) - _otherDamage) max 0; + private _hitPoint = _cache_hitpoints select _index; + private _restore = ((_unit getHitIndex _hitPoint) - _otherDamage) max 0; _unit setHitIndex [_hitPoint, _restore]; _cache_hitpoints set [_index, _hitPointIndex]; @@ -137,9 +135,9 @@ if (_selectionName != "") then { }; }; - _cache_hitpoints = _unit getVariable QGVAR(cachedHitPoints); - _cache_damages = _unit getVariable QGVAR(cachedDamages); - _cache_params = _unit getVariable QGVAR(cachedHandleDamageParams); + private _cache_hitpoints = _unit getVariable QGVAR(cachedHitPoints); + private _cache_damages = _unit getVariable QGVAR(cachedDamages); + private _cache_params = _unit getVariable QGVAR(cachedHandleDamageParams); // This is an unhandled projectile _cache_projectiles pushBack _projectile; diff --git a/addons/medical/functions/fnc_handleDamage_wounds.sqf b/addons/medical/functions/fnc_handleDamage_wounds.sqf index 14c74df11a..31a3e360a5 100644 --- a/addons/medical/functions/fnc_handleDamage_wounds.sqf +++ b/addons/medical/functions/fnc_handleDamage_wounds.sqf @@ -17,27 +17,26 @@ #include "script_component.hpp" -private ["_bodyPartn", "_injuryTypeInfo", "_allInjuriesForDamageType", "_allPossibleInjuries", "_highestPossibleDamage", "_highestPossibleSpot", "_minDamage", "_openWounds", "_woundID", "_toAddInjury", "_painToAdd", "_bloodLoss", "_bodyPartNToAdd", "_classType", "_damageLevels", "_foundIndex", "_i", "_injury", "_maxDamage", "_pain", "_painLevel", "_selections", "_toAddClassID", "_woundsCreated"]; params ["_unit", "_selectionName", "_damage", "_typeOfProjectile", "_typeOfDamage"]; TRACE_6("ACE_DEBUG: HandleDamage Called",_unit, _selectionName, _damage, _shooter, _typeOfProjectile,_typeOfDamage); // Administration for open wounds and ids -_openWounds = _unit getVariable[QGVAR(openWounds), []]; -_woundID = _unit getVariable[QGVAR(lastUniqueWoundID), 1]; +private _openWounds = _unit getVariable[QGVAR(openWounds), []]; +private _woundID = _unit getVariable[QGVAR(lastUniqueWoundID), 1]; -_extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _selectionName, _damage, _typeOfDamage, _woundID]; +private _extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _selectionName, _damage, _typeOfDamage, _woundID]; -_painToAdd = 0; -_woundsCreated = []; +private _painToAdd = 0; +private _woundsCreated = []; call compile _extensionOutput; { + _x params ["", "_toAddClassID", "_bodyPartNToAdd"]; _foundIndex = -1; - _toAddClassID = _x select 1; - _bodyPartNToAdd = _x select 2; { + _x params ["", "_compareId", "_comparyBodyPartN"]; // Check if we have an id of the given class on the given bodypart already - if (_x select 1 == _toAddClassID && {_x select 2 == _bodyPartNToAdd}) exitWith { + if (_compareId == _toAddClassID && {_comparyBodyPartN2 == _bodyPartNToAdd}) exitWith { _foundIndex = _forEachIndex; }; } forEach _openWounds; @@ -47,7 +46,7 @@ call compile _extensionOutput; _openWounds pushBack _x; } else { // We already have one of these, so we are just going to increase the number that we have of it with a new one. - _injury = _openWounds select _foundIndex; + private _injury = _openWounds select _foundIndex; _injury set [3, (_injury select 3) + 1]; }; } forEach _woundsCreated; @@ -59,6 +58,6 @@ if (count _woundsCreated > 0) then { _unit setVariable [QGVAR(lastUniqueWoundID), _woundID, true]; }; -_painLevel = _unit getVariable [QGVAR(pain), 0]; +private _painLevel = _unit getVariable [QGVAR(pain), 0]; _unit setVariable [QGVAR(pain), _painLevel + _painToAdd]; TRACE_6("ACE_DEBUG: HandleDamage_WoundsOLD",_unit, _painLevel, _painToAdd, _unit getVariable QGVAR(pain), _unit getVariable QGVAR(openWounds),_woundsCreated); From 6657bde9210f66657f00e3fed7d7fffbb052d369 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 13 Jun 2016 12:18:56 +0200 Subject: [PATCH 2/4] 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; From d56804183826f5510741036ab80899154110709e Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 13 Jun 2016 12:19:19 +0200 Subject: [PATCH 3/4] Change medical menu to work with basic medical injury overhaul --- .../functions/fnc_updateUIInfo.sqf | 65 +++++++++++-------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/addons/medical_menu/functions/fnc_updateUIInfo.sqf b/addons/medical_menu/functions/fnc_updateUIInfo.sqf index e36315bd08..a956cdde69 100644 --- a/addons/medical_menu/functions/fnc_updateUIInfo.sqf +++ b/addons/medical_menu/functions/fnc_updateUIInfo.sqf @@ -106,40 +106,53 @@ if ((EGVAR(medical,level) >= 2) && {([_target] call EFUNC(medical,hasMedicalEnab }; } forEach _bandagedwounds; } else { - _damaged = [true, true, true, true, true, true]; + // Add all bleeding from wounds on selection + _openWounds = _target getVariable [QEGVAR(medical,openWounds), []]; + private "_amountOf"; { - _selectionBloodLoss set [_forEachIndex, _x]; - - if ((_x > 0) && {_forEachIndex == _selectionN}) then { - _pointDamage = _x; - _severity = switch (true) do { - case (_pointDamage > 0.5): {localize ELSTRING(medical,HeavilyWounded)}; - case (_pointDamage > 0.1): {localize ELSTRING(medical,LightlyWounded)}; - default {localize ELSTRING(medical,VeryLightlyWounded)}; - }; - _part = localize ([ - ELSTRING(medical,Head), - ELSTRING(medical,Torso), - ELSTRING(medical,LeftArm), - ELSTRING(medical,RightArm), - ELSTRING(medical,LeftLeg), - ELSTRING(medical,RightLeg) - ] select _forEachIndex); - _allInjuryTexts pushBack [format ["%1 %2", _severity, toLower _part], [1,1,1,1]]; + _amountOf = _x select 3; + // Find how much this bodypart is bleeding + if (_amountOf > 0) then { + _damaged set [_x select 2, true]; + _selectionBloodLoss set [_x select 2, (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))]; }; - } forEach (_target getVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0]]); + } forEach _openWounds; + + _bandagedwounds = _target getVariable [QEGVAR(medical,bandagedWounds), []]; + { + _amountOf = _x select 3; + // Find how much this bodypart is bleeding + if !(_damaged select (_x select 2)) then { + _selectionBloodLoss set [_x select 2, (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))]; + }; + } forEach _bandagedwounds; + + private _bloodLossOnSelection = _selectionBloodLoss select _selectionN; + if (_bloodLossOnSelection > 0) then { + private _severity = switch (true) do { + case (_bloodLossOnSelection > 0.5): {localize ELSTRING(medical,HeavilyWounded)}; + case (_bloodLossOnSelection > 0.1): {localize ELSTRING(medical,LightlyWounded)}; + default {localize ELSTRING(medical,VeryLightlyWounded)}; + }; + private _part = localize ([ + ELSTRING(medical,Head), + ELSTRING(medical,Torso), + ELSTRING(medical,LeftArm), + ELSTRING(medical,RightArm), + ELSTRING(medical,LeftLeg), + ELSTRING(medical,RightLeg) + ] select _selectionN); + _allInjuryTexts pushBack [format ["%1 %2", _severity, toLower _part], [1,1,1,1]]; + }; }; [_selectionBloodLoss, _damaged, _display] call FUNC(updateBodyImage); [_display, _genericMessages, _allInjuryTexts] call FUNC(updateInformationLists); -_logs = _target getVariable [QEGVAR(medical,logFile_activity_view), []]; -[_display, _logs] call FUNC(updateActivityLog); +[_display, _target getVariable [QEGVAR(medical,logFile_activity_view), []]] call FUNC(updateActivityLog); +[_display, _target getVariable [QEGVAR(medical,logFile_quick_view), []]] call FUNC(updateQuickViewLog); -_logs = _target getVariable [QEGVAR(medical,logFile_quick_view), []]; -[_display, _logs] call FUNC(updateQuickViewLog); - -_triageStatus = [_target] call EFUNC(medical,getTriageStatus); +private _triageStatus = [_target] call EFUNC(medical,getTriageStatus); (_display displayCtrl 2000) ctrlSetText (_triageStatus select 0); (_display displayCtrl 2000) ctrlSetBackgroundColor (_triageStatus select 2); From 58f43f8a512cdead824d3b8653a6efdd0efff36a Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 13 Jun 2016 12:24:28 +0200 Subject: [PATCH 4/4] Remove unneeded and deprecated functions from medical --- addons/medical/ACE_Medical_Treatments.hpp | 2 - addons/medical/XEH_PREP.hpp | 6 -- addons/medical/XEH_postInit.sqf | 1 - addons/medical/config.cpp | 1 - .../fnc_displayPatientInformation.sqf | 4 -- .../functions/fnc_handleDamage_basic.sqf | 61 ------------------- .../functions/fnc_onPropagateWound.sqf | 36 ----------- .../functions/fnc_onWoundUpdateRequest.sqf | 24 -------- .../functions/fnc_requestWoundSync.sqf | 22 ------- .../functions/fnc_treatmentBasic_bandage.sqf | 27 -------- .../fnc_treatmentBasic_bandageLocal.sqf | 51 ---------------- 11 files changed, 235 deletions(-) delete mode 100644 addons/medical/functions/fnc_handleDamage_basic.sqf delete mode 100644 addons/medical/functions/fnc_onPropagateWound.sqf delete mode 100644 addons/medical/functions/fnc_onWoundUpdateRequest.sqf delete mode 100644 addons/medical/functions/fnc_requestWoundSync.sqf delete mode 100644 addons/medical/functions/fnc_treatmentBasic_bandage.sqf delete mode 100644 addons/medical/functions/fnc_treatmentBasic_bandageLocal.sqf diff --git a/addons/medical/ACE_Medical_Treatments.hpp b/addons/medical/ACE_Medical_Treatments.hpp index c2a22d36f5..b89afc8b1a 100644 --- a/addons/medical/ACE_Medical_Treatments.hpp +++ b/addons/medical/ACE_Medical_Treatments.hpp @@ -15,8 +15,6 @@ class ACE_Medical_Actions { condition = ""; patientStateCondition = 0; itemConsumed = 1; - - //callbackSuccess = QUOTE(DFUNC(treatmentBasic_bandage)); callbackSuccess = QUOTE(DFUNC(treatmentAdvanced_bandage)); callbackFailure = ""; callbackProgress = ""; diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index 1b5c752653..b754f00f5d 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -35,7 +35,6 @@ PREP(handleDamage); PREP(handleDamage_advanced); PREP(handleDamage_advancedSetDamage); PREP(handleDamage_airway); -PREP(handleDamage_basic); PREP(handleDamage_caching); PREP(handleDamage_fractures); PREP(handleDamage_internalInjuries); @@ -61,8 +60,6 @@ PREP(itemCheck); PREP(medicationEffectLoop); PREP(modifyMedicalAction); PREP(onMedicationUsage); -PREP(onWoundUpdateRequest); -PREP(onPropagateWound); PREP(parseConfigForInjuries); PREP(playInjuredSound); PREP(reviveStateLoop); @@ -88,8 +85,6 @@ PREP(treatmentAdvanced_fullHealTreatmentTime); PREP(treatmentAdvanced_medication); PREP(treatmentAdvanced_medicationLocal); PREP(treatmentAdvanced_surgicalKit_onProgress); -PREP(treatmentBasic_bandage); -PREP(treatmentBasic_bandageLocal); PREP(treatmentBasic_bloodbag); PREP(treatmentBasic_bloodbagLocal); PREP(treatmentBasic_epipen); @@ -113,7 +108,6 @@ PREP(moduleAssignMedicRoles); PREP(moduleAssignMedicalVehicle); PREP(moduleAssignMedicalFacility); PREP(copyDeadBody); -PREP(requestWoundSync); PREP(unconsciousPFH); // Networked litter diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 7e40f09693..487858ca6c 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -21,7 +21,6 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"]; [QGVAR(treatmentAdvanced_CPRLocal), DFUNC(treatmentAdvanced_CPRLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentAdvanced_fullHealLocal), DFUNC(treatmentAdvanced_fullHealLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentAdvanced_medicationLocal), DFUNC(treatmentAdvanced_medicationLocal)] call CBA_fnc_addEventHandler; -[QGVAR(treatmentBasic_bandageLocal), DFUNC(treatmentBasic_bandageLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentBasic_bloodbagLocal), DFUNC(treatmentBasic_bloodbagLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentBasic_morphineLocal), DFUNC(treatmentBasic_morphineLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentIVLocal), DFUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler; diff --git a/addons/medical/config.cpp b/addons/medical/config.cpp index 1bc006471e..ce9c6ea0e9 100644 --- a/addons/medical/config.cpp +++ b/addons/medical/config.cpp @@ -40,7 +40,6 @@ class ACE_newEvents { treatmentIVLocal = QGVAR(treatmentIVLocal); treatmentBasic_morphineLocal = QGVAR(treatmentBasic_morphineLocal); treatmentBasic_bloodbagLocal = QGVAR(treatmentBasic_bloodbagLocal); - treatmentBasic_bandageLocal = QGVAR(treatmentBasic_bandageLocal); treatmentAdvanced_medicationLocal = QGVAR(treatmentAdvanced_medicationLocal); treatmentAdvanced_fullHealLocal = QGVAR(treatmentAdvanced_fullHealLocal); treatmentAdvanced_CPRLocal = QGVAR(treatmentAdvanced_CPRLocal); diff --git a/addons/medical/functions/fnc_displayPatientInformation.sqf b/addons/medical/functions/fnc_displayPatientInformation.sqf index 11bcc3b093..ad53842275 100644 --- a/addons/medical/functions/fnc_displayPatientInformation.sqf +++ b/addons/medical/functions/fnc_displayPatientInformation.sqf @@ -24,10 +24,6 @@ params ["_target", ["_show", true], ["_selectionN", 0]]; GVAR(currentSelectedSelectionN) = [0, _selectionN] select (IS_SCALAR(_selectionN)); GVAR(displayPatientInformationTarget) = [ObjNull, _target] select _show; -if (USE_WOUND_EVENT_SYNC) then { - [_target, ACE_player] call FUNC(requestWoundSync); -}; - if (_show) then { ("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutRsc [QGVAR(DisplayInformation),"PLAIN"]; diff --git a/addons/medical/functions/fnc_handleDamage_basic.sqf b/addons/medical/functions/fnc_handleDamage_basic.sqf deleted file mode 100644 index 0d4e9292a8..0000000000 --- a/addons/medical/functions/fnc_handleDamage_basic.sqf +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Author: KoffeinFlummi, Glowbal - * Handle damage basic medical - * - * Arguments: - * - * Return Value: - * - * - * Public: No - */ - -#include "script_component.hpp" - -params ["_target"]; -TRACE_1("ACE_DEBUG: HandleDamage_BASIC Called",_target); - -private _damageBodyParts = _target getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]; -private _cache_params = _target getVariable [QGVAR(cachedHandleDamageParams), []]; -private _cache_damages = _target getVariable QGVAR(cachedDamages); - -TRACE_4("ACE_DEBUG: HandleDamage BASIC",_unit, _damageBodyParts,_cache_params,_cache_damages); - -{ - _x params ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage"]; - TRACE_6("_x",_unit,_selectionName,_amountOfDamage,_sourceOfDamage,_typeOfProjectile,_typeOfDamage); - if !(isNull _sourceOfDamage && {_typeOfProjectile == ""} && {vehicle _unit == _unit} && {(_selectionName == "head" || isBurning _unit)}) then { - _part = [_selectionName] call FUNC(selectionNameToNumber); - if (_part < 0) exitwith {}; - - private ["_newDamage", "_pain"]; - _newDamage = (_cache_damages select _foreachIndex); - _damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage]; - _unit setVariable [QGVAR(bodyPartStatus), _damageBodyParts]; - - 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 3 frames after the damage has been passed. - if ([_unit, _part, if (_part > 1) then {_newDamage * 1.3} else {_newDamage * 2}] call FUNC(determineIfFatal)) then { - [_unit, true, 0.5+random(10)] call FUNC(setUnconscious); - }; - }; - _pain = _unit getVariable [QGVAR(pain), 0]; - _pain = _pain + (_newDamage / 4) * (1 - (_unit getVariable [QGVAR(morphine), 0])); - _unit setVariable [QGVAR(pain), _pain min 1, true]; - }; -}foreach _cache_params; - -// We broadcast the value across the net here, in order to avoid broadcasting it multiple times earlier in the above code block -_target setVariable [QGVAR(bodyPartStatus), _damageBodyParts, true]; -TRACE_2("ACE_DEBUG: HandleDamage BASIC Broadcast value here",_unit, _target getVariable QGVAR(bodyPartStatus)); - -EXPLODE_6_PVT(_damageBodyParts,_headDamage,_torsoDamage,_handsDamageR,_handsDamageL,_legsDamageR,_legsDamageL); -_target setHitPointDamage ["hitHead", _headDamage min 0.95]; -_target setHitPointDamage ["hitBody", _torsoDamage min 0.95]; -_target setHitPointDamage ["hitHands", (_handsDamageR + _handsDamageL) min 0.95]; -_target setHitPointDamage ["hitLegs", (_legsDamageR + _legsDamageL) min 0.95]; - -{ - private _hitPointName = [_target, _x, true] call FUNC(translateSelections); - _target setHitPointDamage [_hitPointName, (_damageBodyParts select _foreachIndex) min 0.95]; -}foreach GVAR(SELECTIONS); diff --git a/addons/medical/functions/fnc_onPropagateWound.sqf b/addons/medical/functions/fnc_onPropagateWound.sqf deleted file mode 100644 index 84fc33dec2..0000000000 --- a/addons/medical/functions/fnc_onPropagateWound.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Author: Glowbal - * Adds a new injury to the wounds collection from remote clients. Is used to split up the large collection of injuries broadcasting across network. - * - * Arguments: - * 0: The remote unit - * 1: injury - * - * Return Value: - * None - * - * Public: No - */ - -#include "script_component.hpp" - -private ["_unit", "_injury", "_openWounds", "_injuryID", "_exists"]; -params ["_unit", "_injury"]; - -if (!local _unit) then { - _openWounds = _unit getVariable[QGVAR(openWounds), []]; - _injuryID = _injury select 0; - - _exists = false; - { - if (_x select 0 == _injuryID) exitWith { - _exists = true; - _openWounds set [_forEachIndex, _injury]; - }; - } forEach _openWounds; - - if (!_exists) then { - _openWounds pushBack _injury; - }; - _unit setVariable [QGVAR(openWounds), _openWounds]; -}; diff --git a/addons/medical/functions/fnc_onWoundUpdateRequest.sqf b/addons/medical/functions/fnc_onWoundUpdateRequest.sqf deleted file mode 100644 index e0a28dfd18..0000000000 --- a/addons/medical/functions/fnc_onWoundUpdateRequest.sqf +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Author: Glowbal - * Handles an wound update request. - * - * Arguments: - * 0: The Unit - * 1: Origin object - * - * ReturnValue: - * None - * - * Public: Yes - */ - -#include "script_component.hpp" -private ["_unit", "_openWounds", "_originOfrequest"]; -params ["_unit", "_originOfrequest"]; - -if (local _unit && !(local _originOfrequest)) then { - _openWounds = _unit getVariable [QGVAR(openWounds), []]; - { - ["ace_medical_propagateWound", [_unit, _x], [_originOfrequest]] call CBA_fnc_targetEvent; - } forEach _openWounds; -}; diff --git a/addons/medical/functions/fnc_requestWoundSync.sqf b/addons/medical/functions/fnc_requestWoundSync.sqf deleted file mode 100644 index 9f72c0b322..0000000000 --- a/addons/medical/functions/fnc_requestWoundSync.sqf +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Author: Glowbal - * Ask for the latest wound information. - * - * Arguments: - * 0: The target - * 1: object belonging to the caller - * - * ReturnValue: - * None - * - * Public: Yes - */ - -#include "script_component.hpp" - -params [ "_target", "_caller"]; - -if (local _target || GVAR(level) < 2) exitWith {}; // if the target is local, we already got the most update to date information -if (_target getVariable [QGVAR(isWoundSynced), false]) exitWith {}; -_target setVariable [QGVAR(isWoundSynced), true]; -["ace_medical_woundUpdateRequest", [_target, _caller], [_target]] call CBA_fnc_targetEvent; diff --git a/addons/medical/functions/fnc_treatmentBasic_bandage.sqf b/addons/medical/functions/fnc_treatmentBasic_bandage.sqf deleted file mode 100644 index c0411c09e4..0000000000 --- a/addons/medical/functions/fnc_treatmentBasic_bandage.sqf +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Author: KoffeinFlummi - * Callback when the bandaging treatment is complete - * - * Arguments: - * 0: The medic - * 1: The patient - * 2: Selection Name - * 3: Treatment classname - * - * Return Value: - * None - * - * Public: No - */ - -#include "script_component.hpp" -#define BANDAGEHEAL 0.8 - -private ["_hitSelections", "_hitPoints", "_point", "_damage"]; -params ["_caller", "_target", "_selection", "_className"]; - -if (local _target) then { - [QGVAR(treatmentBasic_bandageLocal), [_target, _selection]] call CBA_fnc_localEvent; -} else { - [QGVAR(treatmentBasic_bandageLocal), [_target, _selection], _target] call CBA_fnc_targetEvent; -}; diff --git a/addons/medical/functions/fnc_treatmentBasic_bandageLocal.sqf b/addons/medical/functions/fnc_treatmentBasic_bandageLocal.sqf deleted file mode 100644 index f8c11a7484..0000000000 --- a/addons/medical/functions/fnc_treatmentBasic_bandageLocal.sqf +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Author: Glowbal - * Handles the bandage of a patient. - * - * Arguments: - * 0: The patient - * 1: Treatment classname - * - * - * Return Value: - * Succesful treatment started - * - * Public: No - */ - -#include "script_component.hpp" -#define BANDAGEHEAL 0.8 - -params ["_target", "_selectionName"]; - -private _damageBodyParts = _target getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]; - -// Ensure it is a valid bodypart -private _part = [_selectionName] call FUNC(selectionNameToNumber); -if (_part < 0) exitwith {false}; - -if ((_damageBodyParts select _part) > 0) then { - private _damageOnPart = (_damageBodyParts select _part); - // Temp quick fix to change in behaviour of basic medical bandaging - if (_damageOnPart - BANDAGEHEAL > 0) then { - _damageOnPart = _damageOnPart - (_damageOnPart * BANDAGEHEAL); - } else { - _damageOnPart = _damageOnPart - BANDAGEHEAL; - }; - _damageBodyParts set [_part, _damageOnPart max 0]; - _target setVariable [QGVAR(bodyPartStatus), _damageBodyParts, true]; - TRACE_2("ACE_DEBUG: Treatment BASIC Bandage Broadcast value here",_unit, _target getVariable QGVAR(bodyPartStatus)); -}; - -EXPLODE_6_PVT(_damageBodyParts,_headDamage,_torsoDamage,_handsDamageR,_handsDamageL,_legsDamageR,_legsDamageL); -_target setHitPointDamage ["hitHead", _headDamage min 0.95]; -_target setHitPointDamage ["hitBody", _torsoDamage min 0.95]; -_target setHitPointDamage ["hitHands", (_handsDamageR + _handsDamageL) min 0.95]; -_target setHitPointDamage ["hitLegs", (_legsDamageR + _legsDamageL) min 0.95]; - -{ - private _hitPointName = [_target, _x, true] call FUNC(translateSelections); - _target setHitPointDamage [_hitPointName, (_damageBodyParts select _foreachIndex) min 0.95]; -}foreach GVAR(SELECTIONS); - -true;