Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIDecoBallisticPath.c
Go to the documentation of this file.
2{
3 // Inputs
4 protected static const string PORT_DISTANCE_COMPENSATION = "DistanceCompensation";
5 protected static const string PORT_TARGET_POSITION = "TargetPos";
6
7 protected ref TraceParam m_TraceParam;
8
9#ifdef WORKBENCH
10 protected ref array<ref Shape> m_aDebugShapes = {};
11#endif
12
13 //--------------------------------------------------------------------------------
14 //override void OnInit(AIAgent owner) { }
15
16 //--------------------------------------------------------------------------------
17 override bool TestFunction(AIAgent owner)
18 {
19 SCR_ChimeraCharacter myCharacter = SCR_ChimeraCharacter.Cast(owner.GetControlledEntity());
20 if (!myCharacter)
21 return false;
22
23 vector targetPos;
25
26 vector distanceCompensation;
27 GetVariableIn(PORT_DISTANCE_COMPENSATION, distanceCompensation);
28
29 vector traceFrom = myCharacter.EyePosition(); // todo For now it only works for character, and not for turrets!
30 vector targetPosCompensated = targetPos + distanceCompensation;
31 vector traceTo = 0.5*(traceFrom + targetPosCompensated);
32
33
34 if (!m_TraceParam)
36
37 m_TraceParam.Start = traceFrom;
38 m_TraceParam.End = traceTo;
39 m_TraceParam.Exclude = myCharacter;
40 m_TraceParam.LayerMask = EPhysicsLayerDefs.Projectile;
41 m_TraceParam.Flags = TraceFlags.ENTS | TraceFlags.OCEAN | TraceFlags.WORLD | TraceFlags.ANY_CONTACT;
42
43 float traceResult = GetGame().GetWorld().TraceMove(m_TraceParam, null);
44 bool traceHit = traceResult != 1.0;
45
46#ifdef WORKBENCH
47 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_DEBUG_SHAPES))
48 {
49 m_aDebugShapes.Clear();
50
51 int lineColor;
52 if (!traceHit)
53 lineColor = Color.GREEN;
54 else
55 lineColor = Color.RED;
56
57 vector lineVerts[2];
58 lineVerts[0] = m_TraceParam.Start;
59 lineVerts[1] = m_TraceParam.End;
60 Shape lineShape = Shape.CreateLines(lineColor, ShapeFlags.DEFAULT, lineVerts, 2);
61 m_aDebugShapes.Insert(lineShape);
62
63 if (traceHit)
64 {
65 vector hitPos = m_TraceParam.Start + traceResult * (m_TraceParam.End - m_TraceParam.Start);
66 Shape sphereShape = Shape.CreateSphere(Color.RED, ShapeFlags.DEFAULT, hitPos, 0.2);
67 m_aDebugShapes.Insert(sphereShape);
68 }
69 }
70#endif
71
72 return !traceHit;
73 }
74
75 //--------------------------------------------------------------------------------
76 static override string GetOnHoverDescription() { return "Estimates if projectile ballistic path can reach destination. It is performance heavy, use with some timer."; }
77 static override bool VisibleInPalette() { return true; }
78
80 override TStringArray GetVariablesIn() { return s_aVarsIn; }
81}
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ArmaReforgerScripted GetGame()
Definition game.c:1398
Definition Color.c:13
Diagnostic and developer menu system.
Definition DiagMenu.c:18
proto bool GetVariableIn(string name, out void val)
static ref TStringArray s_aVarsIn
static const string PORT_DISTANCE_COMPENSATION
override TStringArray GetVariablesIn()
static const string PORT_TARGET_POSITION
override bool TestFunction(AIAgent owner)
static override bool VisibleInPalette()
static override string GetOnHoverDescription()
Instance of created debug visualizer.
Definition Shape.c:14
ShapeFlags
Definition ShapeFlags.c:13
array< string > TStringArray
Definition Types.c:385
TraceFlags
Definition TraceFlags.c:13