mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 08:36:00 +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! /🆑
139 lines
4.8 KiB
Plaintext
139 lines
4.8 KiB
Plaintext
// A 10% chance that out of a group of 25 people, one person will get appendicitis in 1 hour.
|
|
#define APPENDICITIS_PROB 100 * (0.1 * (1 / 25) / 3600)
|
|
#define INFLAMATION_ADVANCEMENT_PROB 2
|
|
|
|
/obj/item/organ/appendix
|
|
name = "appendix"
|
|
icon_state = "appendix"
|
|
base_icon_state = "appendix"
|
|
|
|
zone = BODY_ZONE_PRECISE_GROIN
|
|
slot = ORGAN_SLOT_APPENDIX
|
|
food_reagents = list(/datum/reagent/consumable/nutriment/organ_tissue = 5, /datum/reagent/toxin/bad_food = 5)
|
|
grind_results = list(/datum/reagent/toxin/bad_food = 5)
|
|
healing_factor = STANDARD_ORGAN_HEALING
|
|
decay_factor = STANDARD_ORGAN_DECAY
|
|
|
|
now_failing = span_warning("An explosion of pain erupts in your lower right abdomen!")
|
|
now_fixed = span_info("The pain in your abdomen has subsided.")
|
|
|
|
var/inflamation_stage = 0
|
|
|
|
/obj/item/organ/appendix/update_name()
|
|
. = ..()
|
|
name = "[inflamation_stage ? "inflamed " : null][initial(name)]"
|
|
|
|
/obj/item/organ/appendix/update_icon_state()
|
|
icon_state = "[base_icon_state][inflamation_stage ? "inflamed" : ""]"
|
|
return ..()
|
|
|
|
/obj/item/organ/appendix/on_life(seconds_per_tick, times_fired)
|
|
. = ..()
|
|
if(!owner)
|
|
return
|
|
|
|
if(organ_flags & ORGAN_FAILING)
|
|
// forced to ensure people don't use it to gain tox as slime person
|
|
owner.adjust_tox_loss(2 * seconds_per_tick, forced = TRUE)
|
|
else if(inflamation_stage)
|
|
inflamation(seconds_per_tick)
|
|
else if(SPT_PROB(APPENDICITIS_PROB, seconds_per_tick) && !HAS_TRAIT(owner, TRAIT_TEMPORARY_BODY))
|
|
become_inflamed()
|
|
|
|
/obj/item/organ/appendix/proc/become_inflamed()
|
|
inflamation_stage = 1
|
|
update_appearance()
|
|
if(isnull(owner))
|
|
return
|
|
ADD_TRAIT(owner, TRAIT_DISEASELIKE_SEVERITY_MEDIUM, type)
|
|
owner.med_hud_set_status()
|
|
RegisterSignal(owner, COMSIG_LIVING_POST_FULLY_HEAL, PROC_REF(on_fully_heal))
|
|
if(isnull(owner.client))
|
|
return
|
|
notify_ghosts(
|
|
"[owner.real_name] has developed spontaneous appendicitis!",
|
|
source = owner,
|
|
header = "Whoa, Sick!",
|
|
)
|
|
|
|
/obj/item/organ/appendix/proc/inflamation(seconds_per_tick)
|
|
var/mob/living/carbon/organ_owner = owner
|
|
if(inflamation_stage < 3 && SPT_PROB(INFLAMATION_ADVANCEMENT_PROB, seconds_per_tick))
|
|
inflamation_stage += 1
|
|
|
|
switch(inflamation_stage)
|
|
if(1)
|
|
if(SPT_PROB(2.5, seconds_per_tick))
|
|
organ_owner.emote("cough")
|
|
if(2)
|
|
if(SPT_PROB(1.5, seconds_per_tick))
|
|
to_chat(organ_owner, span_warning("You feel a stabbing pain in your abdomen!"))
|
|
organ_owner.adjust_organ_loss(ORGAN_SLOT_APPENDIX, 5)
|
|
organ_owner.Stun(rand(40, 60))
|
|
organ_owner.adjust_tox_loss(1, forced = TRUE)
|
|
if(3)
|
|
if(SPT_PROB(0.5, seconds_per_tick))
|
|
organ_owner.vomit(VOMIT_CATEGORY_DEFAULT, lost_nutrition = 95)
|
|
organ_owner.adjust_organ_loss(ORGAN_SLOT_APPENDIX, 15)
|
|
|
|
/obj/item/organ/appendix/feel_for_damage(self_aware)
|
|
var/effective_stage = floor(inflamation_stage + (damage / maxHealth))
|
|
switch(effective_stage)
|
|
if(1)
|
|
return span_warning("Your [self_aware ? "appendix" : "lower abdomen"] feels a little off.")
|
|
if(2)
|
|
return span_warning("Your [self_aware ? "appendix" : "lower right abdomen"] feels sore.")
|
|
if(3 to INFINITY)
|
|
return span_boldwarning("Your [self_aware ? "appendix" : "lower right abdomen"] feels like it's on fire!")
|
|
|
|
/obj/item/organ/appendix/get_availability(datum/species/owner_species, mob/living/owner_mob)
|
|
return owner_species.mutantappendix
|
|
|
|
/obj/item/organ/appendix/on_mob_remove(mob/living/carbon/organ_owner)
|
|
. = ..()
|
|
UnregisterSignal(organ_owner, COMSIG_LIVING_POST_FULLY_HEAL)
|
|
REMOVE_TRAIT(organ_owner, TRAIT_DISEASELIKE_SEVERITY_MEDIUM, type)
|
|
organ_owner.med_hud_set_status()
|
|
|
|
/obj/item/organ/appendix/on_mob_insert(mob/living/carbon/organ_owner)
|
|
. = ..()
|
|
if(!inflamation_stage)
|
|
return
|
|
ADD_TRAIT(organ_owner, TRAIT_DISEASELIKE_SEVERITY_MEDIUM, type)
|
|
organ_owner.med_hud_set_status()
|
|
RegisterSignal(organ_owner, COMSIG_LIVING_POST_FULLY_HEAL, PROC_REF(on_fully_heal))
|
|
|
|
/obj/item/organ/appendix/proc/on_fully_heal(datum/source, heal_flags)
|
|
SIGNAL_HANDLER
|
|
|
|
if (!(heal_flags & HEAL_ORGANS))
|
|
return
|
|
|
|
inflamation_stage = 0
|
|
update_appearance()
|
|
UnregisterSignal(owner, COMSIG_LIVING_POST_FULLY_HEAL)
|
|
REMOVE_TRAIT(owner, TRAIT_DISEASELIKE_SEVERITY_MEDIUM, type)
|
|
owner.med_hud_set_status()
|
|
|
|
/obj/item/organ/appendix/get_status_text(advanced, add_tooltips, colored)
|
|
if(!(organ_flags & ORGAN_FAILING) && inflamation_stage)
|
|
return conditional_tooltip("<font color='#ff9933'>Inflamed</font>", "Remove surgically.", add_tooltips)
|
|
return ..()
|
|
|
|
/obj/item/organ/appendix/pod
|
|
name = "pod thingy"
|
|
desc = "Strangest salad you've ever seen."
|
|
foodtype_flags = PODPERSON_ORGAN_FOODTYPES
|
|
color = COLOR_LIME
|
|
|
|
/obj/item/organ/appendix/pod/Initialize(mapload)
|
|
. = ..()
|
|
// this could be anything... anything. still useless though
|
|
name = pick("pod endoplasmic reticulum", "pod golgi apparatus", "pod plastid", "pod vesicle")
|
|
|
|
/obj/item/organ/appendix/pod/become_inflamed()
|
|
return
|
|
|
|
#undef APPENDICITIS_PROB
|
|
#undef INFLAMATION_ADVANCEMENT_PROB
|