Files
Bubberstation/code/game/atom/atom_vv.dm
T
LemonInTheDarkandGitHub 9d14e327b5 Begins Improving Sparks/Flares Somewhat, Adds Animatable Light Overlays (#95362)
## About The Pull Request

[Adds a visual tick helper, integrates it into SSmove and
such](https://github.com/tgstation/tgstation/commit/e97035f9f74fad5c67c5bf19d8d5d3bb4bd476b4)

Basically, if we do "stuff" during verb time then the next chance
clients have to actually see it is on the next visual tick (rather then
the normal "this tick"). This is cause clients get their next frame
during maptick, and maptick runs before verbs.

We want to be able to handle this properly because if you say, create an
object and then move it on the same VISUAL tick (NOT game tick), it will
just teleport instead of playing out the move. I don't want this for
stuff like sparks, so we need a way to work around it.

[Moves most users of the _FAST flag to
_INSTANT](https://github.com/tgstation/tgstation/commit/6f96daac00519c69adc7554f52114798a65f3ad5)

These are the kids that don't immediately spawn something and the move
it, and we want to allow them to move actually as soon as possible
(important for stuff like space)

[Improves basic effect systems, makes their products delete when they
stop
moving](https://github.com/tgstation/tgstation/commit/172cb25d80ed34e1ec523172a1677fb524239fba)

Moves some stuff out to getters or vars so children can better decide
how long effects should last/how fast they should move. Uses this to
clean up weird dupe code used by explosions.

Makes all these effects delete on contact with something that stops
them. I'm doing this because an effect just hanging in the air looks
really really odd. Does have consequences for sparks that are already
moving at a wall though, might need a better way to handle that.

Makes all these effects use _FAST loops so they don't just hang in the
air for a second on spawn

Adds a setter proc on sparks for their duration, gonna use this to
improve their effects some

[Refactors overlay lights, adds support for animating their
images](https://github.com/tgstation/tgstation/commit/3ad0083cf2b536df51a6d93dca40eac20c1d62d1)

Implements light_render_source and relevant setters, this allows us to
replace the components of an overlay light with basically whatever we
want

Refactors overlay lighting to handle its images more consistently,
allowing us to hook into an image being modified

Combining the two of these will allow us to consistently copy a light's
image, modify it in some way, and then relay that modification back
down. Allowing us to animate it or do more advanced effects painlessly

Also, fixes ranges of 1 or less not rendering at all on initial set
(thank you kapu)

[In which I get fed up and add a macro helper for UID
generation](https://github.com/tgstation/tgstation/commit/aab48b03d407104d4f9cf9acb034494237def911)

[adds vv hooking for all existing lighting
vars](https://github.com/tgstation/tgstation/commit/b81c6200a0d74c36b440aa3f4c1f22c422090a2d)

[Upgrade effect system's dir picking to avoid duplicates when
possible](https://github.com/tgstation/tgstation/commit/18b622586b509c6be4c4bca4e3e7c175ad75fe91)

[Uses the technique described above to animate spark's lights out as
they
move](https://github.com/tgstation/tgstation/commit/67ba177982213799984a70e89536c5efb3d17e14)

This is a decently nice effect imo, it allows us to bump their power
(read, alpha) since it'll get animated away. I try to sync the animation
to the actual icon state's flow (it's 0.7s long). I also sped them up
somewhat to hopefully have a nicer looking effect? we'll see.

[Abstracts away intercepting overlay lights into a holder
datum](https://github.com/tgstation/tgstation/pull/95362/commits/b3f1fe74f2c3bab1d8912ab8a666bd05677ad032)

This should make it far easier to reuse this pattern!

[Fixes overlay lights flashing to double intensity when picked up off
the
ground](https://github.com/tgstation/tgstation/pull/95362/commits/1d83f2031fa2b33312b2aea4359c0c37c9d04ac7)

We needed to clear out their underlays BEFORE the animation

[Adds a flickering effect to flares and their
children](https://github.com/tgstation/tgstation/pull/95362/commits/b7a858e04a607c58b6c7fbe1476ffe2239e63bde)

I'm still not 100% happy with this, I was trying to avoid it feeling
like a heartbeat with random noise and I.. THINK it worked? it's
honestly quite hard to tell

[Adds the same flickering to lighters, welding tools and life
candles](https://github.com/tgstation/tgstation/pull/95362/commits/3ec44027e17835ae96702cec5f0b12d1f4deb32b)

Also, updated light candles to mirror the appearance of normal candles
and use overlay lighting

EDIT:
I realized while working on flares that I accidentally double applied
color, so if you saw the sparks animations before now it was different
(less vibrant). IDK if I like this better or worse but it is RIGHT and
that's what matters.

## Why It's Good For The Game

I got mad about how bad these looked, and this is a start at improving
them.
Also, adds a framework for more dynamic effects applied to overlay
lights (you could use this to apply a sort of "emergency rotating"
effect, or flicker/buzz for example).

<details>
 <summary>Before</summary>


https://github.com/user-attachments/assets/66437f27-ee3c-4f14-a7ee-4a1c3e68533a


https://github.com/user-attachments/assets/ed14fff8-a7eb-47fe-bab5-9a490ac96629

</details>

<details>
 <summary>After</summary>


https://github.com/user-attachments/assets/fb24ff2e-c745-42a5-8e11-c8a1eeef35a5


https://github.com/user-attachments/assets/fd8c2116-cb92-4fe6-ad3e-786a6538e52a

</details>

## Changelog
🆑
add: Reworks how sparks render. They're now a bit brighter, will fade
out as they move/if they hit something, will stack with each other less
and also won't start hang in the air on spawn.
add: Added a flickering effect to lighters, welding tools, flares,
torches and candles (since they're flames).
fix: Overlay based lights (think flashlights) will no longer flash to
double intensity while being picked up.
refactor: Reworked how some effects (explosion particles, sparks, some
reagent stuff) function, report any bugs!
/🆑
2026-03-20 14:48:57 +13:00

323 lines
11 KiB
Plaintext

/**
* Return the markup to for the dropdown list for the VV panel for this atom
*
* Override in subtypes to add custom VV handling in the VV panel
*/
/atom/vv_get_dropdown()
. = ..()
VV_DROPDOWN_OPTION("", "---------")
if(!ismovable(src))
var/turf/curturf = get_turf(src)
if(curturf)
. += "<option value='?_src_=holder;[HrefToken()];adminplayerobservecoodjump=1;X=[curturf.x];Y=[curturf.y];Z=[curturf.z]'>Jump To</option>"
VV_DROPDOWN_OPTION(VV_HK_MODIFY_TRANSFORM, "Modify Transform")
VV_DROPDOWN_OPTION(VV_HK_SPIN_ANIMATION, "SpinAnimation")
VV_DROPDOWN_OPTION(VV_HK_STOP_ALL_ANIMATIONS, "Stop All Animations")
VV_DROPDOWN_OPTION(VV_HK_SHOW_HIDDENPRINTS, "Show Hiddenprint log")
VV_DROPDOWN_OPTION(VV_HK_ADD_REAGENT, "Add Reagent")
VV_DROPDOWN_OPTION(VV_HK_TRIGGER_EMP, "EMP Pulse")
VV_DROPDOWN_OPTION(VV_HK_TRIGGER_EXPLOSION, "Explosion")
VV_DROPDOWN_OPTION(VV_HK_EDIT_FILTERS, "Edit Filters")
VV_DROPDOWN_OPTION(VV_HK_EDIT_COLOR_MATRIX, "Edit Color as Matrix")
VV_DROPDOWN_OPTION(VV_HK_TEST_MATRIXES, "Test Matrices")
VV_DROPDOWN_OPTION(VV_HK_ADD_AI, "Add AI controller")
VV_DROPDOWN_OPTION(VV_HK_ARMOR_MOD, "Modify Armor")
if(greyscale_colors)
VV_DROPDOWN_OPTION(VV_HK_MODIFY_GREYSCALE, "Modify greyscale colors")
/atom/vv_do_topic(list/href_list)
. = ..()
if(!.)
return
if(href_list[VV_HK_ADD_REAGENT])
if(!check_rights(R_VAREDIT))
return
if(!reagents)
var/amount = input(usr, "Specify the reagent size of [src]", "Set Reagent Size", 50) as num|null
if(amount)
create_reagents(amount)
if(reagents)
var/chosen_id
switch(tgui_alert(usr, "Choose a method.", "Add Reagents", list("Search", "Choose from a list", "I'm feeling lucky")))
if("Search")
var/valid_id
while(!valid_id)
chosen_id = input(usr, "Enter the ID of the reagent you want to add.", "Search reagents") as null|text
if(isnull(chosen_id)) //Get me out of here!
break
if (!ispath(text2path(chosen_id)))
chosen_id = pick_closest_path(chosen_id, make_types_fancy(subtypesof(/datum/reagent)))
if (ispath(chosen_id))
valid_id = TRUE
else
valid_id = TRUE
if(!valid_id)
to_chat(usr, span_warning("A reagent with that ID doesn't exist!"))
if("Choose from a list")
chosen_id = input(usr, "Choose a reagent to add.", "Choose a reagent.") as null|anything in sort_list(subtypesof(/datum/reagent), GLOBAL_PROC_REF(cmp_typepaths_asc))
if("I'm feeling lucky")
chosen_id = pick(subtypesof(/datum/reagent))
if(chosen_id)
var/amount = input(usr, "Choose the amount to add.", "Choose the amount.", reagents.maximum_volume) as num|null
if(amount)
reagents.add_reagent(chosen_id, amount)
log_admin("[key_name(usr)] has added [amount] units of [chosen_id] to [src]")
message_admins(span_notice("[key_name(usr)] has added [amount] units of [chosen_id] to [src]"))
if(href_list[VV_HK_TRIGGER_EXPLOSION])
return SSadmin_verbs.dynamic_invoke_verb(usr, /datum/admin_verb/admin_explosion, src)
if(href_list[VV_HK_TRIGGER_EMP])
return SSadmin_verbs.dynamic_invoke_verb(usr, /datum/admin_verb/admin_emp, src)
if(href_list[VV_HK_SHOW_HIDDENPRINTS])
if(!check_rights(R_ADMIN))
return
usr.client.cmd_show_hiddenprints(src)
if(href_list[VV_HK_ARMOR_MOD])
if(!check_rights(NONE))
return
var/list/picker_list = list()
var/list/armor_list = get_armor().get_rating_list()
for (var/rating in armor_list)
picker_list += list(list("value" = armor_list[rating], "name" = rating))
var/list/result = present_picker(usr, "Modify armor", "Modify armor: [src]", button_1 = "Save", button_2 = "Cancel", timeout = FALSE, input_type = "text", values = picker_list)
if(!islist(result))
return
if(result["button"] == 2) // If the user pressed the cancel button
return
var/list/armor_all = ARMOR_LIST_ALL
// text2num conveniently returns a null on invalid values
var/list/converted = list()
for(var/armor_key in armor_all)
converted[armor_key] = text2num(result["values"][armor_key])
set_armor(get_armor().generate_new_with_specific(converted))
var/message = "[key_name(usr)] modified the armor on [src] ([type]) to: "
for(var/armor_key in armor_all)
message += "[armor_key]=[get_armor_rating(armor_key)],"
message = copytext(message, 1, -1)
log_admin(span_notice(message))
message_admins(span_notice(message))
if(href_list[VV_HK_ADD_AI])
if(!check_rights(R_VAREDIT))
return
var/result = input(usr, "Choose the AI controller to apply to this atom WARNING: Not all AI works on all atoms.", "AI controller") as null|anything in subtypesof(/datum/ai_controller)
if(!result)
return
ai_controller = new result(src)
if(href_list[VV_HK_MODIFY_TRANSFORM])
if(!check_rights(R_VAREDIT))
return
var/result = input(usr, "Choose the transformation to apply","Transform Mod") as null|anything in list("Scale","Translate","Rotate","Shear")
var/matrix/M = transform
if(!result)
return
switch(result)
if("Scale")
var/x = input(usr, "Choose x mod","Transform Mod") as null|num
var/y = input(usr, "Choose y mod","Transform Mod") as null|num
if(isnull(x) || isnull(y))
return
transform = M.Scale(x,y)
if("Translate")
var/x = input(usr, "Choose x mod (negative = left, positive = right)","Transform Mod") as null|num
var/y = input(usr, "Choose y mod (negative = down, positive = up)","Transform Mod") as null|num
if(isnull(x) || isnull(y))
return
transform = M.Translate(x,y)
if("Shear")
var/x = input(usr, "Choose x mod","Transform Mod") as null|num
var/y = input(usr, "Choose y mod","Transform Mod") as null|num
if(isnull(x) || isnull(y))
return
transform = M.Shear(x,y)
if("Rotate")
var/angle = input(usr, "Choose angle to rotate","Transform Mod") as null|num
if(isnull(angle))
return
transform = M.Turn(angle)
SEND_SIGNAL(src, COMSIG_ATOM_VV_MODIFY_TRANSFORM)
if(href_list[VV_HK_SPIN_ANIMATION])
if(!check_rights(R_VAREDIT))
return
var/num_spins = input(usr, "Do you want infinite spins?", "Spin Animation") in list("Yes", "No")
if(num_spins == "No")
num_spins = input(usr, "How many spins?", "Spin Animation") as null|num
else
num_spins = -1
if(!num_spins)
return
var/spins_per_sec = input(usr, "How many spins per second?", "Spin Animation") as null|num
if(!spins_per_sec)
return
var/direction = input(usr, "Which direction?", "Spin Animation") in list("Clockwise", "Counter-clockwise")
switch(direction)
if("Clockwise")
direction = 1
if("Counter-clockwise")
direction = 0
else
return
SpinAnimation(1 SECONDS / spins_per_sec, num_spins, direction)
if(href_list[VV_HK_STOP_ALL_ANIMATIONS])
if(!check_rights(R_VAREDIT))
return
var/result = input(usr, "Are you sure?", "Stop Animating") in list("Yes", "No")
if(result == "Yes")
animate(src, transform = null, flags = ANIMATION_END_NOW) // Literally just fucking stop animating entirely because admin said so
return
if(href_list[VV_HK_AUTO_RENAME])
if(!check_rights(R_VAREDIT))
return
var/newname = input(usr, "What do you want to rename this to?", "Automatic Rename") as null|text
// Check the new name against the chat filter. If it triggers the IC chat filter, give an option to confirm.
if(newname && !(is_ic_filtered(newname) || is_soft_ic_filtered(newname) && tgui_alert(usr, "Your selected name contains words restricted by IC chat filters. Confirm this new name?", "IC Chat Filter Conflict", list("Confirm", "Cancel")) != "Confirm"))
vv_auto_rename(newname)
if(href_list[VV_HK_EDIT_FILTERS])
if(!check_rights(R_VAREDIT))
return
usr.client?.open_filter_editor(src)
if(href_list[VV_HK_EDIT_COLOR_MATRIX])
if(!check_rights(R_VAREDIT))
return
usr.client?.open_color_matrix_editor(src)
if(href_list[VV_HK_TEST_MATRIXES])
if(!check_rights(R_VAREDIT))
return
usr.client?.open_matrix_tester(src)
/atom/vv_get_header()
. = ..()
var/refid = REF(src)
. += "[VV_HREF_TARGETREF(refid, VV_HK_AUTO_RENAME, "<b id='name'>[src]</b>")]"
. += "<br><font size='1'><a href='byond://?_src_=vars;[HrefToken()];rotatedatum=[refid];rotatedir=left'><<</a> <a href='byond://?_src_=vars;[HrefToken()];datumedit=[refid];varnameedit=dir' id='dir'>[dir2text(dir) || dir]</a> <a href='byond://?_src_=vars;[HrefToken()];rotatedatum=[refid];rotatedir=right'>>></a></font>"
/**
* call back when a var is edited on this atom
*
* Can be used to implement special handling of vars
*
* At the atom level, if you edit a var named "color" it will add the atom colour with
* admin level priority to the atom colours list
*
* Also, if GLOB.debugging_enabled is FALSE, it sets the [ADMIN_SPAWNED_1] flag on [flags_1][/atom/var/flags_1], which signifies
* the object has been admin edited
*/
/atom/vv_edit_var(var_name, var_value)
var/old_light_flags = light_flags
// Disable frozen lights for now, so we can actually modify it
light_flags &= ~LIGHT_FROZEN
switch(var_name)
if(NAMEOF(src, light_range))
if(light_system == COMPLEX_LIGHT)
set_light(l_range = var_value)
else
set_light_range(var_value)
. = TRUE
if(NAMEOF(src, light_power))
if(light_system == COMPLEX_LIGHT)
set_light(l_power = var_value)
else
set_light_power(var_value)
. = TRUE
if(NAMEOF(src, light_color))
if(light_system == COMPLEX_LIGHT)
set_light(l_color = var_value)
else
set_light_color(var_value)
. = TRUE
if(NAMEOF(src, light_angle))
if(light_system == COMPLEX_LIGHT)
set_light(l_angle = var_value)
. = TRUE
if(NAMEOF(src, light_dir))
if(light_system == COMPLEX_LIGHT)
set_light(l_dir = var_value)
. = TRUE
if(NAMEOF(src, light_height))
if(light_system == COMPLEX_LIGHT)
set_light(l_height = var_value)
. = TRUE
if(NAMEOF(src, light_on))
if(light_system == COMPLEX_LIGHT)
set_light(l_on = var_value)
else
set_light_on(var_value)
. = TRUE
if(NAMEOF(src, light_flags))
set_light_flags(var_value)
// I'm sorry
old_light_flags = var_value
. = TRUE
if(NAMEOF(src, light_render_source))
set_light_render_source(var_value)
. = TRUE
if(NAMEOF(src, light_angle))
if(light_system == COMPLEX_LIGHT)
set_light(l_angle = var_value)
else
set_light_angle(var_value)
. = TRUE
if(NAMEOF(src, light_dir))
if(light_system == COMPLEX_LIGHT)
set_light(l_dir = var_value)
else
set_light_dir(var_value)
. = TRUE
if(NAMEOF(src, light_height))
if(light_system == COMPLEX_LIGHT)
set_light(l_height = var_value)
else
set_light_height(var_value)
. = TRUE
if(NAMEOF(src, smoothing_junction))
set_smoothed_icon_state(var_value)
. = TRUE
if(NAMEOF(src, opacity))
set_opacity(var_value)
. = TRUE
if(NAMEOF(src, base_pixel_x))
set_base_pixel_x(var_value)
. = TRUE
if(NAMEOF(src, base_pixel_y))
set_base_pixel_y(var_value)
. = TRUE
if(NAMEOF(src, material_flags))
toggle_material_flags(var_value)
. = TRUE
if(NAMEOF(src, material_modifier))
change_material_modifier(var_value)
. = TRUE
light_flags = old_light_flags
if(!isnull(.))
datum_flags |= DF_VAR_EDITED
return
if(!GLOB.debugging_enabled)
flags_1 |= ADMIN_SPAWNED_1
. = ..()
switch(var_name)
if(NAMEOF(src, color))
add_atom_colour(color, ADMIN_COLOUR_PRIORITY)
update_appearance()
/atom/proc/vv_auto_rename(newname)
name = newname