[MIRROR] RCD now rebuilds existing constructs faster and with less resources (#4641)

* RCD now rebuilds existing constructs faster and with less resources (#58029)

* RCD now rebuilds faster

* Reconstructing now costs less

* Fix _

* Remove unused flag, use helper proc

* Add sound

* Remove previously useless, now inaccurate comment

* Add MIN_COMPILER_VERSION warning

* RCD now rebuilds existing constructs faster and with less resources

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
SkyratBot
2021-04-04 16:58:57 +02:00
committed by GitHub
parent 3df39faa9c
commit 5ed908387f
16 changed files with 150 additions and 11 deletions

View File

@@ -117,3 +117,12 @@
#define RCD_WINDOW_DIRECTIONAL "directional"
#define RCD_WINDOW_NORMAL "glass"
#define RCD_WINDOW_REINFORCED "reinforced glass"
#define RCD_MEMORY_WALL 1
#define RCD_MEMORY_WINDOWGRILLE 2
// How much faster to use the RCD when on a tile with memory
#define RCD_MEMORY_SPEED_BUFF 5
/// How much less resources the RCD uses when reconstructing
#define RCD_MEMORY_COST_BUFF 8

View File

@@ -0,0 +1,10 @@
/// Produces a new RCD result from the given one if it can be calculated that
/// the RCD should speed up with the remembered form.
/proc/rcd_result_with_memory(list/defaults, turf/place, expected_memory)
if (place?.rcd_memory == expected_memory)
return defaults + list(
"cost" = defaults["cost"] / RCD_MEMORY_COST_BUFF,
"delay" = defaults["delay"] / RCD_MEMORY_SPEED_BUFF,
)
else
return defaults

View File

@@ -943,10 +943,10 @@ world
I.pixel_y++
add_overlay(I)//And finally add the overlay.
/proc/getHologramIcon(icon/A, safety=1)//If safety is on, a new icon is not created.
/proc/getHologramIcon(icon/A, safety = TRUE, opacity = 0.5)//If safety is on, a new icon is not created.
var/icon/flat_icon = safety ? A : new(A)//Has to be a new icon to not constantly change the same icon.
flat_icon.ColorTone(rgb(125,180,225))//Let's make it bluish.
flat_icon.ChangeOpacity(0.5)//Make it half transparent.
flat_icon.ChangeOpacity(opacity)
var/icon/alpha_mask = new('icons/effects/effects.dmi', "scanline")//Scanline effect.
flat_icon.AddAlphaMask(alpha_mask)//Finally, let's mix in a distortion effect.
return flat_icon

View File

@@ -25,6 +25,13 @@ again.
spawn_list = list(/obj/structure/grille, /obj/structure/window/fulltile)
dir = SOUTH
/obj/effect/spawner/structure/window/Initialize()
. = ..()
if (is_station_level(z))
var/turf/current_turf = get_turf(src)
current_turf.rcd_memory = RCD_MEMORY_WINDOWGRILLE
/obj/effect/spawner/structure/window/hollow
name = "hollow window spawner"
icon_state = "hwindow_spawner_full"

View File

@@ -210,6 +210,10 @@ RLD
return FALSE
return TRUE
#define RCD_DESTRUCTIVE_SCAN_RANGE 10
#define RCD_HOLOGRAM_FADE_TIME (15 SECONDS)
#define RCD_DESTRUCTIVE_SCAN_COOLDOWN (RCD_HOLOGRAM_FADE_TIME + 1 SECONDS)
/obj/item/construction/rcd
name = "rapid-construction-device (RCD)"
icon = 'icons/obj/tools.dmi'
@@ -222,6 +226,7 @@ RLD
slot_flags = ITEM_SLOT_BELT
item_flags = NO_MAT_REDEMPTION | NOBLUDGEON
has_ammobar = TRUE
actions_types = list(/datum/action/item_action/rcd_scan)
var/mode = RCD_FLOORWALL
var/construction_mode = RCD_FLOORWALL
var/ranged = FALSE
@@ -240,6 +245,82 @@ RLD
/// Integrated airlock electronics for setting access to a newly built airlocks
var/obj/item/electronics/airlock/airlock_electronics
COOLDOWN_DECLARE(destructive_scan_cooldown)
GLOBAL_VAR_INIT(icon_holographic_wall, init_holographic_wall())
GLOBAL_VAR_INIT(icon_holographic_window, init_holographic_window())
// `initial` does not work here. Neither does instantiating a wall/whatever
// and referencing that. I don't know why.
/proc/init_holographic_wall()
return getHologramIcon(
icon('icons/turf/walls/wall.dmi', "wall-0"),
opacity = 1,
)
/proc/init_holographic_window()
var/icon/grille_icon = icon('icons/obj/structures.dmi', "grille")
var/icon/window_icon = icon('icons/obj/smooth_structures/window.dmi', "window-0")
grille_icon.Blend(window_icon, ICON_OVERLAY)
return getHologramIcon(grille_icon)
/obj/item/construction/rcd/ui_action_click(mob/user, actiontype)
if (!COOLDOWN_FINISHED(src, destructive_scan_cooldown))
to_chat(user, "<span class='warning'>[src] lets out a low buzz.</span>")
return
COOLDOWN_START(src, destructive_scan_cooldown, RCD_DESTRUCTIVE_SCAN_COOLDOWN)
playsound(src, 'sound/items/rcdscan.ogg', 50, vary = TRUE, pressure_affected = FALSE)
var/turf/source_turf = get_turf(src)
for (var/turf/open/surrounding_turf in RANGE_TURFS(RCD_DESTRUCTIVE_SCAN_RANGE, source_turf))
var/rcd_memory = surrounding_turf.rcd_memory
if (!rcd_memory)
continue
var/skip_to_next_turf = FALSE
#if MIN_COMPILER_VERSION >= 514
#warn Please replace the loop below this warning with an `as anything` loop.
#endif
for (var/_content_of_turf in surrounding_turf.contents)
// `as anything` doesn't play well on 513 with special lists such as contents.
// When the minimum version is raised to 514, upgrade this to `as anything`.
var/atom/content_of_turf = _content_of_turf
if (content_of_turf.density)
skip_to_next_turf = TRUE
break
if (skip_to_next_turf)
continue
var/hologram_icon
switch (rcd_memory)
if (RCD_MEMORY_WALL)
hologram_icon = GLOB.icon_holographic_wall
if (RCD_MEMORY_WINDOWGRILLE)
hologram_icon = GLOB.icon_holographic_window
var/obj/effect/rcd_hologram/hologram = new (surrounding_turf)
hologram.icon = hologram_icon
animate(hologram, alpha = 0, time = RCD_HOLOGRAM_FADE_TIME, easing = CIRCULAR_EASING | EASE_IN)
/obj/effect/rcd_hologram
name = "hologram"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/obj/effect/rcd_hologram/Initialize(mapload)
. = ..()
QDEL_IN(src, RCD_HOLOGRAM_FADE_TIME)
#undef RCD_DESTRUCTIVE_SCAN_COOLDOWN
#undef RCD_DESTRUCTIVE_SCAN_RANGE
#undef RCD_HOLOGRAM_FADE_TIME
/obj/item/construction/rcd/suicide_act(mob/living/user)
var/turf/T = get_turf(user)
@@ -1132,11 +1213,14 @@ RLD
/obj/item/rcd_upgrade/silo_link
desc = "It contains direct silo connection RCD upgrade."
upgrade = RCD_UPGRADE_SILO_LINK
/obj/item/rcd_upgrade/furnishing
desc = "It contains the design for chairs, stools, tables, and glass tables."
upgrade = RCD_UPGRADE_FURNISHING
/datum/action/item_action/rcd_scan
name = "Destruction Scan"
desc = "Scans the surrounding area for destruction. Scanned structures will rebuild significantly faster."
#undef GLOW_MODE
#undef LIGHT_MODE
#undef REMOVE_MODE

View File

@@ -385,7 +385,10 @@
/obj/structure/girder/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.mode)
if(RCD_FLOORWALL)
return list("mode" = RCD_FLOORWALL, "delay" = 20, "cost" = 8)
return rcd_result_with_memory(
list("mode" = RCD_FLOORWALL, "delay" = 2 SECONDS, "cost" = 8),
get_turf(src), RCD_MEMORY_WALL,
)
if(RCD_DECONSTRUCT)
return list("mode" = RCD_DECONSTRUCT, "delay" = 20, "cost" = 13)
return FALSE

View File

@@ -54,9 +54,17 @@
if(RCD_DECONSTRUCT)
return list("mode" = RCD_DECONSTRUCT, "delay" = 20, "cost" = 5)
if(RCD_WINDOWGRILLE)
var/cost = 8
var/delay = 2 SECONDS
if(the_rcd.window_glass == RCD_WINDOW_REINFORCED)
return list("mode" = RCD_WINDOWGRILLE, "delay" = 40, "cost" = 12)
return list("mode" = RCD_WINDOWGRILLE, "delay" = 20, "cost" = 8)
delay = 4 SECONDS
cost = 12
return rcd_result_with_memory(
list("mode" = RCD_WINDOWGRILLE, "delay" = delay, "cost" = cost),
get_turf(src), RCD_MEMORY_WINDOWGRILLE,
)
return FALSE
/obj/structure/grille/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, passed_mode)

