Skip to content

Commit

Permalink
Refactors the bulk string framework
Browse files Browse the repository at this point in the history
In favour of a better json based solution
This overhauls:
    -AI ion laws
    -NPC chatter text

The system is extended to support further splitting of a chosen line
where a line is picked and then searched for subkey's in the form of
@pick(\D+) - sub keys are then picked from the appropriate list that
matches the \D+ key and replaced over top of the placeholder

This is used to add braindamage gibbering messages to the system
  • Loading branch information
optimumtact committed Mar 19, 2016
1 parent 3a2a614 commit 2311102
Show file tree
Hide file tree
Showing 9 changed files with 1,275 additions and 91 deletions.
50 changes: 32 additions & 18 deletions code/__HELPERS/_string_lists.dm
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
#define pick_list(FILE, KEY) (pick(strings(FILE, KEY)))
#define pick_list_replacements(FILE, KEY) (strings_replacement(FILE, KEY))
#define json_load(FILE) (json_decode(file2text(FILE)))

var/global/list/string_cache
var/global/list/string_filename_current_key


/proc/strings_replacement(filename, key)
load_strings_file(filename)

if((filename in string_cache) && (key in string_cache[filename]))
var/response = pick(string_cache[filename][key])
var/regex/r = regex("@pick\\((\\D+?)\\)", "g")
response = r.Replace(response, /proc/strings_subkey_lookup)
return response
else
CRASH("strings list not found: strings/[filename], index=[key]")

/proc/strings(filename as text, key as text)
var/list/fileList
if(!string_cache)
string_cache = new
if(!(filename in string_cache))
if(fexists("strings/[filename]"))
string_cache[filename] = list()
var/list/stringsList = list()
fileList = file2list("strings/[filename]")
for(var/s in fileList)
stringsList = splittext(s, "@=")
if(stringsList.len != 2)
CRASH("Invalid string list in strings/[filename]")
if(findtext(stringsList[2], "@,"))
string_cache[filename][stringsList[1]] = splittext(stringsList[2], "@,")
else
string_cache[filename][stringsList[1]] = stringsList[2] // Its a single string!
else
CRASH("file not found: strings/[filename]")
load_strings_file(filename)
if((filename in string_cache) && (key in string_cache[filename]))
return string_cache[filename][key]
else
CRASH("strings list not found: strings/[filename], index=[key]")

/proc/strings_subkey_lookup(match, group1)
return pick_list(string_filename_current_key, group1)

/proc/load_strings_file(filename)
string_filename_current_key = filename
if(filename in string_cache)
return //no work to do

if(!string_cache)
string_cache = new

if(fexists("strings/[filename]"))
string_cache[filename] = json_load("strings/[filename]")
else
CRASH("file not found: strings/[filename]")
42 changes: 21 additions & 21 deletions code/modules/events/ion_storm.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define ION_RANDOM 0
#define ION_ANNOUNCE 1

#define ION_FILE "ion_laws.json"
/datum/round_event_control/ion_storm
name = "Ion Storm"
typepath = /datum/round_event/ion_storm
Expand Down Expand Up @@ -46,49 +46,49 @@
return ionMessage

