From c486f17539de438251051554c79c683d019a7e56 Mon Sep 17 00:00:00 2001 From: ulteq Date: Thu, 8 Dec 2016 18:11:24 +0100 Subject: [PATCH] Implemented Medkit (works like in ACE2) --- addons/medical/ACE_Settings.hpp | 40 +++++-- addons/medical/CfgVehicles.hpp | 11 ++ addons/medical/CfgWeapons.hpp | 10 ++ addons/medical/stringtable.xml | 48 ++++++-- .../ACE_Medical_Treatment_Actions.hpp | 8 ++ addons/medical_treatment/XEH_PREP.hpp | 22 ++-- addons/medical_treatment/XEH_postInit.sqf | 1 + .../functions/fnc_healTime.sqf | 2 +- .../functions/fnc_treatmentFullHealLocal.sqf | 104 ++++++------------ .../functions/fnc_treatmentPartialHeal.sqf | 23 ++++ .../fnc_treatmentPartialHealLocal.sqf | 43 ++++++++ 11 files changed, 209 insertions(+), 103 deletions(-) create mode 100644 addons/medical_treatment/functions/fnc_treatmentPartialHeal.sqf create mode 100644 addons/medical_treatment/functions/fnc_treatmentPartialHealLocal.sqf diff --git a/addons/medical/ACE_Settings.hpp b/addons/medical/ACE_Settings.hpp index 550651b58f..c95d74500c 100644 --- a/addons/medical/ACE_Settings.hpp +++ b/addons/medical/ACE_Settings.hpp @@ -121,6 +121,14 @@ class ACE_Settings { value = 0; values[] = {"Anyone", "Medics only", "Doctors only"}; }; + class GVAR(medicSetting_Medkit) { + category = CSTRING(Category_Medical); + displayName = CSTRING(AdvancedMedicalSettings_medicSetting_Medkit_DisplayName); + description = CSTRING(AdvancedMedicalSettings_medicSetting_Medkit_Description); + typeName = "SCALAR"; + value = 0; + values[] = {"Anyone", "Medics only", "Doctors only"}; + }; class GVAR(medicSetting_PAK) { category = CSTRING(Category_Medical); displayName = CSTRING(AdvancedMedicalSettings_medicSetting_PAK_DisplayName); @@ -137,6 +145,14 @@ class ACE_Settings { value = 0; values[] = {"Anyone", "Medics only", "Doctors only"}; }; + class GVAR(consumeItem_Medkit) { + category = CSTRING(Category_Medical); + displayName = CSTRING(AdvancedMedicalSettings_consumeItem_Medkit_DisplayName); + description = CSTRING(AdvancedMedicalSettings_consumeItem_Medkit_Description); + typeName = "SCALAR"; + value = 1; + values[] = {"No", "Yes"}; + }; class GVAR(consumeItem_PAK) { category = CSTRING(Category_Medical); displayName = CSTRING(AdvancedMedicalSettings_consumeItem_PAK_DisplayName); @@ -161,6 +177,14 @@ class ACE_Settings { value = 0; values[] = {CSTRING(AdvancedMedicalSettings_anywhere), CSTRING(AdvancedMedicalSettings_vehicle), CSTRING(AdvancedMedicalSettings_facility), CSTRING(AdvancedMedicalSettings_vehicleAndFacility), ECSTRING(common,Disabled)}; }; + class GVAR(useLocation_Medkit) { + category = CSTRING(Category_Medical); + displayName = CSTRING(AdvancedMedicalSettings_useLocation_Medkit_DisplayName); + description = CSTRING(AdvancedMedicalSettings_useLocation_Medkit_Description); + typeName = "SCALAR"; + value = 0; + values[] = {CSTRING(AdvancedMedicalSettings_anywhere), CSTRING(AdvancedMedicalSettings_vehicle), CSTRING(AdvancedMedicalSettings_facility), CSTRING(AdvancedMedicalSettings_vehicleAndFacility), ECSTRING(common,Disabled)}; + }; class GVAR(useLocation_PAK) { category = CSTRING(Category_Medical); displayName = CSTRING(AdvancedMedicalSettings_useLocation_PAK_DisplayName); @@ -177,20 +201,12 @@ class ACE_Settings { value = 0; values[] = {CSTRING(AdvancedMedicalSettings_anywhere), CSTRING(AdvancedMedicalSettings_vehicle), CSTRING(AdvancedMedicalSettings_facility), CSTRING(AdvancedMedicalSettings_vehicleAndFacility), ECSTRING(common,Disabled)}; }; - class GVAR(fullHealLocation_PAK) { + class GVAR(remainingDamage_Medkit) { category = CSTRING(Category_Medical); - displayName = CSTRING(MedicalSettings_fullHealLocation_PAK_DisplayName); - description = CSTRING(MedicalSettings_fullHealLocation_PAK_Description); + displayName = CSTRING(AdvancedMedicalSettings_remainingDamage_Medkit_DisplayName); + description = CSTRING(AdvancedMedicalSettings_remainingDamage_Medkit_Description); typeName = "SCALAR"; - value = 3; - values[] = {CSTRING(AdvancedMedicalSettings_anywhere), CSTRING(AdvancedMedicalSettings_vehicle), CSTRING(AdvancedMedicalSettings_facility), CSTRING(AdvancedMedicalSettings_vehicleAndFacility), ECSTRING(common,Disabled)}; - }; - class GVAR(fieldEffectiveness_PAK) { - category = CSTRING(Category_Medical); - displayName = CSTRING(MedicalSettings_fieldEffectiveness_PAK_DisplayName); - description = CSTRING(MedicalSettings_fieldEffectiveness_PAK_Description); - typeName = "SCALAR"; - value = 0.9; + value = 0.1; }; class GVAR(painEffectType) { category = CSTRING(Category_Medical); diff --git a/addons/medical/CfgVehicles.hpp b/addons/medical/CfgVehicles.hpp index a4e28c1da4..103b5718bb 100644 --- a/addons/medical/CfgVehicles.hpp +++ b/addons/medical/CfgVehicles.hpp @@ -207,6 +207,16 @@ class CfgVehicles { MACRO_ADDITEM(ACE_quikclot,1); }; }; + class ACE_medKitItem: Item_Base_F { + scope = 2; + scopeCurator = 2; + displayName = CSTRING(Med_Kit_Display); + author = ECSTRING(common,ACETeam); + vehicleClass = "Items"; + class TransportItems { + MACRO_ADDITEM(ACE_medKit,1); + }; + }; class ACE_personalAidKitItem: Item_Base_F { scope = 2; scopeCurator = 2; @@ -277,6 +287,7 @@ class CfgVehicles { MACRO_ADDITEM(ACE_bloodIV_500,7); MACRO_ADDITEM(ACE_bloodIV_250,7); MACRO_ADDITEM(ACE_quikClot,20); + MACRO_ADDITEM(ACE_medKit,20); MACRO_ADDITEM(ACE_personalAidKit,3); MACRO_ADDITEM(ACE_surgicalKit,2); MACRO_ADDITEM(ACE_bodyBag,5); diff --git a/addons/medical/CfgWeapons.hpp b/addons/medical/CfgWeapons.hpp index e135b1c627..3461596c95 100644 --- a/addons/medical/CfgWeapons.hpp +++ b/addons/medical/CfgWeapons.hpp @@ -207,6 +207,16 @@ class CfgWeapons { mass = 2; }; }; + class ACE_medKit: ACE_ItemCore { + scope = 2; + displayName = CSTRING(Med_Kit_Display); + picture = QPATHTOF(ui\items\personal_aid_kit_x_ca.paa); // todo: new picture + descriptionShort = CSTRING(Med_Kit_Desc_Short); + descriptionUse = CSTRING(Med_Kit_Desc_Use); + class ItemInfo: InventoryItem_Base_F { + mass = 10; + }; + }; class ACE_personalAidKit: ACE_ItemCore { scope = 2; displayName = CSTRING(Aid_Kit_Display); diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index 11fecf22ec..f9a7b0ae50 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -1374,6 +1374,18 @@ Hemostatický obvaz určený k zástavě krvácení 血液凝固剤をふくむ包帯により、止血できます。 + + Medkit + + + ... + + + ... + + + Use Medkit + Personal Aid Kit Аптечка @@ -2322,6 +2334,9 @@ %1 použil škrtidlo %1 は止血帯を巻いた + + %1 used Medkit + %1 used Personal Aid Kit %1 hat das eigene Erste-Hilfe-Set verwendet @@ -2903,18 +2918,6 @@ Coefficiente che modifica l'intensità del dolore この係数では痛みの強さを変更できます - - Full Heal Locations - - - Where does the PAK perform a full heal? - - - PAK effectiveness - - - PAK effectiveness when used outside of medical facilities - Provides a medical system for both players and AI. Включает медицинскую систему как для игроков, так и для ботов. @@ -3081,6 +3084,12 @@ Кому разрешено использовать адреналин для полного излечения? (Только для базовой медицины) 完全に回復できるよう誰しもがアドレナリンを使えるようにしますか?(ベーシック医療のみ) + + Allow Medkit + + + Who can use the Medkit for partial heal? + Allow PAK Использование аптечки @@ -3146,6 +3155,12 @@ Solo dottori 医師のみ + + Remove Medkit on use + + + Should Medkit be removed on usage? + Remove PAK on use Удалять аптечки после использования @@ -3196,6 +3211,9 @@ Где может использоваться адреналин? (Базовая медицина) どこでもアドレナリンをつかえるようにしますか?(ベーシック医療のみ) + + Locations Medkit + Locations PAK Место использования аптечки @@ -3378,6 +3396,12 @@ Dove può essere usato il Kit Chirurgico? どこでも縫合キットをつかえるようにしますか? + + Remaining Damage + + + Remaining damage on Medkit usage (increases with every use)? + Condition Surgical Kit (Adv) Beding. für d. Operationskasten (erw.) diff --git a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp index 30929cbede..5872d9129b 100644 --- a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp +++ b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp @@ -298,4 +298,12 @@ class GVAR(Actions) { {"All", "_bloodLossOnBodyPart <= 0", {"ACE_MedicalLitter_clean"}} }; }; + class MedKit: PersonalAidKit { + displayName = ECSTRING(medical,Use_Med_Kit); + items[] = {"ACE_medKit"}; + treatmentLocations[] = {QEGVAR(medical,useLocation_MedKit)}; + requiredMedic = QEGVAR(medical,medicSetting_MedKit); + callbackSuccess = QFUNC(treatmentPartialHeal); + itemConsumed = QEGVAR(medical,consumeItem_MedKit); + }; }; diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index eeb0a2e8e1..cbbfda23cf 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -14,23 +14,25 @@ PREP(actionUnloadUnit); PREP(canTreat); PREP(canTreatCached); PREP(treatment); -PREP(treatment_success); PREP(treatment_failure); +PREP(treatment_success); PREP(treatmentBandage); PREP(treatmentBandageLocal); -PREP(treatmentTourniquet); -PREP(treatmentTourniquetLocal); -PREP(treatmentTourniquetRemove); -PREP(treatmentMedication); -PREP(treatmentMedicationLocal); -PREP(treatmentIV); -PREP(treatmentIVLocal); PREP(treatmentCPR); PREP(treatmentCPRLocal); PREP(treatmentFullHeal); PREP(treatmentFullHealLocal); +PREP(treatmentIV); +PREP(treatmentIVLocal); +PREP(treatmentMedication); +PREP(treatmentMedicationLocal); +PREP(treatmentPartialHeal); +PREP(treatmentPartialHealLocal); PREP(treatmentSurgicalKit_onProgress); +PREP(treatmentTourniquet); +PREP(treatmentTourniquetLocal); +PREP(treatmentTourniquetRemove); // misc PREP(addToLog); @@ -40,10 +42,10 @@ PREP(canAccessMedicalEquipment); PREP(dropDownTriageCard); PREP(getTriageStatus); PREP(handleBandageOpening); +PREP(healTime); PREP(isBeingCarried); PREP(isBeingDragged); PREP(onMedicationUsage); -PREP(healTime); // items PREP(checkItems); @@ -53,6 +55,6 @@ PREP(useItem); PREP(useItems); // litter +PREP(litterCleanupLoop); PREP(litterCreate); PREP(litterHandleCreate); -PREP(litterCleanupLoop); diff --git a/addons/medical_treatment/XEH_postInit.sqf b/addons/medical_treatment/XEH_postInit.sqf index 86f2cf1ffa..bbd6daeaaf 100644 --- a/addons/medical_treatment/XEH_postInit.sqf +++ b/addons/medical_treatment/XEH_postInit.sqf @@ -13,6 +13,7 @@ if (isServer) then { [QGVAR(treatmentMedicationLocal), FUNC(treatmentMedicationLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentIVLocal), FUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentCPRLocal), FUNC(treatmentCPRLocal)] call CBA_fnc_addEventHandler; +[QGVAR(treatmentPartialHealLocal), FUNC(treatmentPartialHealLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentFullHealLocal), FUNC(treatmentFullHealLocal)] call CBA_fnc_addEventHandler; // action events diff --git a/addons/medical_treatment/functions/fnc_healTime.sqf b/addons/medical_treatment/functions/fnc_healTime.sqf index 9f62bfea9b..9f0c4adfbc 100644 --- a/addons/medical_treatment/functions/fnc_healTime.sqf +++ b/addons/medical_treatment/functions/fnc_healTime.sqf @@ -23,4 +23,4 @@ private _totalDamage = 0; _totalDamage = _totalDamage + _x; } forEach (_unit getVariable [QEGVAR(medical,bodyPartDamage), []]); -10 max (_totalDamage * 10) min 180 +10 max (_totalDamage * 5) min 180 diff --git a/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf index 1a2eeb5ef2..89569a7e38 100644 --- a/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf @@ -17,84 +17,52 @@ params ["_caller", "_target"]; if (!alive _target) exitWith {}; -private _fullHealLocation = EGVAR(medical,fullHealLocation_PAK); -private _partialHeal = _fullHealLocation > 0; // Full heal not everywhere +_target setVariable [QEGVAR(medical,pain), 0, true]; +_target setVariable [QEGVAR(medical,bloodVolume), DEFAULT_BLOOD_VOLUME, true]; -if (_partialHeal) then { - private _medFacility = ([_caller] call EFUNC(medical,isInMedicalFacility)) || {[_target] call EFUNC(medical,isInMedicalFacility)}; - private _medVeh = ([_caller] call EFUNC(medical,isInMedicalVehicle)) || {[_target] call EFUNC(medical,isInMedicalVehicle)}; - switch (_fullHealLocation) do { - case 1: { _partialHeal = !_medFacility; }; - case 2: { _partialHeal = !_medVeh; }; - case 3: { _partialHeal = !_medFacility && {!_medVeh}; }; - }; -}; +// tourniquets +_target setVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0], true]; +_target setVariable [QGVAR(occludedMedications), nil, true]; -if (_partialHeal) then { - private _partialHealCounter = _target getVariable [QGVAR(partialHealCounter), 0]; - _partialHealCounter = _partialHealCounter + 1; - _target setVariable [QGVAR(partialHealCounter), _partialHealCounter, true]; +// wounds and injuries +_target setVariable [QEGVAR(medical,openWounds), [], true]; +_target setVariable [QEGVAR(medical,bandagedWounds), [], true]; +_target setVariable [QEGVAR(medical,stitchedWounds), [], true]; - private _effectiveness = (0 max EGVAR(medical,fieldEffectiveness_PAK) min 1) ^ _partialHealCounter; - private _persistentDamage = 1 - _effectiveness; +// vitals +_target setVariable [QEGVAR(medical,heartRate), 80, true]; +_target setVariable [QEGVAR(medical,heartRateAdjustments), [], true]; +_target setVariable [QEGVAR(medical,bloodPressure), [80, 120], true]; +_target setVariable [QEGVAR(medical,peripheralResistance), 100, true]; +_target setVariable [QGVAR(peripheralResistanceAdjustments), [], true]; - private _bodyPartDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; - _bodyPartDamage = _bodyPartDamage apply { - (_x min _persistentDamage) - }; - _target setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; +// IVs +_target setVariable [QEGVAR(medical,ivBags), nil, true]; - if ((_bodyPartDamage select 4) < 0.3 && {(_bodyPartDamage select 5) < 0.3}) then { - [_unit, false] call EFUNC(medical_engine,setLimping); - }; -} else { - _target setVariable [QEGVAR(medical,pain), 0, true]; - _target setVariable [QEGVAR(medical,bloodVolume), DEFAULT_BLOOD_VOLUME, true]; - - // tourniquets - _target setVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0], true]; - _target setVariable [QGVAR(occludedMedications), nil, true]; - - // wounds and injuries - _target setVariable [QEGVAR(medical,openWounds), [], true]; - _target setVariable [QEGVAR(medical,bandagedWounds), [], true]; - _target setVariable [QEGVAR(medical,stitchedWounds), [], true]; - - // vitals - _target setVariable [QEGVAR(medical,heartRate), 80, true]; - _target setVariable [QEGVAR(medical,heartRateAdjustments), [], true]; - _target setVariable [QEGVAR(medical,bloodPressure), [80, 120], true]; - _target setVariable [QEGVAR(medical,peripheralResistance), 100, true]; - _target setVariable [QGVAR(peripheralResistanceAdjustments), [], true]; - - // IVs - _target setVariable [QEGVAR(medical,ivBags), nil, true]; - - // damage storage - _target setVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0], true]; +// damage storage +_target setVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0], true]; #ifdef DEBUG_TESTRESULTS - _target setVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0], true]; +_target setVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0], true]; #endif - // generic medical admin - _target setVariable [QEGVAR(medical,inCardiacArrest), false, true]; - _target setVariable [QEGVAR(medical,isUnconscious), false, true]; - _target setVariable [QEGVAR(medical,hasLostBlood), 0, true]; - _target setVariable [QEGVAR(medical,isBleeding), false, true]; - _target setVariable [QEGVAR(medical,hasPain), false, true]; - _target setVariable [QEGVAR(medical,painSuppress), 0, true]; - _target setVariable [QGVAR(painSuppressAdjustments), [], true]; - _target setVariable [QGVAR(partialHealCounter), 0, true]; - - // medication - private _allUsedMedication = _target getVariable [QEGVAR(medical,allUsedMedication), []]; +// generic medical admin +_target setVariable [QEGVAR(medical,inCardiacArrest), false, true]; +_target setVariable [QEGVAR(medical,isUnconscious), false, true]; +_target setVariable [QEGVAR(medical,hasLostBlood), 0, true]; +_target setVariable [QEGVAR(medical,isBleeding), false, true]; +_target setVariable [QEGVAR(medical,hasPain), false, true]; +_target setVariable [QEGVAR(medical,painSuppress), 0, true]; +_target setVariable [QGVAR(painSuppressAdjustments), [], true]; +_target setVariable [QGVAR(partialHealCounter), 0, true]; - { - _target setVariable [_x select 0, nil]; - } forEach _allUsedMedication; +// medication +private _allUsedMedication = _target getVariable [QEGVAR(medical,allUsedMedication), []]; - [_unit, false] call EFUNC(medical_engine,setLimping); -}; +{ + _target setVariable [_x select 0, nil]; +} forEach _allUsedMedication; + +[_unit, false] call EFUNC(medical_engine,setLimping); // Resetting damage _target setDamage 0; diff --git a/addons/medical_treatment/functions/fnc_treatmentPartialHeal.sqf b/addons/medical_treatment/functions/fnc_treatmentPartialHeal.sqf new file mode 100644 index 0000000000..2f05ab1977 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_treatmentPartialHeal.sqf @@ -0,0 +1,23 @@ +/* + * Author: Glowbal + * Partial heal treatment + * + * Arguments: + * 0: The medic + * 1: The patient + * 2: Body part + * 3: Treatment class name + * 4: Item + * + * Return Value: + * Succesful treatment started + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_caller", "_target"]; + +[QGVAR(treatmentPartialHealLocal), [_caller, _target], _target] call CBA_fnc_targetEvent; + +true diff --git a/addons/medical_treatment/functions/fnc_treatmentPartialHealLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentPartialHealLocal.sqf new file mode 100644 index 0000000000..f094398ee3 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_treatmentPartialHealLocal.sqf @@ -0,0 +1,43 @@ +/* + * Author: Glowbal + * Handles partial heal of a patient. + * + * Arguments: + * 0: The medic + * 1: The patient + * + * Return Value: + * Succesful treatment started + * + * Public: No + */ +#include "script_component.hpp" + +params ["_caller", "_target"]; + +if (!alive _target) exitWith {}; + +private _partialHealCounter = _target getVariable [QGVAR(partialHealCounter), 0]; +_partialHealCounter = _partialHealCounter + 1; +_target setVariable [QGVAR(partialHealCounter), _partialHealCounter, true]; + +private _healingPower = (0 max (1 - EGVAR(medical,remainingDamage_Medkit)) min 1) ^ _partialHealCounter; +private _damageRemainder = 1 - _healingPower; + +private _bodyPartDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; +_bodyPartDamage = _bodyPartDamage apply { + (_x min _damageRemainder) +}; +_target setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; + +if ((_bodyPartDamage select 4) < 0.3 && {(_bodyPartDamage select 5) < 0.3}) then { + [_unit, false] call EFUNC(medical_engine,setLimping); +}; + +// Resetting damage +_target setDamage 0; + +//[QEGVAR(medical,FullHeal), _target] call CBA_fnc_localEvent; + +[_target, "activity", ELSTRING(medical,Activity_partialHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); +[_target, "activity_view", ELSTRING(medical,Activity_partialHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message