mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fixes state machine (#6435)
This commit is contained in:
parent
9b5c5bc866
commit
3bf3629047
@ -51,11 +51,11 @@ if (!hasInterface) exitWith {};
|
||||
uiNamespace setVariable [QGVAR(debugControl), _ctrl];
|
||||
|
||||
[{
|
||||
private _playerState = [ACE_player, GVAR(STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
|
||||
private _playerState = [ACE_player, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
|
||||
(uiNamespace getVariable [QGVAR(debugControl), controlNull]) ctrlSetText format ["Player state: %1", _playerState];
|
||||
|
||||
if (!isNull cursorTarget && {cursorTarget isKindOf "CAManBase"}) then {
|
||||
private _targetState = [cursorTarget, GVAR(STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
|
||||
private _targetState = [cursorTarget, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
|
||||
drawIcon3D ["", [0.6, 0, 0, 1], cursorTarget modelToWorldVisual (cursorTarget selectionPosition "pelvis"), 0, 0, 0, format ["State: %1", _targetState], 2, 40 * pixelH, "RobotoCondensed"];
|
||||
};
|
||||
}, 0 ,[]] call CBA_fnc_addPerFrameHandler;
|
||||
|
@ -9,8 +9,6 @@ PREP_RECOMPILE_END;
|
||||
GVAR(HITPOINTS) = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"];
|
||||
GVAR(SELECTIONS) = ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"];
|
||||
|
||||
GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call CBA_statemachine_fnc_createFromConfig;
|
||||
|
||||
/*
|
||||
[
|
||||
QGVAR(advancedBandages),
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
// State:
|
||||
private _hasStableVitals = [_unit] call EFUNC(medical_status,hasStableVitals);
|
||||
private _targetState = [_unit, GVAR(STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
|
||||
private _targetState = [_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
|
||||
if (!local _unit) then {_targetState = "NotLocal";};
|
||||
private _color = switch (_targetState) do {case "Default": {"33FF33"}; case "Injured": {"FF3333"}; case "Unconscious": {"FF8833"}; case "CardiacArrest": {"FF33AA"}; default {"555555"}};
|
||||
private _unconcFlag = if IS_UNCONSCIOUS(_unit) then {"[<t color='#FFFFFF'>U</t>]"} else {""};
|
||||
|
@ -19,4 +19,4 @@ params ["_unit"];
|
||||
|
||||
if (!local _unit) exitWith { ERROR("unit is not local"); };
|
||||
|
||||
[_unit, GVAR(STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState
|
||||
[_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState
|
||||
|
@ -5,7 +5,7 @@ class GVAR(stateMachine) {
|
||||
class Initial {
|
||||
class Injured {
|
||||
targetState = "Injured";
|
||||
condition = QUOTE(call FUNC(isInjured));
|
||||
condition = QFUNC(isInjured);
|
||||
};
|
||||
class HealUnit {
|
||||
targetState = "HealUnit";
|
||||
@ -20,7 +20,7 @@ class GVAR(stateMachine) {
|
||||
|
||||
class InSafety {
|
||||
targetState = "Safe";
|
||||
condition = QUOTE(call FUNC(isSafe));
|
||||
condition = QFUNC(isSafe);
|
||||
};
|
||||
};
|
||||
|
||||
@ -31,8 +31,8 @@ class GVAR(stateMachine) {
|
||||
|
||||
class RequestMedic {
|
||||
targetState = "HealSelf";
|
||||
condition = QUOTE(call FUNC(canRequestMedic));
|
||||
onTransition = QUOTE(call FUNC(requestMedic));
|
||||
condition = QFUNC(canRequestMedic);
|
||||
onTransition = QFUNC(requestMedic);
|
||||
};
|
||||
class HealSelf {
|
||||
targetState = "HealSelf";
|
||||
@ -41,7 +41,7 @@ class GVAR(stateMachine) {
|
||||
};
|
||||
|
||||
class HealSelf {
|
||||
onState = QUOTE(call FUNC(healSelf));
|
||||
onState = QFUNC(healSelf);
|
||||
onStateLeaving = QUOTE(_this setVariable [ARR_2(QUOTE(QGVAR(treatmentOverAt)),nil)]);
|
||||
|
||||
class Initial {
|
||||
@ -63,7 +63,7 @@ class GVAR(stateMachine) {
|
||||
};
|
||||
|
||||
class HealUnit {
|
||||
onState = QUOTE(call FUNC(healUnit));
|
||||
onState = QFUNC(healUnit);
|
||||
onStateLeaving = QUOTE(_this setVariable [ARR_2(QUOTE(QGVAR(treatmentOverAt)),nil)]);
|
||||
|
||||
class Initial {
|
||||
|
@ -5,7 +5,7 @@ class ACE_Medical_StateMachine {
|
||||
skipNull = 1;
|
||||
|
||||
class Default {
|
||||
onState = QUOTE(call FUNC(handleStateDefault));
|
||||
onState = QFUNC(handleStateDefault);
|
||||
class Injury {
|
||||
targetState = "Injured";
|
||||
events[] = {QEGVAR(medical,Injury)};
|
||||
@ -24,7 +24,7 @@ class ACE_Medical_StateMachine {
|
||||
};
|
||||
};
|
||||
class Injured {
|
||||
onState = QUOTE(call FUNC(handleStateInjured));
|
||||
onState = QFUNC(handleStateInjured);
|
||||
class FullHeal {
|
||||
targetState = "Default";
|
||||
events[] = {QEGVAR(medical,FullHeal)};
|
||||
@ -43,7 +43,7 @@ class ACE_Medical_StateMachine {
|
||||
};
|
||||
};
|
||||
class Unconscious {
|
||||
onState = QUOTE(call FUNC(handleStateUnconscious));
|
||||
onState = QFUNC(handleStateUnconscious);
|
||||
onStateEntered = QUOTE([ARR_2(_this,(true))] call EFUNC(medical,setUnconsciousStatemachine));
|
||||
class DeathAI {
|
||||
targetState = "Dead";
|
||||
@ -51,7 +51,7 @@ class ACE_Medical_StateMachine {
|
||||
};
|
||||
class WakeUp {
|
||||
targetState = "Injured";
|
||||
condition = QUOTE(_this call EFUNC(medical_status,hasStableVitals));
|
||||
condition = QEFUNC(medical_status,hasStableVitals);
|
||||
events[] = {QEGVAR(medical,WakeUp)};
|
||||
onTransition = QUOTE([ARR_2(_this,(false))] call EFUNC(medical,setUnconsciousStatemachine));
|
||||
};
|
||||
@ -67,7 +67,7 @@ class ACE_Medical_StateMachine {
|
||||
class FatalInjury {
|
||||
// Transition state for handling instant death
|
||||
// This state raises the next transition in the same frame
|
||||
onStateEntered = QUOTE(call FUNC(enteredStateFatalInjury));
|
||||
onStateEntered = QFUNC(enteredStateFatalInjury);
|
||||
class DeathAI {
|
||||
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
|
||||
targetState = "Dead";
|
||||
@ -77,7 +77,7 @@ class ACE_Medical_StateMachine {
|
||||
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
|
||||
targetState = "CardiacArrest";
|
||||
condition = QUOTE(EGVAR(medical,fatalInjuryCondition) > 0);
|
||||
onTransition = QUOTE(call FUNC(transitionSecondChance));
|
||||
onTransition = QFUNC(transitionSecondChance);
|
||||
};
|
||||
class Death {
|
||||
events[] = {QEGVAR(medical,FatalInjuryInstantTransition)};
|
||||
@ -86,15 +86,15 @@ class ACE_Medical_StateMachine {
|
||||
};
|
||||
};
|
||||
class CardiacArrest {
|
||||
onStateEntered = QUOTE(call FUNC(enteredStateCardiacArrest));
|
||||
onStateLeaving = QUOTE(call FUNC(leftStateCardiacArrest));
|
||||
onStateEntered = QFUNC(enteredStateCardiacArrest);
|
||||
onStateLeaving = QFUNC(leftStateCardiacArrest);
|
||||
class DeathAI {
|
||||
targetState = "Dead";
|
||||
condition = QUOTE(!isPlayer _this && {EGVAR(medical,fatalInjuryConditionAI)});
|
||||
};
|
||||
class Timeout {
|
||||
targetState = "Dead";
|
||||
condition = QUOTE(call EFUNC(medical,conditionCardiacArrestTimer));
|
||||
condition = QEFUNC(medical,conditionCardiacArrestTimer);
|
||||
};
|
||||
class Reanimation {
|
||||
targetState = "Unconscious";
|
||||
@ -102,7 +102,7 @@ class ACE_Medical_StateMachine {
|
||||
};
|
||||
class Execution {
|
||||
targetState = "Dead";
|
||||
condition = QUOTE(call EFUNC(medical,conditionExecutionDeath));
|
||||
condition = QEFUNC(medical,conditionExecutionDeath);
|
||||
events[] = {QEGVAR(medical,FatalInjury)};
|
||||
};
|
||||
};
|
||||
|
@ -4,4 +4,6 @@ ADDON = false;
|
||||
|
||||
#include "XEH_PREP.hpp"
|
||||
|
||||
EGVAR(medical,STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call CBA_statemachine_fnc_createFromConfig;
|
||||
|
||||
ADDON = true;
|
||||
|
@ -19,3 +19,4 @@ private _painLevel = GET_PAIN_PERCEIVED(_unit);
|
||||
if (_painLevel > 0) then {
|
||||
[_unit, "moan", PAIN_TO_MOAN(_painLevel)] call EFUNC(medical_engine,playInjuredSound);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user