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 {
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 {

View File

@ -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;