MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / grow

Method grow

game/state/battle/battlehazard.cpp:259–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259void BattleHazard::grow(GameState &state)
260{
261 if (hazardType->fire)
262 {
263 auto &map = tileObject->map;
264
265 // Try to light up adjacent stuff on fire
266
267 for (int x = position.x - 1; x <= position.x + 1; x++)
268 {
269 for (int y = position.y - 1; y <= position.y + 1; y++)
270 {
271 expand(state, map, {x, y, position.z}, 0);
272 }
273 }
274 for (int z = position.z - 1; z <= position.z + 1; z++)
275 {
276 expand(state, map, {position.x, position.y, z}, 0);
277 }
278
279 // Now spread smoke
280
281 if (randBoundsExclusive(state.rng, 0, 100) >= HAZARD_SPREAD_CHANCE)
282 {
283 return;
284 }
285
286 for (int x = position.x - 1; x <= position.x + 1; x++)
287 {
288 for (int y = position.y - 1; y <= position.y + 1; y++)
289 {
290 if (expand(state, map, {x, y, position.z}, 0, true))
291 {
292 return;
293 }
294 }
295 }
296 for (int z = position.z - 1; z <= position.z + 1; z++)
297 {
298 if (expand(state, map, {position.x, position.y, z}, 0, true))
299 {
300 return;
301 }
302 }
303 }
304 else
305 {
306 if (power == 0)
307 {
308 return;
309 }
310 if (randBoundsExclusive(state.rng, 0, 100) >= HAZARD_SPREAD_CHANCE)
311 {
312 return;
313 }
314 auto &map = tileObject->map;
315 int newTTL = lifetime - age;
316

Callers 1

initBattleMethod · 0.45

Calls 1

randBoundsExclusiveFunction · 0.85

Tested by

no test coverage detected