mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 07:38:05 +01:00
## About The Pull Request It's just a partial cleanup of anti-[STYLE](https://github.com/tgstation/tgstation/blob/master/.github/guides/STYLE.md) code from /tg/'s ancient history. I compiled & tested with my helpful assistant and damage is still working. <img width="1920" height="1040" alt="image" src="https://github.com/user-attachments/assets/26dabc17-088f-4008-b299-3ff4c27142c3" /> I'll upload the .cs script I used to do it shortly. ## Why It's Good For The Game Just minor code cleanup. Script used is located at https://metek.tech/camelTo-Snake.7z EDIT 11/23/25: Updated the script to use multithreading and sequential scan so it works a hell of a lot faster ``` /* // Copyright 2025 Joshua 'Joan Metekillot' Kidder This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. // */ using System.Text.RegularExpressions; class Program { static async Task Main(string[] args) { var readFile = new FileStreamOptions { Access = FileAccess.Read, Share = FileShare.ReadWrite, Options = FileOptions.Asynchronous | FileOptions.SequentialScan }; FileStreamOptions writeFile = new FileStreamOptions { Share = FileShare.ReadWrite, Access = FileAccess.ReadWrite, Mode = FileMode.Truncate, Options = FileOptions.Asynchronous }; RegexOptions regexOptions = RegexOptions.Multiline | RegexOptions.Compiled; Dictionary<string, int> changedProcs = new(); string regexPattern = @"(?<=\P{L})([a-z]+)([A-Z]{1,2}[a-z]+)*(Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss)([A-Z]{1,2}[a-z]+)*"; Regex camelCaseProcRegex = new(regexPattern, regexOptions); string snakeify(Match matchingRegex) { var vals = matchingRegex.Groups.Cast<Group>().SelectMany(_ => _.Captures).Select(_ => _.Value).ToArray(); var newVal = string.Join("_", vals.Skip(1).ToArray()).ToLower(); string logString = $"{vals[0]} => {newVal}"; if (changedProcs.TryGetValue(logString, out int value)) { changedProcs[logString] = value + 1; } else { changedProcs.Add(logString, 1); } return newVal; } var dmFiles = Directory.EnumerateFiles(".", "*.dm", SearchOption.AllDirectories).ToAsyncEnumerable<string>(); // uses default ParallelOptions // https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.paralleloptions?view=net-10.0#main await Parallel.ForEachAsync(dmFiles, async (filePath, UnusedCancellationToken) => { var reader = new StreamReader(filePath, readFile); string oldContent = await reader.ReadToEndAsync(); string newContent = camelCaseProcRegex.Replace(oldContent, new MatchEvaluator((Func<Match, string>)snakeify)); if (oldContent != newContent) { var writer = new StreamWriter(filePath, writeFile); await writer.WriteAsync(newContent); await writer.DisposeAsync(); } reader.Dispose(); }); var logToList = changedProcs.Cast<KeyValuePair<string, int>>().ToList(); foreach (var pair in logToList) { Console.WriteLine($"{pair.Key}: {pair.Value} locations"); } } } ``` ## Changelog 🆑 Bisar code: All (Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss) procs now use snake_case, in-line with the STYLE guide. Underscores rule! /🆑
181 lines
6.7 KiB
Plaintext
181 lines
6.7 KiB
Plaintext
/obj/crystal_mass
|
|
name = "crystal mass"
|
|
desc = "You see this massive crystal mass looming towards you, cracking and screeching at every seemingly random movement."
|
|
icon = 'icons/turf/walls.dmi'
|
|
icon_state = "crystal_cascade_1"
|
|
layer = AREA_LAYER
|
|
plane = ABOVE_LIGHTING_PLANE
|
|
opacity = FALSE
|
|
density = TRUE
|
|
anchored = TRUE
|
|
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF | FREEZE_PROOF
|
|
light_power = 1
|
|
light_range = 5
|
|
light_color = COLOR_VIVID_YELLOW
|
|
move_resist = INFINITY
|
|
///All dirs we can expand to
|
|
var/list/available_dirs = list(NORTH,SOUTH,EAST,WEST,UP,DOWN)
|
|
///Handler that helps with properly killing mobs that the crystal grows over
|
|
var/datum/component/supermatter_crystal/sm_comp
|
|
///Cooldown on the expansion process
|
|
COOLDOWN_DECLARE(sm_wall_cooldown)
|
|
|
|
/obj/crystal_mass/Initialize(mapload, dir_to_remove)
|
|
. = ..()
|
|
icon_state = "crystal_cascade_[rand(1,6)]"
|
|
START_PROCESSING(SSsupermatter_cascade, src)
|
|
|
|
sm_comp = AddComponent(/datum/component/supermatter_crystal, null, null)
|
|
|
|
playsound(src, 'sound/misc/cracking_crystal.ogg', 45, TRUE)
|
|
|
|
available_dirs -= dir_to_remove
|
|
|
|
var/turf/our_turf = get_turf(src)
|
|
|
|
if(our_turf)
|
|
our_turf.opacity = FALSE
|
|
|
|
// Ideally this'd be part of the SM component, but the SM itself snowflakes bullets (emitters are bullets).
|
|
RegisterSignal(src, COMSIG_ATOM_PRE_BULLET_ACT, PROC_REF(eat_bullets))
|
|
|
|
/obj/crystal_mass/process()
|
|
|
|
if(!COOLDOWN_FINISHED(src, sm_wall_cooldown))
|
|
return
|
|
|
|
if(!available_dirs || available_dirs.len <= 0)
|
|
return PROCESS_KILL
|
|
|
|
COOLDOWN_START(src, sm_wall_cooldown, rand(0, 3 SECONDS))
|
|
|
|
var/picked_dir = pick_n_take(available_dirs)
|
|
var/turf/next_turf = get_step_multiz(src, picked_dir)
|
|
|
|
icon_state = "crystal_cascade_[rand(1,6)]"
|
|
|
|
if(!next_turf || locate(/obj/crystal_mass) in next_turf)
|
|
return
|
|
|
|
for(var/atom/movable/checked_atom as anything in next_turf)
|
|
if(isliving(checked_atom))
|
|
sm_comp.dust_mob(src, checked_atom, span_danger("\The [src] lunges out on [checked_atom], touching [checked_atom.p_them()]... \
|
|
[checked_atom.p_their()] body begins to shine with a brilliant light before crystallizing from the inside out and joining \the [src]!"),
|
|
span_userdanger("The crystal mass lunges on you and hits you in the chest. As your vision is filled with a blinding light, you think to yourself \"Damn it.\""))
|
|
else if(istype(checked_atom, /obj/cascade_portal))
|
|
checked_atom.visible_message(span_userdanger("\The [checked_atom] screeches and closes away as it is hit by \a [src]! Too late!"))
|
|
playsound(get_turf(checked_atom), 'sound/effects/magic/charge.ogg', 50, TRUE)
|
|
playsound(get_turf(checked_atom), 'sound/effects/supermatter.ogg', 50, TRUE)
|
|
qdel(checked_atom)
|
|
else if(isitem(checked_atom))
|
|
playsound(get_turf(checked_atom), 'sound/effects/supermatter.ogg', 50, TRUE)
|
|
qdel(checked_atom)
|
|
|
|
new /obj/crystal_mass(next_turf, get_dir(next_turf, src))
|
|
|
|
/obj/crystal_mass/proc/eat_bullets(datum/source, obj/projectile/hitting_projectile)
|
|
SIGNAL_HANDLER
|
|
|
|
visible_message(
|
|
span_warning("[hitting_projectile] flies into [src] with a loud crack, before rapidly flashing into ash."),
|
|
null,
|
|
span_hear("You hear a loud crack as you are washed with a wave of heat."),
|
|
)
|
|
|
|
playsound(src, 'sound/effects/supermatter.ogg', 50, TRUE)
|
|
qdel(hitting_projectile)
|
|
return COMPONENT_BULLET_BLOCKED
|
|
|
|
/obj/crystal_mass/singularity_act()
|
|
return
|
|
|
|
/obj/crystal_mass/attack_tk(mob/user)
|
|
if(!iscarbon(user))
|
|
return
|
|
var/mob/living/carbon/jedi = user
|
|
to_chat(jedi, span_userdanger("That was a really dense idea."))
|
|
jedi.ghostize()
|
|
var/obj/item/organ/brain/rip_u = locate(/obj/item/organ/brain) in jedi.organs
|
|
if(rip_u)
|
|
rip_u.Remove(jedi)
|
|
qdel(rip_u)
|
|
return COMPONENT_CANCEL_ATTACK_CHAIN
|
|
|
|
/obj/crystal_mass/Destroy()
|
|
STOP_PROCESSING(SSsupermatter_cascade, src)
|
|
sm_comp = null
|
|
return ..()
|
|
|
|
/obj/cascade_portal
|
|
name = "Bluespace Rift"
|
|
desc = "Your mind begins to spin as it tries to comprehend what it sees."
|
|
icon = 'icons/effects/224x224.dmi'
|
|
icon_state = "reality"
|
|
anchored = TRUE
|
|
appearance_flags = LONG_GLIDE
|
|
density = TRUE
|
|
plane = MASSIVE_OBJ_PLANE
|
|
light_color = COLOR_RED
|
|
light_power = 0.7
|
|
light_range = 15
|
|
move_resist = INFINITY
|
|
pixel_x = -96
|
|
pixel_y = -96
|
|
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF | FREEZE_PROOF
|
|
|
|
/obj/cascade_portal/Initialize(mapload)
|
|
. = ..()
|
|
var/turf/location = get_turf(src)
|
|
var/area_name = get_area_name(src)
|
|
message_admins("Exit rift created at [area_name]. [ADMIN_VERBOSEJMP(location)]")
|
|
log_game("Bluespace Exit Rift was created at [area_name].")
|
|
investigate_log("created at [area_name].", INVESTIGATE_ENGINE)
|
|
|
|
/obj/cascade_portal/Destroy(force)
|
|
var/turf/location = get_turf(src)
|
|
var/area_name = get_area_name(src)
|
|
message_admins("Exit rift at [area_name] deleted. [ADMIN_VERBOSEJMP(location)]")
|
|
log_game("Bluespace Exit Rift at [area_name] was deleted.")
|
|
investigate_log("was deleted.", INVESTIGATE_ENGINE)
|
|
return ..()
|
|
|
|
/obj/cascade_portal/Bumped(atom/movable/hit_object)
|
|
consume(hit_object)
|
|
new /obj/effect/particle_effect/sparks(loc)
|
|
playsound(loc, SFX_SPARKS, 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
|
|
|
|
/**
|
|
* Proc to consume the objects colliding with the portal
|
|
*
|
|
* Arguments: atom/movable/consumed_object is the object hitting the portal
|
|
*/
|
|
/obj/cascade_portal/proc/consume(atom/movable/consumed_object)
|
|
if(isliving(consumed_object))
|
|
consumed_object.visible_message(span_danger("\The [consumed_object] walks into \the [src]... \
|
|
A blinding light covers [consumed_object.p_their()] body before disappearing completely!"),
|
|
span_userdanger("You walk into \the [src] as your body is washed with a powerful blue light. \
|
|
You contemplate about this decision before landing face first onto the cold, hard floor."),
|
|
span_hear("You hear a loud crack as a distortion passes through you."))
|
|
|
|
var/list/arrival_turfs = get_area_turfs(/area/centcom/central_command_areas/evacuation)
|
|
var/turf/arrival_turf
|
|
do
|
|
arrival_turf = pick_n_take(arrival_turfs)
|
|
while(!is_safe_turf(arrival_turf))
|
|
|
|
var/mob/living/consumed_mob = consumed_object
|
|
message_admins("[key_name_admin(consumed_mob)] has entered [src] [ADMIN_VERBOSEJMP(src)].")
|
|
investigate_log("was entered by [key_name(consumed_mob)].", INVESTIGATE_ENGINE)
|
|
consumed_mob.forceMove(arrival_turf)
|
|
consumed_mob.Paralyze(100)
|
|
consumed_mob.adjust_brute_loss(30)
|
|
consumed_mob.flash_act(1, TRUE, TRUE)
|
|
|
|
new /obj/effect/particle_effect/sparks(consumed_object)
|
|
playsound(consumed_object, SFX_SPARKS, 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
|
|
else if(isitem(consumed_object))
|
|
consumed_object.visible_message(span_danger("\The [consumed_object] smacks into \the [src] and disappears out of sight."), null,
|
|
span_hear("You hear a loud crack as a small distortion passes through you."))
|
|
|
|
qdel(consumed_object)
|