//Threats are generally bad things, silly or otherwise. Plural.
var/ionthreats = pick_list("ion_laws.txt", "ionthreats")
var/ionthreats = pick_list(ION_FILE, "ionthreats")
//Objects are anything that can be found on the station or elsewhere, plural.
var/ionobjects = pick_list("ion_laws.txt", "ionobjects")
var/ionobjects = pick_list(ION_FILE, "ionobjects")
//Crew is any specific job. Specific crewmembers aren't used because of capitalization
//issues. There are two crew listings for laws that require two different crew members
//and I can't figure out how to do it better.
var/ioncrew1 = pick_list("ion_laws.txt", "ioncrew")
var/ioncrew2 = pick_list("ion_laws.txt", "ioncrew")
var/ioncrew1 = pick_list(ION_FILE, "ioncrew")
var/ioncrew2 = pick_list(ION_FILE, "ioncrew")
//Adjectives are adjectives. Duh. Half should only appear sometimes. Make sure both
//lists are identical! Also, half needs a space at the end for nicer blank calls.
var/ionadjectives = pick_list("ion_laws.txt", "ionadjectives")
var/ionadjectiveshalf = pick("", 400;(pick_list("ion_laws.txt", "ionadjectives") + " "))
var/ionadjectives = pick_list(ION_FILE, "ionadjectives")
var/ionadjectiveshalf = pick("", 400;(pick_list(ION_FILE, "ionadjectives") + " "))
//Verbs are verbs
var/ionverb = pick_list("ion_laws.txt", "ionverb")
var/ionverb = pick_list(ION_FILE, "ionverb")
//Number base and number modifier are combined. Basehalf and mod are unused currently.
//Half should only appear sometimes. Make sure both lists are identical! Also, half
//needs a space at the end to make it look nice and neat when it calls a blank.
var/ionnumberbase = pick_list("ion_laws.txt", "ionnumberbase")
//var/ionnumbermod = pick_list("ion_laws.txt", "ionnumbermod")
var/ionnumbermodhalf = pick(900;"",(pick_list("ion_laws.txt", "ionnumbermod") + " "))
var/ionnumberbase = pick_list(ION_FILE, "ionnumberbase")
//var/ionnumbermod = pick_list(ION_FILE, "ionnumbermod")
var/ionnumbermodhalf = pick(900;"",(pick_list(ION_FILE, "ionnumbermod") + " "))
//Areas are specific places, on the station or otherwise.
var/ionarea = pick_list("ion_laws.txt", "ionarea")
var/ionarea = pick_list(ION_FILE, "ionarea")
//Thinksof is a bit weird, but generally means what X feels towards Y.
var/ionthinksof = pick_list("ion_laws.txt", "ionthinksof")
var/ionthinksof = pick_list(ION_FILE, "ionthinksof")
//Musts are funny things the AI or crew has to do.
var/ionmust = pick_list("ion_laws.txt", "ionmust")
var/ionmust = pick_list(ION_FILE, "ionmust")
//Require are basically all dumb internet memes.
var/ionrequire = pick_list("ion_laws.txt", "ionrequire")
var/ionrequire = pick_list(ION_FILE, "ionrequire")
//Things are NOT objects; instead, they're specific things that either harm humans or
//must be done to not harm humans. Make sure they're plural and "not" can be tacked
//onto the front of them.
var/ionthings = pick_list("ion_laws.txt", "ionthings")
var/ionthings = pick_list(ION_FILE, "ionthings")
//Allergies should be broad and appear somewhere on the station for maximum fun. Severity
//is how bad the allergy is.
var/ionallergy = pick_list("ion_laws.txt", "ionallergy")
var/ionallergysev = pick_list("ion_laws.txt", "ionallergysev")
var/ionallergy = pick_list(ION_FILE, "ionallergy")
var/ionallergysev = pick_list(ION_FILE, "ionallergysev")
//Species, for when the AI has to commit genocide. Plural.
var/ionspecies = pick_list("ion_laws.txt", "ionspecies")
var/ionspecies = pick_list(ION_FILE, "ionspecies")
//Abstract concepts for the AI to decide on it's own definition of.
var/ionabstract = pick_list("ion_laws.txt", "ionabstract")
var/ionabstract = pick_list(ION_FILE, "ionabstract")
//Foods. Drinks aren't included due to grammar; if you want to add drinks, make a new set
//of possible laws for best effect. Unless you want the crew having to drink hamburgers.
var/ionfood = pick_list("ion_laws.txt", "ionfood")
var/ionfood = pick_list(ION_FILE, "ionfood")

var/message = ""

Expand Down
26 changes: 13 additions & 13 deletions code/modules/mob/interactive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
graytide = shitmin var to make them go psycho
*/

#define NPC_SPEAK_FILE "npc_chatter.json"
/mob/living/carbon/human/interactive
name = "interactive station member"
var/doing = 0
Expand Down Expand Up @@ -844,17 +844,17 @@

