Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIThrowGrenadeToBehavior.c
Go to the documentation of this file.
2 {
3  //Target Position of the behavior
4  ref SCR_BTParam<vector> m_vTargetPosition = new SCR_BTParam<vector>(SCR_AIActionTask.TARGETPOSITION_PORT);
5  ref SCR_BTParam<EWeaponType> e_WeaponType = new SCR_BTParam<EWeaponType>(SCR_AIActionTask.WEAPON_TYPE_PORT);
6  ref SCR_BTParam<float> m_fDelay = new SCR_BTParam<float>(SCR_AIActionTask.DELAY_PORT);
7 
8  BaseWorld m_World;
9  float m_fStartTime;
10 
11 #ifdef WORKBENCH
12  //Diagnostic visualization
13  ref array<ref Shape> m_aDbgShapes = {};
14 #endif
15  private static vector CHARACTER_HEIGHT_OFFSET = {0, 1.6, 0};
16 
17  void SCR_AIThrowGrenadeToBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, vector position, EWeaponType weaponType, float delay, float priority = PRIORITY_BEHAVIOR_THROW_GRENADE, float priorityLevel = PRIORITY_LEVEL_NORMAL)
18  {
19  m_vTargetPosition.Init(this, position);
20  e_WeaponType.Init(this, weaponType);
21  m_fDelay.Init(this, delay);
22 
23  if (utility)
24  {
25  m_World = utility.m_OwnerEntity.GetWorld();
26  m_fStartTime = m_World.GetWorldTime() + delay;
27  }
28 
29  m_sBehaviorTree = "{3187CAE77AAF1A35}AI/BehaviorTrees/Chimera/Soldier/ThrowGrenadeTo.bt";
30  SetPriority(priority);
31  m_fPriorityLevel.m_Value = priorityLevel;
32  m_bAllowLook = false;
33 
34 #ifdef WORKBENCH
35  if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_SMOKE_COVER_POSITIONS))
36  DrawPositionDebug(false);
37 #endif
38  }
39 
40  //------------------------------------------------------------------------------------------------------------------------------------
41  override float CustomEvaluate()
42  {
43  if (m_World && m_World.GetWorldTime() < m_fStartTime)
44  return 0;
45 
46  return GetPriority();
47  }
48 
49  //----------------------------------------------------------------------------------
50  override void OnActionSelected()
51  {
52  m_Utility.m_AIInfo.SetAIState(EUnitAIState.BUSY);
53 
54 #ifdef WORKBENCH
55  m_aDbgShapes.Clear();
56  if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_SMOKE_COVER_POSITIONS))
57  DrawPositionDebug(true);
58 #endif
59  }
60 
61  //----------------------------------------------------------------------------------
62  override void OnActionCompleted()
63  {
64  super.OnActionCompleted();
65  m_Utility.m_AIInfo.SetAIState(EUnitAIState.AVAILABLE);
66 #ifdef WORKBENCH
67  SCR_AIDebugVisualization.VisualizeMessage(m_Utility.m_OwnerEntity, "Grenade thrown", EAIDebugCategory.INFO, 5);
68  m_aDbgShapes.Clear();
69 #endif
70  }
71 
72  //----------------------------------------------------------------------------------
73  override void OnActionFailed()
74  {
75  super.OnActionFailed();
76  m_Utility.m_AIInfo.SetAIState(EUnitAIState.AVAILABLE);
77 #ifdef WORKBENCH
78  SCR_AIDebugVisualization.VisualizeMessage(m_Utility.m_OwnerEntity, "Grenade throw failed", EAIDebugCategory.INFO, 5);
79  m_aDbgShapes.Clear();
80 #endif
81  }
82 
83  //----------------------------------------------------------------------------------
84  override string GetActionDebugInfo()
85  {
86  return this.ToString() + " throwing grenade to " + m_vTargetPosition.ValueToString();
87  }
88 
89  //------------------------------------------------------------------------------------------------------------------------------------
90  void DrawPositionDebug(bool selected)
91  {
92  int shapeColor = Color.RED;
93  if (selected)
94  shapeColor = Color.GREEN;
95 #ifdef WORKBENCH
96  m_aDbgShapes.Insert(Shape.CreateCylinder(Color.WHITE, ShapeFlags.DEFAULT, m_vTargetPosition.m_Value, 0.3, 100));
97  m_aDbgShapes.Insert(Shape.CreateSphere(shapeColor, ShapeFlags.DEFAULT, m_vTargetPosition.m_Value, 0.6));
98 #endif
99  }
100 };
SCR_AIDebugVisualization
Definition: SCR_AIDebugVisualization.c:9
SCR_AIThrowGrenadeToBehavior
Definition: SCR_AIThrowGrenadeToBehavior.c:1
m_fDelay
protected float m_fDelay
Definition: SCR_TooltipManagerEditorUIComponent.c:8
m_fPriorityLevel
float m_fPriorityLevel
Definition: SendGoalMessage.c:3
SCR_AIActivityBase
Definition: SCR_AIActivity.c:1
GetPriority
int GetPriority()
Definition: SCR_BaseManualCameraComponent.c:107
EAIDebugCategory
EAIDebugCategory
Definition: SCR_AIWorld.c:11
m_World
protected BaseWorld m_World
Definition: SCR_PreviewEntityEditorUIComponent.c:46
EWeaponType
EWeaponType
Definition: EWeaponType.c:12
SCR_AIActionTask
Definition: SCR_AIBehaviorTask.c:1
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
SCR_AIBehaviorBase
Definition: SCR_AIBehavior.c:1