Reset default state on respawn (#6518)

* Reset default state on respawn
* Remove old getUnitState function
* Add locality check
This commit is contained in:
SilentSpike 2018-08-12 10:14:48 +01:00 committed by GitHub
parent 14d52ee77e
commit 7fcd12c792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 24 deletions

View File

@ -1,4 +1,3 @@
PREP(addDamageToUnit);
PREP(dev_watchMedicalStats);
PREP(getUnitState);
PREP(setUnconscious);

View File

@ -1,22 +0,0 @@
#include "script_component.hpp"
/*
* 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
*/
params ["_unit"];
if (!local _unit) exitWith { ERROR("unit is not local"); };
[_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState

View File

@ -15,3 +15,11 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
class Extended_Respawn_EventHandlers {
class CAManBase {
class ADDON {
respawn = QUOTE(call FUNC(resetStateDefault));
};
};
};

View File

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

View File

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

View File

@ -0,0 +1,20 @@
#include "script_component.hpp"
/*
* Author: SilentSpike
* Resets the default state on a unit after respawning.
*
* Arguments:
* 0: The Unit <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
params ["_unit"];
// Statemachine only handles local units
if !(local _unit) exitWith {};
[_unit, EGVAR(medical,STATE_MACHINE), "Dead", "Default"] call CBA_statemachine_fnc_manualTransition;