Skip to content

Commit

Permalink
Add function to check if AI and condition from fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcanum417 committed May 22, 2017
1 parent d055845 commit 31e1e29
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
9 changes: 8 additions & 1 deletion addons/medical/ACE_Medical_StateMachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ class ACE_Medical_StateMachine {
class SecondChance {
events[] = {QGVAR(FatalInjuryInstantTransition)};
targetState = "CardiacArrest";
condition = QUOTE(GVAR(fatalInjuryCondition) > 0);
condition = QUOTE(DFUNC(conditionFromFatalToCardiac));
onTransition = QUOTE(DFUNC(transitionSecondChance));
};
class SecondChanceAI {
events[] = {QGVAR(FatalInjuryInstantTransition)};
targetState = "CardiacArrest";
//conditionFromFatalToCardiac
condition = QUOTE(DFUNC(conditionFromFatalToCardiac));
onTransition = QUOTE(DFUNC(transitionSecondChance));
};
class Death {
Expand Down
17 changes: 17 additions & 0 deletions addons/medical/functions/fnc_conditionFromFatalToCardiac.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Author: Arcanum
* Condition for trasfer from FatalInjury to Second chance.
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: 1 for AI 0 for player <BOOL>
*
* Return Value:
* Condition fo state machine <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit","_wantAI"];

(GVAR(fatalInjuryConditionAI) > 0) && (QUOTE(_this call FUNC(isAi)) == _wantAI)
27 changes: 27 additions & 0 deletions addons/medical/functions/fnc_isAI.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Author: Arcanum
* Check if a unit is AI
*
* Arguments:
* 0: The Unit <OBJECT>
*
* ReturnValue:
* Is AI <BOOL>
*
* Example:
* [player] call ace_medical_fnc_isAI
*
* Public: Yes
*/

#include "script_component.hpp"

params ["_unit"];
private _return = 0;

if (isPlayer _unit) then {
_return=0;
else {
_return=1;
};
_return

0 comments on commit 31e1e29

Please sign in to comment.