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_WaypointGroupCommand.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
[
BaseContainerProps
(),
SCR_BaseGroupCommandTitleField
(
"m_sCommandName"
)]
3
class
SCR_WaypointGroupCommand
:
SCR_BaseGroupCommand
4
{
5
[
Attribute
(
desc
:
"Prefab of the AI waypoint used in this command"
,
params
:
"et class=AIWaypoint"
)]
6
protected
ResourceName
m_sWaypointPrefab
;
7
8
[
Attribute
(defvalue:
"1"
,
desc
:
"Will the command override all previous commands?"
)]
9
protected
bool
m_bOverridePreviousCommands
;
10
11
[
Attribute
(defvalue:
"0"
,
desc
:
"Will the command be automatically set to players position?"
)]
12
protected
bool
m_bTargetSelf
;
13
14
[
Attribute
(defvalue:
"0"
,
desc
:
"Will the command override autonomous group behavior?"
)]
15
protected
bool
m_bForceCommand
;
16
17
[
Attribute
(defvalue:
"5"
,
desc
:
"Completion radius of command"
)]
18
protected
float
m_fCompletionRadius
;
19
20
[
Attribute
(
"0"
,
UIWidgets
.CheckBox,
desc
:
"Optionally, execution of this command can set combat mode of the group."
)]
21
bool
m_bSetCombatMode
;
22
23
[
Attribute
(
typename
.EnumToString(
EAIGroupCombatMode
,
EAIGroupCombatMode
.FIRE_AT_WILL),
UIWidgets
.ComboBox,
desc
:
"New combat mode value"
, enums: ParamEnumArray.FromEnum(
EAIGroupCombatMode
))]
24
protected
EAIGroupCombatMode
m_eCombatMode
;
25
26
[
Attribute
(
desc
:
"Handler which is going to be called to manipualte the waypoint when it is created as well as when it is assigned to the group."
)]
27
protected
ref
SCR_BaseWaypointCommandHandler
m_WaypointCommandHandler
;
28
29
//------------------------------------------------------------------------------------------------
30
override
bool
Execute
(
IEntity
cursorTarget,
IEntity
target,
vector
targetPosition,
int
playerID,
bool
isClient)
31
{
32
SCR_ChimeraCharacter user = SCR_ChimeraCharacter.Cast(
GetGame
().GetPlayerManager().GetPlayerControlledEntity(playerID));
33
if
(user && !
CanBePerformed
(user))
34
return
false
;
//verify that at the moment of execution player can actually do that
35
36
if
(isClient && playerID ==
SCR_PlayerController
.
GetLocalPlayerId
())
37
{
38
SpawnWPVisualization
(targetPosition, playerID);
39
return
true
;
40
}
41
42
SpawnWPVisualization
(targetPosition, playerID);
43
if
(!
m_sWaypointPrefab
|| !target || !targetPosition)
44
return
false
;
45
46
bool
waypointCreated =
SetWaypointForAIGroup
(target, targetPosition, playerID);
47
48
if
(!waypointCreated)
49
return
false
;
50
51
// Set combat mode
52
if
(
m_bSetCombatMode
)
53
SetCombatMode
(target,
m_eCombatMode
);
54
55
return
true
;
56
}
57
58
//------------------------------------------------------------------------------------------------
59
bool
SetWaypointForAIGroup
(
IEntity
target,
vector
targetPosition,
int
playerID)
60
{
61
SCR_AIGroup
slaveGroup =
SCR_AIGroup
.Cast(target);
62
if
(!slaveGroup)
63
return
false
;
64
65
array<AIWaypoint> currentWaypoints = {};
66
slaveGroup.GetWaypoints(currentWaypoints);
67
foreach
(AIWaypoint currentwp : currentWaypoints)
68
{
69
slaveGroup.RemoveWaypoint(currentwp);
70
}
71
72
Resource
waypointPrefab =
Resource
.Load(
GetWaypointPrefab
());
73
if
(!waypointPrefab.IsValid())
74
{
75
//add custom error
76
return
false
;
77
}
78
79
vector
position
;
80
position
=
GetTargetPosition
(playerID, targetPosition);
81
82
EntitySpawnParams
params
=
EntitySpawnParams
();
83
params
.TransformMode = ETransformMode.WORLD;
84
params
.Transform[3] =
position
;
85
86
CheckPreviousWaypoints
(slaveGroup);
87
88
SCR_AIWaypoint
wp =
SCR_AIWaypoint
.Cast(
GetGame
().SpawnEntityPrefabLocal(waypointPrefab, null,
params
));
89
if
(!wp)
90
return
false
;
91
92
if
(
m_WaypointCommandHandler
)
93
m_WaypointCommandHandler
.OnWaypointCreated(wp);
94
95
if
(
m_bForceCommand
)
96
wp.
SetPriorityLevel
(SCR_AIActionBase.PRIORITY_LEVEL_PLAYER);
97
98
wp.SetCompletionRadius(
m_fCompletionRadius
);
99
slaveGroup.AddWaypoint(wp);
100
if
(
m_WaypointCommandHandler
)
101
m_WaypointCommandHandler
.OnWaypointIssued(wp, slaveGroup);
102
103
return
true
;
104
}
105
106
//------------------------------------------------------------------------------------------------
107
void
SpawnWPVisualization
(
vector
targetPosition,
int
playerID)
108
{
109
PlayerController controller =
GetGame
().GetPlayerManager().GetPlayerController(playerID);
110
if
(!controller)
111
return
;
112
113
SCR_PlayerControllerCommandingComponent commandingComp = SCR_PlayerControllerCommandingComponent.Cast(controller.FindComponent(SCR_PlayerControllerCommandingComponent));
114
if
(!commandingComp)
115
return
;
116
117
commandingComp.DrawWaypointVisualization(targetPosition,
m_fCompletionRadius
);
118
}
119
120
//------------------------------------------------------------------------------------------------
121
ResourceName
GetWaypointPrefab
()
122
{
123
return
m_sWaypointPrefab
;
124
}
125
126
//------------------------------------------------------------------------------------------------
127
void
SetWaypointPrefab
(
ResourceName
wpPrefab)
128
{
129
m_sWaypointPrefab
= wpPrefab;
130
}
131
132
//------------------------------------------------------------------------------------------------
133
bool
GetOverridePreviousCommands
()
134
{
135
return
m_bOverridePreviousCommands
;
136
}
137
138
//------------------------------------------------------------------------------------------------
139
void
SetOverridePreviousCommands
(
bool
overridePrevious)
140
{
141
m_bOverridePreviousCommands
= overridePrevious;
142
}
143
144
//----------------------------------------------------------------------------------------------
145
vector
GetTargetPosition
(
int
playerID,
vector
targetPosition)
146
{
147
if
(
m_bTargetSelf
)
148
{
149
SCR_PlayerController
orderingPlayerController =
SCR_PlayerController
.Cast(
GetGame
().GetPlayerManager().
GetPlayerController
(playerID));
150
IEntity
playerEntity = orderingPlayerController.GetControlledEntity();
151
if
(!playerEntity)
152
return
vector
.Zero;
153
return
playerEntity.
GetOrigin
();
154
}
155
else
156
return
targetPosition;
157
}
158
159
//-------------------------------------------------------------------------------------------------
160
void
CheckPreviousWaypoints
(
SCR_AIGroup
slaveGroup)
161
{
162
if
(!
m_bOverridePreviousCommands
)
163
return
;
164
165
array<AIWaypoint> currentWaypoints = {};
166
slaveGroup.GetWaypoints(currentWaypoints);
167
foreach
(AIWaypoint currentwp : currentWaypoints)
168
{
169
slaveGroup.RemoveWaypoint(currentwp);
170
}
171
AIGroupMovementComponent slaveGroupMovementComp = AIGroupMovementComponent.Cast(slaveGroup.FindComponent(AIGroupMovementComponent));
172
if
(slaveGroupMovementComp)
173
slaveGroupMovementComp.SetFormationDisplacement(0);
174
}
175
176
//------------------------------------------------------------------------------------------------
177
override
bool
CanShowOnMap
()
178
{
179
return
CanBeShown
();
180
}
181
182
//------------------------------------------------------------------------------------------------
183
override
bool
CanBeShown
()
184
{
185
if
(!
CanBeShownInCurrentLifeState
())
186
return
false
;
187
188
SCR_PlayerControllerGroupComponent groupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
189
return
groupController &&
CanRoleShow
();
190
}
191
192
//------------------------------------------------------------------------------------------------
193
void
SetCombatMode
(
IEntity
target,
EAIGroupCombatMode
combatMode)
194
{
195
SCR_AIGroup
slaveGroup =
SCR_AIGroup
.Cast(target);
196
if
(!slaveGroup)
197
return
;
198
199
SCR_AIGroupUtilityComponent
groupUtility =
SCR_AIGroupUtilityComponent
.Cast(slaveGroup.FindComponent(
SCR_AIGroupUtilityComponent
));
200
201
groupUtility.
SetCombatMode
(combatMode);
202
}
203
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
GetTargetPosition
override vector GetTargetPosition()
Definition
SCR_AICombatMoveLogic_Attack.c:664
EAIGroupCombatMode
EAIGroupCombatMode
Definition
SCR_AIGroupUtilityComponent.c:6
position
vector position
Definition
SCR_DestructibleTreeV2.c:30
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
Resource
Object holding reference to resource. In destructor release the resource.
Definition
Resource.c:25
ResourceName
Definition
ResourceName.c:13
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIGroupUtilityComponent
Definition
SCR_AIGroupUtilityComponent.c:18
SCR_AIGroupUtilityComponent::SetCombatMode
void SetCombatMode(EAIGroupCombatMode combatMode)
Sets combat mode as desired by external means, such as scenario, or commanding, or game master.
Definition
SCR_AIGroupUtilityComponent.c:140
SCR_AIWaypoint
Definition
SCR_AIWaypoint.c:6
SCR_AIWaypoint::SetPriorityLevel
void SetPriorityLevel(float priority)
Definition
SCR_AIWaypoint.c:29
SCR_BaseGroupCommand
Definition
SCR_BaseGroupCommand.c:4
SCR_BaseGroupCommand::CanRoleShow
override bool CanRoleShow()
Definition
SCR_BaseGroupCommand.c:44
SCR_BaseGroupCommand::CanBeShownInCurrentLifeState
override bool CanBeShownInCurrentLifeState()
Definition
SCR_BaseGroupCommand.c:101
SCR_BaseGroupCommandTitleField
Definition
SCR_PlayerCommandsConfig.c:155
SCR_BaseRadialCommand::CanBePerformed
bool CanBePerformed(notnull SCR_ChimeraCharacter user)
Definition
SCR_BaseRadialCommand.c:102
SCR_BaseWaypointCommandHandler
Definition
SCR_BaseWaypointCommandHandler.c:3
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalPlayerId
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
Definition
SCR_PlayerController.c:481
SCR_WaypointGroupCommand
Definition
SCR_WaypointGroupCommand.c:4
SCR_WaypointGroupCommand::m_fCompletionRadius
float m_fCompletionRadius
Definition
SCR_WaypointGroupCommand.c:18
SCR_WaypointGroupCommand::m_bForceCommand
bool m_bForceCommand
Definition
SCR_WaypointGroupCommand.c:15
SCR_WaypointGroupCommand::SetWaypointPrefab
void SetWaypointPrefab(ResourceName wpPrefab)
Definition
SCR_WaypointGroupCommand.c:127
SCR_WaypointGroupCommand::CanBeShown
override bool CanBeShown()
Definition
SCR_WaypointGroupCommand.c:183
SCR_WaypointGroupCommand::m_bTargetSelf
bool m_bTargetSelf
Definition
SCR_WaypointGroupCommand.c:12
SCR_WaypointGroupCommand::m_sWaypointPrefab
ResourceName m_sWaypointPrefab
Definition
SCR_WaypointGroupCommand.c:6
SCR_WaypointGroupCommand::m_bOverridePreviousCommands
bool m_bOverridePreviousCommands
Definition
SCR_WaypointGroupCommand.c:9
SCR_WaypointGroupCommand::m_bSetCombatMode
bool m_bSetCombatMode
Definition
SCR_WaypointGroupCommand.c:21
SCR_WaypointGroupCommand::Execute
override bool Execute(IEntity cursorTarget, IEntity target, vector targetPosition, int playerID, bool isClient)
Definition
SCR_WaypointGroupCommand.c:30
SCR_WaypointGroupCommand::CanShowOnMap
override bool CanShowOnMap()
Definition
SCR_WaypointGroupCommand.c:177
SCR_WaypointGroupCommand::GetTargetPosition
vector GetTargetPosition(int playerID, vector targetPosition)
Definition
SCR_WaypointGroupCommand.c:145
SCR_WaypointGroupCommand::GetWaypointPrefab
ResourceName GetWaypointPrefab()
Definition
SCR_WaypointGroupCommand.c:121
SCR_WaypointGroupCommand::m_eCombatMode
EAIGroupCombatMode m_eCombatMode
Definition
SCR_WaypointGroupCommand.c:24
SCR_WaypointGroupCommand::CheckPreviousWaypoints
void CheckPreviousWaypoints(SCR_AIGroup slaveGroup)
Definition
SCR_WaypointGroupCommand.c:160
SCR_WaypointGroupCommand::SetOverridePreviousCommands
void SetOverridePreviousCommands(bool overridePrevious)
Definition
SCR_WaypointGroupCommand.c:139
SCR_WaypointGroupCommand::SetWaypointForAIGroup
bool SetWaypointForAIGroup(IEntity target, vector targetPosition, int playerID)
Definition
SCR_WaypointGroupCommand.c:59
SCR_WaypointGroupCommand::SetCombatMode
void SetCombatMode(IEntity target, EAIGroupCombatMode combatMode)
Definition
SCR_WaypointGroupCommand.c:193
SCR_WaypointGroupCommand::m_WaypointCommandHandler
ref SCR_BaseWaypointCommandHandler m_WaypointCommandHandler
Definition
SCR_WaypointGroupCommand.c:27
SCR_WaypointGroupCommand::SpawnWPVisualization
void SpawnWPVisualization(vector targetPosition, int playerID)
Definition
SCR_WaypointGroupCommand.c:107
SCR_WaypointGroupCommand::GetOverridePreviousCommands
bool GetOverridePreviousCommands()
Definition
SCR_WaypointGroupCommand.c:133
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
EntitySpawnParams
void EntitySpawnParams()
Definition
gameLib.c:130
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
GetPlayerController
proto external PlayerController GetPlayerController()
Definition
SCR_PlayerDeployMenuHandlerComponent.c:307
scripts
Game
Commanding
Commands
SCR_WaypointGroupCommand.c
Generated by
1.17.0