MORE progress.

This commit is contained in:
Arokha Sieyes
2017-02-13 01:20:51 -05:00
parent 9817d67461
commit 41169628da
4 changed files with 97 additions and 48 deletions

View File

@@ -190,7 +190,7 @@ var/list/gamemode_cache = list()
var/list/admin_levels= list(2) // Defines which Z-levels which are for admin functionality, for example including such areas as Central Command and the Syndicate Shuttle
var/list/contact_levels = list(1, 5) // Defines which Z-levels which, for example, a Code Red announcement may affect
var/list/player_levels = list(1, 3, 4, 5, 6) // Defines all Z-levels a character can typically reach
var/list/sealed_levels = list() // Defines levels that do not allow random transit at the edges.
var/list/sealed_levels = list(7) // Defines levels that do not allow random transit at the edges.
// Event settings
var/expected_round_length = 3 * 60 * 60 * 10 // 3 hours

View File

@@ -10,7 +10,6 @@
//Dimensions
var/coresize = 3 //The size of the center square
var/armsize = 3 //(max)Length of the 'arms' on the sides
var/width = 9
//Other Attribs
@@ -33,32 +32,34 @@
// ^type1
// type2 //These are items/objects at the coordinate
// type3 //This would be object 3 at x2,y2
var/list/map = list()
var/list/map
//Builds an empty map
/datum/rogue/asteroid/New(var/core, var/arm, var/tw, var/tu)
/datum/rogue/asteroid/New(var/core, var/tw, var/tu)
rm_controller.dbg("A(n): New asteroid, with: C:[core], TW:[tw], TU:[tu].")
if(core)
coresize = core
if(arm)
armsize = arm
if(tw)
type_wall = tw
if(tu)
type_under = tu
width = coresize+(armsize*2)
world << "calling xy_lists with [width]"
xy_lists(width)
width = coresize*3
rm_controller.dbg("A(n): My width is [width].")
map = new/list(width,width,0)
rm_controller.dbg("A(n): Created empty map lists. Map now has [map.len] X-lists.")
//Adds something to a spot in the asteroid map
/datum/rogue/asteroid/proc/spot_add(var/x,var/y,var/thing)
if(!x || !y || !thing)
return
rm_controller.dbg("A(sa): Adding [thing] at [x],[y] in the map.")
var/list/work = map[x][y]
work += thing
work.Add(thing)
rm_controller.dbg("A(n): [x],[y] now contains [work.len] items.")
//Removes something from a spot in the asteroid map
/datum/rogue/asteroid/proc/spot_remove(var/x,var/y,var/thing)
@@ -66,7 +67,7 @@
return
var/list/work = map[x][y]
work -= thing
work.Add(thing)
//Just removes everything from a spot in the asteroid map
/datum/rogue/asteroid/proc/spot_clear(var/x,var/y)
@@ -75,21 +76,3 @@
var/list/work = map[x][y]
work.Cut()
//Given a size it will create the lists if they don't already exist
/datum/rogue/asteroid/proc/xy_lists(var/gridsize)
map = list()
world << "Now in xy_lists"
for(var/Ix=0, Ix < gridsize, Ix++)
world << "Making new 'x' list for x=[Ix]"
var/list/curr_x = list()
for(var/Iy=0, Iy < gridsize, Iy++)
world << "Making new 'y' list for y=[Iy]"
var/list/curr_y = list()
curr_x[++curr_x.len] = curr_y
world << "Inserted new 'y', x=[Ix] list now [curr_x.len] long"
map[++map.len] = curr_x
world << "Inserted new 'x', map now [map.len] long"
return map

View File

