Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIThrowGrenadeToBehavior.c
Go to the documentation of this file.
1class SCR_AIThrowGrenadeToBehavior : SCR_AIBehaviorBase
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 //---------------------------------------------------------------------------------------------------------------------------------
18 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)
19 {
20 m_vTargetPosition.Init(this, position);
21 e_WeaponType.Init(this, weaponType);
22 m_fDelay.Init(this, delay);
23
24 if (utility)
25 {
26 m_World = utility.m_OwnerEntity.GetWorld();
27 m_fStartTime = m_World.GetWorldTime() + delay;
28 }
29
30 m_sBehaviorTree = "{3187CAE77AAF1A35}AI/BehaviorTrees/Chimera/Soldier/ThrowGrenadeTo.bt";
31 SetPriority(priority);
32 m_fPriorityLevel.m_Value = priorityLevel;
33 m_bAllowLook = false;
34
35#ifdef WORKBENCH
36 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_GRENADE_POSITIONS))
37 DrawPositionDebug(false);
38#endif
39 }
40
41 //---------------------------------------------------------------------------------------------------------------------------------
42 override int GetCause()
43 {
44 return SCR_EAIBehaviorCause.COMBAT;
45 }
46
47 //------------------------------------------------------------------------------------------------------------------------------------
48 override float CustomEvaluate()
49 {
50 if (m_World && m_World.GetWorldTime() < m_fStartTime)
51 return 0;
52
53 return GetPriority();
54 }
55
56 //----------------------------------------------------------------------------------
57 override void OnActionSelected()
58 {
59 m_Utility.m_AIInfo.SetAIState(EUnitAIState.BUSY);
60
61#ifdef WORKBENCH
62 m_aDbgShapes.Clear();
63 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_GRENADE_POSITIONS))
64 DrawPositionDebug(true);
65#endif
66 }
67
68 //----------------------------------------------------------------------------------
69 override void OnActionCompleted()
70 {
71 super.OnActionCompleted();
72 m_Utility.m_AIInfo.SetAIState(EUnitAIState.AVAILABLE);
73#ifdef WORKBENCH
74 SCR_AIDebugVisualization.VisualizeMessage(m_Utility.m_OwnerEntity, "Grenade thrown", EAIDebugCategory.INFO, 5);
75 m_aDbgShapes.Clear();
76#endif
77 }
78
79 //----------------------------------------------------------------------------------
80 override void OnActionFailed()
81 {
82 super.OnActionFailed();
83 m_Utility.m_AIInfo.SetAIState(EUnitAIState.AVAILABLE);
84#ifdef WORKBENCH
85 SCR_AIDebugVisualization.VisualizeMessage(m_Utility.m_OwnerEntity, "Grenade throw failed", EAIDebugCategory.INFO, 5);
86 m_aDbgShapes.Clear();
87#endif
88 }
89
90 //----------------------------------------------------------------------------------
91 override string GetActionDebugInfo()
92 {
93 return this.ToString() + " throwing grenade to " + m_vTargetPosition.m_Value.ToString();
94 }
95
96 //------------------------------------------------------------------------------------------------------------------------------------
97 void DrawPositionDebug(bool selected)
98 {
99 int shapeColor = Color.RED;
100 if (selected)
101 shapeColor = Color.GREEN;
102#ifdef WORKBENCH
103 m_aDbgShapes.Insert(Shape.CreateCylinder(Color.WHITE, ShapeFlags.DEFAULT, m_vTargetPosition.m_Value, 0.3, 100));
104 m_aDbgShapes.Insert(Shape.CreateSphere(shapeColor, ShapeFlags.DEFAULT, m_vTargetPosition.m_Value, 0.6));
105#endif
106 }
107};
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ref SCR_BTParam< float > m_fPriorityLevel
void OnActionCompleted()
enum EAIActionFailReason PRIORITY_LEVEL_NORMAL
ResourceName m_sBehaviorTree
override void OnActionSelected()
void OnActionFailed()
string GetActionDebugInfo()
int GetCause()
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
enum SCR_EAIActivityCause m_Utility
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
SCR_EAIBehaviorCause
bool m_bAllowLook
override float CustomEvaluate()
EAIDebugCategory
Definition SCR_AIWorld.c:12
vector position
Definition Color.c:13
Diagnostic and developer menu system.
Definition DiagMenu.c:18
static void VisualizeMessage(IEntity entity, string message, EAIDebugCategory category, float showTime, Color color=Color.White, float fontSize=16, bool ignoreCategory=false)
Instance of created debug visualizer.
Definition Shape.c:14
ShapeFlags
Definition ShapeFlags.c:13
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
EWeaponType
Definition EWeaponType.c:13