fences and railings

This commit is contained in:
S34NW
2021-09-10 15:55:22 +01:00
parent f286927c07
commit 5fde45d366
6 changed files with 314 additions and 2 deletions
+168
View File
@@ -0,0 +1,168 @@
//Chain link fences
//Sprites ported from /VG/
#define CUT_TIME 100
#define CLIMB_TIME 150
#define NO_HOLE 0 //section is intact
#define MEDIUM_HOLE 1 //medium hole in the section - can climb through
#define LARGE_HOLE 2 //large hole in the section - can walk through
#define MAX_HOLE_SIZE LARGE_HOLE
#define HOLE_REPAIR (hole_size * 2) //How many rods to fix these sections
/obj/structure/fence
name = "fence"
desc = "A chain link fence. Not as effective as a wall, but generally it keeps people out."
density = TRUE
anchored = TRUE
icon = 'icons/obj/fence.dmi'
icon_state = "straight"
var/cuttable = TRUE
var/hole_size= NO_HOLE
var/invulnerable = FALSE
/obj/structure/fence/Initialize()
. = ..()
update_cut_status()
/obj/structure/fence/examine(mob/user)
. = ..()
switch(hole_size)
if(MEDIUM_HOLE)
. += "There is a large hole in \the [src]."
if(LARGE_HOLE)
. += "\The [src] has been completely cut through."
/obj/structure/fence/end
icon_state = "end"
cuttable = FALSE
/obj/structure/fence/corner
icon_state = "corner"
cuttable = FALSE
/obj/structure/fence/post
icon_state = "post"
cuttable = FALSE
/obj/structure/fence/cut/medium
icon_state = "straight_cut2"
hole_size = MEDIUM_HOLE
/obj/structure/fence/cut/large
icon_state = "straight_cut3"
hole_size = LARGE_HOLE
/obj/structure/fence/wirecutter_act(mob/living/user, obj/item/W)
if(!cuttable)
to_chat(user, "<span class='warning'>This section of the fence can't be cut!</span>")
return
if(invulnerable)
to_chat(user, "<span class='warning'>This fence is too strong to cut through!</span>")
return
var/current_stage = hole_size
if(current_stage >= MAX_HOLE_SIZE)
to_chat(user, "<span class='warning'>This fence has too much cut out of it already!</span>")
return
user.visible_message("<span class='danger'>\The [user] starts cutting through \the [src] with \the [W].</span>",\
"<span class='danger'>You start cutting through \the [src] with \the [W].</span>")
if(W.use_tool(src, user, CUT_TIME * W.toolspeed, volume = W.tool_volume))
if(current_stage == hole_size)
switch(++hole_size)
if(MEDIUM_HOLE)
visible_message("<span class='notice'>\The [user] cuts into \the [src] some more.</span>")
to_chat(user, "<span class='info'>You could probably fit yourself through that hole now. Although climbing through would be much faster if you made it even bigger.</span>")
climbable = TRUE
if(LARGE_HOLE)
visible_message("<span class='notice'>\The [user] completely cuts through \the [src].</span>")
to_chat(user, "<span class='info'>The hole in \the [src] is now big enough to walk through.</span>")
climbable = FALSE
update_cut_status()
return
/obj/structure/fence/attackby(obj/item/C, mob/user)
. = ..()
if(istype(C, /obj/item/stack/rods))
if(hole_size == NO_HOLE)
return
var/obj/item/stack/rods/R = C
if(R.get_amount() < HOLE_REPAIR)
to_chat(user, "<span class='warning'>You need [HOLE_REPAIR] rods to fix this fence!</span>")
return TRUE
else
to_chat(user, "<span class='notice'>You begin repairing the fence...</span>")
if(do_after(user, 30 * C.toolspeed, target = src))
if(R.get_amount() >= HOLE_REPAIR && !(hole_size == NO_HOLE))
hole_size = NO_HOLE
playsound(src, C.usesound, 80, 1)
R.use(2)
to_chat(user, "<span class='notice'>You repair the fence.</span>")
update_cut_status()
return TRUE
/obj/structure/fence/proc/update_cut_status()
if(!cuttable)
return
var/new_density = TRUE
switch(hole_size)
if(NO_HOLE)
icon_state = initial(icon_state)
if(MEDIUM_HOLE)
icon_state = "straight_cut2"
if(LARGE_HOLE)
icon_state = "straight_cut3"
new_density = FALSE
set_density(new_density)
//FENCE DOORS
/obj/structure/fence/door
name = "fence door"
desc = "Not very useful without a real lock."
icon_state = "door_closed"
cuttable = FALSE
var/open = FALSE
/obj/structure/fence/door/Initialize()
. = ..()
update_door_status()
/obj/structure/fence/door/opened
icon_state = "door_opened"
open = TRUE
density = TRUE
/obj/structure/fence/door/attack_hand(mob/user, list/modifiers)
if(can_open(user))
toggle(user)
return TRUE
/obj/structure/fence/door/proc/toggle(mob/user)
open = !open
visible_message("<span class='notice'>\The [user] [open ? "opens" : "closes"] \the [src].</span>")
update_door_status()
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"
/obj/structure/fence/door/proc/can_open(mob/user)
return TRUE
#undef CUT_TIME
#undef CLIMB_TIME
#undef NO_HOLE
#undef MEDIUM_HOLE
#undef LARGE_HOLE
#undef MAX_HOLE_SIZE
+124
View File
@@ -0,0 +1,124 @@
/obj/structure/railing
name = "railing"
desc = "Basic railing meant to protect idiots like you from falling."
icon = 'icons/obj/fence.dmi'
icon_state = "railing"
density = TRUE
anchored = TRUE
climbable = TRUE
var/currently_climbed = FALSE
/obj/structure/railing/corner //aesthetic corner sharp edges hurt oof ouch
icon_state = "railing_corner"
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, "<span class='notice'>You begin repairing [src]...</span>")
if(I.use_tool(src, user, 40, volume = 50))
obj_integrity = max_integrity
to_chat(user, "<span class='notice'>You repair [src].</span>")
return
to_chat(user, "<span class='warning'>[src] is already in good condition!</span>")
return
/obj/structure/railing/wirecutter_act(mob/living/user, obj/item/I)
. = ..()
if(!anchored)
to_chat(user, "<span class='warning'>You cut apart the railing.</span>")
I.play_tool_sound(src, 100)
deconstruct()
return TRUE
/obj/structure/railing/deconstruct(disassembled)
if(!(flags & NODECONSTRUCT))
var/obj/item/stack/rods/rod = new /obj/item/stack/rods(drop_location(), 3)
transfer_fingerprints_to(rod)
return ..()
///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, "<span class='notice'>You begin to [anchored ? "unfasten the railing from":"fasten the railing to"] the floor...</span>")
if(I.use_tool(src, user, volume = 75, extra_checks = CALLBACK(src, .proc/check_anchored, anchored)))
if(!anchored)
anchored = TRUE
else
anchored = FALSE
to_chat(user, "<span class='notice'>You [anchored ? "fasten the railing to":"unfasten the railing from"] the floor.</span>")
return TRUE
/obj/structure/railing/CanPass(atom/movable/mover, turf/target)
..()
var/mob/living/M = mover
if(M.flying || M.floating || mover.throwing)
return TRUE
if(get_dir(loc, target) == dir)
return !density
return TRUE
/obj/structure/railing/corner/CanPass()
..()
return TRUE
/obj/structure/railing/CheckExit(atom/movable/O, target)
var/mob/living/M = O
if(M.flying | M.floating)
return TRUE
if(O.throwing)
return TRUE
if(O.move_force >= MOVE_FORCE_EXTREMELY_STRONG)
return TRUE
if(currently_climbed)
if(get_turf(M) == get_turf(src))
var/turf/T = target
if(T.density)
return TRUE
for(var/atom/A in T)
if(A.density)
return FALSE
currently_climbed = FALSE
return TRUE
if(get_dir(O.loc, target) == dir)
return FALSE
return TRUE
/obj/structure/railing/do_climb(mob/living/user)
. = ..()
if(!climbable)
return
if(get_turf(user) == get_turf(src))
currently_climbed = TRUE
/obj/structure/railing/proc/can_be_rotated(mob/user, rotation_type)
if(anchored)
to_chat(user, "<span class='warning'>[src] cannot be rotated while it is fastened to the floor!</span>")
return FALSE
var/target_dir = turn(dir, -90)
if(!valid_window_location(loc, target_dir)) //Expanded to include rails, as well!
to_chat(user, "<span class='warning'>[src] cannot be rotated in that direction!</span>")
return FALSE
return TRUE
/obj/structure/railing/proc/check_anchored(checked_anchored)
if(anchored == checked_anchored)
return TRUE
/obj/structure/railing/proc/after_rotation(mob/user,rotation_type)
add_fingerprint(user)