|
139 | 139 | x1_new = x0_new |
140 | 140 | y0_new = rand(CAVE_MARGIN, y0) |
141 | 141 | y1_new = rand(y0, CAVE_SIZE - CAVE_MARGIN) |
142 | | - draw_recursive_corridor(x0_new, x1_new, y0_new, y1_new, N - 1) |
| 142 | + draw_recursive_corridor(x0_new, x1_new, y0_new, y1_new, N - 1) |
143 | 143 |
|
144 | 144 | // Run one iteration of the cellular automata that processes the initial random noise |
145 | 145 | /obj/cave_generator/proc/run_cellular_automata() |
|
159 | 159 | return CAVE_FREE |
160 | 160 | else if(num_walls >= 5) |
161 | 161 | return CAVE_WALL |
162 | | - |
| 162 | + |
163 | 163 | return CAVE_FREE |
164 | 164 |
|
165 | 165 | // Get number of walls in a given range around the target tile |
|
172 | 172 | return num_walls |
173 | 173 |
|
174 | 174 | // Place points of interest on the map |
175 | | -/obj/cave_generator/proc/generate_pois(seismic_lvl) |
| 175 | +/obj/cave_generator/proc/generate_pois(seismic_lvl) |
176 | 176 |
|
177 | 177 | // Reset pois lists |
178 | 178 | pois_placed = list() |
|
217 | 217 | pois_placed_pos += list(list(x_corner_bl, y_corner_bl, x_corner_tr, y_corner_tr)) |
218 | 218 |
|
219 | 219 | // Check if a potential poi does not overlap with already placed pois |
220 | | -/obj/cave_generator/proc/check_poi_overlap(x_bl, y_bl, size_x, size_y) |
| 220 | +/obj/cave_generator/proc/check_poi_overlap(x_bl, y_bl, size_x, size_y) |
221 | 221 | if(!pois_placed.len) |
222 | 222 | // No overlap since no poi has been placed yet |
223 | 223 | return TRUE |
224 | | - |
| 224 | + |
225 | 225 | var/x_tr = x_bl + size_x |
226 | 226 | var/y_tr = y_bl + size_y |
227 | 227 | for(var/k = 1 to pois_placed.len) |
228 | 228 | // If bottom left corner is on the right or above the top right corner of already placed poi, then it's clear |
229 | 229 | // If top right corner is on the left or under the bottom left corner of already placed poi, then it's clear |
230 | 230 | // Otherwise it means they overlap |
231 | 231 | var/list/placed_pos = pois_placed_pos[k] |
232 | | - |
| 232 | + |
233 | 233 | if(!(x_bl > placed_pos[3] || y_bl > placed_pos[4] || x_tr < placed_pos[1] || y_tr < placed_pos[2])) |
234 | 234 | return FALSE |
235 | 235 | // No overlap |
236 | 236 | return TRUE |
237 | 237 |
|
238 | 238 | // Generate mineral veins once cave layout has been decided |
239 | | -/obj/cave_generator/proc/generate_mineral_veins(seismic_lvl) |
| 239 | +/obj/cave_generator/proc/generate_mineral_veins(seismic_lvl) |
240 | 240 | var/x_vein = 0 |
241 | 241 | var/y_vein = 0 |
242 | 242 | var/N_veins = rand(15, 20 * (1 + 0.5 * (seismic_lvl - SEISMIC_MIN) / (SEISMIC_MAX - SEISMIC_MIN))) |
|
250 | 250 | // Find a free spot in the cave |
251 | 251 | /obj/cave_generator/proc/find_free_spot(x_start, y_start, x_margin = 0, y_margin = 0) |
252 | 252 |
|
253 | | - var/x0 = x_start - 1 |
| 253 | + var/x0 = x_start - 1 |
254 | 254 | var/x1 = x_start + 1 |
255 | 255 | var/y0 = y_start - 1 |
256 | 256 | var/y1 = y_start + 1 |
|
270 | 270 | y_start = y1 |
271 | 271 | else |
272 | 272 | found = FALSE |
273 | | - |
| 273 | + |
274 | 274 | if(!found) |
275 | 275 | x0-- |
276 | 276 | x1++ |
277 | 277 | y0-- |
278 | 278 | y1++ |
279 | 279 | edge = (x0 <= 1 + x_margin) || (x1 >= CAVE_SIZE - x_margin) || (y0 <= 1 + y_margin) || (y1 >= CAVE_SIZE - y_margin) |
280 | | - |
| 280 | + |
281 | 281 | // Hit an edge before finding an available spot |
282 | 282 | if(!found) |
283 | 283 | return list(FALSE, 0, 0) |
|
421 | 421 |
|
422 | 422 | // Find closest available spot (wall tile near a free tile) |
423 | 423 | var/search_for = map[x_start][y_start] == CAVE_FREE ? CAVE_WALL : CAVE_FREE |
424 | | - var/x0 = x_start - 1 |
| 424 | + var/x0 = x_start - 1 |
425 | 425 | var/x1 = x_start + 1 |
426 | 426 | var/y0 = y_start - 1 |
427 | 427 | var/y1 = y_start + 1 |
|
447 | 447 | y_start = y1 |
448 | 448 | else |
449 | 449 | found = FALSE |
450 | | - |
| 450 | + |
451 | 451 | if(!found) |
452 | 452 | x0-- |
453 | 453 | x1++ |
454 | 454 | y0-- |
455 | 455 | y1++ |
456 | 456 | edge = (x0 == 1) || (x1 == CAVE_SIZE) || (y0 == 1) || (y1 == CAVE_SIZE) |
457 | | - |
| 457 | + |
458 | 458 | // Hit an edge before finding an available spot |
459 | 459 | if(!found) |
460 | 460 | return 0 |
|
477 | 477 | var/datum/cave_vein/CV = new vein_path() |
478 | 478 |
|
479 | 479 | // Place mineral vein at the available spot in a recursive manner |
480 | | - place_recursive_mineral(x_start, y_start, CV.p_spread, CV.size_max, CV.size_min, CV.mineral) |
| 480 | + place_recursive_mineral(x_start, y_start, CV.p_spread, CV.size_max, CV.size_min, CV.mineral) |
481 | 481 | return 1 |
482 | 482 |
|
483 | 483 | // Place a mineral vein in a recursive manner |
|
580 | 580 | /obj/cave_generator/proc/place_pois() |
581 | 581 | if(!LAZYLEN(pois_placed)) |
582 | 582 | return |
583 | | - |
| 583 | + |
584 | 584 | for(var/k = 1 to LAZYLEN(pois_placed)) |
585 | 585 | var/turf/corner_turf = get_turf(locate(x + pois_placed_pos[k][1], y + pois_placed_pos[k][2], z)) |
586 | 586 | pois_placed[k].load(corner_turf) |
|
597 | 597 | else |
598 | 598 | golem_type = pick(GLOB.golems_normal) |
599 | 599 | // Spawn golem at free location |
600 | | - new golem_type(get_turf(locate(x + i, y + j, z)), drill=null, parent=null) |
| 600 | + new golem_type(get_turf(locate(x + i, y + j, z))) |
601 | 601 |
|
602 | 602 | ////////////////////////////// |
603 | 603 | // Mineral veins for the cave generator |
|
0 commit comments