mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge medical core and medical state. Add working version of the state machine, re-add sounds
This commit is contained in:
parent
2d330e36e0
commit
e8eb729e04
@ -5,15 +5,15 @@ class ACE_Medical_StateMachine {
|
||||
onStateLeaving = "";
|
||||
class Injury {
|
||||
targetState = "Injured";
|
||||
events[] = {'TakenInjury'};
|
||||
events[] = {"TakenInjury"};
|
||||
};
|
||||
class CriticalInjuryOrVitals {
|
||||
targetState = "Unconscious";
|
||||
events[] = {'InjuryCritical', 'CriticalVitals'};
|
||||
events[] = {"InjuryCritical", "CriticalVitals"};
|
||||
};
|
||||
class FatalInjuryOrVitals {
|
||||
targetState = "Dead";
|
||||
events[] = {'FatalVitals', 'InjuryFatal'};
|
||||
events[] = {"FatalVitals", "InjuryFatal"};
|
||||
};
|
||||
};
|
||||
class Injured {
|
||||
@ -23,19 +23,19 @@ class ACE_Medical_StateMachine {
|
||||
|
||||
class FullHeal {
|
||||
targetState = "Default";
|
||||
events[] = {'FullHeal'};
|
||||
events[] = {"FullHeal"};
|
||||
};
|
||||
class LastWoundTreated {
|
||||
targetState = "Default";
|
||||
events[] = {'LastWoundTreated'};
|
||||
events[] = {"LastWoundTreated"};
|
||||
};
|
||||
class CriticalInjuryOrVitals {
|
||||
targetState = "Unconscious";
|
||||
events[] = {'InjuryCritical', 'CriticalVitals'};
|
||||
events[] = {"InjuryCritical", "CriticalVitals"};
|
||||
};
|
||||
class FatalInjuryOrVitals {
|
||||
targetState = "Dead";
|
||||
events[] = {'FatalVitals', 'InjuryFatal'};
|
||||
events[] = {"FatalVitals", "InjuryFatal"};
|
||||
};
|
||||
};
|
||||
class Unconscious {
|
||||
@ -45,16 +45,16 @@ class ACE_Medical_StateMachine {
|
||||
class WakeUpFromKnockDown {
|
||||
targetState = "Injured";
|
||||
condition = QUOTE(_unit call FUNC(hasStableVitals));
|
||||
events[] = {'MinUnconsciousTimer'};
|
||||
events[] = {"MinUnconsciousTimer"};
|
||||
};
|
||||
class WakeUpStable {
|
||||
targetState = "Injured";
|
||||
condition = "unitUnconsciousTimer >= MinUnconsciousTimer";
|
||||
events[] = {'VitalsWentStable'};
|
||||
events[] = {"VitalsWentStable"};
|
||||
};
|
||||
class FatalTransitions {
|
||||
targetState = "Dead";
|
||||
events[] = {'InjuryFatal', 'FatalVitals', 'UnconsciousTimerRanOut'};
|
||||
events[] = {"InjuryFatal", "FatalVitals", "UnconsciousTimerRanOut"};
|
||||
};
|
||||
};
|
||||
class Dead {
|
||||
@ -66,24 +66,24 @@ class ACE_Medical_StateMachine {
|
||||
onStateLeaving = QUOTE(DFUNC(leavingRevive)); // leave unconscious animation & state
|
||||
class FullHeal {
|
||||
targetState = "Default";
|
||||
events[] = {'fullyHealed'};
|
||||
events[] = {"fullyHealed"};
|
||||
onTransition = "";
|
||||
};
|
||||
class Revived {
|
||||
targetState = "Injured";
|
||||
events[] = {'Revived'};
|
||||
events[] = {"Revived"};
|
||||
onTransition = "";
|
||||
};
|
||||
class TimerRanOut {
|
||||
targetState = "Dead";
|
||||
condition = "timerValue >= maxReviveTime";
|
||||
events[] = {'ReviveTimer'};
|
||||
events[] = {"ReviveTimer"};
|
||||
onTransition = "";
|
||||
};
|
||||
class FatalTransitions {
|
||||
targetState = "Dead";
|
||||
condition = "killOnFatalDamageInRevive && inReviveState >= 10";
|
||||
events[] = {'FatalInjury'};
|
||||
events[] = {"FatalInjury"};
|
||||
};
|
||||
};
|
||||
};
|
37
addons/medical/CfgSounds.hpp
Normal file
37
addons/medical/CfgSounds.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
class CfgSounds {
|
||||
class ACE_heartbeat_fast_1 {
|
||||
name = "ACE_heartbeat_fast_1";
|
||||
sound[] = {QPATHTOF(sounds\heart_beats\fast_1.wav), "db+1", 1};
|
||||
titles[] = {};
|
||||
};
|
||||
class ACE_heartbeat_fast_2 {
|
||||
name = "ACE_heartbeat_fast_2";
|
||||
sound[] = {QPATHTOF(sounds\heart_beats\fast_2.wav), "db+1", 1};
|
||||
titles[] = {};
|
||||
};
|
||||
class ACE_heartbeat_fast_3 {
|
||||
name = "ACE_heartbeat_fast_3";
|
||||
sound[] = {QPATHTOF(sounds\heart_beats\fast_3.wav), "db+1", 1};
|
||||
titles[] = {};
|
||||
};
|
||||
class ACE_heartbeat_norm_1 {
|
||||
name = "ACE_heartbeat_norm_1";
|
||||
sound[] = {QPATHTOF(sounds\heart_beats\norm_1.wav), "db+1", 1};
|
||||
titles[] = {};
|
||||
};
|
||||
class ACE_heartbeat_norm_2 {
|
||||
name = "ACE_heartbeat_norm_2";
|
||||
sound[] = {QPATHTOF(sounds\heart_beats\norm_2.wav), "db+1", 1};
|
||||
titles[] = {};
|
||||
};
|
||||
class ACE_heartbeat_slow_1 {
|
||||
name = "ACE_heartbeat_slow_1";
|
||||
sound[] = {QPATHTOF(sounds\heart_beats\slow_1.wav), "db+1", 1};
|
||||
titles[] = {};
|
||||
};
|
||||
class ACE_heartbeat_slow_2 {
|
||||
name = "ACE_heartbeat_slow_2";
|
||||
sound[] = {QPATHTOF(sounds\heart_beats\slow_2.wav), "db+1", 1};
|
||||
titles[] = {};
|
||||
};
|
||||
};
|
@ -1,6 +1,7 @@
|
||||
|
||||
PREP(addStateHandler);
|
||||
PREP(adjustPainLevel);
|
||||
PREP(createStateMachine);
|
||||
PREP(getBloodLoss);
|
||||
PREP(getBloodPressure);
|
||||
PREP(getBloodVolumeChange);
|
||||
@ -18,3 +19,5 @@ PREP(parseConfigForInjuries);
|
||||
PREP(selectionNameToNumber);
|
||||
PREP(setHitPointDamage);
|
||||
PREP(setStructuralDamage);
|
||||
PREP(stateEvent);
|
||||
PREP(stateMachine);
|
||||
|
23
addons/medical/XEH_postInit.sqf
Normal file
23
addons/medical/XEH_postInit.sqf
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
GVAR(heartBeatSounds_Fast) = ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3"];
|
||||
GVAR(heartBeatSounds_Normal) = ["ACE_heartbeat_norm_1", "ACE_heartbeat_norm_2"];
|
||||
GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"];
|
||||
|
||||
|
||||
|
||||
["ace_unconscious", {
|
||||
params ["_unit", "_status"];
|
||||
if (local _unit) then {
|
||||
if (_status) then {
|
||||
_unit setVariable ["tf_voiceVolume", 0, true];
|
||||
_unit setVariable ["tf_unable_to_use_radio", true, true];
|
||||
_unit setVariable ["acre_sys_core_isDisabled", true, true];
|
||||
} else {
|
||||
_unit setVariable ["tf_voiceVolume", 1, true];
|
||||
_unit setVariable ["tf_unable_to_use_radio", false, true];
|
||||
_unit setVariable ["acre_sys_core_isDisabled", false, true];
|
||||
};
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
@ -8,6 +8,7 @@ GVAR(HITPOINTS) = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLe
|
||||
GVAR(SELECTIONS) = ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"];
|
||||
|
||||
call FUNC(parseConfigForInjuries);
|
||||
GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call FUNC(createStateMachine);
|
||||
|
||||
//Hack for #3168 (units in static weapons do not take any damage):
|
||||
//doing a manual pre-load with a small distance seems to fix the LOD problems with handle damage not returning full results
|
||||
|
@ -15,4 +15,7 @@ class CfgPatches {
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgSounds.hpp"
|
||||
|
||||
#include "injuries.hpp"
|
||||
#include "ACE_Medical_StateMachine.hpp"
|
||||
|
@ -5,9 +5,10 @@ params ["_stateMachineConfig"];
|
||||
private _getCode = {
|
||||
params ["_config", "_attribute"];
|
||||
private _value = getText (_config >> _attribute);
|
||||
if (_value == "") {_value = "true"};
|
||||
if (_value == "") then {_value = "true"};
|
||||
compile _value;
|
||||
};
|
||||
private _stateMachine = call CBA_fnc_createNamespace;
|
||||
|
||||
private _states = [];
|
||||
{
|
||||
@ -21,7 +22,7 @@ private _states = [];
|
||||
{
|
||||
private _transitionName = configName _x;
|
||||
private _targetState = getText (_x >> "targetState");
|
||||
private _events = getArray (_x >> "events");
|
||||
private _events = getArray (_x >> "events") apply { toLower _x};
|
||||
private _condition = [_x, "condition"] call _getCode;
|
||||
private _onTransition = [_x, "onTransition"] call _getCode;
|
||||
|
||||
@ -40,14 +41,12 @@ private _getState = {
|
||||
_state;
|
||||
};
|
||||
|
||||
_stateMachine setvariable [QGVAR(allStates), _states];
|
||||
|
||||
// Now we have collected all the states, link them in transitions so we do not have to look them up on state transitions
|
||||
{
|
||||
_x params ["", "", "", "", "_transitions"];
|
||||
{
|
||||
_x params ["", "", "", "", "_targetState"];
|
||||
private _state = [_targetState] call _getState;
|
||||
_x set [4, _state];
|
||||
} forEach _transitions;
|
||||
_x params ["_stateName"];
|
||||
_stateMachine setvariable [_stateName, _x];
|
||||
} forEach _states;
|
||||
|
||||
_states;
|
||||
_stateMachine;
|
52
addons/medical/functions/fnc_stateEvent.sqf
Normal file
52
addons/medical/functions/fnc_stateEvent.sqf
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
*
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Unit <OBJECT>
|
||||
* 1: Event name <STRING>
|
||||
* 2: Event Arguments
|
||||
*
|
||||
* ReturnValue:
|
||||
* Name of the state after handling the state event <STRING>
|
||||
*
|
||||
* Example:
|
||||
* [unit, "TakenInjury", []] call ace_medical_stateEvent;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_event", "_args"];
|
||||
diag_log format["ace_medical_stateEvent: %1", _this];
|
||||
|
||||
_event = toLower _event;
|
||||
|
||||
private _unitState = _unit getvariable [QGVAR(state), [CBA_missionTime, GVAR(STATE_MACHINE) getVariable "Default"]];
|
||||
_unitState params ["_lastTime", "_state"];
|
||||
_state params ["_name", "_handler", "_onEntry", "_onExit", "_transitions"];
|
||||
|
||||
private _newStateName = _name;
|
||||
{
|
||||
_x params ["_transitionName", "_condition", "_events", "_onTransition", "_targetStateName"];
|
||||
|
||||
if (_event in _events && {[_unit, _event, _args] call _condition}) exitWith {
|
||||
private _targetState = GVAR(STATE_MACHINE) getVariable _targetStateName;
|
||||
|
||||
_targetState params ["_targetStateName", "_targetStateHandler", "_targetStateOnEntry", "_targetStateOnExit", "_targetStateTansitions"];
|
||||
_newStateName = _targetStateName;
|
||||
// Handle state leaving
|
||||
[_unit, _event, _args] call _onExit;
|
||||
[_unit, _event, _args] call _onTransition;
|
||||
|
||||
// Switch the state
|
||||
_unitState set [1, _targetState];
|
||||
_unit setvariable [QGVAR(state), _unitState];
|
||||
|
||||
// Enter the state
|
||||
[_unit, _event, _args] call _targetStateOnEntry;
|
||||
};
|
||||
} forEach _transitions;
|
||||
|
||||
_newStateName;
|
@ -2,7 +2,7 @@
|
||||
|
||||
// Delay between state runs
|
||||
#define DELAY 10
|
||||
#define DEFAULT_STATE [0, "Default", {}, {}, {}, []];
|
||||
#define DEFAULT_STATE [0, "Default", {}, {}, {}, []]
|
||||
|
||||
GVAR(monitoredUnitsList) = [];
|
||||
GVAR(monitoredUnitsListIsSorted) = false;
|
||||
@ -20,7 +20,7 @@ GVAR(monitoredUnitsListIsSorted) = false;
|
||||
{
|
||||
_x params ["_unit"];
|
||||
|
||||
if (!isNull _unit && alive _unit) {
|
||||
if (!isNull _unit && alive _unit) then {
|
||||
private _unitState = _unit getvariable [QGVAR(state), [CBA_missionTime, DEFAULT_STATE]];
|
||||
_unitState params ["_lastTime", "_state"];
|
||||
|
BIN
addons/medical/sounds/Inject.ogg
Normal file
BIN
addons/medical/sounds/Inject.ogg
Normal file
Binary file not shown.
BIN
addons/medical/sounds/heart_beats/fast_1.wav
Normal file
BIN
addons/medical/sounds/heart_beats/fast_1.wav
Normal file
Binary file not shown.
BIN
addons/medical/sounds/heart_beats/fast_2.wav
Normal file
BIN
addons/medical/sounds/heart_beats/fast_2.wav
Normal file
Binary file not shown.
BIN
addons/medical/sounds/heart_beats/fast_3.wav
Normal file
BIN
addons/medical/sounds/heart_beats/fast_3.wav
Normal file
Binary file not shown.
BIN
addons/medical/sounds/heart_beats/norm_1.wav
Normal file
BIN
addons/medical/sounds/heart_beats/norm_1.wav
Normal file
Binary file not shown.
BIN
addons/medical/sounds/heart_beats/norm_2.wav
Normal file
BIN
addons/medical/sounds/heart_beats/norm_2.wav
Normal file
Binary file not shown.
BIN
addons/medical/sounds/heart_beats/slow_1.wav
Normal file
BIN
addons/medical/sounds/heart_beats/slow_1.wav
Normal file
Binary file not shown.
BIN
addons/medical/sounds/heart_beats/slow_2.wav
Normal file
BIN
addons/medical/sounds/heart_beats/slow_2.wav
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
z\ace\addons\medical_state
|
@ -1,11 +0,0 @@
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preStart));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
#include "XEH_PREP.hpp"
|
||||
|
||||
ADDON = true;
|
@ -1,3 +0,0 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
#include "XEH_PREP.hpp"
|
@ -1,17 +0,0 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class ADDON {
|
||||
name = COMPONENT_NAME;
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_medical"};
|
||||
author = ECSTRING(common,ACETeam);
|
||||
authors[] = {""};
|
||||
url = ECSTRING(main,URL);
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
@ -1,33 +0,0 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_event", "_args"];
|
||||
|
||||
private _unitState = _unit getvariable [QGVAR(state), [CBA_missionTime, DEFAULT_STATE]];
|
||||
_unitState params ["_lastTime", "_state"];
|
||||
_state params ["_name", "_handler", "_onEntry", "_onExit", "_transitions"];
|
||||
|
||||
{
|
||||
_x params ["_transitionName", "_condition", "_events", "_onTransition", "_targetState"];
|
||||
|
||||
if (_condition && {_event in _events}) exitWith {
|
||||
_targetState params ["_targetStateName", "_targetStateHandler", "_targetStateOnEntry", "_targetStateOnExit", "_targetStateTansitions"];
|
||||
|
||||
// Handle state leaving
|
||||
[_unit, _event, _args] call {
|
||||
params ["_unit", "_event", "_args"];
|
||||
[_unit, _event, _args] call _onExit;
|
||||
[_unit, _event, _args] call _onTransition;
|
||||
};
|
||||
|
||||
// Switch the state
|
||||
_unitState set [1, _targetState];
|
||||
_unit setvariable [QGVAR(state), _unitState];
|
||||
|
||||
// Enter the state
|
||||
[_unit, _event, _args] call {
|
||||
params ["_unit", "_event", "_args"];
|
||||
[_unit, _event, _args] call _targetStateOnEntry;
|
||||
};
|
||||
};
|
||||
} forEach _transitions;
|
@ -1 +0,0 @@
|
||||
#include "\z\ace\addons\medical_state\script_component.hpp"
|
@ -1,18 +0,0 @@
|
||||
#define COMPONENT medical_state
|
||||
#define COMPONENT_BEAUTIFIED Medical State Machine
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
// #define DISABLE_COMPILE_CACHE
|
||||
// #define CBA_DEBUG_SYNCHRONOUS
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef DEBUG_ENABLED_MEDICAL_STATE
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_MEDICAL_STATE
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_MEDICAL_STATE
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
Loading…
Reference in New Issue
Block a user