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

◆ RandomArtillery()

void MissionBase::RandomArtillery ( float deltaTime)
inlineprotected

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

118 {
119 // ARTY barrage
120 if (m_PlayArty)
121 {
122 // We only perform timer checks and increments if we enabled the artillery barrage
124 {
125 //We clamp to guarantee 1 and never have multiple shots on same pos, even in case of entry error
128
129 // Variables to be used in this scope
130 int randPos; // Select random position
131 Param1<vector> pos; // The value to be sent through RPC
132 array<ref Param> params; // The RPC params
133
135 {
136 // We only have one set of coordinates to send
137 randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
138 pos = new Param1<vector>(m_FiringPos[randPos]);
139 params = new array<ref Param>;
140 params.Insert(pos);
141 GetGame().RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true);
142 }
143 else
144 {
145 //We will do some extra steps to
146 /*
147 1. Send multiple coords (Send one RPC per coord set)
148 2. Ensure we don't have duplicates
149 */
150 array<int> usedIndices = new array<int>; // Will store all previusly fired upon indices
151
152 // We determine how many positions fire between MIN and MAX
153 int randFireNb = Math.RandomIntInclusive(m_MinSimultaneousStrikes, m_MaxSimultaneousStrikes);
154 for (int i = 0; i < randFireNb; i++)
155 {
156 randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
157
158 if (usedIndices.Count() <= 0 || usedIndices.Find(randPos) < 0) //We do not find the index or array is empty
159 {
160 // We prepare to send the message
161 pos = new Param1<vector>(m_FiringPos[randPos]);
162 params = new array<ref Param>;
163
164 // We send the message with this set of coords
165 params.Insert(pos);
166 GetGame().RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true);
167
168 // We store the last used value
169 usedIndices.Insert(randPos);
170 }
171 }
172 }
173
174 // Reset timer for new loop
175 m_ArtyBarrageTimer = 0.0;
176 }
177
178 m_ArtyBarrageTimer += deltaTime;
179 }
180 }
ERPCs
Определения ERPCs.c:2
proto native void RPC(Object target, int rpcType, notnull array< ref Param > params, bool guaranteed, PlayerIdentity recipient=null)
Initiate remote procedure call. When called on client, RPC is evaluated on server; When called on ser...
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
proto native CGame GetGame()

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

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