Files
Joshua Kidder 7a3ad79506 All camelCase (Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss) procs now use snake_case. UNDERSCORES RULE! (#94111)
## 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!
/🆑
2025-11-27 15:50:23 -05:00

85 lines
3.4 KiB
Plaintext

/datum/status_effect/incapacitating/stamcrit
id = "stamcrit"
status_type = STATUS_EFFECT_UNIQUE
// Lasts until we go back to 0 stamina, which is handled by the mob
duration = STATUS_EFFECT_PERMANENT
tick_interval = STATUS_EFFECT_NO_TICK
/// Cooldown between displaying warning messages that we hit diminishing returns
COOLDOWN_DECLARE(warn_cd)
/// A counter that tracks every time we've taken enough damage to trigger diminishing returns
var/diminishing_return_counter = 0
/datum/status_effect/incapacitating/stamcrit/on_creation(mob/living/new_owner, set_duration)
. = ..()
if(!.)
return .
// This should be in on apply but we need it to happen AFTER being added to the mob
// (Because we need to wait until the status effect is in their status effect list, or we'll add two)
if(owner.get_stamina_loss() < 120)
// Puts you a little further into the initial stamcrit, makes stamcrit harder to outright counter with chems.
owner.adjust_stamina_loss(30, FALSE)
// Same
RegisterSignal(owner, COMSIG_LIVING_ADJUST_STAMINA_DAMAGE, PROC_REF(update_diminishing_return))
RegisterSignal(owner, COMSIG_LIVING_STAMINA_UPDATE, PROC_REF(check_remove))
/datum/status_effect/incapacitating/stamcrit/on_apply()
if(owner.stat == DEAD)
return FALSE
if(owner.check_stun_immunity(CANSTUN))
return FALSE
if(SEND_SIGNAL(owner, COMSIG_LIVING_ENTER_STAMCRIT) & STAMCRIT_CANCELLED)
return FALSE
. = ..()
if(!.)
return .
if(owner.stat == CONSCIOUS)
to_chat(owner, span_notice("You're too exhausted to keep going..."))
owner.add_traits(list(TRAIT_INCAPACITATED, TRAIT_IMMOBILIZED, TRAIT_FLOORED), STAMINA)
return .
/datum/status_effect/incapacitating/stamcrit/on_remove()
UnregisterSignal(owner, COMSIG_LIVING_HEALTH_UPDATE)
UnregisterSignal(owner, COMSIG_LIVING_ADJUST_STAMINA_DAMAGE)
owner.remove_traits(list(TRAIT_INCAPACITATED, TRAIT_IMMOBILIZED, TRAIT_FLOORED), STAMINA)
return ..()
/datum/status_effect/incapacitating/stamcrit/proc/update_diminishing_return(datum/source, type, amount, forced)
SIGNAL_HANDLER
if(amount <= 0 || forced)
return NONE
// Here we fake the effect of having diminishing returns
// We don't actually decrease incoming stamina damage because that would be pointless, the mob is at stam damage cap anyways
// Instead we just "ignore" the damage if we have a sufficiently high diminishing return counter
var/mod_amount = ceil(sqrt(amount) / 2) - diminishing_return_counter
// We check base amount not mod_amount because we still want to up tick it even if we've already got a high counter
// We also only uptick it after calculating damage so we start ticking up after the damage and not before
switch(amount)
if(5 to INFINITY)
diminishing_return_counter += 1
if(2 to 5) // Prevent chems from skyrockting DR
diminishing_return_counter += 0.05
if(mod_amount > 0)
return NONE
if(COOLDOWN_FINISHED(src, warn_cd) && owner.stat == CONSCIOUS)
to_chat(owner, span_notice("You start to recover from the exhaustion!"))
owner.visible_message(span_warning("[owner] starts to recover from the exhaustion!"), ignored_mobs = owner)
COOLDOWN_START(src, warn_cd, 2.5 SECONDS)
return COMPONENT_IGNORE_CHANGE
/datum/status_effect/incapacitating/stamcrit/proc/check_remove(datum/source)
SIGNAL_HANDLER
if (isbasicmob(owner))
var/mob/living/basic/basic_owner = owner
if(basic_owner.staminaloss < basic_owner.stamina_crit_threshold)
qdel(src)
return
if(owner.maxHealth - owner.get_stamina_loss() > owner.crit_threshold)
qdel(src)