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_AutoSpawnLogic.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
/*
3
Object responsible for handling respawn logic on the authority side.
4
*/
5
[
BaseContainerProps
(
category
:
"Respawn"
)]
6
class
SCR_AutoSpawnLogic
: SCR_SpawnLogic
7
{
8
[
Attribute
(
""
, uiwidget:
UIWidgets
.EditBox,
category
:
"Respawn"
,
desc
:
"Default faction for players to spawn with or empty if none."
)]
9
protected
FactionKey
m_sForcedFaction
;
10
11
[
Attribute
(
""
, uiwidget:
UIWidgets
.EditBox,
category
:
"Respawn"
,
desc
:
"Default loadout for players to spawn with or empty if none"
)]
12
protected
string
m_sForcedLoadout
;
13
14
//------------------------------------------------------------------------------------------------
15
override
void
OnPlayerAuditSuccess_S
(
int
playerId)
16
{
17
super.OnPlayerAuditSuccess_S(playerId);
18
ExcuteInitialLoadOrSpawn_S(playerId);
19
}
20
21
//------------------------------------------------------------------------------------------------
22
override
void
OnPlayerEntityLost_S
(
int
playerId)
23
{
24
super.OnPlayerEntityLost_S(playerId);
25
DoSpawn_S
(playerId);
26
}
27
28
//------------------------------------------------------------------------------------------------
29
override
void
OnPlayerSpawnFailed_S
(
int
playerId)
30
{
31
super.OnPlayerSpawnFailed_S(playerId);
32
33
const
int
delay =
Math
.RandomFloat(900, 1100);
34
GetGame
().GetCallqueue().CallLater(
DoSpawn_S
, delay,
false
, playerId);
35
}
36
37
//------------------------------------------------------------------------------------------------
38
override
protected
void
DoSpawn_S
(
int
playerId)
39
{
40
array<Faction> factions = {};
41
GetGame
().GetFactionManager().GetFactionsList(factions);
42
43
Faction
targetFaction;
44
if
(!
GetForcedFaction
(targetFaction))
45
targetFaction = factions.GetRandomElement();
46
47
GetPlayerFactionComponent_S(playerId).RequestFaction(targetFaction);
48
49
SCR_BasePlayerLoadout
targetLoadout;
50
if
(!
GetForcedLoadout
(targetLoadout))
51
targetLoadout =
GetGame
().GetLoadoutManager().GetRandomFactionLoadout(targetFaction);
52
53
GetPlayerLoadoutComponent_S(playerId).RequestLoadout(targetLoadout);
54
55
Faction
faction = GetPlayerFactionComponent_S(playerId).GetAffiliatedFaction();
56
if
(!faction)
57
{
58
OnPlayerSpawnFailed_S
(playerId);
59
return
;
60
}
61
62
SCR_BasePlayerLoadout
loadout
= GetPlayerLoadoutComponent_S(playerId).GetLoadout();
63
if
(!
loadout
)
64
{
65
OnPlayerSpawnFailed_S
(playerId);
66
return
;
67
}
68
69
SCR_SpawnPoint
point =
SCR_SpawnPoint
.GetRandomSpawnPointForFaction(faction.GetFactionKey());
70
if
(!point)
71
{
72
OnPlayerSpawnFailed_S
(playerId);
73
return
;
74
}
75
76
SCR_SpawnPointSpawnData
data
=
new
SCR_SpawnPointSpawnData
(
loadout
.GetLoadoutResource(), point.
GetRplId
());
77
if
(!GetPlayerRespawnComponent_S(playerId).
CanSpawn
(
data
))
78
{
79
OnPlayerSpawnFailed_S
(playerId);
80
return
;
81
}
82
83
GetPlayerRespawnComponent_S(playerId).RequestSpawn(
data
);
84
}
85
86
//------------------------------------------------------------------------------------------------
87
protected
bool
GetForcedFaction
(out
Faction
faction)
88
{
89
if
(
m_sForcedFaction
.IsEmpty() &&
90
!
System
.GetCLIParam(
"autodeployFaction"
,
m_sForcedFaction
) &&
91
!
System
.GetCLIParam(
"tdmf"
,
m_sForcedFaction
))
92
{
93
return
false
;
94
}
95
96
faction =
GetGame
().GetFactionManager().GetFactionByKey(
m_sForcedFaction
);
97
if
(!faction)
98
{
99
Print
(
string
.Format(
"Auto spawn logic did not find faction by name: %1"
,
m_sForcedFaction
),
LogLevel
.WARNING);
100
return
false
;
101
}
102
103
return
true
;
104
}
105
106
//------------------------------------------------------------------------------------------------
107
protected
bool
GetForcedLoadout
(out
SCR_BasePlayerLoadout
loadout
)
108
{
109
if
(
m_sForcedLoadout
.IsEmpty())
110
return
false
;
111
112
loadout
=
GetGame
().GetLoadoutManager().GetLoadoutByName(
m_sForcedLoadout
,
m_sForcedFaction
);
113
if
(!
loadout
)
114
{
115
Print
(
string
.Format(
"Auto spawn logic did not find loadout by name: %1"
,
m_sForcedLoadout
),
LogLevel
.WARNING);
116
return
false
;
117
}
118
return
true
;
119
}
120
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
loadout
string loadout
Definition
SCR_ArsenalManagerComponent.c:0
data
Get all prefabs that have the spawner data
Definition
SCR_EntityCatalogManagerComponent.c:320
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
CanSpawn
bool CanSpawn(SCR_SpawnData data)
Definition
SCR_RespawnComponent.c:380
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
Faction
Definition
Faction.c:13
FactionKey
Definition
FactionKey.c:3
Math
Definition
Math.c:13
SCR_AutoSpawnLogic
Definition
SCR_AutoSpawnLogic.c:7
SCR_AutoSpawnLogic::GetForcedLoadout
bool GetForcedLoadout(out SCR_BasePlayerLoadout loadout)
Definition
SCR_AutoSpawnLogic.c:107
SCR_AutoSpawnLogic::OnPlayerEntityLost_S
override void OnPlayerEntityLost_S(int playerId)
Definition
SCR_AutoSpawnLogic.c:22
SCR_AutoSpawnLogic::OnPlayerSpawnFailed_S
override void OnPlayerSpawnFailed_S(int playerId)
Definition
SCR_AutoSpawnLogic.c:29
SCR_AutoSpawnLogic::DoSpawn_S
void DoSpawn_S(int playerId)
Definition
SCR_AutoSpawnLogic.c:38
SCR_AutoSpawnLogic::m_sForcedLoadout
string m_sForcedLoadout
Definition
SCR_AutoSpawnLogic.c:12
SCR_AutoSpawnLogic::OnPlayerAuditSuccess_S
override void OnPlayerAuditSuccess_S(int playerId)
Definition
SCR_AutoSpawnLogic.c:15
SCR_AutoSpawnLogic::m_sForcedFaction
FactionKey m_sForcedFaction
Definition
SCR_AutoSpawnLogic.c:9
SCR_AutoSpawnLogic::GetForcedFaction
bool GetForcedFaction(out Faction faction)
Definition
SCR_AutoSpawnLogic.c:87
SCR_BasePlayerLoadout
Definition
SCR_BasePlayerLoadout.c:3
SCR_SpawnPoint
Spawn point entity defines positions on which players can possibly spawn.
Definition
SCR_SpawnPoint.c:28
SCR_SpawnPoint::GetRplId
RplId GetRplId()
Definition
SCR_SpawnPoint.c:302
SCR_SpawnPointSpawnData
Definition
SCR_SpawnPointSpawnData.c:3
System
Definition
System.c:13
UIWidgets
Definition
attributes.c:40
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
Respawn
Logic
SCR_AutoSpawnLogic.c
Generated by
1.17.0