Skip to content

Commit 5c933d8

Browse files
authored
Pig Latin Mutation (tgstation#61184)
1 parent 22f83d4 commit 5c933d8

File tree

5 files changed

+88
-3
lines changed

5 files changed

+88
-3
lines changed

Diff for: code/__DEFINES/DNA.dm

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define ACIDFLESH /datum/mutation/human/acidflesh
77
#define ANTENNA /datum/mutation/human/antenna
88
#define ANTIGLOWY /datum/mutation/human/glow/anti
9+
#define AUTONOMY /datum/mutation/human/self_amputation
910
#define BADBLINK /datum/mutation/human/badblink
1011
#define BADSIGHT /datum/mutation/human/nearsight
1112
#define BIOTECHCOMPAT /datum/mutation/human/biotechcompat
@@ -37,9 +38,9 @@
3738
#define NERVOUS /datum/mutation/human/nervousness
3839
#define OLFACTION /datum/mutation/human/olfaction
3940
#define PARANOIA /datum/mutation/human/paranoia
41+
#define PIGLATIN /datum/mutation/human/piglatin
4042
#define RACEMUT /datum/mutation/human/race
4143
#define RADIOACTIVE /datum/mutation/human/radioactive
42-
#define AUTONOMY /datum/mutation/human/self_amputation
4344
#define SHOCKTOUCH /datum/mutation/human/shock
4445
#define SPACEMUT /datum/mutation/human/space_adaptation
4546
#define SPASTIC /datum/mutation/human/spastic

Diff for: code/__HELPERS/text.dm

+53-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
/**
7777
* Returns the text if properly formatted, or null else.
78-
*
78+
*
7979
* Things considered improper:
8080
* * Larger than max_length.
8181
* * Presence of non-ASCII characters if asci_only is set to TRUE.
@@ -937,3 +937,55 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
937937
continue
938938
out += prob(replaceprob)? pick(replacementchars) : char
939939
return out.Join("")
940+
941+
///runs `piglatin_word()` proc on each word in a sentence. preserves caps and punctuation
942+
/proc/piglatin_sentence(text)
943+
var/text_length = length(text)
944+
945+
//remove caps since words will be shuffled
946+
text = lowertext(text)
947+
//remove punctuation for same reasons as above
948+
var/punctuation = ""
949+
var/punctuation_hit_list = list("!","?",".","-")
950+
for(var/letter_index in text_length to 1 step -1)
951+
var/letter = text[letter_index]
952+
if(!(letter in punctuation_hit_list))
953+
break
954+
punctuation += letter
955+
punctuation = reverse_text(punctuation)
956+
text = copytext(text, 1, ((text_length + 1) - length(punctuation)))
957+
958+
//now piglatin each word
959+
var/list/old_words = splittext(text, " ")
960+
var/list/new_words = list()
961+
for(var/word in old_words)
962+
new_words += piglatin_word(word)
963+
text = new_words.Join(" ")
964+
//replace caps and punc
965+
text = capitalize(text)
966+
text += punctuation
967+
return text
968+
969+
///takes "word", and returns it piglatinized.
970+
/proc/piglatin_word(word)
971+
if(length(word) == 1)
972+
return word
973+
var/first_letter = copytext(word, 1, 2)
974+
var/first_two_letters = copytext(word, 1, 3)
975+
var/first_word_is_vowel = (first_letter in list("a", "e", "i", "o", "u"))
976+
var/second_word_is_vowel = (copytext(word, 2, 3) in list("a", "e", "i", "o", "u"))
977+
//If a word starts with a vowel add the word "way" at the end of the word.
978+
if(first_word_is_vowel)
979+
return word + pick("yay", "way", "hay") //in cultures around the world it's different, so heck lets have fun and make it random. should still be readable
980+
//If a word starts with a consonant and a vowel, put the first letter of the word at the end of the word and add "ay."
981+
if(!first_word_is_vowel && second_word_is_vowel)
982+
word = copytext(word, 2)
983+
word += first_letter
984+
return word + "ay"
985+
//If a word starts with two consonants move the two consonants to the end of the word and add "ay."
986+
if(!first_word_is_vowel && !second_word_is_vowel)
987+
word = copytext(word, 3)
988+
word += first_two_letters
989+
return word + "ay"
990+
//otherwise unmutated
991+
return word

Diff for: code/datums/mutations/speech.dm

+24
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,27 @@
240240
message = "[chosen_starting] [message]"
241241

242242
speech_args[SPEECH_MESSAGE] = message
243+
244+
/datum/mutation/human/piglatin
245+
name = "Pig Latin"
246+
desc = "Historians say back in the 2020's humanity spoke entirely in this mystical language."
247+
quality = MINOR_NEGATIVE
248+
text_gain_indication = span_notice("Omethingsay eelsfay offyay.")
249+
text_lose_indication = span_notice("The off sensation passes.")
250+
251+
/datum/mutation/human/piglatin/on_acquiring(mob/living/carbon/human/owner)
252+
if(..())
253+
return
254+
RegisterSignal(owner, COMSIG_MOB_SAY, .proc/handle_speech)
255+
256+
/datum/mutation/human/piglatin/on_losing(mob/living/carbon/human/owner)
257+
if(..())
258+
return
259+
UnregisterSignal(owner, COMSIG_MOB_SAY)
260+
261+
/datum/mutation/human/piglatin/proc/handle_speech(datum/source, list/speech_args)
262+
SIGNAL_HANDLER
263+
264+
var/spoken_message = speech_args[SPEECH_MESSAGE]
265+
spoken_message = piglatin_sentence(spoken_message)
266+
speech_args[SPEECH_MESSAGE] = spoken_message

Diff for: code/game/objects/items/dna_injector.dm

+8
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@
245245
name = "\improper DNA injector (Wacky)"
246246
add_mutations = list(WACKY)
247247

248+
/obj/item/dnainjector/piglatinmut
249+
name = "\improper DNA injector (Pig Latin)"
250+
add_mutations = list(PIGLATIN)
251+
252+
/obj/item/dnainjector/antipiglatin
253+
name = "\improper DNA injector (Anti-Pig Latin)"
254+
remove_mutations = list(PIGLATIN)
255+
248256
/obj/item/dnainjector/antimute
249257
name = "\improper DNA injector (Anti-Mute)"
250258
remove_mutations = list(MUT_MUTE)

Diff for: code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ Basically, we fill the time between now and 2s from now with hands based off the
590590
var/mob/living/carbon/carbon = owner
591591
if(!carbon.dna)
592592
return
593-
var/list/speech_options = list(SWEDISH, UNINTELLIGIBLE, STONER, MEDIEVAL, WACKY, NERVOUS, MUT_MUTE)
593+
var/list/speech_options = list(SWEDISH, UNINTELLIGIBLE, STONER, MEDIEVAL, WACKY, PIGLATIN, NERVOUS, MUT_MUTE)
594594
speech_options = shuffle(speech_options)
595595
for(var/option in speech_options)
596596
if(carbon.dna.get_mutation(option))

0 commit comments

Comments
 (0)