Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIProvideAmmoBehavior.c
Go to the documentation of this file.
1 
5 {
6  protected float MOVE_COMPLETION_RADIUS = 10;
7 
8  static const string AMMO_CONSUMER_ENTITY_PORT = "AmmoConsumerEntity";
9  static const string MAGAZINE_WELL_TYPE_PORT = "MagazineWellType";
10 
11  ref SCR_BTParam<IEntity> m_AmmoConsumer = new SCR_BTParam<IEntity>(AMMO_CONSUMER_ENTITY_PORT);
12  ref SCR_BTParam<typename> m_MagazineWellType = new SCR_BTParam<typename>(MAGAZINE_WELL_TYPE_PORT);
13 
14  ref SCR_AIMoveIndividuallyBehavior m_MoveBehavior;
15 
16  //------------------------------------------------------------------------------------------------------------------------------------
17  void SCR_AIProvideAmmoBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity,
18  IEntity ammoConsumer, typename magazineWellType, float priorityLevel = PRIORITY_LEVEL_NORMAL)
19  {
20  SetPriority(SCR_AIActionBase.PRIORITY_BEHAVIOR_PROVIDE_AMMO);
21  m_fPriorityLevel.m_Value = priorityLevel;
22  m_sBehaviorTree = "{ADA6E7C5BC3C8C8D}AI/BehaviorTrees/Chimera/Soldier/ProvideAmmo.bt";
23 
24  m_AmmoConsumer.Init(this, ammoConsumer);
25  m_MagazineWellType.Init(this, magazineWellType);
26 
27  if (!utility)
28  return;
29 
30  float movePriority = GetPriority() + 0.1;
31  m_MoveBehavior = new SCR_AIMoveIndividuallyBehavior(utility, groupActivity, vector.Zero, priority : movePriority, priorityLevel: priorityLevel, ent: ammoConsumer, radius: 30.0);
32  utility.AddAction(m_MoveBehavior);
33  }
34 
35  //------------------------------------------------------------------------------------------------------------------------------------
36  override float CustomEvaluate()
37  {
38  // Fail is our ammo consumer is not alive any more
39  if(!SCR_AIDamageHandling.IsAlive(m_AmmoConsumer.m_Value))
40  {
41  Fail();
42  if (m_MoveBehavior)
43  m_MoveBehavior.Fail();
44  return 0;
45  }
46 
47  return GetPriority();
48  }
49 
50  //------------------------------------------------------------------------------------------------------------------------------------
51  override void OnActionCompleted()
52  {
53  super.OnActionCompleted();
54  if (m_MoveBehavior)
55  m_MoveBehavior.Complete();
56  }
57 
58  //------------------------------------------------------------------------------------------------------------------------------------
59  override void OnActionFailed()
60  {
61  super.OnActionFailed();
62  if (m_MoveBehavior)
63  m_MoveBehavior.Fail();
64  }
65 }
66 
67 class SCR_AIGetProvideAmmoBehaviorParameters : SCR_AIGetActionParameters
68 {
69  static ref TStringArray s_aVarsOut = (new SCR_AIProvideAmmoBehavior(null, null, null, BaseMagazineWell)).GetPortNames();
70  override TStringArray GetVariablesOut() { return s_aVarsOut; }
71 
72  override bool VisibleInPalette() { return true; }
73 };
SCR_AIDamageHandling
Definition: SCR_AIUtils.c:246
m_MagazineWellType
m_MagazineWellType
Definition: SCR_AIMessage.c:478
VisibleInPalette
override bool VisibleInPalette()
Definition: SCR_AIProvideAmmoBehavior.c:72
SCR_AIActionBase
Definition: SCR_AIAction.c:1
SCR_AIProvideAmmoBehavior
Definition: SCR_AIProvideAmmoBehavior.c:4
m_fPriorityLevel
float m_fPriorityLevel
Definition: SendGoalMessage.c:3
SCR_AIActivityBase
Definition: SCR_AIActivity.c:1
GetPriority
int GetPriority()
Definition: SCR_BaseManualCameraComponent.c:107
BaseMagazineWell
Definition: BaseMagazineWell.c:12
GetVariablesOut
override TStringArray GetVariablesOut()
Definition: SCR_AIProvideAmmoBehavior.c:70
SCR_AIMoveIndividuallyBehavior
Definition: SCR_AIMoveBehavior.c:30
SCR_AIGetActionParameters
Definition: SCR_AIGetActionParameters.c:22
SCR_AIBehaviorBase
Definition: SCR_AIBehavior.c:1
s_aVarsOut
SCR_AIProvideAmmoBehavior s_aVarsOut