Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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
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 int GetCause()
37 {
38 return SCR_EAIBehaviorCause.GROUP_GOAL;
39 }
40
41 //------------------------------------------------------------------------------------------------------------------------------------
42 override float CustomEvaluate()
43 {
44 // Fail is our ammo consumer is not alive any more
45 if(!SCR_AIDamageHandling.IsAlive(m_AmmoConsumer.m_Value))
46 {
47 Fail();
49 m_MoveBehavior.Fail();
50 return 0;
51 }
52
53 return GetPriority();
54 }
55
56 //------------------------------------------------------------------------------------------------------------------------------------
57 override void OnActionCompleted()
58 {
59 super.OnActionCompleted();
61 m_MoveBehavior.Complete();
62 }
63
64 //------------------------------------------------------------------------------------------------------------------------------------
65 override void OnActionFailed()
66 {
67 super.OnActionFailed();
69 m_MoveBehavior.Fail();
70 }
71}
72
73class SCR_AIGetProvideAmmoBehaviorParameters : SCR_AIGetActionParameters
74{
75 static ref TStringArray s_aVarsOut = (new SCR_AIProvideAmmoBehavior(null, null, null, BaseMagazineWell)).GetPortNames();
76 override TStringArray GetVariablesOut() { return s_aVarsOut; }
77
78 static override bool VisibleInPalette() { return true; }
79};
ref SCR_BTParam< float > m_fPriorityLevel
enum EAIActionFailReason PRIORITY_LEVEL_NORMAL
TStringArray GetPortNames()
ResourceName m_sBehaviorTree
void Fail(bool doNotCompleteWaypoint)
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
SCR_EAIBehaviorCause
override TStringArray GetVariablesOut()
static override bool VisibleInPalette()
ref SCR_AIMoveIndividuallyBehavior m_MoveBehavior
ref SCR_BTParam< IEntity > m_AmmoConsumer
static const string AMMO_CONSUMER_ENTITY_PORT
static const string MAGAZINE_WELL_TYPE_PORT
void SCR_AIProvideAmmoBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity ammoConsumer, typename magazineWellType, float priorityLevel=PRIORITY_LEVEL_NORMAL)
ref SCR_BTParam< typename > m_MagazineWellType
array< string > TStringArray
Definition Types.c:385