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_FollowGroupCommand.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
[
BaseContainerProps
(),
SCR_BaseGroupCommandTitleField
(
"m_sCommandName"
)]
3
class
SCR_FollowGroupCommand
:
SCR_WaypointGroupCommand
4
{
5
//------------------------------------------------------------------------------------------------
6
override
bool
Execute(
IEntity
cursorTarget,
IEntity
target,
vector
targetPosition,
int
playerID,
bool
isClient)
7
{
8
if
(!
m_sWaypointPrefab
|| !target || !targetPosition)
9
return
false
;
10
11
if
(isClient)
12
{
13
//place to place a logic that would be executed for other players
14
return
true
;
15
}
16
17
SCR_AIGroup
slaveGroup =
SCR_AIGroup
.Cast(target);
18
if
(!slaveGroup)
19
return
false
;
20
21
Resource
waypointPrefab =
Resource
.Load(
GetWaypointPrefab
());
22
if
(!waypointPrefab.IsValid())
23
return
false
;
24
25
PlayerController playerController =
GetGame
().GetPlayerManager().GetPlayerController(playerID);
26
if
(!playerController)
27
return
false
;
28
IEntity
controlledEntity = playerController.GetControlledEntity();
29
if
(!controlledEntity)
30
return
false
;
31
32
EntitySpawnParams
params
=
EntitySpawnParams
();
33
params
.TransformMode = ETransformMode.WORLD;
34
params
.Transform[3] = controlledEntity.
GetOrigin
();
35
36
CheckPreviousWaypoints
(slaveGroup);
37
38
// Hotfix: teleport group to leader, otherwise if group is very split up, bots will try to regroup somewhere in the middle, far away
39
vector
targetTransform[4];
40
controlledEntity.
GetTransform
(targetTransform);
41
slaveGroup.SetTransform(targetTransform);
42
slaveGroup.Update();
43
44
// Crucial part about follow waypoint: we must set entity so it knows who to follow
45
// Also it is of SCR_EntityWaypoint class, not SCR_AIWaypoint.
46
SCR_EntityWaypoint
wp =
SCR_EntityWaypoint
.Cast(
GetGame
().SpawnEntityPrefabLocal(waypointPrefab, null,
params
));
47
if
(!wp)
48
return
false
;
49
wp.SetEntity(controlledEntity);
50
51
if
(
m_bForceCommand
)
52
wp.SetPriorityLevel(SCR_AIActionBase.PRIORITY_LEVEL_PLAYER);
53
slaveGroup.AddWaypoint(wp);
54
55
AIGroupMovementComponent slaveGroupMovementComp = AIGroupMovementComponent.Cast(slaveGroup.FindComponent(AIGroupMovementComponent));
56
if
(slaveGroupMovementComp)
57
slaveGroupMovementComp.SetFormationDisplacement(1);
58
59
return
true
;
60
}
61
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetTransform
proto external void GetTransform(out vector mat[])
Resource
Object holding reference to resource. In destructor release the resource.
Definition
Resource.c:25
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_BaseGroupCommandTitleField
Definition
SCR_PlayerCommandsConfig.c:155
SCR_EntityWaypoint
Definition
SCR_EntityWaypoint.c:44
SCR_FollowGroupCommand
Definition
SCR_FollowGroupCommand.c:4
SCR_WaypointGroupCommand
Definition
SCR_WaypointGroupCommand.c:4
SCR_WaypointGroupCommand::m_bForceCommand
bool m_bForceCommand
Definition
SCR_WaypointGroupCommand.c:15
SCR_WaypointGroupCommand::m_sWaypointPrefab
ResourceName m_sWaypointPrefab
Definition
SCR_WaypointGroupCommand.c:6
SCR_WaypointGroupCommand::GetWaypointPrefab
ResourceName GetWaypointPrefab()
Definition
SCR_WaypointGroupCommand.c:121
SCR_WaypointGroupCommand::CheckPreviousWaypoints
void CheckPreviousWaypoints(SCR_AIGroup slaveGroup)
Definition
SCR_WaypointGroupCommand.c:160
vector
Definition
vector.c:13
EntitySpawnParams
void EntitySpawnParams()
Definition
gameLib.c:130
scripts
Game
Commanding
Commands
SCR_FollowGroupCommand.c
Generated by
1.17.0