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_AIGetPosForwardToTarget.c
Go to the documentation of this file.
1
class
SCR_AIGetPosForwardToTarget
:
AITaskScripted
2
{
3
static
const
string
PORT_DISTANCE =
"Distance"
;
4
static
const
string
PORT_RESULT_VECTOR =
"ResultVector"
;
5
static
const
string
PORT_TARGET =
"Target"
;
6
7
[
Attribute
(
"10"
,
UIWidgets
.EditBox, PORT_DISTANCE)]
8
float
m_Distance;
9
10
protected
vector
m_ResultVector
;
11
protected
IEntity
m_Target
;
12
protected
vector
m_vPosition
;
13
14
//------------------------------------------------------------------------------------------------
15
override
void
OnInit
(AIAgent owner)
16
{
17
if
(
GetVariableType
(
false
, PORT_RESULT_VECTOR) !=
vector
)
18
{
19
NodeError
(
this
, owner, PORT_RESULT_VECTOR +
" should be vector"
);
20
}
21
22
if
(
GetVariableIn
(PORT_DISTANCE, m_Distance) && (
GetVariableType
(
true
, PORT_DISTANCE) !=
int
&&
GetVariableType
(
true
, PORT_DISTANCE) !=
float
) )
23
{
24
NodeError
(
this
, owner, PORT_DISTANCE +
" type should be number"
);
25
}
26
27
if
(
GetVariableType
(
true
, PORT_TARGET) !=
vector
&&
GetVariableType
(
true
, PORT_TARGET) !=
IEntity
)
28
{
29
NodeError
(
this
, owner, PORT_TARGET +
" should be IEntity or vector"
);
30
}
31
}
32
33
//------------------------------------------------------------------------------------------------
34
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
35
{
36
IEntity
controlledEntity = owner.GetControlledEntity();
37
if
(
GetVariableType
(
true
, PORT_TARGET) ==
vector
)
38
{
39
GetVariableIn
(PORT_TARGET,
m_vPosition
);
40
}
41
else
if
(
GetVariableType
(
true
, PORT_TARGET) ==
IEntity
)
42
{
43
GetVariableIn
(PORT_TARGET,
m_Target
);
44
if
(!
m_Target
)
45
return
ENodeResult
.FAIL;
46
47
if
(
m_Target
== owner ||
m_Target
== controlledEntity)
48
return
NodeError
(
this
, owner, PORT_TARGET +
" can't be the same as owner entity"
);
49
}
50
51
if
(
GetVariableType
(
true
, PORT_DISTANCE) ==
int
)
52
{
53
int
distance
;
54
GetVariableIn
(PORT_DISTANCE,
distance
);
55
m_Distance =
distance
;
56
}
57
else
if
(
GetVariableType
(
true
, PORT_DISTANCE) ==
float
)
58
{
59
GetVariableIn
(PORT_DISTANCE, m_Distance);
60
}
61
62
63
vector
ownerPos = controlledEntity.
GetOrigin
();
64
65
vector
pos =
m_vPosition
;
66
if
(
m_Target
)
67
pos =
m_Target
.GetOrigin();
68
69
vector
direction
=
vector
.Direction(ownerPos, pos).Normalized();
70
vector
forwardVector = ownerPos + (
direction
* m_Distance );
71
// snap the vector on ground, for valid location to run to
72
forwardVector[1] = controlledEntity.
GetWorld
().GetSurfaceY(forwardVector[0], forwardVector[2]);
73
74
m_ResultVector
= forwardVector;
75
76
SetVariableOut
(PORT_RESULT_VECTOR,
m_ResultVector
);
77
78
//DrawDebug();
79
80
return
ENodeResult
.SUCCESS;
81
}
82
83
//------------------------------------------------------------------------------------------------
84
protected
static
override
string
GetOnHoverDescription
()
85
{
86
return
"It will return world position in direction to target away from owner position. Doesn't take navmesh in account. Target can be entity or vector."
;
87
}
88
89
//------------------------------------------------------------------------------------------------
90
void
DrawDebug
()
91
{
92
int
color =
ARGB
(255, 255, 64, 64);
93
94
Shape
dbgShape =
Shape
.CreateSphere(color,
ShapeFlags
.TRANSP |
ShapeFlags
.DOUBLESIDE |
ShapeFlags
.NOZWRITE |
ShapeFlags
.ONCE |
ShapeFlags
.NOOUTLINE,
vector
.Zero, 1.0);
95
96
vector
mat[4];
97
Math3D
.MatrixIdentity4(mat);
98
mat[3] =
m_ResultVector
;
99
dbgShape.SetMatrix(mat);
100
}
101
102
//------------------------------------------------------------------------------------------------
103
static
override
bool
VisibleInPalette
()
104
{
105
return
true
;
106
}
107
108
//------------------------------------------------------------------------------------------------
109
protected
static
ref
TStringArray
s_aVarsIn
= {
110
PORT_TARGET,
111
PORT_DISTANCE
112
};
113
override
TStringArray
GetVariablesIn
()
114
{
115
return
s_aVarsIn
;
116
}
117
118
//------------------------------------------------------------------------------------------------
119
protected
static
ref
TStringArray
s_aVarsOut
= {
120
PORT_RESULT_VECTOR
121
};
122
override
TStringArray
GetVariablesOut
()
123
{
124
return
s_aVarsOut
;
125
}
126
};
NodeError
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition
NodeError.c:3
distance
float distance
Definition
SCR_DestructibleTreeV2.c:29
direction
vector direction
Definition
SCR_DestructibleTreeV2.c:31
AITaskScripted
Definition
AITaskScripted.c:13
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetWorld
proto external BaseWorld GetWorld()
Math3D
Definition
Math3D.c:13
Node::SetVariableOut
proto void SetVariableOut(string name, void val)
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
Node::GetVariableType
proto external GetVariableType(bool inputPort, string name)
SCR_AIGetPosForwardToTarget
Definition
SCR_AIGetPosForwardToTarget.c:2
SCR_AIGetPosForwardToTarget::DrawDebug
void DrawDebug()
Definition
SCR_AIGetPosForwardToTarget.c:90
SCR_AIGetPosForwardToTarget::GetVariablesOut
override TStringArray GetVariablesOut()
Definition
SCR_AIGetPosForwardToTarget.c:122
SCR_AIGetPosForwardToTarget::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AIGetPosForwardToTarget.c:84
SCR_AIGetPosForwardToTarget::m_Target
IEntity m_Target
Definition
SCR_AIGetPosForwardToTarget.c:11
SCR_AIGetPosForwardToTarget::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AIGetPosForwardToTarget.c:109
SCR_AIGetPosForwardToTarget::s_aVarsOut
static ref TStringArray s_aVarsOut
Definition
SCR_AIGetPosForwardToTarget.c:119
SCR_AIGetPosForwardToTarget::m_vPosition
vector m_vPosition
Definition
SCR_AIGetPosForwardToTarget.c:12
SCR_AIGetPosForwardToTarget::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AIGetPosForwardToTarget.c:113
SCR_AIGetPosForwardToTarget::OnInit
override void OnInit(AIAgent owner)
Definition
SCR_AIGetPosForwardToTarget.c:15
SCR_AIGetPosForwardToTarget::m_ResultVector
vector m_ResultVector
Definition
SCR_AIGetPosForwardToTarget.c:10
SCR_AIGetPosForwardToTarget::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AIGetPosForwardToTarget.c:34
SCR_AIGetPosForwardToTarget::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIGetPosForwardToTarget.c:103
Shape
Instance of created debug visualizer.
Definition
Shape.c:14
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
ShapeFlags
ShapeFlags
Definition
ShapeFlags.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
TStringArray
array< string > TStringArray
Definition
Types.c:385
ARGB
proto int ARGB(int a, int r, int g, int b)
scripts
Game
AI
ScriptedNodes
Utils
SCR_AIGetPosForwardToTarget.c
Generated by
1.17.0