diff --git a/code/game/turfs/closed/minerals.dm b/code/game/turfs/closed/minerals.dm index 693e8aac02e..803554a6bbf 100644 --- a/code/game/turfs/closed/minerals.dm +++ b/code/game/turfs/closed/minerals.dm @@ -662,6 +662,7 @@ /turf/closed/mineral/gibtonite mineralAmt = 1 + icon_state = "rock_Gibtonite_inactive" scan_state = "rock_Gibtonite" var/det_time = 8 //Countdown till explosion, but also rewards the player for how close you were to detonation when you defuse it var/stage = GIBTONITE_UNSTRUCK //How far into the lifecycle of gibtonite we are @@ -766,7 +767,7 @@ defer_change = TRUE /turf/closed/mineral/gibtonite/ice - icon_state = "icerock_Gibtonite" + icon_state = "icerock_Gibtonite_inactive" icon = MAP_SWITCH('icons/turf/walls/icerock_wall.dmi', 'icons/turf/mining.dmi') base_icon_state = "icerock_wall" smoothing_flags = SMOOTH_BITMASK | SMOOTH_BORDER diff --git a/code/game/turfs/open/_open.dm b/code/game/turfs/open/_open.dm index 00fa4546768..240b9765948 100644 --- a/code/game/turfs/open/_open.dm +++ b/code/game/turfs/open/_open.dm @@ -8,6 +8,49 @@ var/clawfootstep = null var/heavyfootstep = null + /// Determines the type of damage overlay that will be used for the tile + var/damaged_dmi = null + var/broken = FALSE + var/burnt = FALSE + + +/// Returns a list of every turf state considered "broken". +/// Will be randomly chosen if a turf breaks at runtime. +/turf/open/proc/broken_states() + return list() + +/// Returns a list of every turf state considered "burnt". +/// Will be randomly chosen if a turf is burnt at runtime. +/turf/open/proc/burnt_states() + return list() + +/turf/open/break_tile() + if(isnull(damaged_dmi) || broken) + return FALSE + broken = TRUE + update_appearance() + return TRUE + +/turf/open/burn_tile() + if(isnull(damaged_dmi) || burnt) + return FALSE + burnt = TRUE + update_appearance() + return TRUE + +/turf/open/update_overlays() + if(isnull(damaged_dmi)) + return ..() + . = ..() + if(broken) + . += mutable_appearance(damaged_dmi, pick(broken_states())) + else if(burnt) + var/list/burnt_states = burnt_states() + if(burnt_states.len) + . += mutable_appearance(damaged_dmi, pick(burnt_states)) + else + . += mutable_appearance(damaged_dmi, pick(broken_states())) + //direction is direction of travel of A /turf/open/zPassIn(atom/movable/A, direction, turf/source) if(direction == DOWN) diff --git a/code/game/turfs/open/asteroid.dm b/code/game/turfs/open/asteroid.dm index af5340c2da2..a7f78ec5904 100644 --- a/code/game/turfs/open/asteroid.dm +++ b/code/game/turfs/open/asteroid.dm @@ -6,6 +6,7 @@ desc = "It's coarse and rough and gets everywhere." baseturfs = /turf/open/misc/asteroid icon = 'icons/turf/floors.dmi' + damaged_dmi = 'icons/turf/floors.dmi' icon_state = "asteroid" base_icon_state = "asteroid" @@ -24,13 +25,23 @@ var/obj/item/stack/dig_result = /obj/item/stack/ore/glass /// Whether the turf has been dug or not var/dug = FALSE - /// Icon state to use when broken - var/broken_state = "asteroid_dug" /// Percentage chance of receiving a bonus worm var/worm_chance = 30 +/turf/open/misc/asteroid/broken_states() + if(initial(dug)) + return list(icon_state) + return list("[base_icon_state]_dug") + /turf/open/misc/asteroid/break_tile() - icon_state = broken_state + . = ..() + if(!.) + return FALSE + dug = TRUE + return TRUE + +/turf/open/misc/asteroid/burn_tile() + return /turf/open/misc/asteroid/Initialize(mapload) var/proper_name = name @@ -42,10 +53,11 @@ /// Drops itemstack when dug and changes icon /turf/open/misc/asteroid/proc/getDug() dug = TRUE + broken = TRUE new dig_result(src, 5) if (prob(worm_chance)) new /obj/item/food/bait/worm(src) - icon_state = "[base_icon_state]_dug" + update_appearance() /// If the user can dig the turf /turf/open/misc/asteroid/proc/can_dig(mob/user) @@ -99,6 +111,10 @@ base_icon_state = "asteroid_dug" icon_state = "asteroid_dug" +/turf/open/misc/asteroid/dug/broken_states() + return list("asteroid_dug") + + /turf/open/misc/asteroid/lavaland_atmos initial_gas_mix = LAVALAND_DEFAULT_ATMOS planetary_atmos = TRUE @@ -115,7 +131,6 @@ GLOBAL_LIST_EMPTY(dug_up_basalt) base_icon_state = "basalt" floor_variance = 15 dig_result = /obj/item/stack/ore/glass/basalt - broken_state = "basalt_dug" /turf/open/misc/asteroid/basalt/getDug() set_light(0) @@ -171,10 +186,10 @@ GLOBAL_LIST_EMPTY(dug_up_basalt) name = "snow" desc = "Looks cold." icon = 'icons/turf/snow.dmi' + damaged_dmi = 'icons/turf/snow.dmi' baseturfs = /turf/open/misc/asteroid/snow icon_state = "snow" base_icon_state = "snow" - broken_state = "snow_dug" initial_gas_mix = FROZEN_ATMOS slowdown = 2 flags_1 = NONE @@ -182,17 +197,19 @@ GLOBAL_LIST_EMPTY(dug_up_basalt) bullet_sizzle = TRUE bullet_bounce_sound = null dig_result = /obj/item/stack/sheet/mineral/snow - var/burnt = FALSE /turf/open/misc/asteroid/snow/burn_tile() if(!burnt) visible_message(span_danger("[src] melts away!.")) slowdown = 0 burnt = TRUE - icon_state = "snow_dug" + update_appearance() return TRUE return FALSE +/turf/open/misc/grass/burnt_states() + return list("snow_dug") + /turf/open/misc/asteroid/snow/icemoon baseturfs = /turf/open/openspace/icemoon initial_gas_mix = ICEMOON_DEFAULT_ATMOS @@ -222,9 +239,13 @@ GLOBAL_LIST_EMPTY(dug_up_basalt) barefootstep = FOOTSTEP_HARD_BAREFOOT clawfootstep = FOOTSTEP_HARD_CLAW heavyfootstep = FOOTSTEP_GENERIC_HEAVY + damaged_dmi = null /turf/open/misc/asteroid/snow/ice/break_tile() - return + return FALSE + +/turf/open/misc/asteroid/snow/ice/burn_tile() + return FALSE /turf/open/misc/asteroid/snow/ice/icemoon baseturfs = /turf/open/misc/asteroid/snow/ice/icemoon @@ -232,9 +253,6 @@ GLOBAL_LIST_EMPTY(dug_up_basalt) planetary_atmos = TRUE slowdown = 0 -/turf/open/misc/asteroid/snow/ice/burn_tile() - return FALSE - /turf/open/misc/asteroid/snow/airless initial_gas_mix = AIRLESS_ATMOS worm_chance = 0 @@ -272,7 +290,6 @@ GLOBAL_LIST_EMPTY(dug_up_basalt) base_icon_state = "moon" floor_variance = 40 dig_result = /obj/item/stack/ore/glass/basalt - broken_state = "moon_dug" /turf/open/misc/asteroid/moon/dug //When you want one of these to be already dug. dug = TRUE diff --git a/code/game/turfs/open/floor.dm b/code/game/turfs/open/floor.dm index a1f31099c5a..f2234981f48 100644 --- a/code/game/turfs/open/floor.dm +++ b/code/game/turfs/open/floor.dm @@ -20,11 +20,7 @@ overfloor_placed = TRUE - - /// Determines the type of damage overlay that will be used for the tile - var/damaged_dmi = 'icons/turf/damaged.dmi' - var/broken = FALSE - var/burnt = FALSE + damaged_dmi = 'icons/turf/damaged.dmi' /// Path of the tile that this floor drops var/floor_tile = null /// Determines if you can deconstruct this with a RCD @@ -32,33 +28,16 @@ /turf/open/floor/Initialize(mapload) . = ..() - - if (PERFORM_ALL_TESTS(focus_only/valid_turf_states)) - var/static/list/previous_errors = list() - - if (!(type in previous_errors)) - if (broken != (icon_state in broken_states())) - stack_trace("[icon_state] (from [type]), which should be [broken ? "NOT broken, IS" : "broken, IS NOT"]") - previous_errors[type] = TRUE - - if (burnt != (icon_state in burnt_states())) - stack_trace("[icon_state] (from [type]), which should be [burnt ? "NOT burnt, IS" : "burnt, IS NOT"]") - previous_errors[type] = TRUE - if(mapload && prob(33)) MakeDirty() if(is_station_level(z)) GLOB.station_turfs += src -/// Returns a list of every turf state considered "broken". -/// Will be randomly chosen if a turf breaks at runtime. -/turf/open/floor/proc/broken_states() +/turf/open/floor/broken_states() return list("damaged1", "damaged2", "damaged3", "damaged4", "damaged5") -/// Returns a list of every turf state considered "burnt". -/// Will be randomly chosen if a turf is burnt at runtime. -/turf/open/floor/proc/burnt_states() +/turf/open/floor/burnt_states() return list() /turf/open/floor/Destroy() @@ -123,29 +102,6 @@ return T.break_tile() -/turf/open/floor/break_tile() - if(broken) - return - broken = TRUE - update_appearance() - -/turf/open/floor/burn_tile() - if(burnt) - return - burnt = TRUE - update_appearance() - -/turf/open/floor/update_overlays() - . = ..() - if(broken) - . += mutable_appearance(damaged_dmi, pick(broken_states())) - else if(burnt) - var/list/burnt_states = burnt_states() - if(burnt_states.len) - . += mutable_appearance(damaged_dmi, pick(burnt_states)) - else - . += mutable_appearance(damaged_dmi, pick(broken_states())) - /// Things seem to rely on this actually returning plating. Override it if you have other baseturfs. /turf/open/floor/proc/make_plating(force = FALSE) return ScrapeAway(flags = CHANGETURF_INHERIT_AIR) diff --git a/code/game/turfs/open/floor/fancy_floor.dm b/code/game/turfs/open/floor/fancy_floor.dm index 701b18bf129..f4f21c45a2b 100644 --- a/code/game/turfs/open/floor/fancy_floor.dm +++ b/code/game/turfs/open/floor/fancy_floor.dm @@ -133,7 +133,7 @@ /turf/open/floor/grass name = "grass patch" desc = "You can't tell if this is real grass or just cheap plastic imitation." - icon_state = "grass0" + icon_state = "grass" floor_tile = /obj/item/stack/tile/grass flags_1 = NONE bullet_bounce_sound = null @@ -144,7 +144,7 @@ tiled_dirt = FALSE /turf/open/floor/grass/broken_states() - return list("sand") + return list("[initial(icon_state)]_damaged") /turf/open/floor/grass/Initialize(mapload) . = ..() @@ -161,6 +161,7 @@ icon_state = "sand" broken = TRUE initial_gas_mix = LAVALAND_DEFAULT_ATMOS + damaged_dmi = 'icons/turf/damaged.dmi' /turf/open/floor/grass/lavaland/spawniconchange() return @@ -168,7 +169,7 @@ /turf/open/floor/grass/fairy //like grass but fae-er name = "fairygrass patch" desc = "Something about this grass makes you want to frolic. Or get high." - icon_state = "fairygrass0" + icon_state = "fairygrass" floor_tile = /obj/item/stack/tile/fairygrass light_range = 2 light_power = 0.80 @@ -181,6 +182,7 @@ gender = PLURAL name = "snow" icon = 'icons/turf/snow.dmi' + damaged_dmi = 'icons/turf/snow.dmi' desc = "Looks cold." icon_state = "snow" flags_1 = NONE @@ -823,6 +825,7 @@ floor_tile = /obj/item/stack/tile/fakespace plane = PLANE_SPACE tiled_dirt = FALSE + damaged_dmi = 'icons/turf/space.dmi' /turf/open/floor/fakespace/broken_states() return list("damaged") diff --git a/code/game/turfs/open/floor/mineral_floor.dm b/code/game/turfs/open/floor/mineral_floor.dm index 3356694b27f..620bfe85e04 100644 --- a/code/game/turfs/open/floor/mineral_floor.dm +++ b/code/game/turfs/open/floor/mineral_floor.dm @@ -11,7 +11,7 @@ /turf/open/floor/mineral name = "mineral floor" - icon_state = "" + icon_state = null material_flags = MATERIAL_EFFECTS var/list/icons tiled_dirt = FALSE @@ -22,7 +22,7 @@ icons = typelist("icons", icons) /turf/open/floor/mineral/broken_states() - return list("[initial(icon_state)]_dam") + return isnull(icon_state) ? list() : list("[initial(icon_state)]_dam") /turf/open/floor/mineral/update_icon_state() if(!broken && !burnt && !(icon_state in icons)) @@ -288,6 +288,7 @@ icons = list("alienpod1", "alienpod2", "alienpod3", "alienpod4", "alienpod5", "alienpod6", "alienpod7", "alienpod8", "alienpod9") baseturfs = /turf/open/floor/plating/abductor2 custom_materials = list(/datum/material/alloy/alien = SMALL_MATERIAL_AMOUNT*5) + damaged_dmi = null /turf/open/floor/mineral/abductor/Initialize(mapload) . = ..() diff --git a/code/game/turfs/open/floor/plating/misc_plating.dm b/code/game/turfs/open/floor/plating/misc_plating.dm index 142a9fcbdcc..1cfb360eff4 100644 --- a/code/game/turfs/open/floor/plating/misc_plating.dm +++ b/code/game/turfs/open/floor/plating/misc_plating.dm @@ -17,9 +17,7 @@ tiled_dirt = FALSE // Not actually broken, just should never break...yeah. broken = TRUE - -/turf/open/floor/plating/abductor/broken_states() - return list("alienpod1") + damaged_dmi = null /turf/open/floor/plating/abductor/Initialize(mapload) . = ..() @@ -30,6 +28,7 @@ icon_state = "alienplating" base_icon_state = "alienplating" tiled_dirt = FALSE + damaged_dmi = null /turf/open/floor/plating/abductor2/break_tile() return //unbreakable diff --git a/code/game/turfs/open/grass.dm b/code/game/turfs/open/grass.dm index 357216b1362..d4bfc051e3b 100644 --- a/code/game/turfs/open/grass.dm +++ b/code/game/turfs/open/grass.dm @@ -2,7 +2,7 @@ name = "grass" desc = "A patch of grass." icon = 'icons/turf/floors.dmi' - icon_state = "grass0" + icon_state = "grass" base_icon_state = "grass" baseturfs = /turf/open/misc/sandy_dirt bullet_bounce_sound = null @@ -14,12 +14,14 @@ smoothing_groups = SMOOTH_GROUP_TURF_OPEN + SMOOTH_GROUP_FLOOR_GRASS canSmoothWith = SMOOTH_GROUP_FLOOR_GRASS + SMOOTH_GROUP_CLOSED_TURFS layer = HIGH_TURF_LAYER - var/damaged_dmi = 'icons/turf/floors/grass.dmi' + damaged_dmi = 'icons/turf/damaged.dmi' var/smooth_icon = 'icons/turf/floors/grass.dmi' -/turf/open/misc/grass/break_tile() - . = ..() - icon_state = "damaged" +/turf/open/misc/grass/broken_states() + return list("grass_damaged") + +/turf/open/misc/grass/burnt_states() + return list("grass_damaged") /turf/open/misc/grass/Initialize(mapload) . = ..() @@ -29,5 +31,8 @@ transform = translation icon = smooth_icon + if(is_station_level(z)) + GLOB.station_turfs += src + /turf/open/misc/grass/lavaland initial_gas_mix = LAVALAND_DEFAULT_ATMOS diff --git a/code/game/turfs/open/misc.dm b/code/game/turfs/open/misc.dm index fa3a65f44c5..a3c3433ab6b 100644 --- a/code/game/turfs/open/misc.dm +++ b/code/game/turfs/open/misc.dm @@ -4,7 +4,6 @@ /turf/open/misc name = "coder/mapper fucked up" desc = "report on github please" - icon_state = "BROKEN" flags_1 = NO_SCREENTIPS_1 turf_flags = CAN_BE_DIRTY_1 | IS_SOLID | NO_RUST diff --git a/code/game/turfs/open/planet.dm b/code/game/turfs/open/planet.dm index 6b113aec1f7..88f9518a08e 100644 --- a/code/game/turfs/open/planet.dm +++ b/code/game/turfs/open/planet.dm @@ -52,9 +52,14 @@ desc = "Greener on the other side." icon_state = "junglegrass" base_icon_state = "junglegrass" - damaged_dmi = 'icons/turf/floors/junglegrass.dmi' smooth_icon = 'icons/turf/floors/junglegrass.dmi' +/turf/open/misc/grass/broken_states() + return list("jungle_damaged") + +/turf/open/misc/grass/burnt_states() + return list("jungle_damaged") + /turf/closed/mineral/random/jungle baseturfs = /turf/open/misc/dirt/dark diff --git a/code/game/turfs/open/snow.dm b/code/game/turfs/open/snow.dm index 27def9bdc59..5c34a91038e 100644 --- a/code/game/turfs/open/snow.dm +++ b/code/game/turfs/open/snow.dm @@ -2,6 +2,7 @@ gender = PLURAL name = "snow" icon = 'icons/turf/snow.dmi' + damaged_dmi = 'icons/turf/snow.dmi' desc = "Looks cold." icon_state = "snow" planetary_atmos = TRUE @@ -17,9 +18,8 @@ . = ..() AddElement(/datum/element/diggable, /obj/item/stack/sheet/mineral/snow, 2) -/turf/open/misc/snow/break_tile() - . = ..() - icon_state = "snow_dug" +/turf/open/misc/snow/broken_states() + return list("snow_dug") /turf/open/misc/snow/actually_safe slowdown = 0 diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 1ed4429a113..22b1693f392 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -230,6 +230,7 @@ #include "timer_sanity.dm" #include "trait_addition_and_removal.dm" #include "traitor.dm" +#include "turf_icons.dm" #include "tutorial_sanity.dm" #include "unit_test.dm" #include "verify_config_tags.dm" diff --git a/code/modules/unit_tests/turf_icons.dm b/code/modules/unit_tests/turf_icons.dm new file mode 100644 index 00000000000..c261fbae7a1 --- /dev/null +++ b/code/modules/unit_tests/turf_icons.dm @@ -0,0 +1,44 @@ +/// Makes sure turf icons actually exist. :) +/datum/unit_test/turf_icons + +/datum/unit_test/turf_icons/Run() + for(var/turf/turf_path as anything in (subtypesof(/turf) - typesof(/turf/closed/mineral))) + + var/icon_state = initial(turf_path.icon_state) + var/icon_file = initial(turf_path.icon) + if(isnull(icon_state) || isnull(icon_file)) + continue + if(!(icon_state in icon_states(icon_file))) + TEST_FAIL("[turf_path] using invalid icon_state - \"[icon_state]\" in icon file, '[icon_file]") + + for(var/turf/closed/mineral/turf_path as anything in typesof(/turf/closed/mineral)) //minerals use a special (read: snowflake) MAP_SWITCH definition that changes their icon based on if we're just compiling or if we're actually PLAYING the game. + + var/icon_state = initial(turf_path.icon_state) + var/icon_file = 'icons/turf/mining.dmi' + if(isnull(icon_state)) + continue + if(!(icon_state in icon_states(icon_file))) + TEST_FAIL("[turf_path] using invalid icon_state - \"[icon_state]\" in icon file, '[icon_file]") + + var/turf/initial_turf_type = run_loc_floor_bottom_left.type + + for(var/turf/open/open_turf_path as anything in subtypesof(/turf/open)) + + var/damaged_dmi = initial(open_turf_path.damaged_dmi) + if(isnull(damaged_dmi)) + continue + + var/turf/open/instanced_turf = run_loc_floor_bottom_left.ChangeTurf(open_turf_path) + + var/list/burnt_states = instanced_turf.burnt_states() + for(var/state in burnt_states) + if(!(state in icon_states(damaged_dmi))) + TEST_FAIL("[open_turf_path] has an invalid icon in burnt_states - \"[state]\", in '[damaged_dmi]'") + + + var/list/broken_states = instanced_turf.broken_states() + for(var/state in broken_states) + if(!(state in icon_states(damaged_dmi))) + TEST_FAIL("[open_turf_path] has an invalid icon in broken_states - \"[state]\", in '[damaged_dmi]'") + + run_loc_floor_bottom_left = run_loc_floor_bottom_left.ChangeTurf(initial_turf_type) //cleanup. diff --git a/icons/turf/damaged.dmi b/icons/turf/damaged.dmi index 98ac42a4d6a..d3d06d53e46 100644 Binary files a/icons/turf/damaged.dmi and b/icons/turf/damaged.dmi differ diff --git a/icons/turf/floors.dmi b/icons/turf/floors.dmi index 25c14c70e0a..b6a4f8347c5 100644 Binary files a/icons/turf/floors.dmi and b/icons/turf/floors.dmi differ diff --git a/icons/turf/floors/grass.dmi b/icons/turf/floors/grass.dmi index e3dc219bc4f..2ffb5242562 100644 Binary files a/icons/turf/floors/grass.dmi and b/icons/turf/floors/grass.dmi differ diff --git a/icons/turf/floors/junglegrass.dmi b/icons/turf/floors/junglegrass.dmi index f2944d18cf6..80456e469b1 100644 Binary files a/icons/turf/floors/junglegrass.dmi and b/icons/turf/floors/junglegrass.dmi differ