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_AIGetSidePosition.c
Go to the documentation of this file.
1
class
SCR_AIGetSidePosition
:
AITaskScripted
2
{
3
static
const
string
PORT_ENEMY =
"Enemy"
;
4
static
const
string
PORT_ENEMY_POSITION =
"EnemyPosition"
;
5
static
const
string
PORT_KEEP_SIDE =
"KeepSide"
;
6
static
const
string
PORT_POSITION =
"PositionOut"
;
7
8
9
[
Attribute
(
"4"
,
UIWidgets
.EditBox,
"Distance from origin"
)]
10
private
float
m_fDistance;
11
12
private
int
m_iSide = 0;
13
private
IEntity
m_OwnerEntity;
14
15
//------------------------------------------------------------------------------------------------
16
override
void
OnEnter(AIAgent owner)
17
{
18
if
(
GetVariableType
(
false
, PORT_POSITION) !=
vector
)
19
{
20
NodeError
(
this
, owner, PORT_POSITION +
" has to be vector"
);
21
}
22
m_OwnerEntity = owner.GetControlledEntity();
23
if
(!m_OwnerEntity)
24
{
25
NodeError
(
this
, owner,
"Owner must be a character!"
);
26
}
27
}
28
29
//------------------------------------------------------------------------------------------------
30
override
ENodeResult
EOnTaskSimulate(AIAgent owner,
float
dt)
31
{
32
vector
direction
, enemyPos, origin = m_OwnerEntity.GetOrigin();
33
IEntity
enemy
;
34
bool
keepSide;
35
if
(!
GetVariableIn
(PORT_KEEP_SIDE, keepSide) || !keepSide)
// if parameter keepSide == true, it will not change side from previous run
36
m_iSide =
Math
.RandomInt(0,2);
37
// get direction of enemy
38
if
(
GetVariableIn
(PORT_ENEMY,
enemy
))
39
{
40
direction
=
vector
.Direction(
enemy
.GetOrigin(), origin);
41
direction
.Normalize();
42
}
43
else
if
(
GetVariableIn
(PORT_ENEMY_POSITION, enemyPos))
44
{
45
direction
=
vector
.Direction(enemyPos, origin);
46
direction
.Normalize();
47
48
}
49
else
50
direction
= m_OwnerEntity.GetYawPitchRoll().AnglesToVector();
// gets normalized forward vector of m_OwnerEntity
51
52
// make perpendicular vector
53
if
(m_iSide == 0)
54
{
55
float
x =
direction
[0];
56
direction
[0] =
direction
[2];
57
direction
[2] = -x;
58
}
59
else
60
{
61
float
x =
direction
[0];
62
direction
[0] = -
direction
[2];
63
direction
[2] = x;
64
}
65
66
origin +=
direction
* m_fDistance;
67
68
SetVariableOut
(PORT_POSITION, origin);
69
70
return
ENodeResult
.SUCCESS;
71
}
72
73
//------------------------------------------------------------------------------------------------
74
static
override
bool
VisibleInPalette
()
75
{
76
return
true
;
77
}
78
79
//------------------------------------------------------------------------------------------------
80
static
override
protected
string
GetOnHoverDescription
()
81
{
82
return
"Returns position from owner entity that is either on random side of the direction towards enemy pos or the keeps the same side as previously if KeepSide is true"
;
83
}
84
85
//------------------------------------------------------------------------------------------------
86
protected
static
ref
TStringArray
s_aVarsIn
= {
87
PORT_ENEMY,
88
PORT_ENEMY_POSITION,
89
PORT_KEEP_SIDE
90
};
91
override
TStringArray
GetVariablesIn
()
92
{
93
return
s_aVarsIn
;
94
}
95
96
//------------------------------------------------------------------------------------------------
97
protected
static
ref
TStringArray
s_aVarsOut
= {
98
PORT_POSITION
99
};
100
override
TStringArray
GetVariablesOut
()
101
{
102
return
s_aVarsOut
;
103
}
104
};
NodeError
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition
NodeError.c:3
enemy
when task is activated by player or by killing enemy
Definition
SCR_AttackTaskEntity.c:12
direction
vector direction
Definition
SCR_DestructibleTreeV2.c:31
AITaskScripted
Definition
AITaskScripted.c:13
IEntity
Definition
IEntity.c:13
Math
Definition
Math.c:13
Node::SetVariableOut
proto void SetVariableOut(string name, void val)
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
Node::VisibleInPalette
bool VisibleInPalette()
Node::GetVariableType
proto external GetVariableType(bool inputPort, string name)
SCR_AIGetSidePosition
Definition
SCR_AIGetSidePosition.c:2
SCR_AIGetSidePosition::GetVariablesOut
override TStringArray GetVariablesOut()
Definition
SCR_AIGetSidePosition.c:100
SCR_AIGetSidePosition::GetOnHoverDescription
string GetOnHoverDescription()
Definition
SCR_AIGetSidePosition.c:80
SCR_AIGetSidePosition::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AIGetSidePosition.c:86
SCR_AIGetSidePosition::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AIGetSidePosition.c:91
SCR_AIGetSidePosition::s_aVarsOut
static ref TStringArray s_aVarsOut
Definition
SCR_AIGetSidePosition.c:97
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_AIGetSidePosition.c
Generated by
1.17.0