diff --git a/code/game/atoms.dm b/code/game/atoms.dm
index b067e6f0812..e46086d9b2b 100644
--- a/code/game/atoms.dm
+++ b/code/game/atoms.dm
@@ -1154,7 +1154,12 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
appearance_flags |= PIXEL_SCALE
transform = M
-///Setter for the `density` variable to append behavior related to its changing.
+/*
+ Setter for the `density` variable.
+ Arguments:
+ * new_value - the new density you would want it to set.
+ Returns: Either null if identical to existing density, or the new density if different.
+*/
/atom/proc/set_density(new_value)
if(density == new_value)
return
diff --git a/code/game/objects/structures/fence.dm b/code/game/objects/structures/fence.dm
index 6fd7f3ea8bf..21ad71f329f 100644
--- a/code/game/objects/structures/fence.dm
+++ b/code/game/objects/structures/fence.dm
@@ -51,6 +51,7 @@
/obj/structure/fence/cut/medium
icon_state = "straight_cut2"
hole_size = MEDIUM_HOLE
+ climbable = TRUE
/obj/structure/fence/cut/large
icon_state = "straight_cut3"
@@ -65,10 +66,11 @@
return TRUE
return FALSE
-// shock user with probability prb (if all connections & power are working)
-// returns 1 if shocked, 0 otherwise
-// Totally not stolen from code\game\objects\structures\grille.dm
-
+/*
+ Shock user with probability prb (if all connections & power are working)
+ Returns TRUE if shocked, FALSE otherwise
+ Totally not stolen from code\game\objects\structures\grille.dm
+*/
/obj/structure/fence/proc/shock(mob/user, prb)
if(!prob(prb))
return FALSE
@@ -101,22 +103,21 @@
if(NO_HOLE)
visible_message("\The [user] cuts into \the [src] some more.")
to_chat(user, "You could probably fit yourself through that hole now. Although climbing through would be much faster if you made it even bigger.")
- climbable = TRUE
- ++hole_size
+ hole_size = MEDIUM_HOLE
if(MEDIUM_HOLE)
visible_message("\The [user] completely cuts through \the [src].")
to_chat(user, "The hole in \the [src] is now big enough to walk through.")
- climbable = FALSE
- ++hole_size
+ hole_size = LARGE_HOLE
if(LARGE_HOLE)
visible_message("\The [user] completely dismantles \the [src].")
to_chat(user, "You completely take apart \the [src].")
qdel(src)
return
update_cut_status()
- return
/obj/structure/fence/attackby(obj/item/C, mob/user)
+ if(shock(user, 90))
+ return
if(istype(C, /obj/item/stack/rods))
if(hole_size == NO_HOLE)
return
@@ -125,26 +126,23 @@
to_chat(user, "You need [HOLE_REPAIR] rods to fix this fence!")
return
to_chat(user, "You begin repairing the fence...")
- if(do_after(user, 30 * C.toolspeed, target = src))
- if(R.get_amount() >= HOLE_REPAIR && !(hole_size == NO_HOLE))
- R.use(HOLE_REPAIR)
- playsound(src, C.usesound, 80, 1)
- hole_size = NO_HOLE
- obj_integrity = max_integrity
- to_chat(user, "You repair the fence.")
- update_cut_status()
- return
- . = ..()
- if(shock(user, 90))
+ if(do_after(user, 3 SECONDS * C.toolspeed, target = src) && hole_size != NO_HOLE && R.use(HOLE_REPAIR))
+ playsound(src, C.usesound, 80, 1)
+ hole_size = NO_HOLE
+ obj_integrity = max_integrity
+ to_chat(user, "You repair the fence.")
+ update_cut_status()
return
+ . = ..()
/obj/structure/fence/Bumped(atom/user)
- if(ismob(user))
- if(shock_cooldown)
- return
- shock(user, 70)
- shock_cooldown = TRUE // We do not want bump shock spam!
- addtimer(CALLBACK(src, .proc/shock_cooldown), 1 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE)
+ if(!ismob(user))
+ return
+ if(shock_cooldown)
+ return
+ shock(user, 70)
+ shock_cooldown = TRUE // We do not want bump shock spam!
+ addtimer(CALLBACK(src, .proc/shock_cooldown), 1 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE)
/obj/structure/fence/proc/shock_cooldown()
shock_cooldown = FALSE
@@ -161,11 +159,14 @@
switch(hole_size)
if(NO_HOLE)
icon_state = initial(icon_state)
+ climbable = FALSE
if(MEDIUM_HOLE)
icon_state = "straight_cut2"
+ climbable = TRUE
if(LARGE_HOLE)
icon_state = "straight_cut3"
new_density = FALSE
+ climbable = FALSE
set_density(new_density)
//FENCE DOORS
@@ -199,8 +200,8 @@
playsound(src, 'sound/machines/door_open.ogg', 100, TRUE)
/obj/structure/fence/door/proc/update_door_status()
- set_density(!density)
- icon_state = density ? "door_closed" : "door_opened"
+ set_density(!open)
+ icon_state = open ? "door_opened" : "door_closed"
/obj/structure/fence/door/proc/can_open(mob/user)
return TRUE
@@ -212,3 +213,4 @@
#undef MEDIUM_HOLE
#undef LARGE_HOLE
#undef MAX_HOLE_SIZE
+#undef HOLE_REPAIR
diff --git a/code/game/objects/structures/railings.dm b/code/game/objects/structures/railings.dm
index eb6fa650fee..2f61eb51fed 100644
--- a/code/game/objects/structures/railings.dm
+++ b/code/game/objects/structures/railings.dm
@@ -15,34 +15,30 @@
density = FALSE
climbable = FALSE
-/obj/structure/railing/Initialize()
- . = ..()
-
/obj/structure/railing/attackby(obj/item/I, mob/living/user, params)
..()
add_fingerprint(user)
/obj/structure/railing/welder_act(mob/living/user, obj/item/I)
- if(user.intent == INTENT_HELP)
- if(obj_integrity < max_integrity)
- if(!I.tool_start_check(user, amount = 0))
- return
- to_chat(user, "You begin repairing [src]...")
- if(I.use_tool(src, user, 40, volume = 50))
- obj_integrity = max_integrity
- to_chat(user, "You repair [src].")
- return
-
+ if(user.intent != INTENT_HELP)
+ return
+ if(obj_integrity >= max_integrity)
to_chat(user, "[src] is already in good condition!")
return
+ if(!I.tool_start_check(user, amount = 0))
+ return
+ to_chat(user, "You begin repairing [src]...")
+ if(I.use_tool(src, user, 40, volume = 50))
+ obj_integrity = max_integrity
+ to_chat(user, "You repair [src].")
/obj/structure/railing/wirecutter_act(mob/living/user, obj/item/I)
- . = ..()
- if(!anchored)
- to_chat(user, "You cut apart the railing.")
- I.play_tool_sound(src, 100)
- deconstruct()
- return TRUE
+ if(anchored)
+ return
+ to_chat(user, "You cut apart the railing.")
+ I.play_tool_sound(src, 100)
+ deconstruct()
+ return TRUE
/obj/structure/railing/deconstruct(disassembled)
if(!(flags & NODECONSTRUCT))
@@ -52,15 +48,11 @@
///Implements behaviour that makes it possible to unanchor the railing.
/obj/structure/railing/wrench_act(mob/living/user, obj/item/I)
- . = ..()
if(flags & NODECONSTRUCT)
return
to_chat(user, "You begin to [anchored ? "unfasten the railing from":"fasten the railing to"] the floor...")
if(I.use_tool(src, user, volume = 75, extra_checks = CALLBACK(src, .proc/check_anchored, anchored)))
- if(!anchored)
- anchored = TRUE
- else
- anchored = FALSE
+ anchored = !anchored
to_chat(user, "You [anchored ? "fasten the railing to":"unfasten the railing from"] the floor.")
return TRUE
@@ -92,7 +84,7 @@
if(istype(O, /obj/item/projectile))
return TRUE
if(ismob(O))
- if(M.flying | M.floating)
+ if(M.flying || M.floating)
return TRUE
if(O.throwing)
return TRUE
@@ -115,9 +107,10 @@
/obj/structure/railing/do_climb(mob/living/user)
. = ..()
if(!climbable)
- return
+ return FALSE
if(get_turf(user) == get_turf(src))
currently_climbed = TRUE
+ return TRUE
/obj/structure/railing/proc/can_be_rotated(mob/user)
if(anchored)