Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BarrageEffectModule.c
Go to the documentation of this file.
1[BaseContainerProps(configRoot: true)]
3{
4 [Attribute("5", params: "1 inf 1", desc: "Min amount of Projectiles in barrage", category: "Barrage")]
6
7 [Attribute("5", params: "1 inf 1", desc: "Max amount of Projectiles in barrage", category: "Barrage")]
9
10 [Attribute("1", params: "0 inf 0.05", desc: "Min delay between Projectiles in barrage", category: "Barrage")]
11 protected float m_fMinProjectileDelay;
12
13 [Attribute("2", params: "0 inf 0.05", desc: "Max delay between Projectiles in barrage", category: "Barrage")]
14 protected float m_fMaxProjectileDelay;
15
16 [Attribute("1", desc: "How many barrages there should be", category: "Barrage")]
17 protected int m_iBarrageAmount;
18
19 [Attribute("5", desc: "Min delay between barrages", params: "0 inf 0", category: "Barrage")]
20 protected float m_fMinBarrageDelay;
21
22 [Attribute("10", desc: "Max delay between barrages", params: "0 inf 0", category: "Barrage")]
23 protected float m_fMaxBarrageDelay;
24
25 [Attribute(desc: "If true allows the module to be paused", category: "General")]
26 protected bool m_bCanPause;
27
28 [Attribute(desc: "If true allows the module to loop aka continuously execute", category: "General")]
29 protected bool m_bCanLoop;
30
31 [Attribute(desc: "If true will continuously execute module", category: "General")]
32 protected bool m_bIsLooping;
33
34 //~ How many projectiles for current barrage are left
35 protected int m_iProjectilesLeftInBarrage = -1;
36
37 //~ How many projectiles where set at the start of the barrage
38 protected int m_iTotalProjectilesInBarrage = -1;
39
40 //~ Current waiting time left before the next projectile is spawned
42
43 //~ How many barrages are left
44 protected int m_iBarragesLeft = -1;
45
46 //~ Make sure m_fMinProjectileDelay and m_fMaxProjectileDelay attribute step is set to this value. Never set to 0 or less
47 protected const float UPDATE_TIME = 0.05;
48
49 //~ If the system is currently waiting for the next barrage. This makes sure the Callque is removed on delete
51
52 //------------------------------------------------------------------------------------------------
53 override void Init(notnull IEntity owner, notnull SCR_EffectsModuleComponent effectModuleParent)
54 {
55 super.Init(owner, effectModuleParent);
56
57 if (UPDATE_TIME <= 0)
58 Debug.Error2("SCR_BarrageEffectsModule", "'UPDATE_TIME' is set to 0 or less!");
59
61 {
62 Print("'SCR_EffectsModule', Effect is set to looping but it cannot loop! So looping is set false", LogLevel.WARNING);
63 SetLooping(false);
64 }
65
67 {
68 Print("'SCR_EffectsModule', m_fMinProjectileDelay is greater than m_fMaxProjectileDelay! This is not allowed. m_fMinProjectileDelay is set equal to m_fMaxProjectileDelay", LogLevel.WARNING);
70 }
71
73 {
74 Print("'SCR_EffectsModule', m_fMinBarrageDelay is greater than m_fMaxBarrageDelay! This is not allowed. m_fMinBarrageDelay is set equal to m_fMaxBarrageDelay", LogLevel.WARNING);
76 }
77
79 {
80 Print("'SCR_EffectsModule', m_iMinProjectilesEachBarrage is greater than m_fMaxBarrageDelay! This is not allowed. m_iMinProjectilesEachBarrage is set equal to m_iMaxProjectilesEachBarrage", LogLevel.WARNING);
82 }
83 }
84
85 //------------------------------------------------------------------------------------------------
86 //~ (Server Only)
87 override void OnModuleExecute()
88 {
89 // May already be set from e.g. save-data
90 if (m_iBarragesLeft == -1)
92
94 {
97 }
98
100 }
101
102 //------------------------------------------------------------------------------------------------
103 override bool CanPause()
104 {
106 }
107
108 //------------------------------------------------------------------------------------------------
109 override void SetPaused(bool paused)
110 {
111 if (paused == IsPaused())
112 return;
113
114 super.SetPaused(paused);
115
116 if (m_bIsPaused)
117 m_EffectsModuleParent.CancelModuleServer();
118 else
119 StartBarrage();
120 }
121
122 //------------------------------------------------------------------------------------------------
123 override bool CanLoop()
124 {
125 return m_bCanLoop && !m_bCheckForDelete;
126 }
127
128 //------------------------------------------------------------------------------------------------
129 override void SetLooping(bool loop)
130 {
131 if (!CanLoop())
132 return;
133
134 m_bIsLooping = loop;
135 }
136
137 //------------------------------------------------------------------------------------------------
138 //~ (Server Only)
139 override void CancelModule()
140 {
141 super.CancelModule();
142
144 {
145 GetGame().GetCallqueue().Remove(BarrageUpdateLoop);
146 }
147
149 {
151 GetGame().GetCallqueue().Remove(StartBarrage);
152 }
153 }
154
155 //------------------------------------------------------------------------------------------------
160
161 //------------------------------------------------------------------------------------------------
163 protected void SetTotalProjectilesInBarrage(int projectiles)
164 {
165 m_iTotalProjectilesInBarrage = projectiles;
166 }
167
168 //------------------------------------------------------------------------------------------------
173
174 //------------------------------------------------------------------------------------------------
176 protected void SetProjectilesLeftInBarrage(int projectiles)
177 {
178 m_iProjectilesLeftInBarrage = projectiles;
179 }
180
181 //------------------------------------------------------------------------------------------------
183 {
184 return m_iBarragesLeft;
185 }
186
187 //------------------------------------------------------------------------------------------------
189 protected void SetBarragesLeft(int barrages)
190 {
191 m_iBarragesLeft = barrages;
192 }
193
194 //------------------------------------------------------------------------------------------------
195 //~ Start executing the barrage (Server Only)
196 protected void StartBarrage()
197 {
199 {
201 GetGame().GetCallqueue().Remove(StartBarrage);
202 }
203
205 {
208 }
209
210 //~ No time so spawn a entity each frame
212 {
214 GetGame().GetCallqueue().CallLater(BarrageUpdateLoop, 0, true);
215 return;
216 }
217
218 //~ Time is set so calculate delay
220 GetGame().GetCallqueue().CallLater(BarrageUpdateLoop, UPDATE_TIME * 1000, true);
221 }
222
223 //------------------------------------------------------------------------------------------------
224 //~ Update loop that Spawns an new entity every time the m_fCurrentProjectileDelay reaches 0 (Server Only)
225 protected void BarrageUpdateLoop()
226 {
227 ChimeraWorld world = GetGame().GetWorld();
228 if (world.IsGameTimePaused())
229 return;
230
231 if (!m_Owner || m_Owner.IsDeleted())
232 {
233 Print("SCR_BarrageEffectsModule.BarrageUpdateLoop: Effect module owner no longer exists. Spawning of " + m_sModuleEntityPrefab + " aborted.", LogLevel.WARNING);
234 GetGame().GetCallqueue().Remove(BarrageUpdateLoop);
235 return;
236 }
237
238 //~ Update time
240
241 //~ Do not execute yet
243 return;
244
246
247 //~ Spawn effect
248 m_EffectsModuleParent.SpawnEffectEntity();
250
251 //~ Done executing
253 {
254 GetGame().GetCallqueue().Remove(BarrageUpdateLoop);
255 BarrageDone();
256 }
257 //~ Instant call close together
259 {
261 }
262 }
263
264 //------------------------------------------------------------------------------------------------
265 //~ The barrage is done, check if there are more barrages, if so wait and start again otherwise set module done (Server Only)
266 protected void BarrageDone()
267 {
268 if (!m_bIsLooping)
270
271 if (m_iBarragesLeft <= 0)
272 {
273 //~ Done executing
274 m_EffectsModuleParent.DoneExecutingModule();
275 return;
276 }
277
278 //~ Reset the Zone data target positions
279 m_ModuleZoneData.ResetPositions(this);
280
283 }
284}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Debug.c:13
Definition Math.c:13
void SetProjectilesLeftInBarrage(int projectiles)
void SetTotalProjectilesInBarrage(int projectiles)
override void Init(notnull IEntity owner, notnull SCR_EffectsModuleComponent effectModuleParent)
override void SetLooping(bool loop)
override void SetPaused(bool paused)
ResourceName m_sModuleEntityPrefab
SCR_EffectsModuleComponent m_EffectsModuleParent
ref SCR_BaseEffectsModulePositionData m_ModuleZoneData
static float RandomFloatInclusive(float min, float max)
Definition SCR_Math.c:34
static int RandomIntInclusive(int min, int max)
Definition SCR_Math.c:95
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute