[Medical Rewrite] Adding respawn compatibility (#5020)

* Added respawn transition

* Removed respawn transition from statemachine and added manual transition comment

* Changed transiton to manual. Added easy way to get current status as well

* Updated event reference

* Fixed manualTransition call

* Minor headers changes
This commit is contained in:
Zakant 2017-06-18 01:28:16 +02:00 committed by PabstMirror
parent b5f6169341
commit bdea0fcdba
5 changed files with 58 additions and 0 deletions

View File

@ -1,3 +1,5 @@
// Manual transitions applied to this statemachine
// - medical_fnc_handleRespawn:18
class ACE_Medical_StateMachine {
list = "allUnits select {local _x}";
skipNull = 1;

View File

@ -23,3 +23,11 @@ class Extended_Init_EventHandlers {
};
};
};
class Extended_Respawn_EventHandlers {
class CAManBase {
class ADDON {
respawn = QUOTE(call FUNC(handleRespawn));
};
};
};

View File

@ -15,9 +15,11 @@ PREP(getBloodPressure);
PREP(getBloodVolumeChange);
PREP(getCardiacOutput);
PREP(getPainLevel);
PREP(getUnitState);
PREP(handleIncapacitation);
PREP(handleKilled);
PREP(handleLocal);
PREP(handleRespawn);
PREP(handleStateDefault);
PREP(handleStateInjured);
PREP(handleStateUnconscious);

View File

@ -0,0 +1,22 @@
/*
* Author: Zakant
* Gets the name of the current medical state of an unit. Unit has to be local to the caller.
*
* Arguments:
* 0: The Unit <OBJECT>
*
* Return Value:
* Name of the current medical state of the unit <STRING>
*
* Example:
* [player] call ace_medical_fnc_getUnitState
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit"];
if (!local _unit) exitWith { ERROR("unit is not local"); };
[_unit, GVAR(STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState

View File

@ -0,0 +1,24 @@
/*
* Author: Zakant
* Handles respawn of a unit.
*
* Arguments:
* 0: The Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_medical_fnc_handleRespawn
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
TRACE_2("handleRespawn",_unit,local _unit);
if (!local _unit) exitWith {};
_unit call FUNC(init); // Call init to reset the medical states for the unit.
[_unit, GVAR(STATE_MACHINE), _unit call FUNC(getUnitState), "Default"] call CBA_statemachine_fnc_manualTransition; // Move the unit to the default medical state