DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ RandomArtillery()

void MissionBase::RandomArtillery ( float deltaTime)
inlineprotected

См. определение в файле missionServer.c строка 163

164 {
165 // ARTY barrage
166 if (m_PlayArty)
167 {
168 // We only perform timer checks and increments if we enabled the artillery barrage
170 {
171 //We clamp to guarantee 1 and never have multiple shots on same pos, even in case of entry error
174
175 // Variables to be used in this scope
176 int randPos; // Select random position
177 Param1<vector> pos; // The value to be sent through RPC
178 array<ref Param> params; // The RPC params
179
181 {
182 // We only have one set of coordinates to send
183 randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
184 pos = new Param1<vector>(m_FiringPos[randPos]);
185 params = new array<ref Param>;
186 params.Insert(pos);
187 g_Game.RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true);
188 }
189 else
190 {
191 //We will do some extra steps to
192 /*
193 1. Send multiple coords (Send one RPC per coord set)
194 2. Ensure we don't have duplicates
195 */
196 array<int> usedIndices = new array<int>; // Will store all previusly fired upon indices
197
198 // We determine how many positions fire between MIN and MAX
199 int randFireNb = Math.RandomIntInclusive(m_MinSimultaneousStrikes, m_MaxSimultaneousStrikes);
200 for (int i = 0; i < randFireNb; i++)
201 {
202 randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
203
204 if (usedIndices.Count() <= 0 || usedIndices.Find(randPos) < 0) //We do not find the index or array is empty
205 {
206 // We prepare to send the message
207 pos = new Param1<vector>(m_FiringPos[randPos]);
208 params = new array<ref Param>;
209
210 // We send the message with this set of coords
211 params.Insert(pos);
212 g_Game.RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true);
213
214 // We store the last used value
215 usedIndices.Insert(randPos);
216 }
217 }
218 }
219
220 // Reset timer for new loop
221 m_ArtyBarrageTimer = 0.0;
222 }
223
224 m_ArtyBarrageTimer += deltaTime;
225 }
226 }
DayZGame g_Game
Определения DayZGame.c:3942
ERPCs
Определения ERPCs.c:2
ref array< vector > m_FiringPos
Определения missionServer.c:26
float m_ArtyBarrageTimer
Определения missionServer.c:19
int m_MaxSimultaneousStrikes
Определения missionServer.c:25
bool m_PlayArty
Определения missionServer.c:22
float m_ArtyDelay
Определения missionServer.c:23
int m_MinSimultaneousStrikes
Определения missionServer.c:24

Перекрестные ссылки Math::Clamp(), g_Game, m_ArtyBarrageTimer, m_ArtyDelay, m_FiringPos, m_MaxSimultaneousStrikes, m_MinSimultaneousStrikes, m_PlayArty и Math::RandomIntInclusive().

Используется в OnUpdate().