From 9d728f326c8fcc8924f9e0045a3dc9ef5a0ef36e Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 19 Jun 2019 00:16:15 -0500 Subject: [PATCH] Medical StateMachine - Tweak dead state handling - Don't call setDammage inside HandleDamage EH - Add death reason on death transition --- addons/medical_statemachine/Statemachine.hpp | 7 +++++++ .../functions/fnc_enteredStateDeath.sqf | 13 ++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/addons/medical_statemachine/Statemachine.hpp b/addons/medical_statemachine/Statemachine.hpp index 12a5a01779..05f661146f 100644 --- a/addons/medical_statemachine/Statemachine.hpp +++ b/addons/medical_statemachine/Statemachine.hpp @@ -48,6 +48,7 @@ class ACE_Medical_StateMachine { class DeathAI { targetState = "Dead"; condition = QUOTE(!isPlayer _this && {GVAR(unconsciousConditionAI)}); + onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Unconscious (AI)')];); }; class WakeUp { targetState = "Injured"; @@ -72,6 +73,7 @@ class ACE_Medical_StateMachine { events[] = {QEGVAR(medical,FatalInjuryInstantTransition)}; targetState = "Dead"; condition = QUOTE(!isPlayer _this && {GVAR(fatalInjuryConditionAI)}); + onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Fatal Injury (AI)')];); }; class SecondChance { events[] = {QEGVAR(medical,FatalInjuryInstantTransition)}; @@ -83,6 +85,7 @@ class ACE_Medical_StateMachine { events[] = {QEGVAR(medical,FatalInjuryInstantTransition)}; targetState = "Dead"; condition = "true"; + onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Fatal Injury')];); }; }; class CardiacArrest { @@ -91,10 +94,12 @@ class ACE_Medical_StateMachine { class DeathAI { targetState = "Dead"; condition = QUOTE(!isPlayer _this && {GVAR(fatalInjuryConditionAI)}); + onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Cardiac Arrest (AI)')];); }; class Timeout { targetState = "Dead"; condition = QFUNC(conditionCardiacArrestTimer); + onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Cardiac Arrest (Brain Damage)')];); }; class Reanimation { targetState = "Unconscious"; @@ -104,10 +109,12 @@ class ACE_Medical_StateMachine { targetState = "Dead"; condition = QFUNC(conditionExecutionDeath); events[] = {QEGVAR(medical,FatalInjury)}; + onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Fatal Injury (Execution)')];); }; class Bleedout { targetState = "Dead"; events[] = {QEGVAR(medical,Bleedout)}; + onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Bleedout')];); }; }; class Dead { diff --git a/addons/medical_statemachine/functions/fnc_enteredStateDeath.sqf b/addons/medical_statemachine/functions/fnc_enteredStateDeath.sqf index d99d13faca..21cf465dcd 100644 --- a/addons/medical_statemachine/functions/fnc_enteredStateDeath.sqf +++ b/addons/medical_statemachine/functions/fnc_enteredStateDeath.sqf @@ -15,11 +15,14 @@ * Public: No */ -params ["_unit"]; +[{ + params ["_unit"]; -// TODO: Probably also needs additional logic to deal with edge cases + // TODO: Probably also needs additional logic to deal with edge cases -// Send a local event before death -[QEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent; + // Send a local event before death + [QEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent; -[_unit] call EFUNC(medical_status,setDead); + private _deathReason = _unit getVariable [QGVAR(deathReason), nil]; + [_unit, _deathReason] call EFUNC(medical_status,setDead); +}, _this] call CBA_fnc_execNextFrame;