Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medical - Fix unconsicous problems with minWaitingTime and fullHealLocal #7030

Merged
merged 2 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/medical_statemachine/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

#include "initSettings.sqf"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (_painLevel > 0) then {
// Handle spontaneous wakeup from unconsciousness
if (EGVAR(medical,spontaneousWakeUpChance) > 0) then {
if (_unit call EFUNC(medical_status,hasStableVitals)) then {
private _lastWakeUpCheck = _unit getVariable [QEGVAR(medical,lastWakeUpCheck), CBA_missionTime];
private _lastWakeUpCheck = _unit getVariable [QEGVAR(medical,lastWakeUpCheck), 0];
if (CBA_missionTime - _lastWakeUpCheck > SPONTANEOUS_WAKE_UP_INTERVAL) then {
TRACE_2("Checking for wake up",_unit,EGVAR(medical,spontaneousWakeUpChance));
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), CBA_missionTime];
Expand All @@ -42,6 +42,7 @@ if (EGVAR(medical,spontaneousWakeUpChance) > 0) then {
};
} else {
// Unstable vitals, procrastinate the next wakeup check
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), CBA_missionTime];
private _lastWakeUpCheck = _unit getVariable [QEGVAR(medical,lastWakeUpCheck), 0];
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), _lastWakeUpCheck max CBA_missionTime];
};
};
3 changes: 3 additions & 0 deletions addons/medical_status/functions/fnc_initUnit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ if (_isRespawn) then {

// medication
_unit setVariable [VAR_MEDICATIONS, [], true];

// Unconscious spontanious wake up chance
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), nil];
};

[{
Expand Down
3 changes: 2 additions & 1 deletion addons/medical_status/functions/fnc_setUnconscious.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ _unit setVariable [VAR_UNCON, _active, true];
if (_active) then {
// Don't bother setting this if not used
if (EGVAR(medical,spontaneousWakeUpChance) > 0) then {
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), CBA_missionTime];
private _lastWakeUpCheck = _unit getVariable [QEGVAR(medical,lastWakeUpCheck), 0]; // could be set higher from ace_medical_fnc_setUnconscious
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), _lastWakeUpCheck max CBA_missionTime];
};

if (_unit == ACE_player) then {
Expand Down
30 changes: 15 additions & 15 deletions addons/medical_treatment/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
[_unit] call FUNC(checkItems);
}] call CBA_fnc_addEventHandler;

["loadout", FUNC(checkItems)] call CBA_fnc_addPlayerEventHandler;
["loadout", LINKFUNC(checkItems)] call CBA_fnc_addPlayerEventHandler;

// Handle body removal and litter on server
if (isServer) then {
[QGVAR(createLitterServer), FUNC(createLitterServer)] call CBA_fnc_addEventHandler;
["ace_placedInBodyBag", FUNC(removeBody)] call CBA_fnc_addEventHandler;
[QGVAR(createLitterServer), LINKFUNC(createLitterServer)] call CBA_fnc_addEventHandler;
["ace_placedInBodyBag", LINKFUNC(removeBody)] call CBA_fnc_addEventHandler;
};

