Improve medical statemachine settings (#7154)

* Improve medical statemachine settings

* Multi-line condition and update fatal injury description

* Check isPlayer in DeathAI transition

Co-Authored-By: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
mharis001 2019-09-10 00:30:56 -04:00 committed by PabstMirror
parent b4c1d0cb57
commit 5dbaef4e07
7 changed files with 61 additions and 50 deletions

View File

@ -3,7 +3,6 @@
class ACE_Medical_StateMachine {
list = QUOTE(call EFUNC(common,getLocalUnits));
skipNull = 1;
class Default {
onState = QFUNC(handleStateDefault);
class Injury {
@ -44,7 +43,7 @@ class ACE_Medical_StateMachine {
};
class Unconscious {
onState = QFUNC(handleStateUnconscious);
onStateEntered = QUOTE([ARR_2(_this,(true))] call EFUNC(medical_status,setUnconscious));
onStateEntered = QUOTE([ARR_2(_this,true)] call EFUNC(medical_status,setUnconscious));
class DeathAI {
targetState = "Dead";
condition = QUOTE(!GVAR(AIUnconsciousness) && {!isPlayer _this});
@ -53,7 +52,7 @@ class ACE_Medical_StateMachine {
targetState = "Injured";
condition = QEFUNC(medical_status,hasStableVitals);
events[] = {QEGVAR(medical,WakeUp)};
onTransition = QUOTE([ARR_2(_this,(false))] call EFUNC(medical_status,setUnconscious));
onTransition = QUOTE([ARR_2(_this,false)] call EFUNC(medical_status,setUnconscious));
};
class FatalTransitions {
targetState = "CardiacArrest";
@ -65,24 +64,18 @@ class ACE_Medical_StateMachine {
};
};
class FatalInjury {
// Transition state for handling instant death
// Transition state for handling instant death from fatal injuries
// This state raises the next transition in the same frame
onStateEntered = QFUNC(enteredStateFatalInjury);
class DeathAI {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "Dead";
condition = QUOTE(!isPlayer _this && {GVAR(fatalInjuryConditionAI)});
};
class SecondChance {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "CardiacArrest";
condition = QUOTE(GVAR(fatalInjuryCondition) > 0);
condition = QFUNC(conditionSecondChance);
onTransition = QFUNC(transitionSecondChance);
};
class Death {
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
targetState = "Dead";
condition = "true";
};
};
class CardiacArrest {
@ -90,8 +83,10 @@ class ACE_Medical_StateMachine {
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(!isPlayer _this && {GVAR(fatalInjuryConditionAI)});
condition = QUOTE(!GVAR(AIUnconsciousness) && {!isPlayer _this});
};
class Timeout {
targetState = "Dead";

View File

@ -1,5 +1,6 @@
PREP(conditionCardiacArrestTimer);
PREP(conditionExecutionDeath);
PREP(conditionSecondChance);
PREP(enteredStateCardiacArrest);
PREP(enteredStateDeath);
PREP(enteredStateFatalInjury);

View File

@ -1,10 +1,10 @@
#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Condition for an execution caused death.
* Condition for an execution caused death (fatal injury received in cardiac arrest).
*
* Arguments:
* 0: The Unit <OBJECT>
* 0: Unit <OBJECT>
*
* Return Value:
* None
@ -17,4 +17,6 @@
params ["_unit"];
(GVAR(fatalInjuryCondition) < 2) && {!(_unit getVariable [QEGVAR(medical,deathBlocked), false])}
(isPlayer _unit && {GVAR(fatalInjuriesPlayer) != FATAL_INJURIES_NEVER}
|| {!isPlayer _unit && {GVAR(fatalInjuriesAI) != FATAL_INJURIES_NEVER}})
&& {!(_unit getVariable [QEGVAR(medical,deathBlocked), false])}

View File

@ -0,0 +1,20 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Condition for going into cardiac arrest upon receiving a fatal injury.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_medical_statemachine_fnc_conditionSecondChance
*
* Public: No
*/
params ["_unit"];
isPlayer _unit && {GVAR(fatalInjuriesPlayer) != FATAL_INJURIES_ALWAYS} || {!isPlayer _unit && {GVAR(fatalInjuriesAI) != FATAL_INJURIES_ALWAYS}}

View File

@ -1,18 +1,26 @@
[
QGVAR(fatalInjuryCondition),
QGVAR(fatalInjuriesPlayer),
"LIST",
[LSTRING(FatalInjuryCondition_DisplayName), LSTRING(FatalInjuryCondition_Description)],
[LSTRING(FatalInjuriesPlayer_DisplayName), LSTRING(FatalInjuriesPlayer_Description)],
[ELSTRING(medical,Category), LSTRING(SubCategory)],
[[0, 1, 2], [ELSTRING(common,Always), LSTRING(InCardiacArrest), ELSTRING(common,Never)], 0],
[
[FATAL_INJURIES_ALWAYS, FATAL_INJURIES_CRDC_ARRST, FATAL_INJURIES_NEVER],
[ELSTRING(common,Always), LSTRING(InCardiacArrest), ELSTRING(common,Never)],
0
],
true
] call CBA_settings_fnc_init;
[
QGVAR(fatalInjuryConditionAI),
"CHECKBOX",
[LSTRING(FatalInjuryConditionAI_DisplayName), LSTRING(FatalInjuryConditionAI_Description)],
QGVAR(fatalInjuriesAI),
"LIST",
[LSTRING(FatalInjuriesAI_DisplayName), LSTRING(FatalInjuriesAI_Description)],
[ELSTRING(medical,Category), LSTRING(SubCategory)],
true,
[
[FATAL_INJURIES_ALWAYS, FATAL_INJURIES_CRDC_ARRST, FATAL_INJURIES_NEVER],
[ELSTRING(common,Always), LSTRING(InCardiacArrest), ELSTRING(common,Never)],
0
],
true
] call CBA_settings_fnc_init;

View File

@ -16,3 +16,7 @@
#include "\z\ace\addons\medical_engine\script_macros_medical.hpp"
#include "\z\ace\addons\main\script_macros.hpp"
#define FATAL_INJURIES_ALWAYS 0
#define FATAL_INJURIES_CRDC_ARRST 1
#define FATAL_INJURIES_NEVER 2

View File

@ -8,33 +8,17 @@
<Russian>Состояния</Russian>
<French>États</French>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_FatalInjuryCondition_DisplayName">
<English>Fatal Injury Player</English>
<German>Tödliche Spielerverletzungen</German>
<Japanese>致命傷プレイヤー</Japanese>
<Russian>Смертельные ранения игрока</Russian>
<French>Blessure fatale des joueurs</French>
<Key ID="STR_ACE_Medical_Statemachine_FatalInjuriesPlayer_DisplayName">
<English>Player Fatal Injuries</English>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_FatalInjuryCondition_Description">
<English>Controls when a player can receive a fatal injury.</English>
<German>Definiert wann ein Spieler tödliche Verletzungen bekommen kann</German>
<Japanese>プレイヤーが致命傷から蘇生できるかどうか決定します</Japanese>
<Russian>Определяет, когда игрок может получить смертельное ранение</Russian>
<French>Définit quand un joueur peut recevoir une blessure fatale.</French>
<Key ID="STR_ACE_Medical_Statemachine_FatalInjuriesPlayer_Description">
<English>Controls when players can receive fatal injuries. A fatal injury is caused by significant damage to the head or body.</English>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_FatalInjuryConditionAI_DisplayName">
<English>AI Instant Death</English>
<German>Direkter Tod KI</German>
<Japanese>AI の即死</Japanese>
<Russian>Мгновенная смерть ИИ</Russian>
<French>Mort instantanée de l'IA</French>
<Key ID="STR_ACE_Medical_Statemachine_FatalInjuriesAI_DisplayName">
<English>AI Fatal Injuries</English>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_FatalInjuryConditionAI_Description">
<English>Controls if AI units are able to die instantly.</English>
<German>Legt fest, ob eine KI direkt sterben kann</German>
<Japanese>AI が即死できるかどうか決定します</Japanese>
<Russian>Определяет, сможет ли ИИ мгновенно умереть</Russian>
<French>Définit si les unités IA peuvent mourir instantanément.</French>
<Key ID="STR_ACE_Medical_Statemachine_FatalInjuriesAI_Description">
<English>Controls when AI can receive fatal injuries. A fatal injury is caused by significant damage to the head or body.\nWhen set to "Always", this effectively produces "AI Instant Death" behaviour as AI will immediately die from any fatal injury.\nNOTE: Any mode other than "Always" requires AI Unconsciousness to be enabled.</English>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_AIUnconsciousness_DisplayName">
<English>AI Unconsciousness</English>
@ -53,10 +37,7 @@
<Chinese>AI無意識</Chinese>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_AIUnconsciousness_Description">
<English>Allows AI to go unconscious instead of dying.</English>
<Japanese>AI が即死ではなく気絶へ移行できるかどうか決定します。</Japanese>
<French>Permet aux unités IA de perdre connaissance au lieu de mourir.</French>
<Russian>Позволяет ИИ оставаться без сознания вместо смерти.</Russian>
<English>Controls whether AI can go unconscious instead of immediately dying.\nThis setting works together with the "AI Fatal Injuries" setting since, going into cardiac arrest requires that the unit is able to go unconscious.\nHowever, these settings are separated because units can go unconscious from critical vitals resulting from non-fatal injuries.\nIn essence, this means that in order to enable cardiac arrest for AI units, this setting must be enabled.</English>
</Key>
<Key ID="STR_ACE_Medical_Statemachine_CardiacArrestTime_DisplayName">
<English>Cardiac Arrest Time</English>