mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 00:29:02 +01:00
## 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! /🆑
110 lines
4.7 KiB
Plaintext
110 lines
4.7 KiB
Plaintext
/datum/martial_art/psychotic_brawling
|
|
name = "Psychotic Brawling"
|
|
id = MARTIALART_PSYCHOBRAWL
|
|
pacifist_style = TRUE
|
|
|
|
/datum/martial_art/psychotic_brawling/disarm_act(mob/living/attacker, mob/living/defender)
|
|
return psycho_attack(attacker, defender)
|
|
|
|
/datum/martial_art/psychotic_brawling/grab_act(mob/living/attacker, mob/living/defender)
|
|
return psycho_attack(attacker, defender, TRUE)
|
|
|
|
/datum/martial_art/psychotic_brawling/harm_act(mob/living/attacker, mob/living/defender)
|
|
return psycho_attack(attacker, defender)
|
|
|
|
/datum/martial_art/psychotic_brawling/proc/psycho_attack(mob/living/attacker, mob/living/defender, grab_attack)
|
|
var/atk_verb
|
|
switch(rand(1,8))
|
|
if(1)
|
|
if(iscarbon(defender) && iscarbon(attacker))
|
|
var/mob/living/carbon/carbon_defender = defender
|
|
carbon_defender.help_shake_act(attacker)
|
|
atk_verb = "helped"
|
|
if(2)
|
|
attacker.emote("cry")
|
|
attacker.Stun(2 SECONDS)
|
|
atk_verb = "cried looking at"
|
|
if(3)
|
|
if(defender.check_block(attacker, 0, "[attacker]'s grab", UNARMED_ATTACK))
|
|
return MARTIAL_ATTACK_FAIL
|
|
if(attacker.body_position == LYING_DOWN)
|
|
return MARTIAL_ATTACK_INVALID
|
|
|
|
if(attacker.grab_state >= GRAB_AGGRESSIVE)
|
|
defender.grabbedby(attacker, 1)
|
|
else
|
|
attacker.start_pulling(defender, supress_message = TRUE)
|
|
if(attacker.pulling)
|
|
defender.drop_all_held_items()
|
|
defender.stop_pulling()
|
|
if(grab_attack)
|
|
log_combat(attacker, defender, "grabbed", addition="aggressively")
|
|
defender.visible_message(
|
|
span_warning("[attacker] violently grabs [defender]!"),
|
|
span_userdanger("You're violently grabbed by [attacker]!"),
|
|
span_hear("You hear sounds of aggressive fondling!"),
|
|
null,
|
|
attacker,
|
|
)
|
|
to_chat(attacker, span_danger("You violently grab [defender]!"))
|
|
attacker.setGrabState(GRAB_AGGRESSIVE) //Instant aggressive grab
|
|
else
|
|
log_combat(attacker, defender, "grabbed", addition="passively")
|
|
attacker.setGrabState(GRAB_PASSIVE)
|
|
if(4)
|
|
atk_verb = "headbutt"
|
|
var/defender_damage = rand(5, 10)
|
|
if(defender.check_block(attacker, defender_damage, "[attacker]'s [atk_verb]", UNARMED_ATTACK))
|
|
return MARTIAL_ATTACK_FAIL
|
|
|
|
attacker.do_attack_animation(defender, ATTACK_EFFECT_PUNCH)
|
|
attacker.emote("flip")
|
|
defender.visible_message(
|
|
span_danger("[attacker] [atk_verb]s [defender]!"),
|
|
span_userdanger("You're [atk_verb]ed by [attacker]!"),
|
|
span_hear("You hear a sickening sound of flesh hitting flesh!"),
|
|
null,
|
|
attacker,
|
|
)
|
|
to_chat(attacker, span_danger("You [atk_verb] [defender]!"))
|
|
playsound(defender, 'sound/items/weapons/punch1.ogg', 40, TRUE, -1)
|
|
defender.apply_damage(defender_damage, attacker.get_attack_type(), BODY_ZONE_HEAD)
|
|
attacker.apply_damage(rand(5, 10), attacker.get_attack_type(), BODY_ZONE_HEAD)
|
|
if(iscarbon(defender))
|
|
var/mob/living/carbon/carbon_defender = defender
|
|
if(!istype(carbon_defender.head, /obj/item/clothing/head/helmet/) && !istype(carbon_defender.head, /obj/item/clothing/head/utility/hardhat))
|
|
carbon_defender.adjust_organ_loss(ORGAN_SLOT_BRAIN, 5)
|
|
attacker.Stun(rand(1 SECONDS, 4.5 SECONDS))
|
|
defender.Stun(rand(0.5 SECONDS, 3 SECONDS))
|
|
if(HAS_TRAIT(attacker, TRAIT_PACIFISM))
|
|
attacker.add_mood_event("bypassed_pacifism", /datum/mood_event/pacifism_bypassed)
|
|
if(5,6)
|
|
atk_verb = pick("kick", "hit", "slam")
|
|
if(defender.check_block(attacker, 0, "[attacker]'s [atk_verb]", UNARMED_ATTACK))
|
|
return MARTIAL_ATTACK_FAIL
|
|
|
|
attacker.do_attack_animation(defender, ATTACK_EFFECT_PUNCH)
|
|
defender.visible_message(
|
|
span_danger("[attacker] [atk_verb]s [defender] with such inhuman strength that it sends [defender.p_them()] flying backwards!"),
|
|
span_userdanger("You're [atk_verb]ed by [attacker] with such inhuman strength that it sends you flying backwards!"),
|
|
span_hear("You hear a sickening sound of flesh hitting flesh!"),
|
|
null,
|
|
attacker,
|
|
)
|
|
to_chat(attacker, span_danger("You [atk_verb] [defender] with such inhuman strength that it sends [defender.p_them()] flying backwards!"))
|
|
defender.apply_damage(rand(15, 30), attacker.get_attack_type())
|
|
playsound(defender, 'sound/effects/meteorimpact.ogg', 25, TRUE, -1)
|
|
var/throwtarget = get_edge_target_turf(attacker, get_dir(attacker, get_step_away(defender, attacker)))
|
|
defender.throw_at(throwtarget, 4, 2, attacker)//So stuff gets tossed around at the same time.
|
|
defender.Paralyze(6 SECONDS)
|
|
if(HAS_TRAIT(attacker, TRAIT_PACIFISM))
|
|
attacker.add_mood_event("bypassed_pacifism", /datum/mood_event/pacifism_bypassed)
|
|
if(7,8)
|
|
return MARTIAL_ATTACK_INVALID //Resume default behaviour
|
|
|
|
if(atk_verb)
|
|
log_combat(attacker, defender, "[atk_verb] (Psychotic Brawling)")
|
|
return MARTIAL_ATTACK_SUCCESS
|
|
|
|
return MARTIAL_ATTACK_FAIL
|