// Treatment events
[QGVAR(bandageLocal), FUNC(bandageLocal)] call CBA_fnc_addEventHandler;
[QGVAR(checkBloodPressureLocal), FUNC(checkBloodPressureLocal)] call CBA_fnc_addEventHandler;
[QGVAR(checkPulseLocal), FUNC(checkPulseLocal)] call CBA_fnc_addEventHandler;
[QGVAR(cprLocal), FUNC(cprLocal)] call CBA_fnc_addEventHandler;
[QGVAR(fullHealLocal), FUNC(fullHealLocal)] call CBA_fnc_addEventHandler;
[QGVAR(ivBagLocal), FUNC(ivBagLocal)] call CBA_fnc_addEventHandler;
[QGVAR(medicationLocal), FUNC(medicationLocal)] call CBA_fnc_addEventHandler;
[QGVAR(placeInBodyBag), FUNC(placeInBodyBag)] call CBA_fnc_addEventHandler;
[QGVAR(splintLocal), FUNC(splintLocal)] call CBA_fnc_addEventHandler;
[QGVAR(tourniquetLocal), FUNC(tourniquetLocal)] call CBA_fnc_addEventHandler;
[QGVAR(bandageLocal), LINKFUNC(bandageLocal)] call CBA_fnc_addEventHandler;
[QGVAR(checkBloodPressureLocal), LINKFUNC(checkBloodPressureLocal)] call CBA_fnc_addEventHandler;
[QGVAR(checkPulseLocal), LINKFUNC(checkPulseLocal)] call CBA_fnc_addEventHandler;
[QGVAR(cprLocal), LINKFUNC(cprLocal)] call CBA_fnc_addEventHandler;
[QGVAR(fullHealLocal), LINKFUNC(fullHealLocal)] call CBA_fnc_addEventHandler;
[QGVAR(ivBagLocal), LINKFUNC(ivBagLocal)] call CBA_fnc_addEventHandler;
[QGVAR(medicationLocal), LINKFUNC(medicationLocal)] call CBA_fnc_addEventHandler;
[QGVAR(placeInBodyBag), LINKFUNC(placeInBodyBag)] call CBA_fnc_addEventHandler;
[QGVAR(splintLocal), LINKFUNC(splintLocal)] call CBA_fnc_addEventHandler;
[QGVAR(tourniquetLocal), LINKFUNC(tourniquetLocal)] call CBA_fnc_addEventHandler;

// Logging events
[QGVAR(addToLog), FUNC(addToLog)] call CBA_fnc_addEventHandler;
[QGVAR(addToTriageCard), FUNC(addToTriageCard)] call CBA_fnc_addEventHandler;
[QGVAR(addToLog), LINKFUNC(addToLog)] call CBA_fnc_addEventHandler;
[QGVAR(addToTriageCard), LINKFUNC(addToTriageCard)] call CBA_fnc_addEventHandler;
17 changes: 8 additions & 9 deletions addons/medical_treatment/functions/fnc_fullHealLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

params ["_patient"];
TRACE_1("fullHealLocal",_patient);

if (!alive _patient) exitWith {};

Expand All @@ -26,12 +27,6 @@ if IN_CRDC_ARRST(_patient) then {
[QEGVAR(medical,CPRSucceeded), _patient] call CBA_fnc_localEvent;
};

if IS_UNCONSCIOUS(_patient) then {
TRACE_1("Waking up",_patient);
// Wake patient up first or unconscious variables will be reset
[QEGVAR(medical,WakeUp), _patient] call CBA_fnc_localEvent;
};

_patient setVariable [VAR_PAIN, 0, true];
_patient setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true];

Expand Down Expand Up @@ -59,9 +54,13 @@ _patient setVariable [QEGVAR(medical,ivBags), nil, true];

// Damage storage
_patient setVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0], true];
#ifdef DEBUG_TESTRESULTS
_patient setVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0], true];
#endif

// 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); };
TRACE_1("Waking up",_patient);
[QEGVAR(medical,WakeUp), _patient] call CBA_fnc_localEvent;
};

// Generic medical admin
_patient setVariable [VAR_CRDC_ARRST, false, true];
Expand Down
2 changes: 2 additions & 0 deletions addons/medical_vitals/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

ADDON = true;
2 changes: 1 addition & 1 deletion addons/zeus/functions/fnc_moduleHeal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ switch (false) do {
// Heal validated target
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
TRACE_1("healing with ace_medical",_unit);
[QEGVAR(medical_treatment,treatmentFullHealLocal), [_unit], _unit] call CBA_fnc_targetEvent;
[QEGVAR(medical_treatment,fullHealLocal), [_unit], _unit] call CBA_fnc_targetEvent;
} else {
// BI's scripted revive system
if ((missionNamespace getVariable ["bis_revive_mode", 0]) != 0) then {
Expand Down