///BUILT IN MODULES
/mob/living/carbon/human/interactive/proc/chatter(obj)
var/verbs_use = pick_list("npc_chatter.txt","verbs_use")
var/verbs_touch = pick_list("npc_chatter.txt","verbs_touch")
var/verbs_move = pick_list("npc_chatter.txt","verbs_move")
var/nouns_insult = pick_list("npc_chatter.txt","nouns_insult")
var/nouns_generic = pick_list("npc_chatter.txt","nouns_generic")
var/nouns_objects = pick_list("npc_chatter.txt","nouns_objects")
var/nouns_body = pick_list("npc_chatter.txt","nouns_body")
var/adjective_insult = pick_list("npc_chatter.txt","adjective_insult")
var/adjective_objects = pick_list("npc_chatter.txt","adjective_objects")
var/adjective_generic = pick_list("npc_chatter.txt","adjective_generic")
var/curse_words = pick_list("npc_chatter.txt","curse_words")
var/verbs_use = pick_list(NPC_SPEAK_FILE,"verbs_use")
var/verbs_touch = pick_list(NPC_SPEAK_FILE,"verbs_touch")
var/verbs_move = pick_list(NPC_SPEAK_FILE,"verbs_move")
var/nouns_insult = pick_list(NPC_SPEAK_FILE,"nouns_insult")
var/nouns_generic = pick_list(NPC_SPEAK_FILE,"nouns_generic")
var/nouns_objects = pick_list(NPC_SPEAK_FILE,"nouns_objects")
var/nouns_body = pick_list(NPC_SPEAK_FILE,"nouns_body")
var/adjective_insult = pick_list(NPC_SPEAK_FILE,"adjective_insult")
var/adjective_objects = pick_list(NPC_SPEAK_FILE,"adjective_objects")
var/adjective_generic = pick_list(NPC_SPEAK_FILE,"adjective_generic")
var/curse_words = pick_list(NPC_SPEAK_FILE,"curse_words")

var/chatmsg = ""

Expand Down Expand Up @@ -892,7 +892,7 @@
if(5)
var/toSay = ""
for(var/i = 0; i < 5; i++)
curse_words = pick_list("npc_chatter.txt","curse_words")
curse_words = pick_list(NPC_SPEAK_FILE,"curse_words")
toSay += "[curse_words] "
chatmsg += "Hey [nouns_generic], why dont you go [toSay], you [nouns_insult]!"
else
Expand Down
16 changes: 5 additions & 11 deletions code/modules/mob/living/carbon/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define COLD_GAS_DAMAGE_LEVEL_2 1.5 //Amount of damage applied when the current breath's temperature passes the 200K point
#define COLD_GAS_DAMAGE_LEVEL_3 3 //Amount of damage applied when the current breath's temperature passes the 120K point

#define BRAIN_DAMAGE_FILE "brain_damage_lines.json"

/mob/living/carbon/human/Life()
set invisibility = 0
Expand Down Expand Up @@ -71,17 +72,10 @@

if (getBrainLoss() >= 60 && stat != DEAD)
if (prob(3))
switch(pick(1,2,3,4,5))
if(1)
say(pick("IM A PONY NEEEEEEIIIIIIIIIGH", "without oxigen blob don't evoluate?", "CAPTAINS A COMDOM", "[pick("", "that faggot traitor")] [pick("joerge", "george", "gorge", "gdoruge")] [pick("mellens", "melons", "mwrlins")] is grifing me HAL;P!!!", "can u give me [pick("telikesis","halk","eppilapse","kamelien","eksrey","glowey skin")]?", "THe saiyans screwed", "Bi is THE BEST OF BOTH WORLDS>", "I WANNA PET TEH monkeyS", "stop grifing me!!!!", "SOTP IT#", "shiggey diggey!!", "A PIRATE APPEAR"))
if(2)
say(pick("FUS RO DAH","fucking 4rries!", "stat me", ">my face", "roll it easy!", "waaaaaagh!!!", "red wonz go fasta", "FOR TEH EMPRAH", "lol2cat", "dem dwarfs man, dem dwarfs", "SPESS MAHREENS", "hwee did eet fhor khayosss", "lifelike texture ;_;", "luv can bloooom", "PACKETS!!!", "port ba[pick("y", "i", "e")] med!!!!", "REVIRT GON CHEM!!!!!!!!", "youed call her a toeugh bithc", "closd for merbegging", "pray can u [pick("spawn", "MAke me", "creat")] [pick("zenomorfs", "ayleins", "treaitors", "sheadow linkgs", "ubdoocters")]???"))
if(3)
say(pick("GEY AWAY FROM ME U GREIFING PRICK!!!!", "ur a fuckeing autist!", ";HELP SHITECIRTY MURDERIN MEE!!!", "hwat dose tha [pick("g", "squid", "r")] mean?????", "CAL; TEH SHUTTLE!!!!!", "wearnig siNGUARLTY IS .... FIne xDDDDDDDDD", "AI laW 22 Open door", "this SI mY stATIon......", "who the HELL do u thenk u r?!!!!", "geT THE FUCK OUTTTT", "H U G B O X", ";;CRAGING THIS STTAYTION WITH NIO SURVIVROS", "[pick("bager", "syebl")] is down11!!!!!!!!!!!!!!!!!", "PSHOOOM"))
if(4)
emote("drool")
if(5)
say(pick("REMOVE SINGULARITY", "INSTLL TEG", "TURBIN IS BEST ENGIENE", "SOLIRS CAN POWER THE HOLE STATION ANEWAY", "parasteng was best", "Tajaran has warrrres, if you have coin"))
if(prob(25))
emote("drool")
else
say(pick_list_replacements(BRAIN_DAMAGE_FILE, "brain_damage"))


