Implements some of the helpers I made for #90354 (#90436)

## About The Pull Request
Adds a couple helpers from #90354

1. `/proc/pick_recursive()` > able to take in nested lists and pick one
object from them. Works the same way `pick_weight_recursive()` does,
just without all the extra `_weight` stuff
2. `span_tinynicegreen()` > we had span_tiny for danger and notice but
not nicegreen, just filling that gap
3. `/matrix/proc/get_angle()` > Tells us the angle a matrix is currently
in
4. `GLOB.all_tool_behaviours` > in case you wanted an easy list for all
tool behaviors
5. `transition_filter_chain()` > a more complicated one, this is used if
you want to make an animation chain for a filter. (Thank you
LemonInTheDark for the help on this one.)
## Why It's Good For The Game

Helpful stuff for future coders is good
## Changelog
🆑 Wallem, LemonInTheDark 
code: Added a couple helpers & procs for coders
/🆑
This commit is contained in:
Wallem
2025-04-29 17:44:07 -06:00
committed by Shadow-Quill
parent f5f64c2a9e
commit 753d8a2440
17 changed files with 102 additions and 44 deletions
+2
View File
@@ -0,0 +1,2 @@
/// The animation/chain runs indefinitely
#define INDEFINITE -1
+1
View File
@@ -145,6 +145,7 @@
#define span_tinydanger(str) ("<span class='tinydanger'>" + str + "</span>")
#define span_tinynotice(str) ("<span class='tinynotice'>" + str + "</span>")
#define span_tinynoticeital(str) ("<span class='tinynoticeital'>" + str + "</span>")
#define span_tinynicegreen(str) ("<span class='tinynicegreen'>" + str + "</span>")
#define span_unconscious(str) ("<span class='unconscious'>" + str + "</span>")
#define span_userdanger(str) ("<span class='userdanger'>" + str + "</span>")
#define span_warning(str) ("<span class='warning'>" + str + "</span>")
+1
View File
@@ -1,4 +1,5 @@
// Tool types, if you add new ones please add them to /obj/item/debug/omnitool in code/game/objects/items/debug_items.dm
// and to GLOB.all_tool_behaviours in code/_globalvars/lists/engineering.dm
#define TOOL_CROWBAR "crowbar"
#define TOOL_MULTITOOL "multitool"
#define TOOL_SCREWDRIVER "screwdriver"
+17
View File
@@ -1327,3 +1327,20 @@
&& deep_compare_list(log_1["stack"], log_2["stack"])
else
return TRUE
/**
* Similar to pick_weight_recursive, except without the weight part, meaning it should hopefully not take
* up as much computing power for things that don't +need+ weights.
* * * Able to handle cases such as:
* * pick_recursive(list(a), list(b), list(c))
* * pick_recursive(list(list(a), list(b)))
* * pick_recursive(a, list(b), list(list(c), list(d)))
* * pick_recusrive(list(a, b, c), d, e)
* Really any combination of lists & vars, as long as the passed lists aren't empty
*/
/proc/pick_recursive(...)
var/result = pick(args)
while(islist(result))
result = pick(result)
return result
+4
View File
@@ -86,6 +86,10 @@ c f 1
/matrix/proc/get_y_shift()
. = f
///The angle of this matrix
/matrix/proc/get_angle()
. = -ATAN2(a,d)
/////////////////////
// COLOUR MATRICES //
/////////////////////
+2
View File
@@ -376,6 +376,8 @@ GLOBAL_DATUM(syndicate_code_response_regex, /regex)
return "a blood filter"
if(TOOL_ROLLINGPIN)
return "a rolling pin"
if(TOOL_RUSTSCRAPER)
return "a rust scraper"
else
return "something... but the gods didn't set this up right (Please report this bug)"
+2
View File
@@ -144,6 +144,8 @@ GLOBAL_LIST_INIT(spanname_to_formatting, list(
"Tape Recorder" = "tape_recorder",
"Tiny Notice" = "tinynotice",
"Tiny Notice Italic" = "tinynoticeital",
"Tiny Danger" = "tinydanger",
"Tiny Nice Green" = "tinynicegreen",
"Unconscious" = "unconscious",
"User Danger" = "userdanger",
"Warning" = "warning",
+23
View File
@@ -0,0 +1,23 @@
// List of all tool behaviours.
GLOBAL_LIST_INIT(all_tool_behaviours, list(
TOOL_ANALYZER,
TOOL_BLOODFILTER,
TOOL_BONESET,
TOOL_CAUTERY,
TOOL_CROWBAR,
TOOL_DRILL,
TOOL_HEMOSTAT,
TOOL_KNIFE,
TOOL_MINING,
TOOL_MULTITOOL,
TOOL_RETRACTOR,
TOOL_ROLLINGPIN,
TOOL_RUSTSCRAPER,
TOOL_SAW,
TOOL_SCALPEL,
TOOL_SCREWDRIVER,
TOOL_SHOVEL,
TOOL_WELDER,
TOOL_WIRECUTTER,
TOOL_WRENCH,
))
+34
View File
@@ -385,6 +385,40 @@
animate(filter, new_params, time = time, easing = easing, loop = loop)
modify_filter(name, new_params)
/** Keeps the steps in the correct order.
* Arguments:
* * params - the parameters you want this step to animate to
* * duration - the time it takes to animate this step
* * easing - the type of easing this step has
*/
/proc/FilterChainStep(params, duration, easing)
params -= "type"
return list("params"= params, "duration"=duration, "easing"=easing)
/** Similar to transition_filter(), except it creates an animation chain that moves between a list of states.
* Arguments:
* * name - Filter name
* * num_loops - Amount of times the chain loops. INDEFINITE = Infinite
* * ... - a list of each link in the animation chain. Use FilterChainStep(params, duration, easing) for each link
* Example use:
* * add_filter("blue_pulse", 1, color_matrix_filter(COLOR_WHITE))
* * transition_filter_chain(src, "blue_pulse", INDEFINITE,\
* * FilterChainStep(color_matrix_filter(COLOR_BLUE), 10 SECONDS, CUBIC_EASING),\
* * FilterChainStep(color_matrix_filter(COLOR_WHITE), 10 SECONDS, CUBIC_EASING))
* The above code would edit a color_matrix_filter() to slowly turn blue over 10 seconds before returning back to white 10 seconds after, repeating this chain forever.
*/
/datum/proc/transition_filter_chain(name, num_loops, ...)
var/list/transition_steps = args.Copy(3)
var/filter = get_filter(name)
if(!filter)
return
var/list/first_step = transition_steps[1]
animate(filter, first_step["params"], time = first_step["duration"], easing = first_step["easing"], loop = num_loops)
for(var/transition_step in 2 to length(transition_steps))
var/list/this_step = transition_steps[transition_step]
animate(this_step["params"], time = this_step["duration"], easing = this_step["easing"])
/// Updates the priority of the passed filter key
/datum/proc/change_filter_priority(name, new_priority)
if(!filter_data || !filter_data[name])
+1 -21
View File
@@ -52,27 +52,7 @@
return TRUE
/obj/item/debug/omnitool/get_all_tool_behaviours()
return list(TOOL_ANALYZER,
TOOL_BLOODFILTER,
TOOL_BONESET,
TOOL_CAUTERY,
TOOL_CROWBAR,
TOOL_DRILL,
TOOL_HEMOSTAT,
TOOL_KNIFE,
TOOL_MINING,
TOOL_MULTITOOL,
TOOL_RETRACTOR,
TOOL_ROLLINGPIN,
TOOL_RUSTSCRAPER,
TOOL_SAW,
TOOL_SCALPEL,
TOOL_SCREWDRIVER,
TOOL_SHOVEL,
TOOL_WELDER,
TOOL_WIRECUTTER,
TOOL_WRENCH,
)
return GLOB.all_tool_behaviours
/obj/item/debug/omnitool/attack_self(mob/user)
if(!user)
@@ -463,7 +463,7 @@
if(isnull(linked_extract))
qdel(src)
return
if(linked_extract.get_held_mob() == owner)
if(get_atom_on_turf(linked_extract, /mob/living) == owner)
return
owner.balloon_alert(owner, "[colour] extract faded!")
if(!QDELETED(linked_extract))
@@ -22,25 +22,8 @@ Stabilized extracts:
qdel(linked_effect)
return ..()
/// Returns the mob that is currently holding us if we are either in their inventory or a backpack analogue.
/// Returns null if it's in an invalid location, so that we can check explicitly for null later.
/obj/item/slimecross/stabilized/proc/get_held_mob()
if(isnull(loc))
return null
if(isliving(loc))
return loc
// Snowflake check for modsuit backpacks, which should be valid but are 3 rather than 2 steps from the owner
if(istype(loc, /obj/item/mod/module/storage))
var/obj/item/mod/module/storage/mod_backpack = loc
var/mob/living/modsuit_wearer = mod_backpack.mod?.wearer
return modsuit_wearer ? modsuit_wearer : null
var/nested_loc = loc.loc
if (isliving(nested_loc))
return nested_loc
return null
/obj/item/slimecross/stabilized/process()
var/mob/living/holder = get_held_mob()
var/mob/living/holder = get_atom_on_turf(src, /mob/living)
if(isnull(holder))
return
var/effectpath = /datum/status_effect/stabilized
@@ -118,10 +118,6 @@
balloon_alert(organ_owner, "your heart strengthtens")
playsound(organ_owner, 'sound/items/eshield_recharge.ogg', 40)
///Returns the mob we are implanted in so that the electricity effect doesn't runtime
/obj/item/organ/heart/cybernetic/anomalock/proc/get_held_mob()
return owner
/obj/item/organ/heart/cybernetic/anomalock/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(!istype(tool, required_anomaly))
return NONE
+1
View File
@@ -95,6 +95,7 @@ h1.alert, h2.alert {color: #000000;}
.grey {color: #838383;}
.nicegreen {color: #14a833;}
.boldnicegreen {color: #14a833; font-weight: bold;}
.tinynicegreen {color: #14a833; font-size: 85%;}
.cult {color: #973e3b;}
.cultlarge {color: #973e3b; font-weight: bold; font-size: 3;}
.narsie {color: #973e3b; font-weight: bold; font-size: 15;}
+2
View File
@@ -42,6 +42,7 @@
#include "code\__DEFINES\airlock.dm"
#include "code\__DEFINES\alarm.dm"
#include "code\__DEFINES\alerts.dm"
#include "code\__DEFINES\animate.dm"
#include "code\__DEFINES\announcements.dm"
#include "code\__DEFINES\anomaly.dm"
#include "code\__DEFINES\antagonists.dm"
@@ -694,6 +695,7 @@
#include "code\_globalvars\lists\client.dm"
#include "code\_globalvars\lists\color.dm"
#include "code\_globalvars\lists\crafting.dm"
#include "code\_globalvars\lists\engineering.dm"
#include "code\_globalvars\lists\flavor_misc.dm"
#include "code\_globalvars\lists\icons.dm"
#include "code\_globalvars\lists\keybindings.dm"
@@ -587,6 +587,11 @@ em {
font-weight: bold;
}
.tinynicegreen {
color: hsl(132.8, 93.4%, 29.6%);
font-size: 85%;
}
.blob {
color: hsl(16.1, 100%, 46.7%);
}
@@ -600,6 +600,11 @@ h2.alert {
font-weight: bold;
}
.tinynicegreen {
color: hsl(132.6, 78.7%, 36.9%);
font-size: 85%;
}
.cult {
color: hsl(2, 43.8%, 41.2%);
}