Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_AIDecoBallisticPath.c
Go to the documentation of this file.
1
class
SCR_AIDecoBallisticPath
:
DecoratorScripted
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;
24
GetVariableIn
(
PORT_TARGET_POSITION
, 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
)
35
m_TraceParam
=
new
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
79
protected
static
ref
TStringArray
s_aVarsIn
= {
PORT_DISTANCE_COMPENSATION
,
PORT_TARGET_POSITION
};
80
override
TStringArray
GetVariablesIn
() {
return
s_aVarsIn
; }
81
}
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition
DebugMenuID.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
Color
Definition
Color.c:13
DecoratorScripted
Definition
DecoratorScripted.c:13
DiagMenu
Diagnostic and developer menu system.
Definition
DiagMenu.c:18
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
SCR_AIDecoBallisticPath
Definition
SCR_AIDecoBallisticPath.c:2
SCR_AIDecoBallisticPath::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AIDecoBallisticPath.c:79
SCR_AIDecoBallisticPath::PORT_DISTANCE_COMPENSATION
static const string PORT_DISTANCE_COMPENSATION
Definition
SCR_AIDecoBallisticPath.c:4
SCR_AIDecoBallisticPath::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AIDecoBallisticPath.c:80
SCR_AIDecoBallisticPath::PORT_TARGET_POSITION
static const string PORT_TARGET_POSITION
Definition
SCR_AIDecoBallisticPath.c:5
SCR_AIDecoBallisticPath::TestFunction
override bool TestFunction(AIAgent owner)
Definition
SCR_AIDecoBallisticPath.c:17
SCR_AIDecoBallisticPath::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIDecoBallisticPath.c:77
SCR_AIDecoBallisticPath::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AIDecoBallisticPath.c:76
SCR_AIDecoBallisticPath::m_TraceParam
ref TraceParam m_TraceParam
Definition
SCR_AIDecoBallisticPath.c:7
Shape
Instance of created debug visualizer.
Definition
Shape.c:14
TraceParam
Definition
TraceParam.c:16
vector
Definition
vector.c:13
ShapeFlags
ShapeFlags
Definition
ShapeFlags.c:13
TStringArray
array< string > TStringArray
Definition
Types.c:385
TraceFlags
TraceFlags
Definition
TraceFlags.c:13
scripts
Game
AI
ScriptedNodes
Weapons
SCR_AIDecoBallisticPath.c
Generated by
1.17.0