Medical - Transfer state machine state on locality (#6950)

* Medical - Transfer state machine state on locality

* Fix feedback isUnconscious var

* Exclude AI
This commit is contained in:
PabstMirror 2019-05-07 09:08:00 -05:00 committed by GitHub
parent a23b22aef6
commit cdd1de04f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 76 additions and 23 deletions

View File

@ -56,8 +56,7 @@ GVAR(heartBeatEffectRunning) = false;
// Update effects to match new unit's current status (this also handles respawn)
["unit", {
params ["_new"];
private _status = _new getVariable ["ace_unconscious", false];
private _status = IS_UNCONSCIOUS(_new);
if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {
_new setVariable ["tf_voiceVolume", [1, 0] select _status, true];

View File

@ -23,3 +23,12 @@ class Extended_Respawn_EventHandlers {
};
};
};
class Extended_Local_EventHandlers {
class CAManBase {
class ADDON {
local = QUOTE(call FUNC(localityChangedEH));
exclude[] = {"B_UAV_AI","O_UAV_AI","UAV_AI_base_F"};
};
};
};

View File

@ -7,5 +7,7 @@ PREP(handleStateDefault);
PREP(handleStateInjured);
PREP(handleStateUnconscious);
PREP(leftStateCardiacArrest);
PREP(localityChangedEH);
PREP(localityTransfer);
PREP(resetStateDefault);
PREP(transitionSecondChance);

View File

@ -1 +1,3 @@
#include "script_component.hpp"
[QGVAR(localityTransfer), LINKFUNC(localityTransfer)] call CBA_fnc_addEventHandler;

View File

@ -19,13 +19,7 @@ params ["_unit"];
// If the unit died the loop is finished
if (!alive _unit) exitWith {};
// If locality changed, broadcast the last medical state and finish the local loop
if (!local _unit) exitWith {
_unit setVariable [VAR_HEART_RATE, GET_HEART_RATE(_unit), true];
_unit setVariable [VAR_BLOOD_PRESS, _unit getVariable [VAR_BLOOD_PRESS, [80, 120]], true];
_unit setVariable [VAR_BLOOD_VOL, GET_BLOOD_VOLUME(_unit), true];
};
if (!local _unit) exitWith {};
[_unit] call EFUNC(medical_vitals,handleUnitVitals);

View File

@ -19,13 +19,7 @@ params ["_unit"];
// If the unit died the loop is finished
if (!alive _unit) exitWith {};
// If locality changed, broadcast the last medical state and finish the local loop
if (!local _unit) exitWith {
_unit setVariable [VAR_HEART_RATE, GET_HEART_RATE(_unit), true];
_unit setVariable [VAR_BLOOD_PRESS, _unit getVariable [VAR_BLOOD_PRESS, [80, 120]], true];
_unit setVariable [VAR_BLOOD_VOL, GET_BLOOD_VOLUME(_unit), true];
};
if (!local _unit) exitWith {};
[_unit] call EFUNC(medical_vitals,handleUnitVitals);

View File

@ -19,13 +19,7 @@ params ["_unit"];
// If the unit died the loop is finished
if (!alive _unit) exitWith {};
// If locality changed, broadcast the last medical state and finish the local loop
if (!local _unit) exitWith {
_unit setVariable [VAR_HEART_RATE, GET_HEART_RATE(_unit), true];
_unit setVariable [VAR_BLOOD_PRESS, _unit getVariable [VAR_BLOOD_PRESS, [80, 120]], true];
_unit setVariable [VAR_BLOOD_VOL, GET_BLOOD_VOLUME(_unit), true];
};
if (!local _unit) exitWith {};
[_unit] call EFUNC(medical_vitals,handleUnitVitals);

View File

@ -0,0 +1,33 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Handles locality switch.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: isLocal <BOOL>
*
* Return Value:
* None
*
* Example:
* [player, true] call ace_medical_statemachine_fnc_localityChangedEH
*
* Public: No
*/
params ["_unit", "_isLocal"];
TRACE_2("localityChangedEH",_unit,_isLocal);
if (!alive _unit) exitWith {TRACE_1("dead", _this)};
if (!_isLocal) then {
// If locality changed, broadcast the last medical state
_unit setVariable [VAR_HEART_RATE, GET_HEART_RATE(_unit), true];
_unit setVariable [VAR_BLOOD_PRESS, _unit getVariable [VAR_BLOOD_PRESS, [80, 120]], true];
_unit setVariable [VAR_BLOOD_VOL, GET_BLOOD_VOLUME(_unit), true];
private _currentState = [_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
TRACE_2("sending current state",_unit,_currentState);
[QGVAR(localityTransfer), [_unit, _currentState], _unit] call CBA_fnc_targetEvent;
};

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Handles locality switch.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: State <STRING>
*
* Return Value:
* None
*
* Example:
* [player, "Injured"] call ace_medical_statemachine_fnc_localityTransfer
*
* Public: No
*/
params ["_unit", "_currentState"];
TRACE_2("localityTransfer",_unit,_currentState);
private _oldState = [_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState;
if (_oldState != _currentState) then {
TRACE_2("changing state",_oldState,_currentState);
[_unit, EGVAR(medical,STATE_MACHINE), _oldState, _currentState, {}, "LocalityChange"] call CBA_statemachine_fnc_manualTransition;
};