Move mining surprise shit around, start working on layout rules.

Conflicts:
	baystation12.dme
	code/game/mining_surprise.dm
	compare_report.txt
This commit is contained in:
Rob Nelson
2014-02-28 19:29:24 -05:00
committed by ZomgPonies
parent e6ce757d4c
commit 24185de680
5 changed files with 661 additions and 434 deletions
+342
View File
@@ -0,0 +1,342 @@
#define CONTIGUOUS_WALLS 1
#define CONTIGUOUS_FLOORS 2
#define TURF_FLOOR 0
#define TURF_WALL 1
var/global/list/mining_surprises = typesof(/mining_surprise)-/mining_surprise
/surprise_turf_info
var/list/types[0]
var/list/adjacents
var/turf_type=TURF_FLOOR
New()
adjacents=list(
"[NORTH]"=list(),
"[SOUTH]"=list(),
"[EAST]"=list(),
"[WEST]"=list()
)
proc/GetAdjacentTypes(var/dir)
return adjacents["[dir]"]
/surprise_room
var/list/turfs[0]
// Used for layout system.
var/list/turf_info[0]
var/size_x=0
var/size_y=0
proc/UpdateTurfs()
for(var/turf/T in turfs)
UpdateTurf(T)
proc/GetTurfs(var/ttype)
var/list/selected[0]
for(var/turf/T in turfs)
var/surprise_turf_info/Ti = GetTurfInfo(T)
if(Ti.turf_type==ttype)
selected |= T
return selected
proc/GetTurfInfo(var/turf/T)
var/surprise_turf_info/sti
if(!(T in turf_info))
sti = new
turf_info[T]=sti
else
sti = turf_info[T]
return sti
proc/UpdateTurf(var/turf/T, var/no_adjacent=0)
// List types in this turf.
var/surprise_turf_info/sti = GetTurfInfo(T)
sti.types=0
for(var/atom/A in T.contents)
sti.types |= A.type
if(no_adjacent) return
UpdateAdjacentsOfTurf(T)
proc/AddTypeToTurf(var/turf/T, var/newtype)
var/surprise_turf_info/sti = GetTurfInfo(T)
sti.types |= newtype
//UpdateAdjacentsOfTurf(T)
proc/UpdateAdjacentsOfTurf(var/turf/T)
var/surprise_turf_info/Ti = turf_info[T]
for(var/dir in cardinal)
var/turf/AT = get_step(T,dir)
if(!(AT in turfs))
return
if(!(AT in turf_info))
UpdateTurf(AT, no_adjacent=1)
var/surprise_turf_info/ATi = turf_info[AT]
// By-Ref so shit gets updated.
ATi.adjacents["[reverse_direction(dir)]"]=Ti.types
// For room layouts.
/layout_rule
var/mining_surprise/root
var/surprise_room/room
// What to place if true
var/placetype=null
var/min_to_place=0 // Force placement at ALL candidates.
var/max_to_place=0 // 0 = max amount of ALL candidates.
var/placed_times=0
var/list/decorations=list() // types, empty for no decorations
var/flags = 0
New(var/mining_surprise/_root,var/surprise_room/_room)
root=_root
room=_room
// Called in Evaluate
proc/Plop(var/turf/T)
new placetype(T)
placed_times++
room.AddTypeToTurf(T,placetype)
if(decorations.len)
var/decoration = pickweight(decorations)
new decoration(T)
room.AddTypeToTurf(T,decoration)
// Return 1 if we Plop()'d something.
// Return 0 if we didn't or something went wrong.
proc/Evaluate()
var/list/candidates=GetCandidates()
if(candidates.len==0)
return 0
if(max_to_place<=0)
max_to_place=candidates.len
var/n=candidates.len
if(min_to_place>0)
n = min(candidates.len,rand(min_to_place,max_to_place))
if(n==0)
return 0
for(var/i=0;i<n;i++)
var/turf/T = candidates[1]
candidates-=T
Plop(T)
// Return list of turfs.
proc/GetCandidates()
return list()
/layout_rule/place_adjacent
// MUST be next to any of these. Anywhere if not set.
var/list/next_to=list(
// type = list(NORTH,SOUTH,etc)
)
// MUST NOT be next to these.
var/list/not_next_to=list(
// type = list(NORTH,SOUTH,etc)
)
GetCandidates()
// Organize next_to/not_next_to so it's easier to use.
var/list/opt_nt[0]
var/list/opt_nnt[0]
var/list/candidates[0]
for(var/dir in cardinal)
var/di = "[dir]"
if(!di in opt_nt)
opt_nt[di]=list()
opt_nnt[di]=list()
for(var/t in next_to)
if(dir in next_to[t])
var/list/tl = opt_nt[di]
tl |= t
for(var/t in not_next_to)
if(dir in not_next_to[t])
var/list/tl = opt_nnt[di]
tl |= t
// Check each turf.
for(var/turf/T in room.turfs)
if(IsTurfCandidate(T,opt_nt,opt_nnt))
candidates += T
return candidates
proc/IsTurfCandidate(var/turf/T,var/list/opt_nt,var/list/opt_nnt)
var/surprise_turf_info/sti = room.GetTurfInfo(T)
for(var/dir in cardinal)
var/di = "[dir]"
for(var/_type in sti.adjacents[di])
if(_type in opt_nnt[di])
return 0
if(_type in opt_nt[di])
return 1
return 1
/mining_surprise
var/name = "Hidden Complex"
//: Types of floor to use
var/list/floortypes[0]
var/list/walltypes[0]
var/list/spawntypes[0]
var/list/fluffitems[0]
var/max_richness=2
//: How many rooms?
var/complex_max_size=1
var/room_size_max=5
var/flags=0
var/list/rooms=list()
var/list/goodies=list()
var/list/candidates=list()
var/area/asteroid/artifactroom/complex_area
proc/spawn_complex(var/atom/start_loc)
name = "[initial(name)] #[rand(100,999)]"
complex_area = new
complex_area.name = name
var/atom/pos=start_loc
var/nrooms=complex_max_size
var/maxtries=50
var/l_size_x=0
var/l_size_y=0
while(nrooms && maxtries)
var/sx=rand(3,room_size_max)
var/sy=rand(3,room_size_max)
var/o_x=l_size_x?rand(0,l_size_x):0
var/o_y=l_size_y?rand(0,l_size_y):0
var/atom/npos
switch(pick(cardinal))
if(NORTH)
npos=locate(pos.x+o_x, pos.y+sy-1, pos.z)
if(SOUTH)
npos=locate(pos.x+o_x, pos.y-sy+1, pos.z)
if(WEST)
npos=locate(pos.x-sx-1, pos.y+o_y, pos.z)
if(EAST)
npos=locate(pos.x+sx+1, pos.y+o_y, pos.z)
if(spawn_room(npos,sx,sy,1))
pos=npos
l_size_x=sx
l_size_y=sy
else if(complex_max_size==nrooms)
// Failed to make first room, abort.
del(complex_area)
return 0
else
maxtries--
continue
nrooms--
postProcessComplex()
message_admins("Complex spawned at [formatJumpTo(start_loc)]")
return 1
proc/postProcessRoom(var/surprise_room/room)
for(var/turf/floor in room.turfs)
if(floor.density) continue
for(var/turf/T in floor.AdjacentTurfs())
if(T in room.turfs)
if(T.density) continue
candidates|=T
break
proc/postProcessComplex()
for(var/i=0;i<=rand(1,max_richness);i++)
if(!candidates.len)
return
var/turf/T = pick(candidates)
var/thing = pickweight(spawntypes)
if(thing==null)
continue
new thing(T)
candidates -= T
message_admins("Goodie [thing] spawned at [formatJumpTo(T)]")
for(var/i=0;i<=rand(5,10);i++)
if(!candidates.len)
return
var/turf/T = pick(candidates)
var/thing = pickweight(fluffitems)
if(thing==null)
continue
new thing(T)
proc/spawn_room(var/atom/start_loc, var/x_size, var/y_size, var/clean=0)
if(!check_complex_placement(start_loc,x_size,y_size))
return 0
// If walls/floors are contiguous, pick them out.
var/wall_type
if(flags & CONTIGUOUS_WALLS)
wall_type = pickweight(walltypes)
var/floor_type
if(flags & CONTIGUOUS_FLOORS)
floor_type = pickweight(floortypes)
var/list/walls[0]
var/list/floors[0]
for(var/x = 0,x<x_size,x++)
for(var/y = 0,y<y_size,y++)
var/turf/cur_loc = locate(start_loc.x+x,start_loc.y+y,start_loc.z)
if(clean)
for(var/O in cur_loc)
qdel(O)
if(x == 0 || x==x_size-1 || y==0 || y==y_size-1)
walls |= cur_loc
else
floors |= cur_loc
var/surprise_room/room = new
for(var/turf/turf in walls)
if(!(flags & CONTIGUOUS_WALLS))
wall_type=pickweight(walltypes)
var/turf/T
if(dd_hasprefix("[wall_type]","/obj"))
if(!(flags & CONTIGUOUS_FLOORS))
floor_type=pickweight(floortypes)
T=new floor_type(turf)
new wall_type(T)
else
//testing("Creating wall of type [wall_type].")
T=new wall_type(turf)
room.turfs += T
complex_area.contents += T
var/surprise_turf_info/Ti = room.GetTurfInfo(T)
Ti.turf_type=TURF_WALL
for(var/turf/turf in floors)
if(!(flags & CONTIGUOUS_FLOORS))
floor_type=pickweight(floortypes)
var/turf/T = new floor_type(turf)
room.turfs += T
complex_area.contents += T
var/surprise_turf_info/Ti = room.GetTurfInfo(T)
Ti.turf_type=TURF_FLOOR
room.UpdateTurfs()
postProcessRoom(room)
rooms += room
message_admins("Room spawned at [formatJumpTo(start_loc)]")
return 1
+183
View File
@@ -0,0 +1,183 @@
///////////////////
// /tg/ Surprises
///////////////////
/mining_surprise/organharvest
walltypes = list(
/turf/simulated/wall/r_wall=2,
/turf/simulated/wall=2,
/turf/simulated/mineral/random/high_chance=1
)
floortypes = list(
/turf/simulated/floor=1,
/turf/simulated/floor/engine=1
)
spawntypes = list(
/obj/item/device/mass_spectrometer/adv=1,
/obj/item/clothing/glasses/hud/health=1,
/obj/machinery/bot/medbot/mysterious=1
)
fluffitems = list(
/obj/effect/decal/cleanable/blood=5,
/obj/item/weapon/reagent_containers/food/snacks/appendix=2, // OM NOM
/obj/structure/closet/crate/freezer=2,
/obj/machinery/optable=1,
/obj/item/weapon/scalpel=1,
/obj/item/weapon/storage/firstaid/regular=3,
/obj/item/weapon/tank/anesthetic=1,
///obj/item/weapon/surgical_drapes=2
)
flags = CONTIGUOUS_WALLS | CONTIGUOUS_FLOORS
complex_max_size=3
room_size_max=7
/mining_surprise/cult
name = "Hidden Temple"
walltypes = list(
/turf/simulated/wall/cult=3,
/turf/simulated/mineral/random/high_chance=1
)
floortypes = list(
/turf/simulated/floor/engine/cult=1
)
spawntypes = list(
/mob/living/simple_animal/hostile/creature=1,
// /obj/item/organ/heart=2,
/obj/item/device/soulstone=1
)
fluffitems = list(
/obj/effect/gateway=1,
/obj/effect/gibspawner=1,
/obj/structure/cult/talisman=1,
/obj/item/toy/crayon/red=2,
/obj/effect/decal/cleanable/blood=4,
/obj/structure/table/woodentable=2,
/obj/item/weapon/ectoplasm=3
)
flags = CONTIGUOUS_WALLS | CONTIGUOUS_FLOORS
complex_max_size=3
room_size_max=5
/mining_surprise/wizden
name = "Hidden Den"
walltypes = list(
/turf/simulated/wall/mineral/plasma=3,
/turf/simulated/mineral/random/high_chance=1
)
floortypes = list(
/turf/simulated/floor/wood=1
)
spawntypes = list(
// /vg/: Let's not. /obj/item/weapon/veilrender/vealrender=1,
// /vg/: /obj/item/key=1
/obj/item/clothing/glasses/monocle=5,
)
fluffitems = list(
/obj/structure/safe/floor=1,
// /obj/structure/wardrobe=1,
/obj/item/weapon/storage/belt/soulstone=1,
/obj/item/trash/candle=3,
/obj/item/weapon/dice=3,
/obj/item/weapon/staff=2,
/obj/effect/decal/cleanable/dirt=3,
/obj/item/weapon/coin/mythril=3
)
flags = CONTIGUOUS_WALLS | CONTIGUOUS_FLOORS
complex_max_size=1
room_size_max=7
/mining_surprise/cavein
name="Cave-In"
walltypes = list(
/turf/simulated/mineral/random/high_chance=1
)
floortypes = list(
/turf/simulated/floor/plating/airless/asteroid=1
)
spawntypes = list(
/obj/mecha/working/ripley/mining=1,
/obj/item/weapon/pickaxe/jackhammer=2,
/obj/item/weapon/pickaxe/diamonddrill=2
)
fluffitems = list(
/obj/effect/decal/cleanable/blood=3,
/obj/effect/decal/remains/human=1,
/obj/item/clothing/under/overalls=1,
/obj/item/weapon/reagent_containers/food/snacks/grown/chili=1,
/obj/item/weapon/tank/oxygen/red=2
)
complex_max_size=3
room_size_max=7
/mining_surprise/human/hitech
complex_max_size=3
room_size_max=7
walltypes = list(
/turf/simulated/wall/r_wall=1
)
floortypes = list(
/turf/simulated/floor/greengrid=1,
/turf/simulated/floor/bluegrid=1
)
spawntypes = list(
/obj/item/weapon/pickaxe/plasmacutter=1,
/obj/machinery/shieldgen=1,
/obj/item/weapon/cell/hyper=1
)
fluffitems = list(
/obj/structure/table/reinforced=2,
/obj/item/weapon/stock_parts/scanning_module/phasic=3,
/obj/item/weapon/stock_parts/matter_bin/super=3,
/obj/item/weapon/stock_parts/manipulator/pico=3,
/obj/item/weapon/stock_parts/capacitor/super=3,
/obj/item/device/pda/clear=1
)
/mining_surprise/human/speakeasy
complex_max_size=3
room_size_max=7
floortypes = list(
/turf/simulated/floor,
/turf/simulated/floor/wood)
spawntypes = list(
/obj/item/weapon/melee/energy/sword/pirate=1,
/obj/structure/closet/syndicate/resources=2
)
fluffitems = list(
/obj/structure/table/woodentable=2,
/obj/structure/reagent_dispensers/beerkeg=1,
/obj/item/weapon/spacecash/c500=4,
/obj/item/weapon/reagent_containers/food/drinks/shaker=1,
/obj/item/weapon/reagent_containers/food/drinks/bottle/wine=3,
/obj/item/weapon/reagent_containers/food/drinks/bottle/whiskey=3,
/obj/item/clothing/shoes/laceup=2
)
/mining_surprise/human/plantlab
complex_max_size=2
room_size_max=7
spawntypes = list(
/obj/item/weapon/gun/energy/floragun=1,
/obj/item/seeds/novaflowerseed=2,
/obj/item/seeds/bluespacetomatoseed=2
)
fluffitems = list(
// /obj/structure/flora/kirbyplants=1,
/obj/structure/table/reinforced=2,
/obj/machinery/hydroponics=1,
/obj/effect/glowshroom/single=2,
/obj/item/weapon/reagent_containers/syringe/antitoxin=2,
/obj/item/weapon/reagent_containers/glass/bottle/diethylamine=3,
/obj/item/weapon/reagent_containers/glass/bottle/ammonia=3
)
+133
View File
@@ -0,0 +1,133 @@
/* Not quite there yet
#define ANY_SIDE list(NORTH,SOUTH,EAST,WEST)
/layout_rule/place_adjacent/workbench
placetype=/obj/structure/table
min_to_place=3
min_to_place=7
next_to=list(
/turf/simulated/wall = ANY_SIDE,
/turf/simulated/wall/r_wall = ANY_SIDE,
)
// MUST NOT be next to these.
not_next_to=list()
decorations=list(
/obj/item/weapon/screwdriver=2,
/obj/item/weapon/crowbar=2,
/obj/item/stack/metal=1,
/obj/item/weapon/wrench=2
)
/layout_rule/place_adjacent/workbench/wooden
placetype=/obj/structure/table/woodentable
/layout_rule/place_adjacent/workbench/reinforced
placetype=/obj/structure/table/reinforced
/layout_rule/place_adjacent/chair
placetype=/obj/structure/stool/bed/chair
min_to_place=1
min_to_place=2
next_to=list(
/obj/structure/table = ANY_SIDE,
)
// MUST NOT be next to these.
not_next_to=list(
/obj/structure/stool/bed/chair = ANY_SIDE
)
//flags = FACE_MATCH
/layout_rule/place_adjacent/chair/wooden
placetype=/obj/structure/stool/bed/chair/wooden
min_to_place=1
min_to_place=2
next_to=list(
/obj/structure/table/wooden = ANY_SIDE,
)
// MUST NOT be next to these.
not_next_to=list(
/obj/structure/stool/bed/chair = ANY_SIDE
)
//flags = FACE_MATCH
*/
/mining_surprise/human
name="Hidden Complex"
floortypes = list(
/turf/simulated/floor/airless=95,
/turf/simulated/floor/plating/airless=5
)
walltypes = list(
/turf/simulated/wall=100
)
spawntypes = list(
/obj/item/weapon/pickaxe/silver =4,
/obj/item/weapon/pickaxe/drill =4,
/obj/item/weapon/pickaxe/jackhammer =4,
/obj/item/weapon/pickaxe/diamond =3,
/obj/item/weapon/pickaxe/diamonddrill =3,
/obj/item/weapon/pickaxe/gold =3,
/obj/item/weapon/pickaxe/plasmacutter =2,
/obj/structure/closet/syndicate/resources =2,
/obj/item/weapon/melee/energy/sword/pirate =1,
/obj/mecha/working/ripley/mining =1
)
complex_max_size=2
flags = CONTIGUOUS_WALLS | CONTIGUOUS_FLOORS
/mining_surprise/alien_nest
name="Hidden Nest"
floortypes = list(
/turf/simulated/floor/plating/airless/asteroid=100
)
walltypes = list(
/turf/simulated/mineral/random/high_chance=1
)
spawntypes = list(
/obj/item/clothing/mask/facehugger =4,
/obj/mecha/working/ripley/mining =1
)
fluffitems = list(
/obj/effect/decal/remains/human = 5,
/obj/effect/decal/cleanable/xenoblood = 5,
/obj/effect/decal/mecha_wreckage/ripley = 1
)
complex_max_size=6
room_size_max=7
var/const/eggs_left=10 // Per complex
var/turf/weeds[0] // Turfs with weeds.
postProcessComplex()
..()
var/list/all_floors=list()
for(var/surprise_room/room in rooms)
var/list/w_cand=room.GetTurfs(TURF_FLOOR)
all_floors |= w_cand
var/egged=0
while(w_cand.len>0)
var/turf/weed_turf = pick(w_cand)
w_cand -= weed_turf
if(weed_turf.density)
continue
if(locate(/obj/effect/alien) in weed_turf)
continue
if(weed_turf && !egged)
new /obj/effect/alien/weeds/node(weed_turf)
weeds += weed_turf
break
for(var/e=0;e<eggs_left;e++)
var/turf/egg_turf = pick(all_floors)
if(egg_turf && !(locate(/obj/effect/alien) in egg_turf))
new /obj/effect/alien/egg(egg_turf)