/(global)
Vars | |
Failsafe | Failsafe |
---|---|
Master | StonedMC |
SSambience | The subsystem used to play ambience to users every now and then, makes them real excited. |
SSchat | Copyright (c) 2020 Aleksej Komarov SPDX-License-Identifier: MIT |
SScleanup | |
SSearly_assets | Initializes any assets that need to be loaded ASAP. |
SSpathfinder | Queues and manages JPS pathfinding steps |
SSpersistent_data | |
SStgui | tgui subsystem |
SStimer | |
SSverb_manager | SSverb_manager, a subsystem that runs every tick and runs through its entire queue without yielding like SSinput. this exists because of how the byond tick works and where user inputted verbs are put within it. |
Procs | |
HTTPGet | HTTP Get (Powered by RUSTG) |
MakeAPICall | Internal API Caller |
RoundDiagBar | Diagnostic HUDs! |
_queue_verb | queue a callback for the given verb/verblike proc and any given arguments to the specified verb subsystem, so that they process in the next tick. intended to only work with verbs or verblike procs called directly from client input, use as part of TRY_QUEUE_VERB() and co. |
add_attack_logs | Creates attack (old and new) logs for the user and defense logs for the target. Will message admins depending on the custom_level, user and target. |
add_verb | handles adding verbs and updating the stat panel browser |
addtimer | Create a new timer and insert it in the queue. You should not call this directly, and should instead use the addtimer macro, which includes source information. |
announce_merge_conflict_marker | We REALLY do not want un-addressed merge conflicts in maps for an inexhaustible list of reasons. This should help ensure that this will not be missed in case linters fail to catch it for any reason what-so-ever. |
assoc_to_keys | Turns an associative list into a flat list of keys |
atmos_scan | Outputs a message to the user describing the target's gasmixes. Used in chat-based gas scans. |
avoid_assoc_duplicate_keys | takes an input_key, as text, and the list of keys already used, outputting a replacement key in the format of "[input_key] ([number_of_duplicates])" if it finds a duplicate use this for lists of things that might have the same name, like mobs or objects, that you plan on giving to a player as input |
bang | Creates a flashing effect that blinds and deafens mobs within range |
broadcast_message | Message Broadcast Proc |
calculate_projectile_angle_and_pixel_offsets | Calculates the pixel offsets and angle that a projectile should be launched at. |
callback_add_trait | Proc wrapper of add_trait. You should only use this for callback. Otherwise, use the macro. |
callback_remove_trait | Proc wrapper of remove_trait. You should only use this for callback. Otherwise, use the macro. |
check_active_security_force | |
check_rights_all | Requires the holder to have all the rights specified |
client2rankcolour | Proc to generate a "rank colour" from a client |
compare_list | compare two lists, returns TRUE if they are the same |
costly_icon2asset | Costlier version of icon2asset() that uses getFlatIcon() to account for overlays, underlays, etc. Use with extreme moderation, ESPECIALLY on mobs. |
create_shrapnel | Creates an explosion of shrapnel at a turf. |
create_strippable_list | Creates an assoc list of keys to /datum/strippable_item |
cut_relative_direction | Takes a screen_loc string and cut out any directions like NORTH or SOUTH |
delete_all_SS_and_recreate_master | Delete all existing SS to basically start over |
deltimer | Delete a timer |
do_teleport | Will teleport the given atom to the given destination using the other parameters |
emissive_appearance | Produces a mutable appearance glued to the EMISSIVE_PLANE dyed to be the EMISSIVE_COLOR. Order of application matters: Default generated blockers are overlays, and will block its own emissive underlays. If you want an object to be both a blocker, and have their own emissive, it has to be an overlay instead. Grayscale lightmasks are visible in the BYOND right-click and Examine pane, unless they're covered up by another overlay. |
emissive_blocker | Produces a mutable appearance glued to the EMISSIVE_PLANE dyed to be the EM_BLOCK_COLOR. |
emoji_parse | Turns :ai: into an emoji in text. |
empulse | Will cause an EMP on the given epicenter. This proc can sleep depending on the affected objects. So assume it sleeps! |
fill_with_ones | Given a list, return a copy where values without defined weights are given weight 1. For example, fill_with_ones(list(A, B=2, C)) = list(A=1, B=2, C=1) Useful for weighted random choices (loot tables, syllables in languages, etc.) |
finish_unequip_mob | A utility function for /datum/strippable_item s to finish unequipping an item from a mob. |
fire_flash_log | Flashfire is a proc used to log fire causing chemical reactions. |
format_si_suffix | Formats num with an SI prefix. |
generate_and_hash_rsc_file | Generates a filename for a given asset. Like generate_asset_name(), except returns the rsc reference and the rsc file hash as well as the asset name (sans extension) Used so that certain asset files dont have to be hashed twice |
generate_bitfields | Turns /datum/bitfield subtypes into a list for use in debugging |
get_admin_objective_targets | Allows admins to safely pick from SSticker.minds for objectives |
get_all_linked_levels_zpos | Proc to get a list of all the linked-together Z-Levels |
get_allowed_instrument_ids | Get all non admin_only instruments as a list of text ids. |
get_antag_type_strings_list | A proc that return an array of capitalized strings containing name of the antag types they are |
get_antag_type_truncated_plaintext_string | A proc that return a string containing all the singled out antags . Empty string if not antag |
get_atoms_of_type | Returns a list of atoms in a location of a given type. Can be refined to look for pixel-shift. |
get_bbox_of_atoms | Get a bounding box of a list of atoms. |
get_channel_name | Returns the clean name of an audio channel. |
get_departments_from_job | matches a string job name to their department(s) and returns it as a list |
get_dummy_savefile | Gets a dummy savefile for usage in icon generation. Savefiles generated from this proc will be empty. |
get_edge_target_turf | Returns the turf located at the map edge in the specified direction relative to target_atom used for mass driver |
get_icon_dmi_path | Given an icon object, dmi file path, or atom/image/mutable_appearance, attempts to find and return an associated dmi file path. A weird quirk about dm is that /icon objects represent both compile-time or dynamic icons in the rsc, But stringifying rsc references returns a dmi file path ONLY if that icon represents a completely unchanged dmi file from when the game was compiled. So if the given object is associated with an icon that was in the rsc when the game was compiled, this returns a path. otherwise it returns "" |
get_line | Get a list of turfs in a line from starting_atom to ending_atom . |
get_living_players | This proc returns every player with a client who is not a ghost or a new_player |
get_path_to | This is the proc you use whenever you want to have pathfinding more complex than "try stepping towards the thing". If no path was found, returns an empty list, which is important for bots like medibots who expect an empty list rather than nothing. It will yield until a path is returned, using magic |
get_rad_contents | A special GetAllContents that doesn't search past things with rad insulation Components which return COMPONENT_BLOCK_RADIATION prevent further searching into that object's contents. The object itself will get returned still. The ignore list makes those objects never return at all |
get_ranged_target_turf | |
get_ranged_target_turf_direct | Get ranged target turf, but with direct targets as opposed to directions |
get_safe_species | Returns a list of names of non-blacklisted or hazardous species. |
get_swarm_path_to | POTENTIALLY cheaper version of get_path_to This proc generates a path map for the end atom's turf, which allows us to cheaply do pathing operations "at" it Generation is significantly SLOWER then get_path_to, but if many things are/might be pathing at something then it is much faster Runs the risk of returning an suboptimal or INVALID PATH if the delay between map creation and use is too long |
get_unrestricted_random_reagent_id | Returns a random reagent ID, with real non blacklisted balance boosting action! |
get_valid_screen_location | Returns a valid location to place a screen object without overflowing the viewport |
get_valid_vent_spawns | Returns a list of vents that can be used as a potential spawn if they meet the criteria set by the arguments |
goonchem_vortex | Throws or pulls objects to/from a chem reaction |
icon2asset | generate an asset for the given icon or the icon of the given appearance for [thing], and send it to any clients in target. Arguments: |
icon2base64 | Converts an icon to base64. Operates by putting the icon in the iconCache savefile, exporting it as text, and then parsing the base64 from that. (This relies on byond automatically storing icons in savefiles as base64) |
icon_exists | Checks if the given iconstate exists in the given file, caching the result. Setting no_sprite to TRUE will print a stack trace ONCE. |
is_bad_connection | Connection checker |
is_color_dark | Given a color in the format of "#RRGGBB", will return if the color is dark. |
is_special_character | ADMIN HELPER PROCS A proc that return whether the mob is a "Special Character" aka Antagonist |
is_type_in_UID_list | If the list L contains a datum UID who's type matches D 's type, returns the UID of that datum in the list. Otherwise returns null. |
is_valid_dmi_file | given a text string, returns whether it is a valid dmi icons folder path |
lists_equal_unordered | Checks to make sure that the lists have the exact same contents, ignores the order of the contents. |
locateUID | Locates a datum based off of the UID |
makeDatumRefLists | Initial Building |
make_associative | A proc for turning a list into an associative list. |
md5asfile | Save file as an external file then md5 it. Used because md5ing files stored in the rsc sometimes gives incorrect md5 results. |
md5filepath | Returns the md5 of a file at a given path. |
message_adminTicket | Sends a message to the staff able to see admin tickets Arguments: msg - The message being send important - If the message is important. If TRUE it will ignore the CHAT_NO_TICKETLOGS preferences, send a sound and flash the window. Defaults to FALSE |
message_mentorTicket | Sends a message to the staff able to see mentor tickets Arguments: msg - The message being send important - If the message is important. If TRUE it will ignore the CHAT_NO_TICKETLOGS preferences, send a sound and flash the window. Defaults to FALSE |
message_to_html | Message-related procs |
offset_to_screen_loc | Takes a list in the form (x_offset, y_offset) And converts it to a screen loc string Accepts an optional view string/size to force the screen_loc around, so it can't go out of scope |
parse_caught_click_modifiers | Returns a turf based on text inputs, original turf and viewing client |
path_map_passalong | We generate a path for the passed in callbacks, and then pipe it over |
pathfinding_finished | Uses funny pass by reference bullshit to take the output created by pathfinding, and insert it into a return list We'll be able to use this return list to tell a sleeping proc to continue execution |
phase_filter | This filter proc makes a visual effect where the object is split into fragments, with vertical lines cut out of them. It will appear as 2 seperate things are made of the one object that was cut out |
pick_multiple_unique | Picks multiple unique elements from the suplied list. If the given list has a length less than the amount given then it will return a list with an equal amount |
pick_unique_lawset | returns a random non starting / kill crew lawset if the station has a unique ai lawset |
pick_weight_recursive | Like pick_weight, but allowing for nested lists. |
pickweight | Picks an element based on its weight. L - The input list |
propagate_network | remove the old powernet and replace it with a new one throughout the network. |
radial_menu_helper | Similar to show_radial_menu, but choices is a list of atoms, for which icons will be automatically generated. Supports multiple items of the same name, 2 soaps will become soap (1) and soap (2) to the user. Otherwise, has the exact same arguments as show_radial_menu |
random_body_accessory | Returns a random body accessory for a given species name. Can be null based on is_optional argument. |
recover_all_SS_and_recreate_master | Recreate all SSs which will still cause data survive due to Recover(), the new Master will then find and take them from global.vars |
remove_clunky_diagonals | Processes a path (list of turfs), removes any diagonal moves that would lead to a weird bump |
remove_diagonals | Processes a path (list of turfs), removes any diagonal moves |
remove_verb | handles removing verb and sending it to browser to update, use this for removing verbs |
round_health | rounds value to limited symbols after the period for organ damage and other values |
rustg_get_version | Gets the version of rust_g |
rustg_git_commit_date | Returns the date of the given revision using the provided format. Defaults to returning %F which is YYYY-MM-DD. |
rustg_git_commit_date_head | Returns the formatted datetime string of HEAD using the provided format. Defaults to returning %F which is YYYY-MM-DD. This is different to rustg_git_commit_date because it only needs the logs directory. |
rustg_redis_disconnect_rq | Disconnects from a previously connected redis server |
rustg_unix_timestamp | Returns the timestamp as a string |
safe_get_ckey | Safe ckey getter |
sanitize_for_ic | sanitize() with a pre-set list of characters to remove from IC speech. |
screen_loc_to_offset | Takes a screen loc string in the format "+-left-offset:+-pixel,+-bottom-offset:+-pixel" Where the :pixel is optional, and returns A list in the format (x_offset, y_offset) We require context to get info out of screen locs that contain relative info, so NORTH, SOUTH, etc |
seconds_to_clock | Take a value in seconds and makes it display like a clock. Hours are stripped. (mm:ss) |
seconds_to_full_clock | Take a value in seconds and makes it display like a clock (h:mm:ss) |
seedify | Convert a grown object into seeds. |
setup_mod_themes | Global proc that sets up all MOD themes as singletons in a list and returns it. |
shake_camera | Shake the camera of the person viewing the mob SO REAL! |
show_blurb | Shows a ticker reading out the given text on a client's screen. |
start_unequip_mob | A utility function for /datum/strippable_item s to start unequipping an item from a mob. |
start_watch | Returns "watch handle" (really just a timestamp :V) |
stop_watch | Returns number of seconds elapsed. @param wh number The "Watch Handle" from start_watch(). (timestamp) |
strip_html_tags | Strips HTML tags (and only tags) from the input. The result may still include HTML entities, like ' for ' |
tgui_Topic | Middleware for /client/Topic. |
tgui_alert | Creates a TGUI alert window and returns the user's response. |
tgui_input_checkbox_list | Creates a TGUI input list window and returns the user's response in a ranked order. |
tgui_input_color | Creates a TGUI color picker window and returns the user's response. |
tgui_input_keycombo | Creates a TGUI window with a key input. Returns the user's response as a full key with modifiers, eg ShiftK. |
tgui_input_list | Creates a TGUI input list window and returns the user's response. |
tgui_input_number | Creates a TGUI window with a number input. Returns the user's response as num | null. |
tgui_input_ranked_list | Creates a TGUI ranked input list window and returns the user's response in a ranked order. |
tgui_input_text | Creates a TGUI window with a text input. Returns the user's response. |
to_chat | Sends the message to the recipient (target). |
to_chat_immediate | Circumvents the message queue and sends the message to the recipient (target) as soon as possible. trailing_newline, confidential, and handle_whitespace currently have no effect, please fix this in the future or remove the arguments to lower cache! |
trim_length | Returns a string that does not exceed max_length characters in size |
type_list_to_counted_assoc_list | This proc takes a list of types, and returns them in the format below. [type] = amount of type in list. Useful for recipes. |
view_to_pixels | Takes a string or num view, and converts it to pixel width/height in a list(pixel_width, pixel_height) |
wiki_link | Creates a hyperlink for a specified wiki article. |
Var Details
Failsafe
Failsafe
Pretty much pokes the MC to make sure it's still alive.
Master
StonedMC
Designed to properly split up a given tick among subsystems Note: if you read parts of this code and think "why is it doing it that way" Odds are, there is a reason
SSambience
The subsystem used to play ambience to users every now and then, makes them real excited.
SSchat
Copyright (c) 2020 Aleksej Komarov SPDX-License-Identifier: MIT
SScleanup
Cleanup Subsystem
For now, all it does is periodically clean the supplied global lists of any null values they may contain.
Why is this important?
Sometimes, these lists can gain nulls due to errors.
For example, when a dead player trasitions from the dead_mob_list
to the alive_mob_list
, a null value may get stuck in the dead mob list.
This can cause issues when other code tries to do things with the values in the list, but are instead met with null values.
These problems are incredibly hard to track down and fix, so this subsystem is a solution to that.
SSearly_assets
Initializes any assets that need to be loaded ASAP.
SSpathfinder
Queues and manages JPS pathfinding steps
SSpersistent_data
Persistent Data Subsystem
Provides a centralised handler for persistent data reading and writing. The subsystem does not do any actual spawning itself, as this focuses on objects and mobs Should anything that is turf persistence related added in, that can be chucked into this SS Its quite a simple subsystem. For now, anyways.
SStgui
tgui subsystem
Contains all tgui state and subsystem code.
Copyright (c) 2020 Aleksej Komarov SPDX-License-Identifier: MIT
SStimer
Timer Subsystem
Handles creation, callbacks, and destruction of timed events.
It is important to understand the buckets used in the timer subsystem are just a series of doubly-linked lists. The object at a given index in bucket_list is a /datum/timedevent, the head of a list, which has prev and next references for the respective elements in that bucket's list.
SSverb_manager
SSverb_manager, a subsystem that runs every tick and runs through its entire queue without yielding like SSinput. this exists because of how the byond tick works and where user inputted verbs are put within it.
see TICK_ORDER.md for more info on how the byond tick is structured.
The way the MC allots its time is via TICK_LIMIT_RUNNING, it simply subtracts the cost of SendMaps (MAPTICK_LAST_INTERNAL_TICK_USAGE) plus TICK_BYOND_RESERVE from the tick and uses up to that amount of time (minus the percentage of the tick used by the time it executes subsystems) on subsystems running cool things like atmospherics or Life or SSInput or whatever.
Without this subsystem, verbs are likely to cause overtime if the MC uses all of the time it has alloted for itself in the tick, and SendMaps uses as much as its expected to, and an expensive verb ends up executing that tick. This is because the MC is completely blind to the cost of verbs, it can't account for it at all. The only chance for verbs to not cause overtime in a tick where the MC used as much of the tick as it alloted itself and where SendMaps costed as much as it was expected to is if the verb(s) take less than TICK_BYOND_RESERVE percent of the tick, which isnt much. Not to mention if SendMaps takes more than 30% of the tick and the MC forces itself to take at least 70% of the normal tick duration which causes ticks to naturally overrun even in the absence of verbs.
With this subsystem, the MC can account for the cost of verbs and thus stop major overruns of ticks. This means that the most important subsystems like SSinput can start at the same time they were supposed to, leading to a smoother experience for the player since ticks arent riddled with minor hangs over and over again.
Proc Details
HTTPGet
HTTP Get (Powered by RUSTG)
This proc should be used as a replacement for /world/proc/Export due to an underlying issue with it. See: https://www.byond.com/forum/post/2772166 The one thing you will need to be aware of is that this no longer wraps the response inside a "file", so anything that relies on a file2text() unwrap will need tweaking. RUST HTTP also has better support for HTTPS as well as weird quirks with modern webservers. Returns an assoc list that follows the standard /world/proc/Export format (https://secure.byond.com/docs/ref/index.html#/world/proc/Export), with the above exception
Arguments:
- url - URL to GET
MakeAPICall
Internal API Caller
Makes calls to the internal Paradise API and returns a /datum/http_response.
Arguments:
- method - The relevant HTTP method to use
- path - The path of the API call. DO NOT USE A LEADING SLASH
- body - The request body, if applicable
RoundDiagBar
Diagnostic HUDs!
_queue_verb
queue a callback for the given verb/verblike proc and any given arguments to the specified verb subsystem, so that they process in the next tick. intended to only work with verbs or verblike procs called directly from client input, use as part of TRY_QUEUE_VERB() and co.
returns TRUE if the queuing was successful, FALSE otherwise.
add_attack_logs
Creates attack (old and new) logs for the user and defense logs for the target. Will message admins depending on the custom_level, user and target.
custom_level will determine the log level set. Unless the target is SSD and there is a user doing it If custom_level is not set then the log level will be determined using the user and the target.
- Arguments:
- user - The thing doing it. Can be null
- target - The target of the attack
- what_done - What has happened
- custom_level - The log level override
add_verb
handles adding verbs and updating the stat panel browser
pass the verb type path to this instead of adding it directly to verbs so the statpanel can update Arguments:
- target - Who the verb is being added to, client or mob typepath
- verb - typepath to a verb, or a list of verbs, supports lists of lists
addtimer
Create a new timer and insert it in the queue. You should not call this directly, and should instead use the addtimer macro, which includes source information.
Arguments:
- callback the callback to call on timer finish
- wait deciseconds to run the timer for
- flags flags for this timer, see: code__DEFINES\subsystems.dm
announce_merge_conflict_marker
We REALLY do not want un-addressed merge conflicts in maps for an inexhaustible list of reasons. This should help ensure that this will not be missed in case linters fail to catch it for any reason what-so-ever.
assoc_to_keys
Turns an associative list into a flat list of keys
atmos_scan
Outputs a message to the user describing the target's gasmixes. Used in chat-based gas scans.
avoid_assoc_duplicate_keys
takes an input_key, as text, and the list of keys already used, outputting a replacement key in the format of "[input_key] ([number_of_duplicates])" if it finds a duplicate use this for lists of things that might have the same name, like mobs or objects, that you plan on giving to a player as input
bang
Creates a flashing effect that blinds and deafens mobs within range
Arguments:
- T - The turf to flash
- A - The flashing atom
- range - The range in tiles of the flash
- flash - Whether to flash (blind)
- bang - Whether to bang (deafen)
broadcast_message
Message Broadcast Proc
This big fat disaster is responsible for sending the message out to all headsets and radios on the station It is absolutely disgusting, but used to take about 20 arguments before I slimmed it down to just one Arguments:
- tcm - The tcomms message datum
calculate_projectile_angle_and_pixel_offsets
Calculates the pixel offsets and angle that a projectile should be launched at.
Arguments:
- source: The thing that the projectile is being shot from.
- target: (Optional) The thing that the projectile is being shot at.
- If this is not provided the source atom must be a mob with a client.
- modifiers: A list of click parameters used to modify the shot angle.
callback_add_trait
Proc wrapper of add_trait. You should only use this for callback. Otherwise, use the macro.
callback_remove_trait
Proc wrapper of remove_trait. You should only use this for callback. Otherwise, use the macro.
check_active_security_force
- checks the security force on station and returns a list of numbers, of the form:
- total, active, dead, antag
- where active is defined as conscious (STAT = 0) and not an antag
check_rights_all
Requires the holder to have all the rights specified
rights_required = R_ADMIN|R_EVENT means they must have both flags, or it will return false
client2rankcolour
Proc to generate a "rank colour" from a client
This takes the client and looks at various factors in order, such as patreon status, staff rank, and more Arguments:
- C - The client were looking up
compare_list
compare two lists, returns TRUE if they are the same
costly_icon2asset
Costlier version of icon2asset() that uses getFlatIcon() to account for overlays, underlays, etc. Use with extreme moderation, ESPECIALLY on mobs.
create_shrapnel
Creates an explosion of shrapnel at a turf.
- /turf/epicenter - where the explosion occurs
- shrapnel_number - the amount of shrapnel to create
- /obj/item/projectile/shrapnel_type - the type of shrapnel bullets to shoot
- chance_to_hit_same_turf - the probability to hit someone on the same turf, doubled for someone lying down
create_strippable_list
Creates an assoc list of keys to /datum/strippable_item
cut_relative_direction
Takes a screen_loc string and cut out any directions like NORTH or SOUTH
delete_all_SS_and_recreate_master
Delete all existing SS to basically start over
deltimer
Delete a timer
Arguments:
- id a timerid or a /datum/timedevent
do_teleport
Will teleport the given atom to the given destination using the other parameters
Arguments:
- atom_to_teleport - Atom to teleport
- destination - Where to teleport the atom to
- variance_range - With what precision to do the teleport. 0 means on target. Higher means that many turfs around it
- force_teleport - Whether to use forceMove instead of Move to move the atom to the destination
- effect_in - The effect started at the starting turf. If set to NONE then no effect is used
- effect_out - The effect started at the destination turf. If set to NONE then no effect is used
- sound_in - The sound played at the starting turf
- sound_out - The sound played at the destination turf
- bypass_area_flag - Whether is_teleport_allowed is skipped or not
- safe_turf_pick - Whether the chosen random turf from the variance is prefered to be a safe turf or not
- do_effect - Whether to play the effect or not
emissive_appearance
Produces a mutable appearance glued to the EMISSIVE_PLANE dyed to be the EMISSIVE_COLOR. Order of application matters: Default generated blockers are overlays, and will block its own emissive underlays. If you want an object to be both a blocker, and have their own emissive, it has to be an overlay instead. Grayscale lightmasks are visible in the BYOND right-click and Examine pane, unless they're covered up by another overlay.
emissive_blocker
Produces a mutable appearance glued to the EMISSIVE_PLANE dyed to be the EM_BLOCK_COLOR.
emoji_parse
Turns :ai: into an emoji in text.
empulse
Will cause an EMP on the given epicenter. This proc can sleep depending on the affected objects. So assume it sleeps!
epicenter - The center of the EMP. Can be an atom, as long as the given atom is on a turf (in)directly heavy_range - The max distance from the epicenter where objects will be get heavy EMPed light_range - The max distance from the epicenter where objects will get light EMPed log - Whether or not this action should be logged or not. Will use the cause if provided cause - The cause of the EMP. Used for the logging
fill_with_ones
Given a list, return a copy where values without defined weights are given weight 1. For example, fill_with_ones(list(A, B=2, C)) = list(A=1, B=2, C=1) Useful for weighted random choices (loot tables, syllables in languages, etc.)
finish_unequip_mob
A utility function for /datum/strippable_item
s to finish unequipping an item from a mob.
fire_flash_log
Flashfire is a proc used to log fire causing chemical reactions.
Call this whenever you have a chemical reaction that makes fire flashes. Arguments:
- holder: the beaker that the reagent is in
- name: name of the reagent / reaction
format_si_suffix
Formats num with an SI prefix.
Returns a string formatted with a multiple of num and an SI prefix corresponding to an exponent of 10. Only considers exponents that are multiples of 3 (deca, deci, hecto, and centi are not included). A unit is not included in the string, the prefix is placed after the number with no spacing added anywhere. Listing of prefixes: https://en.wikipedia.org/wiki/Metric_prefix#List_of_SI_prefixes
generate_and_hash_rsc_file
Generates a filename for a given asset. Like generate_asset_name(), except returns the rsc reference and the rsc file hash as well as the asset name (sans extension) Used so that certain asset files dont have to be hashed twice
generate_bitfields
Turns /datum/bitfield subtypes into a list for use in debugging
get_admin_objective_targets
Allows admins to safely pick from SSticker.minds for objectives
- caller, mob to ask for results
- blacklist, optional list of targets that are not available
- default_target, the target to show in the list as default
get_all_linked_levels_zpos
Proc to get a list of all the linked-together Z-Levels
Returns a list of zlevel numbers which can be accessed from travelling space naturally
get_allowed_instrument_ids
Get all non admin_only instruments as a list of text ids.
get_antag_type_strings_list
A proc that return an array of capitalized strings containing name of the antag types they are
Arguments:
- M - the mob you're checking
get_antag_type_truncated_plaintext_string
A proc that return a string containing all the singled out antags . Empty string if not antag
Usually, you'd return a FALSE, but since this is consumed by javascript you're in for a world of hurt if you pass a byond FALSE which get converted into a fucking string anyway and pass for TRUE in check. Fuck. It always append "(May be other antag)" Arguments:
- M - the mob you're checking
get_atoms_of_type
Returns a list of atoms in a location of a given type. Can be refined to look for pixel-shift.
Arguments:
- loc - The atom to look in.
- type - The type to look for.
- check_shift - If true, will exclude atoms whose pixel_x/pixel_y do not match shift_x/shift_y.
- shift_x - If check_shift is true, atoms whose pixel_x is different to this will be excluded.
- shift_y - If check_shift is true, atoms whose pixel_y is different to this will be excluded.
get_bbox_of_atoms
Get a bounding box of a list of atoms.
Arguments:
- atoms - List of atoms. Can accept output of view() and range() procs.
Returns: list(x1, y1, x2, y2)
get_channel_name
Returns the clean name of an audio channel.
Arguments:
- channel - The channel number.
get_departments_from_job
matches a string job name to their department(s) and returns it as a list
get_dummy_savefile
Gets a dummy savefile for usage in icon generation. Savefiles generated from this proc will be empty.
get_edge_target_turf
Returns the turf located at the map edge in the specified direction relative to target_atom used for mass driver
get_icon_dmi_path
Given an icon object, dmi file path, or atom/image/mutable_appearance, attempts to find and return an associated dmi file path. A weird quirk about dm is that /icon objects represent both compile-time or dynamic icons in the rsc, But stringifying rsc references returns a dmi file path ONLY if that icon represents a completely unchanged dmi file from when the game was compiled. So if the given object is associated with an icon that was in the rsc when the game was compiled, this returns a path. otherwise it returns ""
get_line
Get a list of turfs in a line from starting_atom
to ending_atom
.
Uses the ultra-fast Bresenham Line-Drawing Algorithm.
get_living_players
This proc returns every player with a client who is not a ghost or a new_player
get_path_to
This is the proc you use whenever you want to have pathfinding more complex than "try stepping towards the thing". If no path was found, returns an empty list, which is important for bots like medibots who expect an empty list rather than nothing. It will yield until a path is returned, using magic
Arguments:
- caller: The movable atom that's trying to find the path
- end: What we're trying to path to. It doesn't matter if this is a turf or some other atom, we're gonna just path to the turf it's on anyway
- max_distance: The maximum number of steps we can take in a given path to search (default: 30, 0 = infinite)
- mintargetdistance: Minimum distance to the target before path returns, could be used to get near a target, but not right to it - for an AI mob with a gun, for example.
- access: A list representing what access we have and what doors we can open.
- simulated_only: Whether we consider tur fs without atmos simulation (AKA do we want to ignore space)
- exclude: If we want to avoid a specific turf, like if we're a mulebot who already got blocked by some turf
- skip_first: Whether or not to delete the first item in the path. This would be done because the first item is the starting tile, which can break movement for some creatures.
- diagonal_handling: defines how we handle diagonal moves. see __DEFINES/path.dm
get_rad_contents
A special GetAllContents that doesn't search past things with rad insulation Components which return COMPONENT_BLOCK_RADIATION prevent further searching into that object's contents. The object itself will get returned still. The ignore list makes those objects never return at all
get_ranged_target_turf
- returns turf relative to A in given direction at set range // result is bounded to map size // note range is non-pythagorean // used for disposal system
get_ranged_target_turf_direct
Get ranged target turf, but with direct targets as opposed to directions
Starts at atom starting_atom and gets the exact angle between starting_atom and target Moves from starting_atom with that angle, Range amount of times, until it stops, bound to map size Arguments:
- starting_atom - Initial Firer / Position
- target - Target to aim towards
- range - Distance of returned target turf from starting_atom
- offset - Angle offset, 180 input would make the returned target turf be in the opposite direction
get_safe_species
Returns a list of names of non-blacklisted or hazardous species.
get_swarm_path_to
POTENTIALLY cheaper version of get_path_to This proc generates a path map for the end atom's turf, which allows us to cheaply do pathing operations "at" it Generation is significantly SLOWER then get_path_to, but if many things are/might be pathing at something then it is much faster Runs the risk of returning an suboptimal or INVALID PATH if the delay between map creation and use is too long
If no path was found, returns an empty list, which is important for bots like medibots who expect an empty list rather than nothing. It will yield until a path is returned, using magic
Arguments:
- caller: The movable atom that's trying to find the path
- end: What we're trying to path to. It doesn't matter if this is a turf or some other atom, we're gonna just path to the turf it's on anyway
- max_distance: The maximum number of steps we can take in a given path to search (default: 30, 0 = infinite)
- mintargetdistance: Minimum distance to the target before path returns, could be used to get near a target, but not right to it - for an AI mob with a gun, for example.
- age: How old a path map can be before we'll avoid reusing it. Use the defines found in code/__DEFINES/path_defines.dm, values larger then MAP_REUSE_SLOWEST will be discarded
- access: A list representing what access we have and what doors we can open.
- simulated_only: Whether we consider tur fs without atmos simulation (AKA do we want to ignore space)
- exclude: If we want to avoid a specific turf, like if we're a mulebot who already got blocked by some turf
- skip_first: Whether or not to delete the first item in the path. This would be done because the first item is the starting tile, which can break movement for some creatures.
get_unrestricted_random_reagent_id
Returns a random reagent ID, with real non blacklisted balance boosting action!
get_valid_screen_location
Returns a valid location to place a screen object without overflowing the viewport
- target: The target location as a purely number based screen_loc string "+-left-offset:+-pixel,+-bottom-offset:+-pixel"
- target_offset: The amount we want to offset the target location by. We explictly don't care about direction here, we will try all 4
- view: The view variable of the client we're doing this for. We use this to get the size of the screen
Returns a screen loc representing the valid location
get_valid_vent_spawns
Returns a list of vents that can be used as a potential spawn if they meet the criteria set by the arguments
Will not include parent-less vents to the returned list. Arguments:
- unwelded_only - Whether the list should only include vents that are unwelded
- exclude_mobs_nearby - Whether to exclude vents that are near living mobs
- min_network_size - The minimum length (non-inclusive) of the vent's parent network. A smaller number means vents in small networks (Security, Virology) will appear in the list
goonchem_vortex
Throws or pulls objects to/from a chem reaction
Scales the amount of objects thrown with the volume, unless ignore_volume is TRUE
Arguments:
- T - The turf to use as the throw from/to point
- pull - Do we want to pull objects towards T (TRUE) or push them away from it (FALSE)
- volume - The volume of reagents. Used to scale the effect is ignore_volume = FALSE
- ignore_volume - Do we want to ignore the volume of reagents and just throw regardless
icon2asset
generate an asset for the given icon or the icon of the given appearance for [thing], and send it to any clients in target. Arguments:
- thing - either a /icon object, or an object that has an appearance (atom, image, mutable_appearance).
- target - either a reference to or a list of references to /client's or mobs with clients
- icon_state - string to force a particular icon_state for the icon to be used
- dir - dir number to force a particular direction for the icon to be used
- frame - what frame of the icon_state's animation for the icon being used
- moving - whether or not to use a moving state for the given icon
- sourceonly - if TRUE, only generate the asset and send back the asset url, instead of tags that display the icon to players
- extra_classes - string of extra css classes to use when returning the icon string
icon2base64
Converts an icon to base64. Operates by putting the icon in the iconCache savefile, exporting it as text, and then parsing the base64 from that. (This relies on byond automatically storing icons in savefiles as base64)
icon_exists
Checks if the given iconstate exists in the given file, caching the result. Setting no_sprite to TRUE will print a stack trace ONCE.
is_bad_connection
Connection checker
Checks the connection frequency against the intended frequency for the message NOTE: I barely know what on earth this does, but it works and it scares me Arguments:
- old_freq - Frequency of the connection
- new_freq - Frequency of the message
is_color_dark
Given a color in the format of "#RRGGBB", will return if the color is dark.
is_special_character
ADMIN HELPER PROCS A proc that return whether the mob is a "Special Character" aka Antagonist
Arguments:
- M - the mob you're checking
is_type_in_UID_list
If the list L
contains a datum UID who's type matches D
's type, returns the UID of that datum in the list. Otherwise returns null.
is_valid_dmi_file
given a text string, returns whether it is a valid dmi icons folder path
lists_equal_unordered
Checks to make sure that the lists have the exact same contents, ignores the order of the contents.
locateUID
Locates a datum based off of the UID
Replacement for locate() which takes a UID instead of a ref Returns the datum, if found
makeDatumRefLists
Initial Building
make_associative
A proc for turning a list into an associative list.
A simple proc for turning all things in a list into an associative list, instead Each item in the list will have an associative value of TRUE
Arguments:
- flat_list - the list that it passes to make associative
md5asfile
Save file as an external file then md5 it. Used because md5ing files stored in the rsc sometimes gives incorrect md5 results.
md5filepath
Returns the md5 of a file at a given path.
message_adminTicket
Sends a message to the staff able to see admin tickets Arguments: msg - The message being send important - If the message is important. If TRUE it will ignore the CHAT_NO_TICKETLOGS preferences, send a sound and flash the window. Defaults to FALSE
message_mentorTicket
Sends a message to the staff able to see mentor tickets Arguments: msg - The message being send important - If the message is important. If TRUE it will ignore the CHAT_NO_TICKETLOGS preferences, send a sound and flash the window. Defaults to FALSE
message_to_html
Message-related procs
Message format (/list):
- type - Message type, must be one of defines in
code/__DEFINES/chat.dm
- text - Plain message text
- html - HTML message text
- Optional metadata, can be any key/value pair.
Copyright (c) 2020 Aleksej Komarov SPDX-License-Identifier: MIT
offset_to_screen_loc
Takes a list in the form (x_offset, y_offset) And converts it to a screen loc string Accepts an optional view string/size to force the screen_loc around, so it can't go out of scope
parse_caught_click_modifiers
Returns a turf based on text inputs, original turf and viewing client
path_map_passalong
We generate a path for the passed in callbacks, and then pipe it over
pathfinding_finished
Uses funny pass by reference bullshit to take the output created by pathfinding, and insert it into a return list We'll be able to use this return list to tell a sleeping proc to continue execution
phase_filter
This filter proc makes a visual effect where the object is split into fragments, with vertical lines cut out of them. It will appear as 2 seperate things are made of the one object that was cut out
pick_multiple_unique
Picks multiple unique elements from the suplied list. If the given list has a length less than the amount given then it will return a list with an equal amount
Arguments:
- listfrom - The list where to pick from
- amount - The amount of elements it tries to pick.
pick_unique_lawset
returns a random non starting / kill crew lawset if the station has a unique ai lawset
pick_weight_recursive
Like pick_weight, but allowing for nested lists.
For example, given the following list: list(A = 1, list(B = 1, C = 1)) A would have a 50% chance of being picked, and list(B, C) would have a 50% chance of being picked. If list(B, C) was picked, B and C would then each have a 50% chance of being picked. So the final probabilities would be 50% for A, 25% for B, and 25% for C.
Weights should be integers. Entries without weights are assigned weight 1 (so unweighted lists can be used as well)
pickweight
Picks an element based on its weight. L - The input list
example: list("a" = 1, "b" = 2) will pick "b" 2/3s of the time
propagate_network
remove the old powernet and replace it with a new one throughout the network.
radial_menu_helper
Similar to show_radial_menu, but choices is a list of atoms, for which icons will be automatically generated. Supports multiple items of the same name, 2 soaps will become soap (1) and soap (2) to the user. Otherwise, has the exact same arguments as show_radial_menu
random_body_accessory
Returns a random body accessory for a given species name. Can be null based on is_optional argument.
Arguments:
- species - The name of the species to filter valid body accessories.
- is_optional - Whether no body accessory (null) is an option.
recover_all_SS_and_recreate_master
Recreate all SSs which will still cause data survive due to Recover(), the new Master will then find and take them from global.vars
remove_clunky_diagonals
Processes a path (list of turfs), removes any diagonal moves that would lead to a weird bump
path - The path to process down pass_info - Holds all the info about what this path attempt can go through simulated_only - If we are not allowed to pass space turfs avoid - A turf to be avoided
remove_diagonals
Processes a path (list of turfs), removes any diagonal moves
path - The path to process down pass_info - Holds all the info about what this path attempt can go through simulated_only - If we are not allowed to pass space turfs avoid - A turf to be avoided
remove_verb
handles removing verb and sending it to browser to update, use this for removing verbs
pass the verb type path to this instead of removing it from verbs so the statpanel can update Arguments:
- target - Who the verb is being removed from, client or mob typepath
- verb - typepath to a verb, or a list of verbs, supports lists of lists
round_health
rounds value to limited symbols after the period for organ damage and other values
rustg_get_version
Gets the version of rust_g
rustg_git_commit_date
Returns the date of the given revision using the provided format. Defaults to returning %F which is YYYY-MM-DD.
rustg_git_commit_date_head
Returns the formatted datetime string of HEAD using the provided format. Defaults to returning %F which is YYYY-MM-DD. This is different to rustg_git_commit_date because it only needs the logs directory.
rustg_redis_disconnect_rq
Disconnects from a previously connected redis server
rustg_unix_timestamp
Returns the timestamp as a string
safe_get_ckey
Safe ckey getter
Should be used whenever broadcasting public information about a mob, as this proc will make a best effort to hide the users ckey if they request it. It will first check the mob for a client, then use the mobs last ckey as a directory lookup. If a client cant be found to check preferences on, it will just show as DC'd. This proc should only be used for public facing stuff, not administration related things.
Arguments:
- M - Mob to get a safe ckey of
sanitize_for_ic
sanitize() with a pre-set list of characters to remove from IC speech.
screen_loc_to_offset
Takes a screen loc string in the format "+-left-offset:+-pixel,+-bottom-offset:+-pixel" Where the :pixel is optional, and returns A list in the format (x_offset, y_offset) We require context to get info out of screen locs that contain relative info, so NORTH, SOUTH, etc
seconds_to_clock
Take a value in seconds and makes it display like a clock. Hours are stripped. (mm:ss)
seconds_to_full_clock
Take a value in seconds and makes it display like a clock (h:mm:ss)
seedify
Convert a grown object into seeds.
setup_mod_themes
Global proc that sets up all MOD themes as singletons in a list and returns it.
shake_camera
Shake the camera of the person viewing the mob SO REAL!
show_blurb
Shows a ticker reading out the given text on a client's screen.
Arguments:
- targets - mob or list of mobs to show it to.
- duration - how long it lingers after it finishes ticking.
- message - the message to display. Due to using maptext it isn't very
flexible format-wise. 11px font, up to 480 pixels per line. Use
\n
for line breaks. Single-character HTML tags (<b>
,<i>
,<u>
etc.) are handled correctly but others display strangely. Note that maptext can display text macros in strange ways, ex. \improper showing as "ÿ". Lines containing only spaces, including ones only containing "\improper ", don't display. - scroll_down - by default each line pushes the previous line upwards - this
tells it to start high and scroll down. Ticks on
\n
- does not autodetect line breaks in long strings. - screen_position - screen loc for the bottom-left corner of the blurb.
- text_alignment - "right", "left", or "center"
- text_color - colour of the text.
- blurb_key - a key used for specific blurb types so they are not shown repeatedly.
- ignore_key - used to skip key checks.
- text_limit - limit in characters of the message.
start_unequip_mob
A utility function for /datum/strippable_item
s to start unequipping an item from a mob.
start_watch
Returns "watch handle" (really just a timestamp :V)
stop_watch
Returns number of seconds elapsed. @param wh number The "Watch Handle" from start_watch(). (timestamp)
strip_html_tags
Strips HTML tags (and only tags) from the input. The result may still include HTML entities, like ' for '
tgui_Topic
Middleware for /client/Topic.
return bool If TRUE, prevents propagation of the topic call.
tgui_alert
Creates a TGUI alert window and returns the user's response.
This proc should be used to create alerts that the caller will wait for a response from. Arguments:
- user - The user to show the alert to.
- message - The content of the alert, shown in the body of the TGUI window.
- title - The of the alert modal, shown on the top of the TGUI window.
- buttons - The options that can be chosen by the user, each string is assigned a button on the UI.
- timeout - The timeout of the alert, after which the modal will close and qdel itself. Set to zero for no timeout.
- autofocus - The bool that controls if this alert should grab window focus.
tgui_input_checkbox_list
Creates a TGUI input list window and returns the user's response in a ranked order.
Arguments:
- user - The user to show the input box to.
- message - The content of the input box, shown in the body of the TGUI window.
- title - The title of the input box, shown on the top of the TGUI window.
- items - The options that can be chosen by the user, each string is assigned a button on the UI.
- default - If an option is already preselected on the UI. Current values, etc.
- timeout - The timeout of the input box, after which the menu will close and qdel itself. Set to zero for no timeout.
tgui_input_color
Creates a TGUI color picker window and returns the user's response.
This proc should be used to create a color picker that the caller will wait for a response from. Arguments:
- user - The user to show the picker to.
- title - The of the picker modal, shown on the top of the TGUI window.
- timeout - The timeout of the picker, after which the modal will close and qdel itself. Set to zero for no timeout.
- autofocus - The bool that controls if this picker should grab window focus.
tgui_input_keycombo
Creates a TGUI window with a key input. Returns the user's response as a full key with modifiers, eg ShiftK.
This proc should be used to create windows for key entry that the caller will wait for a response from. If tgui fancy chat is turned off: Will return a normal input.
Arguments:
- user - The user to show the number input to.
- message - The content of the number input, shown in the body of the TGUI window.
- title - The title of the number input modal, shown on the top of the TGUI window.
- default - The default (or current) key, shown as a placeholder.
tgui_input_list
Creates a TGUI input list window and returns the user's response.
This proc should be used to create alerts that the caller will wait for a response from. Arguments:
- user - The user to show the input box to.
- message - The content of the input box, shown in the body of the TGUI window.
- title - The title of the input box, shown on the top of the TGUI window.
- items - The options that can be chosen by the user, each string is assigned a button on the UI.
- default - If an option is already preselected on the UI. Current values, etc.
- timeout - The timeout of the input box, after which the menu will close and qdel itself. Set to zero for no timeout.
tgui_input_number
Creates a TGUI window with a number input. Returns the user's response as num | null.
This proc should be used to create windows for number entry that the caller will wait for a response from. If tgui fancy chat is turned off: Will return a normal input. If a max or min value is specified, will validate the input inside the UI and ui_act.
Arguments:
- user - The user to show the number input to.
- message - The content of the number input, shown in the body of the TGUI window.
- title - The title of the number input modal, shown on the top of the TGUI window.
- default - The default (or current) value, shown as a placeholder. Users can press refresh with this.
- max_value - Specifies a maximum value. If none is set, any number can be entered. Pressing "max" defaults to 1000.
- min_value - Specifies a minimum value. Often 0.
- timeout - The timeout of the number input, after which the modal will close and qdel itself. Set to zero for no timeout.
- round_value - whether the inputted number is rounded down into an integer.
tgui_input_ranked_list
Creates a TGUI ranked input list window and returns the user's response in a ranked order.
Arguments:
- user - The user to show the input box to.
- message - The content of the input box, shown in the body of the TGUI window.
- title - The title of the input box, shown on the top of the TGUI window.
- items - The options that can be chosen by the user, each string is assigned a button on the UI.
- default - If an option is already preselected on the UI. Current values, etc.
- timeout - The timeout of the input box, after which the menu will close and qdel itself. Set to zero for no timeout.
tgui_input_text
Creates a TGUI window with a text input. Returns the user's response.
This proc should be used to create windows for text entry that the caller will wait for a response from. If tgui fancy chat is turned off: Will return a normal input. If max_length is specified, will return stripped_multiline_input.
Arguments:
- user - The user to show the text input to.
- message - The content of the text input, shown in the body of the TGUI window.
- title - The title of the text input modal, shown on the top of the TGUI window.
- default - The default (or current) value, shown as a placeholder.
- max_length - Specifies a max length for input. MAX_MESSAGE_LEN is default (1024)
- multiline - Bool that determines if the input box is much larger. Good for large messages, laws, etc.
- encode - Toggling this determines if input is filtered via html_encode. Setting this to FALSE gives raw input.
- timeout - The timeout of the textbox, after which the modal will close and qdel itself. Set to zero for no timeout.
to_chat
Sends the message to the recipient (target).
Recommended way to write to_chat calls:
to_chat(client, "You have found <strong>[object]</strong>", MESSAGE_TYPE_INFO,
Always remember to close spans!
Arguments:
- target: Refers to the target of the to_chat message. Valid targets include clients, mobs, and the static world controller
- html: The Message to be sent to the TARGET. Converted to a string if not already one in this function
- type: The chat tab that this message will be sent to, a list of all valid types can be found in chat.dm
- text: Unused
- avoid_highlighting: Unused
trailing_newline
, confidential
, and handle_whitespace
currently have no effect, please fix this in the future or remove the arguments to lower cache!
to_chat_immediate
Circumvents the message queue and sends the message to the recipient (target) as soon as possible. trailing_newline, confidential, and handle_whitespace currently have no effect, please fix this in the future or remove the arguments to lower cache!
trim_length
Returns a string that does not exceed max_length characters in size
type_list_to_counted_assoc_list
This proc takes a list of types, and returns them in the format below. [type] = amount of type in list. Useful for recipes.
view_to_pixels
Takes a string or num view, and converts it to pixel width/height in a list(pixel_width, pixel_height)
wiki_link
Creates a hyperlink for a specified wiki article.