Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AICombatTargetGetterTask.c
Go to the documentation of this file.
1 class SCR_AICombatTargetGetterTask : AITaskScripted
3 {
4  protected SCR_AICombatComponent m_CombatComponent;
5 
6  protected static const string ENEMY_ENTITY_PORT = "EntityOut";
7  protected static const string ENEMY_LAST_SEEN_POS_PORT = "EntityLastSeenPos";
8  protected static const string ENEMY_LAST_SEEN_TIME_PORT = "EntityLastSeenTime";
9  protected static const string ENEMY_TARGET_INFO_PORT = "TargetInfoOut";
10 
11  ref SCR_AITargetInfo m_TargetInfo;
12 
13  //-------------------------------------------------------------------------------------------
14  protected override void OnInit(AIAgent owner)
15  {
16  m_CombatComponent = SCR_AICombatComponent.Cast(owner.GetControlledEntity().FindComponent(SCR_AICombatComponent));
17  }
18 
19  //-------------------------------------------------------------------------------------------
21  protected BaseTarget GetEnemy(SCR_AICombatComponent combatComp);
22 
23 
24  //-------------------------------------------------------------------------------------------
25  protected override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
26  {
27  if (!m_CombatComponent)
28  return ENodeResult.FAIL;
29 
30  BaseTarget targetEnemy = GetEnemy(m_CombatComponent);
31 
32  if (!targetEnemy)
33  return Fail();
34 
35  IEntity entEnemy = targetEnemy.GetTargetEntity();
36 
37  if (!entEnemy)
38  return Fail();
39 
40  m_TargetInfo = new SCR_AITargetInfo();
41  m_TargetInfo.Init(entEnemy, worldPos: targetEnemy.GetLastSeenPosition(), timestamp: targetEnemy.GetTimeLastSeen());
42 
43  SetVariableOut(ENEMY_ENTITY_PORT, entEnemy);
44  SetVariableOut(ENEMY_LAST_SEEN_POS_PORT, m_TargetInfo.m_vWorldPos);
45  SetVariableOut(ENEMY_LAST_SEEN_TIME_PORT, m_TargetInfo.m_fTimestamp);
46  SetVariableOut(ENEMY_TARGET_INFO_PORT, m_TargetInfo);
47  return ENodeResult.SUCCESS;
48  }
49 
50  //-------------------------------------------------------------------------------------------
51  protected ENodeResult Fail()
52  {
53  IEntity _enemy;
54  SetVariableOut(ENEMY_ENTITY_PORT, _enemy); // must be null to make deco test NotNull work <- unassigned variable does not
55  ClearVariable(ENEMY_LAST_SEEN_POS_PORT);
56  ClearVariable(ENEMY_LAST_SEEN_TIME_PORT);
57  ClearVariable(ENEMY_TARGET_INFO_PORT);
58  return ENodeResult.FAIL;
59  }
60 
61  //-------------------------------------------------------------------------------------------
62  static ref TStringArray s_aVarsOut =
63  {
64  ENEMY_ENTITY_PORT,
65  ENEMY_LAST_SEEN_POS_PORT,
66  ENEMY_LAST_SEEN_TIME_PORT,
67  ENEMY_TARGET_INFO_PORT
68  };
69  protected override TStringArray GetVariablesOut()
70  {
71  return s_aVarsOut;
72  }
73 
74  //-------------------------------------------------------------------------------------------
75  override bool VisibleInPalette() {return false;}
76 };
77 
78 
80 {
81  //-------------------------------------------------------------------------------------------
82  protected static override string GetOnHoverDescription()
83  {
84  return "Returns current enemy from SCR_AICombatComponent.GetCurrentTarget()";
85  }
86 
87  //-------------------------------------------------------------------------------------------
88  override protected BaseTarget GetEnemy(SCR_AICombatComponent combatComp)
89  {
90  return combatComp.GetCurrentTarget();
91  }
92 
93  //-------------------------------------------------------------------------------------------
94  override bool VisibleInPalette() {return true;}
95 };
96 
97 
99 {
100  //-------------------------------------------------------------------------------------------
101  protected static override string GetOnHoverDescription()
102  {
103  return "Returns current enemy from SCR_AICombatComponent.GetLastSeenEnemy()";
104  }
105 
106  //-------------------------------------------------------------------------------------------
107  override protected BaseTarget GetEnemy(SCR_AICombatComponent combatComp)
108  {
109  return combatComp.GetLastSeenEnemy();
110  }
111 
112  //-------------------------------------------------------------------------------------------
113  override bool VisibleInPalette() {return true;}
114 };
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
SCR_AICombatTargetGetterTask
Base class for tasks which return some target from combat component.
Definition: SCR_AICombatTargetGetterTask.c:2
BaseTarget
Definition: BaseTarget.c:12
SCR_AIGetLastSeenEnemy
Definition: SCR_AICombatTargetGetterTask.c:98
m_CombatComponent
SCR_AICombatComponent m_CombatComponent
Definition: SCR_AIUtilityComponent.c:12
SCR_AIGetCurrentEnemy
Definition: SCR_AICombatTargetGetterTask.c:79