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_AIDecoDistanceHysteresis.c
Go to the documentation of this file.
1
// if you want this node to abort subtree when conditions change, you must specify abort condition!
2
// normal mode: smaller than low distance -> Condition TRUE
3
// negate mode: bigger than high distance -> Condition TRUE
4
class
SCR_AIDecoDistanceHysteresis
:
DecoratorScripted
5
{
6
static
const
string
PORT_ENTITY_IN =
"EntityIn"
;
7
static
const
string
PORT_POSITION_IN =
"PositionIn"
;
8
9
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Low boundary distance"
)]
10
private
float
m_lowBoundary;
11
12
[
Attribute
(
""
,
UIWidgets
.EditBox,
"High boundary distance"
)]
13
private
float
m_highBoundary;
14
15
private
bool
m_lastValueOfGate =
false
;
16
17
/*
18
//------------------------------------------------------------------------------------------------
19
override void OnInit(AIAgent owner)
20
{
21
// make sure it works when uncomenting
22
23
if (GetVariableType(true, PORT_POSITION_IN) == vector || GetVariableType(true, PORT_ENTITY_IN) == IEntity)
24
{
25
NodeError(this, owner, PORT_POSITION_IN + "(vector) or " + PORT_ENTITY_IN + "(IEntity) has to be provided");
26
}
27
28
//TODO uncoment OnInit
29
}
30
*/
31
32
//------------------------------------------------------------------------------------------------
33
protected
override
bool
TestFunction
(AIAgent owner)
34
{
35
vector
ownerPos,destinationPos;
36
IEntity
entity;
37
bool
openGate =
false
;
38
39
AIGroup ownerIsGroup = AIGroup.Cast(owner);
40
if
(ownerIsGroup)
41
ownerPos = ownerIsGroup.GetLeaderEntity().GetOrigin();
42
else
43
ownerPos = owner.GetControlledEntity().GetOrigin();
44
45
46
if
(!
GetVariableIn
(PORT_ENTITY_IN, entity))
47
{
48
if
(!
GetVariableIn
(PORT_POSITION_IN,destinationPos))
49
return
false
;
50
}
51
else
if
(!entity)
52
return
false
;
53
else
54
destinationPos = entity.
GetOrigin
();
55
56
float
dist =
vector
.Distance(destinationPos, ownerPos);
57
if
( dist < m_lowBoundary)
58
{
59
openGate =
true
;
60
m_lastValueOfGate = openGate;
61
}
62
else
if
( dist > m_highBoundary)
63
{
64
openGate =
false
;
65
m_lastValueOfGate = openGate;
66
}
67
else
68
{
69
openGate = m_lastValueOfGate;
70
}
71
72
return
openGate;
73
}
74
75
//------------------------------------------------------------------------------------------------
76
protected
static
override
bool
VisibleInPalette
()
77
{
78
return
true
;
79
}
80
81
//------------------------------------------------------------------------------------------------
82
protected
static
override
string
GetOnHoverDescription
()
83
{
84
return
"SCR_AIDecoDistanceHysteresis: Checks distance to entity within boundaries and in circumference it returns value according to history of moving"
;
85
}
86
87
//------------------------------------------------------------------------------------------------
88
protected
static
ref
TStringArray
s_aVarsIn
= {
89
PORT_ENTITY_IN,
90
PORT_POSITION_IN
91
};
92
protected
override
TStringArray
GetVariablesIn
()
93
{
94
return
s_aVarsIn
;
95
}
96
97
//------------------------------------------------------------------------------------------------
98
protected
override
string
GetNodeMiddleText
()
99
{
100
return
"Low boundary: "
+ m_lowBoundary.ToString() +
"\n"
+
"High boundary: "
+ m_highBoundary.ToString();
101
}
102
};
DecoratorScripted
Definition
DecoratorScripted.c:13
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
SCR_AIDecoDistanceHysteresis
Definition
SCR_AIDecoDistanceHysteresis.c:5
SCR_AIDecoDistanceHysteresis::TestFunction
override bool TestFunction(AIAgent owner)
Definition
SCR_AIDecoDistanceHysteresis.c:33
SCR_AIDecoDistanceHysteresis::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIDecoDistanceHysteresis.c:76
SCR_AIDecoDistanceHysteresis::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AIDecoDistanceHysteresis.c:82
SCR_AIDecoDistanceHysteresis::GetNodeMiddleText
override string GetNodeMiddleText()
Definition
SCR_AIDecoDistanceHysteresis.c:98
SCR_AIDecoDistanceHysteresis::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AIDecoDistanceHysteresis.c:88
SCR_AIDecoDistanceHysteresis::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AIDecoDistanceHysteresis.c:92
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
TStringArray
array< string > TStringArray
Definition
Types.c:385
scripts
Game
AI
ScriptedNodes
Logical
SCR_AIDecoDistanceHysteresis.c
Generated by
1.17.0