From 68415f6cf59241337d807dcc8072a43468a0a3d2 Mon Sep 17 00:00:00 2001 From: VikingPingvin Date: Mon, 5 Jun 2017 10:19:12 +0200 Subject: [PATCH] Portable Ladders (#2434) Add portable ladders as items. Deploy on floors that have an open space above them, and in open spaces that have floors beneath them. Fold them, to reuse them. Need item,structure base and structure body sprites. Probably an in hand sprite too. --- baystation12.dme | 1 + code/modules/multiz/movement.dm | 4 +++ code/modules/multiz/mz_items.dm | 60 +++++++++++++++++++++++++++++++ code/modules/multiz/structures.dm | 21 +++++++++++ 4 files changed, 86 insertions(+) create mode 100644 code/modules/multiz/mz_items.dm diff --git a/baystation12.dme b/baystation12.dme index ba5f2823c2d..ecda588124e 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1705,6 +1705,7 @@ #include "code\modules\multiz\_stubs.dm" #include "code\modules\multiz\basic.dm" #include "code\modules\multiz\movement.dm" +#include "code\modules\multiz\mz_items.dm" #include "code\modules\multiz\openspace.dm" #include "code\modules\multiz\pipes.dm" #include "code\modules\multiz\structures.dm" diff --git a/code/modules/multiz/movement.dm b/code/modules/multiz/movement.dm index 9a50a2c0dd3..38b76aa17ff 100644 --- a/code/modules/multiz/movement.dm +++ b/code/modules/multiz/movement.dm @@ -188,6 +188,10 @@ // Lattices and stairs stop things from falling. if(locate(/obj/structure/lattice, dest) || locate(/obj/structure/stairs, dest)) return FALSE + //Ladders too + if(below && locate(/obj/structure/ladder) in below) + return FALSE + // The var/climbers API is implemented here. if (LAZYLEN(dest.climbers) && (src in dest.climbers)) diff --git a/code/modules/multiz/mz_items.dm b/code/modules/multiz/mz_items.dm new file mode 100644 index 00000000000..10892bfca4b --- /dev/null +++ b/code/modules/multiz/mz_items.dm @@ -0,0 +1,60 @@ +/obj/item/weapon/ladder_mobile + name = "mobile ladder" + desc = "A lightweight deployable ladder, which you can use to move up or down. Or alternatively, you can bash some faces in." + icon_state = "ladder01" + icon = 'icons/obj/structures.dmi' + throw_range = 3 + force = 10 + w_class = 4.0 + slot_flags = SLOT_BACK + +/obj/item/weapon/ladder_mobile/proc/place_ladder(atom/A,mob/user) + + if(istype(A, /turf/simulated/open)) //Place into open space + var/turf/below_loc = GetBelow(A) + if (!below_loc || (istype(/turf/space,below_loc))) + user << "Why would you do that?! There is only infinite space there..." + return + user.visible_message("[user] begins to lower \the [src] into \the [A].") + if(!handle_action(A,user)) + return + var/obj/structure/ladder/mobile/body/R = new(A) + var/obj/structure/ladder/mobile/base/D = new(A) + D.forceMove(below_loc) + R.target_down = D + D.target_up = R + + user.drop_item() + qdel(src) + + if(istype(A, /turf/simulated/floor)) //Place onto Floor + var/turf/upper_loc = GetAbove(A) + if (!upper_loc || !istype(upper_loc,/turf/simulated/open)) + user << "There is something above. You can't deploy!" + return + user.visible_message("[user] begins deploying \the [src] on \the [A].") + if(!handle_action(A,user)) + return + var/obj/structure/ladder/mobile/base/R = new(A) + var/obj/structure/ladder/mobile/body/D = new(A) + D.forceMove(upper_loc) // moves A up to upper_loc. + R.target_up = D + D.target_down = R + + user.drop_item() + qdel(src) + +/obj/item/weapon/ladder_mobile/afterattack(atom/A, mob/user,proximity) + if(!proximity) + return + //addtimer(CALLBACK(src, .proc/place_ladder, A, user), 5000) + place_ladder(A,user) + +/obj/item/weapon/ladder_mobile/proc/handle_action(atom/A, mob/user) + if (!do_after(user, 30, act_target = user)) + to_chat(user, "Can't place ladder! You were interrupted!") + return FALSE + if (!A || QDELETED(src) || QDELETED(user)) + // Shit was deleted during delay, call is no longer valid. + return FALSE + return TRUE \ No newline at end of file diff --git a/code/modules/multiz/structures.dm b/code/modules/multiz/structures.dm index a5dc5b0cf31..6140df5696d 100644 --- a/code/modules/multiz/structures.dm +++ b/code/modules/multiz/structures.dm @@ -123,6 +123,27 @@ allowed_directions = UP|DOWN icon_state = "ladder11" +/obj/structure/ladder/mobile/base + allowed_directions = UP + icon_state = "ladder11" +/obj/structure/ladder/mobile/body + allowed_directions = DOWN + icon_state = "ladder11" + +/obj/structure/ladder/mobile/verb/fold() + set name = "Fold Ladder" + set category = "Object" + set src in oview(1) + var/obj/item/weapon/ladder_mobile/R = new(src.loc) + src.transfer_fingerprints_to(R) + + if(src.target_down == null) + QDEL_NULL(src.target_up) + qdel(src) + else + QDEL_NULL(src.target_down) + qdel(src) + /obj/structure/stairs name = "Stairs" desc = "Stairs leading to another deck. Not too useful if the gravity goes out."