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

◆ RandomArtillery()

void MissionBase::RandomArtillery ( float deltaTime)
inlineprotected

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

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