ACE3/addons/medical_statemachine/Statemachine.hpp

115 lines
4.5 KiB
C++
Raw Normal View History

// Manual transitions applied to this statemachine
// - fnc_resetStateDefault on unit respawn
2016-06-30 21:43:25 +00:00
class ACE_Medical_StateMachine {
2019-03-26 03:49:53 +00:00
list = QUOTE(call EFUNC(common,getLocalUnits));
skipNull = 1;
2016-06-30 21:43:25 +00:00
class Default {
2018-07-16 21:25:54 +00:00
onState = QFUNC(handleStateDefault);
2016-06-30 21:43:25 +00:00
class Injury {
targetState = "Injured";
events[] = {QEGVAR(medical,injured), QEGVAR(medical,LoweredVitals)};
2016-06-30 21:43:25 +00:00
};
class CriticalInjuryOrVitals {
targetState = "Unconscious";
events[] = {QEGVAR(medical,CriticalInjury), QEGVAR(medical,CriticalVitals), QEGVAR(medical,knockOut)};
};
class FatalVitals {
targetState = "CardiacArrest";
events[] = {QEGVAR(medical,FatalVitals), QEGVAR(medical,Bleedout)};
2016-06-30 21:43:25 +00:00
};
class FatalInjury {
targetState = "FatalInjury";
events[] = {QEGVAR(medical,FatalInjury)};
2016-06-30 21:43:25 +00:00
};
};
class Injured {
2018-07-16 21:25:54 +00:00
onState = QFUNC(handleStateInjured);
2016-06-30 21:43:25 +00:00
class FullHeal {
targetState = "Default";
events[] = {QEGVAR(medical,FullHeal)};
2016-06-30 21:43:25 +00:00
};
class CriticalInjuryOrVitals {
targetState = "Unconscious";
events[] = {QEGVAR(medical,CriticalInjury), QEGVAR(medical,CriticalVitals), QEGVAR(medical,knockOut)};
2016-06-30 21:43:25 +00:00
};
class FatalVitals {
targetState = "CardiacArrest";
events[] = {QEGVAR(medical,FatalVitals), QEGVAR(medical,Bleedout)};
};
class FatalInjury {
targetState = "FatalInjury";
events[] = {QEGVAR(medical,FatalInjury)};
2016-06-30 21:43:25 +00:00
};
};
class Unconscious {
2018-07-16 21:25:54 +00:00
onState = QFUNC(handleStateUnconscious);
onStateEntered = QFUNC(enteredStateUnconscious);
class DeathAI {
targetState = "Dead";
condition = QUOTE(!GVAR(AIUnconsciousness) && {!isPlayer _this});
};
2016-12-05 20:34:20 +00:00
class WakeUp {
2016-06-30 21:43:25 +00:00
targetState = "Injured";
2018-07-16 21:25:54 +00:00
condition = QEFUNC(medical_status,hasStableVitals);
events[] = {QEGVAR(medical,WakeUp)};
onTransition = QUOTE([ARR_2(_this,false)] call EFUNC(medical_status,setUnconsciousState));
2016-06-30 21:43:25 +00:00
};
class FatalTransitions {
targetState = "CardiacArrest";
events[] = {QEGVAR(medical,FatalVitals), QEGVAR(medical,Bleedout)};
2016-06-30 21:43:25 +00:00
};
class FatalInjury {
targetState = "FatalInjury";
events[] = {QEGVAR(medical,FatalInjury)};
2016-06-30 21:43:25 +00:00
};
};
class FatalInjury {
// Transition state for handling instant death from fatal injuries
2016-11-07 22:46:10 +00:00
// This state raises the next transition in the same frame
2018-07-16 21:25:54 +00:00
onStateEntered = QFUNC(enteredStateFatalInjury);
class SecondChance {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "CardiacArrest";
condition = QFUNC(conditionSecondChance);
2018-07-16 21:25:54 +00:00
onTransition = QFUNC(transitionSecondChance);
2016-06-30 21:43:25 +00:00
};
class Death {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
2016-06-30 21:43:25 +00:00
targetState = "Dead";
};
};
class CardiacArrest {
onState = QFUNC(handleStateCardiacArrest);
2018-07-16 21:25:54 +00:00
onStateEntered = QFUNC(enteredStateCardiacArrest);
onStateLeaving = QFUNC(leftStateCardiacArrest);
2017-06-18 10:43:39 +00:00
class DeathAI {
// If an AI unit reanimates, they will immediately die upon entering unconsciousness if AI Unconsciousness is disabled
// As a result, we immediately kill the AI unit since cardiac arrest is effectively useless for it
2017-06-18 10:43:39 +00:00
targetState = "Dead";
condition = QUOTE(!GVAR(AIUnconsciousness) && {!isPlayer _this});
2017-06-18 10:43:39 +00:00
};
2016-12-05 20:34:20 +00:00
class Timeout {
2016-06-30 21:43:25 +00:00
targetState = "Dead";
condition = QFUNC(conditionCardiacArrestTimer);
2016-06-30 21:43:25 +00:00
};
2016-12-05 20:34:20 +00:00
class Reanimation {
targetState = "Unconscious";
events[] = {QEGVAR(medical,CPRSucceeded)};
};
class Execution {
targetState = "Dead";
condition = QFUNC(conditionExecutionDeath);
events[] = {QEGVAR(medical,FatalInjury)};
};
class Bleedout {
targetState = "Dead";
condition = QUOTE((GVAR(cardiacArrestBleedoutEnabled))); // wrap to ensure cba uses this as code and not a direct variable
events[] = {QEGVAR(medical,Bleedout)};
};
};
class Dead {
// When the unit is killed it's no longer handled by the statemachine
onStateEntered = QFUNC(enteredStateDeath);
2016-06-30 21:43:25 +00:00
};
};