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_GameModeLastStand.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
SCR_GameModeLastStandClass
:
SCR_BaseGameModeClass
3
{
4
};
5
6
//------------------------------------------------------------------------------------------------
7
class
SCR_GameModeLastStand
:
SCR_BaseGameMode
8
{
9
[
Attribute
(
"10"
,
UIWidgets
.EditBox,
"How long between clearing the last wave and a new one"
)]
10
float
m_TimeoutBetweenWaves;
11
12
[
Attribute
(
"4"
,
UIWidgets
.EditBox,
"How many groups spawned each wave"
)]
13
int
m_InitialGroupsCount;
14
15
[
Attribute
(
"1"
,
UIWidgets
.EditBox,
"How many new groups should spawn each round"
)]
16
int
m_AddedGroupsPerRound;
17
18
[
Attribute
(
""
,
UIWidgets
.ResourceNamePicker,
"What group type should spawn"
)]
19
ResourceName
m_GroupType;
20
21
[
Attribute
(
"USSR"
,
UIWidgets
.EditBox,
"Enemy faction key"
)]
22
protected
FactionKey
m_sEnemyFactionKey
;
23
24
[
Attribute
(
"US"
,
UIWidgets
.EditBox,
"Friendly faction key"
)]
25
protected
FactionKey
m_sFriendlyFactionKey
;
26
27
int
m_iGroupsToSpawn
;
28
int
m_iRoundNumber
;
29
30
Widget
m_wRoot
;
31
TextWidget
m_wText
;
32
ref array<IEntity>
m_aEnemySoldiers
;
33
ref array<SCR_AIGroup>
m_aGroups
;
34
ref array<SCR_SpawnPoint>
m_aEnemySpawnPoints
;
35
ref array<SCR_SpawnPoint>
m_aPlayerSpawnPoints
;
36
float
m_fCurrentTimeout
;
37
AIWaypoint
m_AttackWP
;
38
39
//------------------------------------------------------------------------------------------------
40
override
void
EOnFrame
(
IEntity
owner,
float
timeSlice)
41
{
42
//PrintString("printing");
43
super.EOnFrame(owner, timeSlice);
44
45
if
(
m_fCurrentTimeout
> 0)
46
{
47
m_fCurrentTimeout
-= timeSlice;
48
if
(
m_fCurrentTimeout
< 0)
49
{
50
m_fCurrentTimeout
= 0;
51
m_iRoundNumber
++;
52
if
(
m_iRoundNumber
> 0)
53
{
54
SpawnEnemies
(
m_iRoundNumber
);
55
Print
(
"Sending next wave of enemies."
);
56
ShowHint
(
"Sending next wave of enemies."
, 5);
57
}
58
}
59
}
60
else
if
(
m_aEnemySoldiers
.Count() == 0)
61
{
62
Print
(
"All enemies are dead. Wave cleared."
);
63
ShowHint
(
"All enemies are dead. Wave cleared."
, 5);
64
m_fCurrentTimeout
= m_TimeoutBetweenWaves;
65
}
66
}
67
68
//------------------------------------------------------------------------------------------------
69
void
ShowHint
(
string
text,
float
showTime)
70
{
71
if
(!
m_wText
|| !
m_wRoot
)
72
return
;
73
74
m_wText
.SetText(text);
75
AnimateWidget
.
Opacity
(
m_wRoot
, 1, 1);
76
77
ScriptCallQueue
queue =
GetGame
().GetCallqueue();
78
queue.CallLater(this.
HideHint
, showTime * 1000);
79
}
80
81
//------------------------------------------------------------------------------------------------
82
void
HideHint
()
83
{
84
if
(
m_wRoot
)
85
AnimateWidget
.
Opacity
(
m_wRoot
, 0, 1);
86
}
87
88
//------------------------------------------------------------------------------------------------
89
void
SpawnEnemies
(
int
round)
90
{
91
if
(
m_aEnemySpawnPoints
.Count() == 0)
92
return
;
93
94
// Clean up groups
95
for
(
int
i =
m_aGroups
.Count() - 1; i >= 0; i--)
96
{
97
delete
m_aGroups
[i];
98
}
99
m_aGroups
.Clear();
100
m_aEnemySoldiers
.Clear();
101
102
m_iGroupsToSpawn
= m_InitialGroupsCount + (round - 1) * m_AddedGroupsPerRound;
103
104
for
(
int
i = 0; i <
m_iGroupsToSpawn
; i++)
105
{
106
RandomGenerator
generator =
new
RandomGenerator
;
107
generator.SetSeed(
Math
.RandomInt(0,100));
108
109
SCR_SpawnPoint
spawnPoint =
m_aEnemySpawnPoints
.GetRandomElement();
110
if
(!spawnPoint)
111
return
;
112
113
vector
position
= generator.GenerateRandomPointInRadius(0, 2, spawnPoint.GetOrigin());
114
position
[1] = spawnPoint.GetOrigin()[1];
115
EntitySpawnParams
params
=
EntitySpawnParams
();
116
params
.TransformMode = ETransformMode.WORLD;
117
params
.Transform[3] =
position
;
118
119
Resource
res =
Resource
.Load(m_GroupType);
120
SCR_AIGroup
newGrp =
SCR_AIGroup
.Cast(
GetGame
().SpawnEntityPrefab(res, null,
params
));
121
m_aGroups
.Insert(newGrp);
122
123
array<AIAgent> agents =
new
array<AIAgent>;
124
125
newGrp.GetAgents(agents);
126
foreach
(AIAgent agent : agents)
127
{
128
if
(agent)
129
{
130
m_aEnemySoldiers
.Insert(agent.GetControlledEntity());
131
}
132
}
133
134
if
(
m_AttackWP
)
135
{
136
newGrp.
AddWaypointToGroup
(
m_AttackWP
);
137
}
138
}
139
}
140
141
//------------------------------------------------------------------------------------------------
142
override
void
OnControllableDestroyed
(
IEntity
entity,
IEntity
killerEntity, notnull
Instigator
instigator)
143
{
144
super.OnControllableDestroyed(entity, killerEntity, instigator);
145
146
m_aEnemySoldiers
.RemoveItemOrdered(entity);
147
}
148
149
//------------------------------------------------------------------------------------------------
150
override
void
EOnInit
(
IEntity
owner)
151
{
152
super.EOnInit(owner);
153
154
m_fCurrentTimeout
= m_TimeoutBetweenWaves;
155
156
m_wRoot
=
GetGame
().GetWorkspace().CreateWidgets(
"{EA1CC57D868E94F9}UI/layouts/HUD/Hint.layout"
);
157
if
(
m_wRoot
)
158
{
159
m_wText
=
TextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Text"
));
160
TextWidget
title =
TextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Title"
));
161
if
(title)
162
title.SetText(
"LAST STAND"
);
163
164
m_wRoot
.SetOpacity(0);
165
}
166
BaseWorld
world = owner.
GetWorld
();
167
m_AttackWP
= AIWaypoint.Cast(world.FindEntityByName(
"WP1"
));
168
m_aEnemySoldiers
= {};
169
m_aGroups
= {};
170
m_aPlayerSpawnPoints
= {};
171
m_aEnemySpawnPoints
= {};
172
array<SCR_SpawnPoint> spawnPoints = {};
173
spawnPoints =
SCR_SpawnPoint
.GetSpawnPoints();
174
175
FactionKey
faction;
176
SCR_SpawnPoint
spawnPoint;
177
for
(
int
i = spawnPoints.Count() - 1; i >= 0; i--)
178
{
179
spawnPoint = spawnPoints[i];
180
if
(!spawnPoint)
181
continue
;
182
183
faction = spawnPoint.
GetFactionKey
();
184
if
(faction ==
m_sEnemyFactionKey
)
185
m_aEnemySpawnPoints
.Insert(spawnPoint);
186
187
if
(faction ==
m_sFriendlyFactionKey
)
188
m_aPlayerSpawnPoints
.Insert(spawnPoint);
189
}
190
}
191
};
192
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
position
vector position
Definition
SCR_DestructibleTreeV2.c:30
SpawnEnemies
void SpawnEnemies()
Definition
SCR_GameModeCleanSweep.c:263
ShowHint
void ShowHint()
Definition
SCR_PerceivedFactionManagerComponent.c:54
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Opacity
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition
AnimateWidget.c:167
BaseWorld
Definition
BaseWorld.c:13
FactionKey
Definition
FactionKey.c:3
IEntity
Definition
IEntity.c:13
IEntity::GetWorld
proto external BaseWorld GetWorld()
Instigator
Definition
Instigator.c:13
Math
Definition
Math.c:13
RandomGenerator
Definition
RandomGenerator.c:13
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_AIGroup::AddWaypointToGroup
void AddWaypointToGroup(AIWaypoint waypoint)
Definition
SCR_AIGroup.c:1947
SCR_BaseGameModeClass
Definition
SCR_BaseGameMode.c:13
SCR_BaseGameMode::SCR_BaseGameMode
void SCR_BaseGameMode(IEntitySource src, IEntity parent)
Definition
SCR_BaseGameMode.c:2292
SCR_GameModeLastStandClass
Definition
SCR_GameModeLastStand.c:3
SCR_GameModeLastStand
Definition
SCR_GameModeLastStand.c:8
SCR_GameModeLastStand::EOnFrame
override void EOnFrame(IEntity owner, float timeSlice)
Definition
SCR_GameModeLastStand.c:40
SCR_GameModeLastStand::SpawnEnemies
void SpawnEnemies(int round)
Definition
SCR_GameModeLastStand.c:89
SCR_GameModeLastStand::m_aPlayerSpawnPoints
ref array< SCR_SpawnPoint > m_aPlayerSpawnPoints
Definition
SCR_GameModeLastStand.c:35
SCR_GameModeLastStand::EOnInit
override void EOnInit(IEntity owner)
Definition
SCR_GameModeLastStand.c:150
SCR_GameModeLastStand::m_aGroups
ref array< SCR_AIGroup > m_aGroups
Definition
SCR_GameModeLastStand.c:33
SCR_GameModeLastStand::m_sEnemyFactionKey
FactionKey m_sEnemyFactionKey
Definition
SCR_GameModeLastStand.c:22
SCR_GameModeLastStand::OnControllableDestroyed
override void OnControllableDestroyed(IEntity entity, IEntity killerEntity, notnull Instigator instigator)
Definition
SCR_GameModeLastStand.c:142
SCR_GameModeLastStand::m_aEnemySpawnPoints
ref array< SCR_SpawnPoint > m_aEnemySpawnPoints
Definition
SCR_GameModeLastStand.c:34
SCR_GameModeLastStand::m_aEnemySoldiers
ref array< IEntity > m_aEnemySoldiers
Definition
SCR_GameModeLastStand.c:32
SCR_GameModeLastStand::m_iGroupsToSpawn
int m_iGroupsToSpawn
Definition
SCR_GameModeLastStand.c:27
SCR_GameModeLastStand::HideHint
void HideHint()
Definition
SCR_GameModeLastStand.c:82
SCR_GameModeLastStand::m_sFriendlyFactionKey
FactionKey m_sFriendlyFactionKey
Definition
SCR_GameModeLastStand.c:25
SCR_GameModeLastStand::ShowHint
void ShowHint(string text, float showTime)
Definition
SCR_GameModeLastStand.c:69
SCR_GameModeLastStand::m_AttackWP
AIWaypoint m_AttackWP
Definition
SCR_GameModeLastStand.c:37
SCR_GameModeLastStand::m_fCurrentTimeout
float m_fCurrentTimeout
Definition
SCR_GameModeLastStand.c:36
SCR_GameModeLastStand::m_iRoundNumber
int m_iRoundNumber
Definition
SCR_GameModeLastStand.c:28
SCR_GameModeLastStand::m_wText
TextWidget m_wText
Definition
SCR_GameModeLastStand.c:31
SCR_GameModeLastStand::m_wRoot
Widget m_wRoot
Definition
SCR_GameModeLastStand.c:30
SCR_SpawnPoint
Spawn point entity defines positions on which players can possibly spawn.
Definition
SCR_SpawnPoint.c:28
SCR_SpawnPoint::GetFactionKey
string GetFactionKey()
Definition
SCR_SpawnPoint.c:503
ScriptCallQueue
ScriptCallQueue Class provide "lazy" calls - when we don't want to execute function immediately but l...
Definition
tools.c:53
TextWidget
Definition
TextWidget.c:16
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
vector
Definition
vector.c:13
EntitySpawnParams
void EntitySpawnParams()
Definition
gameLib.c:130
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
GameMode
SCR_GameModeLastStand.c
Generated by
1.17.0