Skip to content

Commit

Permalink
Merge pull request #3523 from MistakeNot4892/pottery
Browse files Browse the repository at this point in the history
Generalizing diggable turfs.
  • Loading branch information
out-of-phaze authored Dec 13, 2023
2 parents 5a4feaf + a9a47de commit ff6d85e
Show file tree
Hide file tree
Showing 36 changed files with 269 additions and 200 deletions.
18 changes: 9 additions & 9 deletions code/__defines/tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
#define TOOL_PEN /decl/tool_archetype/pen

// Surgical tools.
#define TOOL_SCALPEL /decl/tool_archetype/scalpel
#define TOOL_RETRACTOR /decl/tool_archetype/retractor
#define TOOL_HEMOSTAT /decl/tool_archetype/hemostat
#define TOOL_SAW /decl/tool_archetype/saw
#define TOOL_CAUTERY /decl/tool_archetype/cautery
#define TOOL_SUTURES /decl/tool_archetype/sutures
#define TOOL_BONE_GEL /decl/tool_archetype/bone_gel
#define TOOL_BONE_SETTER /decl/tool_archetype/bone_setter
#define TOOL_DRILL /decl/tool_archetype/surgical_drill
#define TOOL_SCALPEL /decl/tool_archetype/scalpel
#define TOOL_RETRACTOR /decl/tool_archetype/retractor
#define TOOL_HEMOSTAT /decl/tool_archetype/hemostat
#define TOOL_SAW /decl/tool_archetype/saw
#define TOOL_CAUTERY /decl/tool_archetype/cautery
#define TOOL_SUTURES /decl/tool_archetype/sutures
#define TOOL_BONE_GEL /decl/tool_archetype/bone_gel
#define TOOL_BONE_SETTER /decl/tool_archetype/bone_setter
#define TOOL_SURGICAL_DRILL /decl/tool_archetype/surgical_drill

// Tool qualities (positive multplier)
#define TOOL_QUALITY_WORST 0.1
Expand Down
4 changes: 2 additions & 2 deletions code/__defines/turfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#define EXT_EDGE_VOLCANIC (12 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_DIRT (20 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_BARREN (21 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_MUD (21 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_MUD_DARK (22 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_CLAY (21 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_MUD (22 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_SAND (30 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_CHLORINE_SAND (31 * EXT_LAYER_CONSTANT)
#define EXT_EDGE_WATER (40 * EXT_LAYER_CONSTANT)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/meteor/meteors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ var/global/list/meteors_cataclysm = list(\
hits = 1
hitpwr = 3
dropamt = 1
meteordrop = /obj/item/stack/material/ore/glass
meteordrop = /obj/item/stack/material/ore/sand

//Medium-sized
/obj/effect/meteor/medium
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/stacks/rods.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
update_icon()
throwforce = round(0.25*material.get_edge_damage())
force = round(0.5*material.get_blunt_damage())
set_extension(src, /datum/extension/tool, list(TOOL_DRILL = TOOL_QUALITY_WORST))
set_extension(src, /datum/extension/tool, list(TOOL_SURGICAL_DRILL = TOOL_QUALITY_WORST))

/obj/item/stack/material/rods/update_state_from_amount()
if(max_icon_state && amount > 0.5*max_amount)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/surgery_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

/obj/item/surgicaldrill/Initialize()
. = ..()
set_extension(src, /datum/extension/tool, list(TOOL_DRILL = TOOL_QUALITY_DEFAULT))
set_extension(src, /datum/extension/tool, list(TOOL_SURGICAL_DRILL = TOOL_QUALITY_DEFAULT))

