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_ScenarioFrameworkGetClosestAIEntity.c
Go to the documentation of this file.
1
[
BaseContainerProps
(),
SCR_ContainerActionTitle
()]
2
class
SCR_ScenarioFrameworkGetClosestAIEntity
:
SCR_ScenarioFrameworkGet
3
{
4
[
Attribute
(
desc
:
"Closest to what - use getter"
)]
5
ref
SCR_ScenarioFrameworkGet
m_Getter;
6
7
[
Attribute
(
desc
:
"(Optional) You can filter players by putting the Faction Key of desired faction(s). If not used, all factions will be eligible"
)]
8
ref array<string> m_aFactionKeys;
9
10
//------------------------------------------------------------------------------------------------
11
override
SCR_ScenarioFrameworkParamBase
Get()
12
{
13
if
(!m_Getter)
14
{
15
Print
(
"ScenarioFramework: GetClosestPlayerEntity - The object the distance is calculated from is missing!"
,
LogLevel
.ERROR);
16
return
null;
17
}
18
19
SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
20
if
(!entityWrapper)
21
return
null;
22
23
IEntity
entityFrom = entityWrapper.GetValue();
24
if
(!entityFrom)
25
return
null;
26
27
array<AIAgent> agents = {};
28
GetGame
().GetAIWorld().GetAIAgents(agents);
29
30
IEntity
closestEntity;
31
IEntity
entityToBeChecked;
32
SCR_ChimeraCharacter chimeraCharacter;
33
float
fDistance =
float
.MAX;
34
bool
factionKeyIsEmpty = m_aFactionKeys.IsEmpty();
35
36
if
(!factionKeyIsEmpty)
37
{
38
// Resolve Alias
39
SCR_FactionAliasComponent factionAliasComponent = SCR_FactionAliasComponent.Cast(
GetGame
().GetFactionManager().FindComponent(SCR_FactionAliasComponent));
40
if
(factionAliasComponent)
41
{
42
array<string> aliasedFactionKeys = {};
43
foreach
(
string
factionKey : m_aFactionKeys)
44
{
45
aliasedFactionKeys.Insert(factionAliasComponent.ResolveFactionAlias(factionKey))
46
}
47
48
if
(!aliasedFactionKeys.IsEmpty())
49
{
50
m_aFactionKeys.Clear();
51
m_aFactionKeys.InsertAll(aliasedFactionKeys);
52
53
}
54
}
55
}
56
57
foreach
(AIAgent agent : agents)
58
{
59
entityToBeChecked = agent.GetControlledEntity();
60
if
(!entityToBeChecked)
61
continue
;
62
63
if
(!factionKeyIsEmpty)
64
{
65
chimeraCharacter = SCR_ChimeraCharacter.Cast(entityToBeChecked);
66
if
(!chimeraCharacter || !m_aFactionKeys.Contains(chimeraCharacter.GetFactionKey()))
67
continue
;
68
}
69
70
float
fActualDistance =
vector
.DistanceSqXZ(entityFrom.
GetOrigin
(), entityToBeChecked.
GetOrigin
());
71
72
if
(fActualDistance < fDistance)
73
{
74
closestEntity = entityToBeChecked;
75
fDistance = fActualDistance;
76
}
77
}
78
79
if
(!closestEntity)
80
return
null;
81
82
return
new
SCR_ScenarioFrameworkParam<IEntity>(closestEntity);
83
}
84
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
SCR_ContainerActionTitle
Definition
SCR_ContainerActionTitle.c:2
SCR_ScenarioFrameworkGetClosestAIEntity
Definition
SCR_ScenarioFrameworkGetClosestAIEntity.c:3
SCR_ScenarioFrameworkGet
Definition
SCR_ScenarioFrameworkGet.c:3
SCR_ScenarioFrameworkParamBase
Definition
SCR_ScenarioFrameworkParamBase.c:2
vector
Definition
vector.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
ScenarioFramework
Actions
ActionGetters
SCR_ScenarioFrameworkGetClosestAIEntity.c
Generated by
1.17.0