Medical StateMachine - Tweak dead state handling

- Don't call setDammage inside HandleDamage EH
- Add death reason on death transition
This commit is contained in:
PabstMirror 2019-06-19 00:16:15 -05:00
parent a108062685
commit 9d728f326c
2 changed files with 15 additions and 5 deletions

View File

@ -48,6 +48,7 @@ class ACE_Medical_StateMachine {
class DeathAI { class DeathAI {
targetState = "Dead"; targetState = "Dead";
condition = QUOTE(!isPlayer _this && {GVAR(unconsciousConditionAI)}); condition = QUOTE(!isPlayer _this && {GVAR(unconsciousConditionAI)});
onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Unconscious (AI)')];);
}; };
class WakeUp { class WakeUp {
targetState = "Injured"; targetState = "Injured";
@ -72,6 +73,7 @@ class ACE_Medical_StateMachine {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)}; events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "Dead"; targetState = "Dead";
condition = QUOTE(!isPlayer _this && {GVAR(fatalInjuryConditionAI)}); condition = QUOTE(!isPlayer _this && {GVAR(fatalInjuryConditionAI)});
onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Fatal Injury (AI)')];);
}; };
class SecondChance { class SecondChance {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)}; events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
@ -83,6 +85,7 @@ class ACE_Medical_StateMachine {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)}; events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "Dead"; targetState = "Dead";
condition = "true"; condition = "true";
onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Fatal Injury')];);
}; };
}; };
class CardiacArrest { class CardiacArrest {
@ -91,10 +94,12 @@ class ACE_Medical_StateMachine {
class DeathAI { class DeathAI {
targetState = "Dead"; targetState = "Dead";
condition = QUOTE(!isPlayer _this && {GVAR(fatalInjuryConditionAI)}); condition = QUOTE(!isPlayer _this && {GVAR(fatalInjuryConditionAI)});
onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Cardiac Arrest (AI)')];);
}; };
class Timeout { class Timeout {
targetState = "Dead"; targetState = "Dead";
condition = QFUNC(conditionCardiacArrestTimer); condition = QFUNC(conditionCardiacArrestTimer);
onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Cardiac Arrest (Brain Damage)')];);
}; };
class Reanimation { class Reanimation {
targetState = "Unconscious"; targetState = "Unconscious";
@ -104,10 +109,12 @@ class ACE_Medical_StateMachine {
targetState = "Dead"; targetState = "Dead";
condition = QFUNC(conditionExecutionDeath); condition = QFUNC(conditionExecutionDeath);
events[] = {QEGVAR(medical,FatalInjury)}; events[] = {QEGVAR(medical,FatalInjury)};
onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Fatal Injury (Execution)')];);
}; };
class Bleedout { class Bleedout {
targetState = "Dead"; targetState = "Dead";
events[] = {QEGVAR(medical,Bleedout)}; events[] = {QEGVAR(medical,Bleedout)};
onTransition = QUOTE(_this setVariable [ARR_2(QQGVAR(deathReason),'Bleedout')];);
}; };
}; };
class Dead { class Dead {

View File

@ -15,11 +15,14 @@
* Public: No * 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 // Send a local event before death
[QEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent; [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;