View File

@@ -81,6 +81,7 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list(
var/old_lighting_object = lighting_object
var/old_corners = corners
var/old_directional_opacity = directional_opacity
var/old_rcd_memory = rcd_memory
var/old_bp = blueprint_data
blueprint_data = null
@@ -110,6 +111,7 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list(
W.AfterChange(flags, old_type)
W.blueprint_data = old_bp
W.rcd_memory = old_rcd_memory
if(SSlighting.initialized)
lighting_object = old_lighting_object

View File

@@ -7,6 +7,7 @@
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = list(SMOOTH_GROUP_CLOSED_TURFS, SMOOTH_GROUP_WALLS, SMOOTH_GROUP_MATERIAL_WALLS)
canSmoothWith = list(SMOOTH_GROUP_MATERIAL_WALLS)
rcd_memory = null
material_flags = MATERIAL_ADD_PREFIX | MATERIAL_COLOR | MATERIAL_AFFECT_STATISTICS
/turf/closed/wall/material/break_wall()

View File

@@ -4,6 +4,7 @@
icon_state = ""
smoothing_flags = SMOOTH_BITMASK
canSmoothWith = null
rcd_memory = null
var/last_event = 0
var/active = null

View File

@@ -41,6 +41,7 @@
/turf/closed/wall/vault
icon = 'icons/turf/walls.dmi'
icon_state = "rockvault"
rcd_memory = null
/turf/closed/wall/ice
icon = 'icons/turf/walls/icedmetal_wall.dmi'
@@ -49,6 +50,7 @@
desc = "A wall covered in a thick sheet of ice."
smoothing_flags = SMOOTH_BITMASK
canSmoothWith = null
rcd_memory = null
hardness = 35
slicing_duration = 150 //welding through the ice+metal
bullet_sizzle = TRUE

View File

@@ -19,6 +19,8 @@
smoothing_groups = list(SMOOTH_GROUP_CLOSED_TURFS, SMOOTH_GROUP_WALLS)
canSmoothWith = list(SMOOTH_GROUP_WALLS)
rcd_memory = RCD_MEMORY_WALL
///lower numbers are harder. Used to determine the probability of a hulk smashing through.
var/hardness = 40
var/slicing_duration = 100 //default time taken to slice the wall
@@ -311,5 +313,4 @@
new /obj/effect/temp_visual/glowing_rune(src)
ChangeTurf(/turf/closed/wall/rust)
#undef MAX_DENT_DECALS

View File

@@ -238,7 +238,10 @@
/turf/open/floor/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.mode)
if(RCD_FLOORWALL)
return list("mode" = RCD_FLOORWALL, "delay" = 20, "cost" = 16)
return rcd_result_with_memory(
list("mode" = RCD_FLOORWALL, "delay" = 2 SECONDS, "cost" = 16),
src, RCD_MEMORY_WALL,
)
if(RCD_AIRLOCK)
if(the_rcd.airlock_glass)
return list("mode" = RCD_AIRLOCK, "delay" = 50, "cost" = 20)
@@ -247,7 +250,10 @@
if(RCD_DECONSTRUCT)
return list("mode" = RCD_DECONSTRUCT, "delay" = 50, "cost" = 33)
if(RCD_WINDOWGRILLE)
return list("mode" = RCD_WINDOWGRILLE, "delay" = 10, "cost" = 4)
return rcd_result_with_memory(
list("mode" = RCD_WINDOWGRILLE, "delay" = 1 SECONDS, "cost" = 4),
src, RCD_MEMORY_WINDOWGRILLE,
)
if(RCD_MACHINE)
return list("mode" = RCD_MACHINE, "delay" = 20, "cost" = 25)
if(RCD_COMPUTER)

View File

@@ -59,6 +59,11 @@ GLOBAL_LIST_EMPTY(station_turfs)
///the holodeck can load onto this turf if TRUE
var/holodeck_compatible = FALSE
/// If this turf contained an RCD'able object (or IS one, for walls)
/// but is now destroyed, this will preserve the value.
/// See __DEFINES/construction.dm for RCD_MEMORY_*.
var/rcd_memory
/turf/vv_edit_var(var_name, new_value)
var/static/list/banned_edits = list("x", "y", "z")
if(var_name in banned_edits)
@@ -116,7 +121,6 @@ GLOBAL_LIST_EMPTY(station_turfs)
if(T)
T.multiz_turf_new(src, UP)
if (opacity)
directional_opacity = ALL_CARDINALS
@@ -153,7 +157,7 @@ GLOBAL_LIST_EMPTY(station_turfs)
flags_1 &= ~INITIALIZED_1
requires_activation = FALSE
..()
vis_contents.Cut()
/turf/attack_hand(mob/user, list/modifiers)

BIN
sound/items/rcdscan.ogg Normal file

Binary file not shown.

View File

@@ -183,6 +183,7 @@
#include "code\__HELPERS\chat.dm"
#include "code\__HELPERS\cmp.dm"
#include "code\__HELPERS\config.dm"
#include "code\__HELPERS\construction.dm"
#include "code\__HELPERS\dates.dm"
#include "code\__HELPERS\dna.dm"
#include "code\__HELPERS\files.dm"