[MIRROR] RCD repairs grilles before adding windows to them (#5432)

* RCD repairs grilles before adding windows to them (#58812)

* RCD repairs grilles before adding windows to them

- Grilles need to be clear of unanchored items for a window to fit on them
- Attempting to build a window on a grille with unanchored items on it will automatically move 20 of them to your tile
- If more than 20 items are on a tile, adding the window will fail (but you can just do it again to move 20 more)
- Grilles no longer rely on a subtype to break

* Uses text macro thing for simpler code

* RCD repairs grilles before adding windows to them

Co-authored-by: cacogen <25089914+cacogen@users.noreply.github.com>
This commit is contained in:
SkyratBot
2021-05-03 16:19:33 +02:00
committed by GitHub
parent 2ad2553424
commit e50a028297
+54 -8
View File
@@ -1,3 +1,6 @@
/// Max number of unanchored items that will be moved from a tile when attempting to add a window to a grille.
#define CLEAR_TILE_MOVE_LIMIT 20
/obj/structure/grille
desc = "A flimsy framework of iron rods."
name = "grille"
@@ -15,8 +18,6 @@
var/rods_type = /obj/item/stack/rods
var/rods_amount = 2
var/rods_broken = TRUE
var/grille_type = null
var/broken_type = /obj/structure/grille/broken
/obj/structure/grille/Initialize(mapload)
. = ..()
@@ -77,6 +78,13 @@
if(!isturf(loc))
return FALSE
var/turf/T = loc
if(repair_grille())
to_chat(user, "<span class='notice'>You rebuild the broken grille.</span>")
if(!clear_tile(user))
return FALSE
if(!ispath(the_rcd.window_type, /obj/structure/window))
CRASH("Invalid window path type in RCD: [the_rcd.window_type]")
var/obj/structure/window/window_path = the_rcd.window_type
@@ -88,6 +96,29 @@
return TRUE
return FALSE
/obj/structure/grille/proc/clear_tile(mob/user)
var/at_users_feet = get_turf(user)
var/unanchored_items_on_tile
var/obj/item/last_item_moved
for(var/obj/item/item_to_move in loc.contents)
if(!item_to_move.anchored)
if(unanchored_items_on_tile <= CLEAR_TILE_MOVE_LIMIT)
item_to_move.forceMove(at_users_feet)
last_item_moved = item_to_move
unanchored_items_on_tile++
if(!unanchored_items_on_tile)
return TRUE
to_chat(user, "<span class='notice'>You move [unanchored_items_on_tile == 1 ? "[last_item_moved]" : "some things"] out of the way.</span>")
if(unanchored_items_on_tile - CLEAR_TILE_MOVE_LIMIT > 0)
to_chat(user, "<span class ='warning'>There's still too much stuff in the way!</span>")
return FALSE
return TRUE
/obj/structure/grille/Bumped(atom/movable/AM)
if(!ismob(AM))
return
@@ -159,9 +190,8 @@
if(!shock(user, 90))
user.visible_message("<span class='notice'>[user] rebuilds the broken grille.</span>", \
"<span class='notice'>You rebuild the broken grille.</span>")
new grille_type(src.loc)
repair_grille()
R.use(1)
qdel(src)
return
//window placing begin
@@ -178,12 +208,16 @@
for(var/obj/structure/window/WINDOW in loc)
to_chat(user, "<span class='warning'>There is already a window there!</span>")
return
if(!clear_tile(user))
return
to_chat(user, "<span class='notice'>You start placing the window...</span>")
if(do_after(user,20, target = src))
if(!src.loc || !anchored) //Grille broken or unanchored while waiting
return
for(var/obj/structure/window/WINDOW in loc) //Another window already installed on grille
return
if(!clear_tile(user))
return
var/obj/structure/window/WD
if(istype(W, /obj/item/stack/sheet/plasmarglass))
WD = new/obj/structure/window/plasma/reinforced/fulltile(drop_location()) //reinforced plasma window
@@ -232,11 +266,25 @@
/obj/structure/grille/obj_break()
if(!broken && !(flags_1 & NODECONSTRUCT_1))
new broken_type(src.loc)
icon_state = "brokengrille"
density = FALSE
obj_integrity = 20
broken = TRUE
rods_amount = 1
rods_broken = FALSE
var/obj/R = new rods_type(drop_location(), rods_broken)
transfer_fingerprints_to(R)
qdel(src)
/obj/structure/grille/proc/repair_grille()
if(broken)
icon_state = "grille"
density = TRUE
obj_integrity = max_integrity
broken = FALSE
rods_amount = 2
rods_broken = TRUE
return TRUE
return FALSE
// shock user with probability prb (if all connections & power are working)
// returns 1 if shocked, 0 otherwise
@@ -289,5 +337,3 @@
broken = TRUE
rods_amount = 1
rods_broken = FALSE
grille_type = /obj/structure/grille
broken_type = null