Don't like ads? PRO users don't see any ads ;-)
Guest

Building Generator - DM

By: MeekMill on Jun 22nd, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  *      Random City Generator v1.0.0
  3.  *
  4.  *      @author: Desean Jackson "Meek Mill"
  5.  *      @date: June 22,2012
  6.  *
  7.  */
  8.  
  9. world/New()
  10.         ..()
  11.  
  12.         spawn(1) generateBuildings()
  13.  
  14. proc
  15.  
  16.         generateBuildings()
  17.  
  18.                 var/building_location = locate(/area/building_location)
  19.  
  20.                 for(var/area/building_location/b in world) for(var/x in global.get_boxes(building_location))
  21.                         var/height = rand(2, 5), width = 5, turf/pick
  22.  
  23.                         for(var/turf/y in x)
  24.                                 if(y.x >= (pick ? pick.x : world.maxx)) continue
  25.                                 pick = y
  26.  
  27.                         for(var/turf/y in block(pick, locate(pick.x + width - 1, pick.y + height - 1, pick.z)))
  28.                                 new/turf/building(y)
  29.  
  30.         get_boxes(area/a)
  31.                 . = new/list()
  32.  
  33.                 main:
  34.                         for(var/turf/t in a)
  35.  
  36.                                 for(var/x in .) for(var/y in x)
  37.                                         if(y == t) continue main
  38.  
  39.                                 . += null
  40.                                 .[length(.)] = new/list
  41.                                 global.get_touch(t, a, .[length(.)])
  42.  
  43.         get_touch(turf/t, area/a, array[])
  44.  
  45.                 for(var/turf/x in range(1, t))
  46.                         if( (x.loc != a) || (x in array) ) continue
  47.                         array += x
  48.                         .(x, a, array)
  49.  
  50. #define DEBUG