mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-06-05 14:17:12 +01:00
add6d49951
## About The Pull Request
1. Debloats the RCD.dm file i.e. renames it to RHD[Rapid handheld device
the base for all rcd like devices] and moves its subtypes into their
respective files
`/obj/item/construction/rcd` moved to RCD.dm
`/obj/item/construction/rld` moved to RLD.dm
`/obj/item/construction/plumbing` moved to RPLD.dm
`/obj/item/construction/rtd` stays in RTD.dm
Other rcd like device i.e. RPD, RFC, RWD, along with the above mentioned
files are now all moved into 1 folder called "rcd"
majority of the `to_chat()` are now replaced with `balloon_alert()` to
reduce spam
2. Adds early returns, optimizes & adds extra resource sanity checks
before and after the `do_after()` proc for the RLD. RLD silo links now
works again.
- RLD now uses an ammo bar just like the RCD for updating only its
overlays & not its entire icon state, it also has a blinking yellow icon
state when low on ammo
- Remove unused empty blinking yellow icon state for plumbing RCD.
nobody designed the ammo bars for them so having`has_ammobar = TRUE`
caused the unit tests to fail
4. Adds extra structure placement & resource sanity checks for RCD, RTD
& Plumbing RCD before & after the `do_after()` proc
RCD Patches
- removes unused vars window_type & window_glass, these can be infered
from window_type directly
- removes furnish type & cost and let the rcd_vals() proc decide those
for consistency
- copies the rcd stuff from turf/floor to turf/open/misc with some
exceptions, It wasen't updated in a long time
- rcd vals i.e. cost & delay for window types are set for each
directional, full-tile, reinforced types. These all used constant values
& now they are adjusted accordingly
RTD patches
- Fixes #74526 RTD can lay floor tiles on all types of plating's
- The cost of deconstructing tiles was not calculated correctly i.e. it
always used the cost of the selected design & not the cost of the actual
floor type we are trying to deconstruct
- The construction & deconstruction time was constant & very fast for
all tile types, now the delay is adjusted based on the cost of the type
of tile in question
- RTD now has a blinking yellow empty icon state just like the RCD when
low on ammo
6. Fixes #73479 RCL now updates its pipe cleaning coil appearance when
changing colours & selecting white colour no longer yields a random coil
colour
7. makes sure `useResource() ` actually succeeds before doing any
action. The return value of this proc was not previously checked for
some devices
## Why It's Good For The Game
1. rcd like devices all moved into 1 folder for better organization
2. splits the original RCD.dm file into more logical & manageable files
for better maintainability
3. removes unused code & adds some extra sanity checks for everything
4. adds missing sprites for RLD & RTD
## Changelog
🆑
code: RCD & all its subtypes and other devices like it[RTD, RLD,
Plumbing RCD, RWD, RFC, RPD] now moved into 1 folder, removes unused
vars
refactor: RCD window type cost & delay are set based on the window type
selected.
refactor: RLD, RCD & plumbing RCD now has extra resource & target
placement sanity checks, optimizes RLD and code readability.
refactor: RTD now sets the correct delay with the cost of the tile type
currently being constructed/deconstructed taken into account
refactor: large majority of to_chat() replaced with balloon alerts
fix: RLD silo link now works again
fix: RTD can place tiles on any subtype of plating
fix: RCL now lays the correct colour of pipe cleaner when its colour is
changed
imageadd: empty blinking yellow icon states for RTD & RLD & an ammo bar
for RLD
/🆑
207 lines
6.3 KiB
Plaintext
207 lines
6.3 KiB
Plaintext
// RAPID LIGHTING DEVICE
|
|
|
|
#define GLOW_MODE 3
|
|
#define LIGHT_MODE 2
|
|
#define REMOVE_MODE 1
|
|
|
|
/obj/item/construction/rld
|
|
name = "Rapid Lighting Device"
|
|
desc = "A device used to rapidly provide lighting sources to an area. Reload with iron, plasteel, glass or compressed matter cartridges."
|
|
icon = 'icons/obj/tools.dmi'
|
|
icon_state = "rld"
|
|
worn_icon_state = "RPD"
|
|
lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi'
|
|
matter = 200
|
|
max_matter = 200
|
|
slot_flags = ITEM_SLOT_BELT
|
|
has_ammobar = TRUE
|
|
ammo_sections = 6
|
|
///it does not make sense why any of these should be installed
|
|
banned_upgrades = RCD_UPGRADE_FRAMES | RCD_UPGRADE_SIMPLE_CIRCUITS | RCD_UPGRADE_FURNISHING
|
|
|
|
var/mode = LIGHT_MODE
|
|
var/wallcost = 10
|
|
var/floorcost = 15
|
|
var/launchcost = 5
|
|
var/deconcost = 10
|
|
|
|
var/condelay = 10
|
|
var/decondelay = 15
|
|
|
|
///reference to thr original icons
|
|
var/list/original_options = list(
|
|
"Color Pick" = icon(icon = 'icons/hud/radial.dmi', icon_state = "omni"),
|
|
"Glow Stick" = icon(icon = 'icons/obj/lighting.dmi', icon_state = "glowstick"),
|
|
"Deconstruct" = icon(icon = 'icons/obj/tools.dmi', icon_state = "wrench"),
|
|
"Light Fixture" = icon(icon = 'icons/obj/lighting.dmi', icon_state = "ltube"),
|
|
)
|
|
///will contain the original icons modified with the color choice
|
|
var/list/display_options = list()
|
|
var/color_choice = "#ffffff"
|
|
|
|
/obj/item/construction/rld/Initialize(mapload)
|
|
. = ..()
|
|
for(var/option in original_options)
|
|
display_options[option] = icon(original_options[option])
|
|
|
|
/obj/item/construction/rld/attack_self(mob/user)
|
|
. = ..()
|
|
|
|
if((upgrade & RCD_UPGRADE_SILO_LINK) && display_options["Silo Link"] == null) //silo upgrade instaled but option was not updated then update it just one
|
|
display_options["Silo Link"] = icon(icon = 'icons/obj/mining.dmi', icon_state = "silo")
|
|
|
|
var/choice = show_radial_menu(user, src, display_options, custom_check = CALLBACK(src, PROC_REF(check_menu), user), require_near = TRUE, tooltips = TRUE)
|
|
if(!check_menu(user))
|
|
return
|
|
if(!choice)
|
|
return
|
|
|
|
switch(choice)
|
|
if("Light Fixture")
|
|
mode = LIGHT_MODE
|
|
to_chat(user, span_notice("You change RLD's mode to 'Permanent Light Construction'."))
|
|
if("Glow Stick")
|
|
mode = GLOW_MODE
|
|
to_chat(user, span_notice("You change RLD's mode to 'Light Launcher'."))
|
|
if("Color Pick")
|
|
var/new_choice = input(user,"","Choose Color",color_choice) as color
|
|
if(new_choice == null)
|
|
return
|
|
|
|
var/list/new_rgb = ReadRGB(new_choice)
|
|
for(var/option in original_options)
|
|
if(option == "Color Pick" || option == "Deconstruct" || option == "Silo Link")
|
|
continue
|
|
var/icon/icon = icon(original_options[option])
|
|
icon.SetIntensity(new_rgb[1]/255, new_rgb[2]/255, new_rgb[3]/255) //apply new scale
|
|
display_options[option] = icon
|
|
|
|
color_choice = new_choice
|
|
if("Deconstruct")
|
|
mode = REMOVE_MODE
|
|
to_chat(user, span_notice("You change RLD's mode to 'Deconstruct'."))
|
|
else
|
|
toggle_silo(user)
|
|
|
|
/obj/item/construction/rld/afterattack(atom/A, mob/user)
|
|
. = ..()
|
|
if(!range_check(A,user))
|
|
return
|
|
var/turf/start = get_turf(src)
|
|
switch(mode)
|
|
if(REMOVE_MODE)
|
|
if(!istype(A, /obj/machinery/light/))
|
|
return FALSE
|
|
|
|
//resource sanity checks before & after delay
|
|
if(!checkResource(deconcost, user))
|
|
return FALSE
|
|
var/beam = user.Beam(A,icon_state="light_beam", time = 15)
|
|
playsound(loc, 'sound/machines/click.ogg', 50, TRUE)
|
|
if(!do_after(user, decondelay, target = A))
|
|
qdel(beam)
|
|
return FALSE
|
|
if(!checkResource(deconcost, user))
|
|
return FALSE
|
|
|
|
if(!useResource(deconcost, user))
|
|
return FALSE
|
|
activate()
|
|
qdel(A)
|
|
return TRUE
|
|
|
|
if(LIGHT_MODE)
|
|
//resource sanity checks before & after delay
|
|
if(!checkResource(floorcost, user))
|
|
return FALSE
|
|
var/beam = user.Beam(A,icon_state="light_beam", time = condelay)
|
|
playsound(loc, 'sound/machines/click.ogg', 50, TRUE)
|
|
playsound(loc, 'sound/effects/light_flicker.ogg', 50, FALSE)
|
|
if(!do_after(user, condelay, target = A))
|
|
qdel(beam)
|
|
return FALSE
|
|
if(!checkResource(floorcost, user))
|
|
return FALSE
|
|
|
|
if(iswallturf(A))
|
|
var/turf/open/winner = null
|
|
var/winning_dist = null
|
|
var/skip = FALSE
|
|
for(var/direction in GLOB.cardinals)
|
|
var/turf/C = get_step(A, direction)
|
|
//turf already has a light
|
|
skip = FALSE
|
|
for(var/obj/machinery/light/dupe in C)
|
|
if(istype(dupe, /obj/machinery/light))
|
|
skip = TRUE
|
|
break
|
|
if(skip)
|
|
continue
|
|
//can't put a light here
|
|
if(!(isspaceturf(C) || TURF_SHARES(C)))
|
|
continue
|
|
//find turf closest to our player
|
|
var/x0 = C.x
|
|
var/y0 = C.y
|
|
var/contender = CHEAP_HYPOTENUSE(start.x, start.y, x0, y0)
|
|
if(!winner)
|
|
winner = C
|
|
winning_dist = contender
|
|
else if(contender < winning_dist) // lower is better
|
|
winner = C
|
|
winning_dist = contender
|
|
if(!winner)
|
|
balloon_alert(user, "no valid target!")
|
|
return FALSE
|
|
|
|
if(!useResource(wallcost, user))
|
|
return FALSE
|
|
activate()
|
|
var/obj/machinery/light/L = new /obj/machinery/light(get_turf(winner))
|
|
L.setDir(get_dir(winner, A))
|
|
L.color = color_choice
|
|
L.set_light_color(color_choice)
|
|
return TRUE
|
|
|
|
if(isfloorturf(A))
|
|
var/turf/target = get_turf(A)
|
|
for(var/obj/machinery/light/floor/dupe in target)
|
|
if(istype(dupe))
|
|
return FALSE
|
|
|
|
if(!useResource(floorcost, user))
|
|
return FALSE
|
|
activate()
|
|
var/obj/machinery/light/floor/FL = new /obj/machinery/light/floor(target)
|
|
FL.color = color_choice
|
|
FL.set_light_color(color_choice)
|
|
return TRUE
|
|
|
|
if(GLOW_MODE)
|
|
if(!useResource(launchcost, user))
|
|
return FALSE
|
|
activate()
|
|
var/obj/item/flashlight/glowstick/G = new /obj/item/flashlight/glowstick(start)
|
|
G.color = color_choice
|
|
G.set_light_color(G.color)
|
|
G.throw_at(A, 9, 3, user)
|
|
G.on = TRUE
|
|
G.update_brightness()
|
|
|
|
return TRUE
|
|
|
|
/obj/item/construction/rld/mini
|
|
name = "mini-rapid-light-device"
|
|
desc = "A device used to rapidly provide lighting sources to an area. Reload with iron, plasteel, glass or compressed matter cartridges."
|
|
icon = 'icons/obj/tools.dmi'
|
|
icon_state = "rld"
|
|
lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi'
|
|
matter = 100
|
|
max_matter = 100
|
|
|
|
#undef GLOW_MODE
|
|
#undef LIGHT_MODE
|
|
#undef REMOVE_MODE
|