From de1743a1b10d6f6a317f07172ec3044fb10a9b3c Mon Sep 17 00:00:00 2001 From: Geeves Date: Sun, 6 Feb 2022 23:21:56 +0200 Subject: [PATCH] Railing Stuff (#13035) --- code/game/objects/structures.dm | 9 ++++- code/game/objects/structures/railing.dm | 44 +++++++++++++++------- code/modules/materials/material_recipes.dm | 2 +- html/changelogs/geeves-rail_climbtime.yml | 9 +++++ 4 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 html/changelogs/geeves-rail_climbtime.yml diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index 62c4a973441..5bb42b75d26 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -77,7 +77,14 @@ set category = "Object" set src in oview(1) - do_climb(usr) + if(can_climb(usr)) + do_climb(usr) + +/obj/structure/handle_middle_mouse_click(mob/user) + if(can_climb(user)) + do_climb(usr) + return TRUE + return FALSE /obj/structure/MouseDrop_T(mob/target, mob/user) diff --git a/code/game/objects/structures/railing.dm b/code/game/objects/structures/railing.dm index e420ce8d720..ed4ce7d3f6a 100644 --- a/code/game/objects/structures/railing.dm +++ b/code/game/objects/structures/railing.dm @@ -8,6 +8,8 @@ climbable = TRUE layer = OBJ_LAYER anchored = FALSE + + flags = ON_BORDER obj_flags = OBJ_FLAG_ROTATABLE build_amt = 2 @@ -278,35 +280,49 @@ /obj/structure/railing/ex_act(severity) qdel(src) -/obj/structure/railing/can_climb(var/mob/living/user, climb_dir, post_climb_check=0) +/obj/structure/railing/can_climb(var/mob/living/user, post_climb_check=0) . = ..() - var/turf/dest = get_step(user, climb_dir) - if(. && get_turf(user) == get_turf(src)) - if(turf_is_crowded(TRUE) || !user.Adjacent(dest) || turf_contains_dense_objects(dest) && get_turf(src) != dest) + if(!.) + return + + var/turf/destination_turf = get_destination_turf(user) + + if(destination_turf.density) + to_chat(user, SPAN_DANGER("You can't climb into \the [destination_turf].")) + return FALSE + + if(!Adjacent(destination_turf)) + to_chat(user, SPAN_DANGER("You can't climb there, the way is blocked.")) + return FALSE + + for(var/atom/A in destination_turf.contents - src) + if(A.density && !(A.flags & ON_BORDER)) to_chat(user, SPAN_DANGER("You can't climb there, the way is blocked.")) return FALSE -/obj/structure/railing/do_climb(mob/living/user) - var/climb_dir = get_dir(user, src) - if(get_turf(src) == get_turf(user)) - climb_dir = src.dir - if(!can_climb(user, climb_dir)) - return + return TRUE +/obj/structure/railing/do_climb(mob/living/user) user.visible_message(SPAN_WARNING("\The [user] starts climbing over \the [src]!")) LAZYADD(climbers, user) - if(!do_after(user, 50)) + if(!do_after(user, 2 SECONDS)) LAZYREMOVE(climbers, user) return - if(!can_climb(user, climb_dir, post_climb_check = TRUE)) + if(!can_climb(user, post_climb_check = TRUE)) LAZYREMOVE(climbers, user) return - user.forceMove(get_step(user, climb_dir)) + var/turf/destination_turf = get_destination_turf(user) + user.forceMove(destination_turf) user.visible_message(SPAN_WARNING("\The [user] climbs over \the [src]!")) LAZYREMOVE(climbers, user) if(!anchored || material.is_brittle()) - take_damage(maxhealth) // Fatboy \ No newline at end of file + take_damage(maxhealth) // Fatboy + +/obj/structure/railing/proc/get_destination_turf(var/mob/user) + . = get_turf(src) // by default, we pop into the turf the railing's on + if(get_turf(user) == . || !(get_dir(src, user) & dir)) // if the user's inside our turf or behind us, go in front of us + . = get_step(src, dir) diff --git a/code/modules/materials/material_recipes.dm b/code/modules/materials/material_recipes.dm index 172fe40898d..a4e61765be6 100644 --- a/code/modules/materials/material_recipes.dm +++ b/code/modules/materials/material_recipes.dm @@ -21,7 +21,7 @@ list( new /datum/stack_recipe("[display_name] door", /obj/structure/simple_door, BUILD_AMT, time = 50, one_per_turf = 1, on_floor = 1, supplied_material = "[name]"), new /datum/stack_recipe("[display_name] barricade", /obj/structure/barricade, BUILD_AMT, time = 50, one_per_turf = 1, on_floor = 1, supplied_material = "[name]"), - new /datum/stack_recipe("[display_name] railing", /obj/structure/railing, BUILD_AMT, time = 50, one_per_turf = FALSE, on_floor = TRUE, supplied_material = "[name]"), + new /datum/stack_recipe("[display_name] railing", /obj/structure/railing, BUILD_AMT, time = 25, one_per_turf = FALSE, on_floor = TRUE, supplied_material = "[name]"), new /datum/stack_recipe("[display_name] stool", /obj/structure/bed/stool, BUILD_AMT, one_per_turf = 1, on_floor = 1, supplied_material = "[name]"), new /datum/stack_recipe("[display_name] chair", /obj/structure/bed/stool/chair, BUILD_AMT, one_per_turf = 1, on_floor = 1, supplied_material = "[name]"), new /datum/stack_recipe("[display_name] bed", /obj/structure/bed, BUILD_AMT, one_per_turf = 1, on_floor = 1, supplied_material = "[name]"), diff --git a/html/changelogs/geeves-rail_climbtime.yml b/html/changelogs/geeves-rail_climbtime.yml new file mode 100644 index 00000000000..c37d46f6acb --- /dev/null +++ b/html/changelogs/geeves-rail_climbtime.yml @@ -0,0 +1,9 @@ +author: Geeves + +delete-after: True + +changes: + - tweak: "It now takes two seconds to climb railings, down from five." + - tweak: "It now takes two and a half seconds to make a railing, down from five." + - tweak: "When climbing a railing, you always appear on the other side, no more shuffling along it when approached from an angle." + - rscadd: "Middle-clicking a climbable structure now makes you climb it." \ No newline at end of file