diff --git a/addons/medical/ACE_Medical_Treatments.hpp b/addons/medical/ACE_Medical_Treatments.hpp index 3576d89295..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); 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..0af23c9995 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,19 @@ 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 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_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_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/stringtable.xml b/addons/medical/stringtable.xml index 6fa58bb759..b41cc05544 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -3123,13 +3123,19 @@ Lokace osobní lékárničky - 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? Wo kann der Erstehilfekasten verwendet werden? Kde může být osobní lékárnička použita? + + Condition PAK + + + When can the Personal Aid Kit be used? + Anywhere Где угодно @@ -3218,6 +3224,12 @@ Wo kann der Operationskasten verwendet werden? Kde může být použita chirurgická souprava? + + Condition Surgical kit (Adv) + + + When can the Surgical kit be used? + Bloodstains Blutflecken @@ -3509,5 +3521,11 @@ Não No + + Anytime + + + Stable + \ No newline at end of file