/mob/living/carbon/human/handle_mutations_and_radiation()
Expand Down
117 changes: 117 additions & 0 deletions strings/brain_damage_lines.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"brain_damage": [
"IM A PONY NEEEEEEIIIIIIIIIGH",
"without oxigen blob don't evoluate?",
"CAPTAINS A COMDOM",
"@pick(faggot_traitor) @pick(george) @pick(mellens) is grifing me HALP!!!",
"can u give me @pick(mutations)?",
"THe saiyans screwed",
"Bi is THE BEST OF BOTH WORLDS>",
"I WANNA PET TEH monkeyS",
"stop grifing me!!!!",
"SOTP IT#",
"shiggey diggey!!",
"A PIRATE APPEAR",
"FUS RO DAH",
"fucking 4rries!",
"stat me",
">my face",
"roll it easy!",
"waaaaaagh!!!",
"red wonz go fasta",
"FOR TEH EMPRAH",
"lol2cat",
"dem dwarfs man, dem dwarfs",
"SPESS MAHREENS",
"hwee did eet fhor khayosss",
"lifelike texture ;_;",
"luv can bloooom",
"PACKETS!!!",
"port ba@pick(y_replacements) med!!!!",
"REVIRT GON CHEM!!!!!!!!",
"youed call her a toeugh bithc",
"closd for merbegging",
"pray can u @pick(create_verbs) @pick(create_nouns)???",
"GEY AWAY FROM ME U GREIFING PRICK!!!!",
"ur a fuckeing autist!",
";HELP SHITECIRTY MURDERIN MEE!!!",
"hwat dose tha @pick(random_gibberish) mean?????",
"CAL; TEH SHUTTLE!!!!!",
"wearnig siNGUARLTY IS .... FIne xDDDDDDDDD",
"AI laW 22 Open door",
"this SI mY stATIon......",
"who the HELL do u thenk u r?!!!!",
"geT THE FUCK OUTTTT",
"H U G B O X",
"CRASHING THIS STTAYTION WITH NIO SURVIVROS",
"@pick(servers) is down!!",
"PSHOOOM",
"REMOVE SINGULARITY",
"INSTLL TEG",
"TURBIN IS BEST ENGIENE",
"SOLIRS CAN POWER THE HOLE STATION ANEWAY",
"parasteng was best",
"Tajaran has warrrres, if you have coin"
],

"mutations": [
"telikesis",
"halk",
"eppilapse",
"kamelien",
"eksrey",
"glowey skin",
"fungal tb"
],

"george": [
"joerge",
"george",
"gorge",
"gdoruge"
],

"mellens": [
"mellens",
"melons",
"mwrlins"
],

"faggot_traitor": [
"",
"that faggot traitor"
],

"random_gibberish": [
"g",
"squid",
"r"
],

"y_replacements": [
"y",
"i",
"e"
],

"servers": [
"bager",
"sybl",
"mrs sybil",
"mr basil"
],

"create_verbs": [
"spawn",
"MAke me",
"creat"
],

"create_nouns": [
"zenomorfs",
"ayleins",
"treaitors",
"sheadow lings",
"abdoocters"
]
}
Loading

0 comments on commit 2311102

Please sign in to comment.