/*
* Scalpel
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/flora/potted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
snd_cut = 'sound/effects/break_ceramic.ogg'
material = /decl/material/solid/stone/ceramic
matter = list(
/decl/material/solid/clay = MATTER_AMOUNT_REINFORCEMENT,
/decl/material/solid/sand = MATTER_AMOUNT_REINFORCEMENT,
/decl/material/solid/clay = MATTER_AMOUNT_REINFORCEMENT,
/decl/material/solid/sand = MATTER_AMOUNT_REINFORCEMENT,
/decl/material/solid/organic/plantmatter = MATTER_AMOUNT_SECONDARY, //#TODO: Maybe eventually drop the plant, or some seeds or something?
)

Expand Down
28 changes: 12 additions & 16 deletions code/game/objects/structures/pit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

/obj/structure/pit/attackby(obj/item/W, mob/user)
if(IS_SHOVEL(W))
if(W.do_tool_interaction(TOOL_SHOVEL, user, src, 5 SECONDS, "[open ? "filling up" : "digging open"]", "[open ? "fills up" : "digs open"]"))
var/dig_message = open ? "filling in" : "excavating"
if(W.do_tool_interaction(TOOL_SHOVEL, user, src, 5 SECONDS, dig_message, dig_message))
if(open)
close(user)
else
open()
else
to_chat(user, SPAN_NOTICE("You stop shoveling."))
to_chat(user, SPAN_NOTICE("You stop digging."))
return TRUE

if (!open && istype(W, /obj/item/stack/material) && W.material?.type == /decl/material/solid/organic/wood)
Expand Down Expand Up @@ -47,7 +48,7 @@
desc = initial(desc)
open = TRUE
for(var/atom/movable/A in src)
A.forceMove(src.loc)
A.dropInto(loc)
update_icon()

/obj/structure/pit/proc/close(var/user)
Expand All @@ -56,22 +57,17 @@
open = FALSE

//If we close the pit without anything inside, just leave the soil undisturbed
var/turf/T = get_turf(src)
if(!length((T.contents - src)))
if(isturf(loc))
for(var/atom/movable/A in loc)
if(A != src && !A.anchored && A != user && A.simulated)
A.forceMove(src)
if(!length(contents))
qdel(src)
return

for(var/atom/movable/A in T)
if(!A.anchored && A != user && A.simulated)
A.forceMove(src)

update_icon()
else
update_icon()

/obj/structure/pit/return_air()
if(open && loc)
return loc.return_air()
else
return null
return open && loc?.return_air()

/obj/structure/pit/proc/digout(mob/escapee)
var/breakout_time = 1 //2 minutes by default
Expand Down
30 changes: 11 additions & 19 deletions code/game/turfs/exterior/_exterior.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
turf_flags = TURF_FLAG_BACKGROUND | TURF_IS_HOLOMAP_PATH
zone_membership_candidate = TRUE
var/base_color
var/diggable = 1
var/dirt_color = "#7c5e42"
var/possible_states = 0
var/icon_edge_layer = -1
Expand All @@ -19,6 +18,15 @@
///Overrides the level's strata for this turf.
var/strata_override
var/decl/material/material
/// Whether or not sand/clay has been dug up here.
var/dug = FALSE

/turf/exterior/can_be_dug()
return !density && !is_open()

/turf/exterior/clear_diggable_resources()
dug = TRUE
..()

/turf/exterior/Initialize(mapload, no_update_icon = FALSE)

Expand Down Expand Up @@ -78,25 +86,9 @@
for(var/obj/O in src)
O.hide(0)

/turf/exterior/attackby(obj/item/C, mob/user)
//#TODO: Add some way to dig to lower levels?
if(diggable && IS_SHOVEL(C))
if(C.do_tool_interaction(TOOL_SHOVEL, user, src, 5 SECONDS))
new /obj/structure/pit(src)
diggable = FALSE
else
to_chat(user, SPAN_NOTICE("You stop shoveling."))
return TRUE

if(istype(C, /obj/item/stack/tile))
var/obj/item/stack/tile/T = C
T.try_build_turf(user, src)
return TRUE

. = ..()

/turf/exterior/explosion_act(severity)
SHOULD_CALL_PARENT(FALSE)
SHOULD_CALL_PARENT(TRUE)
..()
if(!istype(src, get_base_turf_by_area(src)) && (severity == 1 || (severity == 2 && prob(40))))
ChangeTurf(get_base_turf_by_area(src))

Expand Down
4 changes: 3 additions & 1 deletion code/game/turfs/exterior/exterior_concrete.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ var/global/exterior_broken_states = icon_states('icons/turf/exterior/broken.dmi'
name = "concrete"
desc = "A flat expanse of artificial stone-like artificial material."
icon = 'icons/turf/exterior/concrete.dmi'
diggable = FALSE
var/broken
var/burned

/turf/exterior/concrete/can_be_dug()
return FALSE

/turf/exterior/concrete/flooded
flooded = TRUE
color = COLOR_LIQUID_WATER
Expand Down
22 changes: 17 additions & 5 deletions code/game/turfs/exterior/exterior_mud.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
/turf/exterior/clay
name = "clay"
desc = "Thick, claggy clay."
icon = 'icons/turf/exterior/mud_light.dmi'
icon_edge_layer = EXT_EDGE_CLAY
footstep_type = /decl/footsteps/mud

/turf/exterior/clay/get_diggable_resources()
return dug ? null : list(/obj/item/stack/material/ore/clay = list(3, 2))

/turf/exterior/clay/flooded
flooded = TRUE

/turf/exterior/mud
name = "mud"
desc = "Thick, claggy and waterlogged."
icon = 'icons/turf/exterior/mud_light.dmi'
desc = "Thick, waterlogged mud."
icon = 'icons/turf/exterior/mud_dark.dmi'
icon_edge_layer = EXT_EDGE_MUD
footstep_type = /decl/footsteps/mud

/turf/exterior/mud/dark
icon = 'icons/turf/exterior/mud_dark.dmi'
icon_edge_layer = EXT_EDGE_MUD_DARK
/turf/exterior/mud/flooded
flooded = TRUE

/turf/exterior/dry
name = "dry mud"
Expand Down
3 changes: 3 additions & 0 deletions code/game/turfs/exterior/exterior_rock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
icon = 'icons/turf/exterior/rock.dmi'
icon_edge_layer = EXT_EDGE_VOLCANIC

/turf/exterior/rock/can_be_dug()
return FALSE

/turf/exterior/rock/Initialize(mapload, no_update_icon)
. = ..()
material = SSmaterials.get_strata_material_type(src)
Expand Down
10 changes: 8 additions & 2 deletions code/game/turfs/exterior/exterior_sand.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
dirt_color = "#ae9e66"
footstep_type = /decl/footsteps/sand
icon = 'icons/turf/exterior/sand.dmi'
icon_edge_layer = EXT_EDGE_SAND
icon_edge_layer = EXT_EDGE_SAND
icon_has_corners = TRUE
possible_states = 4

/turf/exterior/sand/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
if((temperature > T0C + 1700 && prob(5)) || temperature > T0C + 3000)
melt()

/turf/exterior/sand/get_diggable_resources()
return dug ? null : list(/obj/item/stack/material/ore/sand = list(3, 2))

/turf/exterior/sand/melt()
if(icon_state != "glass")
SetName("molten silica")
desc = "A glassed patch of sand."
icon_state = "glass"
icon_edge_layer = -1
diggable = FALSE
clear_diggable_resources()

/turf/exterior/sand/can_be_dug()
return icon_state != "glass" && ..()
3 changes: 3 additions & 0 deletions code/game/turfs/exterior/exterior_seafloor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
icon_edge_layer = EXT_EDGE_SEAFLOOR
var/detail_decal

/turf/exterior/seafloor/get_diggable_resources()
return dug ? null : list(/obj/item/stack/material/ore/sand = list(3, 2))

/turf/exterior/seafloor/flooded
flooded = TRUE
color = COLOR_LIQUID_WATER
Expand Down
1 change: 1 addition & 0 deletions code/game/turfs/exterior/exterior_wall.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var/global/list/natural_walls = list()
queue_icon_update()

/turf/exterior/wall/explosion_act(severity)
SHOULD_CALL_PARENT(FALSE)
if(severity == 1 || (severity == 2 && prob(40)))
dismantle_wall()

Expand Down
3 changes: 3 additions & 0 deletions code/game/turfs/exterior/exterior_water.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
O.reagents.add_reagent(reagent_type, fill_amount)
return TRUE
. = ..()

/turf/exterior/water/can_be_dug()
return FALSE
3 changes: 2 additions & 1 deletion code/game/turfs/simulated/floor_acts.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/turf/simulated/floor/explosion_act(severity)
SHOULD_CALL_PARENT(FALSE)
SHOULD_CALL_PARENT(TRUE)
..()
if(severity == 1)
ChangeTurf(get_base_turf_by_area(src))
else if(severity == 2)
Expand Down
5 changes: 0 additions & 5 deletions code/game/turfs/simulated/floor_attackby.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
if(!C || !user)
return 0

if(istype(C, /obj/item/stack/tile/roof))
var/obj/item/stack/tile/roof/T = C
T.try_build_turf(user, src)
return TRUE

if(IS_COIL(C) || (flooring && istype(C, /obj/item/stack/material/rods)))
return ..(C, user)

Expand Down
54 changes: 53 additions & 1 deletion code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@

/turf/explosion_act(severity)
SHOULD_CALL_PARENT(FALSE)
return
if(severity == 1 || (severity == 2 && prob(70)))
drop_diggable_resources()

/turf/proc/is_solid_structure()
return !(turf_flags & TURF_FLAG_BACKGROUND) || locate(/obj/structure/lattice, src)
Expand Down Expand Up @@ -197,6 +198,23 @@

/turf/attackby(obj/item/W, mob/user)

if(is_floor())

if(istype(W, /obj/item/stack/tile))
var/obj/item/stack/tile/T = W
T.try_build_turf(user, src)
return TRUE

if(IS_SHOVEL(W) && can_be_dug())
if(get_diggable_resources())
if(W.do_tool_interaction(TOOL_SHOVEL, user, src, 4 SECONDS))
drop_diggable_resources()
else if(can_dig_pit())
try_dig_pit(user, W)
else
to_chat(user, SPAN_WARNING("There is nothing to be dug out of \the [src]."))
return TRUE

if(ATOM_IS_OPEN_CONTAINER(W) && W.reagents)
var/obj/effect/fluid/F = locate() in src
if(F && F.reagents?.total_volume >= FLUID_PUDDLE)
Expand Down Expand Up @@ -544,3 +562,37 @@

/turf/proc/resolve_to_actual_turf()
return src

/// Return an assoc list of resource item type to a base and a random component
/// ex. return list(/obj/item/stack/material/ore/sand = list(3, 2))
/turf/proc/get_diggable_resources()
return null

/turf/proc/clear_diggable_resources()
SHOULD_CALL_PARENT(TRUE)
update_icon()

/turf/proc/can_be_dug()
return FALSE

/turf/proc/drop_diggable_resources()
SHOULD_CALL_PARENT(TRUE)
var/list/diggable_resources = get_diggable_resources()
if(!length(diggable_resources))
return
for(var/resource_type in diggable_resources)
var/list/resource_amounts = diggable_resources[resource_type]
LAZYADD(., new resource_type(src, resource_amounts[1] + rand(resource_amounts[2])))
clear_diggable_resources()


/turf/proc/can_dig_pit()
return can_be_dug() && !(locate(/obj/structure/pit) in src)

/turf/proc/try_dig_pit(var/mob/user, var/obj/item/tool)
if(!user || !tool || tool.do_tool_interaction(TOOL_SHOVEL, user, src, 4 SECONDS))
return dig_pit()
return null

/turf/proc/dig_pit()
return can_dig_pit() && new /obj/structure/pit(src)
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
descriptor = "grass exoplanet"
land_type = /turf/exterior/wildgrass
water_type = /turf/exterior/water
coast_type = /turf/exterior/mud/dark
coast_type = /turf/exterior/mud
water_level_min = 3
flora_prob = 10
grass_prob = 50
Expand Down
Loading

0 comments on commit ff6d85e

Please sign in to comment.