ACE3/addons/medical_statemachine/Statemachine.hpp
YetheSamartaka e994906169
Medical - Add AI Unconsciousness exception (when using zeus module) (#8903)
* Add DF-15 GForceCoef Value

This adds missing ACE_GForceCoef value for DF-15 uniforms.

* DF-15 PR - cfgWeapons formating

DF-15 PR - cfgWeapons formating

* DF-15 PR - cfgWeapons formating II

Forgot to save it with braces and spaces around =

* Update CfgWeapons.hpp

* sync

* Add AI Unconsciousness exception option

- Adds AI Unconsciousness exception option. If enabled, it allows you to put AI into unconsciousness via Zeus Module even though the AI unconsciousness is disabled. This "feature" was possible before the medical rewrite and allowed to put selected AI units into unconsciousness  even though the overall AI unconsciousness was disabled. This was very handy and many groups missing this option including myself.
- Special thanks to Pterolatypus for consultation.

* tabs to spaces

tabs to spaces

* last tab to space :copium:

last tab to space :copium:

* stringtable tabs to spaces

stringtable tabs to spaces

* Addon option removed, adjusted variable name

- Addon option removed
- adjusted variable name

* utilized QEGVAR

- utilized QEGVAR in getVariable

* removed fnc and put the code inside the condition

- I've managed to properly implement the getVariable inside the condition thus allowing me to remove the function. Also kymckay had a good point on swapping the order for faster eval.

* Update XEH_PREP.hpp

* setVariable optimalization

- setVariable optimalization

Co-authored-by: pterolatypus <pterolatypus@users.noreply.github.com>

* Update addons/medical_statemachine/Statemachine.hpp

Co-authored-by: pterolatypus <pterolatypus@users.noreply.github.com>

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: pterolatypus <pterolatypus@users.noreply.github.com>
2022-05-07 22:44:33 -05:00

115 lines
4.5 KiB
C++

// Manual transitions applied to this statemachine
// - fnc_resetStateDefault on unit respawn
class ACE_Medical_StateMachine {
list = QUOTE(call EFUNC(common,getLocalUnits));
skipNull = 1;
class Default {
onState = QFUNC(handleStateDefault);
class Injury {
targetState = "Injured";
events[] = {QEGVAR(medical,injured), QEGVAR(medical,LoweredVitals)};
};
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)};
};
class FatalInjury {
targetState = "FatalInjury";
events[] = {QEGVAR(medical,FatalInjury)};
};
};
class Injured {
onState = QFUNC(handleStateInjured);
class FullHeal {
targetState = "Default";
events[] = {QEGVAR(medical,FullHeal)};
};
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)};
};
class FatalInjury {
targetState = "FatalInjury";
events[] = {QEGVAR(medical,FatalInjury)};
};
};
class Unconscious {
onState = QFUNC(handleStateUnconscious);
onStateEntered = QFUNC(enteredStateUnconscious);
class DeathAI {
targetState = "Dead";
condition = QUOTE(!(_this getVariable [ARR_2(QQGVAR(AIUnconsciousness), GVAR(AIUnconsciousness))]) && {!isPlayer _this});
};
class WakeUp {
targetState = "Injured";
condition = QEFUNC(medical_status,hasStableVitals);
events[] = {QEGVAR(medical,WakeUp)};
onTransition = QUOTE([ARR_2(_this,false)] call EFUNC(medical_status,setUnconsciousState));
};
class FatalTransitions {
targetState = "CardiacArrest";
events[] = {QEGVAR(medical,FatalVitals), QEGVAR(medical,Bleedout)};
};
class FatalInjury {
targetState = "FatalInjury";
events[] = {QEGVAR(medical,FatalInjury)};
};
};
class FatalInjury {
// Transition state for handling instant death from fatal injuries
// This state raises the next transition in the same frame
onStateEntered = QFUNC(enteredStateFatalInjury);
class SecondChance {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "CardiacArrest";
condition = QFUNC(conditionSecondChance);
onTransition = QFUNC(transitionSecondChance);
};
class Death {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "Dead";
};
};
class CardiacArrest {
onState = QFUNC(handleStateCardiacArrest);
onStateEntered = QFUNC(enteredStateCardiacArrest);
onStateLeaving = QFUNC(leftStateCardiacArrest);
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
targetState = "Dead";
condition = QUOTE(!GVAR(AIUnconsciousness) && {!isPlayer _this});
};
class Timeout {
targetState = "Dead";
condition = QFUNC(conditionCardiacArrestTimer);
};
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);
};
};