mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-14 09:35:30 +01:00
7a3ad79506
## 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! /🆑
103 lines
3.8 KiB
Plaintext
103 lines
3.8 KiB
Plaintext
/// Sends a fake bubblegum charging through a nearby wall to our target.
|
|
/datum/hallucination/oh_yeah
|
|
random_hallucination_weight = 1
|
|
hallucination_tier = HALLUCINATION_TIER_RARE
|
|
/// An image overlayed to the wall bubblegum comes out of, to look destroyed.
|
|
var/image/fake_broken_wall
|
|
/// An image put where bubblegum is expected to land, to mimic his charge "rune" icon.
|
|
var/image/fake_rune
|
|
/// if TRUE, we will also send one of the hallucination lines when we start.
|
|
var/haunt_them = FALSE
|
|
/// if haunt_them is TRUE, they will also be shown one of these lines when the hallucination occurs
|
|
var/static/list/hallucination_lines = BUBBLEGUM_HALLUCINATION_LINES
|
|
|
|
/datum/hallucination/oh_yeah/New(mob/living/hallucinator, source = "an external source", haunt_them = FALSE)
|
|
src.haunt_them = haunt_them
|
|
return ..()
|
|
|
|
/datum/hallucination/oh_yeah/Destroy()
|
|
if(fake_broken_wall)
|
|
hallucinator.client?.images -= fake_broken_wall
|
|
fake_broken_wall = null
|
|
if(fake_rune)
|
|
hallucinator.client?.images -= fake_rune
|
|
fake_rune = null
|
|
|
|
return ..()
|
|
|
|
/datum/hallucination/oh_yeah/start()
|
|
var/turf/closed/wall/wall_source = locate() in range(7, hallucinator)
|
|
if(!wall_source)
|
|
return FALSE
|
|
|
|
feedback_details += "Source: ([wall_source.x], [wall_source.y], [wall_source.z])"
|
|
|
|
var/turf/target_landing_turf = get_turf(hallucinator)
|
|
var/turf/target_landing_image_turf = get_step(target_landing_turf, SOUTHWEST) // The icon is 3x3, so we shift down+left
|
|
|
|
if(hallucinator.client)
|
|
|
|
fake_broken_wall = image('icons/turf/floors.dmi', wall_source, "plating", layer = LOW_FLOOR_LAYER)
|
|
SET_PLANE_EXPLICIT(fake_broken_wall, FLOOR_PLANE, wall_source)
|
|
fake_broken_wall.override = TRUE
|
|
fake_rune = image('icons/effects/96x96.dmi', target_landing_image_turf, "landing", layer = ABOVE_OPEN_TURF_LAYER)
|
|
SET_PLANE_EXPLICIT(fake_rune, FLOOR_PLANE, wall_source)
|
|
|
|
hallucinator.client?.images |= fake_broken_wall
|
|
hallucinator.client?.images |= fake_rune
|
|
|
|
hallucinator.playsound_local(wall_source, 'sound/effects/meteorimpact.ogg', 150, TRUE)
|
|
|
|
if(haunt_them)
|
|
to_chat(hallucinator, pick(hallucination_lines))
|
|
|
|
var/obj/effect/client_image_holder/hallucination/bubblegum/fake_bubbles = new(wall_source, hallucinator, src)
|
|
addtimer(CALLBACK(src, PROC_REF(charge_loop), fake_bubbles, target_landing_turf), 1 SECONDS)
|
|
return TRUE
|
|
|
|
/**
|
|
* Recursive function that operates as a "fake charge" of our effect towards the target turf.
|
|
*/
|
|
/datum/hallucination/oh_yeah/proc/charge_loop(obj/effect/client_image_holder/hallucination/bubblegum/fake_bubbles, turf/landing_turf)
|
|
if(QDELETED(src))
|
|
return
|
|
|
|
if(QDELETED(hallucinator) \
|
|
|| QDELETED(fake_bubbles) \
|
|
|| !landing_turf \
|
|
|| fake_bubbles.z != hallucinator.z \
|
|
|| fake_bubbles.z != landing_turf.z \
|
|
)
|
|
qdel(src)
|
|
return
|
|
|
|
if(get_turf(fake_bubbles) == landing_turf || hallucinator.stat == DEAD)
|
|
QDEL_IN(src, 3 SECONDS)
|
|
return
|
|
|
|
fake_bubbles.forceMove(get_step_towards(fake_bubbles, landing_turf))
|
|
fake_bubbles.setDir(get_dir(fake_bubbles, landing_turf))
|
|
hallucinator.playsound_local(get_turf(fake_bubbles), 'sound/effects/meteorimpact.ogg', 150, TRUE)
|
|
shake_camera(hallucinator, 2, 1)
|
|
|
|
if(fake_bubbles.Adjacent(hallucinator))
|
|
hallucinator.Paralyze(8 SECONDS)
|
|
hallucinator.adjust_stamina_loss(40)
|
|
step_away(hallucinator, fake_bubbles)
|
|
shake_camera(hallucinator, 4, 3)
|
|
hallucinator.visible_message(
|
|
span_warning("[hallucinator] jumps backwards, falling on the ground!"),
|
|
span_userdanger("[fake_bubbles] slams into you!"),
|
|
)
|
|
QDEL_IN(src, 3 SECONDS)
|
|
|
|
else
|
|
addtimer(CALLBACK(src, PROC_REF(charge_loop), fake_bubbles, landing_turf), 0.2 SECONDS)
|
|
|
|
/// Fake bubblegum hallucination effect for the oh yeah hallucination
|
|
/obj/effect/client_image_holder/hallucination/bubblegum
|
|
name = "Bubblegum"
|
|
image_icon = 'icons/mob/simple/lavaland/96x96megafauna.dmi'
|
|
image_state = "bubblegum"
|
|
image_pixel_x = -32
|