ACE3/addons/medical_ai/StateMachine.hpp
Dedmen Miller 7f04d00b7f Add localUnits array and use that inside medical statemachines (#4836)
* Added localUnits EH

Code by @Commy2

* Init localUnits Variable

* use localUnits for medical_blood statemachine

* use localUnits for medical_ai statemachine

* Remove bracket hell

* Add Deleted EH

* Run at preInit, move to seperate file

* Handle Respawns, Filter Dead

* Add detection for Fake deleted EH

* Use a getter function

* delete all objNull at deletedEH

* Cleanup header/comments

* Move isBleeding check to inside statemachine

* opps

* debug off
2019-02-26 23:28:16 -06:00

87 lines
2.8 KiB
C++

class GVAR(stateMachine) {
list = QUOTE(call EFUNC(common,getLocalUnits));
skipNull = 1;
class Initial {
class Injured {
targetState = "Injured";
condition = QUOTE(call FUNC(isInjured));
};
class HealUnit {
targetState = "HealUnit";
condition = QUOTE((call FUNC(isSafe)) && {call FUNC(wasRequested)});
};
};
class Injured {
#ifdef DEBUG_MODE_FULL
onState = "systemChat format [""%1 is injured"", _this]";
#endif
class InSafety {
targetState = "Safe";
condition = QUOTE(call FUNC(isSafe));
};
};
class Safe {
#ifdef DEBUG_MODE_FULL
onState = "systemChat format [""%1 is injured, but safe"", _this]";
#endif
class RequestMedic {
targetState = "HealSelf";
condition = QUOTE(call FUNC(canRequestMedic));
onTransition = QUOTE(call FUNC(requestMedic));
};
class HealSelf {
targetState = "HealSelf";
condition = "true";
};
};
class HealSelf {
onState = QUOTE(call FUNC(healSelf));
onStateLeaving = QUOTE(_this setVariable [ARR_2(QUOTE(QGVAR(treatmentOverAt)),nil)]);
class Initial {
// Go back to initial state when done healing
targetState = "Initial";
condition = QUOTE( \
!(call FUNC(isInjured)) \
&& {_this getVariable [ARR_2(QUOTE(QGVAR(treatmentOverAt)),CBA_missionTime)] <= CBA_missionTime} \
);
};
class Injured {
// Stop treating when it's no more safe
targetState = "Injured";
condition = QUOTE( \
!(call FUNC(isSafe)) \
&& {_this getVariable [ARR_2(QUOTE(QGVAR(treatmentOverAt)),CBA_missionTime)] <= CBA_missionTime} \
);
};
};
class HealUnit {
onState = QUOTE(call FUNC(healUnit));
onStateLeaving = QUOTE(_this setVariable [ARR_2(QUOTE(QGVAR(treatmentOverAt)),nil)]);
class Initial {
// Go back to initial state when done healing or it's no more safe to treat
targetState = "Initial";
condition = QUOTE( \
!((call FUNC(wasRequested)) && {call FUNC(isSafe)}) \
&& {_this getVariable [ARR_2(QUOTE(QGVAR(treatmentOverAt)),CBA_missionTime)] <= CBA_missionTime} \
);
};
class Injured {
// Treating yourself has priority
targetState = "Injured";
condition = QUOTE( \
(call FUNC(isInjured)) \
&& {_this getVariable [ARR_2(QUOTE(QGVAR(treatmentOverAt)),CBA_missionTime)] <= CBA_missionTime} \
);
};
};
};