From ebd31168f4c8f8cb77d55f9fc9a0cb1b1830fd33 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 30 Oct 2016 20:45:02 -0500 Subject: [PATCH 01/12] Fix bleeding hit logic for enabledFor = 1 --- addons/medical_blood/functions/fnc_handleWoundReceived.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical_blood/functions/fnc_handleWoundReceived.sqf b/addons/medical_blood/functions/fnc_handleWoundReceived.sqf index 2fb3cf91c2..b20fb599cc 100644 --- a/addons/medical_blood/functions/fnc_handleWoundReceived.sqf +++ b/addons/medical_blood/functions/fnc_handleWoundReceived.sqf @@ -16,7 +16,7 @@ params ["_unit", "", "_damage", "_shooter"]; -if (GVAR(enabledFor) == 1 && {!isPlayer _unit || {_unit == ACE_player}}) exitWith {}; +if (GVAR(enabledFor) == 1 && {!isPlayer _unit && {_unit != ACE_player}}) exitWith {}; if (vehicle _unit != _unit && {!((vehicle _unit) isKindOf "StaticWeapon")}) exitWith {}; // Don't bleed on ground if mounted _damage = _damage min 1; From a65f1d19fa5dcc89b618e31a645cfeb1d6bd0ccd Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 7 Nov 2016 22:19:55 +0100 Subject: [PATCH 02/12] Added state machine debug functionality --- addons/medical/XEH_postInit.sqf | 26 ++++++++++++++++++++++++++ addons/medical/script_component.hpp | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index fbb5dc78a3..434086bf4b 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -35,3 +35,29 @@ if (!hasInterface) exitWith {}; linearConversion [0, 1, _pain, 1, 5, true]; }] call EFUNC(common,arithmeticSetSource); + +#ifdef DEBUG_MODE_FULL + if (hasInterface) then { + private _ctrl = findDisplay 46 ctrlCreate ["RscText", -1]; + _ctrl ctrlSetPosition [ + safeZoneX, + safeZoneY, + safeZoneW, + 40 * pixelH + ]; + _ctrl ctrlSetFontHeight (40 * pixelH); + _ctrl ctrlSetTextColor [0.6, 0, 0, 1]; + _ctrl ctrlCommit 0; + uiNamespace setVariable [QGVAR(debugControl), _ctrl]; + + [{ + private _playerState = [ACE_player, GVAR(STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; + (uiNamespace getVariable [QGVAR(debugControl), controlNull]) ctrlSetText format ["Player state: %1", _playerState]; + + if (!isNull cursorTarget && {cursorTarget isKindOf "CAManBase"}) then { + private _targetState = [cursorTarget, GVAR(STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; + drawIcon3D ["", [0.6, 0, 0, 1], cursorTarget modelToWorld (cursorTarget selectionPosition "pelvis"), 0, 0, 0, format ["State: %1", _targetState], 2, 40 * pixelH, "RobotoCondensed"]; + }; + }] call CBA_fnc_addPerFrameHandler; + }; +#endif diff --git a/addons/medical/script_component.hpp b/addons/medical/script_component.hpp index c93f584b0c..3802885221 100644 --- a/addons/medical/script_component.hpp +++ b/addons/medical/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED Medical Core #include "\z\ace\addons\main\script_mod.hpp" -// #define DEBUG_MODE_FULL +#define DEBUG_MODE_FULL #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS From 04278149619bd31775cd87986b93dbdc5fd9dfd5 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 7 Nov 2016 22:21:07 +0100 Subject: [PATCH 03/12] Started transition to CBA state machine, removed revive in favour of extended cardiac arrest --- addons/medical/ACE_Medical_StateMachine.hpp | 88 +++++++++++-------- addons/medical/XEH_postInit.sqf | 3 - addons/medical/XEH_preInit.sqf | 20 ++++- .../fnc_conditionCardiacArrestDeath.sqf | 18 ++++ .../functions/fnc_enteredReviveState.sqf | 24 ----- .../fnc_enteredStateCardiacArrest.sqf | 16 ++++ .../functions/fnc_handleStateRevive.sqf | 55 ------------ .../fnc_leavingStateCardiacArrest.sqf | 16 ++++ 8 files changed, 118 insertions(+), 122 deletions(-) create mode 100644 addons/medical/functions/fnc_conditionCardiacArrestDeath.sqf delete mode 100644 addons/medical/functions/fnc_enteredReviveState.sqf create mode 100644 addons/medical/functions/fnc_enteredStateCardiacArrest.sqf delete mode 100644 addons/medical/functions/fnc_handleStateRevive.sqf create mode 100644 addons/medical/functions/fnc_leavingStateCardiacArrest.sqf diff --git a/addons/medical/ACE_Medical_StateMachine.hpp b/addons/medical/ACE_Medical_StateMachine.hpp index 8b6126a0d8..94df783f63 100644 --- a/addons/medical/ACE_Medical_StateMachine.hpp +++ b/addons/medical/ACE_Medical_StateMachine.hpp @@ -3,78 +3,88 @@ class ACE_Medical_StateMachine { onState = QUOTE(DFUNC(handleStateDefault)); class Injury { targetState = "Injured"; - events[] = {"TakenInjury"}; + events[] = {QGVAR(TakenInjury)}; }; class CriticalInjuryOrVitals { targetState = "Unconscious"; - events[] = {"InjuryCritical", "CriticalVitals"}; + events[] = {QGVAR(InjuryCritical), QGVAR(CriticalVitals)}; }; - class FatalInjuryOrVitals { - targetState = "Dead"; - events[] = {"FatalVitals", "InjuryFatal"}; + class FatalInjury { + targetState = "FatalInjury"; + events[] = {QGVAR(InjuryFatal)}; }; }; class Injured { onState = QUOTE(DFUNC(handleStateInjured)); class FullHeal { targetState = "Default"; - events[] = {"FullHeal"}; + events[] = {QGVAR(FullHeal)}; }; class LastWoundTreated { targetState = "Default"; - events[] = {"LastWoundTreated"}; + events[] = {QGVAR(LastWoundTreated)}; }; class CriticalInjuryOrVitals { targetState = "Unconscious"; - events[] = {"InjuryCritical", "CriticalVitals"}; + events[] = {QGVAR(InjuryCritical), QGVAR(CriticalVitals)}; }; - class FatalInjuryOrVitals { - targetState = "Dead"; - events[] = {"FatalVitals", "InjuryFatal"}; + class FatalVitals { + targetState = "CardiacArrest"; + events[] = {QGVAR(FatalVitals)}; + }; + class FatalInjury { + targetState = "FatalInjury"; + events[] = {QGVAR(InjuryFatal)}; }; }; class Unconscious { onState = QUOTE(DFUNC(handleStateUnconscious)); onStateEntered = QUOTE(DFUNC(enteredUnconsciousState)); - onStateLeaving = "_unit setVariable ['ACE_isUnconscious', false, true];"; + onStateLeaving = "_this setVariable ['ACE_isUnconscious', false, true];"; class WakeUpFromKnockDown { targetState = "Injured"; - condition = QUOTE(_unit call FUNC(hasStableVitals)); - events[] = {"MinUnconsciousTimer"}; + condition = QUOTE(_this call FUNC(hasStableVitals)); + events[] = {QGVAR(MinUnconsciousTimer)}; }; class WakeUpStable { targetState = "Injured"; condition = "unitUnconsciousTimer >= MinUnconsciousTimer"; - events[] = {"VitalsWentStable"}; + events[] = {QGVAR(VitalsWentStable)}; }; class FatalTransitions { + targetState = "CardiacArrest"; + events[] = {QGVAR(FatalVitals), QGVAR(UnconsciousTimerRanOut)}; + }; + class FatalInjury { + targetState = "FatalInjury"; + events[] = {QGVAR(InjuryFatal)}; + }; + }; + class FatalInjury { + // Transition state for handling instant death + onStateEntered = QUOTE(DFUNC(enteredStateFatalInjury)); + class InstantDeathPrevented { + targetState = "CardiacArrest"; + condition = QUOTE(DFUNC(conditionPreventInstantDeath)); + }; + class InstantDeath { targetState = "Dead"; - events[] = {"InjuryFatal", "FatalVitals", "UnconsciousTimerRanOut"}; + condition = "true"; + }; + }; + class CardiacArrest { + onStateEntered = QUOTE(DFUNC(enteredStateCardiacArrest)); + onStateLeaving = '_this setVariable [QGVAR(cardiacArrestStart), nil]'; + class Death { + targetState = "Dead"; + condition = QUOTE(DFUNC(conditionCardiacArrestDeath)); + }; + class Reanimated { + targetState = "Unconscious"; + events[] = {QGVAR(CPRSucceeded)}; }; }; class Dead { - onStateEntered = "(_this select 0) setDamage 1"; // killing a unit also exits the state machine for this unit - }; - class Revive { - onState = QUOTE(DFUNC(handleStateRevive)); - onStateEntered = QUOTE(DFUNC(enteredRevive)); // set unconscious animation & state - onStateLeaving = QUOTE(DFUNC(leavingRevive)); // leave unconscious animation & state - class FullHeal { - targetState = "Default"; - events[] = {"fullyHealed"}; - }; - class Revived { - targetState = "Injured"; - events[] = {"Revived"}; - }; - class TimerRanOut { - targetState = "Dead"; - events[] = {"ReviveTimer", "NoLives"}; - }; - class FatalTransitions { - targetState = "Dead"; - condition = QGVAR(killOnFatalDamageInRevive); - events[] = {"FatalInjury"}; - }; + onStateEntered = "_this setDamage 1"; // killing a unit also exits the state machine for this unit }; }; diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 434086bf4b..3f9b0c2df8 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -1,12 +1,9 @@ - #include "script_component.hpp" GVAR(heartBeatSounds_Fast) = ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3"]; GVAR(heartBeatSounds_Normal) = ["ACE_heartbeat_norm_1", "ACE_heartbeat_norm_2"]; GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"]; -call FUNC(stateMachine); - //Handle Deleting Bodies and creating litter on Server: if (isServer) then { ["ace_placedInBodyBag", FUNC(serverRemoveBody)] call CBA_fnc_addEventHandler; diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index b590114b13..2f8b13e377 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -7,7 +7,7 @@ ADDON = false; GVAR(HITPOINTS) = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"]; GVAR(SELECTIONS) = ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"]; -GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call FUNC(createStateMachine); +GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call CBA_statemachine_fnc_createFromConfig; // @todo, ACE_Settings [ @@ -37,4 +37,22 @@ GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call FUNC(creat true ] call CBA_Settings_fnc_init; +[ + QGVAR(enableInstantDeath), + "CHECKBOX", + ["Enable Instant Death", "Enables units instantly dying without entering cardiac arrest first."], //@todo + "ACE Medical", // @todo + true, + true +] call CBA_Settings_fnc_init; + +[ + QGVAR(maximumCardiacArrestTime), + "SLIDER", + ["Maximum Cardiac Arrest Time", "Sets the maximum amount of time a unit can stay in cardiac arrest."], //@todo + "ACE Medical", // @todo + [0, 30, 2, 0], + true +] call CBA_Settings_fnc_init; + ADDON = true; diff --git a/addons/medical/functions/fnc_conditionCardiacArrestDeath.sqf b/addons/medical/functions/fnc_conditionCardiacArrestDeath.sqf new file mode 100644 index 0000000000..fd7348f4bc --- /dev/null +++ b/addons/medical/functions/fnc_conditionCardiacArrestDeath.sqf @@ -0,0 +1,18 @@ +/* + * Author: BaerMitUmlaut + * Handles a unit entering cardiac arrest. + * + * Arguments: + * 0: The Unit + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" +params ["_unit"]; + +private _startTime = _unit getVariable [QGVAR(cardiacArrestStart), CBA_missionTime]; + +(CBA_missionTime - _startTime) > (GVAR(maximumCardiacArrestTime) * 60) diff --git a/addons/medical/functions/fnc_enteredReviveState.sqf b/addons/medical/functions/fnc_enteredReviveState.sqf deleted file mode 100644 index 4368cf5985..0000000000 --- a/addons/medical/functions/fnc_enteredReviveState.sqf +++ /dev/null @@ -1,24 +0,0 @@ - - -#include "script_component.hpp" - -params ["_unit"]; - -private _reviveVal = _unit getVariable [QGVAR(enableRevive), GVAR(enableRevive)]; -if (_reviveVal == 1 && {[_unit] call EFUNC(common,isPlayer)} || _reviveVal == 2) then { - if (_unit getVariable [QGVAR(inReviveState), false]) exitWith { - // Error, already in revive state - false; - }; - - private _lifesLeft = _unit getVariable [QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives)]; - if (GVAR(amountOfReviveLives) > 0 && _lifesLeft == 0) exitWith { - [_unit, "NoLives", []] call FUNC(stateEvent); - }; - - _unit setVariable [QGVAR(inReviveState), true, true]; - _unit setVariable [QGVAR(reviveStartTime), CBA_missionTime]; - [_unit, true] call FUNC(setUnconscious); -} else { - [_unit, "NoLives", []] call FUNC(stateEvent); -}; diff --git a/addons/medical/functions/fnc_enteredStateCardiacArrest.sqf b/addons/medical/functions/fnc_enteredStateCardiacArrest.sqf new file mode 100644 index 0000000000..73f94a8471 --- /dev/null +++ b/addons/medical/functions/fnc_enteredStateCardiacArrest.sqf @@ -0,0 +1,16 @@ +/* + * Author: BaerMitUmlaut + * Handles a unit entering cardiac arrest. + * + * Arguments: + * 0: The Unit + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" +params ["_unit"]; + +_unit setVariable [QGVAR(cardiacArrestStart), CBA_missionTime]; diff --git a/addons/medical/functions/fnc_handleStateRevive.sqf b/addons/medical/functions/fnc_handleStateRevive.sqf deleted file mode 100644 index e5251c93e5..0000000000 --- a/addons/medical/functions/fnc_handleStateRevive.sqf +++ /dev/null @@ -1,55 +0,0 @@ - -#include "script_component.hpp" - -params ["_unit", "_stateName", "_lastTime"]; - -// If the unit died the loop is finished -if (!alive _unit) exitWith {}; - -// If locality changed, broadcast the last medical state and finish the local loop -if (!local _unit) exitWith { - if (GVAR(level) >= 2) then { - _unit setVariable [QGVAR(heartRate), _unit getVariable [QGVAR(heartRate), 80], true]; - _unit setVariable [QGVAR(bloodPressure), _unit getVariable [QGVAR(bloodPressure), [80, 120]], true]; - }; - _unit setVariable [QGVAR(bloodVolume), _unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME], true]; -}; - -private _startTime = _unit getVariable [QGVAR(reviveStartTime), 0]; - -// If we are in revive state in a blown up vehicle, try to unload so that people can access the body -if ((alive _unit) && {(vehicle _unit) != _unit} && {!alive (vehicle _unit)}) then { - TRACE_2("Unloading", _unit, vehicle _unit); - [_unit] call EFUNC(common,unloadPerson); -}; - -// Revive timer ran out -if (GVAR(maxReviveTime) > 0 && {CBA_missionTime - _startTime > GVAR(maxReviveTime)}) exitWith { - [_unit, "ReviveTimer", []] call FUNC(stateEvent); - _unit setVariable [QGVAR(inReviveState), nil, true]; - _unit setVariable [QGVAR(reviveStartTime), nil]; -}; - -// If the unit was taken out from revive state, exit the loop -if !(_unit getVariable [QGVAR(inReviveState), false]) exitWith { - // Revived without dieing, so in case we have lifes, remove one. - if (GVAR(amountOfReviveLives) > 0) then { - _lifesLeft = _unit getVariable [QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives)]; - _unit setVariable [QGVAR(amountOfReviveLives), _lifesLeft - 1, true]; - }; - _unit setVariable [QGVAR(reviveStartTime), nil]; -}; - -// Remove heartbeat -if (GVAR(level) >= 2) then { - if (_unit getVariable [QGVAR(heartRate), 60] > 0) then { - _unit setVariable [QGVAR(heartRate), 0]; - }; -}; - -[_unit, CBA_missionTime - _lastTime] call FUNC(handleUnitVitals); - -private _pain = _unit getVariable [QGVAR(pain), 0]; -if (_pain > (_unit getVariable [QGVAR(painSuppress), 0])) then { - [_unit, "moan", PAIN_TO_MOAN(_pain)] call EFUNC(medical_engine,playInjuredSound); -}; diff --git a/addons/medical/functions/fnc_leavingStateCardiacArrest.sqf b/addons/medical/functions/fnc_leavingStateCardiacArrest.sqf new file mode 100644 index 0000000000..8ec63de5d9 --- /dev/null +++ b/addons/medical/functions/fnc_leavingStateCardiacArrest.sqf @@ -0,0 +1,16 @@ +/* + * Author: BaerMitUmlaut + * Handles a unit entering cardiac arrest. + * + * Arguments: + * 0: The Unit + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" +params ["_unit"]; + +_unit setVariable [QGVAR(cardiacArrestStart), nil]; From ba9fc9240c76c1c6522aa6fb36006d7b7eeaaecc Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 7 Nov 2016 23:44:33 +0100 Subject: [PATCH 04/12] Removed traces of old state machine --- addons/medical/XEH_PREP.hpp | 4 -- .../functions/fnc_createStateMachine.sqf | 59 ------------------- .../functions/fnc_handleUnitVitals.sqf | 2 +- .../medical/functions/fnc_setUnconscious.sqf | 2 +- addons/medical/functions/fnc_stateEvent.sqf | 52 ---------------- addons/medical/functions/fnc_stateMachine.sqf | 45 -------------- .../medical/functions/fnc_unconsciousPFH.sqf | 2 +- 7 files changed, 3 insertions(+), 163 deletions(-) delete mode 100644 addons/medical/functions/fnc_createStateMachine.sqf delete mode 100644 addons/medical/functions/fnc_stateEvent.sqf delete mode 100644 addons/medical/functions/fnc_stateMachine.sqf diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index ba7d979932..dab8edcb16 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -1,7 +1,5 @@ -PREP(addStateHandler); PREP(adjustPainLevel); -PREP(createStateMachine); PREP(getBloodLoss); PREP(getBloodPressure); PREP(getBloodVolumeChange); @@ -14,8 +12,6 @@ PREP(isInMedicalVehicle); PREP(isInStableCondition); PREP(isMedic); PREP(isMedicalVehicle); -PREP(stateEvent); -PREP(stateMachine); // PREP(hasMedicalEnabled); diff --git a/addons/medical/functions/fnc_createStateMachine.sqf b/addons/medical/functions/fnc_createStateMachine.sqf deleted file mode 100644 index 5154d2cedb..0000000000 --- a/addons/medical/functions/fnc_createStateMachine.sqf +++ /dev/null @@ -1,59 +0,0 @@ -#include "script_component.hpp" - -params ["_stateMachineConfig"]; - -private _getCode = { - params ["_config", "_attribute"]; - private _value = getText (_config >> _attribute); - if (isNil {missionNamespace getVariable _value}) exitWith { - if (_value == "") then {_value = "true"}; - systemChat format ["getCode (%1) is returning nil: %3", _attribute, missionnamespace getVariable _value, _value]; - diag_log format ["getCode (%1) is returning nil: %3", _attribute, missionnamespace getVariable _value, _value]; - - compile _value; - }; - missionNamespace getVariable _value; -}; - -private _stateMachine = call CBA_fnc_createNamespace; - -private _states = []; -{ - private _stateName = configName _x; - private _onState = [_x, "onState"] call _getCode; - private _onEntry = [_x, "onEntry"] call _getCode; - private _onExit = [_x, "onExit"] call _getCode; - - // Collect all the transitions for the state - private _transitions = []; - { - private _transitionName = configName _x; - private _targetState = getText (_x >> "targetState"); - private _events = getArray (_x >> "events") apply { toLower _x}; - private _condition = [_x, "condition"] call _getCode; - private _onTransition = [_x, "onTransition"] call _getCode; - - _transitions pushBack [_transitionName, _condition, _events, _onTransition, _targetState]; - } forEach ("true" configClasses _x); - _states pushBack [_stateName, _onState, _onEntry, _onExit, _transitions]; -} forEach ("true" configClasses _stateMachineConfig); - -// Helper method for finding the desired state when linking (See below) -private _getState = { - params ["_stateName"]; - private _state = ["Invalid", {}, {}, {}, []]; - { - if (_stateName == (_x select 0)) exitWith {_state = _x}; - } forEach _states; - _state; -}; - -_stateMachine setvariable [QGVAR(allStates), _states]; - -// Now we have collected all the states, link them in transitions so we do not have to look them up on state transitions -{ - _x params ["_stateName"]; - _stateMachine setvariable [_stateName, _x]; -} forEach _states; - -_stateMachine; diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 715134a373..c5fad60801 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -52,7 +52,7 @@ TRACE_3("ACE_DEBUG",_bloodLoss,_unit getVariable QGVAR(isBleeding),_unit); if (_bloodLoss > 0) then { _unit setVariable [QGVAR(bloodloss), _bloodLoss, _syncValues]; - [_unit, "TakenInjury"] call FUNC(stateEvent); + [QGVAR(TakenInjury), _unit] call CBA_fnc_localEvent; if !(_unit getVariable [QGVAR(isBleeding), false]) then { _unit setVariable [QGVAR(isBleeding), true, true]; diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index 65eadf6e85..bfaf75ce4a 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -81,7 +81,7 @@ if (_isDead) exitWith {}; */ [_unit, true] call EFUNC(medical_engine,setUnconsciousAnim); -[_unit, "Unconscious", []] call FUNC(stateEvent); +[QGVAR(Unconscious), _unit] call CBA_fnc_localEvent; ["ace_unconscious", [_unit, true]] call CBA_fnc_globalEvent; // auto wake up diff --git a/addons/medical/functions/fnc_stateEvent.sqf b/addons/medical/functions/fnc_stateEvent.sqf deleted file mode 100644 index 658497bb1e..0000000000 --- a/addons/medical/functions/fnc_stateEvent.sqf +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Author: Glowbal - * - * - * Arguments: - * 0: The Unit - * 1: Event name - * 2: Event Arguments - * - * ReturnValue: - * Name of the state after handling the state event - * - * Example: - * [unit, "TakenInjury", []] call ace_medical_stateEvent; - * - * Public: No - */ - -#include "script_component.hpp" - -params ["_unit", "_event", "_args"]; -diag_log format["ace_medical_stateEvent: %1", _this]; - -_event = toLower _event; - -private _unitState = _unit getVariable [QGVAR(state), [CBA_missionTime, GVAR(STATE_MACHINE) getVariable "Default"]]; -_unitState params ["_lastTime", "_state"]; -_state params ["_name", "_handler", "_onEntry", "_onExit", "_transitions"]; - -private _newStateName = _name; -{ - _x params ["_transitionName", "_condition", "_events", "_onTransition", "_targetStateName"]; - - if (_event in _events && {[_unit, _event, _args] call _condition}) exitWith { - private _targetState = GVAR(STATE_MACHINE) getVariable _targetStateName; - - _targetState params ["_targetStateName", "_targetStateHandler", "_targetStateOnEntry", "_targetStateOnExit", "_targetStateTansitions"]; - _newStateName = _targetStateName; - // Handle state leaving - [_unit, _event, _args] call _onExit; - [_unit, _event, _args] call _onTransition; - - // Switch the state - _unitState set [1, _targetState]; - _unit setvariable [QGVAR(state), _unitState]; - - // Enter the state - [_unit, _event, _args] call _targetStateOnEntry; - }; -} forEach _transitions; - -_newStateName; diff --git a/addons/medical/functions/fnc_stateMachine.sqf b/addons/medical/functions/fnc_stateMachine.sqf deleted file mode 100644 index 1f2dfed966..0000000000 --- a/addons/medical/functions/fnc_stateMachine.sqf +++ /dev/null @@ -1,45 +0,0 @@ -#include "script_component.hpp" - -// Delay between state runs -#define DELAY 1 -#define DEFAULT_STATE [0, "Default", {}, {}, {}, []] - -GVAR(monitoredUnitsList) = []; -GVAR(monitoredUnitsListIsSorted) = false; - -[{ - params ["_args", "_pfhId"]; - - if (!GVAR(monitoredUnitsListIsSorted)) then { - GVAR(monitoredUnitsList) sort true; - GVAR(monitoredUnitsListIsSorted) = true; - }; - - private _delete = false; - private _exit = false; - { - _x params ["_unit"]; - - if (!isNull _unit && alive _unit) then { - private _unitState = _unit getVariable [QGVAR(state), [-1, DEFAULT_STATE]]; - _unitState params ["_lastTime", "_state"]; - - if (CBA_missionTime - _lastTime < DELAY) exitWith { _exit = true; }; - _state params ["_name", "_handler", "_onEntry", "_onExit", "_transitions"]; - - _unitState set [0, CBA_missionTime]; - - _unit setvariable [QGVAR(state), _unitState]; - - [_unit, _name, _lastTime] call _handler; - } else { - _delete = true; - GVAR(monitoredUnitsList) set [_forEachIndex, objNull]; - }; - if (_exit) exitWith {}; - } forEach GVAR(monitoredUnitsList); - - if (_delete) then { - GVAR(monitoredUnitsList) = GVAR(monitoredUnitsList) - [objNull]; - }; -}, 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/medical/functions/fnc_unconsciousPFH.sqf b/addons/medical/functions/fnc_unconsciousPFH.sqf index 3c29190c42..31bd92d1ef 100644 --- a/addons/medical/functions/fnc_unconsciousPFH.sqf +++ b/addons/medical/functions/fnc_unconsciousPFH.sqf @@ -140,6 +140,6 @@ if ((CBA_missionTime - _startingTime) >= _minWaitingTime) exitWith { TRACE_2("ACE_DEBUG_Unconscious_Temp knock outs",_unit, [_unit] call FUNC(getUnconsciousCondition)); if (!([_unit] call FUNC(getUnconsciousCondition))) then { //_unit setVariable ["ACE_isUnconscious", false, true]; - [_unit, "MinUnconsciousTimer", []] call FUNC(stateEvent); + [QGVAR(MinUnconsciousTimer), _unit] call CBA_fnc_localEvent; }; }; From 928ded0e66673645f23facf4ea39c7cd55487a38 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 7 Nov 2016 23:46:10 +0100 Subject: [PATCH 05/12] Fixed instant death and PREP --- addons/medical/ACE_Medical_StateMachine.hpp | 5 ++++- addons/medical/XEH_PREP.hpp | 7 +++++-- .../functions/fnc_enteredStateFatalInjury.sqf | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 addons/medical/functions/fnc_enteredStateFatalInjury.sqf diff --git a/addons/medical/ACE_Medical_StateMachine.hpp b/addons/medical/ACE_Medical_StateMachine.hpp index 94df783f63..2377414806 100644 --- a/addons/medical/ACE_Medical_StateMachine.hpp +++ b/addons/medical/ACE_Medical_StateMachine.hpp @@ -62,12 +62,15 @@ class ACE_Medical_StateMachine { }; class FatalInjury { // Transition state for handling instant death + // This state raises the next transition in the same frame onStateEntered = QUOTE(DFUNC(enteredStateFatalInjury)); class InstantDeathPrevented { + events[] = {QGVAR(FatalInjuryInstantTransition)}; targetState = "CardiacArrest"; - condition = QUOTE(DFUNC(conditionPreventInstantDeath)); + condition = QUOTE(!GVAR(enableInstantDeath)); }; class InstantDeath { + events[] = {QGVAR(FatalInjuryInstantTransition)}; targetState = "Dead"; condition = "true"; }; diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index dab8edcb16..c195a61104 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -1,4 +1,3 @@ - PREP(adjustPainLevel); PREP(getBloodLoss); PREP(getBloodPressure); @@ -15,12 +14,16 @@ PREP(isMedicalVehicle); // PREP(hasMedicalEnabled); +PREP(enteredStateCardiacArrest); +PREP(leavingStateCardiacArrest); + +PREP(enteredStateFatalInjury); + PREP(handleStateDefault); PREP(handleStateInjured); PREP(handleStateUnconscious); PREP(handleUnitVitals); PREP(handleMedications); -// PREP(handleStateRevive); PREP(addPain); PREP(setUnconscious); diff --git a/addons/medical/functions/fnc_enteredStateFatalInjury.sqf b/addons/medical/functions/fnc_enteredStateFatalInjury.sqf new file mode 100644 index 0000000000..2f9cbb654c --- /dev/null +++ b/addons/medical/functions/fnc_enteredStateFatalInjury.sqf @@ -0,0 +1,16 @@ +/* + * Author: BaerMitUmlaut + * Raises the transition to the next state instantly when fatally injured. + * + * Arguments: + * 0: The Unit + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" +params ["_unit"]; + +[QGVAR(FatalInjuryInstantTransition), _unit] call CBA_fnc_localEvent; From 08a378bb2d76e44ae24c52512a7f55c02e33336c Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Tue, 8 Nov 2016 19:37:56 +0100 Subject: [PATCH 06/12] Added execution system, improved instant death --- addons/medical/ACE_Medical_StateMachine.hpp | 6 ++++++ addons/medical/XEH_PREP.hpp | 3 +++ addons/medical/XEH_preInit.sqf | 11 ++++++++++- .../functions/fnc_conditionExecutionDeath.sqf | 16 ++++++++++++++++ .../fnc_transitionInstantDeathPrevented.sqf | 19 +++++++++++++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 addons/medical/functions/fnc_conditionExecutionDeath.sqf create mode 100644 addons/medical/functions/fnc_transitionInstantDeathPrevented.sqf diff --git a/addons/medical/ACE_Medical_StateMachine.hpp b/addons/medical/ACE_Medical_StateMachine.hpp index 2377414806..94bf48bff2 100644 --- a/addons/medical/ACE_Medical_StateMachine.hpp +++ b/addons/medical/ACE_Medical_StateMachine.hpp @@ -68,6 +68,7 @@ class ACE_Medical_StateMachine { events[] = {QGVAR(FatalInjuryInstantTransition)}; targetState = "CardiacArrest"; condition = QUOTE(!GVAR(enableInstantDeath)); + onTransition = QUOTE(DFUNC(transitionInstantDeathPrevented)); }; class InstantDeath { events[] = {QGVAR(FatalInjuryInstantTransition)}; @@ -86,6 +87,11 @@ class ACE_Medical_StateMachine { targetState = "Unconscious"; events[] = {QGVAR(CPRSucceeded)}; }; + class Execution { + targetState = "Dead"; + condition = QUOTE(DFUNC(conditionExecutionDeath)); + events[] = {QGVAR(InjuryFatal)}; + }; }; class Dead { onStateEntered = "_this setDamage 1"; // killing a unit also exits the state machine for this unit diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index c195a61104..bd526a04bb 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -19,6 +19,9 @@ PREP(leavingStateCardiacArrest); PREP(enteredStateFatalInjury); +PREP(conditionExecutionDeath); +PREP(transitionInstantDeathPrevented); + PREP(handleStateDefault); PREP(handleStateInjured); PREP(handleStateUnconscious); diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 2f8b13e377..1540e538bc 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -46,10 +46,19 @@ GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call CBA_statem true ] call CBA_Settings_fnc_init; +[ + QGVAR(enableExecutions), + "CHECKBOX", + ["Enable Executions", "Enables killing units that are in cardiac arrest. Only matters when instant death is disabled."], //@todo + "ACE Medical", // @todo + true, + true +] call CBA_Settings_fnc_init; + [ QGVAR(maximumCardiacArrestTime), "SLIDER", - ["Maximum Cardiac Arrest Time", "Sets the maximum amount of time a unit can stay in cardiac arrest."], //@todo + ["Maximum Cardiac Arrest Time", "Sets the maximum amount of time a unit can stay in cardiac arrest before dying."], //@todo "ACE Medical", // @todo [0, 30, 2, 0], true diff --git a/addons/medical/functions/fnc_conditionExecutionDeath.sqf b/addons/medical/functions/fnc_conditionExecutionDeath.sqf new file mode 100644 index 0000000000..3c9a1cdf8e --- /dev/null +++ b/addons/medical/functions/fnc_conditionExecutionDeath.sqf @@ -0,0 +1,16 @@ +/* + * Author: BaerMitUmlaut + * Condition for an execution caused death. + * + * Arguments: + * 0: The Unit + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" +params ["_unit"]; + +GVAR(enableInstantDeath) || {GVAR(enableExecutions) && {!(_unit getVariable [QGVAR(deathBlocked), false])}} diff --git a/addons/medical/functions/fnc_transitionInstantDeathPrevented.sqf b/addons/medical/functions/fnc_transitionInstantDeathPrevented.sqf new file mode 100644 index 0000000000..87d9548fbc --- /dev/null +++ b/addons/medical/functions/fnc_transitionInstantDeathPrevented.sqf @@ -0,0 +1,19 @@ +/* + * Author: BaerMitUmlaut + * Prevents instant death for 1 second. + * + * Arguments: + * 0: The Unit + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" +params ["_unit"]; + +_unit setVariable [QGVAR(deathBlocked), true]; +[{ + _this setVariable [QGVAR(deathBlocked), false]; +}, _unit, 1] call CBA_fnc_waitAndExecute; From dac4a4dc42dfa221f6df9bfaff7455b443b02687 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Wed, 9 Nov 2016 19:01:55 +0100 Subject: [PATCH 07/12] Merged instant death and execution into one setting --- addons/medical/ACE_Medical_StateMachine.hpp | 12 +++++------ addons/medical/XEH_preInit.sqf | 21 +++++++------------ ...qf => fnc_conditionCardiacArrestTimer.sqf} | 2 +- .../functions/fnc_conditionExecutionDeath.sqf | 2 +- ...ted.sqf => fnc_transitionSecondChance.sqf} | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) rename addons/medical/functions/{fnc_conditionCardiacArrestDeath.sqf => fnc_conditionCardiacArrestTimer.sqf} (87%) rename addons/medical/functions/{fnc_transitionInstantDeathPrevented.sqf => fnc_transitionSecondChance.sqf} (82%) diff --git a/addons/medical/ACE_Medical_StateMachine.hpp b/addons/medical/ACE_Medical_StateMachine.hpp index 94bf48bff2..82ef3b6c29 100644 --- a/addons/medical/ACE_Medical_StateMachine.hpp +++ b/addons/medical/ACE_Medical_StateMachine.hpp @@ -64,13 +64,13 @@ class ACE_Medical_StateMachine { // Transition state for handling instant death // This state raises the next transition in the same frame onStateEntered = QUOTE(DFUNC(enteredStateFatalInjury)); - class InstantDeathPrevented { + class SecondChance { events[] = {QGVAR(FatalInjuryInstantTransition)}; targetState = "CardiacArrest"; - condition = QUOTE(!GVAR(enableInstantDeath)); - onTransition = QUOTE(DFUNC(transitionInstantDeathPrevented)); + condition = QUOTE(GVAR(allowDeathMode) > 0); + onTransition = QUOTE(DFUNC(transitionSecondChance)); }; - class InstantDeath { + class Death { events[] = {QGVAR(FatalInjuryInstantTransition)}; targetState = "Dead"; condition = "true"; @@ -79,9 +79,9 @@ class ACE_Medical_StateMachine { class CardiacArrest { onStateEntered = QUOTE(DFUNC(enteredStateCardiacArrest)); onStateLeaving = '_this setVariable [QGVAR(cardiacArrestStart), nil]'; - class Death { + class TimerRanOut { targetState = "Dead"; - condition = QUOTE(DFUNC(conditionCardiacArrestDeath)); + condition = QUOTE(DFUNC(conditionCardiacArrestTimer)); }; class Reanimated { targetState = "Unconscious"; diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 1540e538bc..f300d1cd70 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -38,20 +38,15 @@ GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call CBA_statem ] call CBA_Settings_fnc_init; [ - QGVAR(enableInstantDeath), - "CHECKBOX", - ["Enable Instant Death", "Enables units instantly dying without entering cardiac arrest first."], //@todo + QGVAR(allowDeathMode), + "LIST", + ["Kill unit after", ""], //@todo "ACE Medical", // @todo - true, - true -] call CBA_Settings_fnc_init; - -[ - QGVAR(enableExecutions), - "CHECKBOX", - ["Enable Executions", "Enables killing units that are in cardiac arrest. Only matters when instant death is disabled."], //@todo - "ACE Medical", // @todo - true, + [ + [0, 1, 2], + ["Fatal wound", "Second chance after fatal wound", "Only cardiac arrest time expiration"], + 0 + ], true ] call CBA_Settings_fnc_init; diff --git a/addons/medical/functions/fnc_conditionCardiacArrestDeath.sqf b/addons/medical/functions/fnc_conditionCardiacArrestTimer.sqf similarity index 87% rename from addons/medical/functions/fnc_conditionCardiacArrestDeath.sqf rename to addons/medical/functions/fnc_conditionCardiacArrestTimer.sqf index fd7348f4bc..79a3263d58 100644 --- a/addons/medical/functions/fnc_conditionCardiacArrestDeath.sqf +++ b/addons/medical/functions/fnc_conditionCardiacArrestTimer.sqf @@ -1,6 +1,6 @@ /* * Author: BaerMitUmlaut - * Handles a unit entering cardiac arrest. + * Checks if the cardiac arrest timer ran out. * * Arguments: * 0: The Unit diff --git a/addons/medical/functions/fnc_conditionExecutionDeath.sqf b/addons/medical/functions/fnc_conditionExecutionDeath.sqf index 3c9a1cdf8e..1fc870a3a4 100644 --- a/addons/medical/functions/fnc_conditionExecutionDeath.sqf +++ b/addons/medical/functions/fnc_conditionExecutionDeath.sqf @@ -13,4 +13,4 @@ #include "script_component.hpp" params ["_unit"]; -GVAR(enableInstantDeath) || {GVAR(enableExecutions) && {!(_unit getVariable [QGVAR(deathBlocked), false])}} +(GVAR(allowDeathMode) < 2) && {!(_unit getVariable [QGVAR(deathBlocked), false])}} diff --git a/addons/medical/functions/fnc_transitionInstantDeathPrevented.sqf b/addons/medical/functions/fnc_transitionSecondChance.sqf similarity index 82% rename from addons/medical/functions/fnc_transitionInstantDeathPrevented.sqf rename to addons/medical/functions/fnc_transitionSecondChance.sqf index 87d9548fbc..6fcfd0ac08 100644 --- a/addons/medical/functions/fnc_transitionInstantDeathPrevented.sqf +++ b/addons/medical/functions/fnc_transitionSecondChance.sqf @@ -1,6 +1,6 @@ /* * Author: BaerMitUmlaut - * Prevents instant death for 1 second. + * Gives the unit a second chance and prevents death for 1 second. * * Arguments: * 0: The Unit From 20f40f8c555d5b7c9ad7a7651c21cda784a597c5 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 9 Nov 2016 13:00:18 -0600 Subject: [PATCH 08/12] Use single queue for blood cleanup (#4586) --- addons/medical_blood/XEH_PREP.hpp | 1 + addons/medical_blood/XEH_postInit.sqf | 12 ++++++---- .../functions/fnc_serverCleanupBlood.sqf | 23 +++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 addons/medical_blood/functions/fnc_serverCleanupBlood.sqf diff --git a/addons/medical_blood/XEH_PREP.hpp b/addons/medical_blood/XEH_PREP.hpp index 0c6f6e245a..aa7d358388 100644 --- a/addons/medical_blood/XEH_PREP.hpp +++ b/addons/medical_blood/XEH_PREP.hpp @@ -3,4 +3,5 @@ PREP(handleWoundReceived); PREP(isBleeding); PREP(onBleeding); PREP(createBlood); +PREP(serverCleanupBlood); PREP(spurt); diff --git a/addons/medical_blood/XEH_postInit.sqf b/addons/medical_blood/XEH_postInit.sqf index d927797c56..78bf5c43f9 100644 --- a/addons/medical_blood/XEH_postInit.sqf +++ b/addons/medical_blood/XEH_postInit.sqf @@ -10,13 +10,17 @@ if (isServer) then { [QGVAR(bloodDropCreated), { params ["_bloodDrop"]; - GVAR(bloodDrops) pushBack _bloodDrop; + // Add to created queue with format [expireTime, object] + private _index = GVAR(bloodDrops) pushBack [(CBA_missionTime + BLOOD_OBJECT_LIFETIME), _bloodDrop]; + if (count GVAR(bloodDrops) >= MAX_BLOOD_OBJECTS) then { - private _deletedBloodDrop = GVAR(bloodDrops) deleteAt 0; + (GVAR(bloodDrops) deleteAt 0) params ["", "_deletedBloodDrop"]; deleteVehicle _deletedBloodDrop; }; - [{deleteVehicle _this}, _bloodDrop, BLOOD_OBJECT_LIFETIME] call CBA_fnc_waitAndExecute; + if (_index == 1) then { // Start the waitAndExecute loop + [FUNC(serverCleanupBlood), [], BLOOD_OBJECT_LIFETIME] call CBA_fnc_waitAndExecute; + }; }] call CBA_fnc_addEventHandler; }; @@ -30,7 +34,7 @@ if (isServer) then { } else { {allUnits select {(local _x) && {[_x] call FUNC(isBleeding)}}}; // filter all local bleeding units }; - + private _stateMachine = [_listcode, true] call CBA_statemachine_fnc_create; [_stateMachine, {call FUNC(onBleeding)}, {}, {}, "Bleeding"] call CBA_statemachine_fnc_addState; diff --git a/addons/medical_blood/functions/fnc_serverCleanupBlood.sqf b/addons/medical_blood/functions/fnc_serverCleanupBlood.sqf new file mode 100644 index 0000000000..4adc304d8c --- /dev/null +++ b/addons/medical_blood/functions/fnc_serverCleanupBlood.sqf @@ -0,0 +1,23 @@ +/* + * Author: PabstMirror + * Loop that cleans up blood + * + * Arguments: + * None + * + * ReturnValue: + * None + * + * Public: No + */ +#include "script_component.hpp" + +(GVAR(bloodDrops) deleteAt 0) params ["", "_deletedBloodDrop"]; +deleteVehicle _deletedBloodDrop; + +// If we cleaned out the array, exit loop +if (GVAR(bloodDrops) isEqualTo []) exitWith {}; + +// Wait until the next blood drop in the queue will expire +(GVAR(bloodDrops) select 0) params ["_expireTime"]; +[FUNC(serverCleanupBlood), [], (_expireTime - CBA_missionTime)] call CBA_fnc_waitAndExecute; From b4569f0a96d925e63711aaa161f421f15a738216 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 13 Nov 2016 18:11:18 +0100 Subject: [PATCH 09/12] Fix bracket --- addons/medical/functions/fnc_conditionExecutionDeath.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_conditionExecutionDeath.sqf b/addons/medical/functions/fnc_conditionExecutionDeath.sqf index 1fc870a3a4..9577365ae3 100644 --- a/addons/medical/functions/fnc_conditionExecutionDeath.sqf +++ b/addons/medical/functions/fnc_conditionExecutionDeath.sqf @@ -13,4 +13,4 @@ #include "script_component.hpp" params ["_unit"]; -(GVAR(allowDeathMode) < 2) && {!(_unit getVariable [QGVAR(deathBlocked), false])}} +(GVAR(allowDeathMode) < 2) && {!(_unit getVariable [QGVAR(deathBlocked), false])} From 27728172edefba2017bcdf8e55988c7cc570624a Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 13 Nov 2016 21:27:40 +0000 Subject: [PATCH 10/12] Clarify the `allowDeathMode` setting --- addons/medical/ACE_Medical_StateMachine.hpp | 2 +- addons/medical/XEH_preInit.sqf | 6 +++--- addons/medical/functions/fnc_conditionExecutionDeath.sqf | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/medical/ACE_Medical_StateMachine.hpp b/addons/medical/ACE_Medical_StateMachine.hpp index 82ef3b6c29..dc932e909f 100644 --- a/addons/medical/ACE_Medical_StateMachine.hpp +++ b/addons/medical/ACE_Medical_StateMachine.hpp @@ -67,7 +67,7 @@ class ACE_Medical_StateMachine { class SecondChance { events[] = {QGVAR(FatalInjuryInstantTransition)}; targetState = "CardiacArrest"; - condition = QUOTE(GVAR(allowDeathMode) > 0); + condition = QUOTE(GVAR(fatalInjuryCondition) > 0); onTransition = QUOTE(DFUNC(transitionSecondChance)); }; class Death { diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index f300d1cd70..62f8c91e84 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -38,13 +38,13 @@ GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call CBA_statem ] call CBA_Settings_fnc_init; [ - QGVAR(allowDeathMode), + QGVAR(fatalInjuryCondition), "LIST", - ["Kill unit after", ""], //@todo + ["Allow Fatal Injury", "Governs when a fatal injury can occur."], //@todo "ACE Medical", // @todo [ [0, 1, 2], - ["Fatal wound", "Second chance after fatal wound", "Only cardiac arrest time expiration"], + ["Always", "In Cardiac Arrest", "Never"], 0 ], true diff --git a/addons/medical/functions/fnc_conditionExecutionDeath.sqf b/addons/medical/functions/fnc_conditionExecutionDeath.sqf index 9577365ae3..60934c551f 100644 --- a/addons/medical/functions/fnc_conditionExecutionDeath.sqf +++ b/addons/medical/functions/fnc_conditionExecutionDeath.sqf @@ -13,4 +13,4 @@ #include "script_component.hpp" params ["_unit"]; -(GVAR(allowDeathMode) < 2) && {!(_unit getVariable [QGVAR(deathBlocked), false])} +(GVAR(fatalInjuryCondition) < 2) && {!(_unit getVariable [QGVAR(deathBlocked), false])} From 24ada4dab3979c0532a61b2ae71b0b4fb0aa356b Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 13 Nov 2016 21:45:38 +0000 Subject: [PATCH 11/12] Clarify the `maximumCardiacArrestTime` setting --- addons/medical/XEH_preInit.sqf | 4 ++-- addons/medical/functions/fnc_conditionCardiacArrestTimer.sqf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 62f8c91e84..261bfb4a4e 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -51,9 +51,9 @@ GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call CBA_statem ] call CBA_Settings_fnc_init; [ - QGVAR(maximumCardiacArrestTime), + QGVAR(cardiacArrestTime), "SLIDER", - ["Maximum Cardiac Arrest Time", "Sets the maximum amount of time a unit can stay in cardiac arrest before dying."], //@todo + ["Cardiac Arrest Time", "Sets how long cardiac arrest will last for (in minutes)."], //@todo "ACE Medical", // @todo [0, 30, 2, 0], true diff --git a/addons/medical/functions/fnc_conditionCardiacArrestTimer.sqf b/addons/medical/functions/fnc_conditionCardiacArrestTimer.sqf index 79a3263d58..2fffd7cfff 100644 --- a/addons/medical/functions/fnc_conditionCardiacArrestTimer.sqf +++ b/addons/medical/functions/fnc_conditionCardiacArrestTimer.sqf @@ -15,4 +15,4 @@ params ["_unit"]; private _startTime = _unit getVariable [QGVAR(cardiacArrestStart), CBA_missionTime]; -(CBA_missionTime - _startTime) > (GVAR(maximumCardiacArrestTime) * 60) +(CBA_missionTime - _startTime) > (GVAR(cardiacArrestTime) * 60) From ac28bce57812ca0b390111a1f3001c5472df679d Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Tue, 29 Nov 2016 12:35:26 +0100 Subject: [PATCH 12/12] Fixed state machine not running for units --- addons/medical/ACE_Medical_StateMachine.hpp | 3 +++ addons/medical/XEH_PREP.hpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/medical/ACE_Medical_StateMachine.hpp b/addons/medical/ACE_Medical_StateMachine.hpp index dc932e909f..29cb1e8962 100644 --- a/addons/medical/ACE_Medical_StateMachine.hpp +++ b/addons/medical/ACE_Medical_StateMachine.hpp @@ -1,4 +1,7 @@ class ACE_Medical_StateMachine { + list = "allUnits select {local _x}"; + skipNull = 1; + class Default { onState = QUOTE(DFUNC(handleStateDefault)); class Injury { diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index bd526a04bb..84aa378109 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -20,7 +20,7 @@ PREP(leavingStateCardiacArrest); PREP(enteredStateFatalInjury); PREP(conditionExecutionDeath); -PREP(transitionInstantDeathPrevented); +PREP(transitionSecondChance); PREP(handleStateDefault); PREP(handleStateInjured);