diff --git a/addons/medical/ACE_Medical_Treatments.hpp b/addons/medical/ACE_Medical_Treatments.hpp index 8eacf39006..079ae40506 100644 --- a/addons/medical/ACE_Medical_Treatments.hpp +++ b/addons/medical/ACE_Medical_Treatments.hpp @@ -11,6 +11,7 @@ class ACE_Medical_Actions { treatmentTimeSelfCoef = 1; items[] = {{"ACE_fieldDressing", "ACE_packingBandage", "ACE_elasticBandage", "ACE_quikclot"}}; condition = ""; + patientStateCondition = 0; itemConsumed = 1; callbackSuccess = QUOTE(DFUNC(treatmentBasic_bandage)); @@ -107,6 +108,7 @@ class ACE_Medical_Actions { // Item required for the action. Leave empty for no item required. items[] = {"ACE_fieldDressing"}; condition = ""; + patientStateCondition = 0; // Callbacks callbackSuccess = QUOTE(DFUNC(treatmentAdvanced_bandage)); callbackFailure = ""; @@ -206,6 +208,7 @@ class ACE_Medical_Actions { items[] = {"ACE_surgicalKit"}; treatmentLocations[] = {QGVAR(useLocation_SurgicalKit)}; requiredMedic = QGVAR(medicSetting_SurgicalKit); + patientStateCondition = QGVAR(useCondition_SurgicalKit); treatmentTime = "(count ((_this select 1) getVariable ['ACE_Medical_bandagedWounds', []]) * 5)"; callbackSuccess = ""; callbackProgress = QUOTE(DFUNC(treatmentAdvanced_surgicalKit_onProgress)); @@ -219,6 +222,7 @@ class ACE_Medical_Actions { items[] = {"ACE_personalAidKit"}; treatmentLocations[] = {QGVAR(useLocation_PAK)}; requiredMedic = QGVAR(medicSetting_PAK); + patientStateCondition = QGVAR(useCondition_PAK); treatmentTime = QUOTE((_this select 1) call FUNC(treatmentAdvanced_fullHealTreatmentTime)); callbackSuccess = QUOTE(DFUNC(treatmentAdvanced_fullHeal)); itemConsumed = QGVAR(consumeItem_PAK); @@ -266,10 +270,10 @@ class ACE_Medical_Actions { requiredMedic = 0; treatmentTime = 15; items[] = {}; - condition = "((_this select 1) getvariable ['ACE_medical_inCardiacArrest', false])"; + condition = "!([(_this select 1)] call ace_common_fnc_isAwake)"; callbackSuccess = QUOTE(DFUNC(treatmentAdvanced_CPR)); callbackFailure = ""; - callbackProgress = "(((_this select 0) select 1) getvariable ['ACE_medical_inCardiacArrest', false])"; + callbackProgress = "!([((_this select 0) select 1)] call ace_common_fnc_isAwake)"; animationPatient = ""; animationPatientUnconscious = "AinjPpneMstpSnonWrflDnon_rolltoback"; animationCaller = "AinvPknlMstpSlayWnonDnon_medic"; diff --git a/addons/medical/ACE_Settings.hpp b/addons/medical/ACE_Settings.hpp index 2b28e91882..fcaba03aa0 100644 --- a/addons/medical/ACE_Settings.hpp +++ b/addons/medical/ACE_Settings.hpp @@ -133,6 +133,20 @@ class ACE_Settings { value = 2; values[] = {"Anywhere", "Medical vehicles", "Medical facility", "vehicle & facility", "Disabled"}; }; + class GVAR(useCondition_PAK) { + displayName = CSTRING(AdvancedMedicalSettings_useCondition_PAK_DisplayName); + description = CSTRING(AdvancedMedicalSettings_useCondition_PAK_Description); + typeName = "SCALAR"; + value = 0; + values[] = {"Anytime", "Stable"}; + }; + class GVAR(useCondition_SurgicalKit) { + displayName = CSTRING(AdvancedMedicalSettings_useCondition_SurgicalKit_DisplayName); + description = CSTRING(AdvancedMedicalSettings_useCondition_SurgicalKit_Description); + typeName = "SCALAR"; + value = 0; + values[] = {"Anytime", "Stable"}; + }; class GVAR(keepLocalSettingsSynced) { typeName = "BOOL"; value = 1; diff --git a/addons/medical/CfgVehicles.hpp b/addons/medical/CfgVehicles.hpp index c8a4528ca5..66df5550fc 100644 --- a/addons/medical/CfgVehicles.hpp +++ b/addons/medical/CfgVehicles.hpp @@ -196,13 +196,21 @@ class CfgVehicles { class consumeItem_PAK { displayName = CSTRING(AdvancedMedicalSettings_consumeItem_PAK_DisplayName); description = CSTRING(AdvancedMedicalSettings_consumeItem_PAK_Description); - typeName = "NUMBER"; class values { class keep { name = CSTRING(No); value = 0; }; class remove { name = CSTRING(Yes); value = 1; default = 1; }; }; }; + class useCondition_PAK { + displayName = CSTRING(AdvancedMedicalSettings_useCondition_PAK_DisplayName); + description = CSTRING(AdvancedMedicalSettings_useCondition_PAK_Description); + typeName = "NUMBER"; + class values { + class AnyTime { name = CSTRING(AnyTime); value = 0; }; + class Stable { name = CSTRING(Stable); value = 1; default = 1; }; + }; + }; class useLocation_PAK { displayName = CSTRING(AdvancedMedicalSettings_useLocation_PAK_DisplayName); description = CSTRING(AdvancedMedicalSettings_useLocation_PAK_Description); @@ -227,15 +235,23 @@ class CfgVehicles { displayName = CSTRING(AdvancedMedicalSettings_useLocation_SurgicalKit_DisplayName); description = CSTRING(AdvancedMedicalSettings_useLocation_SurgicalKit_Description); }; + class useCondition_SurgicalKit: useCondition_PAK { + displayName = CSTRING(AdvancedMedicalSettings_useCondition_SurgicalKit_DisplayName); + description = CSTRING(AdvancedMedicalSettings_useCondition_SurgicalKit_Description); + class values { + class AnyTime { name = CSTRING(AnyTime); value = 0; default = 1; }; + class Stable { name = CSTRING(Stable); value = 1; }; + }; + }; class healHitPointAfterAdvBandage { displayName = CSTRING(AdvancedMedicalSettings_healHitPointAfterAdvBandage_DisplayName); - description = CSTRING(AdvancedMedicalSettings_healHitPointAfterAdvBandage_Description); + description = CSTRING(AdvancedMedicalSettings_healHitPointAfterAdvBandage_Description); typeName = "BOOL"; defaultValue = 0; }; class painIsOnlySuppressed { displayName = CSTRING(AdvancedMedicalSettings_painIsOnlySuppressed_DisplayName); - description = CSTRING(AdvancedMedicalSettings_painIsOnlySuppressed_Description); + description = CSTRING(AdvancedMedicalSettings_painIsOnlySuppressed_Description); typeName = "BOOL"; defaultValue = 1; }; diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index a932ee5c9d..b479383468 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -56,6 +56,7 @@ PREP(isInMedicalFacility); PREP(isInMedicalVehicle); PREP(isMedic); PREP(isMedicalVehicle); +PREP(isInStableCondition); PREP(itemCheck); PREP(modifyMedicalAction); PREP(onMedicationUsage); diff --git a/addons/medical/functions/fnc_canTreat.sqf b/addons/medical/functions/fnc_canTreat.sqf index 062a696fcd..4795ccc561 100644 --- a/addons/medical/functions/fnc_canTreat.sqf +++ b/addons/medical/functions/fnc_canTreat.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" -private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_condition"]; +private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_condition", "_patientStateCondition"]; _caller = _this select 0; _target = _this select 1; _selectionName = _this select 2; @@ -44,7 +44,6 @@ if !([_caller, _medicRequired] call FUNC(isMedic)) exitwith {false}; _items = getArray (_config >> "items"); if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exitwith {false}; -_locations = getArray (_config >> "treatmentLocations"); _return = true; if (getText (_config >> "condition") != "") then { @@ -62,6 +61,14 @@ if (getText (_config >> "condition") != "") then { }; if (!_return) exitwith {false}; +_patientStateCondition = if (isText(_config >> "patientStateCondition")) then { + missionNamespace getvariable [getText(_config >> "patientStateCondition"), 0] +} else { + getNumber(_config >> "patientStateCondition") +}; +if (_patientStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false}; + +_locations = getArray (_config >> "treatmentLocations"); if ("All" in _locations) exitwith {true}; private [ "_medFacility", "_medVeh"]; diff --git a/addons/medical/functions/fnc_getUnconsciousCondition.sqf b/addons/medical/functions/fnc_getUnconsciousCondition.sqf index 83955f7bd1..19d3bdec1d 100644 --- a/addons/medical/functions/fnc_getUnconsciousCondition.sqf +++ b/addons/medical/functions/fnc_getUnconsciousCondition.sqf @@ -16,7 +16,6 @@ private ["_unit","_return"]; _unit = _this select 0; -if (GVAR(level) == 1) exitwith {true}; if (isnil QGVAR(unconsciousConditions)) then { GVAR(unconsciousConditions) = []; }; diff --git a/addons/medical/functions/fnc_handleBandageOpening.sqf b/addons/medical/functions/fnc_handleBandageOpening.sqf index a92bf9029c..a86077cb3b 100644 --- a/addons/medical/functions/fnc_handleBandageOpening.sqf +++ b/addons/medical/functions/fnc_handleBandageOpening.sqf @@ -58,10 +58,10 @@ if (isClass (_config >> _className)) then { _bandagedWounds = _target getvariable [QGVAR(bandagedWounds), []]; _exist = false; -_injuryId = _injury select 0; +_injuryType = _injury select 1; _bandagedInjury = []; { - if ((_x select 0) == _injuryId) exitwith { + if ((_x select 1) == _injuryType && (_x select 2) == (_injury select 2)) exitwith { _exist = true; _existingInjury = _x; _existingInjury set [3, (_existingInjury select 3) + _impact]; @@ -73,16 +73,11 @@ _bandagedInjury = []; if !(_exist) then { // [ID, classID, bodypart, percentage treated, bloodloss rate] - _bandagedInjury = [_injuryId, _injury select 1, _injury select 2, _impact, _injury select 4]; + _bandagedInjury = [_injury select 0, _injury select 1, _injury select 2, _impact, _injury select 4]; _bandagedWounds pushback _bandagedInjury; }; -_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, !USE_WOUND_EVENT_SYNC]; - -if (USE_WOUND_EVENT_SYNC) then { - // sync _bandagedInjury - -}; +_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, true]; // Check if we are ever going to reopen this if (random(1) <= _reopeningChance) then { @@ -95,22 +90,19 @@ if (random(1) <= _reopeningChance) then { _injuryIndex = _this select 3; _injury = _this select 4; - if (alive _target) then { + //if (alive _target) then { _openWounds = _target getvariable [QGVAR(openWounds), []]; if ((count _openWounds)-1 < _injuryIndex) exitwith {}; _selectedInjury = _openWounds select _injuryIndex; - if (_selectedInjury select 0 == _injury select 0) then { // matching the IDs + if (_selectedInjury select 1 == _injury select 1 && (_selectedInjury select 2) == (_injury select 2)) then { // matching the IDs _selectedInjury set [3, (_selectedInjury select 3) + _impact]; _openWounds set [_injuryIndex, _selectedInjury]; - _target setvariable [QGVAR(openWounds), _openWounds, !USE_WOUND_EVENT_SYNC]; - if (USE_WOUND_EVENT_SYNC) then { - ["medical_propagateWound", [_target, _selectedInjury]] call EFUNC(common,globalEvent); - }; + _bandagedWounds = _target getvariable [QGVAR(bandagedWounds), []]; _exist = false; - _injuryId = _injury select 0; + _injuryId = _injury select 1; { - if ((_x select 0) == _injuryId) exitwith { + if ((_x select 1) == _injuryId && (_x select 2) == (_injury select 2)) exitwith { _exist = true; _existingInjury = _x; _existingInjury set [3, ((_existingInjury select 3) - _impact) max 0]; @@ -119,10 +111,11 @@ if (random(1) <= _reopeningChance) then { }foreach _bandagedWounds; if (_exist) then { - _target setvariable [QGVAR(bandagedWounds), _bandagedWounds, !USE_WOUND_EVENT_SYNC]; + _target setvariable [QGVAR(bandagedWounds), _bandagedWounds, true]; + _target setvariable [QGVAR(openWounds), _openWounds, true]; }; }; // Otherwise something went wrong, we we don't reopen them.. - }; - }, [_target, _impact, _part, _injuryIndex, _injury], _delay, 0] call EFUNC(common,waitAndExecute); + //}; + }, [_target, _impact, _part, _injuryIndex, +_injury], _delay, 0] call EFUNC(common,waitAndExecute); }; diff --git a/addons/medical/functions/fnc_isInStableCondition.sqf b/addons/medical/functions/fnc_isInStableCondition.sqf new file mode 100644 index 0000000000..f7c22ed085 --- /dev/null +++ b/addons/medical/functions/fnc_isInStableCondition.sqf @@ -0,0 +1,30 @@ +/* +* Author: Glowbal +* Check if a unit is in a stable condition +* +* Arguments: +* 0: The patient +* +* Return Value: +* Is in stable condition +* +* Public: No +*/ + +#include "script_component.hpp" + +private ["_unit"]; +_unit = _this select 0; + +if (GVAR(level) <= 1) exitwith { + ([_unit] call FUNC(getBloodloss)) == 0; +}; + +_totalBloodLoss = 0; +_openWounds = _unit getvariable [QGVAR(openWounds), []]; +{ + // total bleeding ratio * percentage of injury left + _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); +}foreach _openWounds; + +(_totalBloodLoss == 0); diff --git a/addons/medical/functions/fnc_moduleAdvancedMedicalSettings.sqf b/addons/medical/functions/fnc_moduleAdvancedMedicalSettings.sqf index 5263044583..2960c65b9d 100644 --- a/addons/medical/functions/fnc_moduleAdvancedMedicalSettings.sqf +++ b/addons/medical/functions/fnc_moduleAdvancedMedicalSettings.sqf @@ -33,5 +33,7 @@ if !(_activated) exitWith {}; [_logic, QGVAR(consumeItem_SurgicalKit), "consumeItem_SurgicalKit"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(useLocation_PAK), "useLocation_PAK"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(useLocation_SurgicalKit), "useLocation_SurgicalKit"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(useCondition_PAK), "useCondition_PAK"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(useCondition_SurgicalKit), "useCondition_SurgicalKit"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(healHitPointAfterAdvBandage), "healHitPointAfterAdvBandage"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(painIsOnlySuppressed), "painIsOnlySuppressed"] call EFUNC(common,readSettingFromModule); diff --git a/addons/medical/functions/fnc_setDead.sqf b/addons/medical/functions/fnc_setDead.sqf index fe18ac581f..831a1fa6a0 100644 --- a/addons/medical/functions/fnc_setDead.sqf +++ b/addons/medical/functions/fnc_setDead.sqf @@ -66,6 +66,11 @@ if (((_reviveVal == 1 && {[_unit] call EFUNC(common,isPlayer)} || _reviveVal == _unit setvariable [QGVAR(reviveStartTime), nil]; [(_this select 1)] call cba_fnc_removePerFrameHandler; }; + if (GVAR(level) >= 2) then { + if (_unit getvariable [QGVAR(heartRate), 60] > 0) then { + _unit setvariable [QGVAR(heartRate), 0]; + }; + }; }, 1, [_unit] ] call CBA_fnc_addPerFrameHandler; false; }; diff --git a/addons/medical/functions/fnc_treatment.sqf b/addons/medical/functions/fnc_treatment.sqf index 06cea8dfe3..18f3406df2 100644 --- a/addons/medical/functions/fnc_treatment.sqf +++ b/addons/medical/functions/fnc_treatment.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" -private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_callbackProgress", "_treatmentTime", "_callerAnim", "_patientAnim", "_iconDisplayed", "_return", "_usersOfItems", "_consumeItems", "_condition", "_displayText", "_wpn", "_treatmentTimeConfig"]; +private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_callbackProgress", "_treatmentTime", "_callerAnim", "_patientAnim", "_iconDisplayed", "_return", "_usersOfItems", "_consumeItems", "_condition", "_displayText", "_wpn", "_treatmentTimeConfig", "_patientStateCondition"]; _caller = _this select 0; _target = _this select 1; _selectionName = _this select 2; @@ -53,9 +53,6 @@ if !([_caller, _medicRequired] call FUNC(isMedic)) exitwith {false}; _items = getArray (_config >> "items"); if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exitwith {false}; -// Check allowed locations -_locations = getArray (_config >> "treatmentLocations"); - _return = true; if (isText (_config >> "Condition")) then { _condition = getText(_config >> "condition"); @@ -74,6 +71,16 @@ if (isText (_config >> "Condition")) then { }; if (!_return) exitwith {false}; +_patientStateCondition = if (isText(_config >> "patientStateCondition")) then { + missionNamespace getvariable [getText(_config >> "patientStateCondition"), 0] +} else { + getNumber(_config >> "patientStateCondition") +}; +if (_patientStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false}; + +// Check allowed locations +_locations = getArray (_config >> "treatmentLocations"); + if ("All" in _locations) then { _return = true; } else { diff --git a/addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf b/addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf index 0a49420783..ade74a6ccb 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf @@ -23,7 +23,7 @@ _selectionName = _this select 2; _className = _this select 3; _items = _this select 4; -// TODO replace by event system instead -[[_caller, _target], QUOTE(DFUNC(treatmentAdvanced_CPRLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ - +if (alive _target && {(_target getvariable [QGVAR(inCardiacArrest), false] || _target getvariable [QGVAR(inReviveState), false])}) then { + [[_caller, _target], QUOTE(DFUNC(treatmentAdvanced_CPRLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +}; true; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_CPRLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_CPRLocal.sqf index 4bb14e1139..61723319a5 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_CPRLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_CPRLocal.sqf @@ -14,17 +14,15 @@ #include "script_component.hpp" -private ["_caller","_target", "_n"]; +private ["_caller","_target", "_reviveStartTime"]; _caller = _this select 0; _target = _this select 1; -_n = _target getvariable [QEGVAR(common,ENABLE_REVIVE_COUNTER),0]; -if (_n > 0) then { - _n = _n - random(20); - if (_n < 0) then { - _n = 0; +if (_target getvariable [QGVAR(inReviveState), false]) exitwith { + _reviveStartTime = _target getvariable [QGVAR(reviveStartTime),0]; + if (_reviveStartTime > 0) then { + _target setvariable [QGVAR(reviveStartTime), (_reviveStartTime + random(20)) min ACE_time]; }; - _target setvariable [QEGVAR(common,ENABLE_REVIVE_COUNTER), _n]; }; if (random(1)>= 0.6) exitwith { diff --git a/addons/medical/functions/fnc_treatment_failure.sqf b/addons/medical/functions/fnc_treatment_failure.sqf index 19352e5441..53fd03d2f3 100644 --- a/addons/medical/functions/fnc_treatment_failure.sqf +++ b/addons/medical/functions/fnc_treatment_failure.sqf @@ -60,4 +60,4 @@ if (isNil _callback) then { _args call _callback; -_args call FUNC(createLitter); +// _args call FUNC(createLitter); diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index e836ebf395..b6278fb47e 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -3179,7 +3179,7 @@ Localizações do KPS - Where can the personal aid kit be used? + Where can the Personal Aid Kit be used? Где может использоваться аптечка? Gdzie można korzystać z apteczek osobistych? ¿Dónde se puede utilizar el equipo de primeros auxilios? @@ -3187,6 +3187,12 @@ Kde může být osobní lékárnička použita? Onde o kit de primeiros socorros pode ser utilizado? + + Condition PAK + + + When can the Personal Aid Kit be used? + Anywhere Где угодно @@ -3286,6 +3292,12 @@ Kde může být použita chirurgická souprava? Onde o kit cirúrgico pode ser utilizado? + + Condition Surgical kit (Adv) + + + When can the Surgical kit be used? + Bloodstains Blutflecken @@ -3611,5 +3623,11 @@ Não No + + Anytime + + + Stable + \ No newline at end of file