From f5782fd1ff18bd920b34f484d5d3aa8a0add1f3b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 6 Aug 2019 08:10:33 -0500 Subject: [PATCH] Medical - Various debugging and fix cpr anim speed (#7122) * Medical - Various debugging and fix cpr anim speed * Update fnc_setCardiacArrest.sqf --- addons/common/functions/fnc_disableUserInput.sqf | 1 + .../functions/fnc_setDisableUserInputStatus.sqf | 3 ++- addons/medical/functions/fnc_adjustPainLevel.sqf | 1 + addons/medical/functions/fnc_setUnconscious.sqf | 1 + addons/medical_engine/script_macros_medical.hpp | 1 + addons/medical_feedback/XEH_postInit.sqf | 1 + .../functions/fnc_handleStateUnconscious.sqf | 1 + .../functions/fnc_adjustPainLevel.sqf | 1 + .../functions/fnc_isInStableCondition.sqf | 2 +- .../functions/fnc_setCardiacArrest.sqf | 7 ++++++- .../functions/fnc_setUnconscious.sqf | 6 +++++- addons/medical_treatment/XEH_preInit.sqf | 3 ++- .../functions/fnc_fullHealLocal.sqf | 16 +++++++++++++--- .../functions/fnc_treatment.sqf | 4 ++++ 14 files changed, 40 insertions(+), 8 deletions(-) diff --git a/addons/common/functions/fnc_disableUserInput.sqf b/addons/common/functions/fnc_disableUserInput.sqf index 44468641f3..ecc3a0a987 100644 --- a/addons/common/functions/fnc_disableUserInput.sqf +++ b/addons/common/functions/fnc_disableUserInput.sqf @@ -16,6 +16,7 @@ */ params ["_state"]; +TRACE_1("disableUserInput",_state); if (_state) then { disableSerialization; diff --git a/addons/common/functions/fnc_setDisableUserInputStatus.sqf b/addons/common/functions/fnc_setDisableUserInputStatus.sqf index 3fdc185325..843837caba 100644 --- a/addons/common/functions/fnc_setDisableUserInputStatus.sqf +++ b/addons/common/functions/fnc_setDisableUserInputStatus.sqf @@ -16,7 +16,8 @@ * Public: Yes */ -params ["_id", "_disable"]; +params [["_id", "#", [""]], ["_disable", false, [false]]]; +TRACE_2("setDisableUserInputStatus",_id,_disable); if (isNil QGVAR(DISABLE_USER_INPUT_COLLECTION)) then { GVAR(DISABLE_USER_INPUT_COLLECTION) = []; diff --git a/addons/medical/functions/fnc_adjustPainLevel.sqf b/addons/medical/functions/fnc_adjustPainLevel.sqf index 40370bf99d..233638180f 100644 --- a/addons/medical/functions/fnc_adjustPainLevel.sqf +++ b/addons/medical/functions/fnc_adjustPainLevel.sqf @@ -2,6 +2,7 @@ /* * Author: PabstMirror * Public interface to allow external modules to safely adjust pain levels. + * Added pain can be positive or negative (Note: ignores painCoefficient setting) * * Arguments: * 0: The patient diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index a073c9e9eb..f6f39b03c5 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -61,6 +61,7 @@ if (_knockOut) then { }, [_unit], _minWaitingTime] call CBA_fnc_waitAndExecute; }; if (EGVAR(medical,spontaneousWakeUpChance) > 0) then { + TRACE_1("setting lastWakeUpCheck",_minWaitingTime); _unit setVariable [QEGVAR(medical,lastWakeUpCheck), CBA_missionTime + _minWaitingTime - SPONTANEOUS_WAKE_UP_INTERVAL]; }; }; diff --git a/addons/medical_engine/script_macros_medical.hpp b/addons/medical_engine/script_macros_medical.hpp index cffa87d5cf..13084d8ae0 100644 --- a/addons/medical_engine/script_macros_medical.hpp +++ b/addons/medical_engine/script_macros_medical.hpp @@ -141,6 +141,7 @@ // - Unit Functions --------------------------------------------------- // Retrieval macros for common unit values // Defined for easy consistency and speed +#define GET_SM_STATE(_unit) ([_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState) #define GET_BLOOD_VOLUME(unit) (unit getVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME]) #define GET_WOUND_BLEEDING(unit) (unit getVariable [VAR_WOUND_BLEEDING, 0]) #define GET_HEART_RATE(unit) (unit getVariable [VAR_HEART_RATE, DEFAULT_HEART_RATE]) diff --git a/addons/medical_feedback/XEH_postInit.sqf b/addons/medical_feedback/XEH_postInit.sqf index 45054daccc..37b2c4c2e6 100644 --- a/addons/medical_feedback/XEH_postInit.sqf +++ b/addons/medical_feedback/XEH_postInit.sqf @@ -30,6 +30,7 @@ GVAR(heartBeatEffectRunning) = false; params ["_unit", "_unconscious"]; if (_unit != ACE_player) exitWith {}; + TRACE_1("player unconscious eh",_unconscious); if (_unconscious && {cameraView == "GUNNER"} && {(vehicle _unit) != _unit} && {cameraOn == vehicle _unit}) then { TRACE_2("exiting gunner view",cameraOn,cameraView); diff --git a/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf b/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf index bd79e2b51b..9968e26645 100644 --- a/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf +++ b/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf @@ -35,6 +35,7 @@ if (EGVAR(medical,spontaneousWakeUpChance) > 0) then { // Handle setting being changed mid-mission and still properly check // already unconscious units, should handle locality changes as well if (isNil "_lastWakeUpCheck") exitWith { + TRACE_1("undefined lastWakeUpCheck: setting to current time",_lastWakeUpCheck); _unit setVariable [QEGVAR(medical,lastWakeUpCheck), CBA_missionTime]; }; diff --git a/addons/medical_status/functions/fnc_adjustPainLevel.sqf b/addons/medical_status/functions/fnc_adjustPainLevel.sqf index a8fe5eebd6..c6df1adda3 100644 --- a/addons/medical_status/functions/fnc_adjustPainLevel.sqf +++ b/addons/medical_status/functions/fnc_adjustPainLevel.sqf @@ -2,6 +2,7 @@ /* * Author: PabstMirror * Interface to allow external modules to affect the pain level + * Sets the new pain level to the max between the input and current level * * Arguments: * 0: The patient diff --git a/addons/medical_status/functions/fnc_isInStableCondition.sqf b/addons/medical_status/functions/fnc_isInStableCondition.sqf index c4ee84b58e..56226d3024 100644 --- a/addons/medical_status/functions/fnc_isInStableCondition.sqf +++ b/addons/medical_status/functions/fnc_isInStableCondition.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: Glowbal - * Check if a unit is in a stable condition + * Check if a unit is in a stable condition, needed for PersonalAidKit treatment * * Arguments: * 0: The patient diff --git a/addons/medical_status/functions/fnc_setCardiacArrest.sqf b/addons/medical_status/functions/fnc_setCardiacArrest.sqf index 5ce67938e9..e79d09d28b 100644 --- a/addons/medical_status/functions/fnc_setCardiacArrest.sqf +++ b/addons/medical_status/functions/fnc_setCardiacArrest.sqf @@ -3,13 +3,18 @@ * Author: Glowbal * Marks a unit as in cardiac arrest and sets heart rate to 0. * Will put the unit in an unconscious state if not already. + * For Internal Use: Called from the state machine entered/leftState funcs. * * Arguments: * 0: The unit that will be put in cardiac arrest state + * 1: Set CardiacArrest * * Return Value: * None * + * Example: + * [player, true] call ace_medical_status_fnc_setCardiacArrest + * * Public: No */ @@ -17,7 +22,7 @@ params ["_unit", "_active"]; TRACE_2("setCardiacArrest",_unit,_active); // No change to make -if (_active isEqualTo IN_CRDC_ARRST(_unit)) exitWith {}; +if (_active isEqualTo IN_CRDC_ARRST(_unit)) exitWith { TRACE_2("no change",_active,IN_CRDC_ARRST(_unit)); }; // No heart rate in cardiac arrest, low heart rate if revived _unit setVariable [VAR_CRDC_ARRST, _active, true]; diff --git a/addons/medical_status/functions/fnc_setUnconscious.sqf b/addons/medical_status/functions/fnc_setUnconscious.sqf index cfc20e6a6f..07d67b7af6 100644 --- a/addons/medical_status/functions/fnc_setUnconscious.sqf +++ b/addons/medical_status/functions/fnc_setUnconscious.sqf @@ -11,13 +11,16 @@ * Return Value: * Success * + * Example: + * [player, true] call ace_medical_status_fnc_setUnconscious + * * Public: No */ params ["_unit", "_active"]; // No change to make -if (_active isEqualTo IS_UNCONSCIOUS(_unit)) exitWith {}; +if (_active isEqualTo IS_UNCONSCIOUS(_unit)) exitWith { TRACE_2("no change",_active,IS_UNCONSCIOUS(_unit)); }; _unit setVariable [VAR_UNCON, _active, true]; @@ -31,6 +34,7 @@ if (_active) then { // Don't bother setting this if not used if (EGVAR(medical,spontaneousWakeUpChance) > 0) then { private _lastWakeUpCheck = _unit getVariable [QEGVAR(medical,lastWakeUpCheck), 0]; // could be set higher from ace_medical_fnc_setUnconscious + TRACE_2("setting lastWakeUpCheck to max of",_lastWakeUpCheck,CBA_missionTime); _unit setVariable [QEGVAR(medical,lastWakeUpCheck), _lastWakeUpCheck max CBA_missionTime]; }; diff --git a/addons/medical_treatment/XEH_preInit.sqf b/addons/medical_treatment/XEH_preInit.sqf index dc65ebc308..79949c2479 100644 --- a/addons/medical_treatment/XEH_preInit.sqf +++ b/addons/medical_treatment/XEH_preInit.sqf @@ -31,7 +31,8 @@ GVAR(animDurations) = [] call CBA_fnc_createNamespace; ["AinvPknlMstpSlayWlnrDnon_medicOther", 9], ["AinvPknlMstpSlayWpstDnon_medicOther", 10], ["AinvPpneMstpSlayWpstDnon_medicOther", 8.5], - ["AinvPknlMstpSnonWnonDnon_medic1", 10] + ["AinvPknlMstpSnonWnonDnon_medic1", 10], + ["AinvPknlMstpSnonWnonDr_medic0", 12] ]; // class names of medical facilities (config case) diff --git a/addons/medical_treatment/functions/fnc_fullHealLocal.sqf b/addons/medical_treatment/functions/fnc_fullHealLocal.sqf index e1ccc6fddd..d292394eb6 100644 --- a/addons/medical_treatment/functions/fnc_fullHealLocal.sqf +++ b/addons/medical_treatment/functions/fnc_fullHealLocal.sqf @@ -20,11 +20,16 @@ TRACE_1("fullHealLocal",_patient); if (!alive _patient) exitWith {}; +private _state = GET_SM_STATE(_patient); +TRACE_1("start",_state); + // Treatment conditions would normally limit full heal to non-unconscious units // However, this may be called externally (through Zeus) if IN_CRDC_ARRST(_patient) then { TRACE_1("Exiting cardiac arrest",_patient); [QEGVAR(medical,CPRSucceeded), _patient] call CBA_fnc_localEvent; + _state = GET_SM_STATE(_patient); + TRACE_1("after CPRSucceeded",_state); }; _patient setVariable [VAR_PAIN, 0, true]; @@ -57,14 +62,17 @@ _patient setVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0], true]; // wakeup needs to be done after achieving stable vitals, but before manually reseting unconc var if IS_UNCONSCIOUS(_patient) then { - if (!([_patient] call EFUNC(medical_status,hasStableVitals))) then { WARNING_1("fullheal [%1] did not restore stable vitals",_patient); }; + if (!([_patient] call EFUNC(medical_status,hasStableVitals))) then { ERROR_2("fullheal [unit %1][state %2] did not restore stable vitals",_patient,_state); }; TRACE_1("Waking up",_patient); [QEGVAR(medical,WakeUp), _patient] call CBA_fnc_localEvent; + _state = GET_SM_STATE(_patient); + TRACE_1("after WakeUp",_state); + if IS_UNCONSCIOUS(_patient) then { ERROR_1("fullheal [unit %1][state %2] failed to wake up patient",_patient,_state); }; }; // Generic medical admin -_patient setVariable [VAR_CRDC_ARRST, false, true]; -_patient setVariable [VAR_UNCON, false, true]; +// _patient setVariable [VAR_CRDC_ARRST, false, true]; // this should be set by statemachine transition +// _patient setVariable [VAR_UNCON, false, true]; // this should be set by statemachine transition _patient setVariable [VAR_HEMORRHAGE, 0, true]; _patient setVariable [VAR_IN_PAIN, false, true]; _patient setVariable [VAR_PAIN_SUPP, 0, true]; @@ -81,3 +89,5 @@ _patient setVariable [QEGVAR(medical,triageCard), [], true]; _patient setDamage 0; [QEGVAR(medical,FullHeal), _patient] call CBA_fnc_localEvent; +_state = GET_SM_STATE(_patient); +TRACE_1("after FullHeal",_state); diff --git a/addons/medical_treatment/functions/fnc_treatment.sqf b/addons/medical_treatment/functions/fnc_treatment.sqf index e75c0ba6dd..93c9877ad7 100644 --- a/addons/medical_treatment/functions/fnc_treatment.sqf +++ b/addons/medical_treatment/functions/fnc_treatment.sqf @@ -74,6 +74,10 @@ if (_medicAnim == "AinvPknlMstpSlayWlnrDnon_medic") then { // Determine the animation length private _animDuration = GVAR(animDurations) getVariable _medicAnim; +if (isNil "_animDuration") then { + WARNING_2("animation [%1] for [%2] has no duration defined",_medicAnim,_classname); + _animDuration = 10; +}; // These animations have transitions that take a bit longer... if (weaponLowered _medic) then {