mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Random maintenance dirt.
The state of maintenance is now randomly generated. This includes patches of oil, trash, spiderwebs, dirt, and so forth. Utilizes a system which makes it possible to apply custom turf initializers per area.
This commit is contained in:
@@ -822,6 +822,8 @@
|
||||
#include "code\game\turfs\flooring\flooring.dm"
|
||||
#include "code\game\turfs\flooring\flooring_decals.dm"
|
||||
#include "code\game\turfs\flooring\flooring_premade.dm"
|
||||
#include "code\game\turfs\initialization\init.dm"
|
||||
#include "code\game\turfs\initialization\maintenance.dm"
|
||||
#include "code\game\turfs\simulated\floor.dm"
|
||||
#include "code\game\turfs\simulated\floor_acts.dm"
|
||||
#include "code\game\turfs\simulated\floor_attackby.dm"
|
||||
|
||||
@@ -635,6 +635,7 @@ area/space/atmosalert()
|
||||
/area/maintenance
|
||||
flags = RAD_SHIELDED
|
||||
sound_env = TUNNEL_ENCLOSED
|
||||
turf_initializer = new /datum/turf_initializer/maintenance()
|
||||
|
||||
/area/maintenance/aft
|
||||
name = "Aft Maintenance"
|
||||
|
||||
11
code/game/turfs/initialization/init.dm
Normal file
11
code/game/turfs/initialization/init.dm
Normal file
@@ -0,0 +1,11 @@
|
||||
/datum/turf_initializer/proc/initialize(var/turf/T)
|
||||
return
|
||||
|
||||
/area
|
||||
var/datum/turf_initializer/turf_initializer = null
|
||||
|
||||
/area/initialize()
|
||||
..()
|
||||
if(turf_initializer)
|
||||
for(var/turf/simulated/T in src)
|
||||
turf_initializer.initialize(T)
|
||||
60
code/game/turfs/initialization/maintenance.dm
Normal file
60
code/game/turfs/initialization/maintenance.dm
Normal file
@@ -0,0 +1,60 @@
|
||||
/datum/turf_initializer/maintenance/initialize(var/turf/simulated/T)
|
||||
if(T.density)
|
||||
return
|
||||
// Quick and dirty check to avoid placing things inside windows
|
||||
if(locate(/obj/structure/grille, T))
|
||||
return
|
||||
|
||||
var/cardinal_turfs = T.CardinalTurfs()
|
||||
|
||||
T.dirt = rand(10, 50) + rand(0, 50)
|
||||
// If a neighbor is dirty, then we get dirtier.
|
||||
var/how_dirty = dirty_neighbors(cardinal_turfs)
|
||||
for(var/i = 0; i < how_dirty; i++)
|
||||
T.dirt += rand(0,10)
|
||||
T.update_dirt()
|
||||
|
||||
if(prob(2))
|
||||
PoolOrNew(junk(), T)
|
||||
if(prob(2))
|
||||
PoolOrNew(/obj/effect/decal/cleanable/blood/oil, T)
|
||||
if(prob(25)) // Keep in mind that only "corners" get any sort of web
|
||||
attempt_web(T, cardinal_turfs)
|
||||
|
||||
var/global/list/random_junk
|
||||
/datum/turf_initializer/maintenance/proc/junk()
|
||||
if(prob(25))
|
||||
return /obj/effect/decal/cleanable/generic
|
||||
if(!random_junk)
|
||||
random_junk = subtypes(/obj/item/trash)
|
||||
random_junk += typesof(/obj/item/weapon/cigbutt)
|
||||
random_junk += /obj/effect/decal/cleanable/spiderling_remains
|
||||
random_junk += /obj/effect/decal/remains/mouse
|
||||
random_junk += /obj/effect/decal/remains/robot
|
||||
random_junk -= /obj/item/trash/plate
|
||||
random_junk -= /obj/item/trash/snack_bowl
|
||||
random_junk -= /obj/item/trash/syndi_cakes
|
||||
random_junk -= /obj/item/trash/tray
|
||||
return pick(random_junk)
|
||||
|
||||
/datum/turf_initializer/maintenance/proc/dirty_neighbors(var/list/cardinal_turfs)
|
||||
var/how_dirty = 0
|
||||
for(var/turf/simulated/T in cardinal_turfs)
|
||||
// Considered dirty if more than halfway to visible dirt
|
||||
if(T.dirt > 25)
|
||||
how_dirty++
|
||||
return how_dirty
|
||||
|
||||
/datum/turf_initializer/maintenance/proc/attempt_web(var/turf/simulated/T)
|
||||
var/turf/north_turf = get_step(T, NORTH)
|
||||
if(!north_turf || !north_turf.density)
|
||||
return
|
||||
|
||||
for(var/dir in list(WEST, EAST)) // For the sake of efficiency, west wins over east in the case of 1-tile valid spots, rather than doing pick()
|
||||
var/turf/neighbour = get_step(T, dir)
|
||||
if(neighbour && neighbour.density)
|
||||
if(dir == WEST)
|
||||
PoolOrNew(/obj/effect/decal/cleanable/cobweb, T)
|
||||
if(dir == EAST)
|
||||
PoolOrNew(/obj/effect/decal/cleanable/cobweb2, T)
|
||||
return
|
||||
@@ -25,6 +25,14 @@
|
||||
if(!tracks)
|
||||
tracks = new typepath(src)
|
||||
tracks.AddTracks(bloodDNA,comingdir,goingdir,bloodcolor)
|
||||
|
||||
/turf/simulated/proc/update_dirt()
|
||||
dirt = min(dirt++, 101)
|
||||
var/obj/effect/decal/cleanable/dirt/dirtoverlay = locate(/obj/effect/decal/cleanable/dirt, src)
|
||||
if (dirt > 50)
|
||||
if (!dirtoverlay)
|
||||
dirtoverlay = new/obj/effect/decal/cleanable/dirt(src)
|
||||
dirtoverlay.alpha = min((dirt - 50) * 5, 255)
|
||||
|
||||
/turf/simulated/Entered(atom/A, atom/OL)
|
||||
if(movement_disabled && usr.ckey != movement_disabled_exception)
|
||||
@@ -41,14 +49,7 @@
|
||||
if(plant) plant.trodden_on(M)
|
||||
|
||||
// Dirt overlays.
|
||||
dirt++
|
||||
var/obj/effect/decal/cleanable/dirt/dirtoverlay = locate(/obj/effect/decal/cleanable/dirt, src)
|
||||
if (dirt >= 50)
|
||||
if (!dirtoverlay)
|
||||
dirtoverlay = new/obj/effect/decal/cleanable/dirt(src)
|
||||
dirtoverlay.alpha = 15
|
||||
else if (dirt > 50)
|
||||
dirtoverlay.alpha = min(dirtoverlay.alpha+5, 255)
|
||||
update_dirt()
|
||||
|
||||
if(istype(M, /mob/living/carbon/human))
|
||||
var/mob/living/carbon/human/H = M
|
||||
|
||||
@@ -183,6 +183,13 @@ var/const/enterloopsanity = 100
|
||||
L.Add(t)
|
||||
return L
|
||||
|
||||
/turf/proc/CardinalTurfs()
|
||||
var/L[] = new()
|
||||
for(var/turf/simulated/T in AdjacentTurfs())
|
||||
if(T.x == src.x || T.y == src.y)
|
||||
L.Add(T)
|
||||
return L
|
||||
|
||||
/turf/proc/Distance(turf/t)
|
||||
if(get_dist(src,t) == 1)
|
||||
var/cost = (src.x - t.x) * (src.x - t.x) + (src.y - t.y) * (src.y - t.y)
|
||||
@@ -190,6 +197,7 @@ var/const/enterloopsanity = 100
|
||||
return cost
|
||||
else
|
||||
return get_dist(src,t)
|
||||
|
||||
/turf/proc/AdjacentTurfsSpace()
|
||||
var/L[] = new()
|
||||
for(var/turf/t in oview(src,1))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user