ACE3/addons/medical_statemachine/Statemachine.hpp

115 lines
4.4 KiB
C++
Raw Normal View History

// Manual transitions applied to this statemachine
// - medical_fnc_handleRespawn:18
2016-06-30 21:43:25 +00:00
class ACE_Medical_StateMachine {
list = "allUnits select {local _x}";
skipNull = 1;
2016-06-30 21:43:25 +00:00
class Default {
2018-07-15 12:21:41 +00:00
onState = QUOTE(call FUNC(handleStateDefault));
2016-06-30 21:43:25 +00:00
class Injury {
targetState = "Injured";
events[] = {QEGVAR(medical,Injury)};
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)};
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-15 12:21:41 +00:00
onState = QUOTE(call FUNC(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)};
};
class FatalInjury {
targetState = "FatalInjury";
events[] = {QEGVAR(medical,FatalInjury)};
2016-06-30 21:43:25 +00:00
};
};
class Unconscious {
2018-07-15 12:21:41 +00:00
onState = QUOTE(call FUNC(handleStateUnconscious));
2018-05-09 15:52:26 +00:00
onStateEntered = QUOTE([ARR_2(_this,(true))] call EFUNC(medical,setUnconsciousStatemachine));
class DeathAI {
targetState = "Dead";
2018-05-09 12:37:07 +00:00
condition = QUOTE(!isPlayer _this && {EGVAR(medical,unconsciousConditionAI)});
};
2016-12-05 20:34:20 +00:00
class WakeUp {
2016-06-30 21:43:25 +00:00
targetState = "Injured";
2018-05-08 09:16:12 +00:00
condition = QUOTE(_this call EFUNC(medical_status,hasStableVitals));
events[] = {QEGVAR(medical,WakeUp)};
2018-05-09 15:52:26 +00:00
onTransition = QUOTE([ARR_2(_this,(false))] call EFUNC(medical,setUnconsciousStatemachine));
2016-06-30 21:43:25 +00:00
};
class FatalTransitions {
targetState = "CardiacArrest";
events[] = {QEGVAR(medical,FatalVitals)};
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
2016-11-07 22:46:10 +00:00
// This state raises the next transition in the same frame
2018-07-15 12:21:41 +00:00
onStateEntered = QUOTE(call FUNC(enteredStateFatalInjury));
class DeathAI {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "Dead";
2018-05-09 12:37:07 +00:00
condition = QUOTE(!isPlayer _this && {EGVAR(medical,fatalInjuryConditionAI)});
};
class SecondChance {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "CardiacArrest";
2018-05-09 12:37:07 +00:00
condition = QUOTE(EGVAR(medical,fatalInjuryCondition) > 0);
2018-07-15 12:21:41 +00:00
onTransition = QUOTE(call FUNC(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";
condition = "true";
2016-06-30 21:43:25 +00:00
};
};
class CardiacArrest {
2018-07-15 12:21:41 +00:00
onStateEntered = QUOTE(call FUNC(enteredStateCardiacArrest));
onStateLeaving = QUOTE(call FUNC(leftStateCardiacArrest));
2017-06-18 10:43:39 +00:00
class DeathAI {
targetState = "Dead";
2018-05-09 12:37:07 +00:00
condition = QUOTE(!isPlayer _this && {EGVAR(medical,fatalInjuryConditionAI)});
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";
2018-07-15 12:21:41 +00:00
condition = QUOTE(call EFUNC(medical,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";
2018-07-15 12:21:41 +00:00
condition = QUOTE(call EFUNC(medical,conditionExecutionDeath));
events[] = {QEGVAR(medical,FatalInjury)};
};
};
class Dead {
2018-07-15 12:21:41 +00:00
// TODO: this needs to be handled by a function instead of inline scripts
// Probably also needs additional logic to deal with edge cases
onStateEntered = "_this setDamage 1"; // killing a unit also exits the state machine for this unit
2016-06-30 21:43:25 +00:00
};
};