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

138 lines
4.7 KiB
Plaintext

/// Armsy starts to look a bit funky if he's shorter than this
#define MINIMUM_ARMSY_LENGTH 2
// What if we took a linked list... But made it a mob?
/// The "Terror of the Night" / Armsy, a large worm made of multiple bodyparts that occupies multiple tiles
/mob/living/basic/heretic_summon/armsy
name = "Lord of the Night"
real_name = "Master of Decay"
desc = "An abomination made from dozens and dozens of severed and malformed limbs grasping onto each other."
icon_state = "armsy_start"
icon_living = "armsy_start"
base_icon_state = "armsy"
maxHealth = 400
health = 400
melee_damage_lower = 30
melee_damage_upper = 50
obj_damage = 200
move_force = MOVE_FORCE_OVERPOWERING
move_resist = MOVE_FORCE_OVERPOWERING
pull_force = MOVE_FORCE_OVERPOWERING
mob_size = MOB_SIZE_HUGE
sentience_type = SENTIENCE_BOSS
mob_biotypes = MOB_ORGANIC|MOB_SPECIAL
///Previous segment in the chain, we hold onto this purely to keep track of how long we currently are and to attach new growth to the back
var/mob/living/basic/heretic_summon/armsy/back
///How many arms do we have to eat to expand?
var/stacks_to_grow = 5
///Currently eaten arms
var/current_stacks = 0
/*
* Arguments
* * spawn_bodyparts - whether we spawn additional armsy bodies until we reach length.
* * worm_length - the length of the worm we're creating. Below 2 doesn't work very well.
*/
/mob/living/basic/heretic_summon/armsy/Initialize(mapload, spawn_bodyparts = TRUE, worm_length = 6)
. = ..()
AddElement(/datum/element/wall_smasher, ENVIRONMENT_SMASH_RWALLS)
AddComponent(\
/datum/component/amputating_limbs,\
surgery_time = 0 SECONDS,\
surgery_verb = "tears",\
minimum_stat = CONSCIOUS,\
snip_chance = 10,\
target_zones = GLOB.arm_zones,\
)
AddComponent(\
/datum/component/blood_walk, \
blood_type = /obj/effect/decal/cleanable/blood/tracks, \
target_dir_change = TRUE,\
)
if(spawn_bodyparts)
build_tail(worm_length)
// We are a vessel of otherworldly destruction, we bring our gravity with us
/mob/living/basic/heretic_summon/armsy/has_gravity(turf/gravity_turf)
return TRUE
/mob/living/basic/heretic_summon/armsy/can_be_pulled(user, force)
return FALSE // The component does this but not on the head. We don't want the head to be pulled either.
/mob/living/basic/heretic_summon/armsy/proc/build_tail(worm_length)
worm_length = max(worm_length, MINIMUM_ARMSY_LENGTH)
// Sets the hp of the head to be exactly the (length * hp), so the head is de facto the hardest to destroy.
maxHealth = worm_length * maxHealth
health = maxHealth
AddComponent(/datum/component/mob_chain, vary_icon_state = TRUE) // We're the front
var/mob/living/basic/heretic_summon/armsy/prev = src
for(var/i in 1 to worm_length)
prev = new_segment(behind = prev)
update_appearance(UPDATE_ICON_STATE)
/// Grows a new segment behind the passed mob
/mob/living/basic/heretic_summon/armsy/proc/new_segment(mob/living/basic/heretic_summon/armsy/behind)
var/mob/living/segment = new type(drop_location(), FALSE)
ADD_TRAIT(segment, TRAIT_PERMANENTLY_MORTAL, INNATE_TRAIT)
segment.AddComponent(/datum/component/mob_chain, front = behind, vary_icon_state = TRUE)
behind.register_behind(segment)
return segment
/// Record that we got another guy on our ass
/mob/living/basic/heretic_summon/armsy/proc/register_behind(mob/living/tail)
if(!isnull(back)) // Shouldn't happen but just in case
UnregisterSignal(back, COMSIG_QDELETING)
back = tail
update_appearance(UPDATE_ICON_STATE)
if(!isnull(back))
RegisterSignal(back, COMSIG_QDELETING, PROC_REF(tail_deleted))
/// When our tail is gone stop holding a reference to it
/mob/living/basic/heretic_summon/armsy/proc/tail_deleted()
SIGNAL_HANDLER
register_behind(null)
/mob/living/basic/heretic_summon/armsy/melee_attack(atom/target, list/modifiers, ignore_cooldown)
if(!istype(target, /obj/item/bodypart/arm))
return ..()
visible_message(span_warning("[src] devours [target]!"))
playsound(src, 'sound/effects/magic/demon_consume.ogg', 50, TRUE)
qdel(target)
on_arm_eaten()
/*
* Handle healing our chain.
* Eating arms off the ground heals us, and if we eat enough arms while above a certain health threshold we get longer!
*/
/mob/living/basic/heretic_summon/armsy/proc/on_arm_eaten()
if(!isnull(back))
back.on_arm_eaten()
return
adjust_brute_loss(-maxHealth * 0.5, FALSE)
adjust_fire_loss(-maxHealth * 0.5, FALSE)
if(health < maxHealth * 0.8)
return
current_stacks++
if(current_stacks < stacks_to_grow)
return
visible_message(span_boldwarning("[src] flexes and expands!"))
current_stacks = 0
new_segment(behind = src)
/*
* Recursively get the length of our chain.
*/
/mob/living/basic/heretic_summon/armsy/proc/get_length()
. = 1
if(isnull(back))
return
. += back.get_length()
#undef MINIMUM_ARMSY_LENGTH