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_AISelectDoorOperatorAgent.c
Go to the documentation of this file.
1
class
SCR_AISelectDoorOperatorAgent
:
AITaskScripted
2
{
3
// Inputs
4
protected
static
const
string
PORT_VEHICLE_ENTITY
=
"VehicleEntity"
;
5
protected
static
const
string
PORT_NAVLINK_ENTITY
=
"NavlinkEntity"
;
6
7
// Outputs
8
protected
static
const
string
PORT_DOOR_USER_AGENT
=
"DoorUserAgent"
;
9
protected
static
const
string
PORT_DOOR_USER_ENTITY
=
"DoorUserEntity"
;
10
protected
static
const
string
PORT_USE_TELEKINESIS
=
"UseTelekinesis"
;
11
12
//------------------------------------------------------------------------
13
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
14
{
15
AIGroup group = AIGroup.Cast(owner);
16
17
if
(!group)
18
group = owner.GetParentGroup();
19
20
if
(!group)
21
return
ENodeResult
.FAIL;
22
23
array<AIAgent> agents = {};
24
int
nAgents = group.GetAgents(agents);
25
26
IEntity
vehicleEntity;
27
GetVariableIn
(
PORT_VEHICLE_ENTITY
, vehicleEntity);
28
29
IEntity
navlinkEntity;
30
GetVariableIn
(
PORT_NAVLINK_ENTITY
, navlinkEntity);
31
if
(!navlinkEntity)
32
return
ENodeResult
.FAIL;
33
vector
navlinkPos = navlinkEntity.
GetOrigin
();
34
35
AIAgent bestAgent = null;
36
float
bestScore = -
float
.MAX;
37
38
for
(
int
i = 0; i < nAgents; i++)
39
{
40
AIAgent agent = agents[i];
41
42
IEntity
agentControlledEntity = agent.GetControlledEntity();
43
if
(!agentControlledEntity)
44
continue
;
45
46
BaseCompartmentSlot
agentCompartment;
47
IEntity
agentVehicleEntity =
SCR_AICompartmentHandling
.GetAgentVehicleAndCompartment(agent, agentCompartment);
48
49
float
distanceToNavlink =
vector
.Distance(agentControlledEntity.
GetOrigin
(), navlinkPos);
50
51
float
score = 200.0 - distanceToNavlink;
52
53
if
(!agentVehicleEntity)
54
{
55
// Not in vehicle, best
56
score += 1600.0;
57
}
58
else
59
{
60
// In vehicle
61
62
// Check compartment type
63
ECompartmentType
compType = agentCompartment.GetType();
64
switch
(compType)
65
{
66
case
ECompartmentType
.CARGO: score += 400.0;
break
;
// Best
67
case
ECompartmentType
.PILOT: score += 200.0;
break
;
// Worse
68
//case ECompartmentType.TURRET: score += 0; break; // Worst - gunner should be last to leave
69
}
70
71
// Is in same vehicle?
72
if
(agentVehicleEntity == vehicleEntity)
73
{
74
// In same vehicle, better
75
score += 800.0;
76
}
77
}
78
79
if
(score > bestScore)
80
{
81
bestAgent = agent;
82
bestScore = score;
83
}
84
}
85
86
bool
telekinesisUse =
false
;
87
IEntity
bestAgentEntity;
88
if
(bestAgent)
89
{
90
bestAgentEntity = bestAgent.GetControlledEntity();
91
if
(bestAgent.GetLOD() == bestAgent.GetMaxLOD())
92
{
93
telekinesisUse =
true
;
94
}
95
}
96
97
SetVariableOut
(
PORT_USE_TELEKINESIS
, telekinesisUse);
98
SetVariableOut
(
PORT_DOOR_USER_AGENT
, bestAgent);
99
SetVariableOut
(
PORT_DOOR_USER_ENTITY
, bestAgentEntity);
100
101
if
(bestAgent && bestAgentEntity)
102
return
ENodeResult
.SUCCESS;
103
else
104
return
ENodeResult
.FAIL;
105
}
106
107
//------------------------------------------------------------------------
108
static
override
bool
VisibleInPalette
() {
return
true
; }
109
110
//------------------------------------------------------------------------
111
static
override
string
GetOnHoverDescription
() {
return
"Selects an absolutely best possible group member to open a gate when driving a vehicle"
;};
112
113
//------------------------------------------------------------------------
114
protected
static
ref
TStringArray
s_aVarsOut
= {
PORT_DOOR_USER_AGENT
,
PORT_DOOR_USER_ENTITY
,
PORT_USE_TELEKINESIS
};
115
override
TStringArray
GetVariablesOut
() {
return
s_aVarsOut
; }
116
117
//------------------------------------------------------------------------
118
protected
static
ref
TStringArray
s_aVarsIn
= {
PORT_VEHICLE_ENTITY
,
PORT_NAVLINK_ENTITY
};
119
override
TStringArray
GetVariablesIn
() {
return
s_aVarsIn
; }
120
}
ECompartmentType
ECompartmentType
Definition
ECompartmentType.c:8
AITaskScripted
Definition
AITaskScripted.c:13
BaseCompartmentSlot
Definition
BaseCompartmentSlot.c:2
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
Node::SetVariableOut
proto void SetVariableOut(string name, void val)
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
SCR_AICompartmentHandling
Definition
SCR_AIUtils.c:153
SCR_AISelectDoorOperatorAgent
Definition
SCR_AISelectDoorOperatorAgent.c:2
SCR_AISelectDoorOperatorAgent::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AISelectDoorOperatorAgent.c:108
SCR_AISelectDoorOperatorAgent::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AISelectDoorOperatorAgent.c:119
SCR_AISelectDoorOperatorAgent::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AISelectDoorOperatorAgent.c:118
SCR_AISelectDoorOperatorAgent::PORT_DOOR_USER_ENTITY
static const string PORT_DOOR_USER_ENTITY
Definition
SCR_AISelectDoorOperatorAgent.c:9
SCR_AISelectDoorOperatorAgent::PORT_VEHICLE_ENTITY
static const string PORT_VEHICLE_ENTITY
Definition
SCR_AISelectDoorOperatorAgent.c:4
SCR_AISelectDoorOperatorAgent::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AISelectDoorOperatorAgent.c:13
SCR_AISelectDoorOperatorAgent::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AISelectDoorOperatorAgent.c:111
SCR_AISelectDoorOperatorAgent::PORT_NAVLINK_ENTITY
static const string PORT_NAVLINK_ENTITY
Definition
SCR_AISelectDoorOperatorAgent.c:5
SCR_AISelectDoorOperatorAgent::PORT_DOOR_USER_AGENT
static const string PORT_DOOR_USER_AGENT
Definition
SCR_AISelectDoorOperatorAgent.c:8
SCR_AISelectDoorOperatorAgent::PORT_USE_TELEKINESIS
static const string PORT_USE_TELEKINESIS
Definition
SCR_AISelectDoorOperatorAgent.c:10
SCR_AISelectDoorOperatorAgent::GetVariablesOut
override TStringArray GetVariablesOut()
Definition
SCR_AISelectDoorOperatorAgent.c:115
SCR_AISelectDoorOperatorAgent::s_aVarsOut
static ref TStringArray s_aVarsOut
Definition
SCR_AISelectDoorOperatorAgent.c:114
vector
Definition
vector.c:13
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
TStringArray
array< string > TStringArray
Definition
Types.c:385
scripts
Game
AI
ScriptedNodes
Vehicles
SCR_AISelectDoorOperatorAgent.c
Generated by
1.17.0