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_RestrictedDeployableSpawnPoint.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted/DeployableItems"
, description:
""
, visible:
false
)]
2
class
SCR_RestrictedDeployableSpawnPointClass
:
SCR_DeployableSpawnPointClass
3
{
4
};
5
6
//------------------------------------------------------------------------------------------------
8
class
SCR_RestrictedDeployableSpawnPoint
:
SCR_DeployableSpawnPoint
9
{
10
[
RplProp
()]
11
protected
bool
m_bAllowAllGroupsToSpawn
;
12
13
[
RplProp
()]
14
protected
int
m_iGroupID
= -1;
15
16
protected
SCR_ESpawnPointBudgetType
m_eRespawnBudgetType
;
17
18
protected
int
m_iMaxRespawns
;
19
20
protected
int
m_iRespawnCount
;
21
22
protected
bool
m_bLoadoutAllowed
;
23
24
//------------------------------------------------------------------------------------------------
25
protected
bool
CanSpawn
(notnull array<SCR_ChimeraCharacter> characters,
Faction
spawnPointFaction,
vector
spawnPointOrigin)
26
{
27
SCR_RestrictedDeployableSpawnPointComponent
restrictedDeployableSpawnPointComp =
SCR_RestrictedDeployableSpawnPointComponent
.Cast(
m_DeployableSpawnPointComp
);
28
if
(!restrictedDeployableSpawnPointComp)
29
return
false
;
30
31
if
(restrictedDeployableSpawnPointComp.
GetIgnoreEnemyCharacters
())
32
return
true
;
33
34
int
friendlyCharactersCount, enemyCharactersCount = 0;
35
36
foreach
(SCR_ChimeraCharacter character : characters)
37
{
38
if
(character.GetCharacterController().IsDead())
39
continue
;
40
41
float
distanceToItemSq = (spawnPointOrigin - character.GetOrigin()).LengthSq();
42
float
queryRadius = restrictedDeployableSpawnPointComp.
GetQueryRadiusCharacters
();
43
float
queryRadiusSq = queryRadius * queryRadius;
44
45
if
(distanceToItemSq > queryRadiusSq)
46
continue
;
47
48
SCR_Faction
faction =
SCR_Faction
.Cast(
SCR_Faction
.
GetEntityFaction
(character));
49
50
if
(faction.
DoCheckIfFactionFriendly
(spawnPointFaction))
51
friendlyCharactersCount++;
52
else
53
enemyCharactersCount++;
54
}
55
56
return
friendlyCharactersCount - enemyCharactersCount >= 0;
57
}
58
59
//------------------------------------------------------------------------------------------------
60
override
bool
IsSpawnPointVisibleForPlayer
(
int
pid)
61
{
62
if
(
m_bAllowAllGroupsToSpawn
)
63
return
true
;
64
65
SCR_PlayerControllerGroupComponent playerControllerGroupComp = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(pid);
66
if
(!playerControllerGroupComp)
67
return
false
;
68
69
int
localPlayerGroupID = playerControllerGroupComp.GetGroupID();
70
71
return
m_iGroupID
== localPlayerGroupID;
72
}
73
74
//------------------------------------------------------------------------------------------------
75
override
void
OnFinalizeSpawnDone_S
(SCR_SpawnRequestComponent requestComponent,
SCR_SpawnData
data
,
IEntity
entity)
76
{
77
super.OnFinalizeSpawnDone_S(requestComponent,
data
, entity);
78
79
if
(
m_eRespawnBudgetType
==
SCR_ESpawnPointBudgetType
.SPAWNTICKET)
80
{
81
m_iRespawnCount
++;
82
83
SCR_RestrictedDeployableSpawnPointComponent
restrictedDeployableSpawnPointComp =
SCR_RestrictedDeployableSpawnPointComponent
.Cast(
m_DeployableSpawnPointComp
);
84
if
(!restrictedDeployableSpawnPointComp)
85
return
;
86
87
restrictedDeployableSpawnPointComp.
SetRespawnCount
(
m_iRespawnCount
);
88
}
89
}
90
91
//------------------------------------------------------------------------------------------------
92
override
bool
CanReserveFor_S
(
int
playerId, out
SCR_ESpawnResult
result =
SCR_ESpawnResult
.SPAWN_NOT_ALLOWED)
93
{
94
if
(!super.CanReserveFor_S(playerId, result))
95
return
false
;
96
97
// Deny spawning when respawn limit is reached and supply usage is disabled
98
if
(
m_eRespawnBudgetType
==
SCR_ESpawnPointBudgetType
.SPAWNTICKET &&
m_iRespawnCount
>=
m_iMaxRespawns
)
99
{
100
result =
SCR_ESpawnResult
.NOT_ALLOWED_SPAWNPOINT_DISABLED_OUT_OF_RESPAWNS;
101
return
false
;
102
}
103
104
// Deny spawning if custom loadouts are disabled and player is trying to spawn with one
105
if
(
m_eRespawnBudgetType
==
SCR_ESpawnPointBudgetType
.SUPPLIES && !
m_bLoadoutAllowed
)
106
{
107
IEntity
playerController =
GetGame
().GetPlayerManager().GetPlayerController(playerId);
108
if
(!playerController)
109
return
false
;
110
111
SCR_PlayerLoadoutComponent
loadoutComp =
SCR_PlayerLoadoutComponent
.Cast(playerController.
FindComponent
(
SCR_PlayerLoadoutComponent
));
112
if
(!loadoutComp)
113
return
false
;
114
115
SCR_PlayerArsenalLoadout
loadout
=
SCR_PlayerArsenalLoadout
.Cast(loadoutComp.
GetLoadout
());
116
if
(
loadout
)
117
{
118
result =
SCR_ESpawnResult
.NOT_ALLOWED_CUSTOM_LOADOUT;
119
return
false
;
120
}
121
}
122
123
// Deny spawning when enemies are near spawnpoint
124
array<SCR_ChimeraCharacter> characters =
SCR_CharacterRegistrationComponent
.GetChimeraCharacters();
125
126
FactionManager factionManager =
GetGame
().GetFactionManager();
127
if
(!factionManager)
128
return
false
;
129
130
SCR_Faction
faction =
SCR_Faction
.Cast(factionManager.GetFactionByKey(
GetFactionKey
()));
131
132
if
(!
CanSpawn
(characters, faction,
GetOrigin
()))
133
{
134
result =
SCR_ESpawnResult
.NOT_ALLOWED_SPAWNING_DISABLED_ENEMIES_NEARBY;
135
return
false
;
136
}
137
138
return
true
;
139
}
140
141
//------------------------------------------------------------------------------------------------
142
void
SetAllowAllGroupsToSpawn
(
bool
allowAllGroupsToSpawn)
143
{
144
m_bAllowAllGroupsToSpawn
= allowAllGroupsToSpawn;
145
Replication
.BumpMe();
146
}
147
148
//------------------------------------------------------------------------------------------------
149
void
SetBudgetType
(
SCR_ESpawnPointBudgetType
budgetType)
150
{
151
m_eRespawnBudgetType
= budgetType;
152
}
153
154
//------------------------------------------------------------------------------------------------
155
void
SetGroupID
(
int
groupID)
156
{
157
m_iGroupID
= groupID;
158
Replication
.BumpMe();
159
}
160
161
//------------------------------------------------------------------------------------------------
162
int
GetMaxRespawns
()
163
{
164
return
m_iMaxRespawns
;
165
}
166
167
//------------------------------------------------------------------------------------------------
168
void
SetMaxRespawns
(
int
maxRespawns)
169
{
170
m_iMaxRespawns
= maxRespawns;
171
}
172
173
//------------------------------------------------------------------------------------------------
174
int
GetRespawnCount
()
175
{
176
return
m_iRespawnCount
;
177
}
178
179
//------------------------------------------------------------------------------------------------
180
void
SetRespawnCount
(
int
respawnCount)
181
{
182
m_iRespawnCount
= respawnCount;
183
}
184
185
//------------------------------------------------------------------------------------------------
186
bool
IsLoadoutAllowed
()
187
{
188
return
m_bLoadoutAllowed
;
189
}
190
191
//------------------------------------------------------------------------------------------------
192
void
SetLoadoutAllowed
(
bool
allow)
193
{
194
m_bLoadoutAllowed
= allow;
195
}
196
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetOrigin
vector GetOrigin()
Definition
SCR_AIUtilityComponent.c:471
loadout
string loadout
Definition
SCR_ArsenalManagerComponent.c:0
RplProp
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
SCR_CharacterRegistrationComponent
void SCR_CharacterRegistrationComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_CharacterRegistrationComponent.c:48
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
SCR_ESpawnResult
SCR_ESpawnResult
Definition
SCR_ESpawnResult.c:9
data
Get all prefabs that have the spawner data
Definition
SCR_EntityCatalogManagerComponent.c:320
SCR_ESpawnPointBudgetType
SCR_ESpawnPointBudgetType
Definition
SCR_RestrictedDeployableSpawnPointComponent.c:2
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
Faction
Definition
Faction.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
Replication
Main replication API.
Definition
Replication.c:14
SCR_DeployableSpawnPointClass
Definition
SCR_DeployableSpawnPoint.c:3
SCR_DeployableSpawnPoint
Definition
SCR_DeployableSpawnPoint.c:12
SCR_DeployableSpawnPoint::m_DeployableSpawnPointComp
SCR_BaseDeployableSpawnPointComponent m_DeployableSpawnPointComp
Definition
SCR_DeployableSpawnPoint.c:15
SCR_Faction
Definition
SCR_Faction.c:6
SCR_Faction::DoCheckIfFactionFriendly
override bool DoCheckIfFactionFriendly(Faction faction)
Definition
SCR_Faction.c:504
SCR_Faction::GetEntityFaction
static Faction GetEntityFaction(notnull IEntity entity)
Definition
SCR_Faction.c:810
SCR_PlayerArsenalLoadout
Definition
SCR_PlayerArsenalLoadout.c:3
SCR_PlayerLoadoutComponent
Definition
SCR_PlayerLoadoutComponent.c:17
SCR_PlayerLoadoutComponent::GetLoadout
SCR_BasePlayerLoadout GetLoadout()
Definition
SCR_PlayerLoadoutComponent.c:57
SCR_RestrictedDeployableSpawnPointClass
Definition
SCR_RestrictedDeployableSpawnPoint.c:3
SCR_RestrictedDeployableSpawnPointComponent
Deployable spawn point with configurable conditions.
Definition
SCR_RestrictedDeployableSpawnPointComponent.c:16
SCR_RestrictedDeployableSpawnPointComponent::GetQueryRadiusCharacters
float GetQueryRadiusCharacters()
Definition
SCR_RestrictedDeployableSpawnPointComponent.c:698
SCR_RestrictedDeployableSpawnPointComponent::SetRespawnCount
void SetRespawnCount(int respawnCount)
Definition
SCR_RestrictedDeployableSpawnPointComponent.c:705
SCR_RestrictedDeployableSpawnPointComponent::GetIgnoreEnemyCharacters
bool GetIgnoreEnemyCharacters()
Definition
SCR_RestrictedDeployableSpawnPointComponent.c:684
SCR_RestrictedDeployableSpawnPoint
Basically SCR_SpawnPoint with the ability to limit respawn amount.
Definition
SCR_RestrictedDeployableSpawnPoint.c:9
SCR_RestrictedDeployableSpawnPoint::SetGroupID
void SetGroupID(int groupID)
Definition
SCR_RestrictedDeployableSpawnPoint.c:155
SCR_RestrictedDeployableSpawnPoint::m_iGroupID
int m_iGroupID
Definition
SCR_RestrictedDeployableSpawnPoint.c:14
SCR_RestrictedDeployableSpawnPoint::SetAllowAllGroupsToSpawn
void SetAllowAllGroupsToSpawn(bool allowAllGroupsToSpawn)
Definition
SCR_RestrictedDeployableSpawnPoint.c:142
SCR_RestrictedDeployableSpawnPoint::GetRespawnCount
int GetRespawnCount()
Definition
SCR_RestrictedDeployableSpawnPoint.c:174
SCR_RestrictedDeployableSpawnPoint::m_iMaxRespawns
int m_iMaxRespawns
Definition
SCR_RestrictedDeployableSpawnPoint.c:18
SCR_RestrictedDeployableSpawnPoint::SetRespawnCount
void SetRespawnCount(int respawnCount)
Definition
SCR_RestrictedDeployableSpawnPoint.c:180
SCR_RestrictedDeployableSpawnPoint::GetMaxRespawns
int GetMaxRespawns()
Definition
SCR_RestrictedDeployableSpawnPoint.c:162
SCR_RestrictedDeployableSpawnPoint::m_bAllowAllGroupsToSpawn
bool m_bAllowAllGroupsToSpawn
Definition
SCR_RestrictedDeployableSpawnPoint.c:11
SCR_RestrictedDeployableSpawnPoint::IsLoadoutAllowed
bool IsLoadoutAllowed()
Definition
SCR_RestrictedDeployableSpawnPoint.c:186
SCR_RestrictedDeployableSpawnPoint::CanSpawn
bool CanSpawn(notnull array< SCR_ChimeraCharacter > characters, Faction spawnPointFaction, vector spawnPointOrigin)
Definition
SCR_RestrictedDeployableSpawnPoint.c:25
SCR_RestrictedDeployableSpawnPoint::m_eRespawnBudgetType
SCR_ESpawnPointBudgetType m_eRespawnBudgetType
Definition
SCR_RestrictedDeployableSpawnPoint.c:16
SCR_RestrictedDeployableSpawnPoint::m_bLoadoutAllowed
bool m_bLoadoutAllowed
Definition
SCR_RestrictedDeployableSpawnPoint.c:22
SCR_RestrictedDeployableSpawnPoint::SetMaxRespawns
void SetMaxRespawns(int maxRespawns)
Definition
SCR_RestrictedDeployableSpawnPoint.c:168
SCR_RestrictedDeployableSpawnPoint::m_iRespawnCount
int m_iRespawnCount
Definition
SCR_RestrictedDeployableSpawnPoint.c:20
SCR_RestrictedDeployableSpawnPoint::OnFinalizeSpawnDone_S
override void OnFinalizeSpawnDone_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnData data, IEntity entity)
Definition
SCR_RestrictedDeployableSpawnPoint.c:75
SCR_RestrictedDeployableSpawnPoint::CanReserveFor_S
override bool CanReserveFor_S(int playerId, out SCR_ESpawnResult result=SCR_ESpawnResult.SPAWN_NOT_ALLOWED)
Definition
SCR_RestrictedDeployableSpawnPoint.c:92
SCR_RestrictedDeployableSpawnPoint::SetLoadoutAllowed
void SetLoadoutAllowed(bool allow)
Definition
SCR_RestrictedDeployableSpawnPoint.c:192
SCR_RestrictedDeployableSpawnPoint::IsSpawnPointVisibleForPlayer
override bool IsSpawnPointVisibleForPlayer(int pid)
Definition
SCR_RestrictedDeployableSpawnPoint.c:60
SCR_RestrictedDeployableSpawnPoint::SetBudgetType
void SetBudgetType(SCR_ESpawnPointBudgetType budgetType)
Definition
SCR_RestrictedDeployableSpawnPoint.c:149
SCR_SpawnData
Definition
SCR_SpawnData.c:10
SCR_SpawnPoint::GetFactionKey
string GetFactionKey()
Definition
SCR_SpawnPoint.c:503
vector
Definition
vector.c:13
scripts
Game
DeployableInventoryItems
SCR_RestrictedDeployableSpawnPoint.c
Generated by
1.17.0