[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
🆑
fix: rcd can build wallmounts on reinforced walls
qol: rcd can build directional windows without requiring/building a
grill
/🆑

* RCD directional window qol & wall mount patch. Code improvements

---------

Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-08-30 16:27:07 -04:00
committed by GitHub
co-authored by SyncIt21
parent fbed9bf600
commit 74804a4fca
4 changed files with 81 additions and 36 deletions
+52 -23
View File
@@ -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
+2 -10
View File
@@ -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)