From 74804a4fca68c367344c99527c3f4af8a2f404e8 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 30 Aug 2023 22:27:07 +0200 Subject: [PATCH] [MIRROR] RCD directional window qol & wall mount patch. Code improvements [MDB IGNORE] (#23400) * RCD directional window qol & wall mount patch. Code improvements (#77858) ## About The Pull Request Fixes #77852 RCD can build wall mounts on reinforced walls Closes #77848 Not a fix so labelling this as a qol cause it was always intentional but now RCD can build directional windows without building a grill first. Saving some matter units from building a grill is a plus Added auto doc for some procs & made the extra delay when building multiple structures into a define ## Changelog :cl: fix: rcd can build wallmounts on reinforced walls qol: rcd can build directional windows without requiring/building a grill /:cl: * RCD directional window qol & wall mount patch. Code improvements --------- Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> --- code/game/objects/items/rcd/RCD.dm | 75 +++++++++++++++------- code/game/objects/structures/grille.dm | 12 +--- code/game/turfs/closed/wall/reinf_walls.dm | 4 +- code/game/turfs/open/floor.dm | 26 +++++++- 4 files changed, 81 insertions(+), 36 deletions(-) diff --git a/code/game/objects/items/rcd/RCD.dm b/code/game/objects/items/rcd/RCD.dm index f6e22b784f5..bf6f5c2ab1f 100644 --- a/code/game/objects/items/rcd/RCD.dm +++ b/code/game/objects/items/rcd/RCD.dm @@ -19,6 +19,9 @@ #define CATEGORY_ICON_SUFFIX "category_icon_suffix" #define TITLE_ICON "ICON=TITLE" +///multiplier applied on construction & deconstruction time when building multiple structures +#define FREQUENT_USE_DEBUFF_MULTIPLIER 3 + //RAPID CONSTRUCTION DEVICE /obj/item/construction/rcd @@ -161,8 +164,8 @@ COOLDOWN_DECLARE(destructive_scan_cooldown) + ///number of active rcd effects in use e.g. when building multiple walls at once this value increases var/current_active_effects = 0 - var/frequent_use_debuff_multiplier = 3 GLOBAL_VAR_INIT(icon_holographic_wall, init_holographic_wall()) GLOBAL_VAR_INIT(icon_holographic_window, init_holographic_window()) @@ -262,39 +265,48 @@ GLOBAL_VAR_INIT(icon_holographic_window, init_holographic_window()) user.visible_message(span_suicide("[user] pulls the trigger... But there is not enough ammo!")) return SHAME -/// check can the structure be placed on the turf -/obj/item/construction/rcd/proc/can_place(atom/A, list/rcd_results, mob/user) +/** + * checks if we can build the structure + * Arguments + * + * * [atom][target]- the target we are trying to build on/deconstruct e.g. turf, wall etc + * * rcd_results- list of params specifically the build type of our structure + * * [mob][user]- the user + */ +/obj/item/construction/rcd/proc/can_place(atom/target, list/rcd_results, mob/user) /** *For anything that does not go an a wall we have to make sure that turf is clear for us to put the structure on it *If we are just trying to destory something then this check is not nessassary *RCD_WALLFRAME is also returned as the mode when upgrading apc, airalarm, firealarm using simple circuits upgrade */ if(rcd_results["mode"] != RCD_WALLFRAME && rcd_results["mode"] != RCD_DECONSTRUCT) - var/turf/target_turf = get_turf(A) - //if we are trying to build a window on top of a grill we check for specific edge cases - if(rcd_results["mode"] == RCD_WINDOWGRILLE && istype(A, /obj/structure/grille)) - var/list/structures_to_ignore + var/turf/target_turf = get_turf(target) + //if we are trying to build a window we check for specific edge cases + if(rcd_results["mode"] == RCD_WINDOWGRILLE) + var/is_full_tile = initial(window_type.fulltile) - //if we are trying to build full-tile windows we only ignore the grille but other directional windows on the grill can block its construction - if(window_type == /obj/structure/window/fulltile || window_type == /obj/structure/window/reinforced/fulltile) - structures_to_ignore = list(A) - //for normal directional windows we ignore the grille & other directional windows as they can be in diffrent directions on the grill. There is a later check during construction to deal with those - else - structures_to_ignore = list(/obj/structure/grille, /obj/structure/window) + var/list/structures_to_ignore + if(istype(target, /obj/structure/grille)) + if(is_full_tile) //if we are trying to build full-tile windows we ignore the grille + structures_to_ignore = list(target) + else //no building directional windows on grills + return FALSE + else //for directional windows we ignore other directional windows as they can be in diffrent directions on the turf. + structures_to_ignore = list(/obj/structure/window) //check if we can build our window on the grill - if(target_turf.is_blocked_turf(exclude_mobs = FALSE, source_atom = null, ignore_atoms = structures_to_ignore, type_list = (length(structures_to_ignore) == 2))) + if(target_turf.is_blocked_turf(exclude_mobs = !is_full_tile, source_atom = null, ignore_atoms = structures_to_ignore, type_list = !is_full_tile)) playsound(loc, 'sound/machines/click.ogg', 50, TRUE) - balloon_alert(user, "something is on the grille!") + balloon_alert(user, "something is blocking the turf") return FALSE /** * if we are trying to create plating on turf which is not a proper floor then dont check for objects on top of the turf just allow that turf to be converted into plating. e.g. create plating beneath a player or underneath a machine frame/any dense object * if we are trying to finish a wall girder then let it finish then make sure no one/nothing is stuck in the girder */ - else if(rcd_results["mode"] == RCD_FLOORWALL && (!istype(target_turf, /turf/open/floor) || istype(A, /obj/structure/girder))) + else if(rcd_results["mode"] == RCD_FLOORWALL && (!istype(target_turf, /turf/open/floor) || istype(target, /obj/structure/girder))) //if a player builds a wallgirder on top of himself manually with iron sheets he can't finish the wall if he is still on the girder. Exclude the girder itself when checking for other dense objects on the turf - if(istype(A, /obj/structure/girder) && target_turf.is_blocked_turf(exclude_mobs = FALSE, source_atom = null, ignore_atoms = list(A))) + if(istype(target, /obj/structure/girder) && target_turf.is_blocked_turf(exclude_mobs = FALSE, source_atom = null, ignore_atoms = list(target))) playsound(loc, 'sound/machines/click.ogg', 50, TRUE) balloon_alert(user, "something is on the girder!") return FALSE @@ -334,26 +346,41 @@ GLOBAL_VAR_INIT(icon_holographic_window, init_holographic_window()) return TRUE -/obj/item/construction/rcd/proc/rcd_create(atom/A, mob/user) +/** + * actual proc to create the structure + * + * Arguments + * * [atom][target]- the target we are trying to build on/deconstruct e.g. turf, wall etc + * * [mob][user]- the user building this structure + */ +/obj/item/construction/rcd/proc/rcd_create(atom/target, mob/user) //does this atom allow for rcd actions? - var/list/rcd_results = A.rcd_vals(user, src) + var/list/rcd_results = target.rcd_vals(user, src) if(!rcd_results) return FALSE var/delay = rcd_results["delay"] * delay_mod - if ( !(upgrade & RCD_UPGRADE_NO_FREQUENT_USE_COOLDOWN) \ && !rcd_results[RCD_RESULT_BYPASS_FREQUENT_USE_COOLDOWN] \ && current_active_effects > 0 ) - delay *= frequent_use_debuff_multiplier + delay *= FREQUENT_USE_DEBUFF_MULTIPLIER current_active_effects += 1 - rcd_create_effect(A, user, delay, rcd_results) + _rcd_create_effect(target, user, delay, rcd_results) current_active_effects -= 1 -/obj/item/construction/rcd/proc/rcd_create_effect(atom/target, mob/user, delay, list/rcd_results) +/** + * Internal proc which creates the rcd effects & creates the structure + * + * Arguments + * * [atom][target]- the target we are trying to build on/deconstruct e.g. turf, wall etc + * * [mob][user]- the user trying to build the structure + * * delay- the delay with the disk upgrades applied + * * rcd_results- list of params which contains the cost & build mode to create the structure + */ +/obj/item/construction/rcd/proc/_rcd_create_effect(atom/target, mob/user, delay, list/rcd_results) var/obj/effect/constructing_effect/rcd_effect = new(get_turf(target), delay, src.mode, upgrade) //resource & structure placement sanity checks before & after delay along with beam effects @@ -655,6 +682,8 @@ GLOBAL_VAR_INIT(icon_holographic_window, init_holographic_window()) 0.0, 0.0, 0.0, 0.0, ) +#undef FREQUENT_USE_DEBUFF_MULTIPLIER + #undef CONSTRUCTION_MODE #undef WINDOW_TYPE #undef COMPUTER_DIR diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 8d8d0698b45..2a4ee9c53ac 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -64,13 +64,7 @@ if(RCD_WINDOWGRILLE) var/cost = 0 var/delay = 0 - if(the_rcd.window_type == /obj/structure/window) - cost = 4 - delay = 2 SECONDS - else if(the_rcd.window_type == /obj/structure/window/reinforced) - cost = 6 - delay = 2.5 SECONDS - else if(the_rcd.window_type == /obj/structure/window/fulltile) + if(the_rcd.window_type == /obj/structure/window/fulltile) cost = 8 delay = 3 SECONDS else if(the_rcd.window_type == /obj/structure/window/reinforced/fulltile) @@ -98,15 +92,13 @@ if(repair_grille()) balloon_alert(user, "grille rebuilt") - if(!clear_tile(user)) return FALSE var/obj/structure/window/window_path = the_rcd.window_type if(!ispath(window_path)) CRASH("Invalid window path type in RCD: [window_path]") - if(!valid_build_direction(T, user.dir, is_fulltile = initial(window_path.fulltile))) - balloon_alert(user, "window already here!") + if(!initial(window_path.fulltile)) //only fulltile windows can be built here return FALSE var/obj/structure/window/WD = new the_rcd.window_type(T, user.dir) WD.set_anchored(TRUE) diff --git a/code/game/turfs/closed/wall/reinf_walls.dm b/code/game/turfs/closed/wall/reinf_walls.dm index 23641d09262..e717f867dde 100644 --- a/code/game/turfs/closed/wall/reinf_walls.dm +++ b/code/game/turfs/closed/wall/reinf_walls.dm @@ -211,12 +211,12 @@ dismantle_wall() /turf/closed/wall/r_wall/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd) - if(the_rcd.canRturf) + if(the_rcd.canRturf || the_rcd.construction_mode == RCD_WALLFRAME) return ..() /turf/closed/wall/r_wall/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, passed_mode) - if(the_rcd.canRturf) + if(the_rcd.canRturf || passed_mode == RCD_WALLFRAME) return ..() /turf/closed/wall/r_wall/rust_heretic_act() diff --git a/code/game/turfs/open/floor.dm b/code/game/turfs/open/floor.dm index 6f8be90a560..6e8acf576cb 100644 --- a/code/game/turfs/open/floor.dm +++ b/code/game/turfs/open/floor.dm @@ -222,8 +222,17 @@ if(RCD_DECONSTRUCT) return list("mode" = RCD_DECONSTRUCT, "delay" = 5 SECONDS, "cost" = 33) if(RCD_WINDOWGRILLE) + //default cost for building a grill for fulltile windows + var/cost = 4 + var/delay = 1 SECONDS + if(the_rcd.window_type == /obj/structure/window) + cost = 4 + delay = 2 SECONDS + else if(the_rcd.window_type == /obj/structure/window/reinforced) + cost = 6 + delay = 2.5 SECONDS return rcd_result_with_memory( - list("mode" = RCD_WINDOWGRILLE, "delay" = 1 SECONDS, "cost" = 4), + list("mode" = RCD_WINDOWGRILLE, "delay" = delay, "cost" = cost), src, RCD_MEMORY_WINDOWGRILLE, ) if(RCD_MACHINE) @@ -334,6 +343,21 @@ return FALSE return TRUE if(RCD_WINDOWGRILLE) + //check if we are building a window + var/obj/structure/window/window_path = the_rcd.window_type + if(!ispath(window_path)) + CRASH("Invalid window path type in RCD: [window_path]") + + //allow directional windows to be built without grills + if(!initial(window_path.fulltile)) + if(!valid_build_direction(src, user.dir, is_fulltile = FALSE)) + balloon_alert(user, "window already here!") + return FALSE + var/obj/structure/window/WD = new the_rcd.window_type(src, user.dir) + WD.set_anchored(TRUE) + return TRUE + + //build grills to deal with full tile windows if(locate(/obj/structure/grille) in src) return FALSE var/obj/structure/grille/new_grille = new(src)