@@ -13,6 +13,8 @@ var/datum/controller/rogue/rm_controller = new()
//The current mining zone that the shuttle goes to and whatnot
var/area/current
var/debugging = 0
/datum/controller/rogue/New()
//How many zones are we working with here
for(var/area/asteroid/rogue/A in world)
@@ -23,4 +25,9 @@ var/datum/controller/rogue/rm_controller = new()
if(!manual) //If it was called manually somehow, then don't start the timer, just decay now.
spawn(RM_DIFF_DECAY_TIME)
decay()
return difficulty
return difficulty
/datum/controller/rogue/proc/dbg(var/message)
ASSERT(message) //I want a stack trace if there's no message
if(debugging)
world << "<span class='warning'>[message]</span>"

View File

@@ -44,61 +44,120 @@
///////////////////////////////
///// Asteroid Generation /////
///////////////////////////////
/datum/rogue/zonemaster/proc/generate_asteroid(var/core_min = 2, var/core_max = 5, var/arm_min = 1, var/arm_max = 3)
var/datum/rogue/asteroid/A = new(rand(core_min,core_max),rand(arm_min,arm_max))
//Find the bounding box, basically
A.width = A.coresize+(A.armsize*2)
/datum/rogue/zonemaster/proc/generate_asteroid(var/core_min = 2, var/core_max = 5)
var/datum/rogue/asteroid/A = new(rand(core_min,core_max))
rm_controller.dbg("ZM(ga): New asteroid with C:[A.coresize], TW:[A.type_wall].")
//Add the core to the asteroid's map
var/start = round((A.width-A.coresize)/2)
var/start = A.coresize+1
rm_controller.dbg("ZM(ga): My starting point for the core is [start].")
for(var/x = 1; x <= A.coresize, x++)
rm_controller.dbg("ZM(ga): Doing core x[x].")
for(var/y = 1; y <= A.coresize, y++)
rm_controller.dbg("ZM(ga): Doing core y[y], about to spot_add [start+x],[start+y], [A.type_wall].")
A.spot_add(start+x, start+y, A.type_wall)
//Add the arms to the asteroid's map
//TODO
//Bottom arms
for(var/x = A.coresize+1, x <= A.coresize*2, x++) //Basically for the width of the core, make arms.
rm_controller.dbg("ZM(ga): Bottom. My starting point for the first arm is x[x].")
var/curr_arm = rand(0,A.coresize)
rm_controller.dbg("ZM(ga): Bottom. Going to make an arm of length [curr_arm] for x[x].")
for(var/y = A.coresize, y > A.coresize-curr_arm, y--) //Start at bottom edge of the core, work down
A.spot_add(x,y,A.type_wall)
//Top arms
for(var/x = A.coresize+1, x <= A.coresize*2, x++) //Basically for the width of the core, make arms.
rm_controller.dbg("ZM(ga): Top. My starting point for the first arm is x[x].")
var/curr_arm = rand(0,A.coresize)
rm_controller.dbg("ZM(ga): Top. Going to make an arm of length [curr_arm] for x[x].")
for(var/y = (A.coresize*2)+1, y < ((A.coresize*2)+1)+curr_arm, y++) //Start at top edge of the core, work up.
A.spot_add(x,y,A.type_wall)
//Right arms
for(var/y = A.coresize+1, y <= A.coresize*2, y++) //Basically for the height of the core, make arms.
rm_controller.dbg("ZM(ga): Right. My starting point for the first arm is y[y].")
var/curr_arm = rand(0,A.coresize)
rm_controller.dbg("ZM(ga): Right. Going to make an arm of length [curr_arm] for y[y].")
for(var/x = (A.coresize*2)+1, x <= ((A.coresize*2)+1)+curr_arm, x++) //Start at right edge of core, work right.
A.spot_add(x,y,A.type_wall)
//Left arms
for(var/y = A.coresize+1, y <= A.coresize*2, y++) //Basically for the width of the core, make arms.
rm_controller.dbg("ZM(ga): Left. My starting point for the first arm is y[y].")
var/curr_arm = rand(0,A.coresize)
rm_controller.dbg("ZM(ga): Left. Going to make an arm of length [curr_arm] for y[y].")
for(var/x = A.coresize, x > A.coresize-curr_arm, x--)
A.spot_add(x,y,A.type_wall)
//Diagonals
rm_controller.dbg("ZM(ga): Asteroid generation done.")
return A
/datum/rogue/zonemaster/proc/enrich_asteroid(var/list/asteroid)
/datum/rogue/zonemaster/proc/place_asteroid(var/datum/rogue/asteroid/A,var/obj/asteroid_spawner/SP)
ASSERT(SP && A)
rm_controller.dbg("ZM(pa): Placing at point [SP.x],[SP.y],[SP.z].")
SP.myasteroid = A
//Top-left corner of our bounding box
var/TLx = SP.x - (A.width/2)
var/TLy = SP.y - (A.width/2)
//Bottom-left corner of our bounding box
var/BLx = SP.x - (A.width/2)
var/BLy = SP.y - (A.width/2)
rm_controller.dbg("ZM(pa): BLx is [BLx], BLy is [BLy].")
for(var/x in A.map)
for(var/y in A.map[x])
for(var/turf/T in A.map[x][y])
var/turf/P = locate(TLx+x,TLy+y,SP.z) //Find previous turf
P.ChangeTurf(T)
//TODO spawn everything that's not a turf
rm_controller.dbg("ZM(pa): The asteroid has [A.map.len] X-lists.")
for(var/Ix=1, Ix <= A.map.len, Ix++)
var/list/curr_x = A.map[Ix]
rm_controller.dbg("ZM(pa): Now doing X:[Ix] which has [curr_x.len] Y-lists.")
for(var/Iy=1, Iy <= curr_x.len, Iy++)
var/list/curr_y = curr_x[Iy]
rm_controller.dbg("ZM(pa): Now doing Y:[Iy] which has [curr_y.len] items.")
for(var/T in curr_y)
rm_controller.dbg("ZM(pa): Doing entry [T] in Y-list [Iy].")
if(ispath(T,/turf)) //We're spawning a turf
rm_controller.dbg("ZM(pa): Turf-generate mode.")
var/turf/P = locate(BLx+Ix,BLy+Iy,SP.z) //Find previous turf
rm_controller.dbg("ZM(pa): Checking [BLx+Ix],[BLy+Iy],[SP.z] for turf.")
rm_controller.dbg("ZM(pa): Replacing [P.type] with [T].")
P.ChangeTurf(T)
//TODO spawn everything else. XD
///////////////////////////////
///// Zone Population /////////
///////////////////////////////
//Overall 'prepare' proc (marks as ready)
/datum/rogue/zonemaster/proc/prepare_zone()
/datum/rogue/zonemaster/proc/prepare_zone(var/delay = 0)
clean = 0
//TODO take difficulty into account
rm_controller.dbg("ZM(p): Randomizing spawns.")
randomize_spawns()
rm_controller.dbg("ZM(p): [spawns.len] picked.")
for(var/obj/asteroid_spawner/SP in spawns)
rm_controller.dbg("ZM(p): Spawning at [SP.x],[SP.y],[SP.z].")
var/datum/rogue/asteroid/A = generate_asteroid()
rm_controller.dbg("ZM(p): Placing asteroid.")
place_asteroid(A,SP)
rm_controller.dbg("ZM(p): Zone generation done.")
ready = 1
//Randomize the landmarks that are enabled
/datum/rogue/zonemaster/proc/randomize_spawns(var/chance = 50)
rm_controller.dbg("ZM(rs): Previously [spawns.len] spawns.")
spawns.Cut()
rm_controller.dbg("ZM(rs): Now [spawns.len] spawns.")
for(var/obj/asteroid_spawner/SP in myarea.asteroid_spawns)
if(prob(chance))
spawns += SP
rm_controller.dbg("ZM(rs): Picked [spawns.len] new spawns with [chance]% chance.")
//Call asteroid generation and place over and over proc