mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-09 14:23:38 +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! /🆑
81 lines
3.2 KiB
Plaintext
81 lines
3.2 KiB
Plaintext
/obj/item/mutant_hand/zombie
|
|
name = "zombie claw"
|
|
desc = "A zombie's claw is its primary tool, capable of infecting \
|
|
humans, butchering all other living things to \
|
|
sustain the zombie, smashing open airlock doors and opening \
|
|
child-safe caps on bottles."
|
|
|
|
hitsound = 'sound/effects/hallucinations/growl1.ogg'
|
|
force = 21 // Just enough to break airlocks with melee attacks
|
|
wound_bonus = -30
|
|
exposed_wound_bonus = 15
|
|
sharpness = SHARP_EDGED
|
|
|
|
/obj/item/mutant_hand/zombie/afterattack(atom/target, mob/user, list/modifiers, list/attack_modifiers)
|
|
if(ishuman(target))
|
|
try_to_zombie_infect(target, user, user.zone_selected)
|
|
else if(isliving(target))
|
|
check_feast(target, user)
|
|
|
|
/proc/try_to_zombie_infect(mob/living/carbon/human/target, mob/living/user, def_zone = BODY_ZONE_CHEST)
|
|
CHECK_DNA_AND_SPECIES(target)
|
|
|
|
// Can't zombify with no head
|
|
if(!target.get_bodypart(BODY_ZONE_HEAD))
|
|
return
|
|
|
|
if(HAS_TRAIT(target, TRAIT_NO_ZOMBIFY))
|
|
// cannot infect any TRAIT_NO_ZOMBIFY human
|
|
return
|
|
|
|
// spaceacillin has a 75% chance to block infection
|
|
if(HAS_TRAIT(target, TRAIT_VIRUS_RESISTANCE) && !HAS_TRAIT(target, TRAIT_IMMUNODEFICIENCY) && prob(75))
|
|
return
|
|
|
|
var/obj/item/bodypart/actual_limb = target.get_bodypart(def_zone)
|
|
|
|
// What you hitting bro?
|
|
if(!actual_limb)
|
|
return
|
|
|
|
var/limb_damage = actual_limb.get_damage()
|
|
var/limb_armor = max(0, target.getarmor(actual_limb, BIO) - 25)
|
|
|
|
// This is a pretty jank way to do this, but in short:
|
|
// if they have thick material on that bodypart it will always need at least 25 previous limb damage to trigger an infection.
|
|
// and if their bio armor isn't thick it's a bit weaker.
|
|
for(var/obj/item/clothing/iter_clothing in target.get_clothing_on_part(actual_limb))
|
|
if(iter_clothing.clothing_flags & THICKMATERIAL)
|
|
limb_armor += 25
|
|
|
|
if(limb_armor > limb_damage)
|
|
return
|
|
|
|
var/obj/item/organ/zombie_infection/infection
|
|
infection = target.get_organ_slot(ORGAN_SLOT_ZOMBIE)
|
|
if(!infection)
|
|
infection = new()
|
|
infection.Insert(target)
|
|
to_chat(user, span_alien("You see [target] twitch for a moment as [target.p_their()] head is covered in \a [infection] - [target.p_Theyve()] been infected."))
|
|
|
|
/obj/item/mutant_hand/zombie/suicide_act(mob/living/user)
|
|
user.visible_message(span_suicide("[user] is ripping [user.p_their()] brains out! It looks like [user.p_theyre()] trying to commit suicide!"))
|
|
var/obj/item/bodypart/head = user.get_bodypart(BODY_ZONE_HEAD)
|
|
if(head)
|
|
head.dismember()
|
|
return BRUTELOSS
|
|
|
|
/obj/item/mutant_hand/zombie/proc/check_feast(mob/living/target, mob/living/user)
|
|
if(target.stat == DEAD)
|
|
var/hp_gained = target.maxHealth
|
|
target.investigate_log("has been devoured by a zombie.", INVESTIGATE_DEATHS)
|
|
target.gib(DROP_ALL_REMAINS)
|
|
var/need_mob_update
|
|
need_mob_update = user.adjust_brute_loss(-hp_gained, updating_health = FALSE)
|
|
need_mob_update += user.adjust_tox_loss(-hp_gained, updating_health = FALSE)
|
|
need_mob_update += user.adjust_fire_loss(-hp_gained, updating_health = FALSE)
|
|
need_mob_update += user.adjust_organ_loss(ORGAN_SLOT_BRAIN, -hp_gained) // Zom Bee gibbers "BRAAAAISNSs!1!"
|
|
user.set_nutrition(min(user.nutrition + hp_gained, NUTRITION_LEVEL_FULL))
|
|
if(need_mob_update)
|
|
user.updatehealth()
|