4 private const int USAGE_NONE = 0;
5 private const int USAGE_WAITING_TO_START = 1;
6 private const int USAGE_IN_PROGRESS = 2;
7 private const int USAGE_DONE_SUCCESS = 3;
8 private const int USAGE_DONE_FAILURE = 4;
10 protected const float TIME_OF_HEALING_MS = 12000.0;
11 protected const string PORT_USER_ACTION =
"UserAction";
12 protected const string PORT_TARGET_ENTITY =
"TargetEntity";
13 protected const string PORT_ITEM =
"ItemToUse";
15 protected typename m_sUserAction;
16 protected IEntity m_targetEntity, m_item;
18 protected bool m_bAborted;
20 private int m_iItemUsageInProgress;
21 private float m_fTimeout_ms;
23 [
Attribute( defvalue:
"SCR_BandageUserAction", uiwidget: UIWidgets.EditBox,
desc:
"Insert UserAction class name" )]
24 protected string m_userActionString;
26 override void OnEnter(AIAgent owner)
30 m_iItemUsageInProgress = USAGE_NONE;
34 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
36 switch (m_iItemUsageInProgress)
41 string userActionString;
43 if (!GetVariableIn(PORT_USER_ACTION, userActionString))
44 userActionString = m_userActionString;
45 GetVariableIn(PORT_ITEM, m_item);
47 IEntity controlledEntity = owner.GetControlledEntity();
48 if (!controlledEntity)
49 return ENodeResult.FAIL;
51 if (!GetVariableIn(PORT_TARGET_ENTITY, m_targetEntity))
52 m_targetEntity = controlledEntity;
54 m_sUserAction = userActionString.ToType();
55 if (m_sUserAction ==
typename.Empty)
56 return ENodeResult.FAIL;
58 ChimeraCharacter character = ChimeraCharacter.Cast(m_targetEntity);
62 if (!damageMan && !damageMan.CanBeHealed())
63 return ENodeResult.FAIL;
65 character = ChimeraCharacter.Cast(controlledEntity);
67 if (!m_targetContrComp)
68 return ENodeResult.FAIL;
70 array<BaseUserAction> outActions = {};
72 GetActions(m_targetEntity, outActions);
81 if (action.GetUserActionGroup() != GetTargetGroup(m_targetEntity))
85 if (action && m_sUserAction == action.Type() && action.CanBePerformedScript(controlledEntity))
89 m_iItemUsageInProgress = USAGE_WAITING_TO_START;
90 action.PerformAction(m_targetEntity, controlledEntity);
91 return ENodeResult.RUNNING;
94 return ENodeResult.FAIL;
96 case USAGE_WAITING_TO_START:
98 float worldTime =
GetGame().GetWorld().GetWorldTime();
103 return ENodeResult.RUNNING;
105 case USAGE_IN_PROGRESS:
107 float worldTime =
GetGame().GetWorld().GetWorldTime();
112 return ENodeResult.RUNNING;
114 case USAGE_DONE_SUCCESS:
116 return ENodeResult.SUCCESS;
118 case USAGE_DONE_FAILURE:
120 return ENodeResult.FAIL;
123 return ENodeResult.FAIL;
127 override void OnAbort(AIAgent owner, Node nodeCausingAbort)
132 if (m_targetContrComp)
136 if (m_iItemUsageInProgress < USAGE_DONE_SUCCESS)
137 m_targetContrComp.GetInputContext().SetCancelItemAction(
true);
147 m_iItemUsageInProgress = USAGE_IN_PROGRESS;
157 m_iItemUsageInProgress = USAGE_DONE_SUCCESS;
159 m_iItemUsageInProgress = USAGE_DONE_FAILURE;
163 protected void GetActions(IEntity targetEntity, notnull out array<BaseUserAction> outActions)
168 ActionsManagerComponent actionOnEntity = ActionsManagerComponent.Cast(targetEntity.FindComponent(ActionsManagerComponent));
173 actionOnEntity.GetActionsList(outActions);
179 ChimeraCharacter
char = ChimeraCharacter.Cast(targetEntity);
187 array<ECharacterHitZoneGroup> limbs = {};
188 damageMan.GetAllLimbs(limbs);
193 return charHitZone.GetHitZoneGroup();
197 protected static ref TStringArray s_aVarsIn = {
204 override TStringArray GetVariablesIn()
210 protected override bool VisibleInPalette()
216 override bool CanReturnRunning() {
return true; }
219 protected override string GetOnHoverDescription()
221 return "Uses smart healing action and is running until it finishes.";