diff --git a/code/datums/materials/_material.dm b/code/datums/materials/_material.dm index 91273d9c680..61d3e92ee2d 100644 --- a/code/datums/materials/_material.dm +++ b/code/datums/materials/_material.dm @@ -34,6 +34,8 @@ Simple datum which is instanced once per type and is used for every object of sa var/texture_layer_icon_state ///a cached filter for the texture icon var/cached_texture_filter + ///What type of shard the material will shatter to + var/obj/item/shard_type /datum/material/New() . = ..() diff --git a/code/datums/materials/basemats.dm b/code/datums/materials/basemats.dm index d45d9bf603a..77cfe7b8329 100644 --- a/code/datums/materials/basemats.dm +++ b/code/datums/materials/basemats.dm @@ -20,6 +20,7 @@ categories = list(MAT_CATEGORY_RIGID = TRUE, MAT_CATEGORY_BASE_RECIPES = TRUE) integrity_modifier = 0.1 sheet_type = /obj/item/stack/sheet/glass + shard_type = /obj/item/shard value_per_unit = 0.0025 beauty_modifier = 0.05 armor_modifiers = list("melee" = 0.2, "bullet" = 0.2, "laser" = 0, "energy" = 1, "bomb" = 0, "bio" = 0.2, "rad" = 0.2, "fire" = 1, "acid" = 0.2) @@ -110,6 +111,7 @@ Unless you know what you're doing, only use the first three numbers. They're in color = list(298/255, 46/255, 352/255,0, 0,0,0,0, 0,0,0,0, 0,0,0,1, 0,0,0,0) categories = list(MAT_CATEGORY_ORE = TRUE, MAT_CATEGORY_RIGID = TRUE, MAT_CATEGORY_BASE_RECIPES = TRUE) sheet_type = /obj/item/stack/sheet/mineral/plasma + shard_type = /obj/item/shard/plasma value_per_unit = 0.1 beauty_modifier = 0.15 armor_modifiers = list("melee" = 1.4, "bullet" = 0.7, "laser" = 0, "energy" = 1.2, "bomb" = 0, "bio" = 1.2, "rad" = 1, "fire" = 0, "acid" = 0.5) diff --git a/code/game/objects/items/stacks/sheets/glass.dm b/code/game/objects/items/stacks/sheets/glass.dm index 66540bc87b0..0fe67bf75c3 100644 --- a/code/game/objects/items/stacks/sheets/glass.dm +++ b/code/game/objects/items/stacks/sheets/glass.dm @@ -10,7 +10,8 @@ */ GLOBAL_LIST_INIT(glass_recipes, list ( \ new/datum/stack_recipe("directional window", /obj/structure/window/unanchored, time = 0, on_floor = TRUE, window_checks = TRUE), \ - new/datum/stack_recipe("fulltile window", /obj/structure/window/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE) \ + new/datum/stack_recipe("fulltile window", /obj/structure/window/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \ + new/datum/stack_recipe("glass shard", /obj/item/shard, time = 0, on_floor = TRUE) \ )) /obj/item/stack/sheet/glass @@ -57,7 +58,8 @@ GLOBAL_LIST_INIT(glass_recipes, list ( \ to_chat(user, "You attach wire to the [name].") var/obj/item/stack/light_w/new_tile = new(user.loc) new_tile.add_fingerprint(user) - else if(istype(W, /obj/item/stack/rods)) + return + if(istype(W, /obj/item/stack/rods)) var/obj/item/stack/rods/V = W if (V.get_amount() >= 1 && get_amount() >= 1) var/obj/item/stack/sheet/rglass/RG = new (get_turf(user)) @@ -69,15 +71,13 @@ GLOBAL_LIST_INIT(glass_recipes, list ( \ user.put_in_hands(RG) else to_chat(user, "You need one rod and one sheet of glass to make reinforced glass!") - return - else - return ..() - - + return + return ..() GLOBAL_LIST_INIT(pglass_recipes, list ( \ new/datum/stack_recipe("directional window", /obj/structure/window/plasma/unanchored, time = 0, on_floor = TRUE, window_checks = TRUE), \ - new/datum/stack_recipe("fulltile window", /obj/structure/window/plasma/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE) \ + new/datum/stack_recipe("fulltile window", /obj/structure/window/plasma/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \ + new/datum/stack_recipe("plasma glass shard", /obj/item/shard/plasma, time = 0, on_floor = TRUE) \ )) /obj/item/stack/sheet/plasmaglass @@ -119,8 +119,6 @@ GLOBAL_LIST_INIT(pglass_recipes, list ( \ else return ..() - - /* * Reinforced glass sheets */ @@ -128,7 +126,8 @@ GLOBAL_LIST_INIT(reinforced_glass_recipes, list ( \ new/datum/stack_recipe("windoor frame", /obj/structure/windoor_assembly, 5, time = 0, on_floor = TRUE, window_checks = TRUE), \ null, \ new/datum/stack_recipe("directional reinforced window", /obj/structure/window/reinforced/unanchored, time = 0, on_floor = TRUE, window_checks = TRUE), \ - new/datum/stack_recipe("fulltile reinforced window", /obj/structure/window/reinforced/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE) \ + new/datum/stack_recipe("fulltile reinforced window", /obj/structure/window/reinforced/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \ + new/datum/stack_recipe("glass shard", /obj/item/shard, time = 0, on_floor = TRUE) \ )) @@ -175,7 +174,8 @@ GLOBAL_LIST_INIT(reinforced_glass_recipes, list ( \ GLOBAL_LIST_INIT(prglass_recipes, list ( \ new/datum/stack_recipe("directional reinforced window", /obj/structure/window/plasma/reinforced/unanchored, time = 0, on_floor = TRUE, window_checks = TRUE), \ - new/datum/stack_recipe("fulltile reinforced window", /obj/structure/window/plasma/reinforced/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE) \ + new/datum/stack_recipe("fulltile reinforced window", /obj/structure/window/plasma/reinforced/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \ + new/datum/stack_recipe("plasma glass shard", /obj/item/shard/plasma, time = 0, on_floor = TRUE) \ )) /obj/item/stack/sheet/plasmarglass @@ -198,7 +198,8 @@ GLOBAL_LIST_INIT(prglass_recipes, list ( \ . += GLOB.prglass_recipes GLOBAL_LIST_INIT(titaniumglass_recipes, list( - new/datum/stack_recipe("shuttle window", /obj/structure/window/shuttle/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE) + new/datum/stack_recipe("shuttle window", /obj/structure/window/shuttle/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \ + new/datum/stack_recipe("glass shard", /obj/item/shard, time = 0, on_floor = TRUE) \ )) /obj/item/stack/sheet/titaniumglass @@ -217,7 +218,8 @@ GLOBAL_LIST_INIT(titaniumglass_recipes, list( . += GLOB.titaniumglass_recipes GLOBAL_LIST_INIT(plastitaniumglass_recipes, list( - new/datum/stack_recipe("plastitanium window", /obj/structure/window/plasma/reinforced/plastitanium/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE) + new/datum/stack_recipe("plastitanium window", /obj/structure/window/plasma/reinforced/plastitanium/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \ + new/datum/stack_recipe("plasma glass shard", /obj/item/shard/plasma, time = 0, on_floor = TRUE) \ )) /obj/item/stack/sheet/plastitaniumglass diff --git a/code/game/objects/items/stacks/sheets/sheets.dm b/code/game/objects/items/stacks/sheets/sheets.dm index 67edd1c07b7..4a12788573f 100644 --- a/code/game/objects/items/stacks/sheets/sheets.dm +++ b/code/game/objects/items/stacks/sheets/sheets.dm @@ -20,3 +20,28 @@ . = ..() pixel_x = rand(-4, 4) pixel_y = rand(-4, 4) + +/** + * Facilitates sheets being smacked on the floor + * + * This is used for crafting by hitting the floor with items. + * The inital use case is glass sheets breaking in to shards when the floor is hit. + * Args: + * * user: The user that did the action + * * params: paramas passed in from attackby + */ +/obj/item/stack/sheet/proc/on_attack_floor(mob/user, params) + var/list/shards = list() + for(var/datum/material/mat in custom_materials) + if(mat.shard_type) + var/obj/item/new_shard = new mat.shard_type(user.loc) + new_shard.add_fingerprint(user) + shards += "[new_shard.name]" + if(!shards.len) + return FALSE + user.do_attack_animation(src, ATTACK_EFFECT_BOOP) + playsound(src, "shatter", 70, TRUE) + use(1) + user.visible_message("[user] shatters the sheet of [name] on the floor, leaving [english_list(shards)].", \ + "You shatter the sheet of [name] on the floor, leaving [english_list(shards)].") + return TRUE diff --git a/code/game/turfs/open/floor.dm b/code/game/turfs/open/floor.dm index 8f2e120a2cf..50d47bb3b52 100644 --- a/code/game/turfs/open/floor.dm +++ b/code/game/turfs/open/floor.dm @@ -165,14 +165,19 @@ W.update_icon() return W -/turf/open/floor/attackby(obj/item/C, mob/user, params) - if(!C || !user) - return 1 - if(..()) - return 1 - if(intact && istype(C, /obj/item/stack/tile)) - try_replace_tile(C, user, params) - return 0 +/turf/open/floor/attackby(obj/item/object, mob/user, params) + if(!object || !user) + return TRUE + . = ..() + if(.) + return . + if(intact && istype(object, /obj/item/stack/tile)) + try_replace_tile(object, user, params) + return TRUE + if(user.a_intent == INTENT_HARM && istype(object, /obj/item/stack/sheet)) + var/obj/item/stack/sheet/sheets = object + return sheets.on_attack_floor(user, params) + return FALSE /turf/open/floor/crowbar_act(mob/living/user, obj/item/I) if(intact && pry_tile(I, user))