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_AIGetRandomPoint.c
Go to the documentation of this file.
1
class
SCR_AIGetRandomPoint
:
AITaskScripted
2
{
3
static
const
string
WAYPOINT_PORT =
"Waypoint"
;
4
static
const
string
ORIGIN_PORT =
"Origin"
;
5
static
const
string
RADIUS_PORT =
"Radius"
;
6
static
const
string
EXCLUSION_RADIUS_PORT =
"ExclusionRadius"
;
7
static
const
string
PORT_RESULT_VECTOR =
"ResultVector"
;
8
9
[
Attribute
(
"10"
,
UIWidgets
.EditBox,
"Radius around origin"
)]
10
protected
float
m_Radius
;
11
12
[
Attribute
(
"0"
,
UIWidgets
.EditBox,
"Exclusion radius around origin"
)]
13
protected
float
m_ExclusionRadius
;
14
15
//------------------------------------------------------------------------------------------------
16
override
void
OnEnter
(AIAgent owner)
17
{
18
if
(
GetVariableType
(
false
, PORT_RESULT_VECTOR) !=
vector
)
19
{
20
NodeError
(
this
, owner, PORT_RESULT_VECTOR +
" has to be vector"
);
21
}
22
23
if
(
GetVariableIn
(RADIUS_PORT,
m_Radius
) && (
GetVariableType
(
true
, RADIUS_PORT) !=
int
&&
GetVariableType
(
true
, RADIUS_PORT) !=
float
))
24
{
25
NodeError
(
this
, owner, RADIUS_PORT +
" type should be number"
);
26
}
27
}
28
29
//------------------------------------------------------------------------------------------------
30
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
31
{
32
vector
origin =
vector
.Zero;
33
IEntity
waypointEnt;
34
35
if
(
GetVariableIn
(WAYPOINT_PORT,waypointEnt))
36
{
37
AIWaypoint waypoint = AIWaypoint.Cast(waypointEnt);
38
if
(!waypoint)
39
{
40
NodeError
(
this
,owner, WAYPOINT_PORT +
" is null! or wrong type"
);
41
return
ENodeResult
.FAIL;
42
};
43
m_Radius
= waypoint.GetCompletionRadius();
44
origin = waypoint.GetOrigin();
45
}
46
else
47
{
48
if
(
GetVariableType
(
true
, RADIUS_PORT) ==
int
)
49
{
50
int
radius;
51
GetVariableIn
(RADIUS_PORT, radius);
52
m_Radius
= radius;
53
}
54
else
if
(
GetVariableType
(
true
, RADIUS_PORT) ==
float
)
55
{
56
GetVariableIn
(RADIUS_PORT,
m_Radius
);
57
}
58
59
if
(
GetVariableType
(
true
, ORIGIN_PORT) ==
vector
)
60
{
61
GetVariableIn
(ORIGIN_PORT, origin);
62
}
63
}
64
65
vector
result =
s_AIRandomGenerator
.GenerateRandomPointInRadius(
m_ExclusionRadius
,
m_Radius
, origin,
true
);
66
result[1] = origin[1];
67
SetVariableOut
(PORT_RESULT_VECTOR, result);
68
69
return
ENodeResult
.SUCCESS;
70
}
71
72
//------------------------------------------------------------------------------------------------
73
static
override
bool
VisibleInPalette
()
74
{
75
return
true
;
76
}
77
78
//------------------------------------------------------------------------------------------------
79
static
override
protected
string
GetOnHoverDescription
()
80
{
81
return
"Returns random position in circle (2D) from given point or within radius of a waypoint. When origin vector isn't present it will assume zero vector instead."
;
82
}
83
84
//------------------------------------------------------------------------------------------------
85
protected
static
ref
TStringArray
s_aVarsIn
= {
86
WAYPOINT_PORT,
87
ORIGIN_PORT,
88
RADIUS_PORT
89
};
90
override
TStringArray
GetVariablesIn
()
91
{
92
return
s_aVarsIn
;
93
}
94
95
//------------------------------------------------------------------------------------------------
96
protected
static
ref
TStringArray
s_aVarsOut
= {
97
PORT_RESULT_VECTOR
98
};
99
override
TStringArray
GetVariablesOut
()
100
{
101
return
s_aVarsOut
;
102
}
103
};
NodeError
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition
NodeError.c:3
s_AIRandomGenerator
class SCR_AINodePortsHelpers s_AIRandomGenerator
AITaskScripted
Definition
AITaskScripted.c:13
IEntity
Definition
IEntity.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_AIGetRandomPoint
Definition
SCR_AIGetRandomPoint.c:2
SCR_AIGetRandomPoint::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AIGetRandomPoint.c:30
SCR_AIGetRandomPoint::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIGetRandomPoint.c:73
SCR_AIGetRandomPoint::m_ExclusionRadius
float m_ExclusionRadius
Definition
SCR_AIGetRandomPoint.c:13
SCR_AIGetRandomPoint::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AIGetRandomPoint.c:90
SCR_AIGetRandomPoint::OnEnter
override void OnEnter(AIAgent owner)
Definition
SCR_AIGetRandomPoint.c:16
SCR_AIGetRandomPoint::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AIGetRandomPoint.c:85
SCR_AIGetRandomPoint::s_aVarsOut
static ref TStringArray s_aVarsOut
Definition
SCR_AIGetRandomPoint.c:96
SCR_AIGetRandomPoint::GetOnHoverDescription
string GetOnHoverDescription()
Definition
SCR_AIGetRandomPoint.c:79
SCR_AIGetRandomPoint::GetVariablesOut
override TStringArray GetVariablesOut()
Definition
SCR_AIGetRandomPoint.c:99
SCR_AIGetRandomPoint::m_Radius
float m_Radius
Definition
SCR_AIGetRandomPoint.c:10
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
TStringArray
array< string > TStringArray
Definition
Types.c:385
scripts
Game
AI
ScriptedNodes
Utils
SCR_AIGetRandomPoint.c
Generated by
1.17.0