diff --git a/Dockerfile b/Dockerfile index ec3694c7..5f755e3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM tgstation/byond:512.1488 as base +FROM tgstation/byond:513.1503 as base FROM base as build_base diff --git a/code/__DEFINES/typeids.dm b/code/__DEFINES/typeids.dm index 8bfe6216..275f7719 100644 --- a/code/__DEFINES/typeids.dm +++ b/code/__DEFINES/typeids.dm @@ -2,7 +2,7 @@ #define TYPEID_NULL "0" #define TYPEID_NORMAL_LIST "f" //helper macros -#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, length(ref)-6) ) ) +#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, -7) ) ) #define IS_NORMAL_LIST(L) (GET_TYPEID("\ref[L]") == TYPEID_NORMAL_LIST) diff --git a/code/__HELPERS/files.dm b/code/__HELPERS/files.dm index 4160c197..7c6c186b 100644 --- a/code/__HELPERS/files.dm +++ b/code/__HELPERS/files.dm @@ -20,7 +20,7 @@ continue path += choice - if(copytext(path,-1,0) != "/") //didn't choose a directory, no need to iterate again + if(copytext_char(path, -1) != "/") //didn't choose a directory, no need to iterate again break var/extensions for(var/i in valid_extensions) diff --git a/code/__HELPERS/icons.dm b/code/__HELPERS/icons.dm index aaa5ece4..7bfd0ff1 100644 --- a/code/__HELPERS/icons.dm +++ b/code/__HELPERS/icons.dm @@ -977,7 +977,7 @@ world var/icon/atom_icon = new(A.icon, A.icon_state) if(!letter) - letter = copytext(A.name, 1, 2) + letter = A.name[1] if(uppercase == 1) letter = uppertext(letter) else if(uppercase == -1) @@ -1105,7 +1105,7 @@ GLOBAL_LIST_INIT(freon_color_matrix, list("#2E5E69", "#60A2A8", "#A1AFB1", rgb(0 WRITE_FILE(GLOB.iconCache[iconKey], icon) var/iconData = GLOB.iconCache.ExportText(iconKey) var/list/partial = splittext(iconData, "{") - return replacetext(copytext(partial[2], 3, -5), "\n", "") + return replacetext(copytext_char(partial[2], 3, -5), "\n", "") /proc/icon2html(thing, target, icon_state, dir, frame = 1, moving = FALSE) if (!thing) diff --git a/code/__HELPERS/pronouns.dm b/code/__HELPERS/pronouns.dm index d1add9cb..bab286ba 100644 --- a/code/__HELPERS/pronouns.dm +++ b/code/__HELPERS/pronouns.dm @@ -28,10 +28,10 @@ . = "does" /datum/proc/p_theyve(capitalized, temp_gender) - . = p_they(capitalized, temp_gender) + "'" + copytext(p_have(temp_gender), 3) + . = p_they(capitalized, temp_gender) + "'" + copytext_char(p_have(temp_gender), 3) /datum/proc/p_theyre(capitalized, temp_gender) - . = p_they(capitalized, temp_gender) + "'" + copytext(p_are(temp_gender), 2) + . = p_they(capitalized, temp_gender) + "'" + copytext_char(p_are(temp_gender), 2) /datum/proc/p_s(temp_gender) //is this a descriptive proc name, or what? . = "s" diff --git a/code/__HELPERS/sanitize_values.dm b/code/__HELPERS/sanitize_values.dm index b511c619..601ed966 100644 --- a/code/__HELPERS/sanitize_values.dm +++ b/code/__HELPERS/sanitize_values.dm @@ -43,24 +43,24 @@ if(!istext(color)) color = "" - var/start = 1 + (text2ascii(color,1)==35) + var/start = 1 + (text2ascii(color, 1) == 35) var/len = length(color) - var/step_size = 1 + ((len+1)-start != desired_format) + var/char = "" . = "" - for(var/i=start, i<=len, i+=step_size) - var/ascii = text2ascii(color,i) - switch(ascii) - if(48 to 57) - . += ascii2text(ascii) //numbers 0 to 9 - if(97 to 102) - . += ascii2text(ascii) //letters a to f - if(65 to 70) - . += ascii2text(ascii+32) //letters A to F - translates to lowercase + for(var/i = start, i <= len, i += length(char)) + char = color[i] + switch(text2ascii(char)) + if(48 to 57) //numbers 0 to 9 + . += char + if(97 to 102) //letters a to f + . += char + if(65 to 70) //letters A to F - translates to lowercase + . += lowertext(char) else break - if(length(.) != desired_format) + if(length_char(.) != desired_format) if(default) return default return crunch + repeat_string(desired_format, "0") @@ -68,7 +68,9 @@ return crunch + . /proc/sanitize_ooccolor(color) - var/list/HSL = rgb2hsl(hex2num(copytext(color,2,4)),hex2num(copytext(color,4,6)),hex2num(copytext(color,6,8))) + if(length(color) != length_char(color)) + CRASH("Invalid characters in color '[color]'") + var/list/HSL = rgb2hsl(hex2num(copytext(color, 2, 4)), hex2num(copytext(color, 4, 6)), hex2num(copytext(color, 6, 8))) HSL[3] = min(HSL[3],0.4) var/list/RGB = hsl2rgb(arglist(HSL)) return "#[num2hex(RGB[1],2)][num2hex(RGB[2],2)][num2hex(RGB[3],2)]" \ No newline at end of file diff --git a/code/__HELPERS/shell.dm b/code/__HELPERS/shell.dm index 8b615eac..3438f38b 100644 --- a/code/__HELPERS/shell.dm +++ b/code/__HELPERS/shell.dm @@ -52,6 +52,6 @@ if(bad_chars) bad_match = url_encode(bad_chars_regex.match) scrubbed_url += bad_match - last_good = bad_chars + length(bad_match) + last_good = bad_chars + length(bad_chars_regex.match) while(bad_chars) . = scrubbed_url diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index cd0d8678..3985659b 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -1,797 +1,778 @@ -/* - * Holds procs designed to help with filtering text - * Contains groups: - * SQL sanitization/formating - * Text sanitization - * Text searches - * Text modification - * Misc - */ - - -/* - * SQL sanitization - */ - -// Run all strings to be used in an SQL query through this proc first to properly escape out injection attempts. -/proc/sanitizeSQL(t) - return SSdbcore.Quote("[t]") - -/proc/format_table_name(table as text) - return CONFIG_GET(string/feedback_tableprefix) + table - -/* - * Text sanitization - */ - -//Simply removes < and > and limits the length of the message -/proc/strip_html_simple(t,limit=MAX_MESSAGE_LEN) - var/list/strip_chars = list("<",">") - t = copytext(t,1,limit) - for(var/char in strip_chars) - var/index = findtext(t, char) - while(index) - t = copytext(t, 1, index) + copytext(t, index+1) - index = findtext(t, char) - return t - -//Removes a few problematic characters -/proc/sanitize_simple(t,list/repl_chars = list("\n"="#","\t"="#")) - for(var/char in repl_chars) - var/index = findtext(t, char) - while(index) - t = copytext(t, 1, index) + repl_chars[char] + copytext(t, index+1) - index = findtext(t, char, index+1) - return t - -/proc/sanitize_filename(t) - return sanitize_simple(t, list("\n"="", "\t"="", "/"="", "\\"="", "?"="", "%"="", "*"="", ":"="", "|"="", "\""="", "<"="", ">"="")) - -//Runs byond's sanitization proc along-side sanitize_simple -/proc/sanitize(t,list/repl_chars = null) - return html_encode(sanitize_simple(t,repl_chars)) - -//Runs sanitize and strip_html_simple -//I believe strip_html_simple() is required to run first to prevent '<' from displaying as '<' after sanitize() calls byond's html_encode() -/proc/strip_html(t,limit=MAX_MESSAGE_LEN) - return copytext((sanitize(strip_html_simple(t))),1,limit) - -//Runs byond's sanitization proc along-side strip_html_simple -//I believe strip_html_simple() is required to run first to prevent '<' from displaying as '<' that html_encode() would cause -/proc/adminscrub(t,limit=MAX_MESSAGE_LEN) - return copytext((html_encode(strip_html_simple(t))),1,limit) - - -//Returns null if there is any bad text in the string -/proc/reject_bad_text(text, max_length=512) - if(length(text) > max_length) - return //message too long - var/non_whitespace = 0 - for(var/i=1, i<=length(text), i++) - switch(text2ascii(text,i)) - if(62,60,92,47) - return //rejects the text if it contains these bad characters: <, >, \ or / - if(127 to 255) - return //rejects weird letters like � - if(0 to 31) - return //more weird stuff - if(32) - continue //whitespace - else - non_whitespace = 1 - if(non_whitespace) - return text //only accepts the text if it has some non-spaces - -// Used to get a properly sanitized input, of max_length -// no_trim is self explanatory but it prevents the input from being trimed if you intend to parse newlines or whitespace. -/proc/stripped_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE) - var/name = input(user, message, title, default) as text|null - if(no_trim) - return copytext(html_encode(name), 1, max_length) - else - return trim(html_encode(name), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into <) - -// Used to get a properly sanitized multiline input, of max_length -/proc/stripped_multiline_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE) - var/name = input(user, message, title, default) as message|null - if(isnull(name)) // Return null if canceled. - return null - if(no_trim) - return copytext(html_encode(name), 1, max_length) - else - return trim(html_encode(name), max_length) - - -//Filters out undesirable characters from names -/proc/reject_bad_name(t_in, allow_numbers=1, max_length=MAX_NAME_LEN) - if(!t_in || length(t_in) > max_length) - return //Rejects the input if it is null or if it is longer then the max length allowed - - var/number_of_alphanumeric = 0 - var/last_char_group = 0 - var/t_out = "" - - for(var/i=1, i<=length(t_in), i++) - var/ascii_char = text2ascii(t_in,i) - switch(ascii_char) - // A .. Z - if(65 to 90) //Uppercase Letters - t_out += ascii2text(ascii_char) - number_of_alphanumeric++ - last_char_group = 4 - - // a .. z - if(97 to 122) //Lowercase Letters - if(last_char_group<2) - t_out += ascii2text(ascii_char-32) //Force uppercase first character - else - t_out += ascii2text(ascii_char) - number_of_alphanumeric++ - last_char_group = 4 - - // 0 .. 9 - if(48 to 57) //Numbers - if(!last_char_group) - continue //suppress at start of string - if(!allow_numbers) - continue - t_out += ascii2text(ascii_char) - number_of_alphanumeric++ - last_char_group = 3 - - // ' - . - if(39,45,46) //Common name punctuation - if(!last_char_group) - continue - t_out += ascii2text(ascii_char) - last_char_group = 2 - - // ~ | @ : # $ % & * + - if(126,124,64,58,35,36,37,38,42,43) //Other symbols that we'll allow (mainly for AI) - if(!last_char_group) - continue //suppress at start of string - if(!allow_numbers) - continue - t_out += ascii2text(ascii_char) - last_char_group = 2 - - //Space - if(32) - if(last_char_group <= 1) - continue //suppress double-spaces and spaces at start of string - t_out += ascii2text(ascii_char) - last_char_group = 1 - else - return - - if(number_of_alphanumeric < 2) - return //protects against tiny names like "A" and also names like "' ' ' ' ' ' ' '" - - if(last_char_group == 1) - t_out = copytext(t_out,1,length(t_out)) //removes the last character (in this case a space) - - for(var/bad_name in list("space","floor","wall","r-wall","monkey","unknown","inactive ai")) //prevents these common metagamey names - if(cmptext(t_out,bad_name)) - return //(not case sensitive) - - return t_out - -//html_encode helper proc that returns the smallest non null of two numbers -//or 0 if they're both null (needed because of findtext returning 0 when a value is not present) -/proc/non_zero_min(a, b) - if(!a) - return b - if(!b) - return a - return (a < b ? a : b) - -/* - * Text searches - */ - -//Checks the beginning of a string for a specified sub-string -//Returns the position of the substring or 0 if it was not found -/proc/dd_hasprefix(text, prefix) - var/start = 1 - var/end = length(prefix) + 1 - return findtext(text, prefix, start, end) - -//Checks the beginning of a string for a specified sub-string. This proc is case sensitive -//Returns the position of the substring or 0 if it was not found -/proc/dd_hasprefix_case(text, prefix) - var/start = 1 - var/end = length(prefix) + 1 - return findtextEx(text, prefix, start, end) - -//Checks the end of a string for a specified substring. -//Returns the position of the substring or 0 if it was not found -/proc/dd_hassuffix(text, suffix) - var/start = length(text) - length(suffix) - if(start) - return findtext(text, suffix, start, null) - return - -//Checks the end of a string for a specified substring. This proc is case sensitive -//Returns the position of the substring or 0 if it was not found -/proc/dd_hassuffix_case(text, suffix) - var/start = length(text) - length(suffix) - if(start) - return findtextEx(text, suffix, start, null) - -//Checks if any of a given list of needles is in the haystack -/proc/text_in_list(haystack, list/needle_list, start=1, end=0) - for(var/needle in needle_list) - if(findtext(haystack, needle, start, end)) - return 1 - return 0 - -//Like above, but case sensitive -/proc/text_in_list_case(haystack, list/needle_list, start=1, end=0) - for(var/needle in needle_list) - if(findtextEx(haystack, needle, start, end)) - return 1 - return 0 - -//Adds 'u' number of zeros ahead of the text 't' -/proc/add_zero(t, u) - while (length(t) < u) - t = "0[t]" - return t - -//Adds 'u' number of spaces ahead of the text 't' -/proc/add_lspace(t, u) - while(length(t) < u) - t = " [t]" - return t - -//Adds 'u' number of spaces behind the text 't' -/proc/add_tspace(t, u) - while(length(t) < u) - t = "[t] " - return t - -//Returns a string with reserved characters and spaces before the first letter removed -/proc/trim_left(text) - for (var/i = 1 to length(text)) - if (text2ascii(text, i) > 32) - return copytext(text, i) - return "" - -//Returns a string with reserved characters and spaces after the last letter removed -/proc/trim_right(text) - for (var/i = length(text), i > 0, i--) - if (text2ascii(text, i) > 32) - return copytext(text, 1, i + 1) - - return "" - -//Returns a string with reserved characters and spaces before the first word and after the last word removed. -/proc/trim(text, max_length) - if(max_length) - text = copytext(text, 1, max_length) - return trim_left(trim_right(text)) - -//Returns a string with the first element of the string capitalized. -/proc/capitalize(t as text) - return uppertext(copytext(t, 1, 2)) + copytext(t, 2) - -//Centers text by adding spaces to either side of the string. -/proc/dd_centertext(message, length) - var/new_message = message - var/size = length(message) - var/delta = length - size - if(size == length) - return new_message - if(size > length) - return copytext(new_message, 1, length + 1) - if(delta == 1) - return new_message + " " - if(delta % 2) - new_message = " " + new_message - delta-- - var/spaces = add_lspace("",delta/2-1) - return spaces + new_message + spaces - -//Limits the length of the text. Note: MAX_MESSAGE_LEN and MAX_NAME_LEN are widely used for this purpose -/proc/dd_limittext(message, length) - var/size = length(message) - if(size <= length) - return message - return copytext(message, 1, length + 1) - - -/proc/stringmerge(text,compare,replace = "*") -//This proc fills in all spaces with the "replace" var (* by default) with whatever -//is in the other string at the same spot (assuming it is not a replace char). -//This is used for fingerprints - var/newtext = text - if(length(text) != length(compare)) - return 0 - for(var/i = 1, i < length(text), i++) - var/a = copytext(text,i,i+1) - var/b = copytext(compare,i,i+1) -//if it isn't both the same letter, or if they are both the replacement character -//(no way to know what it was supposed to be) - if(a != b) - if(a == replace) //if A is the replacement char - newtext = copytext(newtext,1,i) + b + copytext(newtext, i+1) - else if(b == replace) //if B is the replacement char - newtext = copytext(newtext,1,i) + a + copytext(newtext, i+1) - else //The lists disagree, Uh-oh! - return 0 - return newtext - -/proc/stringpercent(text,character = "*") -//This proc returns the number of chars of the string that is the character -//This is used for detective work to determine fingerprint completion. - if(!text || !character) - return 0 - var/count = 0 - for(var/i = 1, i <= length(text), i++) - var/a = copytext(text,i,i+1) - if(a == character) - count++ - return count - -/proc/reverse_text(text = "") - var/new_text = "" - for(var/i = length(text); i > 0; i--) - new_text += copytext(text, i, i+1) - return new_text - -GLOBAL_LIST_INIT(zero_character_only, list("0")) -GLOBAL_LIST_INIT(hex_characters, list("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f")) -GLOBAL_LIST_INIT(alphabet, list("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")) -GLOBAL_LIST_INIT(binary, list("0","1")) -/proc/random_string(length, list/characters) - . = "" - for(var/i=1, i<=length, i++) - . += pick(characters) - -/proc/repeat_string(times, string="") - . = "" - for(var/i=1, i<=times, i++) - . += string - -/proc/random_short_color() - return random_string(3, GLOB.hex_characters) - -/proc/random_color() - return random_string(6, GLOB.hex_characters) - -/proc/add_zero2(t, u) - var/temp1 - while (length(t) < u) - t = "0[t]" - temp1 = t - if (length(t) > u) - temp1 = copytext(t,2,u+1) - return temp1 - -//merges non-null characters (3rd argument) from "from" into "into". Returns result -//e.g. into = "Hello World" -// from = "Seeya______" -// returns"Seeya World" -//The returned text is always the same length as into -//This was coded to handle DNA gene-splicing. -/proc/merge_text(into, from, null_char="_") - . = "" - if(!istext(into)) - into = "" - if(!istext(from)) - from = "" - var/null_ascii = istext(null_char) ? text2ascii(null_char,1) : null_char - - var/previous = 0 - var/start = 1 - var/end = length(into) + 1 - - for(var/i=1, i") - t = replacetext(t, "))", "") - t = replacetext(t, regex("(-){3,}", "gm"), "
") - t = replacetext(t, regex("^\\((-){3,}\\)$", "gm"), "$1") - - // Parse lists - - var/list/tlist = splittext(t, "\n") - var/tlistlen = tlist.len - var/listlevel = -1 - var/singlespace = -1 // if 0, double spaces are used before asterisks, if 1, single are - for(var/i = 1, i <= tlistlen, i++) - var/line = tlist[i] - var/count_asterisk = length(replacetext(line, regex("\[^\\*\]+", "g"), "")) - if(count_asterisk % 2 == 1 && findtext(line, regex("^\\s*\\*", "g"))) // there is an extra asterisk in the beggining - - var/count_w = length(replacetext(line, regex("^( *)\\*.*$", "g"), "$1")) // whitespace before asterisk - line = replacetext(line, regex("^ *(\\*.*)$", "g"), "$1") - - if(singlespace == -1 && count_w == 2) - if(listlevel == 0) - singlespace = 0 - else - singlespace = 1 - - if(singlespace == 0) - count_w = count_w % 2 ? round(count_w / 2 + 0.25) : count_w / 2 - - line = replacetext(line, regex("\\*", ""), "
  • ") - while(listlevel < count_w) - line = "" + line - listlevel-- - - else while(listlevel >= 0) - line = "" + line - listlevel-- - - tlist[i] = line - // end for - - t = tlist[1] - for(var/i = 2, i <= tlistlen, i++) - t += "\n" + tlist[i] - - while(listlevel >= 0) - t += "" - listlevel-- - - else - t = replacetext(t, "((", "") - t = replacetext(t, "))", "") - - // Parse headers - - t = replacetext(t, regex("^#(?!#) ?(.+)$", "gm"), "

    $1

    ") - t = replacetext(t, regex("^##(?!#) ?(.+)$", "gm"), "

    $1

    ") - t = replacetext(t, regex("^###(?!#) ?(.+)$", "gm"), "

    $1

    ") - t = replacetext(t, regex("^#### ?(.+)$", "gm"), "
    $1
    ") - - // Parse most rules - - t = replacetext(t, regex("\\*(\[^\\*\]*)\\*", "g"), "$1") - t = replacetext(t, regex("_(\[^_\]*)_", "g"), "$1") - t = replacetext(t, "", "!") - t = replacetext(t, "", "!") - t = replacetext(t, regex("\\!(\[^\\!\]+)\\!", "g"), "$1") - t = replacetext(t, regex("\\^(\[^\\^\]+)\\^", "g"), "$1") - t = replacetext(t, regex("\\|(\[^\\|\]+)\\|", "g"), "
    $1
    ") - t = replacetext(t, "!", "
    ") - - return t - -/proc/parsemarkdown_basic_step2(t) - if(length(t) <= 0) - return - - // Restore the single characters used - - t = replacetext(t, "$a", "!") - - // Redo the escaping - - t = replacetext(t, "$1", "\\") - t = replacetext(t, "$2", "**") - t = replacetext(t, "$3", "*") - t = replacetext(t, "$4", "__") - t = replacetext(t, "$5", "_") - t = replacetext(t, "$6", "^") - t = replacetext(t, "$7", "((") - t = replacetext(t, "$8", "))") - t = replacetext(t, "$9", "|") - t = replacetext(t, "$0", "%") - t = replacetext(t, "$-", "$") - - return t - -/proc/parsemarkdown_basic(t, limited=FALSE) - t = parsemarkdown_basic_step1(t, limited) - t = parsemarkdown_basic_step2(t) - return t - -/proc/parsemarkdown(t, mob/user=null, limited=FALSE) - if(length(t) <= 0) - return - - // Premanage whitespace - - t = replacetext(t, regex("\[^\\S\\r\\n \]", "g"), " ") - - t = parsemarkdown_basic_step1(t) - - t = replacetext(t, regex("%s(?:ign)?(?=\\s|$)", "igm"), user ? "[user.real_name]" : "") - t = replacetext(t, regex("%f(?:ield)?(?=\\s|$)", "igm"), "") - - t = parsemarkdown_basic_step2(t) - - // Manage whitespace - - t = replacetext(t, regex("(?:\\r\\n?|\\n)", "g"), "
    ") - - t = replacetext(t, " ", "  ") - - // Done - - return t - -#define string2charlist(string) (splittext(string, regex("(.)")) - splittext(string, "")) - -/proc/rot13(text = "") - var/list/textlist = string2charlist(text) - var/list/result = list() - for(var/c in textlist) - var/ca = text2ascii(c) - if(ca >= text2ascii("a") && ca <= text2ascii("m")) - ca += 13 - else if(ca >= text2ascii("n") && ca <= text2ascii("z")) - ca -= 13 - else if(ca >= text2ascii("A") && ca <= text2ascii("M")) - ca += 13 - else if(ca >= text2ascii("N") && ca <= text2ascii("Z")) - ca -= 13 - result += ascii2text(ca) - return jointext(result, "") - -//Takes a list of values, sanitizes it down for readability and character count, -//then exports it as a json file at data/npc_saves/[filename].json. -//As far as SS13 is concerned this is write only data. You can't change something -//in the json file and have it be reflected in the in game item/mob it came from. -//(That's what things like savefiles are for) Note that this list is not shuffled. -/proc/twitterize(list/proposed, filename, cullshort = 1, storemax = 1000) - if(!islist(proposed) || !filename || !CONFIG_GET(flag/log_twitter)) - return - - //Regular expressions are, as usual, absolute magic - var/regex/all_invalid_symbols = new("\[^ -~]+") - - var/list/accepted = list() - for(var/string in proposed) - if(findtext(string,GLOB.is_website) || findtext(string,GLOB.is_email) || findtext(string,all_invalid_symbols) || !findtext(string,GLOB.is_alphanumeric)) - continue - var/buffer = "" - var/early_culling = TRUE - for(var/pos = 1, pos <= length(string), pos++) - var/let = copytext(string, pos, (pos + 1) % length(string)) - if(early_culling && !findtext(let,GLOB.is_alphanumeric)) - continue - early_culling = FALSE - buffer += let - if(!findtext(buffer,GLOB.is_alphanumeric)) - continue - var/punctbuffer = "" - var/cutoff = length(buffer) - for(var/pos = length(buffer), pos >= 0, pos--) - var/let = copytext(buffer, pos, (pos + 1) % length(buffer)) - if(findtext(let,GLOB.is_alphanumeric)) - break - if(findtext(let,GLOB.is_punctuation)) - punctbuffer = let + punctbuffer //Note this isn't the same thing as using += - cutoff = pos - if(punctbuffer) //We clip down excessive punctuation to get the letter count lower and reduce repeats. It's not perfect but it helps. - var/exclaim = FALSE - var/question = FALSE - var/periods = 0 - for(var/pos = length(punctbuffer), pos >= 0, pos--) - var/punct = copytext(punctbuffer, pos, (pos + 1) % length(punctbuffer)) - if(!exclaim && findtext(punct,"!")) - exclaim = TRUE - if(!question && findtext(punct,"?")) - question = TRUE - if(!exclaim && !question && findtext(punct,".")) - periods += 1 - if(exclaim) - if(question) - punctbuffer = "?!" - else - punctbuffer = "!" - else if(question) - punctbuffer = "?" - else if(periods) - if(periods > 1) - punctbuffer = "..." - else - punctbuffer = "" //Grammer nazis be damned - buffer = copytext(buffer, 1, cutoff) + punctbuffer - if(!findtext(buffer,GLOB.is_alphanumeric)) - continue - if(!buffer || length(buffer) > 280 || length(buffer) <= cullshort || buffer in accepted) - continue - - accepted += buffer - - var/log = file("data/npc_saves/[filename].json") //If this line ever shows up as changed in a PR be very careful you aren't being memed on - var/list/oldjson = list() - var/list/oldentries = list() - if(fexists(log)) - oldjson = json_decode(file2text(log)) - oldentries = oldjson["data"] - if(!isemptylist(oldentries)) - for(var/string in accepted) - for(var/old in oldentries) - if(string == old) - oldentries.Remove(old) //Line's position in line is "refreshed" until it falls off the in game radar - break - - var/list/finalized = list() - finalized = accepted.Copy() + oldentries.Copy() //we keep old and unreferenced phrases near the bottom for culling - listclearnulls(finalized) - if(!isemptylist(finalized) && length(finalized) > storemax) - finalized.Cut(storemax + 1) - fdel(log) - - var/list/tosend = list() - tosend["data"] = finalized - WRITE_FILE(log, json_encode(tosend)) - -//Used for applying byonds text macros to strings that are loaded at runtime -/proc/apply_text_macros(string) - var/next_backslash = findtext(string, "\\") - if(!next_backslash) - return string - - var/leng = length(string) - - var/next_space = findtext(string, " ", next_backslash + 1) - if(!next_space) - next_space = leng - next_backslash - - if(!next_space) //trailing bs - return string - - var/base = next_backslash == 1 ? "" : copytext(string, 1, next_backslash) - var/macro = lowertext(copytext(string, next_backslash + 1, next_space)) - var/rest = next_backslash > leng ? "" : copytext(string, next_space + 1) - - //See https://secure.byond.com/docs/ref/info.html#/DM/text/macros - switch(macro) - //prefixes/agnostic - if("the") - rest = text("\the []", rest) - if("a") - rest = text("\a []", rest) - if("an") - rest = text("\an []", rest) - if("proper") - rest = text("\proper []", rest) - if("improper") - rest = text("\improper []", rest) - if("roman") - rest = text("\roman []", rest) - //postfixes - if("th") - base = text("[]\th", rest) - if("s") - base = text("[]\s", rest) - if("he") - base = text("[]\he", rest) - if("she") - base = text("[]\she", rest) - if("his") - base = text("[]\his", rest) - if("himself") - base = text("[]\himself", rest) - if("herself") - base = text("[]\herself", rest) - if("hers") - base = text("[]\hers", rest) - - . = base - if(rest) - . += .(rest) - -//Replacement for the \th macro when you want the whole word output as text (first instead of 1st) -/proc/thtotext(number) - if(!isnum(number)) - return - switch(number) - if(1) - return "first" - if(2) - return "second" - if(3) - return "third" - if(4) - return "fourth" - if(5) - return "fifth" - if(6) - return "sixth" - if(7) - return "seventh" - if(8) - return "eighth" - if(9) - return "ninth" - if(10) - return "tenth" - if(11) - return "eleventh" - if(12) - return "twelfth" - else - return "[number]\th" - -/proc/unintelligize(message) - var/prefix=copytext(message,1,2) - if(prefix == ";") - message = copytext(message,2) - else if(prefix in list(":","#")) - prefix += copytext(message,2,3) - message = copytext(message,3) - else - prefix="" - - var/list/words = splittext(message," ") - var/list/rearranged = list() - for(var/i=1;i<=words.len;i++) - var/cword = pick(words) - words.Remove(cword) - var/suffix = copytext(cword,length(cword)-1,length(cword)) - while(length(cword)>0 && suffix in list(".",",",";","!",":","?")) - cword = copytext(cword,1 ,length(cword)-1) - suffix = copytext(cword,length(cword)-1,length(cword) ) - if(length(cword)) - rearranged += cword - message = "[prefix][jointext(rearranged," ")]" - . = message - -#define is_alpha(X) ((text2ascii(X) <= 122) && (text2ascii(X) >= 97)) +/* + * Holds procs designed to help with filtering text + * Contains groups: + * SQL sanitization/formating + * Text sanitization + * Text searches + * Text modification + * Misc + */ + + +/* + * SQL sanitization + */ + +// Run all strings to be used in an SQL query through this proc first to properly escape out injection attempts. +/proc/sanitizeSQL(t) + return SSdbcore.Quote("[t]") + +/proc/format_table_name(table as text) + return CONFIG_GET(string/feedback_tableprefix) + table + +/* + * Text sanitization + */ + +//Simply removes < and > and limits the length of the message +/proc/strip_html_simple(t,limit=MAX_MESSAGE_LEN) + var/list/strip_chars = list("<",">") + t = copytext(t,1,limit) + for(var/char in strip_chars) + var/index = findtext(t, char) + while(index) + t = copytext(t, 1, index) + copytext(t, index+1) + index = findtext(t, char) + return t + +//Removes a few problematic characters +/proc/sanitize_simple(t,list/repl_chars = list("\n"="#","\t"="#")) + for(var/char in repl_chars) + var/index = findtext(t, char) + while(index) + t = copytext(t, 1, index) + repl_chars[char] + copytext(t, index + length(char)) + index = findtext(t, char, index + length(char)) + return t + +/proc/sanitize_filename(t) + return sanitize_simple(t, list("\n"="", "\t"="", "/"="", "\\"="", "?"="", "%"="", "*"="", ":"="", "|"="", "\""="", "<"="", ">"="")) + +//Runs byond's sanitization proc along-side sanitize_simple +/proc/sanitize(t,list/repl_chars = null) + return html_encode(sanitize_simple(t,repl_chars)) + +//Runs sanitize and strip_html_simple +//I believe strip_html_simple() is required to run first to prevent '<' from displaying as '<' after sanitize() calls byond's html_encode() +/proc/strip_html(t,limit=MAX_MESSAGE_LEN) + return copytext((sanitize(strip_html_simple(t))),1,limit) + +//Runs byond's sanitization proc along-side strip_html_simple +//I believe strip_html_simple() is required to run first to prevent '<' from displaying as '<' that html_encode() would cause +/proc/adminscrub(t,limit=MAX_MESSAGE_LEN) + return copytext((html_encode(strip_html_simple(t))),1,limit) + + +//Returns null if there is any bad text in the string +/proc/reject_bad_text(text, max_length = 512, ascii_only = TRUE) + var/char_count = 0 + var/non_whitespace = FALSE + var/lenbytes = length(text) + var/char = "" + for(var/i = 1, i <= lenbytes, i += length(char)) + char = text[i] + char_count++ + if(char_count > max_length) + return + switch(text2ascii(char)) + if(62,60,92,47) // <, >, \, / + return + if(0 to 31) + return + if(32) + continue //whitespace + if(127 to INFINITY) + if(ascii_only) + return + else + non_whitespace = TRUE + if(non_whitespace) + return text //only accepts the text if it has some non-spaces + +// Used to get a properly sanitized input, of max_length +// no_trim is self explanatory but it prevents the input from being trimed if you intend to parse newlines or whitespace. +/proc/stripped_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE) + var/name = input(user, message, title, default) as text|null + if(no_trim) + return copytext(html_encode(name), 1, max_length) + else + return trim(html_encode(name), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into <) + +// Used to get a properly sanitized multiline input, of max_length +/proc/stripped_multiline_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE) + var/name = input(user, message, title, default) as message|null + if(isnull(name)) // Return null if canceled. + return null + if(no_trim) + return copytext(html_encode(name), 1, max_length) + else + return trim(html_encode(name), max_length) + +#define NO_CHARS_DETECTED 0 +#define SPACES_DETECTED 1 +#define SYMBOLS_DETECTED 2 +#define NUMBERS_DETECTED 3 +#define LETTERS_DETECTED 4 + +//Filters out undesirable characters from names +/proc/reject_bad_name(t_in, allow_numbers = FALSE, max_length = MAX_NAME_LEN, ascii_only = TRUE) + if(!t_in) + return //Rejects the input if it is null + + var/number_of_alphanumeric = 0 + var/last_char_group = NO_CHARS_DETECTED + var/t_out = "" + var/t_len = length(t_in) + var/charcount = 0 + var/char = "" + + + for(var/i = 1, i <= t_len, i += length(char)) + char = t_in[i] + + switch(text2ascii(char)) + // A .. Z + if(65 to 90) //Uppercase Letters + number_of_alphanumeric++ + last_char_group = LETTERS_DETECTED + + // a .. z + if(97 to 122) //Lowercase Letters + if(last_char_group == NO_CHARS_DETECTED || last_char_group == SPACES_DETECTED || last_char_group == SYMBOLS_DETECTED) //start of a word + char = uppertext(char) + number_of_alphanumeric++ + last_char_group = LETTERS_DETECTED + + // 0 .. 9 + if(48 to 57) //Numbers + if(last_char_group == NO_CHARS_DETECTED || !allow_numbers) //suppress at start of string + continue + number_of_alphanumeric++ + last_char_group = NUMBERS_DETECTED + + // ' - . + if(39,45,46) //Common name punctuation + if(last_char_group == NO_CHARS_DETECTED) + continue + last_char_group = SYMBOLS_DETECTED + + // ~ | @ : # $ % & * + + if(126,124,64,58,35,36,37,38,42,43) //Other symbols that we'll allow (mainly for AI) + if(last_char_group == NO_CHARS_DETECTED || !allow_numbers) //suppress at start of string + continue + last_char_group = SYMBOLS_DETECTED + + //Space + if(32) + if(last_char_group == NO_CHARS_DETECTED || last_char_group == SPACES_DETECTED) //suppress double-spaces and spaces at start of string + continue + last_char_group = SPACES_DETECTED + + if(127 to INFINITY) + if(ascii_only) + continue + last_char_group = SYMBOLS_DETECTED //for now, we'll treat all non-ascii characters like symbols even though most are letters + + else + continue + + t_out += char + charcount++ + if(charcount >= max_length) + break + + if(number_of_alphanumeric < 2) + return //protects against tiny names like "A" and also names like "' ' ' ' ' ' ' '" + + if(last_char_group == SPACES_DETECTED) + t_out = copytext_char(t_out, 1, -1) //removes the last character (in this case a space) + + for(var/bad_name in list("space","floor","wall","r-wall","monkey","unknown","inactive ai")) //prevents these common metagamey names + if(cmptext(t_out,bad_name)) + return //(not case sensitive) + + return t_out + +#undef NO_CHARS_DETECTED +#undef SPACES_DETECTED +#undef NUMBERS_DETECTED +#undef LETTERS_DETECTED + +//html_encode helper proc that returns the smallest non null of two numbers +//or 0 if they're both null (needed because of findtext returning 0 when a value is not present) +/proc/non_zero_min(a, b) + if(!a) + return b + if(!b) + return a + return (a < b ? a : b) + +//Checks if any of a given list of needles is in the haystack +/proc/text_in_list(haystack, list/needle_list, start=1, end=0) + for(var/needle in needle_list) + if(findtext(haystack, needle, start, end)) + return 1 + return 0 + +//Like above, but case sensitive +/proc/text_in_list_case(haystack, list/needle_list, start=1, end=0) + for(var/needle in needle_list) + if(findtextEx(haystack, needle, start, end)) + return 1 + return 0 + +//Adds 'char' ahead of 'text' until there are 'count' characters total +/proc/add_leading(text, count, char = " ") + text = "[text]" + var/charcount = count - length_char(text) + var/list/chars_to_add[max(charcount + 1, 0)] + return jointext(chars_to_add, char) + text + +//Adds 'char' behind 'text' until there are 'count' characters total +/proc/add_trailing(text, count, char = " ") + text = "[text]" + var/charcount = count - length_char(text) + var/list/chars_to_add[max(charcount + 1, 0)] + return text + jointext(chars_to_add, char) + +//Returns a string with reserved characters and spaces before the first letter removed +/proc/trim_left(text) + for (var/i = 1 to length(text)) + if (text2ascii(text, i) > 32) + return copytext(text, i) + return "" + +//Returns a string with reserved characters and spaces after the last letter removed +/proc/trim_right(text) + for (var/i = length(text), i > 0, i--) + if (text2ascii(text, i) > 32) + return copytext(text, 1, i + 1) + + return "" + +//Returns a string with reserved characters and spaces before the first word and after the last word removed. +/proc/trim(text, max_length) + if(max_length) + text = copytext_char(text, 1, max_length) + return trim_left(trim_right(text)) + +//Returns a string with the first element of the string capitalized. +/proc/capitalize(t as text) + . = t + if(t) + . = t[1] + return uppertext(.) + copytext(t, 1 + length(.)) + +/proc/stringmerge(text,compare,replace = "*") +//This proc fills in all spaces with the "replace" var (* by default) with whatever +//is in the other string at the same spot (assuming it is not a replace char). +//This is used for fingerprints + var/newtext = text + var/text_it = 1 //iterators + var/comp_it = 1 + var/newtext_it = 1 + var/text_length = length(text) + var/comp_length = length(compare) + while(comp_it <= comp_length && text_it <= text_length) + var/a = text[text_it] + var/b = compare[comp_it] +//if it isn't both the same letter, or if they are both the replacement character +//(no way to know what it was supposed to be) + if(a != b) + if(a == replace) //if A is the replacement char + newtext = copytext(newtext, 1, newtext_it) + b + copytext(newtext, newtext_it + length(newtext[newtext_it])) + else if(b == replace) //if B is the replacement char + newtext = copytext(newtext, 1, newtext_it) + a + copytext(newtext, newtext_it + length(newtext[newtext_it])) + else //The lists disagree, Uh-oh! + return 0 + text_it += length(a) + comp_it += length(b) + newtext_it += length(newtext[newtext_it]) + return newtext + +/proc/stringpercent(text,character = "*") +//This proc returns the number of chars of the string that is the character +//This is used for detective work to determine fingerprint completion. + if(!text || !character) + return 0 + var/count = 0 + var/lentext = length(text) + var/a = "" + for(var/i = 1, i <= lentext, i += length(a)) + a = text[i] + if(a == character) + count++ + return count + +/proc/reverse_text(text = "") + var/new_text = "" + var/lentext = length(text) + var/letter = "" + for(var/i = 1, i <= lentext, i += length(letter)) + letter = text[i] + new_text = letter + new_text + return new_text + +GLOBAL_LIST_INIT(zero_character_only, list("0")) +GLOBAL_LIST_INIT(hex_characters, list("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f")) +GLOBAL_LIST_INIT(alphabet, list("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")) +GLOBAL_LIST_INIT(binary, list("0","1")) +/proc/random_string(length, list/characters) + . = "" + for(var/i=1, i<=length, i++) + . += pick(characters) + +/proc/repeat_string(times, string="") + . = "" + for(var/i=1, i<=times, i++) + . += string + +/proc/random_short_color() + return random_string(3, GLOB.hex_characters) + +/proc/random_color() + return random_string(6, GLOB.hex_characters) + +//merges non-null characters (3rd argument) from "from" into "into". Returns result +//e.g. into = "Hello World" +// from = "Seeya______" +// returns"Seeya World" +//The returned text is always the same length as into +//This was coded to handle DNA gene-splicing. +/proc/merge_text(into, from, null_char="_") + . = "" + if(!istext(into)) + into = "" + if(!istext(from)) + from = "" + var/null_ascii = istext(null_char) ? text2ascii(null_char, 1) : null_char + var/copying_into = FALSE + var/char = "" + var/start = 1 + var/end_from = length(from) + var/end_into = length(into) + var/into_it = 1 + var/from_it = 1 + while(from_it <= end_from && into_it <= end_into) + char = from[from_it] + if(text2ascii(char) == null_ascii) + if(!copying_into) + . += copytext(from, start, from_it) + start = into_it + copying_into = TRUE + else + if(copying_into) + . += copytext(into, start, into_it) + start = from_it + copying_into = FALSE + into_it += length(into[into_it]) + from_it += length(char) + + if(copying_into) + . += copytext(into, start) + else + . += copytext(from, start, from_it) + if(into_it <= end_into) + . += copytext(into, into_it) + +//finds the first occurrence of one of the characters from needles argument inside haystack +//it may appear this can be optimised, but it really can't. findtext() is so much faster than anything you can do in byondcode. +//stupid byond :( +/proc/findchar(haystack, needles, start=1, end=0) + var/char = "" + var/len = length(needles) + for(var/i = 1, i <= len, i += length(char)) + char = needles[i] + . = findtextEx(haystack, char, start, end) + if(.) + return + return 0 + +/proc/parsemarkdown_basic_step1(t, limited=FALSE) + if(length(t) <= 0) + return + + // This parses markdown with no custom rules + + // Escape backslashed + + t = replacetext(t, "$", "$-") + t = replacetext(t, "\\\\", "$1") + t = replacetext(t, "\\**", "$2") + t = replacetext(t, "\\*", "$3") + t = replacetext(t, "\\__", "$4") + t = replacetext(t, "\\_", "$5") + t = replacetext(t, "\\^", "$6") + t = replacetext(t, "\\((", "$7") + t = replacetext(t, "\\))", "$8") + t = replacetext(t, "\\|", "$9") + t = replacetext(t, "\\%", "$0") + + // Escape single characters that will be used + + t = replacetext(t, "!", "$a") + + // Parse hr and small + + if(!limited) + t = replacetext(t, "((", "") + t = replacetext(t, "))", "") + t = replacetext(t, regex("(-){3,}", "gm"), "
    ") + t = replacetext(t, regex("^\\((-){3,}\\)$", "gm"), "$1") + + // Parse lists + + var/list/tlist = splittext(t, "\n") + var/tlistlen = tlist.len + var/listlevel = -1 + var/singlespace = -1 // if 0, double spaces are used before asterisks, if 1, single are + for(var/i = 1, i <= tlistlen, i++) + var/line = tlist[i] + var/count_asterisk = length(replacetext(line, regex("\[^\\*\]+", "g"), "")) + if(count_asterisk % 2 == 1 && findtext(line, regex("^\\s*\\*", "g"))) // there is an extra asterisk in the beggining + + var/count_w = length(replacetext(line, regex("^( *)\\*.*$", "g"), "$1")) // whitespace before asterisk + line = replacetext(line, regex("^ *(\\*.*)$", "g"), "$1") + + if(singlespace == -1 && count_w == 2) + if(listlevel == 0) + singlespace = 0 + else + singlespace = 1 + + if(singlespace == 0) + count_w = count_w % 2 ? round(count_w / 2 + 0.25) : count_w / 2 + + line = replacetext(line, regex("\\*", ""), "
  • ") + while(listlevel < count_w) + line = "
      " + line + listlevel++ + while(listlevel > count_w) + line = "
    " + line + listlevel-- + + else while(listlevel >= 0) + line = "" + line + listlevel-- + + tlist[i] = line + // end for + + t = tlist[1] + for(var/i = 2, i <= tlistlen, i++) + t += "\n" + tlist[i] + + while(listlevel >= 0) + t += "" + listlevel-- + + else + t = replacetext(t, "((", "") + t = replacetext(t, "))", "") + + // Parse headers + + t = replacetext(t, regex("^#(?!#) ?(.+)$", "gm"), "

    $1

    ") + t = replacetext(t, regex("^##(?!#) ?(.+)$", "gm"), "

    $1

    ") + t = replacetext(t, regex("^###(?!#) ?(.+)$", "gm"), "

    $1

    ") + t = replacetext(t, regex("^#### ?(.+)$", "gm"), "
    $1
    ") + + // Parse most rules + + t = replacetext(t, regex("\\*(\[^\\*\]*)\\*", "g"), "$1") + t = replacetext(t, regex("_(\[^_\]*)_", "g"), "$1") + t = replacetext(t, "", "!") + t = replacetext(t, "
    ", "!") + t = replacetext(t, regex("\\!(\[^\\!\]+)\\!", "g"), "$1") + t = replacetext(t, regex("\\^(\[^\\^\]+)\\^", "g"), "$1") + t = replacetext(t, regex("\\|(\[^\\|\]+)\\|", "g"), "
    $1
    ") + t = replacetext(t, "!", "
    ") + + return t + +/proc/parsemarkdown_basic_step2(t) + if(length(t) <= 0) + return + + // Restore the single characters used + + t = replacetext(t, "$a", "!") + + // Redo the escaping + + t = replacetext(t, "$1", "\\") + t = replacetext(t, "$2", "**") + t = replacetext(t, "$3", "*") + t = replacetext(t, "$4", "__") + t = replacetext(t, "$5", "_") + t = replacetext(t, "$6", "^") + t = replacetext(t, "$7", "((") + t = replacetext(t, "$8", "))") + t = replacetext(t, "$9", "|") + t = replacetext(t, "$0", "%") + t = replacetext(t, "$-", "$") + + return t + +/proc/parsemarkdown_basic(t, limited=FALSE) + t = parsemarkdown_basic_step1(t, limited) + t = parsemarkdown_basic_step2(t) + return t + +/proc/parsemarkdown(t, mob/user=null, limited=FALSE) + if(length(t) <= 0) + return + + // Premanage whitespace + + t = replacetext(t, regex("\[^\\S\\r\\n \]", "g"), " ") + + t = parsemarkdown_basic_step1(t) + + t = replacetext(t, regex("%s(?:ign)?(?=\\s|$)", "igm"), user ? "[user.real_name]" : "") + t = replacetext(t, regex("%f(?:ield)?(?=\\s|$)", "igm"), "") + + t = parsemarkdown_basic_step2(t) + + // Manage whitespace + + t = replacetext(t, regex("(?:\\r\\n?|\\n)", "g"), "
    ") + + t = replacetext(t, " ", "  ") + + // Done + + return t + +/proc/text2charlist(text) + var/char = "" + var/lentext = length(text) + . = list() + for(var/i = 1, i <= lentext, i += length(char)) + char = text[i] + . += char + +/proc/rot13(text = "") + var/lentext = length(text) + var/char = "" + var/ascii = 0 + . = "" + for(var/i = 1, i <= lentext, i += length(char)) + char = text[i] + ascii = text2ascii(char) + switch(ascii) + if(65 to 77, 97 to 109) //A to M, a to m + ascii += 13 + if(78 to 90, 110 to 122) //N to Z, n to z + ascii -= 13 + . += ascii2text(ascii) + +//Takes a list of values, sanitizes it down for readability and character count, +//then exports it as a json file at data/npc_saves/[filename].json. +//As far as SS13 is concerned this is write only data. You can't change something +//in the json file and have it be reflected in the in game item/mob it came from. +//(That's what things like savefiles are for) Note that this list is not shuffled. +/proc/twitterize(list/proposed, filename, cullshort = 1, storemax = 1000) + if(!islist(proposed) || !filename || !CONFIG_GET(flag/log_twitter)) + return + + //Regular expressions are, as usual, absolute magic + //Any characters outside of 32 (space) to 126 (~) because treating things you don't understand as "magic" is really stupid + var/regex/all_invalid_symbols = new(@"[^ -~]{1}") + + var/list/accepted = list() + for(var/string in proposed) + if(findtext(string,GLOB.is_website) || findtext(string,GLOB.is_email) || findtext(string,all_invalid_symbols) || !findtext(string,GLOB.is_alphanumeric)) + continue + var/buffer = "" + var/early_culling = TRUE + var/lentext = length(string) + var/let = "" + + for(var/pos = 1, pos <= lentext, pos += length(let)) + let = string[pos] + if(!findtext(let, GLOB.is_alphanumeric)) + continue + early_culling = FALSE + buffer = copytext(string, pos) + break + if(early_culling) //Never found any letters! Bail! + continue + + var/punctbuffer = "" + var/cutoff = 0 + lentext = length_char(buffer) + for(var/pos = 1, pos <= lentext, pos++) + let = copytext_char(buffer, -pos, -pos + 1) + if(!findtext(let, GLOB.is_punctuation)) //This won't handle things like Nyaaaa!~ but that's fine + break + punctbuffer += let + cutoff += length(let) + if(punctbuffer) //We clip down excessive punctuation to get the letter count lower and reduce repeats. It's not perfect but it helps. + var/exclaim = FALSE + var/question = FALSE + var/periods = 0 + lentext = length(punctbuffer) + for(var/pos = 1, pos <= lentext, pos += length(let)) + let = punctbuffer[pos] + if(!exclaim && findtext(let, "!")) + exclaim = TRUE + if(question) + break + if(!question && findtext(let, "?")) + question = TRUE + if(exclaim) + break + if(!exclaim && !question && findtext(let, ".")) //? and ! take priority over periods + periods += 1 + if(exclaim) + if(question) + punctbuffer = "?!" + else + punctbuffer = "!" + else if(question) + punctbuffer = "?" + else if(periods > 1) + punctbuffer = "..." + else + punctbuffer = "" //Grammer nazis be damned + buffer = copytext(buffer, 1, -cutoff) + punctbuffer + lentext = length_char(buffer) + if(!buffer || lentext > 280 || lentext <= cullshort || (buffer in accepted)) + continue + + accepted += buffer + + var/log = file("data/npc_saves/[filename].json") //If this line ever shows up as changed in a PR be very careful you aren't being memed on + var/list/oldjson = list() + var/list/oldentries = list() + if(fexists(log)) + oldjson = json_decode(file2text(log)) + oldentries = oldjson["data"] + if(!isemptylist(oldentries)) + for(var/string in accepted) + for(var/old in oldentries) + if(string == old) + oldentries.Remove(old) //Line's position in line is "refreshed" until it falls off the in game radar + break + + var/list/finalized = list() + finalized = accepted.Copy() + oldentries.Copy() //we keep old and unreferenced phrases near the bottom for culling + listclearnulls(finalized) + if(!isemptylist(finalized) && length(finalized) > storemax) + finalized.Cut(storemax + 1) + fdel(log) + + var/list/tosend = list() + tosend["data"] = finalized + WRITE_FILE(log, json_encode(tosend)) + +//Used for applying byonds text macros to strings that are loaded at runtime +/proc/apply_text_macros(string) + var/next_backslash = findtext(string, "\\") + if(!next_backslash) + return string + + var/leng = length(string) + + var/next_space = findtext(string, " ", next_backslash + length(string[next_backslash])) + if(!next_space) + next_space = leng - next_backslash + + if(!next_space) //trailing bs + return string + + var/base = next_backslash == 1 ? "" : copytext(string, 1, next_backslash) + var/macro = lowertext(copytext(string, next_backslash + length(string[next_space]), next_space)) + var/rest = next_backslash > leng ? "" : copytext(string, next_space + length(string[next_space])) + + //See https://secure.byond.com/docs/ref/info.html#/DM/text/macros + switch(macro) + //prefixes/agnostic + if("the") + rest = text("\the []", rest) + if("a") + rest = text("\a []", rest) + if("an") + rest = text("\an []", rest) + if("proper") + rest = text("\proper []", rest) + if("improper") + rest = text("\improper []", rest) + if("roman") + rest = text("\roman []", rest) + //postfixes + if("th") + base = text("[]\th", rest) + if("s") + base = text("[]\s", rest) + if("he") + base = text("[]\he", rest) + if("she") + base = text("[]\she", rest) + if("his") + base = text("[]\his", rest) + if("himself") + base = text("[]\himself", rest) + if("herself") + base = text("[]\herself", rest) + if("hers") + base = text("[]\hers", rest) + + . = base + if(rest) + . += .(rest) + +//Replacement for the \th macro when you want the whole word output as text (first instead of 1st) +/proc/thtotext(number) + if(!isnum(number)) + return + switch(number) + if(1) + return "first" + if(2) + return "second" + if(3) + return "third" + if(4) + return "fourth" + if(5) + return "fifth" + if(6) + return "sixth" + if(7) + return "seventh" + if(8) + return "eighth" + if(9) + return "ninth" + if(10) + return "tenth" + if(11) + return "eleventh" + if(12) + return "twelfth" + else + return "[number]\th" + +/proc/unintelligize(message) + var/regex/word_boundaries = regex(@"\b[\S]+\b", "g") + var/prefix = message[1] + if(prefix == ";") + message = copytext(message, 1 + length(prefix)) + else if(prefix in list(":", "#")) + prefix += message[1 + length(prefix)] + message = copytext(message, length(prefix)) + else + prefix = "" + + var/list/rearranged = list() + while(word_boundaries.Find(message)) + var/cword = word_boundaries.match + if(length(cword)) + rearranged += cword + shuffle_inplace(rearranged) + return "[prefix][jointext(rearranged, " ")]" + + +#define is_alpha(X) ((text2ascii(X) <= 122) && (text2ascii(X) >= 97)) #define is_digit(X) ((length(X) == 1) && (length(text2num(X)) == 1)) \ No newline at end of file diff --git a/code/__HELPERS/text_vr.dm b/code/__HELPERS/text_vr.dm index 9be806fc..3c1e1eff 100644 --- a/code/__HELPERS/text_vr.dm +++ b/code/__HELPERS/text_vr.dm @@ -8,14 +8,15 @@ index = findtext(t, char) return t -proc/TextPreview(var/string,var/len=40) - if(length(string) <= len) - if(!length(string)) +/proc/TextPreview(string, len = 40) + var/char_len = length_char(string) + if(char_len <= len) + if(char_len) return "\[...\]" else return string else - return "[copytext(string, 1, 37)]..." + return "[copytext_char(string, 1, 37)]..." GLOBAL_LIST_EMPTY(mentorlog) GLOBAL_PROTECT(mentorlog) diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 8796df70..564cfe9f 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -532,17 +532,17 @@ //assumes format #RRGGBB #rrggbb /proc/color_hex2num(A) - if(!A) + if(!A || length(A) != length_char(A)) return 0 - var/R = hex2num(copytext(A,2,4)) - var/G = hex2num(copytext(A,4,6)) - var/B = hex2num(copytext(A,6,0)) + var/R = hex2num(copytext(A, 2, 4)) + var/G = hex2num(copytext(A, 4, 6)) + var/B = hex2num(copytext(A, 6, 0)) return R+G+B //word of warning: using a matrix like this as a color value will simplify it back to a string after being set /proc/color_hex2color_matrix(string) var/length = length(string) - if(length != 7 && length != 9) + if((length != 7 && length != 9) || length != length_char(string)) return color_matrix_identity() var/r = hex2num(copytext(string, 2, 4))/255 var/g = hex2num(copytext(string, 4, 6))/255 diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 72f53f5e..0050708e 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -6,25 +6,18 @@ //Inverts the colour of an HTML string /proc/invertHTML(HTMLstring) - - if (!( istext(HTMLstring) )) + if(!istext(HTMLstring)) CRASH("Given non-text argument!") return - else - if (length(HTMLstring) != 7) - CRASH("Given non-HTML argument!") - return + else if(length(HTMLstring) != 7) + CRASH("Given non-HTML argument!") + return + else if(length_char(HTMLstring) != 7) + CRASH("Given non-hex symbols in argument!") var/textr = copytext(HTMLstring, 2, 4) var/textg = copytext(HTMLstring, 4, 6) var/textb = copytext(HTMLstring, 6, 8) - var/r = hex2num(textr) - var/g = hex2num(textg) - var/b = hex2num(textb) - textr = num2hex(255 - r, 2) - textg = num2hex(255 - g, 2) - textb = num2hex(255 - b, 2) - return text("#[][][]", textr, textg, textb) - return + return rgb(255 - hex2num(textr), 255 - hex2num(textg), 255 - hex2num(textb)) /proc/Get_Angle(atom/movable/start,atom/movable/end)//For beams. if(!start || !end) @@ -184,15 +177,15 @@ Turf and target are separate in case you want to teleport some distance from a t //Returns whether or not a player is a guest using their ckey as an input /proc/IsGuestKey(key) if (findtext(key, "Guest-", 1, 7) != 1) //was findtextEx - return 0 + return FALSE var/i, ch, len = length(key) - for (i = 7, i <= len, ++i) + for (i = 7, i <= len, ++i) //we know the first 6 chars are Guest- ch = text2ascii(key, i) - if (ch < 48 || ch > 57) - return 0 - return 1 + if (ch < 48 || ch > 57) //0-9 + return FALSE + return TRUE //Generalised helper proc for letting mobs rename themselves. Used to be clname() and ainame() /mob/proc/apply_pref_name(role, client/C) @@ -1421,7 +1414,7 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) /proc/GUID() var/const/GUID_VERSION = "b" var/const/GUID_VARIANT = "d" - var/node_id = copytext(md5("[rand()*rand(1,9999999)][world.name][world.hub][world.hub_password][world.internet_address][world.address][world.contents.len][world.status][world.port][rand()*rand(1,9999999)]"), 1, 13) + var/node_id = copytext_char(md5("[rand()*rand(1,9999999)][world.name][world.hub][world.hub_password][world.internet_address][world.address][world.contents.len][world.status][world.port][rand()*rand(1,9999999)]"), 1, 13) var/time_high = "[num2hex(text2num(time2text(world.realtime,"YYYY")), 2)][num2hex(world.realtime, 6)]" diff --git a/code/_compile_options.dm b/code/_compile_options.dm index af948086..fe4761dd 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -39,6 +39,26 @@ #error You need version 512 or higher #endif +//Compatability -- These procs were added in 513.1493, not 513.1490 +//Which really shoulda bumped us up to 514 right then and there but instead Lummox is a dumb dumb +#if DM_BUILD < 1493 +#define length_char(args...) length(args) +#define text2ascii_char(args...) text2ascii(args) +#define copytext_char(args...) copytext(args) +#define splittext_char(args...) splittext(args) +#define spantext_char(args...) spantext(args) +#define nonspantext_char(args...) nonspantext(args) +#define findtext_char(args...) findtext(args) +#define findtextEx_char(args...) findtextEx(args) +#define findlasttext_char(args...) findlasttext(args) +#define findlasttextEx_char(args...) findlasttextEx(args) +#define replacetext_char(args...) replacetext(args) +#define replacetextEx_char(args...) replacetextEx(args) +// /regex procs +#define Find_char(args...) Find(args) +#define Replace_char(args...) Replace(args) +#endif + //Additional code for the above flags. #ifdef TESTING #warn compiling in TESTING mode. testing() debug messages will be visible. diff --git a/code/controllers/configuration/config_entry.dm b/code/controllers/configuration/config_entry.dm index 624e800b..4c72f83e 100644 --- a/code/controllers/configuration/config_entry.dm +++ b/code/controllers/configuration/config_entry.dm @@ -166,7 +166,8 @@ key_name = copytext(str_val, 1, key_pos) if(lowercase) key_name = lowertext(key_name) - key_value = copytext(str_val, key_pos + 1) + if(key_pos) + key_value = copytext(str_val, key_pos + length(str_val[key_pos])) var/new_key var/new_value var/continue_check_value diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 256b6a8f..5a3cca96 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -106,13 +106,13 @@ if(!L) continue - var/firstchar = copytext(L, 1, 2) + var/firstchar = L[1] if(firstchar == "#") continue var/lockthis = firstchar == "@" if(lockthis) - L = copytext(L, 2) + L = copytext(L, length(firstchar) + 1) var/pos = findtext(L, " ") var/entry = null @@ -120,7 +120,7 @@ if(pos) entry = lowertext(copytext(L, 1, pos)) - value = copytext(L, pos + 1) + value = copytext(L, pos + length(L[pos])) else entry = lowertext(L) @@ -256,7 +256,7 @@ t = trim(t) if(length(t) == 0) continue - else if(copytext(t, 1, 2) == "#") + else if(t[1] == "#") continue var/pos = findtext(t, " ") @@ -265,7 +265,7 @@ if(pos) command = lowertext(copytext(t, 1, pos)) - data = copytext(t, pos + 1) + data = copytext(t, pos + length(t[pos])) else command = lowertext(t) diff --git a/code/controllers/subsystem/pai.dm b/code/controllers/subsystem/pai.dm index 8f95f2ec..0af3454e 100644 --- a/code/controllers/subsystem/pai.dm +++ b/code/controllers/subsystem/pai.dm @@ -39,34 +39,34 @@ SUBSYSTEM_DEF(pai) switch(option) if("name") - t = input("Enter a name for your pAI", "pAI Name", candidate.name) as text + t = reject_bad_name(stripped_input(usr, "Enter a name for your pAI", "pAI Name", candidate.name, MAX_NAME_LEN), TRUE) if(t) - candidate.name = copytext(sanitize(t),1,MAX_NAME_LEN) + candidate.name = t if("desc") - t = input("Enter a description for your pAI", "pAI Description", candidate.description) as message + t = stripped_multiline_input(usr, "Enter a description for your pAI", "pAI Description", candidate.description, MAX_MESSAGE_LEN) if(t) - candidate.description = copytext(sanitize(t),1,MAX_MESSAGE_LEN) + candidate.description = t if("role") - t = input("Enter a role for your pAI", "pAI Role", candidate.role) as text + t = stripped_input(usr, "Enter a role for your pAI", "pAI Role", candidate.role, MAX_MESSAGE_LEN) if(t) - candidate.role = copytext(sanitize(t),1,MAX_MESSAGE_LEN) + candidate.role = t if("ooc") - t = input("Enter any OOC comments", "pAI OOC Comments", candidate.comments) as message + t = stripped_multiline_input(usr, "Enter any OOC comments", "pAI OOC Comments", candidate.comments, MAX_MESSAGE_LEN) if(t) - candidate.comments = copytext(sanitize(t),1,MAX_MESSAGE_LEN) + candidate.comments = t if("save") candidate.savefile_save(usr) if("load") candidate.savefile_load(usr) //In case people have saved unsanitized stuff. if(candidate.name) - candidate.name = copytext(sanitize(candidate.name),1,MAX_NAME_LEN) + candidate.name = copytext_char(sanitize(candidate.name),1,MAX_NAME_LEN) if(candidate.description) - candidate.description = copytext(sanitize(candidate.description),1,MAX_MESSAGE_LEN) + candidate.description = copytext_char(sanitize(candidate.description),1,MAX_MESSAGE_LEN) if(candidate.role) - candidate.role = copytext(sanitize(candidate.role),1,MAX_MESSAGE_LEN) + candidate.role = copytext_char(sanitize(candidate.role),1,MAX_MESSAGE_LEN) if(candidate.comments) - candidate.comments = copytext(sanitize(candidate.comments),1,MAX_MESSAGE_LEN) + candidate.comments = copytext_char(sanitize(candidate.comments),1,MAX_MESSAGE_LEN) if("submit") if(candidate) diff --git a/code/controllers/subsystem/processing/networks.dm b/code/controllers/subsystem/processing/networks.dm index 03276d5b..f7f16538 100644 --- a/code/controllers/subsystem/processing/networks.dm +++ b/code/controllers/subsystem/processing/networks.dm @@ -46,6 +46,6 @@ PROCESSING_SUBSYSTEM_DEF(networks) var/hex = md5(string) if(!hex) return //errored - . = "[copytext(hex, 1, 9)]" //16 ^ 8 possibilities I think. + . = "[copytext_char(hex, 1, 9)]" //16 ^ 8 possibilities I think. if(interfaces_by_id[.]) return resolve_collisions? make_address("[num2text(rand(HID_RESTRICTED_END, 999999999), 12)]"):null diff --git a/code/datums/brain_damage/imaginary_friend.dm b/code/datums/brain_damage/imaginary_friend.dm index 4f500a37..4717be4f 100644 --- a/code/datums/brain_damage/imaginary_friend.dm +++ b/code/datums/brain_damage/imaginary_friend.dm @@ -155,7 +155,7 @@ to_chat(src, compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mode, FALSE, source)) /mob/camera/imaginary_friend/proc/friend_talk(message) - message = capitalize(trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN))) + message = capitalize(trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))) if(!message) return diff --git a/code/datums/brain_damage/mild.dm b/code/datums/brain_damage/mild.dm index 012f771a..5a5407f0 100644 --- a/code/datums/brain_damage/mild.dm +++ b/code/datums/brain_damage/mild.dm @@ -199,13 +199,16 @@ var/list/new_message = list() for(var/word in message_split) - var/suffix = copytext(word,-1) + var/suffix = "" + var/suffix_foundon = 0 + for(var/potential_suffix in list("." , "," , ";" , "!" , ":" , "?")) + suffix_foundon = findtext(word, potential_suffix, -length(potential_suffix)) + if(suffix_foundon) + suffix = potential_suffix + break - // Check if we have a suffix and break it out of the word - if(suffix in list("." , "," , ";" , "!" , ":" , "?")) - word = copytext(word,1,-1) - else - suffix = "" + if(suffix_foundon) + word = copytext(word, 1, suffix_foundon) word = html_decode(word) @@ -216,10 +219,9 @@ new_message += pick("uh","erm") break else - var/list/charlist = string2charlist(word) // Stupid shit code + var/list/charlist = text2charlist(word) shuffle_inplace(charlist) - charlist.len = round(charlist.len * 0.5,1) - new_message += html_encode(jointext(charlist,"")) + suffix + new_message += jointext(charlist, "") + suffix message = jointext(new_message, " ") diff --git a/code/datums/dna.dm b/code/datums/dna.dm index 1c79a396..ac612436 100644 --- a/code/datums/dna.dm +++ b/code/datums/dna.dm @@ -476,14 +476,14 @@ /proc/getleftblocks(input,blocknumber,blocksize) if(blocknumber > 1) - return copytext(input,1,((blocksize*blocknumber)-(blocksize-1))) + return copytext_char(input,1,((blocksize*blocknumber)-(blocksize-1))) /proc/getrightblocks(input,blocknumber,blocksize) if(blocknumber < (length(input)/blocksize)) - return copytext(input,blocksize*blocknumber+1,length(input)+1) + return copytext_char(input,blocksize*blocknumber+1,length(input)+1) /proc/getblock(input, blocknumber, blocksize=DNA_BLOCK_SIZE) - return copytext(input, blocksize*(blocknumber-1)+1, (blocksize*blocknumber)+1) + return copytext_char(input, blocksize*(blocknumber-1)+1, (blocksize*blocknumber)+1) /proc/setblock(istring, blocknumber, replacement, blocksize=DNA_BLOCK_SIZE) if(!istring || !blocknumber || !replacement || !blocksize) diff --git a/code/datums/emotes.dm b/code/datums/emotes.dm index 6c91cc3a..fab8dff2 100644 --- a/code/datums/emotes.dm +++ b/code/datums/emotes.dm @@ -21,6 +21,7 @@ var/list/mob_type_ignore_stat_typecache var/stat_allowed = CONSCIOUS var/static/list/emote_list = list() + var/static/regex/stop_bad_mime = regex(@"says|exclaims|yells|asks") /datum/emote/New() if(key_third_person) diff --git a/code/datums/helper_datums/getrev.dm b/code/datums/helper_datums/getrev.dm index 420602cc..7d040a49 100644 --- a/code/datums/helper_datums/getrev.dm +++ b/code/datums/helper_datums/getrev.dm @@ -43,7 +43,7 @@ for(var/line in testmerge) var/datum/tgs_revision_information/test_merge/tm = line var/cm = tm.pull_request_commit - var/details = ": '" + html_encode(tm.title) + "' by " + html_encode(tm.author) + " at commit " + html_encode(copytext(cm, 1, min(length(cm), 11))) + var/details = ": '" + html_encode(tm.title) + "' by " + html_encode(tm.author) + " at commit " + html_encode(copytext_char(cm, 1, 11)) if(details && findtext(details, "\[s\]") && (!usr || !usr.client.holder)) continue . += "#[tm.number][details]
    " @@ -57,11 +57,11 @@ // Round ID if(GLOB.round_id) msg += "Round ID: [GLOB.round_id]" - + msg += "BYOND Version: [world.byond_version].[world.byond_build]" if(DM_VERSION != world.byond_version || DM_BUILD != world.byond_build) msg += "Compiled with BYOND Version: [DM_VERSION].[DM_BUILD]" - + // Revision information var/datum/getrev/revdata = GLOB.revdata msg += "Server revision compiled on: [revdata.date]" diff --git a/code/datums/holocall.dm b/code/datums/holocall.dm index 5a460043..72fe6f5a 100644 --- a/code/datums/holocall.dm +++ b/code/datums/holocall.dm @@ -257,8 +257,8 @@ var/splitpoint = findtext(prepared_line," ") if(!splitpoint) continue - var/command = copytext(prepared_line,1,splitpoint) - var/value = copytext(prepared_line,splitpoint+1) + var/command = copytext(prepared_line, 1, splitpoint) + var/value = copytext(prepared_line, splitpoint + length(prepared_line[splitpoint])) switch(command) if("DELAY") var/delay_value = text2num(value) diff --git a/code/datums/martial.dm b/code/datums/martial.dm index 39070c5e..e16b4ddd 100644 --- a/code/datums/martial.dm +++ b/code/datums/martial.dm @@ -33,7 +33,7 @@ restraining = 0 streak = streak+element if(length(streak) > max_streak_length) - streak = copytext(streak,2) + streak = copytext(streak, 1 + length(streak[1])) return /datum/martial_art/proc/basic_hit(mob/living/carbon/human/A,mob/living/carbon/human/D) diff --git a/code/datums/mind.dm b/code/datums/mind.dm index b1f235a0..3b549958 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -135,7 +135,7 @@ L.update_arousal_hud() //Removes the old icon /datum/mind/proc/store_memory(new_text) - if((length(memory) + length(new_text)) <= MAX_MESSAGE_LEN) + if((length_char(memory) + length_char(new_text)) <= MAX_MESSAGE_LEN) memory += "[new_text]
    " /datum/mind/proc/wipe_memory() @@ -411,7 +411,7 @@ assigned_role = new_role else if (href_list["memory_edit"]) - var/new_memo = copytext(sanitize(input("Write new memory", "Memory", memory) as null|message),1,MAX_MESSAGE_LEN) + var/new_memo = stripped_multiline_input(usr, "Write new memory", "Memory", memory, MAX_MESSAGE_LEN) if (isnull(new_memo)) return memory = new_memo diff --git a/code/datums/verbs.dm b/code/datums/verbs.dm index d58d3051..82a7b315 100644 --- a/code/datums/verbs.dm +++ b/code/datums/verbs.dm @@ -88,8 +88,8 @@ var/list/entry = list() entry["parent"] = "[type]" entry["name"] = verbpath.desc - if (copytext(verbpath.name,1,2) == "@") - entry["command"] = copytext(verbpath.name,2) + if (verbpath.name[1] == "@") + entry["command"] = copytext(verbpath.name, length(verbpath.name[1]) + 1) else entry["command"] = replacetext(verbpath.name, " ", "-") diff --git a/code/datums/wires/_wires.dm b/code/datums/wires/_wires.dm index fab5a131..e1cfe3a4 100644 --- a/code/datums/wires/_wires.dm +++ b/code/datums/wires/_wires.dm @@ -118,7 +118,7 @@ return TRUE /datum/wires/proc/is_dud(wire) - return dd_hasprefix(wire, WIRE_DUD_PREFIX) + return findtext(wire, WIRE_DUD_PREFIX) /datum/wires/proc/is_dud_color(color) return is_dud(get_wire(color)) diff --git a/code/game/machinery/computer/cloning.dm b/code/game/machinery/computer/cloning.dm index e541bda1..ef98704f 100644 --- a/code/game/machinery/computer/cloning.dm +++ b/code/game/machinery/computer/cloning.dm @@ -487,7 +487,7 @@ R.fields["ckey"] = mob_occupant.ckey R.fields["name"] = mob_occupant.real_name - R.fields["id"] = copytext(md5(mob_occupant.real_name), 2, 6) + R.fields["id"] = copytext_char(md5(mob_occupant.real_name), 2, 6) R.fields["UE"] = dna.unique_enzymes R.fields["UI"] = dna.uni_identity R.fields["SE"] = dna.mutation_index diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index bfa9a87c..4e7c6a5b 100644 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -449,7 +449,7 @@ var/dat = "" if(SSshuttle.emergency.mode == SHUTTLE_CALL) var/timeleft = SSshuttle.emergency.timeLeft() - dat += "Emergency shuttle\n
    \nETA: [timeleft / 60 % 60]:[add_zero(num2text(timeleft % 60), 2)]" + dat += "Emergency shuttle\n
    \nETA: [timeleft / 60 % 60]:[add_leading(num2text(timeleft % 60), 2, "0")]" var/datum/browser/popup = new(user, "communications", "Communications Console", 400, 500) diff --git a/code/game/machinery/computer/dna_console.dm b/code/game/machinery/computer/dna_console.dm index 018405df..dce75068 100644 --- a/code/game/machinery/computer/dna_console.dm +++ b/code/game/machinery/computer/dna_console.dm @@ -650,7 +650,7 @@ viable_occupant.radiation += (RADIATION_IRRADIATION_MULTIPLIER*radduration*radstrength)/(connected.damage_coeff ** 2) //Read comment in "transferbuffer" section above for explanation switch(href_list["task"]) //Same thing as there but values are even lower, on best part they are about 0.0*, effectively no damage if("pulseui") - var/len = length(viable_occupant.dna.uni_identity) + var/len = length_char(viable_occupant.dna.uni_identity) num = WRAP(num, 1, len+1) num = randomize_radiation_accuracy(num, radduration + (connected.precision_coeff ** 2), len) //Each manipulator level above 1 makes randomization as accurate as selected time + manipulator lvl^2 //Value is this high for the same reason as with laser - not worth the hassle of upgrading if the bonus is low @@ -658,12 +658,12 @@ var/subblock = num - block*DNA_BLOCK_SIZE last_change = "UI #[block]-[subblock]; " - var/hex = copytext(viable_occupant.dna.uni_identity, num, num+1) + var/hex = copytext_char(viable_occupant.dna.uni_identity, num, num+1) last_change += "[hex]" hex = scramble(hex, radstrength, radduration) last_change += "->[hex]" - viable_occupant.dna.uni_identity = copytext(viable_occupant.dna.uni_identity, 1, num) + hex + copytext(viable_occupant.dna.uni_identity, num+1, 0) + viable_occupant.dna.uni_identity = copytext_char(viable_occupant.dna.uni_identity, 1, num) + hex + copytext_char(viable_occupant.dna.uni_identity, num + 1) viable_occupant.updateappearance(mutations_overlay_update=1) else current_screen = "mainmenu" diff --git a/code/game/machinery/computer/prisoner/management.dm b/code/game/machinery/computer/prisoner/management.dm index 653f6bf4..496e14b8 100644 --- a/code/game/machinery/computer/prisoner/management.dm +++ b/code/game/machinery/computer/prisoner/management.dm @@ -125,7 +125,7 @@ to_chat(usr, "Unauthorized access.") else if(href_list["warn"]) - var/warning = copytext(sanitize(input(usr,"Message:","Enter your message here!","")),1,MAX_MESSAGE_LEN) + var/warning = stripped_input(usr, "Message:", "Enter your message here!", "", MAX_MESSAGE_LEN) if(!warning) return var/obj/item/implant/I = locate(href_list["warn"]) in GLOB.tracked_implants diff --git a/code/game/machinery/computer/security.dm b/code/game/machinery/computer/security.dm index 3cf5321f..2ca234ce 100644 --- a/code/game/machinery/computer/security.dm +++ b/code/game/machinery/computer/security.dm @@ -543,7 +543,7 @@ What a mess.*/ switch(href_list["field"]) if("name") if(istype(active1, /datum/data/record) || istype(active2, /datum/data/record)) - var/t1 = copytext(sanitize(input("Please input name:", "Secure. records", active1.fields["name"], null) as text),1,MAX_MESSAGE_LEN) + var/t1 = stripped_input(usr, "Please input name:", "Secure. records", active1.fields["name"], MAX_MESSAGE_LEN) if(!canUseSecurityRecordsConsole(usr, t1, a1)) return if(istype(active1, /datum/data/record)) diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm index beaf47d0..a513d7fe 100644 --- a/code/game/machinery/doors/brigdoors.dm +++ b/code/game/machinery/doors/brigdoors.dm @@ -168,7 +168,7 @@ if(timing) var/disp1 = id var/time_left = time_left(seconds = TRUE) - var/disp2 = "[add_zero(num2text((time_left / 60) % 60),2)]~[add_zero(num2text(time_left % 60), 2)]" + var/disp2 = "[add_leading(num2text((time_left / 60) % 60), 2, "0")]:[add_leading(num2text(time_left % 60), 2, "0")]" if(length(disp2) > CHARS_PER_LINE) disp2 = "Error" update_display(disp1, disp2) diff --git a/code/game/machinery/magnet.dm b/code/game/machinery/magnet.dm index b3ea27e1..cd5482d7 100644 --- a/code/game/machinery/magnet.dm +++ b/code/game/machinery/magnet.dm @@ -306,7 +306,7 @@ if(speed <= 0) speed = 1 if("setpath") - var/newpath = copytext(sanitize(input(usr, "Please define a new path!",,path) as text|null),1,MAX_MESSAGE_LEN) + var/newpath = stripped_input(usr, "Please define a new path!", "New Path", path, MAX_MESSAGE_LEN) if(newpath && newpath != "") moving = 0 // stop moving path = newpath @@ -368,13 +368,19 @@ // Generates the rpath variable using the path string, think of this as "string2list" // Doesn't use params2list() because of the akward way it stacks entities rpath = list() // clear rpath - var/maximum_character = min( 50, length(path) ) // chooses the maximum length of the iterator. 50 max length + var/maximum_characters = 50 - for(var/i=1, i<=maximum_character, i++) // iterates through all characters in path + var/lentext = length(path) + var/nextchar = "" + var/charcount = 0 - var/nextchar = copytext(path, i, i+1) // find next character - - if(!(nextchar in list(";", "&", "*", " "))) // if char is a separator, ignore - rpath += copytext(path, i, i+1) // else, add to list + for(var/i = 1, i <= lentext, i += length(nextchar)) // iterates through all characters in path + nextchar = path[i] // find next character + if(nextchar in list(";", "&", "*", " ")) // if char is a separator, ignore + continue + rpath += nextchar // else, add to list // there doesn't HAVE to be separators but it makes paths syntatically visible + charcount++ + if(charcount >= maximum_characters) + break diff --git a/code/game/machinery/navbeacon.dm b/code/game/machinery/navbeacon.dm index 32412f40..38416e94 100644 --- a/code/game/machinery/navbeacon.dm +++ b/code/game/machinery/navbeacon.dm @@ -62,7 +62,7 @@ var/index = findtext(e, "=") // format is "key=value" if(index) var/key = copytext(e, 1, index) - var/val = copytext(e, index+1) + var/val = copytext(e, index + length(e[index])) codes[key] = val else codes[e] = "1" @@ -167,7 +167,7 @@ Transponder Codes:
      "} usr.set_machine(src) if(href_list["locedit"]) - var/newloc = copytext(sanitize(input("Enter New Location", "Navigation Beacon", location) as text|null),1,MAX_MESSAGE_LEN) + var/newloc = stripped_input(usr, "Enter New Location", "Navigation Beacon", location, MAX_MESSAGE_LEN) if(newloc) location = newloc updateDialog() diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index 58fb4c31..20b85555 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -162,7 +162,7 @@ GLOBAL_LIST_EMPTY(allCasters) NEWSCASTER.update_icon() /datum/newscaster/feed_network/proc/save_photo(icon/photo) - var/photo_file = copytext(md5("\icon[photo]"), 1, 6) + var/photo_file = copytext_char(md5("\icon[photo]"), 1, 6) if(!fexists("[GLOB.log_directory]/photos/[photo_file].png")) //Clean up repeated frames var/icon/clean = new /icon() @@ -514,8 +514,6 @@ GLOBAL_LIST_EMPTY(allCasters) scan_user(usr) if(href_list["set_channel_name"]) channel_name = stripped_input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "", MAX_NAME_LEN) - while (findtext(channel_name," ") == 1) - channel_name = copytext(channel_name,2,length(channel_name)+1) updateUsrDialog() else if(href_list["set_channel_lock"]) c_locked = !c_locked @@ -690,7 +688,7 @@ GLOBAL_LIST_EMPTY(allCasters) updateUsrDialog() else if(href_list["new_comment"]) var/datum/newscaster/feed_message/FM = locate(href_list["new_comment"]) - var/cominput = copytext(stripped_input(usr, "Write your message:", "New comment", null),1,141) + var/cominput = copytext_char(stripped_input(usr, "Write your message:", "New comment", null), 140) if(cominput) scan_user(usr) var/datum/newscaster/feed_comment/FC = new/datum/newscaster/feed_comment diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm index ec5d0343..6b191ef1 100644 --- a/code/game/machinery/requests_console.dm +++ b/code/game/machinery/requests_console.dm @@ -263,10 +263,9 @@ GLOBAL_LIST_EMPTY(allConsoles) usr.set_machine(src) add_fingerprint(usr) - if(reject_bad_text(href_list["write"])) - dpt = ckey(href_list["write"]) //write contains the string of the receiving department's name - - var/new_message = copytext(reject_bad_text(input(usr, "Write your message:", "Awaiting Input", "")),1,MAX_MESSAGE_LEN) + if(href_list["write"]) + dpt = ckey(reject_bad_text(href_list["write"])) //write contains the string of the receiving department's name + var/new_message = stripped_input(usr, "Write your message:", "Awaiting Input", "", MAX_MESSAGE_LEN) if(new_message) message = new_message screen = 9 @@ -282,7 +281,7 @@ GLOBAL_LIST_EMPTY(allConsoles) priority = -1 if(href_list["writeAnnouncement"]) - var/new_message = copytext(reject_bad_text(input(usr, "Write your message:", "Awaiting Input", "")),1,MAX_MESSAGE_LEN) + var/new_message = reject_bad_text(stripped_input(usr, "Write your message:", "Awaiting Input", "", MAX_MESSAGE_LEN)) if(new_message) message = new_message if (text2num(href_list["priority"]) < 2) @@ -438,9 +437,8 @@ GLOBAL_LIST_EMPTY(allConsoles) return /obj/machinery/requests_console/say_mod(input, message_mode) - var/ending = copytext(input, length(input) - 2) - if (ending == "!!!") - . = "blares" + if(spantext_char(input, "!", -3)) + return "blares" else . = ..() diff --git a/code/game/machinery/status_display.dm b/code/game/machinery/status_display.dm index af5f50f2..10cd84b7 100644 --- a/code/game/machinery/status_display.dm +++ b/code/game/machinery/status_display.dm @@ -1,368 +1,368 @@ -// Status display -// (formerly Countdown timer display) - -#define CHARS_PER_LINE 5 -#define FONT_SIZE "5pt" -#define FONT_COLOR "#09f" -#define FONT_STYLE "Arial Black" -#define SCROLL_SPEED 2 - -#define SD_BLANK 0 // 0 = Blank -#define SD_EMERGENCY 1 // 1 = Emergency Shuttle timer -#define SD_MESSAGE 2 // 2 = Arbitrary message(s) -#define SD_PICTURE 3 // 3 = alert picture - -#define SD_AI_EMOTE 1 // 1 = AI emoticon -#define SD_AI_BSOD 2 // 2 = Blue screen of death - -/// Status display which can show images and scrolling text. -/obj/machinery/status_display - name = "status display" - desc = null - icon = 'icons/obj/status_display.dmi' - icon_state = "frame" - density = FALSE - use_power = IDLE_POWER_USE - idle_power_usage = 10 - - maptext_height = 26 - maptext_width = 32 - - var/message1 = "" // message line 1 - var/message2 = "" // message line 2 - var/index1 // display index for scrolling messages or 0 if non-scrolling - var/index2 - -/// Immediately blank the display. -/obj/machinery/status_display/proc/remove_display() - cut_overlays() - if(maptext) - maptext = "" - -/// Immediately change the display to the given picture. -/obj/machinery/status_display/proc/set_picture(state) - remove_display() - add_overlay(state) - -/// Immediately change the display to the given two lines. -/obj/machinery/status_display/proc/update_display(line1, line2) - var/new_text = {"
      [line1]
      [line2]
      "} - if(maptext != new_text) - maptext = new_text - -/// Prepare the display to marquee the given two lines. -/// -/// Call with no arguments to disable. -/obj/machinery/status_display/proc/set_message(m1, m2) - if(m1) - index1 = (length(m1) > CHARS_PER_LINE) - message1 = m1 - else - message1 = "" - index1 = 0 - - if(m2) - index2 = (length(m2) > CHARS_PER_LINE) - message2 = m2 - else - message2 = "" - index2 = 0 - -// Timed process - performs default marquee action if so needed. -/obj/machinery/status_display/process() - if(stat & NOPOWER) - // No power, no processing. - remove_display() - return PROCESS_KILL - - var/line1 = message1 - if(index1) - line1 = copytext("[message1]|[message1]", index1, index1+CHARS_PER_LINE) - var/message1_len = length(message1) - index1 += SCROLL_SPEED - if(index1 > message1_len) - index1 -= message1_len - - var/line2 = message2 - if(index2) - line2 = copytext("[message2]|[message2]", index2, index2+CHARS_PER_LINE) - var/message2_len = length(message2) - index2 += SCROLL_SPEED - if(index2 > message2_len) - index2 -= message2_len - - update_display(line1, line2) - if (!index1 && !index2) - // No marquee, no processing. - return PROCESS_KILL - -/// Update the display and, if necessary, re-enable processing. -/obj/machinery/status_display/proc/update() - if (process() != PROCESS_KILL) - START_PROCESSING(SSmachines, src) - -/obj/machinery/status_display/power_change() - . = ..() - update() - -/obj/machinery/status_display/emp_act(severity) - . = ..() - if(stat & (NOPOWER|BROKEN) || . & EMP_PROTECT_SELF) - return - set_picture("ai_bsod") - -/obj/machinery/status_display/examine(mob/user) - . = ..() - if (message1 || message2) - . += "The display says:" - if (message1) - . += "\t[html_encode(message1)]" - if (message2) - . += "\t[html_encode(message2)]" - -// Helper procs for child display types. -/obj/machinery/status_display/proc/display_shuttle_status(obj/docking_port/mobile/shuttle) - if(!shuttle) - // the shuttle is missing - no processing - update_display("shutl?","") - return PROCESS_KILL - else if(shuttle.timer) - var/line1 = "-[shuttle.getModeStr()]-" - var/line2 = shuttle.getTimerStr() - - if(length(line2) > CHARS_PER_LINE) - line2 = "error" - update_display(line1, line2) - else - // don't kill processing, the timer might turn back on - remove_display() - -/obj/machinery/status_display/proc/examine_shuttle(mob/user, obj/docking_port/mobile/shuttle) - if (shuttle) - var/modestr = shuttle.getModeStr() - if (modestr) - if (shuttle.timer) - modestr = "
      \t[modestr]: [shuttle.getTimerStr()]" - else - modestr = "
      \t[modestr]" - return "The display says:
      \t[shuttle.name][modestr]" - else - return "The display says:
      \tShuttle missing!" - - -/// Evac display which shows shuttle timer or message set by Command. -/obj/machinery/status_display/evac - var/frequency = FREQ_STATUS_DISPLAYS - var/mode = SD_EMERGENCY - var/friendc = FALSE // track if Friend Computer mode - var/last_picture // For when Friend Computer mode is undone - -/obj/machinery/status_display/evac/Initialize() - . = ..() - // register for radio system - SSradio.add_object(src, frequency) - -/obj/machinery/status_display/evac/Destroy() - SSradio.remove_object(src,frequency) - return ..() - -/obj/machinery/status_display/evac/process() - if(stat & NOPOWER) - // No power, no processing. - remove_display() - return PROCESS_KILL - - if(friendc) //Makes all status displays except supply shuttle timer display the eye -- Urist - set_picture("ai_friend") - return PROCESS_KILL - - switch(mode) - if(SD_BLANK) - remove_display() - return PROCESS_KILL - - if(SD_EMERGENCY) - return display_shuttle_status(SSshuttle.emergency) - - if(SD_MESSAGE) - return ..() - - if(SD_PICTURE) - set_picture(last_picture) - return PROCESS_KILL - -/obj/machinery/status_display/evac/examine(mob/user) - . = ..() - if(mode == SD_EMERGENCY) - . += examine_shuttle(user, SSshuttle.emergency) - else if(!message1 && !message2) - . += "The display is blank." - -/obj/machinery/status_display/evac/receive_signal(datum/signal/signal) - switch(signal.data["command"]) - if("blank") - mode = SD_BLANK - set_message(null, null) - if("shuttle") - mode = SD_EMERGENCY - set_message(null, null) - if("message") - mode = SD_MESSAGE - set_message(signal.data["msg1"], signal.data["msg2"]) - if("alert") - mode = SD_PICTURE - last_picture = signal.data["picture_state"] - set_picture(last_picture) - if("friendcomputer") - friendc = !friendc - update() - - -/// Supply display which shows the status of the supply shuttle. -/obj/machinery/status_display/supply - name = "supply display" - -/obj/machinery/status_display/supply/process() - if(stat & NOPOWER) - // No power, no processing. - remove_display() - return PROCESS_KILL - - var/line1 - var/line2 - if(!SSshuttle.supply) - // Might be missing in our first update on initialize before shuttles - // have loaded. Cross our fingers that it will soon return. - line1 = "CARGO" - line2 = "shutl?" - else if(SSshuttle.supply.mode == SHUTTLE_IDLE) - if(is_station_level(SSshuttle.supply.z)) - line1 = "CARGO" - line2 = "Docked" - else - line1 = "CARGO" - line2 = SSshuttle.supply.getTimerStr() - if(length(line2) > CHARS_PER_LINE) - line2 = "Error" - update_display(line1, line2) - -/obj/machinery/status_display/supply/examine(mob/user) - . = ..() - var/obj/docking_port/mobile/shuttle = SSshuttle.supply - var/shuttleMsg = null - if (shuttle.mode == SHUTTLE_IDLE) - if (is_station_level(shuttle.z)) - shuttleMsg = "Docked" - else - shuttleMsg = "[shuttle.getModeStr()]: [shuttle.getTimerStr()]" - if (shuttleMsg) - . += "The display says:
      \t[shuttleMsg]" - else - . += "The display is blank." - - -/// General-purpose shuttle status display. -/obj/machinery/status_display/shuttle - name = "shuttle display" - var/shuttle_id - -/obj/machinery/status_display/shuttle/process() - if(!shuttle_id || (stat & NOPOWER)) - // No power, no processing. - remove_display() - return PROCESS_KILL - - return display_shuttle_status(SSshuttle.getShuttle(shuttle_id)) - -/obj/machinery/status_display/shuttle/examine(mob/user) - . = ..() - if(shuttle_id) - . += examine_shuttle(user, SSshuttle.getShuttle(shuttle_id)) - else - . += "The display is blank." - -/obj/machinery/status_display/shuttle/vv_edit_var(var_name, var_value) - . = ..() - if(!.) - return - switch(var_name) - if("shuttle_id") - update() - -/obj/machinery/status_display/shuttle/proc/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock, idnum, override) - if (port && (shuttle_id == initial(shuttle_id) || override)) - shuttle_id = port.id - update() - - -/// Pictograph display which the AI can use to emote. -/obj/machinery/status_display/ai - name = "\improper AI display" - desc = "A small screen which the AI can use to present itself." - - var/mode = SD_BLANK - var/emotion = "Neutral" - -/obj/machinery/status_display/ai/Initialize() - . = ..() - GLOB.ai_status_displays.Add(src) - -/obj/machinery/status_display/ai/Destroy() - GLOB.ai_status_displays.Remove(src) - . = ..() - -/obj/machinery/status_display/ai/attack_ai(mob/living/silicon/ai/user) - if(isAI(user)) - user.ai_statuschange() - -/obj/machinery/status_display/ai/process() - if(mode == SD_BLANK || (stat & NOPOWER)) - remove_display() - return PROCESS_KILL - - if(mode == SD_AI_EMOTE) - switch(emotion) - if("Very Happy") - set_picture("ai_veryhappy") - if("Happy") - set_picture("ai_happy") - if("Neutral") - set_picture("ai_neutral") - if("Unsure") - set_picture("ai_unsure") - if("Confused") - set_picture("ai_confused") - if("Sad") - set_picture("ai_sad") - if("BSOD") - set_picture("ai_bsod") - if("Blank") - set_picture("ai_off") - if("Problems?") - set_picture("ai_trollface") - if("Awesome") - set_picture("ai_awesome") - if("Dorfy") - set_picture("ai_urist") - if("Thinking") - set_picture("ai_thinking") - if("Facepalm") - set_picture("ai_facepalm") - if("Friend Computer") - set_picture("ai_friend") - if("Blue Glow") - set_picture("ai_sal") - if("Red Glow") - set_picture("ai_hal") - return PROCESS_KILL - - if(mode == SD_AI_BSOD) - set_picture("ai_bsod") - return PROCESS_KILL - - -#undef CHARS_PER_LINE -#undef FONT_SIZE -#undef FONT_COLOR -#undef FONT_STYLE -#undef SCROLL_SPEED +// Status display +// (formerly Countdown timer display) + +#define CHARS_PER_LINE 5 +#define FONT_SIZE "5pt" +#define FONT_COLOR "#09f" +#define FONT_STYLE "Arial Black" +#define SCROLL_SPEED 2 + +#define SD_BLANK 0 // 0 = Blank +#define SD_EMERGENCY 1 // 1 = Emergency Shuttle timer +#define SD_MESSAGE 2 // 2 = Arbitrary message(s) +#define SD_PICTURE 3 // 3 = alert picture + +#define SD_AI_EMOTE 1 // 1 = AI emoticon +#define SD_AI_BSOD 2 // 2 = Blue screen of death + +/// Status display which can show images and scrolling text. +/obj/machinery/status_display + name = "status display" + desc = null + icon = 'icons/obj/status_display.dmi' + icon_state = "frame" + density = FALSE + use_power = IDLE_POWER_USE + idle_power_usage = 10 + + maptext_height = 26 + maptext_width = 32 + + var/message1 = "" // message line 1 + var/message2 = "" // message line 2 + var/index1 // display index for scrolling messages or 0 if non-scrolling + var/index2 + +/// Immediately blank the display. +/obj/machinery/status_display/proc/remove_display() + cut_overlays() + if(maptext) + maptext = "" + +/// Immediately change the display to the given picture. +/obj/machinery/status_display/proc/set_picture(state) + remove_display() + add_overlay(state) + +/// Immediately change the display to the given two lines. +/obj/machinery/status_display/proc/update_display(line1, line2) + var/new_text = {"
      [line1]
      [line2]
      "} + if(maptext != new_text) + maptext = new_text + +/// Prepare the display to marquee the given two lines. +/// +/// Call with no arguments to disable. +/obj/machinery/status_display/proc/set_message(m1, m2) + if(m1) + index1 = (length_char(m1) > CHARS_PER_LINE) + message1 = m1 + else + message1 = "" + index1 = 0 + + if(m2) + index2 = (length_char(m2) > CHARS_PER_LINE) + message2 = m2 + else + message2 = "" + index2 = 0 + +// Timed process - performs default marquee action if so needed. +/obj/machinery/status_display/process() + if(stat & NOPOWER) + // No power, no processing. + remove_display() + return PROCESS_KILL + + var/line1 = message1 + if(index1) + line1 = copytext_char("[message1]|[message1]", index1, index1+CHARS_PER_LINE) + var/message1_len = length_char(message1) + index1 += SCROLL_SPEED + if(index1 > message1_len + 1) + index1 -= (message1_len + 1) + + var/line2 = message2 + if(index2) + line2 = copytext_char("[message2]|[message2]", index2, index2+CHARS_PER_LINE) + var/message2_len = length(message2) + index2 += SCROLL_SPEED + if(index2 > message2_len + 1) + index2 -= (message2_len + 1) + + update_display(line1, line2) + if (!index1 && !index2) + // No marquee, no processing. + return PROCESS_KILL + +/// Update the display and, if necessary, re-enable processing. +/obj/machinery/status_display/proc/update() + if (process() != PROCESS_KILL) + START_PROCESSING(SSmachines, src) + +/obj/machinery/status_display/power_change() + . = ..() + update() + +/obj/machinery/status_display/emp_act(severity) + . = ..() + if(stat & (NOPOWER|BROKEN) || . & EMP_PROTECT_SELF) + return + set_picture("ai_bsod") + +/obj/machinery/status_display/examine(mob/user) + . = ..() + if (message1 || message2) + . += "The display says:" + if (message1) + . += "\t[html_encode(message1)]" + if (message2) + . += "\t[html_encode(message2)]" + +// Helper procs for child display types. +/obj/machinery/status_display/proc/display_shuttle_status(obj/docking_port/mobile/shuttle) + if(!shuttle) + // the shuttle is missing - no processing + update_display("shutl?","") + return PROCESS_KILL + else if(shuttle.timer) + var/line1 = "-[shuttle.getModeStr()]-" + var/line2 = shuttle.getTimerStr() + + if(length_char(line2) > CHARS_PER_LINE) + line2 = "error" + update_display(line1, line2) + else + // don't kill processing, the timer might turn back on + remove_display() + +/obj/machinery/status_display/proc/examine_shuttle(mob/user, obj/docking_port/mobile/shuttle) + if (shuttle) + var/modestr = shuttle.getModeStr() + if (modestr) + if (shuttle.timer) + modestr = "
      \t[modestr]: [shuttle.getTimerStr()]" + else + modestr = "
      \t[modestr]" + return "The display says:
      \t[shuttle.name][modestr]" + else + return "The display says:
      \tShuttle missing!" + + +/// Evac display which shows shuttle timer or message set by Command. +/obj/machinery/status_display/evac + var/frequency = FREQ_STATUS_DISPLAYS + var/mode = SD_EMERGENCY + var/friendc = FALSE // track if Friend Computer mode + var/last_picture // For when Friend Computer mode is undone + +/obj/machinery/status_display/evac/Initialize() + . = ..() + // register for radio system + SSradio.add_object(src, frequency) + +/obj/machinery/status_display/evac/Destroy() + SSradio.remove_object(src,frequency) + return ..() + +/obj/machinery/status_display/evac/process() + if(stat & NOPOWER) + // No power, no processing. + remove_display() + return PROCESS_KILL + + if(friendc) //Makes all status displays except supply shuttle timer display the eye -- Urist + set_picture("ai_friend") + return PROCESS_KILL + + switch(mode) + if(SD_BLANK) + remove_display() + return PROCESS_KILL + + if(SD_EMERGENCY) + return display_shuttle_status(SSshuttle.emergency) + + if(SD_MESSAGE) + return ..() + + if(SD_PICTURE) + set_picture(last_picture) + return PROCESS_KILL + +/obj/machinery/status_display/evac/examine(mob/user) + . = ..() + if(mode == SD_EMERGENCY) + . += examine_shuttle(user, SSshuttle.emergency) + else if(!message1 && !message2) + . += "The display is blank." + +/obj/machinery/status_display/evac/receive_signal(datum/signal/signal) + switch(signal.data["command"]) + if("blank") + mode = SD_BLANK + set_message(null, null) + if("shuttle") + mode = SD_EMERGENCY + set_message(null, null) + if("message") + mode = SD_MESSAGE + set_message(signal.data["msg1"], signal.data["msg2"]) + if("alert") + mode = SD_PICTURE + last_picture = signal.data["picture_state"] + set_picture(last_picture) + if("friendcomputer") + friendc = !friendc + update() + + +/// Supply display which shows the status of the supply shuttle. +/obj/machinery/status_display/supply + name = "supply display" + +/obj/machinery/status_display/supply/process() + if(stat & NOPOWER) + // No power, no processing. + remove_display() + return PROCESS_KILL + + var/line1 + var/line2 + if(!SSshuttle.supply) + // Might be missing in our first update on initialize before shuttles + // have loaded. Cross our fingers that it will soon return. + line1 = "CARGO" + line2 = "shutl?" + else if(SSshuttle.supply.mode == SHUTTLE_IDLE) + if(is_station_level(SSshuttle.supply.z)) + line1 = "CARGO" + line2 = "Docked" + else + line1 = "CARGO" + line2 = SSshuttle.supply.getTimerStr() + if(length_char(line2) > CHARS_PER_LINE) + line2 = "Error" + update_display(line1, line2) + +/obj/machinery/status_display/supply/examine(mob/user) + . = ..() + var/obj/docking_port/mobile/shuttle = SSshuttle.supply + var/shuttleMsg = null + if (shuttle.mode == SHUTTLE_IDLE) + if (is_station_level(shuttle.z)) + shuttleMsg = "Docked" + else + shuttleMsg = "[shuttle.getModeStr()]: [shuttle.getTimerStr()]" + if (shuttleMsg) + . += "The display says:
      \t[shuttleMsg]" + else + . += "The display is blank." + + +/// General-purpose shuttle status display. +/obj/machinery/status_display/shuttle + name = "shuttle display" + var/shuttle_id + +/obj/machinery/status_display/shuttle/process() + if(!shuttle_id || (stat & NOPOWER)) + // No power, no processing. + remove_display() + return PROCESS_KILL + + return display_shuttle_status(SSshuttle.getShuttle(shuttle_id)) + +/obj/machinery/status_display/shuttle/examine(mob/user) + . = ..() + if(shuttle_id) + . += examine_shuttle(user, SSshuttle.getShuttle(shuttle_id)) + else + . += "The display is blank." + +/obj/machinery/status_display/shuttle/vv_edit_var(var_name, var_value) + . = ..() + if(!.) + return + switch(var_name) + if("shuttle_id") + update() + +/obj/machinery/status_display/shuttle/proc/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock, idnum, override) + if (port && (shuttle_id == initial(shuttle_id) || override)) + shuttle_id = port.id + update() + + +/// Pictograph display which the AI can use to emote. +/obj/machinery/status_display/ai + name = "\improper AI display" + desc = "A small screen which the AI can use to present itself." + + var/mode = SD_BLANK + var/emotion = "Neutral" + +/obj/machinery/status_display/ai/Initialize() + . = ..() + GLOB.ai_status_displays.Add(src) + +/obj/machinery/status_display/ai/Destroy() + GLOB.ai_status_displays.Remove(src) + . = ..() + +/obj/machinery/status_display/ai/attack_ai(mob/living/silicon/ai/user) + if(isAI(user)) + user.ai_statuschange() + +/obj/machinery/status_display/ai/process() + if(mode == SD_BLANK || (stat & NOPOWER)) + remove_display() + return PROCESS_KILL + + if(mode == SD_AI_EMOTE) + switch(emotion) + if("Very Happy") + set_picture("ai_veryhappy") + if("Happy") + set_picture("ai_happy") + if("Neutral") + set_picture("ai_neutral") + if("Unsure") + set_picture("ai_unsure") + if("Confused") + set_picture("ai_confused") + if("Sad") + set_picture("ai_sad") + if("BSOD") + set_picture("ai_bsod") + if("Blank") + set_picture("ai_off") + if("Problems?") + set_picture("ai_trollface") + if("Awesome") + set_picture("ai_awesome") + if("Dorfy") + set_picture("ai_urist") + if("Thinking") + set_picture("ai_thinking") + if("Facepalm") + set_picture("ai_facepalm") + if("Friend Computer") + set_picture("ai_friend") + if("Blue Glow") + set_picture("ai_sal") + if("Red Glow") + set_picture("ai_hal") + return PROCESS_KILL + + if(mode == SD_AI_BSOD) + set_picture("ai_bsod") + return PROCESS_KILL + + +#undef CHARS_PER_LINE +#undef FONT_SIZE +#undef FONT_COLOR +#undef FONT_STYLE +#undef SCROLL_SPEED diff --git a/code/game/machinery/telecomms/broadcasting.dm b/code/game/machinery/telecomms/broadcasting.dm index 0771963b..4e3e11d1 100644 --- a/code/game/machinery/telecomms/broadcasting.dm +++ b/code/game/machinery/telecomms/broadcasting.dm @@ -132,7 +132,7 @@ set waitfor = FALSE // Perform final composition steps on the message. - var/message = copytext(data["message"], 1, MAX_BROADCAST_LEN) + var/message = copytext_char(data["message"], 1, MAX_BROADCAST_LEN) if(!message) return var/compression = data["compression"] diff --git a/code/game/machinery/telecomms/machine_interactions.dm b/code/game/machinery/telecomms/machine_interactions.dm index 1ad80ccb..8cd8b479 100644 --- a/code/game/machinery/telecomms/machine_interactions.dm +++ b/code/game/machinery/telecomms/machine_interactions.dm @@ -179,7 +179,7 @@ if("id") - var/newid = copytext(reject_bad_text(input(usr, "Specify the new ID for this machine", src, id) as null|text),1,MAX_MESSAGE_LEN) + var/newid = reject_bad_text(stripped_input(usr, "Specify the new ID for this machine", src, id, MAX_MESSAGE_LEN)) if(newid && canAccess(usr)) id = newid temp = "-% New ID assigned: \"[id]\" %-" diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm index 33282afb..f28bd629 100644 --- a/code/game/mecha/mech_fabricator.dm +++ b/code/game/mecha/mech_fabricator.dm @@ -441,7 +441,7 @@ return ..() /obj/machinery/mecha_part_fabricator/proc/material2name(ID) - return copytext(ID,2) + return copytext_char(ID,2) /obj/machinery/mecha_part_fabricator/proc/is_insertion_ready(mob/user) if(panel_open) diff --git a/code/game/mecha/mecha_topic.dm b/code/game/mecha/mecha_topic.dm index f087c67f..5a9a92bf 100644 --- a/code/game/mecha/mecha_topic.dm +++ b/code/game/mecha/mecha_topic.dm @@ -299,11 +299,11 @@ onclose(occupant, "exosuit_log") if (href_list["change_name"]) - var/newname = stripped_input(occupant,"Choose new exosuit name","Rename exosuit","", MAX_NAME_LEN) - if(newname && trim(newname)) - name = newname - else - alert(occupant, "nope.avi") + var/userinput = stripped_input(occupant,"Choose new exosuit name","Rename exosuit","", MAX_NAME_LEN) + if(!userinput || usr != occupant || usr.incapacitated()) + return + name = userinput + return if (href_list["toggle_id_upload"]) add_req_access = !add_req_access diff --git a/code/game/objects/effects/contraband.dm b/code/game/objects/effects/contraband.dm index 4c434b1f..e1a9a416 100644 --- a/code/game/objects/effects/contraband.dm +++ b/code/game/objects/effects/contraband.dm @@ -128,7 +128,7 @@ if (smooth & SMOOTH_DIAGONAL) for (var/O in overlays) var/image/I = O - if (copytext(I.icon_state, 1, 3) == "d-") + if(copytext(I.icon_state, 1, 3) == "d-") //3 == length("d-") + 1 return var/stuff_on_wall = 0 diff --git a/code/game/objects/items/cards_ids.dm b/code/game/objects/items/cards_ids.dm index b8cdb224..823bd380 100644 --- a/code/game/objects/items/cards_ids.dm +++ b/code/game/objects/items/cards_ids.dm @@ -1,562 +1,559 @@ -/* Cards - * Contains: - * DATA CARD - * ID CARD - * FINGERPRINT CARD HOLDER - * FINGERPRINT CARD - */ - - - -/* - * DATA CARDS - Used for the IC data card reader - */ -/obj/item/card - name = "card" - desc = "Does card things." - icon = 'icons/obj/card.dmi' - w_class = WEIGHT_CLASS_TINY - - var/list/files = list() - -/obj/item/card/suicide_act(mob/living/carbon/user) - user.visible_message("[user] begins to swipe [user.p_their()] neck with \the [src]! It looks like [user.p_theyre()] trying to commit suicide!") - return BRUTELOSS - -/obj/item/card/data - name = "data card" - desc = "A plastic magstripe card for simple and speedy data storage and transfer. This one has a stripe running down the middle." - icon_state = "data_1" - obj_flags = UNIQUE_RENAME - var/function = "storage" - var/data = "null" - var/special = null - item_state = "card-id" - lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' - var/detail_color = COLOR_ASSEMBLY_ORANGE - -/obj/item/card/data/Initialize() - .=..() - update_icon() - -/obj/item/card/data/update_icon() - cut_overlays() - if(detail_color == COLOR_FLOORTILE_GRAY) - return - var/mutable_appearance/detail_overlay = mutable_appearance('icons/obj/card.dmi', "[icon_state]-color") - detail_overlay.color = detail_color - add_overlay(detail_overlay) - -/obj/item/card/data/attackby(obj/item/I, mob/living/user) - if(istype(I, /obj/item/integrated_electronics/detailer)) - var/obj/item/integrated_electronics/detailer/D = I - detail_color = D.detail_color - update_icon() - return ..() - -/obj/item/proc/GetCard() - -/obj/item/card/data/GetCard() - return src - -/obj/item/card/data/full_color - desc = "A plastic magstripe card for simple and speedy data storage and transfer. This one has the entire card colored." - icon_state = "data_2" - -/obj/item/card/data/disk - desc = "A plastic magstripe card for simple and speedy data storage and transfer. This one inexplicibly looks like a floppy disk." - icon_state = "data_3" - -/* - * ID CARDS - */ -/obj/item/card/emag - desc = "It's a card with a magnetic strip attached to some circuitry." - name = "cryptographic sequencer" - icon_state = "emag" - item_state = "card-id" - lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' - item_flags = NO_MAT_REDEMPTION | NOBLUDGEON - var/prox_check = TRUE //If the emag requires you to be in range - var/uses = 10 - -/obj/item/card/emag/bluespace - name = "bluespace cryptographic sequencer" - desc = "It's a blue card with a magnetic strip attached to some circuitry. It appears to have some sort of transmitter attached to it." - color = rgb(40, 130, 255) - prox_check = FALSE - -/obj/item/card/emag/attack() - return - -/obj/item/card/emag/afterattack(atom/target, mob/user, proximity) - . = ..() - var/atom/A = target - if(!proximity && prox_check || !(isobj(A) || issilicon(A) || isbot(A) || isdrone(A))) - return - if(istype(A, /obj/item/storage) && !(istype(A, /obj/item/storage/lockbox) || istype(A, /obj/item/storage/pod))) - return - if(!uses) - user.visible_message("[src] emits a weak spark. It's burnt out!") - playsound(src, 'sound/effects/light_flicker.ogg', 100, 1) - return - else if(uses <= 3) - playsound(src, 'sound/effects/light_flicker.ogg', 30, 1) //Tiiiiiiny warning sound to let ya know your emag's almost dead - if(!A.emag_act(user)) - return - uses = max(uses - 1, 0) - if(!uses) - user.visible_message("[src] fizzles and sparks. It seems like it's out of charges.") - playsound(src, 'sound/effects/light_flicker.ogg', 100, 1) - -/obj/item/card/emag/examine(mob/user) - . = ..() - . += "It has [uses ? uses : "no"] charges left." - -/obj/item/card/emag/attackby(obj/item/W, mob/user, params) - if(istype(W, /obj/item/emagrecharge)) - var/obj/item/emagrecharge/ER = W - if(ER.uses) - uses += ER.uses - to_chat(user, "You have added [ER.uses] charges to [src]. It now has [uses] charges.") - playsound(src, "sparks", 100, 1) - ER.uses = 0 - else - to_chat(user, "[ER] has no charges left.") - return - . = ..() - -/obj/item/emagrecharge - name = "electromagnet charging device" - desc = "A small cell with two prongs lazily jabbed into it. It looks like it's made for charging the small batteries found in electromagnetic devices, sadly this can't be recharged like a normal cell." - icon = 'icons/obj/module.dmi' - icon_state = "cell_mini" - item_flags = NOBLUDGEON - var/uses = 5 //Dictates how many charges the device adds to compatible items - -/obj/item/emagrecharge/examine(mob/user) - . = ..() - if(uses) - . += "It can add up to [uses] charges to compatible devices" - else - . += "It has a small, red, blinking light coming from inside of it. It's spent." - -/obj/item/card/emagfake - desc = "It's a card with a magnetic strip attached to some circuitry. Closer inspection shows that this card is a poorly made replica, with a \"DonkCo\" logo stamped on the back." - name = "cryptographic sequencer" - icon_state = "emag" - item_state = "card-id" - lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' - -/obj/item/card/emagfake/afterattack() - . = ..() - playsound(src, 'sound/items/bikehorn.ogg', 50, 1) - -/obj/item/card/id - name = "identification card" - desc = "A card used to provide ID and determine access across the station." - icon_state = "id" - item_state = "card-id" - lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' - slot_flags = ITEM_SLOT_ID - armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 100) - resistance_flags = FIRE_PROOF | ACID_PROOF - var/mining_points = 0 //For redeeming at mining equipment vendors - var/list/access = list() - var/registered_name = null // The name registered_name on the card - var/assignment = null - var/access_txt // mapping aid - - - -/obj/item/card/id/Initialize(mapload) - . = ..() - if(mapload && access_txt) - access = text2access(access_txt) - -/obj/item/card/id/vv_edit_var(var_name, var_value) - . = ..() - if(.) - switch(var_name) - if("assignment","registered_name") - update_label() - -/obj/item/card/id/attack_self(mob/user) - if(Adjacent(user)) - user.visible_message("[user] shows you: [icon2html(src, viewers(user))] [src.name].", \ - "You show \the [src.name].") - add_fingerprint(user) - return - -/obj/item/card/id/examine(mob/user) - . = ..() - if(mining_points) - . += "There's [mining_points] mining equipment redemption point\s loaded onto this card." - -/obj/item/card/id/GetAccess() - return access - -/obj/item/card/id/GetID() - return src - -/obj/item/card/id/RemoveID() - return src - -/* -Usage: -update_label() - Sets the id name to whatever registered_name and assignment is - -update_label("John Doe", "Clowny") - Properly formats the name and occupation and sets the id name to the arguments -*/ -/obj/item/card/id/proc/update_label(newname, newjob) - if(newname || newjob) - name = "[(!newname) ? "identification card" : "[newname]'s ID Card"][(!newjob) ? "" : " ([newjob])"]" - return - - name = "[(!registered_name) ? "identification card" : "[registered_name]'s ID Card"][(!assignment) ? "" : " ([assignment])"]" - -/obj/item/card/id/silver - name = "silver identification card" - desc = "A silver card which shows honour and dedication." - icon_state = "silver" - item_state = "silver_id" - lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' - -/obj/item/card/id/silver/reaper - name = "Thirteen's ID Card (Reaper)" - access = list(ACCESS_MAINT_TUNNELS) - assignment = "Reaper" - registered_name = "Thirteen" - -/obj/item/card/id/gold - name = "gold identification card" - desc = "A golden card which shows power and might." - icon_state = "gold" - item_state = "gold_id" - lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' - -/obj/item/card/id/syndicate - name = "agent card" - access = list(ACCESS_MAINT_TUNNELS, ACCESS_SYNDICATE) - var/anyone = FALSE //Can anyone forge the ID or just syndicate? - -/obj/item/card/id/syndicate/Initialize() - . = ..() - var/datum/action/item_action/chameleon/change/chameleon_action = new(src) - chameleon_action.chameleon_type = /obj/item/card/id - chameleon_action.chameleon_name = "ID Card" - chameleon_action.initialize_disguises() - -/obj/item/card/id/syndicate/afterattack(obj/item/O, mob/user, proximity) - if(!proximity) - return - if(istype(O, /obj/item/card/id)) - var/obj/item/card/id/I = O - src.access |= I.access - if(isliving(user) && user.mind) - if(user.mind.special_role) - to_chat(usr, "The card's microscanners activate as you pass it over the ID, copying its access.") - -/obj/item/card/id/syndicate/attack_self(mob/user) - if(isliving(user) && user.mind) - if(user.mind.special_role || anyone) - if(alert(user, "Action", "Agent ID", "Show", "Forge") == "Forge") - var/t = copytext(sanitize(input(user, "What name would you like to put on this card?", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name))as text | null),1,26) - if(!t || t == "Unknown" || t == "floor" || t == "wall" || t == "r-wall") //Same as mob/dead/new_player/prefrences.dm - if (t) - alert("Invalid name.") - return - registered_name = t - - var/u = copytext(sanitize(input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", "Assistant")as text | null),1,MAX_MESSAGE_LEN) - if(!u) - registered_name = "" - return - assignment = u - update_label() - to_chat(user, "You successfully forge the ID card.") - return - ..() - -/obj/item/card/id/syndicate/anyone - anyone = TRUE - -/obj/item/card/id/syndicate/nuke_leader - name = "lead agent card" - access = list(ACCESS_MAINT_TUNNELS, ACCESS_SYNDICATE, ACCESS_SYNDICATE_LEADER) - -/obj/item/card/id/syndicate_command - name = "syndicate ID card" - desc = "An ID straight from the Syndicate." - registered_name = "Syndicate" - assignment = "Syndicate Overlord" - access = list(ACCESS_SYNDICATE) - -/obj/item/card/id/captains_spare - name = "captain's spare ID" - desc = "The spare ID of the High Lord himself." - icon_state = "gold" - item_state = "gold_id" - lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' - registered_name = "Captain" - assignment = "Captain" - -/obj/item/card/id/captains_spare/Initialize() - var/datum/job/captain/J = new/datum/job/captain - access = J.get_access() - . = ..() - -/obj/item/card/id/centcom - name = "\improper CentCom ID" - desc = "An ID straight from Central Command." - icon_state = "centcom" - registered_name = "Central Command" - assignment = "General" - -/obj/item/card/id/centcom/Initialize() - access = get_all_centcom_access() - . = ..() - -/obj/item/card/id/ert - name = "\improper CentCom ID" - desc = "An ERT ID card." - icon_state = "centcom" - registered_name = "Emergency Response Team Commander" - assignment = "Emergency Response Team Commander" - -/obj/item/card/id/ert/Initialize() - access = get_all_accesses()+get_ert_access("commander")-ACCESS_CHANGE_IDS - . = ..() - -/obj/item/card/id/ert/Security - registered_name = "Security Response Officer" - assignment = "Security Response Officer" - -/obj/item/card/id/ert/Security/Initialize() - access = get_all_accesses()+get_ert_access("sec")-ACCESS_CHANGE_IDS - . = ..() - -/obj/item/card/id/ert/Engineer - registered_name = "Engineer Response Officer" - assignment = "Engineer Response Officer" - -/obj/item/card/id/ert/Engineer/Initialize() - access = get_all_accesses()+get_ert_access("eng")-ACCESS_CHANGE_IDS - . = ..() - -/obj/item/card/id/ert/Medical - registered_name = "Medical Response Officer" - assignment = "Medical Response Officer" - -/obj/item/card/id/ert/Medical/Initialize() - access = get_all_accesses()+get_ert_access("med")-ACCESS_CHANGE_IDS - . = ..() - -/obj/item/card/id/ert/chaplain - registered_name = "Religious Response Officer" - assignment = "Religious Response Officer" - -/obj/item/card/id/ert/chaplain/Initialize() - access = get_all_accesses()+get_ert_access("sec")-ACCESS_CHANGE_IDS - . = ..() - -/obj/item/card/id/prisoner - name = "prisoner ID card" - desc = "You are a number, you are not a free man." - icon_state = "orange" - item_state = "orange-id" - lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' - assignment = "Prisoner" - access = list(ACCESS_ENTER_GENPOP) - - //Lavaland labor camp - var/goal = 0 //How far from freedom? - var/points = 0 - //Genpop - var/sentence = 0 //When world.time is greater than this number, the card will have its ACCESS_ENTER_GENPOP access replaced with ACCESS_LEAVE_GENPOP the next time it's checked, unless this value is 0/null - var/crime= "\[REDACTED\]" - -/obj/item/card/id/prisoner/GetAccess() - if((sentence && world.time >= sentence) || (goal && points >= goal)) - access = list(ACCESS_LEAVE_GENPOP) - return ..() - -/obj/item/card/id/prisoner/process() - if(!sentence) - STOP_PROCESSING(SSobj, src) - return - if(world.time >= sentence) - playsound(loc, 'sound/machines/ping.ogg', 50, 1) - if(isliving(loc)) - to_chat(loc, "[src] buzzes: You have served your sentence! You may now exit prison through the turnstiles and collect your belongings.") - STOP_PROCESSING(SSobj, src) - return - -/obj/item/card/id/prisoner/examine(mob/user) - . = ..() - if(sentence && world.time < sentence) - . += "You're currently serving a sentence for [crime]. [DisplayTimeText(sentence - world.time)] left." - else if(goal) - . += "You have accumulated [points] out of the [goal] points you need for freedom." - else if(!sentence) - . += "You are currently serving a permanent sentence for [crime]." - else - . += "Your sentence is up! You're free!" - -/obj/item/card/id/prisoner/one - name = "Prisoner #13-001" - registered_name = "Prisoner #13-001" - -/obj/item/card/id/prisoner/two - name = "Prisoner #13-002" - registered_name = "Prisoner #13-002" - -/obj/item/card/id/prisoner/three - name = "Prisoner #13-003" - registered_name = "Prisoner #13-003" - -/obj/item/card/id/prisoner/four - name = "Prisoner #13-004" - registered_name = "Prisoner #13-004" - -/obj/item/card/id/prisoner/five - name = "Prisoner #13-005" - registered_name = "Prisoner #13-005" - -/obj/item/card/id/prisoner/six - name = "Prisoner #13-006" - registered_name = "Prisoner #13-006" - -/obj/item/card/id/prisoner/seven - name = "Prisoner #13-007" - registered_name = "Prisoner #13-007" - -/obj/item/card/id/mining - name = "mining ID" - access = list(ACCESS_MINING, ACCESS_MINING_STATION, ACCESS_MAILSORTING, ACCESS_MINERAL_STOREROOM) - -/obj/item/card/id/away - name = "a perfectly generic identification card" - desc = "A perfectly generic identification card. Looks like it could use some flavor." - access = list(ACCESS_AWAY_GENERAL) - -/obj/item/card/id/away/hotel - name = "Staff ID" - desc = "A staff ID used to access the hotel's doors." - access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_MAINT) - -/obj/item/card/id/away/hotel/securty - name = "Officer ID" - access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_MAINT, ACCESS_AWAY_SEC) - -/obj/item/card/id/away/old - name = "a perfectly generic identification card" - desc = "A perfectly generic identification card. Looks like it could use some flavor." - icon_state = "centcom" - -/obj/item/card/id/away/old/sec - name = "Charlie Station Security Officer's ID card" - desc = "A faded Charlie Station ID card. You can make out the rank \"Security Officer\"." - assignment = "Charlie Station Security Officer" - access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_SEC) - -/obj/item/card/id/away/old/sci - name = "Charlie Station Scientist's ID card" - desc = "A faded Charlie Station ID card. You can make out the rank \"Scientist\"." - assignment = "Charlie Station Scientist" - access = list(ACCESS_AWAY_GENERAL) - -/obj/item/card/id/away/old/eng - name = "Charlie Station Engineer's ID card" - desc = "A faded Charlie Station ID card. You can make out the rank \"Station Engineer\"." - assignment = "Charlie Station Engineer" - access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_ENGINE) - -/obj/item/card/id/away/old/apc - name = "APC Access ID" - desc = "A special ID card that allows access to APC terminals." - access = list(ACCESS_ENGINE_EQUIP) - -//Polychromatic Knight Badge - -/obj/item/card/id/knight - var/id_color = "#00FF00" //defaults to green - name = "knight badge" - icon_state = "knight" - desc = "A badge denoting the owner as a knight! It has a strip for swiping like an ID" - -/obj/item/card/id/knight/update_label(newname, newjob) - if(newname || newjob) - name = "[(!newname) ? "knight badge" : "[newname]'s Knight Badge"][(!newjob) ? "" : " ([newjob])"]" - return - - name = "[(!registered_name) ? "knight badge" : "[registered_name]'s Knight Badge"][(!assignment) ? "" : " ([assignment])"]" - -/obj/item/card/id/knight/update_icon() - var/mutable_appearance/id_overlay = mutable_appearance(icon, "knight_overlay") - - if(id_color) - id_overlay.color = id_color - cut_overlays() - - add_overlay(id_overlay) - -/obj/item/card/id/knight/AltClick(mob/living/user) - . = ..() - if(!in_range(src, user)) //Basic checks to prevent abuse - return - if(user.incapacitated() || !istype(user)) - to_chat(user, "You can't do that right now!") - return TRUE - if(alert("Are you sure you want to recolor your id?", "Confirm Repaint", "Yes", "No") == "Yes") - var/energy_color_input = input(usr,"","Choose Energy Color",id_color) as color|null - if(!in_range(src, user) || !energy_color_input) - return TRUE - if(user.incapacitated() || !istype(user)) - to_chat(user, "You can't do that right now!") - return TRUE - id_color = sanitize_hexcolor(energy_color_input, desired_format=6, include_crunch=1) - update_icon() - return TRUE - -/obj/item/card/id/knight/Initialize() - . = ..() - update_icon() - -/obj/item/card/id/knight/examine(mob/user) - . = ..() - . += "Alt-click to recolor it." - -/obj/item/card/id/knight/blue - id_color = "#0000FF" - -/obj/item/card/id/knight/captain - id_color = "#FFD700" - -/obj/item/card/id/away/snowdin/eng - name = "Arctic Station Engineer's ID card" - desc = "A faded Arctic Station ID card. You can make out the rank \"Station Engineer\"." - assignment = "Arctic Station Engineer" - access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_ENGINE, ACCESS_AWAY_MAINT) - -/obj/item/card/id/away/snowdin/sci - name = "Arctic Station Scientist's ID card" - desc = "A faded Arctic Station ID card. You can make out the rank \"Scientist\"." - assignment = "Arctic Station Scientist" - access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_MAINT) - -/obj/item/card/id/away/snowdin/med - name = "Arctic Station Doctor's ID card" - desc = "A faded Arctic Station ID card. You can make out the rank \"Doctor\"." - assignment = "Arctic Station Doctor" - access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_MED, ACCESS_AWAY_MAINT) +/* Cards + * Contains: + * DATA CARD + * ID CARD + * FINGERPRINT CARD HOLDER + * FINGERPRINT CARD + */ + + + +/* + * DATA CARDS - Used for the IC data card reader + */ +/obj/item/card + name = "card" + desc = "Does card things." + icon = 'icons/obj/card.dmi' + w_class = WEIGHT_CLASS_TINY + + var/list/files = list() + +/obj/item/card/suicide_act(mob/living/carbon/user) + user.visible_message("[user] begins to swipe [user.p_their()] neck with \the [src]! It looks like [user.p_theyre()] trying to commit suicide!") + return BRUTELOSS + +/obj/item/card/data + name = "data card" + desc = "A plastic magstripe card for simple and speedy data storage and transfer. This one has a stripe running down the middle." + icon_state = "data_1" + obj_flags = UNIQUE_RENAME + var/function = "storage" + var/data = "null" + var/special = null + item_state = "card-id" + lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' + var/detail_color = COLOR_ASSEMBLY_ORANGE + +/obj/item/card/data/Initialize() + .=..() + update_icon() + +/obj/item/card/data/update_icon() + cut_overlays() + if(detail_color == COLOR_FLOORTILE_GRAY) + return + var/mutable_appearance/detail_overlay = mutable_appearance('icons/obj/card.dmi', "[icon_state]-color") + detail_overlay.color = detail_color + add_overlay(detail_overlay) + +/obj/item/card/data/attackby(obj/item/I, mob/living/user) + if(istype(I, /obj/item/integrated_electronics/detailer)) + var/obj/item/integrated_electronics/detailer/D = I + detail_color = D.detail_color + update_icon() + return ..() + +/obj/item/proc/GetCard() + +/obj/item/card/data/GetCard() + return src + +/obj/item/card/data/full_color + desc = "A plastic magstripe card for simple and speedy data storage and transfer. This one has the entire card colored." + icon_state = "data_2" + +/obj/item/card/data/disk + desc = "A plastic magstripe card for simple and speedy data storage and transfer. This one inexplicibly looks like a floppy disk." + icon_state = "data_3" + +/* + * ID CARDS + */ +/obj/item/card/emag + desc = "It's a card with a magnetic strip attached to some circuitry." + name = "cryptographic sequencer" + icon_state = "emag" + item_state = "card-id" + lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' + item_flags = NO_MAT_REDEMPTION | NOBLUDGEON + var/prox_check = TRUE //If the emag requires you to be in range + var/uses = 10 + +/obj/item/card/emag/bluespace + name = "bluespace cryptographic sequencer" + desc = "It's a blue card with a magnetic strip attached to some circuitry. It appears to have some sort of transmitter attached to it." + color = rgb(40, 130, 255) + prox_check = FALSE + +/obj/item/card/emag/attack() + return + +/obj/item/card/emag/afterattack(atom/target, mob/user, proximity) + . = ..() + var/atom/A = target + if(!proximity && prox_check || !(isobj(A) || issilicon(A) || isbot(A) || isdrone(A))) + return + if(istype(A, /obj/item/storage) && !(istype(A, /obj/item/storage/lockbox) || istype(A, /obj/item/storage/pod))) + return + if(!uses) + user.visible_message("[src] emits a weak spark. It's burnt out!") + playsound(src, 'sound/effects/light_flicker.ogg', 100, 1) + return + else if(uses <= 3) + playsound(src, 'sound/effects/light_flicker.ogg', 30, 1) //Tiiiiiiny warning sound to let ya know your emag's almost dead + if(!A.emag_act(user)) + return + uses = max(uses - 1, 0) + if(!uses) + user.visible_message("[src] fizzles and sparks. It seems like it's out of charges.") + playsound(src, 'sound/effects/light_flicker.ogg', 100, 1) + +/obj/item/card/emag/examine(mob/user) + . = ..() + . += "It has [uses ? uses : "no"] charges left." + +/obj/item/card/emag/attackby(obj/item/W, mob/user, params) + if(istype(W, /obj/item/emagrecharge)) + var/obj/item/emagrecharge/ER = W + if(ER.uses) + uses += ER.uses + to_chat(user, "You have added [ER.uses] charges to [src]. It now has [uses] charges.") + playsound(src, "sparks", 100, 1) + ER.uses = 0 + else + to_chat(user, "[ER] has no charges left.") + return + . = ..() + +/obj/item/emagrecharge + name = "electromagnet charging device" + desc = "A small cell with two prongs lazily jabbed into it. It looks like it's made for charging the small batteries found in electromagnetic devices, sadly this can't be recharged like a normal cell." + icon = 'icons/obj/module.dmi' + icon_state = "cell_mini" + item_flags = NOBLUDGEON + var/uses = 5 //Dictates how many charges the device adds to compatible items + +/obj/item/emagrecharge/examine(mob/user) + . = ..() + if(uses) + . += "It can add up to [uses] charges to compatible devices" + else + . += "It has a small, red, blinking light coming from inside of it. It's spent." + +/obj/item/card/emagfake + desc = "It's a card with a magnetic strip attached to some circuitry. Closer inspection shows that this card is a poorly made replica, with a \"DonkCo\" logo stamped on the back." + name = "cryptographic sequencer" + icon_state = "emag" + item_state = "card-id" + lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' + +/obj/item/card/emagfake/afterattack() + . = ..() + playsound(src, 'sound/items/bikehorn.ogg', 50, 1) + +/obj/item/card/id + name = "identification card" + desc = "A card used to provide ID and determine access across the station." + icon_state = "id" + item_state = "card-id" + lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' + slot_flags = ITEM_SLOT_ID + armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 100) + resistance_flags = FIRE_PROOF | ACID_PROOF + var/mining_points = 0 //For redeeming at mining equipment vendors + var/list/access = list() + var/registered_name = null // The name registered_name on the card + var/assignment = null + var/access_txt // mapping aid + + + +/obj/item/card/id/Initialize(mapload) + . = ..() + if(mapload && access_txt) + access = text2access(access_txt) + +/obj/item/card/id/vv_edit_var(var_name, var_value) + . = ..() + if(.) + switch(var_name) + if("assignment","registered_name") + update_label() + +/obj/item/card/id/attack_self(mob/user) + if(Adjacent(user)) + user.visible_message("[user] shows you: [icon2html(src, viewers(user))] [src.name].", \ + "You show \the [src.name].") + add_fingerprint(user) + return + +/obj/item/card/id/examine(mob/user) + . = ..() + if(mining_points) + . += "There's [mining_points] mining equipment redemption point\s loaded onto this card." + +/obj/item/card/id/GetAccess() + return access + +/obj/item/card/id/GetID() + return src + +/obj/item/card/id/RemoveID() + return src + +/* +Usage: +update_label() + Sets the id name to whatever registered_name and assignment is + +update_label("John Doe", "Clowny") + Properly formats the name and occupation and sets the id name to the arguments +*/ +/obj/item/card/id/proc/update_label(newname, newjob) + if(newname || newjob) + name = "[(!newname) ? "identification card" : "[newname]'s ID Card"][(!newjob) ? "" : " ([newjob])"]" + return + + name = "[(!registered_name) ? "identification card" : "[registered_name]'s ID Card"][(!assignment) ? "" : " ([assignment])"]" + +/obj/item/card/id/silver + name = "silver identification card" + desc = "A silver card which shows honour and dedication." + icon_state = "silver" + item_state = "silver_id" + lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' + +/obj/item/card/id/silver/reaper + name = "Thirteen's ID Card (Reaper)" + access = list(ACCESS_MAINT_TUNNELS) + assignment = "Reaper" + registered_name = "Thirteen" + +/obj/item/card/id/gold + name = "gold identification card" + desc = "A golden card which shows power and might." + icon_state = "gold" + item_state = "gold_id" + lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' + +/obj/item/card/id/syndicate + name = "agent card" + access = list(ACCESS_MAINT_TUNNELS, ACCESS_SYNDICATE) + var/anyone = FALSE //Can anyone forge the ID or just syndicate? + +/obj/item/card/id/syndicate/Initialize() + . = ..() + var/datum/action/item_action/chameleon/change/chameleon_action = new(src) + chameleon_action.chameleon_type = /obj/item/card/id + chameleon_action.chameleon_name = "ID Card" + chameleon_action.initialize_disguises() + +/obj/item/card/id/syndicate/afterattack(obj/item/O, mob/user, proximity) + if(!proximity) + return + if(istype(O, /obj/item/card/id)) + var/obj/item/card/id/I = O + src.access |= I.access + if(isliving(user) && user.mind) + if(user.mind.special_role) + to_chat(usr, "The card's microscanners activate as you pass it over the ID, copying its access.") + +/obj/item/card/id/syndicate/attack_self(mob/user) + if(isliving(user) && user.mind) + if(user.mind.special_role || anyone) + if(alert(user, "Action", "Agent ID", "Show", "Forge") == "Forge") + var/input_name = reject_bad_name(stripped_input(user, "What name would you like to put on this card?", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name), MAX_NAME_LEN), TRUE) + if(!input_name) + return + + var/u = stripped_input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", "Assistant", MAX_MESSAGE_LEN) + if(!u) + registered_name = "" + return + assignment = u + update_label() + to_chat(user, "You successfully forge the ID card.") + return + ..() + +/obj/item/card/id/syndicate/anyone + anyone = TRUE + +/obj/item/card/id/syndicate/nuke_leader + name = "lead agent card" + access = list(ACCESS_MAINT_TUNNELS, ACCESS_SYNDICATE, ACCESS_SYNDICATE_LEADER) + +/obj/item/card/id/syndicate_command + name = "syndicate ID card" + desc = "An ID straight from the Syndicate." + registered_name = "Syndicate" + assignment = "Syndicate Overlord" + access = list(ACCESS_SYNDICATE) + +/obj/item/card/id/captains_spare + name = "captain's spare ID" + desc = "The spare ID of the High Lord himself." + icon_state = "gold" + item_state = "gold_id" + lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' + registered_name = "Captain" + assignment = "Captain" + +/obj/item/card/id/captains_spare/Initialize() + var/datum/job/captain/J = new/datum/job/captain + access = J.get_access() + . = ..() + +/obj/item/card/id/centcom + name = "\improper CentCom ID" + desc = "An ID straight from Central Command." + icon_state = "centcom" + registered_name = "Central Command" + assignment = "General" + +/obj/item/card/id/centcom/Initialize() + access = get_all_centcom_access() + . = ..() + +/obj/item/card/id/ert + name = "\improper CentCom ID" + desc = "An ERT ID card." + icon_state = "centcom" + registered_name = "Emergency Response Team Commander" + assignment = "Emergency Response Team Commander" + +/obj/item/card/id/ert/Initialize() + access = get_all_accesses()+get_ert_access("commander")-ACCESS_CHANGE_IDS + . = ..() + +/obj/item/card/id/ert/Security + registered_name = "Security Response Officer" + assignment = "Security Response Officer" + +/obj/item/card/id/ert/Security/Initialize() + access = get_all_accesses()+get_ert_access("sec")-ACCESS_CHANGE_IDS + . = ..() + +/obj/item/card/id/ert/Engineer + registered_name = "Engineer Response Officer" + assignment = "Engineer Response Officer" + +/obj/item/card/id/ert/Engineer/Initialize() + access = get_all_accesses()+get_ert_access("eng")-ACCESS_CHANGE_IDS + . = ..() + +/obj/item/card/id/ert/Medical + registered_name = "Medical Response Officer" + assignment = "Medical Response Officer" + +/obj/item/card/id/ert/Medical/Initialize() + access = get_all_accesses()+get_ert_access("med")-ACCESS_CHANGE_IDS + . = ..() + +/obj/item/card/id/ert/chaplain + registered_name = "Religious Response Officer" + assignment = "Religious Response Officer" + +/obj/item/card/id/ert/chaplain/Initialize() + access = get_all_accesses()+get_ert_access("sec")-ACCESS_CHANGE_IDS + . = ..() + +/obj/item/card/id/prisoner + name = "prisoner ID card" + desc = "You are a number, you are not a free man." + icon_state = "orange" + item_state = "orange-id" + lefthand_file = 'icons/mob/inhands/equipment/idcards_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/idcards_righthand.dmi' + assignment = "Prisoner" + access = list(ACCESS_ENTER_GENPOP) + + //Lavaland labor camp + var/goal = 0 //How far from freedom? + var/points = 0 + //Genpop + var/sentence = 0 //When world.time is greater than this number, the card will have its ACCESS_ENTER_GENPOP access replaced with ACCESS_LEAVE_GENPOP the next time it's checked, unless this value is 0/null + var/crime= "\[REDACTED\]" + +/obj/item/card/id/prisoner/GetAccess() + if((sentence && world.time >= sentence) || (goal && points >= goal)) + access = list(ACCESS_LEAVE_GENPOP) + return ..() + +/obj/item/card/id/prisoner/process() + if(!sentence) + STOP_PROCESSING(SSobj, src) + return + if(world.time >= sentence) + playsound(loc, 'sound/machines/ping.ogg', 50, 1) + if(isliving(loc)) + to_chat(loc, "[src] buzzes: You have served your sentence! You may now exit prison through the turnstiles and collect your belongings.") + STOP_PROCESSING(SSobj, src) + return + +/obj/item/card/id/prisoner/examine(mob/user) + . = ..() + if(sentence && world.time < sentence) + . += "You're currently serving a sentence for [crime]. [DisplayTimeText(sentence - world.time)] left." + else if(goal) + . += "You have accumulated [points] out of the [goal] points you need for freedom." + else if(!sentence) + . += "You are currently serving a permanent sentence for [crime]." + else + . += "Your sentence is up! You're free!" + +/obj/item/card/id/prisoner/one + name = "Prisoner #13-001" + registered_name = "Prisoner #13-001" + +/obj/item/card/id/prisoner/two + name = "Prisoner #13-002" + registered_name = "Prisoner #13-002" + +/obj/item/card/id/prisoner/three + name = "Prisoner #13-003" + registered_name = "Prisoner #13-003" + +/obj/item/card/id/prisoner/four + name = "Prisoner #13-004" + registered_name = "Prisoner #13-004" + +/obj/item/card/id/prisoner/five + name = "Prisoner #13-005" + registered_name = "Prisoner #13-005" + +/obj/item/card/id/prisoner/six + name = "Prisoner #13-006" + registered_name = "Prisoner #13-006" + +/obj/item/card/id/prisoner/seven + name = "Prisoner #13-007" + registered_name = "Prisoner #13-007" + +/obj/item/card/id/mining + name = "mining ID" + access = list(ACCESS_MINING, ACCESS_MINING_STATION, ACCESS_MAILSORTING, ACCESS_MINERAL_STOREROOM) + +/obj/item/card/id/away + name = "a perfectly generic identification card" + desc = "A perfectly generic identification card. Looks like it could use some flavor." + access = list(ACCESS_AWAY_GENERAL) + +/obj/item/card/id/away/hotel + name = "Staff ID" + desc = "A staff ID used to access the hotel's doors." + access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_MAINT) + +/obj/item/card/id/away/hotel/securty + name = "Officer ID" + access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_MAINT, ACCESS_AWAY_SEC) + +/obj/item/card/id/away/old + name = "a perfectly generic identification card" + desc = "A perfectly generic identification card. Looks like it could use some flavor." + icon_state = "centcom" + +/obj/item/card/id/away/old/sec + name = "Charlie Station Security Officer's ID card" + desc = "A faded Charlie Station ID card. You can make out the rank \"Security Officer\"." + assignment = "Charlie Station Security Officer" + access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_SEC) + +/obj/item/card/id/away/old/sci + name = "Charlie Station Scientist's ID card" + desc = "A faded Charlie Station ID card. You can make out the rank \"Scientist\"." + assignment = "Charlie Station Scientist" + access = list(ACCESS_AWAY_GENERAL) + +/obj/item/card/id/away/old/eng + name = "Charlie Station Engineer's ID card" + desc = "A faded Charlie Station ID card. You can make out the rank \"Station Engineer\"." + assignment = "Charlie Station Engineer" + access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_ENGINE) + +/obj/item/card/id/away/old/apc + name = "APC Access ID" + desc = "A special ID card that allows access to APC terminals." + access = list(ACCESS_ENGINE_EQUIP) + +//Polychromatic Knight Badge + +/obj/item/card/id/knight + var/id_color = "#00FF00" //defaults to green + name = "knight badge" + icon_state = "knight" + desc = "A badge denoting the owner as a knight! It has a strip for swiping like an ID" + +/obj/item/card/id/knight/update_label(newname, newjob) + if(newname || newjob) + name = "[(!newname) ? "knight badge" : "[newname]'s Knight Badge"][(!newjob) ? "" : " ([newjob])"]" + return + + name = "[(!registered_name) ? "knight badge" : "[registered_name]'s Knight Badge"][(!assignment) ? "" : " ([assignment])"]" + +/obj/item/card/id/knight/update_icon() + var/mutable_appearance/id_overlay = mutable_appearance(icon, "knight_overlay") + + if(id_color) + id_overlay.color = id_color + cut_overlays() + + add_overlay(id_overlay) + +/obj/item/card/id/knight/AltClick(mob/living/user) + . = ..() + if(!in_range(src, user)) //Basic checks to prevent abuse + return + if(user.incapacitated() || !istype(user)) + to_chat(user, "You can't do that right now!") + return TRUE + if(alert("Are you sure you want to recolor your id?", "Confirm Repaint", "Yes", "No") == "Yes") + var/energy_color_input = input(usr,"","Choose Energy Color",id_color) as color|null + if(!in_range(src, user) || !energy_color_input) + return TRUE + if(user.incapacitated() || !istype(user)) + to_chat(user, "You can't do that right now!") + return TRUE + id_color = sanitize_hexcolor(energy_color_input, desired_format=6, include_crunch=1) + update_icon() + return TRUE + +/obj/item/card/id/knight/Initialize() + . = ..() + update_icon() + +/obj/item/card/id/knight/examine(mob/user) + . = ..() + . += "Alt-click to recolor it." + +/obj/item/card/id/knight/blue + id_color = "#0000FF" + +/obj/item/card/id/knight/captain + id_color = "#FFD700" + +/obj/item/card/id/away/snowdin/eng + name = "Arctic Station Engineer's ID card" + desc = "A faded Arctic Station ID card. You can make out the rank \"Station Engineer\"." + assignment = "Arctic Station Engineer" + access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_ENGINE, ACCESS_AWAY_MAINT) + +/obj/item/card/id/away/snowdin/sci + name = "Arctic Station Scientist's ID card" + desc = "A faded Arctic Station ID card. You can make out the rank \"Scientist\"." + assignment = "Arctic Station Scientist" + access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_MAINT) + +/obj/item/card/id/away/snowdin/med + name = "Arctic Station Doctor's ID card" + desc = "A faded Arctic Station ID card. You can make out the rank \"Doctor\"." + assignment = "Arctic Station Doctor" + access = list(ACCESS_AWAY_GENERAL, ACCESS_AWAY_MED, ACCESS_AWAY_MAINT) diff --git a/code/game/objects/items/crayons.dm b/code/game/objects/items/crayons.dm index 0176ee61..8c5f1040 100644 --- a/code/game/objects/items/crayons.dm +++ b/code/game/objects/items/crayons.dm @@ -407,7 +407,7 @@ to_chat(user, "You spray a [temp] on \the [target.name]") if(length(text_buffer) > 1) - text_buffer = copytext(text_buffer,2) + text_buffer = copytext(text_buffer, length(text_buffer[1]) + 1) SStgui.update_uis(src) if(post_noise) diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index 7e2a6bcf..8f540525 100644 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -1,1173 +1,1173 @@ - -//The advanced pea-green monochrome lcd of tomorrow. - -GLOBAL_LIST_EMPTY(PDAs) - -#define PDA_SCANNER_NONE 0 -#define PDA_SCANNER_MEDICAL 1 -#define PDA_SCANNER_FORENSICS 2 //unused -#define PDA_SCANNER_REAGENT 3 -#define PDA_SCANNER_HALOGEN 4 -#define PDA_SCANNER_GAS 5 -#define PDA_SPAM_DELAY 2 MINUTES -#define PDA_STANDARD_OVERLAYS list("pda-r", "blank", "id_overlay", "insert_overlay", "light_overlay", "pai_overlay") - -//pda icon overlays list defines -#define PDA_OVERLAY_ALERT 1 -#define PDA_OVERLAY_SCREEN 2 -#define PDA_OVERLAY_ID 3 -#define PDA_OVERLAY_ITEM 4 -#define PDA_OVERLAY_LIGHT 5 -#define PDA_OVERLAY_PAI 6 - -/obj/item/pda - name = "\improper PDA" - desc = "A portable microcomputer by Thinktronic Systems, LTD. Functionality determined by a preprogrammed ROM cartridge." - icon = 'icons/obj/pda_alt.dmi' - icon_state = "pda" - item_state = "electronic" - lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi' - righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi' - item_flags = NOBLUDGEON - w_class = WEIGHT_CLASS_TINY - slot_flags = ITEM_SLOT_ID | ITEM_SLOT_BELT - armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 100) - resistance_flags = FIRE_PROOF | ACID_PROOF - - - //Main variables - var/owner = null // String name of owner - var/default_cartridge = 0 // Access level defined by cartridge - var/obj/item/cartridge/cartridge = null //current cartridge - var/mode = 0 //Controls what menu the PDA will display. 0 is hub; the rest are either built in or based on cartridge. - var/list/overlays_icons = list('icons/obj/pda_alt.dmi' = list("pda-r", "screen_default", "id_overlay", "insert_overlay", "light_overlay", "pai_overlay")) - var/current_overlays = PDA_STANDARD_OVERLAYS - var/font_index = 0 //This int tells DM which font is currently selected and lets DM know when the last font has been selected so that it can cycle back to the first font when "toggle font" is pressed again. - var/font_mode = "font-family:monospace;" //The currently selected font. - var/background_color = "#808000" //The currently selected background color. - - #define FONT_MONO "font-family:monospace;" - #define FONT_SHARE "font-family:\"Share Tech Mono\", monospace;letter-spacing:0px;" - #define FONT_ORBITRON "font-family:\"Orbitron\", monospace;letter-spacing:0px; font-size:15px" - #define FONT_VT "font-family:\"VT323\", monospace;letter-spacing:1px;" - #define MODE_MONO 0 - #define MODE_SHARE 1 - #define MODE_ORBITRON 2 - #define MODE_VT 3 - - //Secondary variables - var/scanmode = PDA_SCANNER_NONE - var/fon = FALSE //Is the flashlight function on? - var/f_lum = 2.3 //Luminosity for the flashlight function - var/f_pow = 0.6 //Power for the flashlight function - var/f_col = "#FFCC66" //Color for the flashlight function - var/silent = FALSE //To beep or not to beep, that is the question - var/toff = FALSE //If TRUE, messenger disabled - var/tnote = null //Current Texts - var/last_text //No text spamming - var/last_everyone //No text for everyone spamming - var/last_noise //Also no honk spamming that's bad too - var/ttone = "beep" //The ringtone! - var/honkamt = 0 //How many honks left when infected with honk.exe - var/mimeamt = 0 //How many silence left when infected with mime.exe - var/note = "Congratulations, your station has chosen the Thinktronic 5230 Personal Data Assistant! To help with navigation, we have provided the following definitions. North: Fore. South: Aft. West: Port. East: Starboard. Quarter is either side of aft." //Current note in the notepad function - var/notehtml = "" - var/notescanned = FALSE // True if what is in the notekeeper was from a paper. - var/detonatable = TRUE // Can the PDA be blown up? - var/hidden = FALSE // Is the PDA hidden from the PDA list? - var/emped = FALSE - var/equipped = FALSE //used here to determine if this is the first time its been picked up - - var/obj/item/card/id/id = null //Making it possible to slot an ID card into the PDA so it can function as both. - var/ownjob = null //related to above - - var/obj/item/paicard/pai = null // A slot for a personal AI device - - var/datum/picture/picture //Scanned photo - - var/list/contained_item = list(/obj/item/pen, /obj/item/toy/crayon, /obj/item/lipstick, /obj/item/flashlight/pen, /obj/item/clothing/mask/cigarette) - var/obj/item/inserted_item //Used for pen, crayon, and lipstick insertion or removal. Same as above. - var/list/overlays_offsets // offsets to use for certain overlays - var/overlays_x_offset = 0 - var/overlays_y_offset = 0 - - var/underline_flag = TRUE //flag for underline - -/obj/item/pda/suicide_act(mob/living/carbon/user) - var/deathMessage = msg_input(user) - if (!deathMessage) - deathMessage = "i ded" - user.visible_message("[user] is sending a message to the Grim Reaper! It looks like [user.p_theyre()] trying to commit suicide!") - tnote += "→ To The Grim Reaper:
      [deathMessage]
      "//records a message in their PDA as being sent to the grim reaper - return BRUTELOSS - -/obj/item/pda/examine(mob/user) - . = ..() - . += id ? "Alt-click to remove the id." : "" - if(inserted_item && (!isturf(loc))) - . += "Ctrl-click to remove [inserted_item]." - if(LAZYLEN(GLOB.pda_reskins)) - . += "Ctrl-shift-click it to reskin it." - -/obj/item/pda/Initialize() - . = ..() - if(fon) - set_light(f_lum, f_pow, f_col) - - GLOB.PDAs += src - if(default_cartridge) - cartridge = new default_cartridge(src) - if(inserted_item) - inserted_item = new inserted_item(src) - else - inserted_item = new /obj/item/pen(src) - update_icon(FALSE, TRUE) - -/obj/item/pda/CtrlShiftClick(mob/living/user) - . = ..() - if(GLOB.pda_reskins && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY)) - reskin_obj(user) - -/obj/item/pda/reskin_obj(mob/M) - if(!LAZYLEN(GLOB.pda_reskins)) - return - var/dat = "Reskin options for [name]:" - for(var/V in GLOB.pda_reskins) - var/output = icon2html(GLOB.pda_reskins[V], M, icon_state) - dat += "\n[V]: [output]" - to_chat(M, dat) - - var/choice = input(M, "Choose the a reskin for [src]","Reskin Object") as null|anything in GLOB.pda_reskins - var/new_icon = GLOB.pda_reskins[choice] - if(QDELETED(src) || isnull(new_icon) || new_icon == icon || !M.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) - return - icon = new_icon - update_icon(FALSE, TRUE) - to_chat(M, "[src] is now skinned as '[choice]'.") - -/obj/item/pda/proc/set_new_overlays() - if(!overlays_offsets || !(icon in overlays_offsets)) - overlays_x_offset = 0 - overlays_y_offset = 0 - else - var/list/new_offsets = overlays_offsets[icon] - if(new_offsets) - overlays_x_offset = new_offsets[1] - overlays_y_offset = new_offsets[2] - if(!(icon in overlays_icons)) - current_overlays = PDA_STANDARD_OVERLAYS - return - current_overlays = overlays_icons[icon] - -/obj/item/pda/equipped(mob/user, slot) - . = ..() - if(equipped) - return - if(user.client) - background_color = user.client.prefs.pda_color - switch(user.client.prefs.pda_style) - if(MONO) - font_index = MODE_MONO - font_mode = FONT_MONO - if(SHARE) - font_index = MODE_SHARE - font_mode = FONT_SHARE - if(ORBITRON) - font_index = MODE_ORBITRON - font_mode = FONT_ORBITRON - if(VT) - font_index = MODE_VT - font_mode = FONT_VT - else - font_index = MODE_MONO - font_mode = FONT_MONO - var/pref_skin = GLOB.pda_reskins[user.client.prefs.pda_skin] - if(icon != pref_skin) - icon = pref_skin - update_icon(FALSE, TRUE) - equipped = TRUE - -/obj/item/pda/proc/update_label() - name = "PDA-[owner] ([ownjob])" //Name generalisation - -/obj/item/pda/GetAccess() - if(id) - return id.GetAccess() - else - return ..() - -/obj/item/pda/GetID() - return id - -/obj/item/pda/RemoveID() - return do_remove_id() - -/obj/item/pda/InsertID(obj/item/inserting_item) - var/obj/item/card/inserting_id = inserting_item.RemoveID() - if(!inserting_id) - return - insert_id(inserting_id) - if(id == inserting_id) - return TRUE - return FALSE - -/obj/item/pda/update_icon(alert = FALSE, new_overlays = FALSE) - if(new_overlays) - set_new_overlays() - cut_overlays() - add_overlay(alert ? current_overlays[PDA_OVERLAY_ALERT] : current_overlays[PDA_OVERLAY_SCREEN]) - var/mutable_appearance/overlay = new() - overlay.pixel_x = overlays_x_offset - if(id) - overlay.icon_state = current_overlays[PDA_OVERLAY_ID] - add_overlay(new /mutable_appearance(overlay)) - if(inserted_item) - overlay.icon_state = current_overlays[PDA_OVERLAY_ITEM] - add_overlay(new /mutable_appearance(overlay)) - if(fon) - overlay.icon_state = current_overlays[PDA_OVERLAY_LIGHT] - add_overlay(new /mutable_appearance(overlay)) - if(pai) - overlay.icon_state = "[current_overlays[PDA_OVERLAY_PAI]][pai.pai ? "" : "_off"]" - add_overlay(new /mutable_appearance(overlay)) - -/obj/item/pda/MouseDrop(mob/over, src_location, over_location) - var/mob/M = usr - if((M == over) && usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) - return attack_self(M) - return ..() - -/obj/item/pda/attack_self_tk(mob/user) - to_chat(user, "The PDA's capacitive touch screen doesn't seem to respond!") - return - -/obj/item/pda/interact(mob/user) - if(!user.IsAdvancedToolUser()) - to_chat(user, "You don't have the dexterity to do this!") - return - - ..() - - var/datum/asset/spritesheet/assets = get_asset_datum(/datum/asset/spritesheet/simple/pda) - assets.send(user) - - user.set_machine(src) - - var/dat = "Personal Data Assistant" - dat += assets.css_tag() - - dat += "[PDAIMG(refresh)]Refresh" - - if ((!isnull(cartridge)) && (mode == 0)) - dat += " | [PDAIMG(eject)]Eject [cartridge]" - if (mode) - dat += " | [PDAIMG(menu)]Return" - - if (mode == 0) - dat += "
      " - dat += "
      Toggle Font" - dat += " | Change Color" - dat += " | Toggle Underline" //underline button - - dat += "
      " - - dat += "
      " - - if (!owner) - dat += "Warning: No owner information entered. Please swipe card.

      " - dat += "[PDAIMG(refresh)]Retry" - else - switch (mode) - if (0) - dat += "

      PERSONAL DATA ASSISTANT v.1.2

      " - dat += "Owner: [owner], [ownjob]
      " - dat += text("ID: [id ? "[id.registered_name], [id.assignment]" : "----------"]") - dat += text("
      [id ? "Update PDA Info" : ""]

      ") - - dat += "[STATION_TIME_TIMESTAMP("hh:mm:ss")]
      " //:[world.time / 100 % 6][world.time / 100 % 10]" - dat += "[time2text(world.realtime, "MMM DD")] [GLOB.year_integer]" - - dat += "

      " - - dat += "

      General Functions

      " - dat += "" - if (cartridge.access & CART_ENGINE) - dat += "

      Engineering Functions

      " - dat += "" - if (cartridge.access & CART_MEDICAL) - dat += "

      Medical Functions

      " - dat += "" - if (cartridge.access & CART_SECURITY) - dat += "

      Security Functions

      " - dat += "" - if(cartridge.access & CART_QUARTERMASTER) - dat += "

      Quartermaster Functions:

      " - dat += "" - dat += "
    " - - dat += "

    Utilities

    " - dat += "" - - if (1) - dat += "

    [PDAIMG(notes)] Notekeeper V2.2

    " - dat += "Edit
    " - if(notescanned) - dat += "(This is a scanned image, editing it may cause some text formatting to change.)
    " - dat += "
    [(!notehtml ? note : notehtml)]" - - if (2) - dat += "

    [PDAIMG(mail)] SpaceMessenger V3.9.6

    " - dat += "[PDAIMG(bell)]Ringer: [silent == 1 ? "Off" : "On"] | " - dat += "[PDAIMG(mail)]Send / Receive: [toff == 1 ? "Off" : "On"] | " - dat += "[PDAIMG(bell)]Set Ringtone | " - dat += "[PDAIMG(mail)]Messages
    " - - if(cartridge) - dat += cartridge.message_header() - - dat += "

    [PDAIMG(menu)] Detected PDAs

    " - - dat += "
      " - var/count = 0 - - if (!toff) - for (var/obj/item/pda/P in sortNames(get_viewable_pdas())) - if (P == src) - continue - dat += "
    • [P]" - if(cartridge) - dat += cartridge.message_special(P) - dat += "
    • " - count++ - dat += "
    " - if (count == 0) - dat += "None detected.
    " - else if(cartridge && cartridge.spam_enabled) - dat += "Send To All" - - if(21) - dat += "

    [PDAIMG(mail)] SpaceMessenger V3.9.6

    " - dat += "[PDAIMG(blank)]Clear Messages" - - dat += "

    [PDAIMG(mail)] Messages

    " - - dat += tnote - dat += "
    " - - if (3) - dat += "

    [PDAIMG(atmos)] Atmospheric Readings

    " - - var/turf/T = user.loc - if (isnull(T)) - dat += "Unable to obtain a reading.
    " - else - var/datum/gas_mixture/environment = T.return_air() - var/list/env_gases = environment.gases - - var/pressure = environment.return_pressure() - var/total_moles = environment.total_moles() - - dat += "Air Pressure: [round(pressure,0.1)] kPa
    " - - if (total_moles) - for(var/id in env_gases) - var/gas_level = env_gases[id]/total_moles - if(gas_level > 0) - dat += "[GLOB.meta_gas_names[id]]: [round(gas_level*100, 0.01)]%
    " - - dat += "Temperature: [round(environment.temperature-T0C)]°C
    " - dat += "
    " - else//Else it links to the cart menu proc. Although, it really uses menu hub 4--menu 4 doesn't really exist as it simply redirects to hub. - dat += cartridge.generate_menu() - - dat += "" - - if (underline_flag) - dat = replacetext(dat, "text-decoration:none", "text-decoration:underline") - if (!underline_flag) - dat = replacetext(dat, "text-decoration:underline", "text-decoration:none") - - user << browse(dat, "window=pda;size=400x450;border=1;can_resize=1;can_minimize=0") - onclose(user, "pda", src) - -/obj/item/pda/Topic(href, href_list) - ..() - var/mob/living/U = usr - //Looking for master was kind of pointless since PDAs don't appear to have one. - - if(usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK) && !href_list["close"]) - add_fingerprint(U) - U.set_machine(src) - - switch(href_list["choice"]) - -//BASIC FUNCTIONS=================================== - - if("Refresh")//Refresh, goes to the end of the proc. - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if ("Toggle_Font") - //CODE REVISION 2 - font_index = (font_index + 1) % 4 - - switch(font_index) - if (MODE_MONO) - font_mode = FONT_MONO - if (MODE_SHARE) - font_mode = FONT_SHARE - if (MODE_ORBITRON) - font_mode = FONT_ORBITRON - if (MODE_VT) - font_mode = FONT_VT - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if ("Change_Color") - var/new_color = input("Please enter a color name or hex value (Default is \'#808000\').",background_color)as color - background_color = new_color - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if ("Toggle_Underline") - underline_flag = !underline_flag - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if("Return")//Return - if(mode<=9) - mode = 0 - else - mode = round(mode/10) - if(mode==4 || mode == 5)//Fix for cartridges. Redirects to hub. - mode = 0 - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if ("Authenticate")//Checks for ID - id_check(U) - - if("UpdateInfo") - ownjob = id.assignment - if(istype(id, /obj/item/card/id/syndicate)) - owner = id.registered_name - update_label() - if (!silent) - playsound(src, 'sound/machines/terminal_processing.ogg', 15, 1) - addtimer(CALLBACK(GLOBAL_PROC, .proc/playsound, src, 'sound/machines/terminal_success.ogg', 15, 1), 13) - - if("Eject")//Ejects the cart, only done from hub. - if (!isnull(cartridge)) - U.put_in_hands(cartridge) - to_chat(U, "You remove [cartridge] from [src].") - scanmode = PDA_SCANNER_NONE - cartridge.host_pda = null - cartridge = null - update_icon() - if (!silent) - playsound(src, 'sound/machines/terminal_eject_disc.ogg', 50, 1) - -//MENU FUNCTIONS=================================== - - if("0")//Hub - mode = 0 - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - if("1")//Notes - mode = 1 - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - if("2")//Messenger - mode = 2 - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - if("21")//Read messeges - mode = 21 - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - if("3")//Atmos scan - mode = 3 - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - if("4")//Redirects to hub - mode = 0 - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - -//MAIN FUNCTIONS=================================== - - if("Light") - toggle_light() - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if("Medical Scan") - if(scanmode == PDA_SCANNER_MEDICAL) - scanmode = PDA_SCANNER_NONE - else if((!isnull(cartridge)) && (cartridge.access & CART_MEDICAL)) - scanmode = PDA_SCANNER_MEDICAL - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if("Reagent Scan") - if(scanmode == PDA_SCANNER_REAGENT) - scanmode = PDA_SCANNER_NONE - else if((!isnull(cartridge)) && (cartridge.access & CART_REAGENT_SCANNER)) - scanmode = PDA_SCANNER_REAGENT - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if("Halogen Counter") - if(scanmode == PDA_SCANNER_HALOGEN) - scanmode = PDA_SCANNER_NONE - else if((!isnull(cartridge)) && (cartridge.access & CART_ENGINE)) - scanmode = PDA_SCANNER_HALOGEN - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if("Honk") - if ( !(last_noise && world.time < last_noise + 20) ) - playsound(src, 'sound/items/bikehorn.ogg', 50, 1) - last_noise = world.time - - if("Trombone") - if ( !(last_noise && world.time < last_noise + 20) ) - playsound(src, 'sound/misc/sadtrombone.ogg', 50, 1) - last_noise = world.time - - if("Gas Scan") - if(scanmode == PDA_SCANNER_GAS) - scanmode = PDA_SCANNER_NONE - else if((!isnull(cartridge)) && (cartridge.access & CART_ATMOS)) - scanmode = PDA_SCANNER_GAS - if (!silent) - playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) - - if("Drone Phone") - var/alert_s = input(U,"Alert severity level","Ping Drones",null) as null|anything in list("Low","Medium","High","Critical") - var/area/A = get_area(U) - if(A && alert_s && !QDELETED(U)) - var/msg = "NON-DRONE PING: [U.name]: [alert_s] priority alert in [A.name]!" - _alert_drones(msg, TRUE, U) - to_chat(U, msg) - if (!silent) - playsound(src, 'sound/machines/terminal_success.ogg', 15, 1) - - -//NOTEKEEPER FUNCTIONS=================================== - - if ("Edit") - var/n = stripped_multiline_input(U, "Please enter message", name, note) - if (in_range(src, U) && loc == U) - if (mode == 1 && n) - note = n - notehtml = parsemarkdown(n, U) - notescanned = FALSE - else - U << browse(null, "window=pda") - return - -//MESSENGER FUNCTIONS=================================== - - if("Toggle Messenger") - toff = !toff - if("Toggle Ringer")//If viewing texts then erase them, if not then toggle silent status - silent = !silent - if("Clear")//Clears messages - tnote = null - if("Ringtone") - var/t = input(U, "Please enter new ringtone", name, ttone) as text - if(in_range(src, U) && loc == U && t) - if(SEND_SIGNAL(src, COMSIG_PDA_CHANGE_RINGTONE, U, t) & COMPONENT_STOP_RINGTONE_CHANGE) - U << browse(null, "window=pda") - return - else - ttone = copytext(sanitize(t), 1, 20) - else - U << browse(null, "window=pda") - return - if("Message") - create_message(U, locate(href_list["target"])) - - if("MessageAll") - send_to_all(U) - - if("cart") - if(cartridge) - cartridge.special(U, href_list) - else - U << browse(null, "window=pda") - return - -//SYNDICATE FUNCTIONS=================================== - - if("Toggle Door") - if(cartridge && cartridge.access & CART_REMOTE_DOOR) - for(var/obj/machinery/door/poddoor/M in GLOB.machines) - if(M.id == cartridge.remote_door_id) - if(M.density) - M.open() - else - M.close() - -//pAI FUNCTIONS=================================== - if("pai") - switch(href_list["option"]) - if("1") // Configure pAI device - pai.attack_self(U) - if("2") // Eject pAI device - var/turf/T = get_turf(loc) - if(T) - pai.forceMove(T) - -//LINK FUNCTIONS=================================== - - else//Cartridge menu linking - mode = max(text2num(href_list["choice"]), 0) - - else//If not in range, can't interact or not using the pda. - U.unset_machine() - U << browse(null, "window=pda") - return - -//EXTRA FUNCTIONS=================================== - - if (mode == 2 || mode == 21)//To clear message overlays. - update_icon() - - if ((honkamt > 0) && (prob(60)))//For clown virus. - honkamt-- - playsound(src, 'sound/items/bikehorn.ogg', 30, 1) - - if(U.machine == src && href_list["skiprefresh"]!="1")//Final safety. - attack_self(U)//It auto-closes the menu prior if the user is not in range and so on. - else - U.unset_machine() - U << browse(null, "window=pda") - return - -/obj/item/pda/proc/remove_id() - if(issilicon(usr) || !usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) - return - do_remove_id(usr) - -/obj/item/pda/proc/do_remove_id(mob/user) - if(!id) - return - if(user) - user.put_in_hands(id) - to_chat(user, "You remove the ID from the [name].") - else - id.forceMove(get_turf(src)) - - . = id - id = null - update_icon() - - if(ishuman(loc)) - var/mob/living/carbon/human/H = loc - if(H.wear_id == src) - H.sec_hud_set_ID() - -/obj/item/pda/proc/msg_input(mob/living/U = usr) - var/t = stripped_input(U, "Please enter message", name) - if (!t || toff) - return - if(!U.canUseTopic(src, BE_CLOSE)) - return - if(emped) - t = Gibberish(t, 100) - return t - -/obj/item/pda/proc/send_message(mob/living/user, list/obj/item/pda/targets, everyone) - var/message = msg_input(user) - if(!message || !targets.len) - return - if((last_text && world.time < last_text + 10) || (everyone && last_everyone && world.time < last_everyone + PDA_SPAM_DELAY)) - return - var/emoji_message = emoji_parse(message) - if(prob(1)) - message += "\nSent from my PDA" - // Send the signal - var/list/string_targets = list() - for (var/obj/item/pda/P in targets) - if (P.owner && P.ownjob) // != src is checked by the UI - string_targets += "[P.owner] ([P.ownjob])" - for (var/obj/machinery/computer/message_monitor/M in targets) - // In case of "Reply" to a message from a console, this will make the - // message be logged successfully. If the console is impersonating - // someone by matching their name and job, the reply will reach the - // impersonated PDA. - string_targets += "[M.customsender] ([M.customjob])" - if (!string_targets.len) - return - - var/datum/signal/subspace/pda/signal = new(src, list( - "name" = "[owner]", - "job" = "[ownjob]", - "message" = message, - "targets" = string_targets, - "emoji_message" = emoji_message - )) - if (picture) - signal.data["photo"] = picture - signal.send_to_receivers() - - // If it didn't reach, note that fact - if (!signal.data["done"]) - to_chat(user, "ERROR: Server isn't responding.") - return - if (!silent) - playsound(src, 'sound/machines/terminal_error.ogg', 15, 1) - - var/target_text = signal.format_target() - // Log it in our logs - tnote += "→ To [target_text]:
    [signal.format_message()]
    " - // Show it to ghosts - var/ghost_message = "[owner] PDA Message --> [target_text]: [signal.format_message(TRUE)]" - for(var/mob/M in GLOB.player_list) - if(isobserver(M) && M.client && (M.client.prefs.chat_toggles & CHAT_GHOSTPDA)) - to_chat(M, "[FOLLOW_LINK(M, user)] [ghost_message]") - // Log in the talk log - user.log_talk(message, LOG_PDA, tag="PDA: [initial(name)] to [target_text]") - to_chat(user, "Message sent to [target_text]: \"[emoji_message]\"") - if (!silent) - playsound(src, 'sound/machines/terminal_success.ogg', 15, 1) - // Reset the photo - picture = null - last_text = world.time - if (everyone) - last_everyone = world.time - -/obj/item/pda/proc/receive_message(datum/signal/subspace/pda/signal) - tnote += "← From [signal.data["name"]] ([signal.data["job"]]):
    [signal.format_message()]
    " - - if (!silent) - playsound(src, 'sound/machines/twobeep.ogg', 50, 1) - audible_message("[icon2html(src, hearers(src))] *[ttone]*", null, 3) - //Search for holder of the PDA. - var/mob/living/L = null - if(loc && isliving(loc)) - L = loc - //Maybe they are a pAI! - else - L = get(src, /mob/living/silicon) - - if(L && L.stat != UNCONSCIOUS) - var/hrefstart - var/hrefend - if (isAI(L)) - hrefstart = "" - hrefend = "" - - to_chat(L, "[icon2html(src)] Message from [hrefstart][signal.data["name"]] ([signal.data["job"]])[hrefend], [signal.format_message(TRUE)] (Reply)") - - update_icon(TRUE) - -/obj/item/pda/proc/send_to_all(mob/living/U) - if (last_everyone && world.time < last_everyone + PDA_SPAM_DELAY) - to_chat(U,"Send To All function is still on cooldown.") - return - send_message(U,get_viewable_pdas(), TRUE) - -/obj/item/pda/proc/create_message(mob/living/U, obj/item/pda/P) - send_message(U,list(P)) - -/obj/item/pda/AltClick() - . = ..() - if(id) - remove_id() - playsound(src, 'sound/machines/terminal_eject_disc.ogg', 50, 1) - else - remove_pen() - playsound(src, 'sound/machines/button4.ogg', 50, 1) - return TRUE - -/obj/item/pda/CtrlClick() - ..() - - if(isturf(loc)) //stops the user from dragging the PDA by ctrl-clicking it. - return - - remove_pen() - -/obj/item/pda/verb/verb_toggle_light() - set category = "Object" - set name = "Toggle Flashlight" - - toggle_light() - -/obj/item/pda/verb/verb_remove_id() - set category = "Object" - set name = "Eject ID" - set src in usr - - if(id) - remove_id() - else - to_chat(usr, "This PDA does not have an ID in it!") - -/obj/item/pda/verb/verb_remove_pen() - set category = "Object" - set name = "Remove Pen" - set src in usr - - remove_pen() - -/obj/item/pda/proc/toggle_light() - if(issilicon(usr) || !usr.canUseTopic(src, BE_CLOSE)) - return - if(fon) - fon = FALSE - set_light(0) - else if(f_lum) - fon = TRUE - set_light(f_lum, f_pow, f_col) - update_icon() - -/obj/item/pda/proc/remove_pen() - - if(issilicon(usr) || !usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) - return - - if(inserted_item) - usr.put_in_hands(inserted_item) - to_chat(usr, "You remove [inserted_item] from [src].") - inserted_item = null - update_icon() - else - to_chat(usr, "This PDA does not have a pen in it!") - -//trying to insert or remove an id -/obj/item/pda/proc/id_check(mob/user, obj/item/card/id/I) - if(!I) - if(id && (src in user.contents)) - remove_id() - return TRUE - else - var/obj/item/card/id/C = user.get_active_held_item() - if(istype(C)) - I = C - - if(I?.registered_name) - if(!user.transferItemToLoc(I, src)) - return FALSE - insert_id(I, user) - update_icon() - playsound(src, 'sound/machines/button.ogg', 50, 1) - return TRUE - -/obj/item/pda/proc/insert_id(obj/item/card/id/inserting_id, mob/user) - var/obj/old_id = id - id = inserting_id - if(ishuman(loc)) - var/mob/living/carbon/human/human_wearer = loc - if(human_wearer.wear_id == src) - human_wearer.sec_hud_set_ID() - if(old_id) - if(user) - user.put_in_hands(old_id) - else - old_id.forceMove(get_turf(src)) - -// access to status display signals -/obj/item/pda/attackby(obj/item/C, mob/user, params) - if(istype(C, /obj/item/cartridge) && !cartridge) - if(!user.transferItemToLoc(C, src)) - return - cartridge = C - cartridge.host_pda = src - to_chat(user, "You insert [cartridge] into [src].") - update_icon() - playsound(src, 'sound/machines/button.ogg', 50, 1) - - else if(istype(C, /obj/item/card/id)) - var/obj/item/card/id/idcard = C - if(!idcard.registered_name) - to_chat(user, "\The [src] rejects the ID!") - return - if (!silent) - playsound(src, 'sound/machines/terminal_error.ogg', 15, 1) - - if(!owner) - owner = idcard.registered_name - ownjob = idcard.assignment - update_label() - to_chat(user, "Card scanned.") - if (!silent) - playsound(src, 'sound/machines/terminal_success.ogg', 15, 1) - else - //Basic safety check. If either both objects are held by user or PDA is on ground and card is in hand. - if(((src in user.contents) || (isturf(loc) && in_range(src, user))) && (C in user.contents)) - if(!id_check(user, idcard)) - return - to_chat(user, "You put the ID into \the [src]'s slot.") - updateSelfDialog()//Update self dialog on success. - return //Return in case of failed check or when successful. - updateSelfDialog()//For the non-input related code. - else if(istype(C, /obj/item/paicard) && !pai) - if(!user.transferItemToLoc(C, src)) - return - pai = C - to_chat(user, "You slot \the [C] into [src].") - update_icon() - updateUsrDialog() - else if(is_type_in_list(C, contained_item)) //Checks if there is a pen - if(inserted_item) - to_chat(user, "There is already \a [inserted_item] in \the [src]!") - else - if(!user.transferItemToLoc(C, src)) - return - to_chat(user, "You slide \the [C] into \the [src].") - inserted_item = C - update_icon() - playsound(src, 'sound/machines/button.ogg', 50, 1) - - else if(istype(C, /obj/item/photo)) - var/obj/item/photo/P = C - picture = P.picture - to_chat(user, "You scan \the [C].") - else - return ..() - -/obj/item/pda/attack(mob/living/carbon/C, mob/living/user) - if(istype(C)) - switch(scanmode) - - if(PDA_SCANNER_MEDICAL) - C.visible_message("[user] has analyzed [C]'s vitals!") - healthscan(user, C, 1) - add_fingerprint(user) - - if(PDA_SCANNER_HALOGEN) - C.visible_message("[user] has analyzed [C]'s radiation levels!") - - user.show_message("Analyzing Results for [C]:") - if(C.radiation) - user.show_message("\green Radiation Level: \black [C.radiation]") - else - user.show_message("No radiation detected.") - -/obj/item/pda/afterattack(atom/A as mob|obj|turf|area, mob/user, proximity) - . = ..() - if(!proximity) - return - switch(scanmode) - if(PDA_SCANNER_REAGENT) - if(!isnull(A.reagents)) - if(A.reagents.reagent_list.len > 0) - var/reagents_length = A.reagents.reagent_list.len - to_chat(user, "[reagents_length] chemical agent[reagents_length > 1 ? "s" : ""] found.") - for (var/re in A.reagents.reagent_list) - to_chat(user, "\t [re]") - else - to_chat(user, "No active chemical agents found in [A].") - else - to_chat(user, "No significant chemical agents found in [A].") - - if(PDA_SCANNER_GAS) - A.analyzer_act(user, src) - - if (!scanmode && istype(A, /obj/item/paper) && owner) - var/obj/item/paper/PP = A - if (!PP.info) - to_chat(user, "Unable to scan! Paper is blank.") - return - notehtml = PP.info - note = replacetext(notehtml, "
    ", "\[br\]") - note = replacetext(note, "
  • ", "\[*\]") - note = replacetext(note, "
      ", "\[list\]") - note = replacetext(note, "
    ", "\[/list\]") - note = html_encode(note) - notescanned = TRUE - to_chat(user, "Paper scanned. Saved to PDA's notekeeper." ) - - -/obj/item/pda/proc/explode() //This needs tuning. - if(!detonatable) - return - var/turf/T = get_turf(src) - - if (ismob(loc)) - var/mob/M = loc - M.show_message("Your [src] explodes!", MSG_VISUAL, "You hear a loud *pop*!", MSG_AUDIBLE) - else - visible_message("[src] explodes!", "You hear a loud *pop*!") - - if(T) - T.hotspot_expose(700,125) - if(istype(cartridge, /obj/item/cartridge/virus/syndicate)) - explosion(T, -1, 1, 3, 4) - else - explosion(T, -1, -1, 2, 3) - qdel(src) - return - -/obj/item/pda/Destroy() - GLOB.PDAs -= src - if(istype(id)) - QDEL_NULL(id) - if(istype(cartridge)) - QDEL_NULL(cartridge) - if(istype(pai)) - QDEL_NULL(pai) - if(istype(inserted_item)) - QDEL_NULL(inserted_item) - return ..() - -//AI verb and proc for sending PDA messages. - -/mob/living/silicon/ai/proc/cmd_send_pdamesg(mob/user) - var/list/plist = list() - var/list/namecounts = list() - - if(aiPDA.toff) - to_chat(user, "Turn on your receiver in order to send messages.") - return - - for (var/obj/item/pda/P in get_viewable_pdas()) - if (P == src) - continue - else if (P == aiPDA) - continue - - plist[avoid_assoc_duplicate_keys(P.owner, namecounts)] = P - - var/c = input(user, "Please select a PDA") as null|anything in sortList(plist) - - if (!c) - return - - var/selected = plist[c] - - if(aicamera.stored.len) - var/add_photo = input(user,"Do you want to attach a photo?","Photo","No") as null|anything in list("Yes","No") - if(add_photo=="Yes") - var/datum/picture/Pic = aicamera.selectpicture(user) - aiPDA.picture = Pic - - if(incapacitated()) - return - - aiPDA.create_message(src, selected) - - -/mob/living/silicon/ai/verb/cmd_toggle_pda_receiver() - set category = "AI Commands" - set name = "PDA - Toggle Sender/Receiver" - if(usr.stat == DEAD) - return //won't work if dead - if(!isnull(aiPDA)) - aiPDA.toff = !aiPDA.toff - to_chat(usr, "PDA sender/receiver toggled [(aiPDA.toff ? "Off" : "On")]!") - else - to_chat(usr, "You do not have a PDA. You should make an issue report about this.") - -/mob/living/silicon/ai/verb/cmd_toggle_pda_silent() - set category = "AI Commands" - set name = "PDA - Toggle Ringer" - if(usr.stat == DEAD) - return //won't work if dead - if(!isnull(aiPDA)) - //0 - aiPDA.silent = !aiPDA.silent - to_chat(usr, "PDA ringer toggled [(aiPDA.silent ? "Off" : "On")]!") - else - to_chat(usr, "You do not have a PDA. You should make an issue report about this.") - -/mob/living/silicon/ai/proc/cmd_show_message_log(mob/user) - if(incapacitated()) - return - if(!isnull(aiPDA)) - var/HTML = "AI PDA Message Log[aiPDA.tnote]" - user << browse(HTML, "window=log;size=400x444;border=1;can_resize=1;can_close=1;can_minimize=0") - else - to_chat(user, "You do not have a PDA. You should make an issue report about this.") - - -// Pass along the pulse to atoms in contents, largely added so pAIs are vulnerable to EMP -/obj/item/pda/emp_act(severity) - . = ..() - if (!(. & EMP_PROTECT_CONTENTS)) - for(var/atom/A in src) - A.emp_act(severity) - if (!(. & EMP_PROTECT_SELF)) - emped += 1 - spawn(200 * severity) - emped -= 1 - -/proc/get_viewable_pdas() - . = list() - // Returns a list of PDAs which can be viewed from another PDA/message monitor. - for(var/obj/item/pda/P in GLOB.PDAs) - if(!P.owner || P.toff || P.hidden) - continue - . += P - -#undef PDA_SCANNER_NONE -#undef PDA_SCANNER_MEDICAL -#undef PDA_SCANNER_FORENSICS -#undef PDA_SCANNER_REAGENT -#undef PDA_SCANNER_HALOGEN -#undef PDA_SCANNER_GAS -#undef PDA_SPAM_DELAY -#undef PDA_STANDARD_OVERLAYS - -#undef PDA_OVERLAY_ALERT -#undef PDA_OVERLAY_SCREEN -#undef PDA_OVERLAY_ID -#undef PDA_OVERLAY_ITEM -#undef PDA_OVERLAY_LIGHT -#undef PDA_OVERLAY_PAI + +//The advanced pea-green monochrome lcd of tomorrow. + +GLOBAL_LIST_EMPTY(PDAs) + +#define PDA_SCANNER_NONE 0 +#define PDA_SCANNER_MEDICAL 1 +#define PDA_SCANNER_FORENSICS 2 //unused +#define PDA_SCANNER_REAGENT 3 +#define PDA_SCANNER_HALOGEN 4 +#define PDA_SCANNER_GAS 5 +#define PDA_SPAM_DELAY 2 MINUTES +#define PDA_STANDARD_OVERLAYS list("pda-r", "blank", "id_overlay", "insert_overlay", "light_overlay", "pai_overlay") + +//pda icon overlays list defines +#define PDA_OVERLAY_ALERT 1 +#define PDA_OVERLAY_SCREEN 2 +#define PDA_OVERLAY_ID 3 +#define PDA_OVERLAY_ITEM 4 +#define PDA_OVERLAY_LIGHT 5 +#define PDA_OVERLAY_PAI 6 + +/obj/item/pda + name = "\improper PDA" + desc = "A portable microcomputer by Thinktronic Systems, LTD. Functionality determined by a preprogrammed ROM cartridge." + icon = 'icons/obj/pda_alt.dmi' + icon_state = "pda" + item_state = "electronic" + lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi' + righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi' + item_flags = NOBLUDGEON + w_class = WEIGHT_CLASS_TINY + slot_flags = ITEM_SLOT_ID | ITEM_SLOT_BELT + armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 100) + resistance_flags = FIRE_PROOF | ACID_PROOF + + + //Main variables + var/owner = null // String name of owner + var/default_cartridge = 0 // Access level defined by cartridge + var/obj/item/cartridge/cartridge = null //current cartridge + var/mode = 0 //Controls what menu the PDA will display. 0 is hub; the rest are either built in or based on cartridge. + var/list/overlays_icons = list('icons/obj/pda_alt.dmi' = list("pda-r", "screen_default", "id_overlay", "insert_overlay", "light_overlay", "pai_overlay")) + var/current_overlays = PDA_STANDARD_OVERLAYS + var/font_index = 0 //This int tells DM which font is currently selected and lets DM know when the last font has been selected so that it can cycle back to the first font when "toggle font" is pressed again. + var/font_mode = "font-family:monospace;" //The currently selected font. + var/background_color = "#808000" //The currently selected background color. + + #define FONT_MONO "font-family:monospace;" + #define FONT_SHARE "font-family:\"Share Tech Mono\", monospace;letter-spacing:0px;" + #define FONT_ORBITRON "font-family:\"Orbitron\", monospace;letter-spacing:0px; font-size:15px" + #define FONT_VT "font-family:\"VT323\", monospace;letter-spacing:1px;" + #define MODE_MONO 0 + #define MODE_SHARE 1 + #define MODE_ORBITRON 2 + #define MODE_VT 3 + + //Secondary variables + var/scanmode = PDA_SCANNER_NONE + var/fon = FALSE //Is the flashlight function on? + var/f_lum = 2.3 //Luminosity for the flashlight function + var/f_pow = 0.6 //Power for the flashlight function + var/f_col = "#FFCC66" //Color for the flashlight function + var/silent = FALSE //To beep or not to beep, that is the question + var/toff = FALSE //If TRUE, messenger disabled + var/tnote = null //Current Texts + var/last_text //No text spamming + var/last_everyone //No text for everyone spamming + var/last_noise //Also no honk spamming that's bad too + var/ttone = "beep" //The ringtone! + var/honkamt = 0 //How many honks left when infected with honk.exe + var/mimeamt = 0 //How many silence left when infected with mime.exe + var/note = "Congratulations, your station has chosen the Thinktronic 5230 Personal Data Assistant! To help with navigation, we have provided the following definitions. North: Fore. South: Aft. West: Port. East: Starboard. Quarter is either side of aft." //Current note in the notepad function + var/notehtml = "" + var/notescanned = FALSE // True if what is in the notekeeper was from a paper. + var/detonatable = TRUE // Can the PDA be blown up? + var/hidden = FALSE // Is the PDA hidden from the PDA list? + var/emped = FALSE + var/equipped = FALSE //used here to determine if this is the first time its been picked up + + var/obj/item/card/id/id = null //Making it possible to slot an ID card into the PDA so it can function as both. + var/ownjob = null //related to above + + var/obj/item/paicard/pai = null // A slot for a personal AI device + + var/datum/picture/picture //Scanned photo + + var/list/contained_item = list(/obj/item/pen, /obj/item/toy/crayon, /obj/item/lipstick, /obj/item/flashlight/pen, /obj/item/clothing/mask/cigarette) + var/obj/item/inserted_item //Used for pen, crayon, and lipstick insertion or removal. Same as above. + var/list/overlays_offsets // offsets to use for certain overlays + var/overlays_x_offset = 0 + var/overlays_y_offset = 0 + + var/underline_flag = TRUE //flag for underline + +/obj/item/pda/suicide_act(mob/living/carbon/user) + var/deathMessage = msg_input(user) + if (!deathMessage) + deathMessage = "i ded" + user.visible_message("[user] is sending a message to the Grim Reaper! It looks like [user.p_theyre()] trying to commit suicide!") + tnote += "→ To The Grim Reaper:
    [deathMessage]
    "//records a message in their PDA as being sent to the grim reaper + return BRUTELOSS + +/obj/item/pda/examine(mob/user) + . = ..() + . += id ? "Alt-click to remove the id." : "" + if(inserted_item && (!isturf(loc))) + . += "Ctrl-click to remove [inserted_item]." + if(LAZYLEN(GLOB.pda_reskins)) + . += "Ctrl-shift-click it to reskin it." + +/obj/item/pda/Initialize() + . = ..() + if(fon) + set_light(f_lum, f_pow, f_col) + + GLOB.PDAs += src + if(default_cartridge) + cartridge = new default_cartridge(src) + if(inserted_item) + inserted_item = new inserted_item(src) + else + inserted_item = new /obj/item/pen(src) + update_icon(FALSE, TRUE) + +/obj/item/pda/CtrlShiftClick(mob/living/user) + . = ..() + if(GLOB.pda_reskins && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY)) + reskin_obj(user) + +/obj/item/pda/reskin_obj(mob/M) + if(!LAZYLEN(GLOB.pda_reskins)) + return + var/dat = "Reskin options for [name]:" + for(var/V in GLOB.pda_reskins) + var/output = icon2html(GLOB.pda_reskins[V], M, icon_state) + dat += "\n[V]: [output]" + to_chat(M, dat) + + var/choice = input(M, "Choose the a reskin for [src]","Reskin Object") as null|anything in GLOB.pda_reskins + var/new_icon = GLOB.pda_reskins[choice] + if(QDELETED(src) || isnull(new_icon) || new_icon == icon || !M.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) + return + icon = new_icon + update_icon(FALSE, TRUE) + to_chat(M, "[src] is now skinned as '[choice]'.") + +/obj/item/pda/proc/set_new_overlays() + if(!overlays_offsets || !(icon in overlays_offsets)) + overlays_x_offset = 0 + overlays_y_offset = 0 + else + var/list/new_offsets = overlays_offsets[icon] + if(new_offsets) + overlays_x_offset = new_offsets[1] + overlays_y_offset = new_offsets[2] + if(!(icon in overlays_icons)) + current_overlays = PDA_STANDARD_OVERLAYS + return + current_overlays = overlays_icons[icon] + +/obj/item/pda/equipped(mob/user, slot) + . = ..() + if(equipped) + return + if(user.client) + background_color = user.client.prefs.pda_color + switch(user.client.prefs.pda_style) + if(MONO) + font_index = MODE_MONO + font_mode = FONT_MONO + if(SHARE) + font_index = MODE_SHARE + font_mode = FONT_SHARE + if(ORBITRON) + font_index = MODE_ORBITRON + font_mode = FONT_ORBITRON + if(VT) + font_index = MODE_VT + font_mode = FONT_VT + else + font_index = MODE_MONO + font_mode = FONT_MONO + var/pref_skin = GLOB.pda_reskins[user.client.prefs.pda_skin] + if(icon != pref_skin) + icon = pref_skin + update_icon(FALSE, TRUE) + equipped = TRUE + +/obj/item/pda/proc/update_label() + name = "PDA-[owner] ([ownjob])" //Name generalisation + +/obj/item/pda/GetAccess() + if(id) + return id.GetAccess() + else + return ..() + +/obj/item/pda/GetID() + return id + +/obj/item/pda/RemoveID() + return do_remove_id() + +/obj/item/pda/InsertID(obj/item/inserting_item) + var/obj/item/card/inserting_id = inserting_item.RemoveID() + if(!inserting_id) + return + insert_id(inserting_id) + if(id == inserting_id) + return TRUE + return FALSE + +/obj/item/pda/update_icon(alert = FALSE, new_overlays = FALSE) + if(new_overlays) + set_new_overlays() + cut_overlays() + add_overlay(alert ? current_overlays[PDA_OVERLAY_ALERT] : current_overlays[PDA_OVERLAY_SCREEN]) + var/mutable_appearance/overlay = new() + overlay.pixel_x = overlays_x_offset + if(id) + overlay.icon_state = current_overlays[PDA_OVERLAY_ID] + add_overlay(new /mutable_appearance(overlay)) + if(inserted_item) + overlay.icon_state = current_overlays[PDA_OVERLAY_ITEM] + add_overlay(new /mutable_appearance(overlay)) + if(fon) + overlay.icon_state = current_overlays[PDA_OVERLAY_LIGHT] + add_overlay(new /mutable_appearance(overlay)) + if(pai) + overlay.icon_state = "[current_overlays[PDA_OVERLAY_PAI]][pai.pai ? "" : "_off"]" + add_overlay(new /mutable_appearance(overlay)) + +/obj/item/pda/MouseDrop(mob/over, src_location, over_location) + var/mob/M = usr + if((M == over) && usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) + return attack_self(M) + return ..() + +/obj/item/pda/attack_self_tk(mob/user) + to_chat(user, "The PDA's capacitive touch screen doesn't seem to respond!") + return + +/obj/item/pda/interact(mob/user) + if(!user.IsAdvancedToolUser()) + to_chat(user, "You don't have the dexterity to do this!") + return + + ..() + + var/datum/asset/spritesheet/assets = get_asset_datum(/datum/asset/spritesheet/simple/pda) + assets.send(user) + + user.set_machine(src) + + var/dat = "Personal Data Assistant" + dat += assets.css_tag() + + dat += "[PDAIMG(refresh)]Refresh" + + if ((!isnull(cartridge)) && (mode == 0)) + dat += " | [PDAIMG(eject)]Eject [cartridge]" + if (mode) + dat += " | [PDAIMG(menu)]Return" + + if (mode == 0) + dat += "
    " + dat += "
    Toggle Font" + dat += " | Change Color" + dat += " | Toggle Underline" //underline button + + dat += "
    " + + dat += "
    " + + if (!owner) + dat += "Warning: No owner information entered. Please swipe card.

    " + dat += "[PDAIMG(refresh)]Retry" + else + switch (mode) + if (0) + dat += "

    PERSONAL DATA ASSISTANT v.1.2

    " + dat += "Owner: [owner], [ownjob]
    " + dat += text("ID: [id ? "[id.registered_name], [id.assignment]" : "----------"]") + dat += text("
    [id ? "Update PDA Info" : ""]

    ") + + dat += "[STATION_TIME_TIMESTAMP("hh:mm:ss")]
    " //:[world.time / 100 % 6][world.time / 100 % 10]" + dat += "[time2text(world.realtime, "MMM DD")] [GLOB.year_integer]" + + dat += "

    " + + dat += "

    General Functions

    " + dat += "" + if (cartridge.access & CART_ENGINE) + dat += "

    Engineering Functions

    " + dat += "" + if (cartridge.access & CART_MEDICAL) + dat += "

    Medical Functions

    " + dat += "" + if (cartridge.access & CART_SECURITY) + dat += "

    Security Functions

    " + dat += "" + if(cartridge.access & CART_QUARTERMASTER) + dat += "

    Quartermaster Functions:

    " + dat += "" + dat += "" + + dat += "

    Utilities

    " + dat += "" + + if (1) + dat += "

    [PDAIMG(notes)] Notekeeper V2.2

    " + dat += "Edit
    " + if(notescanned) + dat += "(This is a scanned image, editing it may cause some text formatting to change.)
    " + dat += "
    [(!notehtml ? note : notehtml)]" + + if (2) + dat += "

    [PDAIMG(mail)] SpaceMessenger V3.9.6

    " + dat += "[PDAIMG(bell)]Ringer: [silent == 1 ? "Off" : "On"] | " + dat += "[PDAIMG(mail)]Send / Receive: [toff == 1 ? "Off" : "On"] | " + dat += "[PDAIMG(bell)]Set Ringtone | " + dat += "[PDAIMG(mail)]Messages
    " + + if(cartridge) + dat += cartridge.message_header() + + dat += "

    [PDAIMG(menu)] Detected PDAs

    " + + dat += "
      " + var/count = 0 + + if (!toff) + for (var/obj/item/pda/P in sortNames(get_viewable_pdas())) + if (P == src) + continue + dat += "
    • [P]" + if(cartridge) + dat += cartridge.message_special(P) + dat += "
    • " + count++ + dat += "
    " + if (count == 0) + dat += "None detected.
    " + else if(cartridge && cartridge.spam_enabled) + dat += "Send To All" + + if(21) + dat += "

    [PDAIMG(mail)] SpaceMessenger V3.9.6

    " + dat += "[PDAIMG(blank)]Clear Messages" + + dat += "

    [PDAIMG(mail)] Messages

    " + + dat += tnote + dat += "
    " + + if (3) + dat += "

    [PDAIMG(atmos)] Atmospheric Readings

    " + + var/turf/T = user.loc + if (isnull(T)) + dat += "Unable to obtain a reading.
    " + else + var/datum/gas_mixture/environment = T.return_air() + var/list/env_gases = environment.gases + + var/pressure = environment.return_pressure() + var/total_moles = environment.total_moles() + + dat += "Air Pressure: [round(pressure,0.1)] kPa
    " + + if (total_moles) + for(var/id in env_gases) + var/gas_level = env_gases[id]/total_moles + if(gas_level > 0) + dat += "[GLOB.meta_gas_names[id]]: [round(gas_level*100, 0.01)]%
    " + + dat += "Temperature: [round(environment.temperature-T0C)]°C
    " + dat += "
    " + else//Else it links to the cart menu proc. Although, it really uses menu hub 4--menu 4 doesn't really exist as it simply redirects to hub. + dat += cartridge.generate_menu() + + dat += "" + + if (underline_flag) + dat = replacetext(dat, "text-decoration:none", "text-decoration:underline") + if (!underline_flag) + dat = replacetext(dat, "text-decoration:underline", "text-decoration:none") + + user << browse(dat, "window=pda;size=400x450;border=1;can_resize=1;can_minimize=0") + onclose(user, "pda", src) + +/obj/item/pda/Topic(href, href_list) + ..() + var/mob/living/U = usr + //Looking for master was kind of pointless since PDAs don't appear to have one. + + if(usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK) && !href_list["close"]) + add_fingerprint(U) + U.set_machine(src) + + switch(href_list["choice"]) + +//BASIC FUNCTIONS=================================== + + if("Refresh")//Refresh, goes to the end of the proc. + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if ("Toggle_Font") + //CODE REVISION 2 + font_index = (font_index + 1) % 4 + + switch(font_index) + if (MODE_MONO) + font_mode = FONT_MONO + if (MODE_SHARE) + font_mode = FONT_SHARE + if (MODE_ORBITRON) + font_mode = FONT_ORBITRON + if (MODE_VT) + font_mode = FONT_VT + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if ("Change_Color") + var/new_color = input("Please enter a color name or hex value (Default is \'#808000\').",background_color)as color + background_color = new_color + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if ("Toggle_Underline") + underline_flag = !underline_flag + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if("Return")//Return + if(mode<=9) + mode = 0 + else + mode = round(mode/10) + if(mode==4 || mode == 5)//Fix for cartridges. Redirects to hub. + mode = 0 + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if ("Authenticate")//Checks for ID + id_check(U) + + if("UpdateInfo") + ownjob = id.assignment + if(istype(id, /obj/item/card/id/syndicate)) + owner = id.registered_name + update_label() + if (!silent) + playsound(src, 'sound/machines/terminal_processing.ogg', 15, 1) + addtimer(CALLBACK(GLOBAL_PROC, .proc/playsound, src, 'sound/machines/terminal_success.ogg', 15, 1), 13) + + if("Eject")//Ejects the cart, only done from hub. + if (!isnull(cartridge)) + U.put_in_hands(cartridge) + to_chat(U, "You remove [cartridge] from [src].") + scanmode = PDA_SCANNER_NONE + cartridge.host_pda = null + cartridge = null + update_icon() + if (!silent) + playsound(src, 'sound/machines/terminal_eject_disc.ogg', 50, 1) + +//MENU FUNCTIONS=================================== + + if("0")//Hub + mode = 0 + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + if("1")//Notes + mode = 1 + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + if("2")//Messenger + mode = 2 + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + if("21")//Read messeges + mode = 21 + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + if("3")//Atmos scan + mode = 3 + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + if("4")//Redirects to hub + mode = 0 + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + +//MAIN FUNCTIONS=================================== + + if("Light") + toggle_light() + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if("Medical Scan") + if(scanmode == PDA_SCANNER_MEDICAL) + scanmode = PDA_SCANNER_NONE + else if((!isnull(cartridge)) && (cartridge.access & CART_MEDICAL)) + scanmode = PDA_SCANNER_MEDICAL + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if("Reagent Scan") + if(scanmode == PDA_SCANNER_REAGENT) + scanmode = PDA_SCANNER_NONE + else if((!isnull(cartridge)) && (cartridge.access & CART_REAGENT_SCANNER)) + scanmode = PDA_SCANNER_REAGENT + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if("Halogen Counter") + if(scanmode == PDA_SCANNER_HALOGEN) + scanmode = PDA_SCANNER_NONE + else if((!isnull(cartridge)) && (cartridge.access & CART_ENGINE)) + scanmode = PDA_SCANNER_HALOGEN + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if("Honk") + if ( !(last_noise && world.time < last_noise + 20) ) + playsound(src, 'sound/items/bikehorn.ogg', 50, 1) + last_noise = world.time + + if("Trombone") + if ( !(last_noise && world.time < last_noise + 20) ) + playsound(src, 'sound/misc/sadtrombone.ogg', 50, 1) + last_noise = world.time + + if("Gas Scan") + if(scanmode == PDA_SCANNER_GAS) + scanmode = PDA_SCANNER_NONE + else if((!isnull(cartridge)) && (cartridge.access & CART_ATMOS)) + scanmode = PDA_SCANNER_GAS + if (!silent) + playsound(src, 'sound/machines/terminal_select.ogg', 15, 1) + + if("Drone Phone") + var/alert_s = input(U,"Alert severity level","Ping Drones",null) as null|anything in list("Low","Medium","High","Critical") + var/area/A = get_area(U) + if(A && alert_s && !QDELETED(U)) + var/msg = "NON-DRONE PING: [U.name]: [alert_s] priority alert in [A.name]!" + _alert_drones(msg, TRUE, U) + to_chat(U, msg) + if (!silent) + playsound(src, 'sound/machines/terminal_success.ogg', 15, 1) + + +//NOTEKEEPER FUNCTIONS=================================== + + if ("Edit") + var/n = stripped_multiline_input(U, "Please enter message", name, note) + if (in_range(src, U) && loc == U) + if (mode == 1 && n) + note = n + notehtml = parsemarkdown(n, U) + notescanned = FALSE + else + U << browse(null, "window=pda") + return + +//MESSENGER FUNCTIONS=================================== + + if("Toggle Messenger") + toff = !toff + if("Toggle Ringer")//If viewing texts then erase them, if not then toggle silent status + silent = !silent + if("Clear")//Clears messages + tnote = null + if("Ringtone") + var/t = stripped_input(U, "Please enter new ringtone", name, ttone, 20) + if(in_range(src, U) && loc == U && t) + if(SEND_SIGNAL(src, COMSIG_PDA_CHANGE_RINGTONE, U, t) & COMPONENT_STOP_RINGTONE_CHANGE) + U << browse(null, "window=pda") + return + else + ttone = t + else + U << browse(null, "window=pda") + return + if("Message") + create_message(U, locate(href_list["target"])) + + if("MessageAll") + send_to_all(U) + + if("cart") + if(cartridge) + cartridge.special(U, href_list) + else + U << browse(null, "window=pda") + return + +//SYNDICATE FUNCTIONS=================================== + + if("Toggle Door") + if(cartridge && cartridge.access & CART_REMOTE_DOOR) + for(var/obj/machinery/door/poddoor/M in GLOB.machines) + if(M.id == cartridge.remote_door_id) + if(M.density) + M.open() + else + M.close() + +//pAI FUNCTIONS=================================== + if("pai") + switch(href_list["option"]) + if("1") // Configure pAI device + pai.attack_self(U) + if("2") // Eject pAI device + var/turf/T = get_turf(loc) + if(T) + pai.forceMove(T) + +//LINK FUNCTIONS=================================== + + else//Cartridge menu linking + mode = max(text2num(href_list["choice"]), 0) + + else//If not in range, can't interact or not using the pda. + U.unset_machine() + U << browse(null, "window=pda") + return + +//EXTRA FUNCTIONS=================================== + + if (mode == 2 || mode == 21)//To clear message overlays. + update_icon() + + if ((honkamt > 0) && (prob(60)))//For clown virus. + honkamt-- + playsound(src, 'sound/items/bikehorn.ogg', 30, 1) + + if(U.machine == src && href_list["skiprefresh"]!="1")//Final safety. + attack_self(U)//It auto-closes the menu prior if the user is not in range and so on. + else + U.unset_machine() + U << browse(null, "window=pda") + return + +/obj/item/pda/proc/remove_id() + if(issilicon(usr) || !usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) + return + do_remove_id(usr) + +/obj/item/pda/proc/do_remove_id(mob/user) + if(!id) + return + if(user) + user.put_in_hands(id) + to_chat(user, "You remove the ID from the [name].") + else + id.forceMove(get_turf(src)) + + . = id + id = null + update_icon() + + if(ishuman(loc)) + var/mob/living/carbon/human/H = loc + if(H.wear_id == src) + H.sec_hud_set_ID() + +/obj/item/pda/proc/msg_input(mob/living/U = usr) + var/t = stripped_input(U, "Please enter message", name) + if (!t || toff) + return + if(!U.canUseTopic(src, BE_CLOSE)) + return + if(emped) + t = Gibberish(t, 100) + return t + +/obj/item/pda/proc/send_message(mob/living/user, list/obj/item/pda/targets, everyone) + var/message = msg_input(user) + if(!message || !targets.len) + return + if((last_text && world.time < last_text + 10) || (everyone && last_everyone && world.time < last_everyone + PDA_SPAM_DELAY)) + return + var/emoji_message = emoji_parse(message) + if(prob(1)) + message += "\nSent from my PDA" + // Send the signal + var/list/string_targets = list() + for (var/obj/item/pda/P in targets) + if (P.owner && P.ownjob) // != src is checked by the UI + string_targets += "[P.owner] ([P.ownjob])" + for (var/obj/machinery/computer/message_monitor/M in targets) + // In case of "Reply" to a message from a console, this will make the + // message be logged successfully. If the console is impersonating + // someone by matching their name and job, the reply will reach the + // impersonated PDA. + string_targets += "[M.customsender] ([M.customjob])" + if (!string_targets.len) + return + + var/datum/signal/subspace/pda/signal = new(src, list( + "name" = "[owner]", + "job" = "[ownjob]", + "message" = message, + "targets" = string_targets, + "emoji_message" = emoji_message + )) + if (picture) + signal.data["photo"] = picture + signal.send_to_receivers() + + // If it didn't reach, note that fact + if (!signal.data["done"]) + to_chat(user, "ERROR: Server isn't responding.") + return + if (!silent) + playsound(src, 'sound/machines/terminal_error.ogg', 15, 1) + + var/target_text = signal.format_target() + // Log it in our logs + tnote += "→ To [target_text]:
    [signal.format_message()]
    " + // Show it to ghosts + var/ghost_message = "[owner] PDA Message --> [target_text]: [signal.format_message(TRUE)]" + for(var/mob/M in GLOB.player_list) + if(isobserver(M) && M.client && (M.client.prefs.chat_toggles & CHAT_GHOSTPDA)) + to_chat(M, "[FOLLOW_LINK(M, user)] [ghost_message]") + // Log in the talk log + user.log_talk(message, LOG_PDA, tag="PDA: [initial(name)] to [target_text]") + to_chat(user, "Message sent to [target_text]: \"[emoji_message]\"") + if (!silent) + playsound(src, 'sound/machines/terminal_success.ogg', 15, 1) + // Reset the photo + picture = null + last_text = world.time + if (everyone) + last_everyone = world.time + +/obj/item/pda/proc/receive_message(datum/signal/subspace/pda/signal) + tnote += "← From [signal.data["name"]] ([signal.data["job"]]):
    [signal.format_message()]
    " + + if (!silent) + playsound(src, 'sound/machines/twobeep.ogg', 50, 1) + audible_message("[icon2html(src, hearers(src))] *[ttone]*", null, 3) + //Search for holder of the PDA. + var/mob/living/L = null + if(loc && isliving(loc)) + L = loc + //Maybe they are a pAI! + else + L = get(src, /mob/living/silicon) + + if(L && L.stat != UNCONSCIOUS) + var/hrefstart + var/hrefend + if (isAI(L)) + hrefstart = "" + hrefend = "" + + to_chat(L, "[icon2html(src)] Message from [hrefstart][signal.data["name"]] ([signal.data["job"]])[hrefend], [signal.format_message(TRUE)] (Reply)") + + update_icon(TRUE) + +/obj/item/pda/proc/send_to_all(mob/living/U) + if (last_everyone && world.time < last_everyone + PDA_SPAM_DELAY) + to_chat(U,"Send To All function is still on cooldown.") + return + send_message(U,get_viewable_pdas(), TRUE) + +/obj/item/pda/proc/create_message(mob/living/U, obj/item/pda/P) + send_message(U,list(P)) + +/obj/item/pda/AltClick() + . = ..() + if(id) + remove_id() + playsound(src, 'sound/machines/terminal_eject_disc.ogg', 50, 1) + else + remove_pen() + playsound(src, 'sound/machines/button4.ogg', 50, 1) + return TRUE + +/obj/item/pda/CtrlClick() + ..() + + if(isturf(loc)) //stops the user from dragging the PDA by ctrl-clicking it. + return + + remove_pen() + +/obj/item/pda/verb/verb_toggle_light() + set category = "Object" + set name = "Toggle Flashlight" + + toggle_light() + +/obj/item/pda/verb/verb_remove_id() + set category = "Object" + set name = "Eject ID" + set src in usr + + if(id) + remove_id() + else + to_chat(usr, "This PDA does not have an ID in it!") + +/obj/item/pda/verb/verb_remove_pen() + set category = "Object" + set name = "Remove Pen" + set src in usr + + remove_pen() + +/obj/item/pda/proc/toggle_light() + if(issilicon(usr) || !usr.canUseTopic(src, BE_CLOSE)) + return + if(fon) + fon = FALSE + set_light(0) + else if(f_lum) + fon = TRUE + set_light(f_lum, f_pow, f_col) + update_icon() + +/obj/item/pda/proc/remove_pen() + + if(issilicon(usr) || !usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) + return + + if(inserted_item) + usr.put_in_hands(inserted_item) + to_chat(usr, "You remove [inserted_item] from [src].") + inserted_item = null + update_icon() + else + to_chat(usr, "This PDA does not have a pen in it!") + +//trying to insert or remove an id +/obj/item/pda/proc/id_check(mob/user, obj/item/card/id/I) + if(!I) + if(id && (src in user.contents)) + remove_id() + return TRUE + else + var/obj/item/card/id/C = user.get_active_held_item() + if(istype(C)) + I = C + + if(I?.registered_name) + if(!user.transferItemToLoc(I, src)) + return FALSE + insert_id(I, user) + update_icon() + playsound(src, 'sound/machines/button.ogg', 50, 1) + return TRUE + +/obj/item/pda/proc/insert_id(obj/item/card/id/inserting_id, mob/user) + var/obj/old_id = id + id = inserting_id + if(ishuman(loc)) + var/mob/living/carbon/human/human_wearer = loc + if(human_wearer.wear_id == src) + human_wearer.sec_hud_set_ID() + if(old_id) + if(user) + user.put_in_hands(old_id) + else + old_id.forceMove(get_turf(src)) + +// access to status display signals +/obj/item/pda/attackby(obj/item/C, mob/user, params) + if(istype(C, /obj/item/cartridge) && !cartridge) + if(!user.transferItemToLoc(C, src)) + return + cartridge = C + cartridge.host_pda = src + to_chat(user, "You insert [cartridge] into [src].") + update_icon() + playsound(src, 'sound/machines/button.ogg', 50, 1) + + else if(istype(C, /obj/item/card/id)) + var/obj/item/card/id/idcard = C + if(!idcard.registered_name) + to_chat(user, "\The [src] rejects the ID!") + return + if (!silent) + playsound(src, 'sound/machines/terminal_error.ogg', 15, 1) + + if(!owner) + owner = idcard.registered_name + ownjob = idcard.assignment + update_label() + to_chat(user, "Card scanned.") + if (!silent) + playsound(src, 'sound/machines/terminal_success.ogg', 15, 1) + else + //Basic safety check. If either both objects are held by user or PDA is on ground and card is in hand. + if(((src in user.contents) || (isturf(loc) && in_range(src, user))) && (C in user.contents)) + if(!id_check(user, idcard)) + return + to_chat(user, "You put the ID into \the [src]'s slot.") + updateSelfDialog()//Update self dialog on success. + return //Return in case of failed check or when successful. + updateSelfDialog()//For the non-input related code. + else if(istype(C, /obj/item/paicard) && !pai) + if(!user.transferItemToLoc(C, src)) + return + pai = C + to_chat(user, "You slot \the [C] into [src].") + update_icon() + updateUsrDialog() + else if(is_type_in_list(C, contained_item)) //Checks if there is a pen + if(inserted_item) + to_chat(user, "There is already \a [inserted_item] in \the [src]!") + else + if(!user.transferItemToLoc(C, src)) + return + to_chat(user, "You slide \the [C] into \the [src].") + inserted_item = C + update_icon() + playsound(src, 'sound/machines/button.ogg', 50, 1) + + else if(istype(C, /obj/item/photo)) + var/obj/item/photo/P = C + picture = P.picture + to_chat(user, "You scan \the [C].") + else + return ..() + +/obj/item/pda/attack(mob/living/carbon/C, mob/living/user) + if(istype(C)) + switch(scanmode) + + if(PDA_SCANNER_MEDICAL) + C.visible_message("[user] has analyzed [C]'s vitals!") + healthscan(user, C, 1) + add_fingerprint(user) + + if(PDA_SCANNER_HALOGEN) + C.visible_message("[user] has analyzed [C]'s radiation levels!") + + user.show_message("Analyzing Results for [C]:") + if(C.radiation) + user.show_message("\green Radiation Level: \black [C.radiation]") + else + user.show_message("No radiation detected.") + +/obj/item/pda/afterattack(atom/A as mob|obj|turf|area, mob/user, proximity) + . = ..() + if(!proximity) + return + switch(scanmode) + if(PDA_SCANNER_REAGENT) + if(!isnull(A.reagents)) + if(A.reagents.reagent_list.len > 0) + var/reagents_length = A.reagents.reagent_list.len + to_chat(user, "[reagents_length] chemical agent[reagents_length > 1 ? "s" : ""] found.") + for (var/re in A.reagents.reagent_list) + to_chat(user, "\t [re]") + else + to_chat(user, "No active chemical agents found in [A].") + else + to_chat(user, "No significant chemical agents found in [A].") + + if(PDA_SCANNER_GAS) + A.analyzer_act(user, src) + + if (!scanmode && istype(A, /obj/item/paper) && owner) + var/obj/item/paper/PP = A + if (!PP.info) + to_chat(user, "Unable to scan! Paper is blank.") + return + notehtml = PP.info + note = replacetext(notehtml, "
    ", "\[br\]") + note = replacetext(note, "
  • ", "\[*\]") + note = replacetext(note, "
      ", "\[list\]") + note = replacetext(note, "
    ", "\[/list\]") + note = html_encode(note) + notescanned = TRUE + to_chat(user, "Paper scanned. Saved to PDA's notekeeper." ) + + +/obj/item/pda/proc/explode() //This needs tuning. + if(!detonatable) + return + var/turf/T = get_turf(src) + + if (ismob(loc)) + var/mob/M = loc + M.show_message("Your [src] explodes!", MSG_VISUAL, "You hear a loud *pop*!", MSG_AUDIBLE) + else + visible_message("[src] explodes!", "You hear a loud *pop*!") + + if(T) + T.hotspot_expose(700,125) + if(istype(cartridge, /obj/item/cartridge/virus/syndicate)) + explosion(T, -1, 1, 3, 4) + else + explosion(T, -1, -1, 2, 3) + qdel(src) + return + +/obj/item/pda/Destroy() + GLOB.PDAs -= src + if(istype(id)) + QDEL_NULL(id) + if(istype(cartridge)) + QDEL_NULL(cartridge) + if(istype(pai)) + QDEL_NULL(pai) + if(istype(inserted_item)) + QDEL_NULL(inserted_item) + return ..() + +//AI verb and proc for sending PDA messages. + +/mob/living/silicon/ai/proc/cmd_send_pdamesg(mob/user) + var/list/plist = list() + var/list/namecounts = list() + + if(aiPDA.toff) + to_chat(user, "Turn on your receiver in order to send messages.") + return + + for (var/obj/item/pda/P in get_viewable_pdas()) + if (P == src) + continue + else if (P == aiPDA) + continue + + plist[avoid_assoc_duplicate_keys(P.owner, namecounts)] = P + + var/c = input(user, "Please select a PDA") as null|anything in sortList(plist) + + if (!c) + return + + var/selected = plist[c] + + if(aicamera.stored.len) + var/add_photo = input(user,"Do you want to attach a photo?","Photo","No") as null|anything in list("Yes","No") + if(add_photo=="Yes") + var/datum/picture/Pic = aicamera.selectpicture(user) + aiPDA.picture = Pic + + if(incapacitated()) + return + + aiPDA.create_message(src, selected) + + +/mob/living/silicon/ai/verb/cmd_toggle_pda_receiver() + set category = "AI Commands" + set name = "PDA - Toggle Sender/Receiver" + if(usr.stat == DEAD) + return //won't work if dead + if(!isnull(aiPDA)) + aiPDA.toff = !aiPDA.toff + to_chat(usr, "PDA sender/receiver toggled [(aiPDA.toff ? "Off" : "On")]!") + else + to_chat(usr, "You do not have a PDA. You should make an issue report about this.") + +/mob/living/silicon/ai/verb/cmd_toggle_pda_silent() + set category = "AI Commands" + set name = "PDA - Toggle Ringer" + if(usr.stat == DEAD) + return //won't work if dead + if(!isnull(aiPDA)) + //0 + aiPDA.silent = !aiPDA.silent + to_chat(usr, "PDA ringer toggled [(aiPDA.silent ? "Off" : "On")]!") + else + to_chat(usr, "You do not have a PDA. You should make an issue report about this.") + +/mob/living/silicon/ai/proc/cmd_show_message_log(mob/user) + if(incapacitated()) + return + if(!isnull(aiPDA)) + var/HTML = "AI PDA Message Log[aiPDA.tnote]" + user << browse(HTML, "window=log;size=400x444;border=1;can_resize=1;can_close=1;can_minimize=0") + else + to_chat(user, "You do not have a PDA. You should make an issue report about this.") + + +// Pass along the pulse to atoms in contents, largely added so pAIs are vulnerable to EMP +/obj/item/pda/emp_act(severity) + . = ..() + if (!(. & EMP_PROTECT_CONTENTS)) + for(var/atom/A in src) + A.emp_act(severity) + if (!(. & EMP_PROTECT_SELF)) + emped += 1 + spawn(200 * severity) + emped -= 1 + +/proc/get_viewable_pdas() + . = list() + // Returns a list of PDAs which can be viewed from another PDA/message monitor. + for(var/obj/item/pda/P in GLOB.PDAs) + if(!P.owner || P.toff || P.hidden) + continue + . += P + +#undef PDA_SCANNER_NONE +#undef PDA_SCANNER_MEDICAL +#undef PDA_SCANNER_FORENSICS +#undef PDA_SCANNER_REAGENT +#undef PDA_SCANNER_HALOGEN +#undef PDA_SCANNER_GAS +#undef PDA_SPAM_DELAY +#undef PDA_STANDARD_OVERLAYS + +#undef PDA_OVERLAY_ALERT +#undef PDA_OVERLAY_SCREEN +#undef PDA_OVERLAY_ID +#undef PDA_OVERLAY_ITEM +#undef PDA_OVERLAY_LIGHT +#undef PDA_OVERLAY_PAI diff --git a/code/game/objects/items/devices/PDA/cart.dm b/code/game/objects/items/devices/PDA/cart.dm index 7ba20c37..a5d954c0 100644 --- a/code/game/objects/items/devices/PDA/cart.dm +++ b/code/game/objects/items/devices/PDA/cart.dm @@ -308,9 +308,14 @@ Code: var/list/S = list(" Off","AOff"," On", " AOn") var/list/chg = list("N","C","F") +//Neither copytext nor copytext_char is appropriate here; neither 30 UTF-8 code units nor 30 code points equates to 30 columns of output. +//Some glyphs are very tall or very wide while others are small or even take up no space at all. +//Emojis can take modifiers which are many characters but render as only one glyph. +//A proper solution here (as far as Unicode goes, maybe not ideal as far as markup goes, a table would be better) +//would be to use [A.area.name] for(var/obj/machinery/power/apc/A in L) - menu += copytext(add_tspace(A.area.name, 30), 1, 30) - menu += " [S[A.equipment+1]] [S[A.lighting+1]] [S[A.environ+1]] [add_lspace(DisplayPower(A.lastused_total), 6)] [A.cell ? "[add_lspace(round(A.cell.percent()), 3)]% [chg[A.charging+1]]" : " N/C"]
    " + menu += copytext_char(add_trailing(A.area.name, 30, " "), 1, 30) + menu += " [S[A.equipment+1]] [S[A.lighting+1]] [S[A.environ+1]] [add_leading(DisplayPower(A.lastused_total), 6, " ")] [A.cell ? "[add_leading(round(A.cell.percent()), 3, " ")]% [chg[A.charging+1]]" : " N/C"]
    " menu += "" diff --git a/code/game/objects/items/devices/paicard.dm b/code/game/objects/items/devices/paicard.dm index 9cd8e4d2..673a134d 100644 --- a/code/game/objects/items/devices/paicard.dm +++ b/code/game/objects/items/devices/paicard.dm @@ -97,7 +97,7 @@ if(pai.radio) pai.radio.wires.cut(wire) if(href_list["setlaws"]) - var/newlaws = copytext(sanitize(input("Enter any additional directives you would like your pAI personality to follow. Note that these directives will not override the personality's allegiance to its imprinted master. Conflicting directives will be ignored.", "pAI Directive Configuration", pai.laws.supplied[1]) as message),1,MAX_MESSAGE_LEN) + var/newlaws = stripped_multiline_input("Enter any additional directives you would like your pAI personality to follow. Note that these directives will not override the personality's allegiance to its imprinted master. Conflicting directives will be ignored.", "pAI Directive Configuration", MAX_MESSAGE_LEN) if(newlaws && pai) pai.add_supplied_law(0,newlaws) if(href_list["toggle_holo"]) diff --git a/code/game/objects/items/devices/radio/electropack.dm b/code/game/objects/items/devices/radio/electropack.dm index f4681210..a73efee1 100644 --- a/code/game/objects/items/devices/radio/electropack.dm +++ b/code/game/objects/items/devices/radio/electropack.dm @@ -1,146 +1,146 @@ -/obj/item/electropack - name = "electropack" - desc = "Dance my monkeys! DANCE!!!" - icon = 'icons/obj/radio.dmi' - icon_state = "electropack0" - item_state = "electropack" - lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi' - righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi' - flags_1 = CONDUCT_1 - slot_flags = ITEM_SLOT_BACK - w_class = WEIGHT_CLASS_HUGE - materials = list(MAT_METAL=10000, MAT_GLASS=2500) - - var/code = 2 - var/frequency = FREQ_ELECTROPACK - var/on = TRUE - var/shock_cooldown = FALSE - -/obj/item/electropack/suicide_act(mob/living/carbon/user) - user.visible_message("[user] hooks [user.p_them()]self to the electropack and spams the trigger! It looks like [user.p_theyre()] trying to commit suicide!") - return (FIRELOSS) - -/obj/item/electropack/Initialize() - . = ..() - set_frequency(frequency) - -/obj/item/electropack/Destroy() - SSradio.remove_object(src, frequency) - . = ..() - -//ATTACK HAND IGNORING PARENT RETURN VALUE -/obj/item/electropack/attack_hand(mob/user) - if(iscarbon(user)) - var/mob/living/carbon/C = user - if(src == C.back) - to_chat(user, "You need help taking this off!") - return - return ..() - -/obj/item/electropack/attackby(obj/item/W, mob/living/user, params) - if(istype(W, /obj/item/clothing/head/helmet)) - var/obj/item/assembly/shock_kit/A = new /obj/item/assembly/shock_kit(user) - A.icon = 'icons/obj/assemblies.dmi' - - if(!user.transferItemToLoc(W, A)) - to_chat(user, "[W] is stuck to your hand, you cannot attach it to [src]!") - return - W.master = A - A.part1 = W - - user.transferItemToLoc(src, A, TRUE) - master = A - A.part2 = src - - user.put_in_hands(A) - A.add_fingerprint(user) - else - return ..() - -/obj/item/electropack/Topic(href, href_list) - var/mob/living/carbon/C = usr - if(usr.stat || usr.restrained() || C.back == src) - return - - if(!usr.canUseTopic(src, BE_CLOSE)) - usr << browse(null, "window=radio") - onclose(usr, "radio") - return - - if(href_list["set"]) - if(href_list["set"] == "freq") - var/new_freq = input(usr, "Input a new receiving frequency", "Electropack Frequency", format_frequency(frequency)) as num|null - if(!usr.canUseTopic(src, BE_CLOSE)) - return - new_freq = unformat_frequency(new_freq) - new_freq = sanitize_frequency(new_freq, TRUE) - set_frequency(new_freq) - - if(href_list["set"] == "code") - var/new_code = input(usr, "Input a new receiving code", "Electropack Code", code) as num|null - if(!usr.canUseTopic(src, BE_CLOSE)) - return - new_code = round(new_code) - new_code = CLAMP(new_code, 1, 100) - code = new_code - - if(href_list["set"] == "power") - if(!usr.canUseTopic(src, BE_CLOSE)) - return - on = !(on) - icon_state = "electropack[on]" - - if(usr) - attack_self(usr) - - return - -/obj/item/electropack/proc/set_frequency(new_frequency) - SSradio.remove_object(src, frequency) - frequency = new_frequency - SSradio.add_object(src, frequency, RADIO_SIGNALER) - return - -/obj/item/electropack/receive_signal(datum/signal/signal) - if(!signal || signal.data["code"] != code) - return - - if(isliving(loc) && on) - if(shock_cooldown == TRUE) - return - shock_cooldown = TRUE - addtimer(VARSET_CALLBACK(src, shock_cooldown, FALSE), 100) - var/mob/living/L = loc - step(L, pick(GLOB.cardinals)) - - to_chat(L, "You feel a sharp shock!") - var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread - s.set_up(3, 1, L) - s.start() - - L.Knockdown(100) - - if(master) - master.receive_signal() - return - -/obj/item/electropack/ui_interact(mob/user) - if(!ishuman(user)) - return - - user.set_machine(src) - var/dat = {" - -Turned [on ? "On" : "Off"] - Toggle
    -Frequency/Code for electropack:
    -Frequency: -[format_frequency(src.frequency)] -Set
    - -Code: -[src.code] -Set
    -
    "} - user << browse(dat, "window=radio") - onclose(user, "radio") - return +/obj/item/electropack + name = "electropack" + desc = "Dance my monkeys! DANCE!!!" + icon = 'icons/obj/radio.dmi' + icon_state = "electropack0" + item_state = "electropack" + lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi' + righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi' + flags_1 = CONDUCT_1 + slot_flags = ITEM_SLOT_BACK + w_class = WEIGHT_CLASS_HUGE + materials = list(MAT_METAL=10000, MAT_GLASS=2500) + + var/code = 2 + var/frequency = FREQ_ELECTROPACK + var/on = TRUE + var/shock_cooldown = FALSE + +/obj/item/electropack/suicide_act(mob/living/carbon/user) + user.visible_message("[user] hooks [user.p_them()]self to the electropack and spams the trigger! It looks like [user.p_theyre()] trying to commit suicide!") + return (FIRELOSS) + +/obj/item/electropack/Initialize() + . = ..() + set_frequency(frequency) + +/obj/item/electropack/Destroy() + SSradio.remove_object(src, frequency) + . = ..() + +//ATTACK HAND IGNORING PARENT RETURN VALUE +/obj/item/electropack/attack_hand(mob/user) + if(iscarbon(user)) + var/mob/living/carbon/C = user + if(src == C.back) + to_chat(user, "You need help taking this off!") + return + return ..() + +/obj/item/electropack/attackby(obj/item/W, mob/living/user, params) + if(istype(W, /obj/item/clothing/head/helmet)) + var/obj/item/assembly/shock_kit/A = new /obj/item/assembly/shock_kit(user) + A.icon = 'icons/obj/assemblies.dmi' + + if(!user.transferItemToLoc(W, A)) + to_chat(user, "[W] is stuck to your hand, you cannot attach it to [src]!") + return + W.master = A + A.part1 = W + + user.transferItemToLoc(src, A, TRUE) + master = A + A.part2 = src + + user.put_in_hands(A) + A.add_fingerprint(user) + else + return ..() + +/obj/item/electropack/Topic(href, href_list) + var/mob/living/carbon/C = usr + if(usr.stat || usr.restrained() || C.back == src) + return + + if(!usr.canUseTopic(src, BE_CLOSE)) + usr << browse(null, "window=radio") + onclose(usr, "radio") + return + + if(href_list["set"]) + if(href_list["set"] == "freq") + var/new_freq = input(usr, "Input a new receiving frequency", "Electropack Frequency", format_frequency(frequency)) as num|null + if(!usr.canUseTopic(src, BE_CLOSE)) + return + new_freq = unformat_frequency(new_freq) + new_freq = sanitize_frequency(new_freq, TRUE) + set_frequency(new_freq) + + if(href_list["set"] == "code") + var/new_code = input(usr, "Input a new receiving code", "Electropack Code", code) as num|null + if(!usr.canUseTopic(src, BE_CLOSE)) + return + new_code = round(new_code) + new_code = CLAMP(new_code, 1, 100) + code = new_code + + if(href_list["set"] == "power") + if(!usr.canUseTopic(src, BE_CLOSE)) + return + on = !(on) + icon_state = "electropack[on]" + + if(usr) + attack_self(usr) + + return + +/obj/item/electropack/proc/set_frequency(new_frequency) + SSradio.remove_object(src, frequency) + frequency = new_frequency + SSradio.add_object(src, frequency, RADIO_SIGNALER) + return + +/obj/item/electropack/receive_signal(datum/signal/signal) + if(!signal || signal.data["code"] != code) + return + + if(isliving(loc) && on) + if(shock_cooldown == TRUE) + return + shock_cooldown = TRUE + addtimer(VARSET_CALLBACK(src, shock_cooldown, FALSE), 100) + var/mob/living/L = loc + step(L, pick(GLOB.cardinals)) + + to_chat(L, "You feel a sharp shock!") + var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread + s.set_up(3, 1, L) + s.start() + + L.Knockdown(100) + + if(master) + master.receive_signal() + return + +/obj/item/electropack/ui_interact(mob/user) + if(!ishuman(user)) + return + + user.set_machine(src) + var/dat = {" + +Turned [on ? "On" : "Off"] - Toggle
    +Frequency/Code for electropack:
    +Frequency: +[format_frequency(src.frequency)] +Set
    + +Code: +[src.code] +Set
    +
    "} + user << browse(dat, "window=radio") + onclose(user, "radio") + return diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm index ee0b4fc9..d2c9f5a1 100644 --- a/code/game/objects/items/devices/scanners.dm +++ b/code/game/objects/items/devices/scanners.dm @@ -1,843 +1,843 @@ - -/* - -CONTAINS: -T-RAY -HEALTH ANALYZER -GAS ANALYZER -SLIME SCANNER -NANITE SCANNER -GENE SCANNER - -*/ -/obj/item/t_scanner - name = "\improper T-ray scanner" - desc = "A terahertz-ray emitter and scanner used to detect underfloor objects such as cables and pipes." - icon = 'icons/obj/device.dmi' - icon_state = "t-ray0" - var/on = FALSE - slot_flags = ITEM_SLOT_BELT - w_class = WEIGHT_CLASS_SMALL - item_state = "electronic" - lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi' - righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi' - materials = list(MAT_METAL=150) - -/obj/item/t_scanner/suicide_act(mob/living/carbon/user) - user.visible_message("[user] begins to emit terahertz-rays into [user.p_their()] brain with [src]! It looks like [user.p_theyre()] trying to commit suicide!") - return TOXLOSS - -/obj/item/t_scanner/attack_self(mob/user) - - on = !on - icon_state = copytext(icon_state, 1, length(icon_state))+"[on]" - - if(on) - START_PROCESSING(SSobj, src) - -/obj/item/t_scanner/process() - if(!on) - STOP_PROCESSING(SSobj, src) - return null - scan() - -/obj/item/t_scanner/proc/scan() - t_ray_scan(loc) - -/proc/t_ray_scan(mob/viewer, flick_time = 8, distance = 3) - if(!ismob(viewer) || !viewer.client) - return - var/list/t_ray_images = list() - for(var/obj/O in orange(distance, viewer) ) - if(O.level != 1) - continue - - if(O.invisibility == INVISIBILITY_MAXIMUM) - var/image/I = new(loc = get_turf(O)) - var/mutable_appearance/MA = new(O) - MA.alpha = 128 - MA.dir = O.dir - I.appearance = MA - t_ray_images += I - if(t_ray_images.len) - flick_overlay(t_ray_images, list(viewer.client), flick_time) - -/obj/item/healthanalyzer - name = "health analyzer" - icon = 'icons/obj/device.dmi' - icon_state = "health" - item_state = "healthanalyzer" - lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi' - desc = "A hand-held body scanner able to distinguish vital signs of the subject." - flags_1 = CONDUCT_1 - item_flags = NOBLUDGEON - slot_flags = ITEM_SLOT_BELT - throwforce = 3 - w_class = WEIGHT_CLASS_TINY - throw_speed = 3 - throw_range = 7 - materials = list(MAT_METAL=200) - var/mode = 1 - var/scanmode = 0 - var/advanced = FALSE - -/obj/item/healthanalyzer/suicide_act(mob/living/carbon/user) - user.visible_message("[user] begins to analyze [user.p_them()]self with [src]! The display shows that [user.p_theyre()] dead!") - return BRUTELOSS - -/obj/item/healthanalyzer/attack_self(mob/user) - if(!scanmode) - to_chat(user, "You switch the health analyzer to scan chemical contents.") - scanmode = 1 - else - to_chat(user, "You switch the health analyzer to check physical health.") - scanmode = 0 - -/obj/item/healthanalyzer/attack(mob/living/M, mob/living/carbon/human/user) - - // Clumsiness/brain damage check - if ((HAS_TRAIT(user, TRAIT_CLUMSY) || HAS_TRAIT(user, TRAIT_DUMB)) && prob(50)) - to_chat(user, "You stupidly try to analyze the floor's vitals!") - user.visible_message("[user] has analyzed the floor's vitals!") - var/msg = "*---------*\nAnalyzing results for The floor:\n\tOverall status: Healthy\n" - msg += "Key: Suffocation/Toxin/Burn/Brute\n" - msg += "\tDamage specifics: 0-0-0-0\n" - msg += "Body temperature: ???\n" - msg += "*---------*" - to_chat(user, msg) - return - - user.visible_message("[user] has analyzed [M]'s vitals.") - - if(scanmode == 0) - healthscan(user, M, mode, advanced) - else if(scanmode == 1) - chemscan(user, M) - - add_fingerprint(user) - - -// Used by the PDA medical scanner too -/proc/healthscan(mob/user, mob/living/M, mode = 1, advanced = FALSE) - if(isliving(user) && (user.incapacitated() || user.eye_blind)) - return - //Damage specifics - var/oxy_loss = M.getOxyLoss() - var/tox_loss = M.getToxLoss() - var/fire_loss = M.getFireLoss() - var/brute_loss = M.getBruteLoss() - var/mob_status = (M.stat == DEAD ? "Deceased" : "[round(M.health/M.maxHealth,0.01)*100] % healthy") - - if(HAS_TRAIT(M, TRAIT_FAKEDEATH) && !advanced) - mob_status = "Deceased" - oxy_loss = max(rand(1, 40), oxy_loss, (300 - (tox_loss + fire_loss + brute_loss))) // Random oxygen loss - - if(ishuman(M)) - var/mob/living/carbon/human/H = M - if(H.undergoing_cardiac_arrest() && H.stat != DEAD) - to_chat(user, "Subject suffering from heart attack: Apply defibrillation or other electric shock immediately!") - if(H.undergoing_liver_failure() && H.stat != DEAD) //might be depreciated BUG_PROBABLE_CAUSE - to_chat(user, "Subject is suffering from liver failure: Apply Corazone and begin a liver transplant immediately!") - - var/msg = "*---------*\nAnalyzing results for [M]:\n\tOverall status: [mob_status]\n" - - // Damage descriptions - if(brute_loss > 10) - msg += "\t[brute_loss > 50 ? "Severe" : "Minor"] tissue damage detected.\n" - if(fire_loss > 10) - msg += "\t[fire_loss > 50 ? "Severe" : "Minor"] burn damage detected.\n" - if(oxy_loss > 10) - msg += "\t[oxy_loss > 50 ? "Severe" : "Minor"] oxygen deprivation detected.\n" - if(tox_loss > 10) - msg += "\t[tox_loss > 50 ? "Severe" : "Minor"] amount of toxin damage detected.\n" - if(M.getStaminaLoss()) - msg += "\tSubject appears to be suffering from fatigue.\n" - if(advanced) - msg += "\tFatigue Level: [M.getStaminaLoss()]%.\n" - if (M.getCloneLoss()) - msg += "\tSubject appears to have [M.getCloneLoss() > 30 ? "Severe" : "Minor"] cellular damage.\n" - if(advanced) - msg += "\tCellular Damage Level: [M.getCloneLoss()].\n" - if (!M.getorgan(/obj/item/organ/brain)) - to_chat(user, "\tSubject lacks a brain.") //Unsure how this won't proc for 50% of the cit playerbase (This is a joke everyone on cit a cute.) - if(ishuman(M) && advanced) // Should I make this not advanced? - var/mob/living/carbon/human/H = M - var/obj/item/organ/liver/L = H.getorganslot("liver") - if(L) - if(L.swelling > 20) - msg += "\tSubject is suffering from an enlarged liver.\n" //i.e. shrink their liver or give them a transplant. - else - msg += "\tSubject's liver is missing.\n" - var/obj/item/organ/tongue/T = H.getorganslot("tongue") - if(T) - if(T.damage > 40) - msg += "\tSubject is suffering from severe burn tissue on their tongue.\n" //i.e. their tongue is shot - if(T.name == "fluffy tongue") - msg += "\tSubject is suffering from a fluffified tongue. Suggested cure: Yamerol or a tongue transplant.\n" - else - msg += "\tSubject's tongue is missing.\n" - var/obj/item/organ/lungs/Lung = H.getorganslot("lungs") - if(Lung) - if(Lung.damage > 150) - msg += "\tSubject is suffering from acute emphysema leading to trouble breathing.\n" //i.e. Their lungs are shot - else - msg += "\tSubject's lungs have collapsed from trauma!\n" - var/obj/item/organ/genital/penis/P = H.getorganslot("penis") - if(P) - if(P.length>20) - msg += "\tSubject has a sizeable gentleman's organ at [P.length] inches.\n" - var/obj/item/organ/genital/breasts/Br = H.getorganslot("breasts") - if(Br) - if(Br.cached_size>5) - msg += "\tSubject has a sizeable bosom with a [Br.size] cup.\n" - if (M.getOrganLoss(ORGAN_SLOT_BRAIN) >= 200 || !M.getorgan(/obj/item/organ/brain)) - msg += "\tSubject's brain function is non-existent.\n" - else if (M.getOrganLoss(ORGAN_SLOT_BRAIN) >= 120) - msg += "\tSevere brain damage detected. Subject likely to have mental traumas.\n" - else if (M.getOrganLoss(ORGAN_SLOT_BRAIN) >= 45) - msg += "\tBrain damage detected.\n" - - if(iscarbon(M)) - - var/mob/living/carbon/C = M - if(LAZYLEN(C.get_traumas())) - var/list/trauma_text = list() - for(var/datum/brain_trauma/B in C.get_traumas()) - var/trauma_desc = "" - switch(B.resilience) - if(TRAUMA_RESILIENCE_SURGERY) - trauma_desc += "severe " - if(TRAUMA_RESILIENCE_LOBOTOMY) - trauma_desc += "deep-rooted " - if(TRAUMA_RESILIENCE_MAGIC, TRAUMA_RESILIENCE_ABSOLUTE) - trauma_desc += "permanent " - trauma_desc += B.scan_desc - trauma_text += trauma_desc - msg += "\tCerebral traumas detected: subject appears to be suffering from [english_list(trauma_text)].\n" - if(C.roundstart_quirks.len) - msg += "\tSubject has the following physiological traits: [C.get_trait_string()].\n" - if(advanced) - msg += "\tBrain Activity Level: [(200 - M.getOrganLoss(ORGAN_SLOT_BRAIN))/2]%.\n" - if(M.radiation) - msg += "\tSubject is irradiated.\n" - if(advanced) - msg += "\tRadiation Level: [M.radiation]%.\n" - - if(advanced && M.hallucinating()) - msg += "\tSubject is hallucinating.\n" - - //MKUltra - if(advanced && M.has_status_effect(/datum/status_effect/chem/enthrall)) - msg += "\tSubject has abnormal brain fuctions.\n" - - //Astrogen shenanigans - if(M.reagents.has_reagent(/datum/reagent/fermi/astral)) - if(M.mind) - msg += "\tWarning: subject may be possesed.\n" - else - msg += "\tSubject appears to be astrally projecting.\n" - - //Eyes and ears - if(advanced) - if(iscarbon(M)) - var/mob/living/carbon/C = M - var/obj/item/organ/ears/ears = C.getorganslot(ORGAN_SLOT_EARS) - msg += "\t==EAR STATUS==\n" - if(istype(ears)) - var/healthy = TRUE - if(HAS_TRAIT_FROM(C, TRAIT_DEAF, GENETIC_MUTATION)) - healthy = FALSE - msg += "\tSubject is genetically deaf.\n" - else if(HAS_TRAIT(C, TRAIT_DEAF)) - healthy = FALSE - msg += "\tSubject is deaf.\n" - else - if(ears.damage) - to_chat(user, "\tSubject has [ears.damage > ears.maxHealth ? "permanent ": "temporary "]hearing damage.") - healthy = FALSE - if(ears.deaf) - to_chat(user, "\tSubject is [ears.damage > ears.maxHealth ? "permanently ": "temporarily "] deaf.") - healthy = FALSE - if(healthy) - msg += "\tHealthy.\n" - else - msg += "\tSubject does not have ears.\n" - var/obj/item/organ/eyes/eyes = C.getorganslot(ORGAN_SLOT_EYES) - msg += "\t==EYE STATUS==\n" - if(istype(eyes)) - var/healthy = TRUE - if(HAS_TRAIT(C, TRAIT_BLIND)) - msg += "\tSubject is blind.\n" - healthy = FALSE - if(HAS_TRAIT(C, TRAIT_NEARSIGHT)) - msg += "\tSubject is nearsighted.\n" - healthy = FALSE - if(eyes.damage > 30) - msg += "\tSubject has severe eye damage.\n" - healthy = FALSE - else if(eyes.damage > 20) - msg += "\tSubject has significant eye damage.\n" - healthy = FALSE - else if(eyes.damage) - msg += "\tSubject has minor eye damage.\n" - healthy = FALSE - if(healthy) - msg += "\tHealthy.\n" - else - msg += "\tSubject does not have eyes.\n" - - - if(ishuman(M)) - var/mob/living/carbon/human/H = M - var/ldamage = H.return_liver_damage() - if(ldamage > 10) - msg += "\t[ldamage > 45 ? "Severe" : "Minor"] liver damage detected.\n" - if(advanced && H.has_dna()) - to_chat(user, "\tGenetic Stability: [H.dna.stability]%.") - // Body part damage report - if(iscarbon(M) && mode == 1) - var/mob/living/carbon/C = M - var/list/damaged = C.get_damaged_bodyparts(1,1) - if(length(damaged)>0 || oxy_loss>0 || tox_loss>0 || fire_loss>0) - msg += "\tDamage: Brute-Burn-Toxin-Suffocation\n\t\tSpecifics: [brute_loss]-[fire_loss]-[tox_loss]-[oxy_loss]\n" - for(var/obj/item/bodypart/org in damaged) - msg += "\t\t[capitalize(org.name)]: [(org.brute_dam > 0) ? "[org.brute_dam]" : "0"]-[(org.burn_dam > 0) ? "[org.burn_dam]" : "0"]\n" - - //Bones broken report! Hyperstation 13 - if(iscarbon(M) && mode == 1) - var/mob/living/carbon/C = M - for(var/X in C.bodyparts) - var/obj/item/bodypart/LB = X - var/broken = LB.broken - if(broken == 1) - msg += "\tSubjects [LB.name] is fractured!\n" - -//Organ damages report - if(ishuman(M)) - var/mob/living/carbon/human/H = M - var/minor_damage - var/major_damage - var/max_damage - var/report_organs = FALSE - - //Piece together the lists to be reported - for(var/O in H.internal_organs) - var/obj/item/organ/organ = O - if(organ.organ_flags & ORGAN_FAILING) - report_organs = TRUE //if we report one organ, we report all organs, even if the lists are empty, just for consistency - if(max_damage) - max_damage += ", " //prelude the organ if we've already reported an organ - max_damage += organ.name //this just slaps the organ name into the string of text - else - max_damage = "\tNon-Functional Organs: " //our initial statement - max_damage += organ.name - else if(organ.damage > organ.high_threshold) - report_organs = TRUE - if(major_damage) - major_damage += ", " - major_damage += organ.name - else - major_damage = "\tSeverely Damaged Organs: " - major_damage += organ.name - else if(organ.damage > organ.low_threshold) - report_organs = TRUE - if(minor_damage) - minor_damage += ", " - minor_damage += organ.name - else - minor_damage = "\tMildly Damaged Organs: " - minor_damage += organ.name - - if(report_organs) //we either finish the list, or set it to be empty if no organs were reported in that category - if(!max_damage) - max_damage = "\tNon-Functional Organs: " - else - max_damage += "" - if(!major_damage) - major_damage = "\tSeverely Damaged Organs: " - else - major_damage += "" - if(!minor_damage) - minor_damage = "\tMildly Damaged Organs: " - else - minor_damage += "" - msg += "[minor_damage]" - msg += "[major_damage]" - msg += "[max_damage]" - - // Species and body temperature - if(ishuman(M)) - var/mob/living/carbon/human/H = M - var/datum/species/S = H.dna.species - var/mutant = FALSE - if (H.dna.check_mutation(HULK)) - mutant = TRUE - else if (S.mutantlungs != initial(S.mutantlungs)) - mutant = TRUE - else if (S.mutant_brain != initial(S.mutant_brain)) - mutant = TRUE - else if (S.mutant_heart != initial(S.mutant_heart)) - mutant = TRUE - else if (S.mutanteyes != initial(S.mutanteyes)) - mutant = TRUE - else if (S.mutantears != initial(S.mutantears)) - mutant = TRUE - else if (S.mutanthands != initial(S.mutanthands)) - mutant = TRUE - else if (S.mutanttongue != initial(S.mutanttongue)) - mutant = TRUE - else if (S.mutanttail != initial(S.mutanttail)) - mutant = TRUE - else if (S.mutantliver != initial(S.mutantliver)) - mutant = TRUE - else if (S.mutantstomach != initial(S.mutantstomach)) - mutant = TRUE - - msg += "Species: [H.dna.custom_species ? H.dna.custom_species : S.name] Base: [S.name]\n" - if(mutant) - msg += "Subject has mutations present." - msg += "Body temperature: [round(M.bodytemperature-T0C,0.1)] °C ([round(M.bodytemperature*1.8-459.67,0.1)] °F)\n" - - // Time of death - if(M.tod && (M.stat == DEAD || ((HAS_TRAIT(M, TRAIT_FAKEDEATH)) && !advanced))) - msg += "Time of Death: [M.tod]\n" - var/tdelta = round(world.time - M.timeofdeath) - if(tdelta < (DEFIB_TIME_LIMIT * 10)) - msg += "Subject died [DisplayTimeText(tdelta)] ago, defibrillation may be possible!\n" - - for(var/thing in M.diseases) - var/datum/disease/D = thing - if(!(D.visibility_flags & HIDDEN_SCANNER)) - msg += "Warning: [D.form] detected\nName: [D.name].\nType: [D.spread_text].\nStage: [D.stage]/[D.max_stages].\nPossible Cure: [D.cure_text]\n" - - // Blood Level - if(M.has_dna()) - var/mob/living/carbon/C = M - var/blood_typepath = C.get_blood_id() - if(blood_typepath) - if(ishuman(C)) - var/mob/living/carbon/human/H = C - if(H.bleed_rate) - msg += "Subject is bleeding!\n" - var/blood_percent = round((C.scan_blood_volume() / (BLOOD_VOLUME_NORMAL * C.blood_ratio))*100) - var/blood_type = C.dna.blood_type - if(!(blood_typepath in GLOB.blood_reagent_types)) - var/datum/reagent/R = GLOB.chemical_reagents_list[blood_typepath] - if(R) - blood_type = R.name - if(C.scan_blood_volume() <= (BLOOD_VOLUME_SAFE*C.blood_ratio) && C.scan_blood_volume() > (BLOOD_VOLUME_OKAY*C.blood_ratio)) - msg += "LOW blood level [blood_percent] %, [C.scan_blood_volume()] cl, type: [blood_type]\n" - else if(C.scan_blood_volume() <= (BLOOD_VOLUME_OKAY*C.blood_ratio)) - msg += "CRITICAL blood level [blood_percent] %, [C.scan_blood_volume()] cl, type: [blood_type]\n" - else - msg += "Blood level [blood_percent] %, [C.scan_blood_volume()] cl, type: [blood_type]\n" - - var/cyberimp_detect - for(var/obj/item/organ/cyberimp/CI in C.internal_organs) - if(CI.status == ORGAN_ROBOTIC && !CI.syndicate_implant) - cyberimp_detect += "[C.name] is modified with a [CI.name].
    " - if(cyberimp_detect) - msg += "Detected cybernetic modifications:\n" - msg += "[cyberimp_detect]\n" - msg += "*---------*
    " - to_chat(user, msg) - SEND_SIGNAL(M, COMSIG_NANITE_SCAN, user, FALSE) - -/proc/chemscan(mob/living/user, mob/living/M) - if(istype(M)) - if(M.reagents) - var/msg = "*---------*\n" - if(M.reagents.reagent_list.len) - var/list/datum/reagent/reagents = list() - for(var/datum/reagent/R in M.reagents.reagent_list) - if(R.chemical_flags & REAGENT_INVISIBLE) - continue - reagents += R - - if(length(reagents)) - msg += "Subject contains the following reagents:\n" - for(var/datum/reagent/R in reagents) - msg += "[R.volume] units of [R.name][R.overdosed == 1 ? " - OVERDOSING" : "."]\n" - else - msg += "Subject contains no reagents.\n" - - else - msg += "Subject contains no reagents.\n" - if(M.reagents.addiction_list.len) - msg += "Subject is addicted to the following reagents:\n" - for(var/datum/reagent/R in M.reagents.addiction_list) - msg += "[R.name]\n" - else - msg += "Subject is not addicted to any reagents.\n" - - var/datum/reagent/impure/fermiTox/F = M.reagents.has_reagent(/datum/reagent/impure/fermiTox) - if(istype(F,/datum/reagent/impure/fermiTox)) - switch(F.volume) - if(5 to 10) - msg += "Subject contains a low amount of toxic isomers.\n" - if(10 to 25) - msg += "Subject contains toxic isomers.\n" - if(25 to 50) - msg += "Subject contains a substantial amount of toxic isomers.\n" - if(50 to 95) - msg += "Subject contains a high amount of toxic isomers.\n" - if(95 to INFINITY) - msg += "Subject contains a extremely dangerous amount of toxic isomers.\n" - - msg += "*---------*
    " - to_chat(user, msg) - -/obj/item/healthanalyzer/verb/toggle_mode() - set name = "Switch Verbosity" - set category = "Object" - - if(usr.stat || !usr.canmove || usr.restrained()) - return - - mode = !mode - switch (mode) - if(1) - to_chat(usr, "The scanner now shows specific limb damage.") - if(0) - to_chat(usr, "The scanner no longer shows limb damage.") - -/obj/item/healthanalyzer/advanced - name = "advanced health analyzer" - icon_state = "health_adv" - desc = "A hand-held body scanner able to distinguish vital signs of the subject with high accuracy." - advanced = TRUE - -/obj/item/analyzer - desc = "A hand-held environmental scanner which reports current gas levels. Alt-Click to use the built in barometer function." - name = "analyzer" - icon = 'icons/obj/device.dmi' - icon_state = "analyzer" - item_state = "analyzer" - lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi' - w_class = WEIGHT_CLASS_SMALL - flags_1 = CONDUCT_1 - item_flags = NOBLUDGEON - slot_flags = ITEM_SLOT_BELT - throwforce = 0 - throw_speed = 3 - throw_range = 7 - tool_behaviour = TOOL_ANALYZER - materials = list(MAT_METAL=30, MAT_GLASS=20) - grind_results = list(/datum/reagent/mercury = 5, /datum/reagent/iron = 5, /datum/reagent/silicon = 5) - var/cooldown = FALSE - var/cooldown_time = 250 - var/accuracy // 0 is the best accuracy. - -/obj/item/analyzer/examine(mob/user) - . = ..() - . += "Alt-click [src] to activate the barometer function." - -/obj/item/analyzer/suicide_act(mob/living/carbon/user) - user.visible_message("[user] begins to analyze [user.p_them()]self with [src]! The display shows that [user.p_theyre()] dead!") - return BRUTELOSS - -/obj/item/analyzer/attack_self(mob/user) - add_fingerprint(user) - - if (user.stat || user.eye_blind) - return - - var/turf/location = user.loc - if(!istype(location)) - return - - var/datum/gas_mixture/environment = location.return_air() - - var/pressure = environment.return_pressure() - var/total_moles = environment.total_moles() - - to_chat(user, "Results:") - if(abs(pressure - ONE_ATMOSPHERE) < 10) - to_chat(user, "Pressure: [round(pressure, 0.01)] kPa") - else - to_chat(user, "Pressure: [round(pressure, 0.01)] kPa") - if(total_moles) - var/list/env_gases = environment.gases - - var/o2_concentration = env_gases[/datum/gas/oxygen]/total_moles - var/n2_concentration = env_gases[/datum/gas/nitrogen]/total_moles - var/co2_concentration = env_gases[/datum/gas/carbon_dioxide]/total_moles - var/plasma_concentration = env_gases[/datum/gas/plasma]/total_moles - - if(abs(n2_concentration - N2STANDARD) < 20) - to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/nitrogen], 0.01)] mol)") - else - to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/nitrogen], 0.01)] mol)") - - if(abs(o2_concentration - O2STANDARD) < 2) - to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/oxygen], 0.01)] mol)") - else - to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/oxygen], 0.01)] mol)") - - if(co2_concentration > 0.01) - to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/carbon_dioxide], 0.01)] mol)") - else - to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/carbon_dioxide], 0.01)] mol)") - - if(plasma_concentration > 0.005) - to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/plasma], 0.01)] mol)") - else - to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/plasma], 0.01)] mol)") - - GAS_GARBAGE_COLLECT(environment.gases) - - for(var/id in env_gases) - if(id in GLOB.hardcoded_gases) - continue - var/gas_concentration = env_gases[id]/total_moles - to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] % ([round(env_gases[id], 0.01)] mol)") - to_chat(user, "Temperature: [round(environment.temperature-T0C, 0.01)] °C ([round(environment.temperature, 0.01)] K)") - -/obj/item/analyzer/AltClick(mob/user) //Barometer output for measuring when the next storm happens - . = ..() - - if(user.canUseTopic(src)) - . = TRUE - if(cooldown) - to_chat(user, "[src]'s barometer function is preparing itself.") - return - - var/turf/T = get_turf(user) - if(!T) - return - - playsound(src, 'sound/effects/pop.ogg', 100) - var/area/user_area = T.loc - var/datum/weather/ongoing_weather = null - - if(!user_area.outdoors) - to_chat(user, "[src]'s barometer function won't work indoors!") - return - - for(var/V in SSweather.processing) - var/datum/weather/W = V - if(W.barometer_predictable && (T.z in W.impacted_z_levels) && W.area_type == user_area.type && !(W.stage == END_STAGE)) - ongoing_weather = W - break - - if(ongoing_weather) - if((ongoing_weather.stage == MAIN_STAGE) || (ongoing_weather.stage == WIND_DOWN_STAGE)) - to_chat(user, "[src]'s barometer function can't trace anything while the storm is [ongoing_weather.stage == MAIN_STAGE ? "already here!" : "winding down."]") - return - - to_chat(user, "The next [ongoing_weather] will hit in [butchertime(ongoing_weather.next_hit_time - world.time)].") - if(ongoing_weather.aesthetic) - to_chat(user, "[src]'s barometer function says that the next storm will breeze on by.") - else - var/next_hit = SSweather.next_hit_by_zlevel["[T.z]"] - var/fixed = next_hit ? next_hit - world.time : -1 - if(fixed < 0) - to_chat(user, "[src]'s barometer function was unable to trace any weather patterns.") - else - to_chat(user, "[src]'s barometer function says a storm will land in approximately [butchertime(fixed)].") - cooldown = TRUE - addtimer(CALLBACK(src,/obj/item/analyzer/proc/ping), cooldown_time) - -/obj/item/analyzer/proc/ping() - if(isliving(loc)) - var/mob/living/L = loc - to_chat(L, "[src]'s barometer function is ready!") - playsound(src, 'sound/machines/click.ogg', 100) - cooldown = FALSE - -/obj/item/analyzer/proc/butchertime(amount) - if(!amount) - return - if(accuracy) - var/inaccurate = round(accuracy*(1/3)) - if(prob(50)) - amount -= inaccurate - if(prob(50)) - amount += inaccurate - return DisplayTimeText(max(1,amount)) - -/proc/atmosanalyzer_scan(mixture, mob/living/user, atom/target = src) - var/icon = target - user.visible_message("[user] has used the analyzer on [icon2html(icon, viewers(src))] [target].", "You use the analyzer on [icon2html(icon, user)] [target].") - to_chat(user, "Results of analysis of [icon2html(icon, user)] [target].") - - var/list/airs = islist(mixture) ? mixture : list(mixture) - for(var/g in airs) - if(airs.len > 1) //not a unary gas mixture - to_chat(user, "Node [airs.Find(g)]") - var/datum/gas_mixture/air_contents = g - - var/total_moles = air_contents.total_moles() - var/pressure = air_contents.return_pressure() - var/volume = air_contents.return_volume() //could just do mixture.volume... but safety, I guess? - var/temperature = air_contents.temperature - var/cached_scan_results = air_contents.analyzer_results - - if(total_moles > 0) - to_chat(user, "Moles: [round(total_moles, 0.01)] mol") - to_chat(user, "Volume: [volume] L") - to_chat(user, "Pressure: [round(pressure,0.01)] kPa") - - var/list/cached_gases = air_contents.gases - for(var/id in cached_gases) - var/gas_concentration = cached_gases[id]/total_moles - to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] % ([round(cached_gases[id], 0.01)] mol)") - to_chat(user, "Temperature: [round(temperature - T0C,0.01)] °C ([round(temperature, 0.01)] K)") - - else - if(airs.len > 1) - to_chat(user, "This node is empty!") - else - to_chat(user, "[target] is empty!") - - if(cached_scan_results && cached_scan_results["fusion"]) //notify the user if a fusion reaction was detected - var/instability = round(cached_scan_results["fusion"], 0.01) - to_chat(user, "Large amounts of free neutrons detected in the air indicate that a fusion reaction took place.") - to_chat(user, "Instability of the last fusion reaction: [instability].") - return - -//slime scanner - -/obj/item/slime_scanner - name = "slime scanner" - desc = "A device that analyzes a slime's internal composition and measures its stats." - icon = 'icons/obj/device.dmi' - icon_state = "adv_spectrometer" - item_state = "analyzer" - lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi' - w_class = WEIGHT_CLASS_SMALL - flags_1 = CONDUCT_1 - throwforce = 0 - throw_speed = 3 - throw_range = 7 - materials = list(MAT_METAL=30, MAT_GLASS=20) - -/obj/item/slime_scanner/attack(mob/living/M, mob/living/user) - if(user.stat || user.eye_blind) - return - if (!isslime(M)) - to_chat(user, "This device can only scan slimes!") - return - var/mob/living/simple_animal/slime/T = M - slime_scan(T, user) - -/proc/slime_scan(mob/living/simple_animal/slime/T, mob/living/user) - to_chat(user, "========================") - to_chat(user, "Slime scan results:") - to_chat(user, "[T.colour] [T.is_adult ? "adult" : "baby"] slime") - to_chat(user, "Nutrition: [T.nutrition]/[T.get_max_nutrition()]") - if (T.nutrition < T.get_starve_nutrition()) - to_chat(user, "Warning: slime is starving!") - else if (T.nutrition < T.get_hunger_nutrition()) - to_chat(user, "Warning: slime is hungry") - to_chat(user, "Electric change strength: [T.powerlevel]") - to_chat(user, "Health: [round(T.health/T.maxHealth,0.01)*100]%") - if (T.slime_mutation[4] == T.colour) - to_chat(user, "This slime does not evolve any further.") - else - if (T.slime_mutation[3] == T.slime_mutation[4]) - if (T.slime_mutation[2] == T.slime_mutation[1]) - to_chat(user, "Possible mutation: [T.slime_mutation[3]]") - to_chat(user, "Genetic destability: [T.mutation_chance/2] % chance of mutation on splitting") - else - to_chat(user, "Possible mutations: [T.slime_mutation[1]], [T.slime_mutation[2]], [T.slime_mutation[3]] (x2)") - to_chat(user, "Genetic destability: [T.mutation_chance] % chance of mutation on splitting") - else - to_chat(user, "Possible mutations: [T.slime_mutation[1]], [T.slime_mutation[2]], [T.slime_mutation[3]], [T.slime_mutation[4]]") - to_chat(user, "Genetic destability: [T.mutation_chance] % chance of mutation on splitting") - if (T.cores > 1) - to_chat(user, "Multiple cores detected") - to_chat(user, "Growth progress: [T.amount_grown]/[SLIME_EVOLUTION_THRESHOLD]") - if(T.effectmod) - to_chat(user, "Core mutation in progress: [T.effectmod]") - to_chat(user, "Progress in core mutation: [T.applied] / [SLIME_EXTRACT_CROSSING_REQUIRED]") - to_chat(user, "========================") - - -/obj/item/nanite_scanner - name = "nanite scanner" - icon = 'icons/obj/device.dmi' - icon_state = "nanite_scanner" - item_state = "nanite_remote" - lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi' - desc = "A hand-held body scanner able to detect nanites and their programming." - flags_1 = CONDUCT_1 - item_flags = NOBLUDGEON - slot_flags = ITEM_SLOT_BELT - throwforce = 3 - w_class = WEIGHT_CLASS_TINY - throw_speed = 3 - throw_range = 7 - materials = list(MAT_METAL=200) - -/obj/item/nanite_scanner/attack(mob/living/M, mob/living/carbon/human/user) - user.visible_message("[user] has analyzed [M]'s nanites.") - - add_fingerprint(user) - - var/response = SEND_SIGNAL(M, COMSIG_NANITE_SCAN, user, TRUE) - if(!response) - to_chat(user, "No nanites detected in the subject.") - -/obj/item/sequence_scanner - name = "genetic sequence scanner" - icon = 'icons/obj/device.dmi' - icon_state = "gene" - item_state = "healthanalyzer" - lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi' - righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi' - desc = "A hand-held scanner able to swiftly scan someone for potential mutations. Hold near a DNA console to update from their database." - flags_1 = CONDUCT_1 - item_flags = NOBLUDGEON - slot_flags = ITEM_SLOT_BELT - throwforce = 3 - w_class = WEIGHT_CLASS_TINY - throw_speed = 3 - throw_range = 7 - materials = list(MAT_METAL=200) - var/list/discovered = list() //hit a dna console to update the scanners database - -/obj/item/sequence_scanner/attack(mob/living/M, mob/living/carbon/human/user) - user.visible_message("[user] has analyzed [M]'s genetic sequence.") - - add_fingerprint(user) - - gene_scan(M, user, src) - -/obj/item/sequence_scanner/afterattack(obj/O, mob/user, proximity) - . = ..() - if(!istype(O) || !proximity) - return - - if(istype(O, /obj/machinery/computer/scan_consolenew)) - var/obj/machinery/computer/scan_consolenew/C = O - if(C.stored_research) - to_chat(user, "[name] database updated.") - discovered = C.stored_research.discovered_mutations - else - to_chat(user,"No database to update from.") - -/proc/gene_scan(mob/living/carbon/C, mob/living/user, obj/item/sequence_scanner/G) - if(!iscarbon(C) || !C.has_dna()) - return - to_chat(user, "[C.name]'s potential mutations.") - for(var/A in C.dna.mutation_index) - var/datum/mutation/human/HM = GET_INITIALIZED_MUTATION(A) - var/mut_name - if(G && (A in G.discovered)) - mut_name = "[HM.name] ([HM.alias])" - else - mut_name = HM.alias - var/temp = GET_GENE_STRING(HM.type, C.dna) - var/display - for(var/i in 0 to length(temp) / DNA_MUTATION_BLOCKS-1) - if(i) - display += "-" - display += copytext(temp, 1 + i*DNA_MUTATION_BLOCKS, DNA_MUTATION_BLOCKS*(1+i) + 1) - - - to_chat(user, "- [mut_name] > [display]") + +/* + +CONTAINS: +T-RAY +HEALTH ANALYZER +GAS ANALYZER +SLIME SCANNER +NANITE SCANNER +GENE SCANNER + +*/ +/obj/item/t_scanner + name = "\improper T-ray scanner" + desc = "A terahertz-ray emitter and scanner used to detect underfloor objects such as cables and pipes." + icon = 'icons/obj/device.dmi' + icon_state = "t-ray0" + var/on = FALSE + slot_flags = ITEM_SLOT_BELT + w_class = WEIGHT_CLASS_SMALL + item_state = "electronic" + lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi' + righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi' + materials = list(MAT_METAL=150) + +/obj/item/t_scanner/suicide_act(mob/living/carbon/user) + user.visible_message("[user] begins to emit terahertz-rays into [user.p_their()] brain with [src]! It looks like [user.p_theyre()] trying to commit suicide!") + return TOXLOSS + +/obj/item/t_scanner/attack_self(mob/user) + + on = !on + icon_state = copytext_char(icon_state, 1, -1) + "[on]" + + if(on) + START_PROCESSING(SSobj, src) + +/obj/item/t_scanner/process() + if(!on) + STOP_PROCESSING(SSobj, src) + return null + scan() + +/obj/item/t_scanner/proc/scan() + t_ray_scan(loc) + +/proc/t_ray_scan(mob/viewer, flick_time = 8, distance = 3) + if(!ismob(viewer) || !viewer.client) + return + var/list/t_ray_images = list() + for(var/obj/O in orange(distance, viewer) ) + if(O.level != 1) + continue + + if(O.invisibility == INVISIBILITY_MAXIMUM) + var/image/I = new(loc = get_turf(O)) + var/mutable_appearance/MA = new(O) + MA.alpha = 128 + MA.dir = O.dir + I.appearance = MA + t_ray_images += I + if(t_ray_images.len) + flick_overlay(t_ray_images, list(viewer.client), flick_time) + +/obj/item/healthanalyzer + name = "health analyzer" + icon = 'icons/obj/device.dmi' + icon_state = "health" + item_state = "healthanalyzer" + lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi' + desc = "A hand-held body scanner able to distinguish vital signs of the subject." + flags_1 = CONDUCT_1 + item_flags = NOBLUDGEON + slot_flags = ITEM_SLOT_BELT + throwforce = 3 + w_class = WEIGHT_CLASS_TINY + throw_speed = 3 + throw_range = 7 + materials = list(MAT_METAL=200) + var/mode = 1 + var/scanmode = 0 + var/advanced = FALSE + +/obj/item/healthanalyzer/suicide_act(mob/living/carbon/user) + user.visible_message("[user] begins to analyze [user.p_them()]self with [src]! The display shows that [user.p_theyre()] dead!") + return BRUTELOSS + +/obj/item/healthanalyzer/attack_self(mob/user) + if(!scanmode) + to_chat(user, "You switch the health analyzer to scan chemical contents.") + scanmode = 1 + else + to_chat(user, "You switch the health analyzer to check physical health.") + scanmode = 0 + +/obj/item/healthanalyzer/attack(mob/living/M, mob/living/carbon/human/user) + + // Clumsiness/brain damage check + if ((HAS_TRAIT(user, TRAIT_CLUMSY) || HAS_TRAIT(user, TRAIT_DUMB)) && prob(50)) + to_chat(user, "You stupidly try to analyze the floor's vitals!") + user.visible_message("[user] has analyzed the floor's vitals!") + var/msg = "*---------*\nAnalyzing results for The floor:\n\tOverall status: Healthy\n" + msg += "Key: Suffocation/Toxin/Burn/Brute\n" + msg += "\tDamage specifics: 0-0-0-0\n" + msg += "Body temperature: ???\n" + msg += "*---------*" + to_chat(user, msg) + return + + user.visible_message("[user] has analyzed [M]'s vitals.") + + if(scanmode == 0) + healthscan(user, M, mode, advanced) + else if(scanmode == 1) + chemscan(user, M) + + add_fingerprint(user) + + +// Used by the PDA medical scanner too +/proc/healthscan(mob/user, mob/living/M, mode = 1, advanced = FALSE) + if(isliving(user) && (user.incapacitated() || user.eye_blind)) + return + //Damage specifics + var/oxy_loss = M.getOxyLoss() + var/tox_loss = M.getToxLoss() + var/fire_loss = M.getFireLoss() + var/brute_loss = M.getBruteLoss() + var/mob_status = (M.stat == DEAD ? "Deceased" : "[round(M.health/M.maxHealth,0.01)*100] % healthy") + + if(HAS_TRAIT(M, TRAIT_FAKEDEATH) && !advanced) + mob_status = "Deceased" + oxy_loss = max(rand(1, 40), oxy_loss, (300 - (tox_loss + fire_loss + brute_loss))) // Random oxygen loss + + if(ishuman(M)) + var/mob/living/carbon/human/H = M + if(H.undergoing_cardiac_arrest() && H.stat != DEAD) + to_chat(user, "Subject suffering from heart attack: Apply defibrillation or other electric shock immediately!") + if(H.undergoing_liver_failure() && H.stat != DEAD) //might be depreciated BUG_PROBABLE_CAUSE + to_chat(user, "Subject is suffering from liver failure: Apply Corazone and begin a liver transplant immediately!") + + var/msg = "*---------*\nAnalyzing results for [M]:\n\tOverall status: [mob_status]\n" + + // Damage descriptions + if(brute_loss > 10) + msg += "\t[brute_loss > 50 ? "Severe" : "Minor"] tissue damage detected.\n" + if(fire_loss > 10) + msg += "\t[fire_loss > 50 ? "Severe" : "Minor"] burn damage detected.\n" + if(oxy_loss > 10) + msg += "\t[oxy_loss > 50 ? "Severe" : "Minor"] oxygen deprivation detected.\n" + if(tox_loss > 10) + msg += "\t[tox_loss > 50 ? "Severe" : "Minor"] amount of toxin damage detected.\n" + if(M.getStaminaLoss()) + msg += "\tSubject appears to be suffering from fatigue.\n" + if(advanced) + msg += "\tFatigue Level: [M.getStaminaLoss()]%.\n" + if (M.getCloneLoss()) + msg += "\tSubject appears to have [M.getCloneLoss() > 30 ? "Severe" : "Minor"] cellular damage.\n" + if(advanced) + msg += "\tCellular Damage Level: [M.getCloneLoss()].\n" + if (!M.getorgan(/obj/item/organ/brain)) + to_chat(user, "\tSubject lacks a brain.") //Unsure how this won't proc for 50% of the cit playerbase (This is a joke everyone on cit a cute.) + if(ishuman(M) && advanced) // Should I make this not advanced? + var/mob/living/carbon/human/H = M + var/obj/item/organ/liver/L = H.getorganslot("liver") + if(L) + if(L.swelling > 20) + msg += "\tSubject is suffering from an enlarged liver.\n" //i.e. shrink their liver or give them a transplant. + else + msg += "\tSubject's liver is missing.\n" + var/obj/item/organ/tongue/T = H.getorganslot("tongue") + if(T) + if(T.damage > 40) + msg += "\tSubject is suffering from severe burn tissue on their tongue.\n" //i.e. their tongue is shot + if(T.name == "fluffy tongue") + msg += "\tSubject is suffering from a fluffified tongue. Suggested cure: Yamerol or a tongue transplant.\n" + else + msg += "\tSubject's tongue is missing.\n" + var/obj/item/organ/lungs/Lung = H.getorganslot("lungs") + if(Lung) + if(Lung.damage > 150) + msg += "\tSubject is suffering from acute emphysema leading to trouble breathing.\n" //i.e. Their lungs are shot + else + msg += "\tSubject's lungs have collapsed from trauma!\n" + var/obj/item/organ/genital/penis/P = H.getorganslot("penis") + if(P) + if(P.length>20) + msg += "\tSubject has a sizeable gentleman's organ at [P.length] inches.\n" + var/obj/item/organ/genital/breasts/Br = H.getorganslot("breasts") + if(Br) + if(Br.cached_size>5) + msg += "\tSubject has a sizeable bosom with a [Br.size] cup.\n" + if (M.getOrganLoss(ORGAN_SLOT_BRAIN) >= 200 || !M.getorgan(/obj/item/organ/brain)) + msg += "\tSubject's brain function is non-existent.\n" + else if (M.getOrganLoss(ORGAN_SLOT_BRAIN) >= 120) + msg += "\tSevere brain damage detected. Subject likely to have mental traumas.\n" + else if (M.getOrganLoss(ORGAN_SLOT_BRAIN) >= 45) + msg += "\tBrain damage detected.\n" + + if(iscarbon(M)) + + var/mob/living/carbon/C = M + if(LAZYLEN(C.get_traumas())) + var/list/trauma_text = list() + for(var/datum/brain_trauma/B in C.get_traumas()) + var/trauma_desc = "" + switch(B.resilience) + if(TRAUMA_RESILIENCE_SURGERY) + trauma_desc += "severe " + if(TRAUMA_RESILIENCE_LOBOTOMY) + trauma_desc += "deep-rooted " + if(TRAUMA_RESILIENCE_MAGIC, TRAUMA_RESILIENCE_ABSOLUTE) + trauma_desc += "permanent " + trauma_desc += B.scan_desc + trauma_text += trauma_desc + msg += "\tCerebral traumas detected: subject appears to be suffering from [english_list(trauma_text)].\n" + if(C.roundstart_quirks.len) + msg += "\tSubject has the following physiological traits: [C.get_trait_string()].\n" + if(advanced) + msg += "\tBrain Activity Level: [(200 - M.getOrganLoss(ORGAN_SLOT_BRAIN))/2]%.\n" + if(M.radiation) + msg += "\tSubject is irradiated.\n" + if(advanced) + msg += "\tRadiation Level: [M.radiation]%.\n" + + if(advanced && M.hallucinating()) + msg += "\tSubject is hallucinating.\n" + + //MKUltra + if(advanced && M.has_status_effect(/datum/status_effect/chem/enthrall)) + msg += "\tSubject has abnormal brain fuctions.\n" + + //Astrogen shenanigans + if(M.reagents.has_reagent(/datum/reagent/fermi/astral)) + if(M.mind) + msg += "\tWarning: subject may be possesed.\n" + else + msg += "\tSubject appears to be astrally projecting.\n" + + //Eyes and ears + if(advanced) + if(iscarbon(M)) + var/mob/living/carbon/C = M + var/obj/item/organ/ears/ears = C.getorganslot(ORGAN_SLOT_EARS) + msg += "\t==EAR STATUS==\n" + if(istype(ears)) + var/healthy = TRUE + if(HAS_TRAIT_FROM(C, TRAIT_DEAF, GENETIC_MUTATION)) + healthy = FALSE + msg += "\tSubject is genetically deaf.\n" + else if(HAS_TRAIT(C, TRAIT_DEAF)) + healthy = FALSE + msg += "\tSubject is deaf.\n" + else + if(ears.damage) + to_chat(user, "\tSubject has [ears.damage > ears.maxHealth ? "permanent ": "temporary "]hearing damage.") + healthy = FALSE + if(ears.deaf) + to_chat(user, "\tSubject is [ears.damage > ears.maxHealth ? "permanently ": "temporarily "] deaf.") + healthy = FALSE + if(healthy) + msg += "\tHealthy.\n" + else + msg += "\tSubject does not have ears.\n" + var/obj/item/organ/eyes/eyes = C.getorganslot(ORGAN_SLOT_EYES) + msg += "\t==EYE STATUS==\n" + if(istype(eyes)) + var/healthy = TRUE + if(HAS_TRAIT(C, TRAIT_BLIND)) + msg += "\tSubject is blind.\n" + healthy = FALSE + if(HAS_TRAIT(C, TRAIT_NEARSIGHT)) + msg += "\tSubject is nearsighted.\n" + healthy = FALSE + if(eyes.damage > 30) + msg += "\tSubject has severe eye damage.\n" + healthy = FALSE + else if(eyes.damage > 20) + msg += "\tSubject has significant eye damage.\n" + healthy = FALSE + else if(eyes.damage) + msg += "\tSubject has minor eye damage.\n" + healthy = FALSE + if(healthy) + msg += "\tHealthy.\n" + else + msg += "\tSubject does not have eyes.\n" + + + if(ishuman(M)) + var/mob/living/carbon/human/H = M + var/ldamage = H.return_liver_damage() + if(ldamage > 10) + msg += "\t[ldamage > 45 ? "Severe" : "Minor"] liver damage detected.\n" + if(advanced && H.has_dna()) + to_chat(user, "\tGenetic Stability: [H.dna.stability]%.") + // Body part damage report + if(iscarbon(M) && mode == 1) + var/mob/living/carbon/C = M + var/list/damaged = C.get_damaged_bodyparts(1,1) + if(length(damaged)>0 || oxy_loss>0 || tox_loss>0 || fire_loss>0) + msg += "\tDamage: Brute-Burn-Toxin-Suffocation\n\t\tSpecifics: [brute_loss]-[fire_loss]-[tox_loss]-[oxy_loss]\n" + for(var/obj/item/bodypart/org in damaged) + msg += "\t\t[capitalize(org.name)]: [(org.brute_dam > 0) ? "[org.brute_dam]" : "0"]-[(org.burn_dam > 0) ? "[org.burn_dam]" : "0"]\n" + + //Bones broken report! Hyperstation 13 + if(iscarbon(M) && mode == 1) + var/mob/living/carbon/C = M + for(var/X in C.bodyparts) + var/obj/item/bodypart/LB = X + var/broken = LB.broken + if(broken == 1) + msg += "\tSubjects [LB.name] is fractured!\n" + +//Organ damages report + if(ishuman(M)) + var/mob/living/carbon/human/H = M + var/minor_damage + var/major_damage + var/max_damage + var/report_organs = FALSE + + //Piece together the lists to be reported + for(var/O in H.internal_organs) + var/obj/item/organ/organ = O + if(organ.organ_flags & ORGAN_FAILING) + report_organs = TRUE //if we report one organ, we report all organs, even if the lists are empty, just for consistency + if(max_damage) + max_damage += ", " //prelude the organ if we've already reported an organ + max_damage += organ.name //this just slaps the organ name into the string of text + else + max_damage = "\tNon-Functional Organs: " //our initial statement + max_damage += organ.name + else if(organ.damage > organ.high_threshold) + report_organs = TRUE + if(major_damage) + major_damage += ", " + major_damage += organ.name + else + major_damage = "\tSeverely Damaged Organs: " + major_damage += organ.name + else if(organ.damage > organ.low_threshold) + report_organs = TRUE + if(minor_damage) + minor_damage += ", " + minor_damage += organ.name + else + minor_damage = "\tMildly Damaged Organs: " + minor_damage += organ.name + + if(report_organs) //we either finish the list, or set it to be empty if no organs were reported in that category + if(!max_damage) + max_damage = "\tNon-Functional Organs: " + else + max_damage += "" + if(!major_damage) + major_damage = "\tSeverely Damaged Organs: " + else + major_damage += "" + if(!minor_damage) + minor_damage = "\tMildly Damaged Organs: " + else + minor_damage += "" + msg += "[minor_damage]" + msg += "[major_damage]" + msg += "[max_damage]" + + // Species and body temperature + if(ishuman(M)) + var/mob/living/carbon/human/H = M + var/datum/species/S = H.dna.species + var/mutant = FALSE + if (H.dna.check_mutation(HULK)) + mutant = TRUE + else if (S.mutantlungs != initial(S.mutantlungs)) + mutant = TRUE + else if (S.mutant_brain != initial(S.mutant_brain)) + mutant = TRUE + else if (S.mutant_heart != initial(S.mutant_heart)) + mutant = TRUE + else if (S.mutanteyes != initial(S.mutanteyes)) + mutant = TRUE + else if (S.mutantears != initial(S.mutantears)) + mutant = TRUE + else if (S.mutanthands != initial(S.mutanthands)) + mutant = TRUE + else if (S.mutanttongue != initial(S.mutanttongue)) + mutant = TRUE + else if (S.mutanttail != initial(S.mutanttail)) + mutant = TRUE + else if (S.mutantliver != initial(S.mutantliver)) + mutant = TRUE + else if (S.mutantstomach != initial(S.mutantstomach)) + mutant = TRUE + + msg += "Species: [H.dna.custom_species ? H.dna.custom_species : S.name] Base: [S.name]\n" + if(mutant) + msg += "Subject has mutations present." + msg += "Body temperature: [round(M.bodytemperature-T0C,0.1)] °C ([round(M.bodytemperature*1.8-459.67,0.1)] °F)\n" + + // Time of death + if(M.tod && (M.stat == DEAD || ((HAS_TRAIT(M, TRAIT_FAKEDEATH)) && !advanced))) + msg += "Time of Death: [M.tod]\n" + var/tdelta = round(world.time - M.timeofdeath) + if(tdelta < (DEFIB_TIME_LIMIT * 10)) + msg += "Subject died [DisplayTimeText(tdelta)] ago, defibrillation may be possible!\n" + + for(var/thing in M.diseases) + var/datum/disease/D = thing + if(!(D.visibility_flags & HIDDEN_SCANNER)) + msg += "Warning: [D.form] detected\nName: [D.name].\nType: [D.spread_text].\nStage: [D.stage]/[D.max_stages].\nPossible Cure: [D.cure_text]\n" + + // Blood Level + if(M.has_dna()) + var/mob/living/carbon/C = M + var/blood_typepath = C.get_blood_id() + if(blood_typepath) + if(ishuman(C)) + var/mob/living/carbon/human/H = C + if(H.bleed_rate) + msg += "Subject is bleeding!\n" + var/blood_percent = round((C.scan_blood_volume() / (BLOOD_VOLUME_NORMAL * C.blood_ratio))*100) + var/blood_type = C.dna.blood_type + if(!(blood_typepath in GLOB.blood_reagent_types)) + var/datum/reagent/R = GLOB.chemical_reagents_list[blood_typepath] + if(R) + blood_type = R.name + if(C.scan_blood_volume() <= (BLOOD_VOLUME_SAFE*C.blood_ratio) && C.scan_blood_volume() > (BLOOD_VOLUME_OKAY*C.blood_ratio)) + msg += "LOW blood level [blood_percent] %, [C.scan_blood_volume()] cl, type: [blood_type]\n" + else if(C.scan_blood_volume() <= (BLOOD_VOLUME_OKAY*C.blood_ratio)) + msg += "CRITICAL blood level [blood_percent] %, [C.scan_blood_volume()] cl, type: [blood_type]\n" + else + msg += "Blood level [blood_percent] %, [C.scan_blood_volume()] cl, type: [blood_type]\n" + + var/cyberimp_detect + for(var/obj/item/organ/cyberimp/CI in C.internal_organs) + if(CI.status == ORGAN_ROBOTIC && !CI.syndicate_implant) + cyberimp_detect += "[C.name] is modified with a [CI.name].
    " + if(cyberimp_detect) + msg += "Detected cybernetic modifications:\n" + msg += "[cyberimp_detect]\n" + msg += "*---------*
    " + to_chat(user, msg) + SEND_SIGNAL(M, COMSIG_NANITE_SCAN, user, FALSE) + +/proc/chemscan(mob/living/user, mob/living/M) + if(istype(M)) + if(M.reagents) + var/msg = "*---------*\n" + if(M.reagents.reagent_list.len) + var/list/datum/reagent/reagents = list() + for(var/datum/reagent/R in M.reagents.reagent_list) + if(R.chemical_flags & REAGENT_INVISIBLE) + continue + reagents += R + + if(length(reagents)) + msg += "Subject contains the following reagents:\n" + for(var/datum/reagent/R in reagents) + msg += "[R.volume] units of [R.name][R.overdosed == 1 ? " - OVERDOSING" : "."]\n" + else + msg += "Subject contains no reagents.\n" + + else + msg += "Subject contains no reagents.\n" + if(M.reagents.addiction_list.len) + msg += "Subject is addicted to the following reagents:\n" + for(var/datum/reagent/R in M.reagents.addiction_list) + msg += "[R.name]\n" + else + msg += "Subject is not addicted to any reagents.\n" + + var/datum/reagent/impure/fermiTox/F = M.reagents.has_reagent(/datum/reagent/impure/fermiTox) + if(istype(F,/datum/reagent/impure/fermiTox)) + switch(F.volume) + if(5 to 10) + msg += "Subject contains a low amount of toxic isomers.\n" + if(10 to 25) + msg += "Subject contains toxic isomers.\n" + if(25 to 50) + msg += "Subject contains a substantial amount of toxic isomers.\n" + if(50 to 95) + msg += "Subject contains a high amount of toxic isomers.\n" + if(95 to INFINITY) + msg += "Subject contains a extremely dangerous amount of toxic isomers.\n" + + msg += "*---------*
    " + to_chat(user, msg) + +/obj/item/healthanalyzer/verb/toggle_mode() + set name = "Switch Verbosity" + set category = "Object" + + if(usr.stat || !usr.canmove || usr.restrained()) + return + + mode = !mode + switch (mode) + if(1) + to_chat(usr, "The scanner now shows specific limb damage.") + if(0) + to_chat(usr, "The scanner no longer shows limb damage.") + +/obj/item/healthanalyzer/advanced + name = "advanced health analyzer" + icon_state = "health_adv" + desc = "A hand-held body scanner able to distinguish vital signs of the subject with high accuracy." + advanced = TRUE + +/obj/item/analyzer + desc = "A hand-held environmental scanner which reports current gas levels. Alt-Click to use the built in barometer function." + name = "analyzer" + icon = 'icons/obj/device.dmi' + icon_state = "analyzer" + item_state = "analyzer" + lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi' + w_class = WEIGHT_CLASS_SMALL + flags_1 = CONDUCT_1 + item_flags = NOBLUDGEON + slot_flags = ITEM_SLOT_BELT + throwforce = 0 + throw_speed = 3 + throw_range = 7 + tool_behaviour = TOOL_ANALYZER + materials = list(MAT_METAL=30, MAT_GLASS=20) + grind_results = list(/datum/reagent/mercury = 5, /datum/reagent/iron = 5, /datum/reagent/silicon = 5) + var/cooldown = FALSE + var/cooldown_time = 250 + var/accuracy // 0 is the best accuracy. + +/obj/item/analyzer/examine(mob/user) + . = ..() + . += "Alt-click [src] to activate the barometer function." + +/obj/item/analyzer/suicide_act(mob/living/carbon/user) + user.visible_message("[user] begins to analyze [user.p_them()]self with [src]! The display shows that [user.p_theyre()] dead!") + return BRUTELOSS + +/obj/item/analyzer/attack_self(mob/user) + add_fingerprint(user) + + if (user.stat || user.eye_blind) + return + + var/turf/location = user.loc + if(!istype(location)) + return + + var/datum/gas_mixture/environment = location.return_air() + + var/pressure = environment.return_pressure() + var/total_moles = environment.total_moles() + + to_chat(user, "Results:") + if(abs(pressure - ONE_ATMOSPHERE) < 10) + to_chat(user, "Pressure: [round(pressure, 0.01)] kPa") + else + to_chat(user, "Pressure: [round(pressure, 0.01)] kPa") + if(total_moles) + var/list/env_gases = environment.gases + + var/o2_concentration = env_gases[/datum/gas/oxygen]/total_moles + var/n2_concentration = env_gases[/datum/gas/nitrogen]/total_moles + var/co2_concentration = env_gases[/datum/gas/carbon_dioxide]/total_moles + var/plasma_concentration = env_gases[/datum/gas/plasma]/total_moles + + if(abs(n2_concentration - N2STANDARD) < 20) + to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/nitrogen], 0.01)] mol)") + else + to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/nitrogen], 0.01)] mol)") + + if(abs(o2_concentration - O2STANDARD) < 2) + to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/oxygen], 0.01)] mol)") + else + to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/oxygen], 0.01)] mol)") + + if(co2_concentration > 0.01) + to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/carbon_dioxide], 0.01)] mol)") + else + to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/carbon_dioxide], 0.01)] mol)") + + if(plasma_concentration > 0.005) + to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/plasma], 0.01)] mol)") + else + to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/plasma], 0.01)] mol)") + + GAS_GARBAGE_COLLECT(environment.gases) + + for(var/id in env_gases) + if(id in GLOB.hardcoded_gases) + continue + var/gas_concentration = env_gases[id]/total_moles + to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] % ([round(env_gases[id], 0.01)] mol)") + to_chat(user, "Temperature: [round(environment.temperature-T0C, 0.01)] °C ([round(environment.temperature, 0.01)] K)") + +/obj/item/analyzer/AltClick(mob/user) //Barometer output for measuring when the next storm happens + . = ..() + + if(user.canUseTopic(src)) + . = TRUE + if(cooldown) + to_chat(user, "[src]'s barometer function is preparing itself.") + return + + var/turf/T = get_turf(user) + if(!T) + return + + playsound(src, 'sound/effects/pop.ogg', 100) + var/area/user_area = T.loc + var/datum/weather/ongoing_weather = null + + if(!user_area.outdoors) + to_chat(user, "[src]'s barometer function won't work indoors!") + return + + for(var/V in SSweather.processing) + var/datum/weather/W = V + if(W.barometer_predictable && (T.z in W.impacted_z_levels) && W.area_type == user_area.type && !(W.stage == END_STAGE)) + ongoing_weather = W + break + + if(ongoing_weather) + if((ongoing_weather.stage == MAIN_STAGE) || (ongoing_weather.stage == WIND_DOWN_STAGE)) + to_chat(user, "[src]'s barometer function can't trace anything while the storm is [ongoing_weather.stage == MAIN_STAGE ? "already here!" : "winding down."]") + return + + to_chat(user, "The next [ongoing_weather] will hit in [butchertime(ongoing_weather.next_hit_time - world.time)].") + if(ongoing_weather.aesthetic) + to_chat(user, "[src]'s barometer function says that the next storm will breeze on by.") + else + var/next_hit = SSweather.next_hit_by_zlevel["[T.z]"] + var/fixed = next_hit ? next_hit - world.time : -1 + if(fixed < 0) + to_chat(user, "[src]'s barometer function was unable to trace any weather patterns.") + else + to_chat(user, "[src]'s barometer function says a storm will land in approximately [butchertime(fixed)].") + cooldown = TRUE + addtimer(CALLBACK(src,/obj/item/analyzer/proc/ping), cooldown_time) + +/obj/item/analyzer/proc/ping() + if(isliving(loc)) + var/mob/living/L = loc + to_chat(L, "[src]'s barometer function is ready!") + playsound(src, 'sound/machines/click.ogg', 100) + cooldown = FALSE + +/obj/item/analyzer/proc/butchertime(amount) + if(!amount) + return + if(accuracy) + var/inaccurate = round(accuracy*(1/3)) + if(prob(50)) + amount -= inaccurate + if(prob(50)) + amount += inaccurate + return DisplayTimeText(max(1,amount)) + +/proc/atmosanalyzer_scan(mixture, mob/living/user, atom/target = src) + var/icon = target + user.visible_message("[user] has used the analyzer on [icon2html(icon, viewers(src))] [target].", "You use the analyzer on [icon2html(icon, user)] [target].") + to_chat(user, "Results of analysis of [icon2html(icon, user)] [target].") + + var/list/airs = islist(mixture) ? mixture : list(mixture) + for(var/g in airs) + if(airs.len > 1) //not a unary gas mixture + to_chat(user, "Node [airs.Find(g)]") + var/datum/gas_mixture/air_contents = g + + var/total_moles = air_contents.total_moles() + var/pressure = air_contents.return_pressure() + var/volume = air_contents.return_volume() //could just do mixture.volume... but safety, I guess? + var/temperature = air_contents.temperature + var/cached_scan_results = air_contents.analyzer_results + + if(total_moles > 0) + to_chat(user, "Moles: [round(total_moles, 0.01)] mol") + to_chat(user, "Volume: [volume] L") + to_chat(user, "Pressure: [round(pressure,0.01)] kPa") + + var/list/cached_gases = air_contents.gases + for(var/id in cached_gases) + var/gas_concentration = cached_gases[id]/total_moles + to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] % ([round(cached_gases[id], 0.01)] mol)") + to_chat(user, "Temperature: [round(temperature - T0C,0.01)] °C ([round(temperature, 0.01)] K)") + + else + if(airs.len > 1) + to_chat(user, "This node is empty!") + else + to_chat(user, "[target] is empty!") + + if(cached_scan_results && cached_scan_results["fusion"]) //notify the user if a fusion reaction was detected + var/instability = round(cached_scan_results["fusion"], 0.01) + to_chat(user, "Large amounts of free neutrons detected in the air indicate that a fusion reaction took place.") + to_chat(user, "Instability of the last fusion reaction: [instability].") + return + +//slime scanner + +/obj/item/slime_scanner + name = "slime scanner" + desc = "A device that analyzes a slime's internal composition and measures its stats." + icon = 'icons/obj/device.dmi' + icon_state = "adv_spectrometer" + item_state = "analyzer" + lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi' + w_class = WEIGHT_CLASS_SMALL + flags_1 = CONDUCT_1 + throwforce = 0 + throw_speed = 3 + throw_range = 7 + materials = list(MAT_METAL=30, MAT_GLASS=20) + +/obj/item/slime_scanner/attack(mob/living/M, mob/living/user) + if(user.stat || user.eye_blind) + return + if (!isslime(M)) + to_chat(user, "This device can only scan slimes!") + return + var/mob/living/simple_animal/slime/T = M + slime_scan(T, user) + +/proc/slime_scan(mob/living/simple_animal/slime/T, mob/living/user) + to_chat(user, "========================") + to_chat(user, "Slime scan results:") + to_chat(user, "[T.colour] [T.is_adult ? "adult" : "baby"] slime") + to_chat(user, "Nutrition: [T.nutrition]/[T.get_max_nutrition()]") + if (T.nutrition < T.get_starve_nutrition()) + to_chat(user, "Warning: slime is starving!") + else if (T.nutrition < T.get_hunger_nutrition()) + to_chat(user, "Warning: slime is hungry") + to_chat(user, "Electric change strength: [T.powerlevel]") + to_chat(user, "Health: [round(T.health/T.maxHealth,0.01)*100]%") + if (T.slime_mutation[4] == T.colour) + to_chat(user, "This slime does not evolve any further.") + else + if (T.slime_mutation[3] == T.slime_mutation[4]) + if (T.slime_mutation[2] == T.slime_mutation[1]) + to_chat(user, "Possible mutation: [T.slime_mutation[3]]") + to_chat(user, "Genetic destability: [T.mutation_chance/2] % chance of mutation on splitting") + else + to_chat(user, "Possible mutations: [T.slime_mutation[1]], [T.slime_mutation[2]], [T.slime_mutation[3]] (x2)") + to_chat(user, "Genetic destability: [T.mutation_chance] % chance of mutation on splitting") + else + to_chat(user, "Possible mutations: [T.slime_mutation[1]], [T.slime_mutation[2]], [T.slime_mutation[3]], [T.slime_mutation[4]]") + to_chat(user, "Genetic destability: [T.mutation_chance] % chance of mutation on splitting") + if (T.cores > 1) + to_chat(user, "Multiple cores detected") + to_chat(user, "Growth progress: [T.amount_grown]/[SLIME_EVOLUTION_THRESHOLD]") + if(T.effectmod) + to_chat(user, "Core mutation in progress: [T.effectmod]") + to_chat(user, "Progress in core mutation: [T.applied] / [SLIME_EXTRACT_CROSSING_REQUIRED]") + to_chat(user, "========================") + + +/obj/item/nanite_scanner + name = "nanite scanner" + icon = 'icons/obj/device.dmi' + icon_state = "nanite_scanner" + item_state = "nanite_remote" + lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi' + desc = "A hand-held body scanner able to detect nanites and their programming." + flags_1 = CONDUCT_1 + item_flags = NOBLUDGEON + slot_flags = ITEM_SLOT_BELT + throwforce = 3 + w_class = WEIGHT_CLASS_TINY + throw_speed = 3 + throw_range = 7 + materials = list(MAT_METAL=200) + +/obj/item/nanite_scanner/attack(mob/living/M, mob/living/carbon/human/user) + user.visible_message("[user] has analyzed [M]'s nanites.") + + add_fingerprint(user) + + var/response = SEND_SIGNAL(M, COMSIG_NANITE_SCAN, user, TRUE) + if(!response) + to_chat(user, "No nanites detected in the subject.") + +/obj/item/sequence_scanner + name = "genetic sequence scanner" + icon = 'icons/obj/device.dmi' + icon_state = "gene" + item_state = "healthanalyzer" + lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi' + desc = "A hand-held scanner able to swiftly scan someone for potential mutations. Hold near a DNA console to update from their database." + flags_1 = CONDUCT_1 + item_flags = NOBLUDGEON + slot_flags = ITEM_SLOT_BELT + throwforce = 3 + w_class = WEIGHT_CLASS_TINY + throw_speed = 3 + throw_range = 7 + materials = list(MAT_METAL=200) + var/list/discovered = list() //hit a dna console to update the scanners database + +/obj/item/sequence_scanner/attack(mob/living/M, mob/living/carbon/human/user) + user.visible_message("[user] has analyzed [M]'s genetic sequence.") + + add_fingerprint(user) + + gene_scan(M, user, src) + +/obj/item/sequence_scanner/afterattack(obj/O, mob/user, proximity) + . = ..() + if(!istype(O) || !proximity) + return + + if(istype(O, /obj/machinery/computer/scan_consolenew)) + var/obj/machinery/computer/scan_consolenew/C = O + if(C.stored_research) + to_chat(user, "[name] database updated.") + discovered = C.stored_research.discovered_mutations + else + to_chat(user,"No database to update from.") + +/proc/gene_scan(mob/living/carbon/C, mob/living/user, obj/item/sequence_scanner/G) + if(!iscarbon(C) || !C.has_dna()) + return + to_chat(user, "[C.name]'s potential mutations.") + for(var/A in C.dna.mutation_index) + var/datum/mutation/human/HM = GET_INITIALIZED_MUTATION(A) + var/mut_name + if(G && (A in G.discovered)) + mut_name = "[HM.name] ([HM.alias])" + else + mut_name = HM.alias + var/temp = GET_GENE_STRING(HM.type, C.dna) + var/display + for(var/i in 0 to length(temp) / DNA_MUTATION_BLOCKS-1) + if(i) + display += "-" + display += copytext(temp, 1 + i*DNA_MUTATION_BLOCKS, DNA_MUTATION_BLOCKS*(1+i) + 1) + + + to_chat(user, "- [mut_name] > [display]") diff --git a/code/game/objects/items/twohanded.dm b/code/game/objects/items/twohanded.dm index 765efbf6..078e9063 100644 --- a/code/game/objects/items/twohanded.dm +++ b/code/game/objects/items/twohanded.dm @@ -37,9 +37,9 @@ wielded = 0 if(force_unwielded) force = force_unwielded - var/sf = findtext(name," (Wielded)") + var/sf = findtext(name, " (Wielded)", -10)//10 == length(" (Wielded)") if(sf) - name = copytext(name,1,sf) + name = copytext(name, 1, sf) else //something wrong name = "[initial(name)]" update_icon() diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 784c6bf8..d9948b8e 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -1,253 +1,253 @@ - -/obj - var/crit_fail = FALSE - animate_movement = 2 - speech_span = SPAN_ROBOT - var/obj_flags = CAN_BE_HIT - var/set_obj_flags // ONLY FOR MAPPING: Sets flags from a string list, handled in Initialize. Usage: set_obj_flags = "EMAGGED;!CAN_BE_HIT" to set EMAGGED and clear CAN_BE_HIT. - - var/damtype = BRUTE - var/force = 0 - - var/datum/armor/armor - var/obj_integrity //defaults to max_integrity - var/max_integrity = 500 - var/integrity_failure = 0 //0 if we have no special broken behavior - - var/resistance_flags = NONE // INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ON_FIRE | UNACIDABLE | ACID_PROOF - - var/acid_level = 0 //how much acid is on that obj - - var/persistence_replacement //have something WAY too amazing to live to the next round? Set a new path here. Overuse of this var will make me upset. - var/current_skin //the item reskin - var/list/unique_reskin //List of options to reskin. - var/always_reskinnable = FALSE - - // Access levels, used in modules\jobs\access.dm - var/list/req_access - var/req_access_txt = "0" - var/list/req_one_access - var/req_one_access_txt = "0" - - var/renamedByPlayer = FALSE //set when a player uses a pen on a renamable object - -/obj/vv_edit_var(vname, vval) - switch(vname) - if("anchored") - setAnchored(vval) - return TRUE - if("obj_flags") - if ((obj_flags & DANGEROUS_POSSESSION) && !(vval & DANGEROUS_POSSESSION)) - return FALSE - if("control_object") - var/obj/O = vval - if(istype(O) && (O.obj_flags & DANGEROUS_POSSESSION)) - return FALSE - return ..() - -/obj/Initialize() - . = ..() - if (islist(armor)) - armor = getArmor(arglist(armor)) - else if (!armor) - armor = getArmor() - else if (!istype(armor, /datum/armor)) - stack_trace("Invalid type [armor.type] found in .armor during /obj Initialize()") - - if(obj_integrity == null) - obj_integrity = max_integrity - if (set_obj_flags) - var/flagslist = splittext(set_obj_flags,";") - var/list/string_to_objflag = GLOB.bitfields["obj_flags"] - for (var/flag in flagslist) - if (findtext(flag,"!",1,2)) - flag = copytext(flag,1-(length(flag))) // Get all but the initial ! - obj_flags &= ~string_to_objflag[flag] - else - obj_flags |= string_to_objflag[flag] - if((obj_flags & ON_BLUEPRINTS) && isturf(loc)) - var/turf/T = loc - T.add_blueprints_preround(src) - - -/obj/Destroy(force=FALSE) - if(!ismachinery(src)) - STOP_PROCESSING(SSobj, src) // TODO: Have a processing bitflag to reduce on unnecessary loops through the processing lists - SStgui.close_uis(src) - . = ..() - -/obj/proc/setAnchored(anchorvalue) - SEND_SIGNAL(src, COMSIG_OBJ_SETANCHORED, anchorvalue) - anchored = anchorvalue - -/obj/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, messy_throw = TRUE) - . = ..() - if(obj_flags & FROZEN) - visible_message("[src] shatters into a million pieces!") - qdel(src) - - -/obj/assume_air(datum/gas_mixture/giver) - if(loc) - return loc.assume_air(giver) - else - return null - -/obj/remove_air(amount) - if(loc) - return loc.remove_air(amount) - else - return null - -/obj/return_air() - if(loc) - return loc.return_air() - else - return null - -/obj/proc/handle_internal_lifeform(mob/lifeform_inside_me, breath_request) - //Return: (NONSTANDARD) - // null if object handles breathing logic for lifeform - // datum/air_group to tell lifeform to process using that breath return - //DEFAULT: Take air from turf to give to have mob process - - if(breath_request>0) - var/datum/gas_mixture/environment = return_air() - var/breath_percentage = BREATH_VOLUME / environment.return_volume() - return remove_air(environment.total_moles() * breath_percentage) - else - return null - -/obj/proc/updateUsrDialog() - if((obj_flags & IN_USE) && !(obj_flags & USES_TGUI)) - var/is_in_use = FALSE - var/list/nearby = viewers(1, src) - for(var/mob/M in nearby) - if ((M.client && M.machine == src)) - is_in_use = TRUE - ui_interact(M) - if(isAI(usr) || iscyborg(usr) || IsAdminGhost(usr)) - if (!(usr in nearby)) - if (usr.client && usr.machine==src) // && M.machine == src is omitted because if we triggered this by using the dialog, it doesn't matter if our machine changed in between triggering it and this - the dialog is probably still supposed to refresh. - is_in_use = TRUE - ui_interact(usr) - - // check for TK users - - if(ishuman(usr)) - var/mob/living/carbon/human/H = usr - if(!(usr in nearby)) - if(usr.client && usr.machine==src) - if(H.dna.check_mutation(TK)) - is_in_use = TRUE - ui_interact(usr) - if (is_in_use) - obj_flags |= IN_USE - else - obj_flags &= ~IN_USE - -/obj/proc/updateDialog(update_viewers = TRUE,update_ais = TRUE) - // Check that people are actually using the machine. If not, don't update anymore. - if(obj_flags & IN_USE) - var/is_in_use = FALSE - if(update_viewers) - for(var/mob/M in viewers(1, src)) - if ((M.client && M.machine == src)) - is_in_use = TRUE - src.interact(M) - var/ai_in_use = FALSE - if(update_ais) - ai_in_use = AutoUpdateAI(src) - - if(update_viewers && update_ais) //State change is sure only if we check both - if(!ai_in_use && !is_in_use) - obj_flags &= ~IN_USE - - -/obj/attack_ghost(mob/user) - . = ..() - if(.) - return - ui_interact(user) - -/obj/proc/container_resist(mob/living/user) - return - -/obj/proc/update_icon() - return - -/mob/proc/unset_machine() - if(machine) - machine.on_unset_machine(src) - machine = null - -//called when the user unsets the machine. -/atom/movable/proc/on_unset_machine(mob/user) - return - -/mob/proc/set_machine(obj/O) - if(src.machine) - unset_machine() - src.machine = O - if(istype(O)) - O.obj_flags |= IN_USE - -/obj/item/proc/updateSelfDialog() - var/mob/M = src.loc - if(istype(M) && M.client && M.machine == src) - src.attack_self(M) - -/obj/proc/hide(h) - return - -/obj/singularity_pull(S, current_size) - ..() - if(!anchored || current_size >= STAGE_FIVE) - step_towards(src,S) - -/obj/get_dumping_location(datum/component/storage/source,mob/user) - return get_turf(src) - -/obj/proc/CanAStarPass() - . = !density - -/obj/proc/check_uplink_validity() - return 1 - -/obj/proc/intercept_user_move(dir, mob, newLoc, oldLoc) - return - -/obj/vv_get_dropdown() - . = ..() - .["Delete all of type"] = "?_src_=vars;[HrefToken()];delall=[REF(src)]" - .["Osay"] = "?_src_=vars;[HrefToken()];osay[REF(src)]" - .["Modify armor values"] = "?_src_=vars;[HrefToken()];modarmor=[REF(src)]" - -/obj/examine(mob/user) - . = ..() - if(obj_flags & UNIQUE_RENAME) - . += "Use a pen on it to rename it or change its description." - if(unique_reskin && (!current_skin || always_reskinnable)) - . += "Alt-click it to reskin it." - -/obj/AltClick(mob/user) - . = ..() - if(unique_reskin && (!current_skin || always_reskinnable) && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY)) - reskin_obj(user) - return TRUE - -/obj/proc/reskin_obj(mob/M) - if(!LAZYLEN(unique_reskin)) - return - var/dat = "Reskin options for [name]:\n" - for(var/V in unique_reskin) - var/output = icon2html(src, M, unique_reskin[V]) - dat += "[V]: [output]\n" - to_chat(M, dat) - - var/choice = input(M, always_reskinnable ? "Choose the a reskin for [src]" : "Warning, you can only reskin [src] once!","Reskin Object") as null|anything in unique_reskin - if(QDELETED(src) || !choice || (current_skin && !always_reskinnable) || M.incapacitated() || !in_range(M,src) || !unique_reskin[choice] || unique_reskin[choice] == current_skin) - return - current_skin = choice - icon_state = unique_reskin[choice] - to_chat(M, "[src] is now skinned as '[choice]'.") + +/obj + var/crit_fail = FALSE + animate_movement = 2 + speech_span = SPAN_ROBOT + var/obj_flags = CAN_BE_HIT + var/set_obj_flags // ONLY FOR MAPPING: Sets flags from a string list, handled in Initialize. Usage: set_obj_flags = "EMAGGED;!CAN_BE_HIT" to set EMAGGED and clear CAN_BE_HIT. + + var/damtype = BRUTE + var/force = 0 + + var/datum/armor/armor + var/obj_integrity //defaults to max_integrity + var/max_integrity = 500 + var/integrity_failure = 0 //0 if we have no special broken behavior + + var/resistance_flags = NONE // INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ON_FIRE | UNACIDABLE | ACID_PROOF + + var/acid_level = 0 //how much acid is on that obj + + var/persistence_replacement //have something WAY too amazing to live to the next round? Set a new path here. Overuse of this var will make me upset. + var/current_skin //the item reskin + var/list/unique_reskin //List of options to reskin. + var/always_reskinnable = FALSE + + // Access levels, used in modules\jobs\access.dm + var/list/req_access + var/req_access_txt = "0" + var/list/req_one_access + var/req_one_access_txt = "0" + + var/renamedByPlayer = FALSE //set when a player uses a pen on a renamable object + +/obj/vv_edit_var(vname, vval) + switch(vname) + if("anchored") + setAnchored(vval) + return TRUE + if("obj_flags") + if ((obj_flags & DANGEROUS_POSSESSION) && !(vval & DANGEROUS_POSSESSION)) + return FALSE + if("control_object") + var/obj/O = vval + if(istype(O) && (O.obj_flags & DANGEROUS_POSSESSION)) + return FALSE + return ..() + +/obj/Initialize() + . = ..() + if (islist(armor)) + armor = getArmor(arglist(armor)) + else if (!armor) + armor = getArmor() + else if (!istype(armor, /datum/armor)) + stack_trace("Invalid type [armor.type] found in .armor during /obj Initialize()") + + if(obj_integrity == null) + obj_integrity = max_integrity + if (set_obj_flags) + var/flagslist = splittext(set_obj_flags,";") + var/list/string_to_objflag = GLOB.bitfields["obj_flags"] + for (var/flag in flagslist) + if(flag[1] == "!") + flag = copytext(flag, length(flag[1]) + 1) // Get all but the initial ! + obj_flags &= ~string_to_objflag[flag] + else + obj_flags |= string_to_objflag[flag] + if((obj_flags & ON_BLUEPRINTS) && isturf(loc)) + var/turf/T = loc + T.add_blueprints_preround(src) + + +/obj/Destroy(force=FALSE) + if(!ismachinery(src)) + STOP_PROCESSING(SSobj, src) // TODO: Have a processing bitflag to reduce on unnecessary loops through the processing lists + SStgui.close_uis(src) + . = ..() + +/obj/proc/setAnchored(anchorvalue) + SEND_SIGNAL(src, COMSIG_OBJ_SETANCHORED, anchorvalue) + anchored = anchorvalue + +/obj/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, messy_throw = TRUE) + . = ..() + if(obj_flags & FROZEN) + visible_message("[src] shatters into a million pieces!") + qdel(src) + + +/obj/assume_air(datum/gas_mixture/giver) + if(loc) + return loc.assume_air(giver) + else + return null + +/obj/remove_air(amount) + if(loc) + return loc.remove_air(amount) + else + return null + +/obj/return_air() + if(loc) + return loc.return_air() + else + return null + +/obj/proc/handle_internal_lifeform(mob/lifeform_inside_me, breath_request) + //Return: (NONSTANDARD) + // null if object handles breathing logic for lifeform + // datum/air_group to tell lifeform to process using that breath return + //DEFAULT: Take air from turf to give to have mob process + + if(breath_request>0) + var/datum/gas_mixture/environment = return_air() + var/breath_percentage = BREATH_VOLUME / environment.return_volume() + return remove_air(environment.total_moles() * breath_percentage) + else + return null + +/obj/proc/updateUsrDialog() + if((obj_flags & IN_USE) && !(obj_flags & USES_TGUI)) + var/is_in_use = FALSE + var/list/nearby = viewers(1, src) + for(var/mob/M in nearby) + if ((M.client && M.machine == src)) + is_in_use = TRUE + ui_interact(M) + if(isAI(usr) || iscyborg(usr) || IsAdminGhost(usr)) + if (!(usr in nearby)) + if (usr.client && usr.machine==src) // && M.machine == src is omitted because if we triggered this by using the dialog, it doesn't matter if our machine changed in between triggering it and this - the dialog is probably still supposed to refresh. + is_in_use = TRUE + ui_interact(usr) + + // check for TK users + + if(ishuman(usr)) + var/mob/living/carbon/human/H = usr + if(!(usr in nearby)) + if(usr.client && usr.machine==src) + if(H.dna.check_mutation(TK)) + is_in_use = TRUE + ui_interact(usr) + if (is_in_use) + obj_flags |= IN_USE + else + obj_flags &= ~IN_USE + +/obj/proc/updateDialog(update_viewers = TRUE,update_ais = TRUE) + // Check that people are actually using the machine. If not, don't update anymore. + if(obj_flags & IN_USE) + var/is_in_use = FALSE + if(update_viewers) + for(var/mob/M in viewers(1, src)) + if ((M.client && M.machine == src)) + is_in_use = TRUE + src.interact(M) + var/ai_in_use = FALSE + if(update_ais) + ai_in_use = AutoUpdateAI(src) + + if(update_viewers && update_ais) //State change is sure only if we check both + if(!ai_in_use && !is_in_use) + obj_flags &= ~IN_USE + + +/obj/attack_ghost(mob/user) + . = ..() + if(.) + return + ui_interact(user) + +/obj/proc/container_resist(mob/living/user) + return + +/obj/proc/update_icon() + return + +/mob/proc/unset_machine() + if(machine) + machine.on_unset_machine(src) + machine = null + +//called when the user unsets the machine. +/atom/movable/proc/on_unset_machine(mob/user) + return + +/mob/proc/set_machine(obj/O) + if(src.machine) + unset_machine() + src.machine = O + if(istype(O)) + O.obj_flags |= IN_USE + +/obj/item/proc/updateSelfDialog() + var/mob/M = src.loc + if(istype(M) && M.client && M.machine == src) + src.attack_self(M) + +/obj/proc/hide(h) + return + +/obj/singularity_pull(S, current_size) + ..() + if(!anchored || current_size >= STAGE_FIVE) + step_towards(src,S) + +/obj/get_dumping_location(datum/component/storage/source,mob/user) + return get_turf(src) + +/obj/proc/CanAStarPass() + . = !density + +/obj/proc/check_uplink_validity() + return 1 + +/obj/proc/intercept_user_move(dir, mob, newLoc, oldLoc) + return + +/obj/vv_get_dropdown() + . = ..() + .["Delete all of type"] = "?_src_=vars;[HrefToken()];delall=[REF(src)]" + .["Osay"] = "?_src_=vars;[HrefToken()];osay[REF(src)]" + .["Modify armor values"] = "?_src_=vars;[HrefToken()];modarmor=[REF(src)]" + +/obj/examine(mob/user) + . = ..() + if(obj_flags & UNIQUE_RENAME) + . += "Use a pen on it to rename it or change its description." + if(unique_reskin && (!current_skin || always_reskinnable)) + . += "Alt-click it to reskin it." + +/obj/AltClick(mob/user) + . = ..() + if(unique_reskin && (!current_skin || always_reskinnable) && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY)) + reskin_obj(user) + return TRUE + +/obj/proc/reskin_obj(mob/M) + if(!LAZYLEN(unique_reskin)) + return + var/dat = "Reskin options for [name]:\n" + for(var/V in unique_reskin) + var/output = icon2html(src, M, unique_reskin[V]) + dat += "[V]: [output]\n" + to_chat(M, dat) + + var/choice = input(M, always_reskinnable ? "Choose the a reskin for [src]" : "Warning, you can only reskin [src] once!","Reskin Object") as null|anything in unique_reskin + if(QDELETED(src) || !choice || (current_skin && !always_reskinnable) || M.incapacitated() || !in_range(M,src) || !unique_reskin[choice] || unique_reskin[choice] == current_skin) + return + current_skin = choice + icon_state = unique_reskin[choice] + to_chat(M, "[src] is now skinned as '[choice]'.") diff --git a/code/game/objects/structures/mirror.dm b/code/game/objects/structures/mirror.dm index 038097ba..cd6f52aa 100644 --- a/code/game/objects/structures/mirror.dm +++ b/code/game/objects/structures/mirror.dm @@ -133,7 +133,7 @@ switch(choice) if("name") - var/newname = copytext(sanitize(input(H, "Who are we again?", "Name change", H.name) as null|text),1,MAX_NAME_LEN) + var/newname = reject_bad_name(stripped_input(H, "Who are we again?", "Name change", H.name, MAX_NAME_LEN)) if(!newname) return diff --git a/code/game/objects/structures/musician.dm b/code/game/objects/structures/musician.dm index 36dbcc1e..df6d033a 100644 --- a/code/game/objects/structures/musician.dm +++ b/code/game/objects/structures/musician.dm @@ -1,381 +1,382 @@ - -#define MUSICIAN_HEARCHECK_MINDELAY 4 -#define MUSIC_MAXLINES 600 -#define MUSIC_MAXLINECHARS 50 - -/datum/song - var/name = "Untitled" - var/list/lines = new() - var/tempo = 5 // delay between notes - - var/playing = 0 // if we're playing - var/help = 0 // if help is open - var/edit = 1 // if we're in editing mode - var/repeat = 0 // number of times remaining to repeat - var/max_repeats = 10 // maximum times we can repeat - - var/instrumentDir = "piano" // the folder with the sounds - var/instrumentExt = "ogg" // the file extension - var/obj/instrumentObj = null // the associated obj playing the sound - var/last_hearcheck = 0 - var/list/hearing_mobs - -/datum/song/New(dir, obj, ext = "ogg") - tempo = sanitize_tempo(tempo) - instrumentDir = dir - instrumentObj = obj - instrumentExt = ext - -/datum/song/Destroy() - instrumentObj = null - return ..() - -// note is a number from 1-7 for A-G -// acc is either "b", "n", or "#" -// oct is 1-8 (or 9 for C) -/datum/song/proc/playnote(note, acc as text, oct) - // handle accidental -> B<>C of E<>F - if(acc == "b" && (note == 3 || note == 6)) // C or F - if(note == 3) - oct-- - note-- - acc = "n" - else if(acc == "#" && (note == 2 || note == 5)) // B or E - if(note == 2) - oct++ - note++ - acc = "n" - else if(acc == "#" && (note == 7)) //G# - note = 1 - acc = "b" - else if(acc == "#") // mass convert all sharps to flats, octave jump already handled - acc = "b" - note++ - - // check octave, C is allowed to go to 9 - if(oct < 1 || (note == 3 ? oct > 9 : oct > 8)) - return - - // now generate name - var/soundfile = "sound/instruments/[instrumentDir]/[ascii2text(note+64)][acc][oct].[instrumentExt]" - soundfile = file(soundfile) - // make sure the note exists - if(!fexists(soundfile)) - return - // and play - var/turf/source = get_turf(instrumentObj) - if((world.time - MUSICIAN_HEARCHECK_MINDELAY) > last_hearcheck) - LAZYCLEARLIST(hearing_mobs) - for(var/mob/M in get_hearers_in_view(15, source)) - if(!M.client || !(M.client.prefs.toggles & SOUND_INSTRUMENTS)) - continue - LAZYADD(hearing_mobs, M) - last_hearcheck = world.time - - var/sound/music_played = sound(soundfile) - for(var/i in hearing_mobs) - var/mob/M = i - M.playsound_local(source, null, 100, falloff = 5, S = music_played) - -/datum/song/proc/updateDialog(mob/user) - instrumentObj.updateDialog() // assumes it's an object in world, override if otherwise - -/datum/song/proc/shouldStopPlaying(mob/user) - if(instrumentObj) - if(!user.canUseTopic(instrumentObj)) - return TRUE - return !instrumentObj.anchored // add special cases to stop in subclasses - else - return TRUE - -/datum/song/proc/playsong(mob/user) - while(repeat >= 0) - var/cur_oct[7] - var/cur_acc[7] - for(var/i = 1 to 7) - cur_oct[i] = 3 - cur_acc[i] = "n" - - for(var/line in lines) - for(var/beat in splittext(lowertext(line), ",")) - var/list/notes = splittext(beat, "/") - for(var/note in splittext(notes[1], "-")) - if(!playing || shouldStopPlaying(user))//If the instrument is playing, or special case - playing = FALSE - hearing_mobs = null - return - if(!length(note)) - continue - var/cur_note = text2ascii(note) - 96 - if(cur_note < 1 || cur_note > 7) - continue - for(var/i=2 to length(note)) - var/ni = copytext(note,i,i+1) - if(!text2num(ni)) - if(ni == "#" || ni == "b" || ni == "n") - cur_acc[cur_note] = ni - else if(ni == "s") - cur_acc[cur_note] = "#" // so shift is never required - else - cur_oct[cur_note] = text2num(ni) - if(user.dizziness > 0 && prob(user.dizziness / 2)) - cur_note = CLAMP(cur_note + rand(round(-user.dizziness / 10), round(user.dizziness / 10)), 1, 7) - if(user.dizziness > 0 && prob(user.dizziness / 5)) - if(prob(30)) - cur_acc[cur_note] = "#" - else if(prob(42)) - cur_acc[cur_note] = "b" - else if(prob(75)) - cur_acc[cur_note] = "n" - playnote(cur_note, cur_acc[cur_note], cur_oct[cur_note]) - if(notes.len >= 2 && text2num(notes[2])) - sleep(sanitize_tempo(tempo / text2num(notes[2]))) - else - sleep(tempo) - repeat-- - hearing_mobs = null - playing = FALSE - repeat = 0 - updateDialog(user) - -/datum/song/proc/interact(mob/user) - var/dat = "" - - if(lines.len > 0) - dat += "

    Playback

    " - if(!playing) - dat += "Play Stop

    " - dat += "Repeat Song: " - dat += repeat > 0 ? "--" : "--" - dat += " [repeat] times " - dat += repeat < max_repeats ? "++" : "++" - dat += "
    " - else - dat += "Play Stop
    " - dat += "Repeats left: [repeat]
    " - if(!edit) - dat += "
    Show Editor
    " - else - dat += "

    Editing

    " - dat += "Hide Editor" - dat += " Start a New Song" - dat += " Import a Song

    " - var/bpm = round(600 / tempo) - dat += "Tempo: - [bpm] BPM +

    " - var/linecount = 0 - for(var/line in lines) - linecount += 1 - dat += "Line [linecount]: Edit X [line]
    " - dat += "Add Line

    " - if(help) - dat += "Hide Help
    " - dat += {" - Lines are a series of chords, separated by commas (,), each with notes separated by hyphens (-).
    - Every note in a chord will play together, with chord timed by the tempo.
    -
    - Notes are played by the names of the note, and optionally, the accidental, and/or the octave number.
    - By default, every note is natural and in octave 3. Defining otherwise is remembered for each note.
    - Example: C,D,E,F,G,A,B will play a C major scale.
    - After a note has an accidental placed, it will be remembered: C,C4,C,C3 is C3,C4,C4,C3
    - Chords can be played simply by seperating each note with a hyphon: A-C#,Cn-E,E-G#,Gn-B
    - A pause may be denoted by an empty chord: C,E,,C,G
    - To make a chord be a different time, end it with /x, where the chord length will be length
    - defined by tempo / x: C,G/2,E/4
    - Combined, an example is: E-E4/4,F#/2,G#/8,B/8,E3-E4/4 -
    - Lines may be up to [MUSIC_MAXLINECHARS] characters.
    - A song may only contain up to [MUSIC_MAXLINES] lines.
    - "} - else - dat += "Show Help
    " - - var/datum/browser/popup = new(user, "instrument", instrumentObj.name, 700, 500) - popup.set_content(dat) - popup.set_title_image(user.browse_rsc_icon(instrumentObj.icon, instrumentObj.icon_state)) - popup.open() - -/datum/song/proc/ParseSong(text) - set waitfor = FALSE - //split into lines - lines = splittext(text, "\n") - if(lines.len) - if(copytext(lines[1],1,6) == "BPM: ") - tempo = sanitize_tempo(600 / text2num(copytext(lines[1],6))) - lines.Cut(1,2) - else - tempo = sanitize_tempo(5) // default 120 BPM - if(lines.len > MUSIC_MAXLINES) - to_chat(usr, "Too many lines!") - lines.Cut(MUSIC_MAXLINES + 1) - var/linenum = 1 - for(var/l in lines) - if(length(l) > MUSIC_MAXLINECHARS) - to_chat(usr, "Line [linenum] too long!") - lines.Remove(l) - else - linenum++ - updateDialog(usr) // make sure updates when complete - -/datum/song/Topic(href, href_list) - if(!usr.canUseTopic(instrumentObj)) - usr << browse(null, "window=instrument") - usr.unset_machine() - return - - instrumentObj.add_fingerprint(usr) - - if(href_list["newsong"]) - lines = new() - tempo = sanitize_tempo(5) // default 120 BPM - name = "" - - else if(href_list["import"]) - var/t = "" - do - t = html_encode(input(usr, "Please paste the entire song, formatted:", text("[]", name), t) as message) - if(!in_range(instrumentObj, usr)) - return - - if(length(t) >= MUSIC_MAXLINES * MUSIC_MAXLINECHARS) - var/cont = input(usr, "Your message is too long! Would you like to continue editing it?", "", "yes") in list("yes", "no") - if(cont == "no") - break - while(length(t) > MUSIC_MAXLINES * MUSIC_MAXLINECHARS) - ParseSong(t) - - else if(href_list["help"]) - help = text2num(href_list["help"]) - 1 - - else if(href_list["edit"]) - edit = text2num(href_list["edit"]) - 1 - - if(href_list["repeat"]) //Changing this from a toggle to a number of repeats to avoid infinite loops. - if(playing) - return //So that people cant keep adding to repeat. If the do it intentionally, it could result in the server crashing. - repeat += round(text2num(href_list["repeat"])) - if(repeat < 0) - repeat = 0 - if(repeat > max_repeats) - repeat = max_repeats - - else if(href_list["tempo"]) - tempo = sanitize_tempo(tempo + text2num(href_list["tempo"])) - - else if(href_list["play"]) - playing = TRUE - spawn() - playsong(usr) - - else if(href_list["newline"]) - var/newline = html_encode(input("Enter your line: ", instrumentObj.name) as text|null) - if(!newline || !in_range(instrumentObj, usr)) - return - if(lines.len > MUSIC_MAXLINES) - return - if(length(newline) > MUSIC_MAXLINECHARS) - newline = copytext(newline, 1, MUSIC_MAXLINECHARS) - lines.Add(newline) - - else if(href_list["deleteline"]) - var/num = round(text2num(href_list["deleteline"])) - if(num > lines.len || num < 1) - return - lines.Cut(num, num+1) - - else if(href_list["modifyline"]) - var/num = round(text2num(href_list["modifyline"]),1) - var/content = html_encode(input("Enter your line: ", instrumentObj.name, lines[num]) as text|null) - if(!content || !in_range(instrumentObj, usr)) - return - if(length(content) > MUSIC_MAXLINECHARS) - content = copytext(content, 1, MUSIC_MAXLINECHARS) - if(num > lines.len || num < 1) - return - lines[num] = content - - else if(href_list["stop"]) - playing = FALSE - hearing_mobs = null - - updateDialog(usr) - return - -/datum/song/proc/sanitize_tempo(new_tempo) - new_tempo = abs(new_tempo) - return max(round(new_tempo, world.tick_lag), world.tick_lag) - -// subclass for handheld instruments, like violin -/datum/song/handheld - -/datum/song/handheld/updateDialog(mob/user) - instrumentObj.interact(user) - -/datum/song/handheld/shouldStopPlaying() - if(instrumentObj) - return !isliving(instrumentObj.loc) - else - return TRUE - - -////////////////////////////////////////////////////////////////////////// - - -/obj/structure/piano - name = "space minimoog" - icon = 'icons/obj/musician.dmi' - icon_state = "minimoog" - anchored = TRUE - density = TRUE - var/datum/song/song - -/obj/structure/piano/unanchored - anchored = FALSE - -/obj/structure/piano/New() - ..() - song = new("piano", src) - - if(prob(50) && icon_state == initial(icon_state)) - name = "space minimoog" - desc = "This is a minimoog, like a space piano, but more spacey!" - icon_state = "minimoog" - else - name = "space piano" - desc = "This is a space piano, like a regular piano, but always in tune! Even if the musician isn't." - icon_state = "piano" - -/obj/structure/piano/Destroy() - qdel(song) - song = null - return ..() - -/obj/structure/piano/Initialize(mapload) - . = ..() - if(mapload) - song.tempo = song.sanitize_tempo(song.tempo) // tick_lag isn't set when the map is loaded - -/obj/structure/piano/attack_hand(mob/user) - . = ..() - if(.) - return - interact(user) - -/obj/structure/piano/attack_paw(mob/user) - return attack_hand(user) - -/obj/structure/piano/interact(mob/user) - ui_interact(user) - -/obj/structure/piano/ui_interact(mob/user) - if(!user || !anchored) - return - - if(!user.IsAdvancedToolUser()) - to_chat(user, "You don't have the dexterity to do this!") - return 1 - user.set_machine(src) - song.interact(user) - -/obj/structure/piano/wrench_act(mob/living/user, obj/item/I) - default_unfasten_wrench(user, I, 40) - return TRUE + +#define MUSICIAN_HEARCHECK_MINDELAY 4 +#define MUSIC_MAXLINES 600 +#define MUSIC_MAXLINECHARS 50 + +/datum/song + var/name = "Untitled" + var/list/lines = new() + var/tempo = 5 // delay between notes + + var/playing = 0 // if we're playing + var/help = 0 // if help is open + var/edit = 1 // if we're in editing mode + var/repeat = 0 // number of times remaining to repeat + var/max_repeats = 10 // maximum times we can repeat + + var/instrumentDir = "piano" // the folder with the sounds + var/instrumentExt = "ogg" // the file extension + var/obj/instrumentObj = null // the associated obj playing the sound + var/last_hearcheck = 0 + var/list/hearing_mobs + +/datum/song/New(dir, obj, ext = "ogg") + tempo = sanitize_tempo(tempo) + instrumentDir = dir + instrumentObj = obj + instrumentExt = ext + +/datum/song/Destroy() + instrumentObj = null + return ..() + +// note is a number from 1-7 for A-G +// acc is either "b", "n", or "#" +// oct is 1-8 (or 9 for C) +/datum/song/proc/playnote(note, acc as text, oct) + // handle accidental -> B<>C of E<>F + if(acc == "b" && (note == 3 || note == 6)) // C or F + if(note == 3) + oct-- + note-- + acc = "n" + else if(acc == "#" && (note == 2 || note == 5)) // B or E + if(note == 2) + oct++ + note++ + acc = "n" + else if(acc == "#" && (note == 7)) //G# + note = 1 + acc = "b" + else if(acc == "#") // mass convert all sharps to flats, octave jump already handled + acc = "b" + note++ + + // check octave, C is allowed to go to 9 + if(oct < 1 || (note == 3 ? oct > 9 : oct > 8)) + return + + // now generate name + var/soundfile = "sound/instruments/[instrumentDir]/[ascii2text(note+64)][acc][oct].[instrumentExt]" + soundfile = file(soundfile) + // make sure the note exists + if(!fexists(soundfile)) + return + // and play + var/turf/source = get_turf(instrumentObj) + if((world.time - MUSICIAN_HEARCHECK_MINDELAY) > last_hearcheck) + LAZYCLEARLIST(hearing_mobs) + for(var/mob/M in get_hearers_in_view(15, source)) + if(!M.client || !(M.client.prefs.toggles & SOUND_INSTRUMENTS)) + continue + LAZYADD(hearing_mobs, M) + last_hearcheck = world.time + + var/sound/music_played = sound(soundfile) + for(var/i in hearing_mobs) + var/mob/M = i + M.playsound_local(source, null, 100, falloff = 5, S = music_played) + +/datum/song/proc/updateDialog(mob/user) + instrumentObj.updateDialog() // assumes it's an object in world, override if otherwise + +/datum/song/proc/shouldStopPlaying(mob/user) + if(instrumentObj) + if(!user.canUseTopic(instrumentObj)) + return TRUE + return !instrumentObj.anchored // add special cases to stop in subclasses + else + return TRUE + +/datum/song/proc/playsong(mob/user) + while(repeat >= 0) + var/cur_oct[7] + var/cur_acc[7] + for(var/i = 1 to 7) + cur_oct[i] = 3 + cur_acc[i] = "n" + + for(var/line in lines) + for(var/beat in splittext(lowertext(line), ",")) + var/list/notes = splittext(beat, "/") + for(var/note in splittext(notes[1], "-")) + if(!playing || shouldStopPlaying(user))//If the instrument is playing, or special case + playing = FALSE + hearing_mobs = null + return + if(!length(note)) + continue + var/cur_note = text2ascii(note) - 96 + if(cur_note < 1 || cur_note > 7) + continue + var/notelen = length(note) + var/ni = "" + for(var/i = length(note[1]) + 1, i <= notelen, i += length(ni)) + ni = note[i] + if(!text2num(ni)) + if(ni == "#" || ni == "b" || ni == "n") + cur_acc[cur_note] = ni + else if(ni == "s") + cur_acc[cur_note] = "#" // so shift is never required + else + cur_oct[cur_note] = text2num(ni) + if(user.dizziness > 0 && prob(user.dizziness / 2)) + cur_note = CLAMP(cur_note + rand(round(-user.dizziness / 10), round(user.dizziness / 10)), 1, 7) + if(user.dizziness > 0 && prob(user.dizziness / 5)) + if(prob(30)) + cur_acc[cur_note] = "#" + else if(prob(42)) + cur_acc[cur_note] = "b" + else if(prob(75)) + cur_acc[cur_note] = "n" + playnote(cur_note, cur_acc[cur_note], cur_oct[cur_note]) + if(notes.len >= 2 && text2num(notes[2])) + sleep(sanitize_tempo(tempo / text2num(notes[2]))) + else + sleep(tempo) + repeat-- + hearing_mobs = null + playing = FALSE + repeat = 0 + updateDialog(user) + +/datum/song/proc/interact(mob/user) + var/dat = "" + + if(lines.len > 0) + dat += "

    Playback

    " + if(!playing) + dat += "Play Stop

    " + dat += "Repeat Song: " + dat += repeat > 0 ? "--" : "--" + dat += " [repeat] times " + dat += repeat < max_repeats ? "++" : "++" + dat += "
    " + else + dat += "Play Stop
    " + dat += "Repeats left: [repeat]
    " + if(!edit) + dat += "
    Show Editor
    " + else + dat += "

    Editing

    " + dat += "Hide Editor" + dat += " Start a New Song" + dat += " Import a Song

    " + var/bpm = round(600 / tempo) + dat += "Tempo: - [bpm] BPM +

    " + var/linecount = 0 + for(var/line in lines) + linecount += 1 + dat += "Line [linecount]: Edit X [line]
    " + dat += "Add Line

    " + if(help) + dat += "Hide Help
    " + dat += {" + Lines are a series of chords, separated by commas (,), each with notes separated by hyphens (-).
    + Every note in a chord will play together, with chord timed by the tempo.
    +
    + Notes are played by the names of the note, and optionally, the accidental, and/or the octave number.
    + By default, every note is natural and in octave 3. Defining otherwise is remembered for each note.
    + Example: C,D,E,F,G,A,B will play a C major scale.
    + After a note has an accidental placed, it will be remembered: C,C4,C,C3 is C3,C4,C4,C3
    + Chords can be played simply by seperating each note with a hyphon: A-C#,Cn-E,E-G#,Gn-B
    + A pause may be denoted by an empty chord: C,E,,C,G
    + To make a chord be a different time, end it with /x, where the chord length will be length
    + defined by tempo / x: C,G/2,E/4
    + Combined, an example is: E-E4/4,F#/2,G#/8,B/8,E3-E4/4 +
    + Lines may be up to [MUSIC_MAXLINECHARS] characters.
    + A song may only contain up to [MUSIC_MAXLINES] lines.
    + "} + else + dat += "Show Help
    " + + var/datum/browser/popup = new(user, "instrument", instrumentObj.name, 700, 500) + popup.set_content(dat) + popup.set_title_image(user.browse_rsc_icon(instrumentObj.icon, instrumentObj.icon_state)) + popup.open() + +/datum/song/proc/ParseSong(text) + set waitfor = FALSE + //split into lines + lines = splittext(text, "\n") + if(lines.len) + var/bpm_string = "BPM: " + if(findtext(lines[1], bpm_string, 1, length(bpm_string) + 1)) + tempo = sanitize_tempo(600 / text2num(copytext(lines[1], length(bpm_string) + 1))) + lines.Cut(1, 2) + else + tempo = sanitize_tempo(5) // default 120 BPM + if(lines.len > MUSIC_MAXLINES) + to_chat(usr, "Too many lines!") + lines.Cut(MUSIC_MAXLINES + 1) + var/linenum = 1 + for(var/l in lines) + if(length_char(l) > MUSIC_MAXLINECHARS) + to_chat(usr, "Line [linenum] too long!") + lines.Remove(l) + else + linenum++ + updateDialog(usr) // make sure updates when complete + +/datum/song/Topic(href, href_list) + if(!usr.canUseTopic(instrumentObj)) + usr << browse(null, "window=instrument") + usr.unset_machine() + return + + instrumentObj.add_fingerprint(usr) + + if(href_list["newsong"]) + lines = new() + tempo = sanitize_tempo(5) // default 120 BPM + name = "" + + else if(href_list["import"]) + var/t = "" + do + t = html_encode(input(usr, "Please paste the entire song, formatted:", text("[]", name), t) as message) + if(!in_range(instrumentObj, usr)) + return + + if(length_char(t) >= MUSIC_MAXLINES * MUSIC_MAXLINECHARS) + var/cont = input(usr, "Your message is too long! Would you like to continue editing it?", "", "yes") in list("yes", "no") + if(cont == "no") + break + while(length_char(t) > MUSIC_MAXLINES * MUSIC_MAXLINECHARS) + ParseSong(t) + + else if(href_list["help"]) + help = text2num(href_list["help"]) - 1 + + else if(href_list["edit"]) + edit = text2num(href_list["edit"]) - 1 + + if(href_list["repeat"]) //Changing this from a toggle to a number of repeats to avoid infinite loops. + if(playing) + return //So that people cant keep adding to repeat. If the do it intentionally, it could result in the server crashing. + repeat += round(text2num(href_list["repeat"])) + if(repeat < 0) + repeat = 0 + if(repeat > max_repeats) + repeat = max_repeats + + else if(href_list["tempo"]) + tempo = sanitize_tempo(tempo + text2num(href_list["tempo"])) + + else if(href_list["play"]) + playing = TRUE + spawn() + playsong(usr) + + else if(href_list["newline"]) + var/newline = html_encode(input("Enter your line: ", instrumentObj.name) as text|null) + if(!newline || !in_range(instrumentObj, usr)) + return + if(lines.len > MUSIC_MAXLINES) + return + if(length(newline) > MUSIC_MAXLINECHARS) + newline = copytext(newline, 1, MUSIC_MAXLINECHARS) + lines.Add(newline) + + else if(href_list["deleteline"]) + var/num = round(text2num(href_list["deleteline"])) + if(num > lines.len || num < 1) + return + lines.Cut(num, num+1) + + else if(href_list["modifyline"]) + var/num = round(text2num(href_list["modifyline"]),1) + var/content = stripped_input(usr, "Enter your line: ", instrumentObj.name, lines[num], MUSIC_MAXLINECHARS) + if(!content || !in_range(instrumentObj, usr)) + return + if(num > lines.len || num < 1) + return + lines[num] = content + + else if(href_list["stop"]) + playing = FALSE + hearing_mobs = null + + updateDialog(usr) + return + +/datum/song/proc/sanitize_tempo(new_tempo) + new_tempo = abs(new_tempo) + return max(round(new_tempo, world.tick_lag), world.tick_lag) + +// subclass for handheld instruments, like violin +/datum/song/handheld + +/datum/song/handheld/updateDialog(mob/user) + instrumentObj.interact(user) + +/datum/song/handheld/shouldStopPlaying() + if(instrumentObj) + return !isliving(instrumentObj.loc) + else + return TRUE + + +////////////////////////////////////////////////////////////////////////// + + +/obj/structure/piano + name = "space minimoog" + icon = 'icons/obj/musician.dmi' + icon_state = "minimoog" + anchored = TRUE + density = TRUE + var/datum/song/song + +/obj/structure/piano/unanchored + anchored = FALSE + +/obj/structure/piano/New() + ..() + song = new("piano", src) + + if(prob(50) && icon_state == initial(icon_state)) + name = "space minimoog" + desc = "This is a minimoog, like a space piano, but more spacey!" + icon_state = "minimoog" + else + name = "space piano" + desc = "This is a space piano, like a regular piano, but always in tune! Even if the musician isn't." + icon_state = "piano" + +/obj/structure/piano/Destroy() + qdel(song) + song = null + return ..() + +/obj/structure/piano/Initialize(mapload) + . = ..() + if(mapload) + song.tempo = song.sanitize_tempo(song.tempo) // tick_lag isn't set when the map is loaded + +/obj/structure/piano/attack_hand(mob/user) + . = ..() + if(.) + return + interact(user) + +/obj/structure/piano/attack_paw(mob/user) + return attack_hand(user) + +/obj/structure/piano/interact(mob/user) + ui_interact(user) + +/obj/structure/piano/ui_interact(mob/user) + if(!user || !anchored) + return + + if(!user.IsAdvancedToolUser()) + to_chat(user, "You don't have the dexterity to do this!") + return 1 + user.set_machine(src) + song.interact(user) + +/obj/structure/piano/wrench_act(mob/living/user, obj/item/I) + default_unfasten_wrench(user, I, 40) + return TRUE diff --git a/code/game/say.dm b/code/game/say.dm index 10c4a698..5fe6024f 100644 --- a/code/game/say.dm +++ b/code/game/say.dm @@ -75,8 +75,8 @@ GLOBAL_LIST_INIT(freqtospan, list( return "" /atom/movable/proc/say_mod(input, message_mode) - var/ending = copytext(input, length(input)) - if(copytext(input, length(input) - 1) == "!!") + var/ending = copytext_char(input, -1) + if(copytext_char(input, -2) == "!!") return verb_yell else if(ending == "?") return verb_ask @@ -89,7 +89,7 @@ GLOBAL_LIST_INIT(freqtospan, list( if(!input) input = "..." - if(copytext(input, length(input) - 1) == "!!") + if(copytext_char(input, -2) == "!!") spans |= SPAN_YELL var/spanned = attach_spans(input, spans) @@ -136,12 +136,12 @@ GLOBAL_LIST_INIT(freqtospan, list( var/returntext = GLOB.reverseradiochannels["[freq]"] if(returntext) return returntext - return "[copytext("[freq]", 1, 4)].[copytext("[freq]", 4, 5)]" + return "[copytext_char("[freq]", 1, 4)].[copytext_char("[freq]", 4, 5)]" /atom/movable/proc/attach_spans(input, list/spans) var/customsayverb = findtext(input, "*") if(customsayverb) - input = capitalize(copytext(input, customsayverb+1)) + input = capitalize(copytext(input, length(input[customsayverb]) + 1)) if(input) return "[message_spans_start(spans)][input]
    " else @@ -155,7 +155,7 @@ GLOBAL_LIST_INIT(freqtospan, list( return output /proc/say_test(text) - var/ending = copytext(text, length(text)) + var/ending = copytext_char(text, -1) if (ending == "?") return "1" else if (ending == "!") diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm index 4f2aa358..8856982c 100644 --- a/code/modules/admin/admin_ranks.dm +++ b/code/modules/admin/admin_ranks.dm @@ -135,10 +135,10 @@ GLOBAL_PROTECT(protected_ranks) var/previous_rights = 0 //load text from file and process each line separately for(var/line in world.file2list("[global.config.directory]/admin_ranks.txt")) - if(!line || findtextEx(line,"#",1,2)) + if(!line || findtextEx_char(line,"#",1,2)) continue var/next = findtext(line, "=") - var/datum/admin_rank/R = new(ckeyEx(copytext(line, 1, next))) + var/datum/admin_rank/R = new(ckeyEx(copytext(line, 1, line[next]))) if(!R) continue GLOB.admin_ranks += R @@ -146,7 +146,7 @@ GLOBAL_PROTECT(protected_ranks) var/prev = findchar(line, "+-*", next, 0) while(prev) next = findchar(line, "+-*", prev + 1, 0) - R.process_keyword(copytext(line, prev, next), previous_rights) + R.process_keyword(copytext_char(line, prev, next), previous_rights) prev = next previous_rights = R.rights if(!CONFIG_GET(flag/admin_legacy_system) || dbfail) diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 3c2f0f14..06a6a86a 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -447,11 +447,9 @@ GLOBAL_LIST_INIT(admin_verbs_hideable, list( mob.name = initial(mob.name) mob.mouse_opacity = initial(mob.mouse_opacity) else - var/new_key = ckeyEx(input("Enter your desired display name.", "Fake Key", key) as text|null) + var/new_key = ckeyEx(stripped_input(usr, "Enter your desired display name.", "Fake Key", key, 26)) if(!new_key) return - if(length(new_key) >= 26) - new_key = copytext(new_key, 1, 26) holder.fakekey = new_key createStealthKey() if(isobserver(mob)) @@ -558,9 +556,9 @@ GLOBAL_LIST_INIT(admin_verbs_hideable, list( set desc = "Gives a spell to a mob." var/list/spell_list = list() - var/type_length = length("/obj/effect/proc_holder/spell") + 2 + var/type_length = length_char("/obj/effect/proc_holder/spell") + 2 for(var/A in GLOB.spells) - spell_list[copytext("[A]", type_length)] = A + spell_list[copytext_char("[A]", type_length)] = A var/obj/effect/proc_holder/spell/S = input("Choose the spell to give to that guy", "ABRAKADABRA") as null|anything in spell_list if(!S) return diff --git a/code/modules/admin/check_antagonists.dm b/code/modules/admin/check_antagonists.dm index 30fa664f..8cb2a9a4 100644 --- a/code/modules/admin/check_antagonists.dm +++ b/code/modules/admin/check_antagonists.dm @@ -149,10 +149,10 @@ else var/timeleft = SSshuttle.emergency.timeLeft() if(SSshuttle.emergency.mode == SHUTTLE_CALL) - dat += "ETA: [(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]
    " + dat += "ETA: [(timeleft / 60) % 60]:[add_leading(num2text(timeleft % 60), 2, "0")]
    " dat += "Send Back
    " else - dat += "ETA: [(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]
    " + dat += "ETA: [(timeleft / 60) % 60]:[add_leading(num2text(timeleft % 60), 2, "0")]
    " dat += "Continuous Round Status
    " dat += "[CONFIG_GET(keyed_list/continuous)[SSticker.mode.config_tag] ? "Continue if antagonists die" : "End on antagonist death"]" if(CONFIG_GET(keyed_list/continuous)[SSticker.mode.config_tag]) diff --git a/code/modules/admin/secrets.dm b/code/modules/admin/secrets.dm index 9dc8b73d..2323de4e 100644 --- a/code/modules/admin/secrets.dm +++ b/code/modules/admin/secrets.dm @@ -345,7 +345,7 @@ if(!SSticker.HasRoundStarted()) alert("The game hasn't started yet!") return - var/objective = copytext(sanitize(input("Enter an objective")),1,MAX_MESSAGE_LEN) + var/objective = stripped_input(usr, "Enter an objective") if(!objective) return SSblackbox.record_feedback("nested tally", "admin_secrets_fun_used", 1, list("Traitor All", "[objective]")) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 09cfb2d1..101d659c 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1,2991 +1,2983 @@ -/datum/admins/proc/CheckAdminHref(href, href_list) - var/auth = href_list["admin_token"] - . = auth && (auth == href_token || auth == GLOB.href_token) - if(.) - return - var/msg = !auth ? "no" : "a bad" - message_admins("[key_name_admin(usr)] clicked an href with [msg] authorization key!") - if(CONFIG_GET(flag/debug_admin_hrefs)) - message_admins("Debug mode enabled, call not blocked. Please ask your coders to review this round's logs.") - log_world("UAH: [href]") - return TRUE - log_admin_private("[key_name(usr)] clicked an href with [msg] authorization key! [href]") - -/datum/admins/Topic(href, href_list) - ..() - - if(usr.client != src.owner || !check_rights(0)) - message_admins("[usr.key] tried to use the admin panel without authorization.") - log_admin("[key_name(usr)] tried to use the admin panel without authorization.") - return - - if(!CheckAdminHref(href, href_list)) - return - - if(href_list["makementor"]) - makeMentor(href_list["makementor"]) - else if(href_list["removementor"]) - removeMentor(href_list["removementor"]) - - if(href_list["ahelp"]) - if(!check_rights(R_ADMIN, TRUE)) - return - - var/ahelp_ref = href_list["ahelp"] - var/datum/admin_help/AH = locate(ahelp_ref) - if(AH) - AH.Action(href_list["ahelp_action"]) - else - to_chat(usr, "Ticket [ahelp_ref] has been deleted!") - - else if(href_list["ahelp_tickets"]) - GLOB.ahelp_tickets.BrowseTickets(text2num(href_list["ahelp_tickets"])) - - else if(href_list["stickyban"]) - stickyban(href_list["stickyban"],href_list) - - else if(href_list["getplaytimewindow"]) - if(!check_rights(R_ADMIN)) - return - var/mob/M = locate(href_list["getplaytimewindow"]) in GLOB.mob_list - if(!M) - to_chat(usr, "ERROR: Mob not found.") - return - cmd_show_exp_panel(M.client) - - else if(href_list["toggleexempt"]) - if(!check_rights(R_ADMIN)) - return - var/client/C = locate(href_list["toggleexempt"]) in GLOB.clients - if(!C) - to_chat(usr, "ERROR: Client not found.") - return - toggle_exempt_status(C) - - else if(href_list["makeAntag"]) - if(!check_rights(R_ADMIN)) - return - if (!SSticker.mode) - to_chat(usr, "Not until the round starts!") - return - switch(href_list["makeAntag"]) - if("traitors") - if(src.makeTraitors()) - message_admins("[key_name_admin(usr)] created traitors.") - log_admin("[key_name(usr)] created traitors.") - else - message_admins("[key_name_admin(usr)] tried to create traitors. Unfortunately, there were no candidates available.") - log_admin("[key_name(usr)] failed to create traitors.") - if("changelings") - if(src.makeChangelings()) - message_admins("[key_name(usr)] created changelings.") - log_admin("[key_name(usr)] created changelings.") - else - message_admins("[key_name_admin(usr)] tried to create changelings. Unfortunately, there were no candidates available.") - log_admin("[key_name(usr)] failed to create changelings.") - if("revs") - if(src.makeRevs()) - message_admins("[key_name(usr)] started a revolution.") - log_admin("[key_name(usr)] started a revolution.") - else - message_admins("[key_name_admin(usr)] tried to start a revolution. Unfortunately, there were no candidates available.") - log_admin("[key_name(usr)] failed to start a revolution.") - if("cult") - if(src.makeCult()) - message_admins("[key_name(usr)] started a cult.") - log_admin("[key_name(usr)] started a cult.") - else - message_admins("[key_name_admin(usr)] tried to start a cult. Unfortunately, there were no candidates available.") - log_admin("[key_name(usr)] failed to start a cult.") - if("wizard") - message_admins("[key_name(usr)] is creating a wizard...") - if(src.makeWizard()) - message_admins("[key_name(usr)] created a wizard.") - log_admin("[key_name(usr)] created a wizard.") - else - message_admins("[key_name_admin(usr)] tried to create a wizard. Unfortunately, there were no candidates available.") - log_admin("[key_name(usr)] failed to create a wizard.") - if("nukeops") - message_admins("[key_name(usr)] is creating a nuke team...") - if(src.makeNukeTeam()) - message_admins("[key_name(usr)] created a nuke team.") - log_admin("[key_name(usr)] created a nuke team.") - else - message_admins("[key_name_admin(usr)] tried to create a nuke team. Unfortunately, there were not enough candidates available.") - log_admin("[key_name(usr)] failed to create a nuke team.") - if("ninja") - message_admins("[key_name(usr)] spawned a ninja.") - log_admin("[key_name(usr)] spawned a ninja.") - src.makeSpaceNinja() - if("aliens") - message_admins("[key_name(usr)] started an alien infestation.") - log_admin("[key_name(usr)] started an alien infestation.") - src.makeAliens() - if("deathsquad") - message_admins("[key_name(usr)] is creating a death squad...") - if(src.makeDeathsquad()) - message_admins("[key_name(usr)] created a death squad.") - log_admin("[key_name(usr)] created a death squad.") - else - message_admins("[key_name_admin(usr)] tried to create a death squad. Unfortunately, there were not enough candidates available.") - log_admin("[key_name(usr)] failed to create a death squad.") - if("blob") - var/strength = input("Set Blob Resource Gain Rate","Set Resource Rate",1) as num|null - if(!strength) - return - message_admins("[key_name(usr)] spawned a blob with base resource gain [strength].") - log_admin("[key_name(usr)] spawned a blob with base resource gain [strength].") - new/datum/round_event/ghost_role/blob(TRUE, strength) - if("centcom") - message_admins("[key_name(usr)] is creating a CentCom response team...") - if(src.makeEmergencyresponseteam()) - message_admins("[key_name(usr)] created a CentCom response team.") - log_admin("[key_name(usr)] created a CentCom response team.") - else - message_admins("[key_name_admin(usr)] tried to create a CentCom response team. Unfortunately, there were not enough candidates available.") - log_admin("[key_name(usr)] failed to create a CentCom response team.") - if("abductors") - message_admins("[key_name(usr)] is creating an abductor team...") - if(src.makeAbductorTeam()) - message_admins("[key_name(usr)] created an abductor team.") - log_admin("[key_name(usr)] created an abductor team.") - else - message_admins("[key_name_admin(usr)] tried to create an abductor team. Unfortunatly there were not enough candidates available.") - log_admin("[key_name(usr)] failed to create an abductor team.") - if("clockcult") - if(src.makeClockCult()) - message_admins("[key_name(usr)] started a clockwork cult.") - log_admin("[key_name(usr)] started a clockwork cult.") - else - message_admins("[key_name_admin(usr)] tried to start a clockwork cult. Unfortunately, there were no candidates available.") - log_admin("[key_name(usr)] failed to start a clockwork cult.") - if("revenant") - if(src.makeRevenant()) - message_admins("[key_name(usr)] created a revenant.") - log_admin("[key_name(usr)] created a revenant.") - else - message_admins("[key_name_admin(usr)] tried to create a revenant. Unfortunately, there were no candidates available.") - log_admin("[key_name(usr)] failed to create a revenant.") - //Hyper - if("lewdtraitors") - if(src.makeLewdtraitors()) - message_admins("[key_name(usr)] created a lewd traitor.") - log_admin("[key_name(usr)] created a lewd traitor.") - else - message_admins("[key_name_admin(usr)] tried to create a lewd traitor. Unfortunately, there were no candidates available.") - log_admin("[key_name(usr)] failed to create a lewd traitor.") - - else if(href_list["forceevent"]) - if(!check_rights(R_FUN)) - return - var/datum/round_event_control/E = locate(href_list["forceevent"]) in SSevents.control - if(E) - E.admin_setup(usr) - var/datum/round_event/event = E.runEvent() - if(event.announceWhen>0) - event.processing = FALSE - var/prompt = alert(usr, "Would you like to alert the crew?", "Alert", "Yes", "No", "Cancel") - switch(prompt) - if("Cancel") - event.kill() - return - if("No") - event.announceWhen = -1 - event.processing = TRUE - message_admins("[key_name_admin(usr)] has triggered an event. ([E.name])") - log_admin("[key_name(usr)] has triggered an event. ([E.name])") - return - - else if(href_list["dbsearchckey"] || href_list["dbsearchadmin"] || href_list["dbsearchip"] || href_list["dbsearchcid"]) - var/adminckey = href_list["dbsearchadmin"] - var/playerckey = href_list["dbsearchckey"] - var/ip = href_list["dbsearchip"] - var/cid = href_list["dbsearchcid"] - var/page = href_list["dbsearchpage"] - - DB_ban_panel(playerckey, adminckey, ip, cid, page) - return - - else if(href_list["dbbanedit"]) - var/banedit = href_list["dbbanedit"] - var/banid = text2num(href_list["dbbanid"]) - if(!banedit || !banid) - return - - DB_ban_edit(banid, banedit) - return - - else if(href_list["dbbanaddtype"]) - if(!check_rights(R_BAN)) - return - var/bantype = text2num(href_list["dbbanaddtype"]) - var/bankey = href_list["dbbanaddkey"] - var/banckey = ckey(bankey) - var/banip = href_list["dbbanaddip"] - var/bancid = href_list["dbbanaddcid"] - var/banduration = text2num(href_list["dbbaddduration"]) - var/banjob = href_list["dbbanaddjob"] - var/banreason = href_list["dbbanreason"] - var/banseverity = href_list["dbbanaddseverity"] - - switch(bantype) - if(BANTYPE_PERMA) - if(!banckey || !banreason || !banseverity) - to_chat(usr, "Not enough parameters (Requires ckey, severity, and reason).") - return - banduration = null - banjob = null - if(BANTYPE_TEMP) - if(!banckey || !banreason || !banduration || !banseverity) - to_chat(usr, "Not enough parameters (Requires ckey, reason, severity and duration).") - return - banjob = null - if(BANTYPE_JOB_PERMA) - if(!banckey || !banreason || !banjob || !banseverity) - to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and job).") - return - banduration = null - if(BANTYPE_JOB_TEMP) - if(!banckey || !banreason || !banjob || !banduration || !banseverity) - to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and job).") - return - if(BANTYPE_ADMIN_PERMA) - if(!banckey || !banreason || !banseverity) - to_chat(usr, "Not enough parameters (Requires ckey, severity and reason).") - return - banduration = null - banjob = null - if(BANTYPE_ADMIN_TEMP) - if(!banckey || !banreason || !banduration || !banseverity) - to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and duration).") - return - banjob = null - - var/mob/playermob - - for(var/mob/M in GLOB.player_list) - if(M.ckey == banckey) - playermob = M - break - - - banreason = "(MANUAL BAN) "+banreason - - if(!playermob) - if(banip) - banreason = "[banreason] (CUSTOM IP)" - if(bancid) - banreason = "[banreason] (CUSTOM CID)" - else - message_admins("Ban process: A mob matching [playermob.key] was found at location [playermob.x], [playermob.y], [playermob.z]. Custom ip and computer id fields replaced with the ip and computer id from the located mob.") - - if(!DB_ban_record(bantype, playermob, banduration, banreason, banjob, bankey, banip, bancid )) - to_chat(usr, "Failed to apply ban.") - return - create_message("note", bankey, null, banreason, null, null, 0, 0, null, 0, banseverity) - - else if(href_list["editrightsbrowser"]) - edit_admin_permissions(0) - - else if(href_list["editrightsbrowserlog"]) - edit_admin_permissions(1, href_list["editrightstarget"], href_list["editrightsoperation"], href_list["editrightspage"]) - - if(href_list["editrightsbrowsermanage"]) - if(href_list["editrightschange"]) - change_admin_rank(ckey(href_list["editrightschange"]), href_list["editrightschange"], TRUE) - else if(href_list["editrightsremove"]) - remove_admin(ckey(href_list["editrightsremove"]), href_list["editrightsremove"], TRUE) - else if(href_list["editrightsremoverank"]) - remove_rank(href_list["editrightsremoverank"]) - edit_admin_permissions(2) - - else if(href_list["editrights"]) - edit_rights_topic(href_list) - - else if(href_list["gamemode_panel"]) - if(!check_rights(R_ADMIN)) - return - SSticker.mode.admin_panel() - - - else if(href_list["call_shuttle"]) - if(!check_rights(R_ADMIN)) - return - - - switch(href_list["call_shuttle"]) - if("1") - if(EMERGENCY_AT_LEAST_DOCKED) - return - SSshuttle.emergency.request() - log_admin("[key_name(usr)] called the Emergency Shuttle.") - message_admins("[key_name_admin(usr)] called the Emergency Shuttle to the station.") - - if("2") - if(EMERGENCY_AT_LEAST_DOCKED) - return - switch(SSshuttle.emergency.mode) - if(SHUTTLE_CALL) - SSshuttle.emergency.cancel() - log_admin("[key_name(usr)] sent the Emergency Shuttle back.") - message_admins("[key_name_admin(usr)] sent the Emergency Shuttle back.") - else - SSshuttle.emergency.cancel() - log_admin("[key_name(usr)] called the Emergency Shuttle.") - message_admins("[key_name_admin(usr)] called the Emergency Shuttle to the station.") - - - href_list["secrets"] = "check_antagonist" - - else if(href_list["edit_shuttle_time"]) - if(!check_rights(R_SERVER)) - return - - var/timer = input("Enter new shuttle duration (seconds):","Edit Shuttle Timeleft", SSshuttle.emergency.timeLeft() ) as num|null - if(!timer) - return - SSshuttle.emergency.setTimer(timer*10) - log_admin("[key_name(usr)] edited the Emergency Shuttle's timeleft to [timer] seconds.") - minor_announce("The emergency shuttle will reach its destination in [round(SSshuttle.emergency.timeLeft(600))] minutes.") - message_admins("[key_name_admin(usr)] edited the Emergency Shuttle's timeleft to [timer] seconds.") - href_list["secrets"] = "check_antagonist" - else if(href_list["trigger_centcom_recall"]) - if(!check_rights(R_ADMIN)) - return - - usr.client.trigger_centcom_recall() - - else if(href_list["toggle_continuous"]) - if(!check_rights(R_ADMIN)) - return - var/list/continuous = CONFIG_GET(keyed_list/continuous) - if(!continuous[SSticker.mode.config_tag]) - continuous[SSticker.mode.config_tag] = TRUE - else - continuous[SSticker.mode.config_tag] = FALSE - - message_admins("[key_name_admin(usr)] toggled the round to [continuous[SSticker.mode.config_tag] ? "continue if all antagonists die" : "end with the antagonists"].") - check_antagonists() - - else if(href_list["toggle_midround_antag"]) - if(!check_rights(R_ADMIN)) - return - - var/list/midround_antag = CONFIG_GET(keyed_list/midround_antag) - if(!midround_antag[SSticker.mode.config_tag]) - midround_antag[SSticker.mode.config_tag] = TRUE - else - midround_antag[SSticker.mode.config_tag] = FALSE - - message_admins("[key_name_admin(usr)] toggled the round to [midround_antag[SSticker.mode.config_tag] ? "use" : "skip"] the midround antag system.") - check_antagonists() - - else if(href_list["alter_midround_time_limit"]) - if(!check_rights(R_ADMIN)) - return - - var/timer = input("Enter new maximum time",, CONFIG_GET(number/midround_antag_time_check)) as num|null - if(!timer) - return - CONFIG_SET(number/midround_antag_time_check, timer) - message_admins("[key_name_admin(usr)] edited the maximum midround antagonist time to [timer] minutes.") - check_antagonists() - - else if(href_list["alter_midround_life_limit"]) - if(!check_rights(R_ADMIN)) - return - - var/ratio = input("Enter new life ratio",, CONFIG_GET(number/midround_antag_life_check) * 100) as num - if(!ratio) - return - CONFIG_SET(number/midround_antag_life_check, ratio / 100) - - message_admins("[key_name_admin(usr)] edited the midround antagonist living crew ratio to [ratio]% alive.") - check_antagonists() - - else if(href_list["toggle_noncontinuous_behavior"]) - if(!check_rights(R_ADMIN)) - return - - if(!SSticker.mode.round_ends_with_antag_death) - SSticker.mode.round_ends_with_antag_death = 1 - else - SSticker.mode.round_ends_with_antag_death = 0 - - message_admins("[key_name_admin(usr)] edited the midround antagonist system to [SSticker.mode.round_ends_with_antag_death ? "end the round" : "continue as extended"] upon failure.") - check_antagonists() - - else if(href_list["delay_round_end"]) - if(!check_rights(R_SERVER)) - return - if(!SSticker.delay_end) - SSticker.admin_delay_notice = input(usr, "Enter a reason for delaying the round end", "Round Delay Reason") as null|text - if(isnull(SSticker.admin_delay_notice)) - return - else - SSticker.admin_delay_notice = null - SSticker.delay_end = !SSticker.delay_end - var/reason = SSticker.delay_end ? "for reason: [SSticker.admin_delay_notice]" : "."//laziness - var/msg = "[SSticker.delay_end ? "delayed" : "undelayed"] the round end [reason]" - log_admin("[key_name(usr)] [msg]") - message_admins("[key_name_admin(usr)] [msg]") - href_list["secrets"] = "check_antagonist" - if(SSticker.ready_for_reboot && !SSticker.delay_end) //we undelayed after standard reboot would occur - SSticker.standard_reboot() - - else if(href_list["end_round"]) - if(!check_rights(R_ADMIN)) - return - - message_admins("[key_name_admin(usr)] is considering ending the round.") - if(alert(usr, "This will end the round, are you SURE you want to do this?", "Confirmation", "Yes", "No") == "Yes") - if(alert(usr, "Final Confirmation: End the round NOW?", "Confirmation", "Yes", "No") == "Yes") - message_admins("[key_name_admin(usr)] has ended the round.") - SSticker.force_ending = 1 //Yeah there we go APC destroyed mission accomplished - return - else - message_admins("[key_name_admin(usr)] decided against ending the round.") - else - message_admins("[key_name_admin(usr)] decided against ending the round.") - - else if(href_list["simplemake"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/M = locate(href_list["mob"]) - if(!ismob(M)) - to_chat(usr, "This can only be used on instances of type /mob.") - return - - var/delmob = 0 - switch(alert("Delete old mob?","Message","Yes","No","Cancel")) - if("Cancel") - return - if("Yes") - delmob = 1 - - log_admin("[key_name(usr)] has used rudimentary transformation on [key_name(M)]. Transforming to [href_list["simplemake"]].; deletemob=[delmob]") - message_admins("[key_name_admin(usr)] has used rudimentary transformation on [key_name_admin(M)]. Transforming to [href_list["simplemake"]].; deletemob=[delmob]") - switch(href_list["simplemake"]) - if("observer") - M.change_mob_type( /mob/dead/observer , null, null, delmob ) - if("drone") - M.change_mob_type( /mob/living/carbon/alien/humanoid/drone , null, null, delmob ) - if("hunter") - M.change_mob_type( /mob/living/carbon/alien/humanoid/hunter , null, null, delmob ) - if("queen") - M.change_mob_type( /mob/living/carbon/alien/humanoid/royal/queen , null, null, delmob ) - if("praetorian") - M.change_mob_type( /mob/living/carbon/alien/humanoid/royal/praetorian , null, null, delmob ) - if("sentinel") - M.change_mob_type( /mob/living/carbon/alien/humanoid/sentinel , null, null, delmob ) - if("larva") - M.change_mob_type( /mob/living/carbon/alien/larva , null, null, delmob ) - if("human") - var/posttransformoutfit = usr.client.robust_dress_shop() - var/mob/living/carbon/human/newmob = M.change_mob_type( /mob/living/carbon/human , null, null, delmob ) - if(posttransformoutfit && istype(newmob)) - newmob.equipOutfit(posttransformoutfit) - if("slime") - M.change_mob_type( /mob/living/simple_animal/slime , null, null, delmob ) - if("monkey") - M.change_mob_type( /mob/living/carbon/monkey , null, null, delmob ) - if("robot") - M.change_mob_type( /mob/living/silicon/robot , null, null, delmob ) - if("cat") - M.change_mob_type( /mob/living/simple_animal/pet/cat , null, null, delmob ) - if("runtime") - M.change_mob_type( /mob/living/simple_animal/pet/cat/Runtime , null, null, delmob ) - if("corgi") - M.change_mob_type( /mob/living/simple_animal/pet/dog/corgi , null, null, delmob ) - if("ian") - M.change_mob_type( /mob/living/simple_animal/pet/dog/corgi/Ian , null, null, delmob ) - if("pug") - M.change_mob_type( /mob/living/simple_animal/pet/dog/pug , null, null, delmob ) - if("crab") - M.change_mob_type( /mob/living/simple_animal/crab , null, null, delmob ) - if("coffee") - M.change_mob_type( /mob/living/simple_animal/crab/Coffee , null, null, delmob ) - if("parrot") - M.change_mob_type( /mob/living/simple_animal/parrot , null, null, delmob ) - if("polyparrot") - M.change_mob_type( /mob/living/simple_animal/parrot/Poly , null, null, delmob ) - if("constructarmored") - M.change_mob_type( /mob/living/simple_animal/hostile/construct/armored , null, null, delmob ) - if("constructbuilder") - M.change_mob_type( /mob/living/simple_animal/hostile/construct/builder , null, null, delmob ) - if("constructwraith") - M.change_mob_type( /mob/living/simple_animal/hostile/construct/wraith , null, null, delmob ) - if("shade") - M.change_mob_type( /mob/living/simple_animal/shade , null, null, delmob ) - - - /////////////////////////////////////new ban stuff - else if(href_list["unbanf"]) - if(!check_rights(R_BAN)) - return - - var/banfolder = href_list["unbanf"] - GLOB.Banlist.cd = "/base/[banfolder]" - var/key = GLOB.Banlist["key"] - if(alert(usr, "Are you sure you want to unban [key]?", "Confirmation", "Yes", "No") == "Yes") - if(RemoveBan(banfolder)) - unbanpanel() - else - alert(usr, "This ban has already been lifted / does not exist.", "Error", "Ok") - unbanpanel() - - else if(href_list["unbane"]) - if(!check_rights(R_BAN)) - return - - UpdateTime() - var/reason - - var/banfolder = href_list["unbane"] - GLOB.Banlist.cd = "/base/[banfolder]" - var/reason2 = GLOB.Banlist["reason"] - var/temp = GLOB.Banlist["temp"] - - var/minutes = GLOB.Banlist["minutes"] - - var/banned_key = GLOB.Banlist["key"] - GLOB.Banlist.cd = "/base" - - var/duration - - switch(alert("Temporary Ban for [banned_key]?",,"Yes","No")) - if("Yes") - temp = 1 - var/mins = 0 - if(minutes > GLOB.CMinutes) - mins = minutes - GLOB.CMinutes - mins = input(usr,"How long (in minutes)? (Default: 1440)","Ban time",mins ? mins : 1440) as num|null - if(mins <= 0) - to_chat(usr, "[mins] is not a valid duration.") - return - minutes = GLOB.CMinutes + mins - duration = GetExp(minutes) - reason = input(usr,"Please State Reason For Banning [banned_key].","Reason",reason2) as message|null - if(!reason) - return - if("No") - temp = 0 - duration = "Perma" - reason = input(usr,"Please State Reason For Banning [banned_key].","Reason",reason2) as message|null - if(!reason) - return - - log_admin_private("[key_name(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]") - ban_unban_log_save("[key_name(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]") - message_admins("[key_name_admin(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]") - GLOB.Banlist.cd = "/base/[banfolder]" - WRITE_FILE(GLOB.Banlist["reason"], reason) - WRITE_FILE(GLOB.Banlist["temp"], temp) - WRITE_FILE(GLOB.Banlist["minutes"], minutes) - WRITE_FILE(GLOB.Banlist["bannedby"], usr.ckey) - GLOB.Banlist.cd = "/base" - unbanpanel() - - /////////////////////////////////////new ban stuff - - else if(href_list["appearanceban"]) - if(!check_rights(R_BAN)) - return - var/mob/M = locate(href_list["appearanceban"]) - if(!ismob(M)) - to_chat(usr, "This can only be used on instances of type /mob") - return - if(!M.ckey) //sanity - to_chat(usr, "This mob has no ckey") - return - - - if(jobban_isbanned(M, "appearance")) - switch(alert("Remove appearance ban?","Please Confirm","Yes","No")) - if("Yes") - ban_unban_log_save("[key_name(usr)] removed [key_name(M)]'s appearance ban.") - log_admin_private("[key_name(usr)] removed [key_name(M)]'s appearance ban.") - DB_ban_unban(M.ckey, BANTYPE_ANY_JOB, "appearance") - if(M.client) - jobban_buildcache(M.client) - message_admins("[key_name_admin(usr)] removed [key_name_admin(M)]'s appearance ban.") - to_chat(M, "[usr.client.key] has removed your appearance ban.") - - else switch(alert("Appearance ban [M.key]?",,"Yes","No", "Cancel")) - if("Yes") - var/reason = input(usr,"Please State Reason.","Reason") as message|null - if(!reason) - return - var/severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None") - if(!severity) - return - if(!DB_ban_record(BANTYPE_JOB_PERMA, M, -1, reason, "appearance")) - to_chat(usr, "Failed to apply ban.") - return - if(M.client) - jobban_buildcache(M.client) - ban_unban_log_save("[key_name(usr)] appearance banned [key_name(M)]. reason: [reason]") - log_admin_private("[key_name(usr)] appearance banned [key_name(M)]. \nReason: [reason]") - create_message("note", M.key, null, "Appearance banned - [reason]", null, null, 0, 0, null, 0, severity) - message_admins("[key_name_admin(usr)] appearance banned [key_name_admin(M)].") - to_chat(M, "You have been appearance banned by [usr.client.key].") - to_chat(M, "The reason is: [reason]") - to_chat(M, "Appearance ban can be lifted only upon request.") - var/bran = CONFIG_GET(string/banappeals) - if(bran) - to_chat(M, "To try to resolve this matter head to [bran]") - else - to_chat(M, "No ban appeals URL has been set.") - if("No") - return - - else if(href_list["jobban2"]) - if(!check_rights(R_BAN)) - return - var/mob/M = locate(href_list["jobban2"]) - if(!ismob(M)) - to_chat(usr, "This can only be used on instances of type /mob.") - return - - if(!M.ckey) //sanity - to_chat(usr, "This mob has no ckey.") - return - - var/dat = "Job-Ban Panel: [key_name(M)]" - - /***********************************WARNING!************************************ - The jobban stuff looks mangled and disgusting - But it looks beautiful in-game - -Nodrak - ************************************WARNING!***********************************/ - var/counter = 0 -//Regular jobs - //Command (Blue) - dat += "" - dat += "" - for(var/jobPos in GLOB.command_positions) - if(!jobPos) - continue - if(jobban_isbanned(M, jobPos)) - dat += "" - counter++ - else - dat += "" - counter++ - - if(counter >= 6) //So things dont get squiiiiished! - dat += "" - counter = 0 - dat += "
    Command Positions
    [jobPos][jobPos]
    " - - //Security (Red) - counter = 0 - dat += "" - dat += "" - for(var/jobPos in GLOB.security_positions) - if(!jobPos) - continue - if(jobban_isbanned(M, jobPos)) - dat += "" - counter++ - else - dat += "" - counter++ - - if(counter >= 5) //So things dont get squiiiiished! - dat += "" - counter = 0 - dat += "
    Security Positions
    [jobPos][jobPos]
    " - - //Engineering (Yellow) - counter = 0 - dat += "" - dat += "" - for(var/jobPos in GLOB.engineering_positions) - if(!jobPos) - continue - if(jobban_isbanned(M, jobPos)) - dat += "" - counter++ - else - dat += "" - counter++ - - if(counter >= 5) //So things dont get squiiiiished! - dat += "" - counter = 0 - dat += "
    Engineering Positions
    [jobPos][jobPos]
    " - - //Medical (White) - counter = 0 - dat += "" - dat += "" - for(var/jobPos in GLOB.medical_positions) - if(!jobPos) - continue - if(jobban_isbanned(M, jobPos)) - dat += "" - counter++ - else - dat += "" - counter++ - - if(counter >= 5) //So things dont get squiiiiished! - dat += "" - counter = 0 - dat += "
    Medical Positions
    [jobPos][jobPos]
    " - - //Science (Purple) - counter = 0 - dat += "" - dat += "" - for(var/jobPos in GLOB.science_positions) - if(!jobPos) - continue - if(jobban_isbanned(M, jobPos)) - dat += "" - counter++ - else - dat += "" - counter++ - - if(counter >= 5) //So things dont get squiiiiished! - dat += "" - counter = 0 - dat += "
    Science Positions
    [jobPos][jobPos]
    " - - //Supply (Brown) - counter = 0 - dat += "" - dat += "" - for(var/jobPos in GLOB.supply_positions) - if(!jobPos) - continue - if(jobban_isbanned(M, jobPos)) - dat += "" - counter++ - else - dat += "" - counter++ - - if(counter >= 5) //So things dont get COPYPASTE! - dat += "" - counter = 0 - dat += "
    Supply Positions
    [jobPos][jobPos]
    " - - //Civilian (Grey) - counter = 0 - dat += "" - dat += "" - for(var/jobPos in GLOB.civilian_positions) - if(!jobPos) - continue - if(jobban_isbanned(M, jobPos)) - dat += "" - counter++ - else - dat += "" - counter++ - - if(counter >= 5) //So things dont get squiiiiished! - dat += "" - counter = 0 - dat += "
    Civilian Positions
    [jobPos][jobPos]
    " - - //Non-Human (Green) - counter = 0 - dat += "" - dat += "" - for(var/jobPos in GLOB.nonhuman_positions) - if(!jobPos) - continue - if(jobban_isbanned(M, jobPos)) - dat += "" - counter++ - else - dat += "" - counter++ - - if(counter >= 5) //So things dont get squiiiiished! - dat += "" - counter = 0 - - dat += "
    Non-human Positions
    [jobPos][jobPos]
    " - - //Ghost Roles (light light gray) - dat += "" - dat += "" - - //pAI - if(jobban_isbanned(M, ROLE_PAI)) - dat += "" - else - dat += "" - - - //Drones - if(jobban_isbanned(M, ROLE_DRONE)) - dat += "" - else - dat += "" - - - //Positronic Brains - if(jobban_isbanned(M, ROLE_POSIBRAIN)) - dat += "" - else - dat += "" - - //Sentience Potion Spawn - if(jobban_isbanned(M, ROLE_SENTIENCE)) - dat += "" - else - dat += "" - - //Deathsquad - if(jobban_isbanned(M, ROLE_DEATHSQUAD)) - dat += "" - else - dat += "" - - //Lavaland roles - if(jobban_isbanned(M, ROLE_LAVALAND)) - dat += "" - else - dat += "" - - dat += "
    Ghost Roles
    pAIpAIDroneDronePosibrainPosibrainSentience Potion SpawnSentience Potion SpawnDeathsquadDeathsquadLavalandLavaland
    " - - //Antagonist (Orange) - var/isbanned_dept = jobban_isbanned(M, ROLE_SYNDICATE) - dat += "" - dat += "" - - //Traitor - if(jobban_isbanned(M, ROLE_TRAITOR) || isbanned_dept) - dat += "" - else - dat += "" - - //Changeling - if(jobban_isbanned(M, ROLE_CHANGELING) || isbanned_dept) - dat += "" - else - dat += "" - - //Nuke Operative - if(jobban_isbanned(M, ROLE_OPERATIVE) || isbanned_dept) - dat += "" - else - dat += "" - - //Revolutionary - if(jobban_isbanned(M, ROLE_REV) || isbanned_dept) - dat += "" - else - dat += "" - - //Cultist - if(jobban_isbanned(M, ROLE_CULTIST) || isbanned_dept) - dat += "" - else - dat += "" - - dat += "" //So things dont get squished. - - //Servant of Ratvar - if(jobban_isbanned(M, ROLE_SERVANT_OF_RATVAR) || isbanned_dept) - dat += "" - else - dat += "" - - //Wizard - if(jobban_isbanned(M, ROLE_WIZARD) || isbanned_dept) - dat += "" - else - dat += "" - - //Abductor - if(jobban_isbanned(M, ROLE_ABDUCTOR) || isbanned_dept) - dat += "" - else - dat += "" - - //Alien - if(jobban_isbanned(M, ROLE_ALIEN) || isbanned_dept) - dat += "" - else - dat += "" - - //Gang - if(jobban_isbanned(M, ROLE_GANG) || isbanned_dept) - dat += "" - else - dat += "" - - - //Other Roles (black) - dat += "
    Antagonist Positions | " - dat += "Team Antagonists | " - dat += "Conversion Antagonists
    TraitorTraitorChangelingChangelingNuke OperativeNuke OperativeRevolutionaryRevolutionaryCultistCultist
    ServantServantWizardWizardAbductorAbductorAlienAlienGangGang
    " - dat += "" - - //Mind Transfer Potion - if(jobban_isbanned(M, ROLE_MIND_TRANSFER)) - dat += "" - else - dat += "" - - dat += "
    Other Roles
    Mind Transfer PotionMind Transfer Potion
    " - usr << browse(dat, "window=jobban2;size=800x450") - return - - //JOBBAN'S INNARDS - else if(href_list["jobban3"]) - if(!check_rights(R_BAN)) - return - var/mob/M = locate(href_list["jobban4"]) - if(!ismob(M)) - to_chat(usr, "This can only be used on instances of type /mob") - return - if(!SSjob) - to_chat(usr, "Jobs subsystem not initialized yet!") - return - //get jobs for department if specified, otherwise just return the one job in a list. - var/list/joblist = list() - switch(href_list["jobban3"]) - if("commanddept") - for(var/jobPos in GLOB.command_positions) - if(!jobPos) - continue - joblist += jobPos - if("securitydept") - for(var/jobPos in GLOB.security_positions) - if(!jobPos) - continue - joblist += jobPos - if("engineeringdept") - for(var/jobPos in GLOB.engineering_positions) - if(!jobPos) - continue - joblist += jobPos - if("medicaldept") - for(var/jobPos in GLOB.medical_positions) - if(!jobPos) - continue - joblist += jobPos - if("sciencedept") - for(var/jobPos in GLOB.science_positions) - if(!jobPos) - continue - joblist += jobPos - if("supplydept") - for(var/jobPos in GLOB.supply_positions) - if(!jobPos) - continue - joblist += jobPos - if("civiliandept") - for(var/jobPos in GLOB.civilian_positions) - if(!jobPos) - continue - joblist += jobPos - if("nonhumandept") - for(var/jobPos in GLOB.nonhuman_positions) - if(!jobPos) - continue - joblist += jobPos - if("ghostroles") - joblist += list(ROLE_PAI, ROLE_POSIBRAIN, ROLE_DRONE , ROLE_DEATHSQUAD, ROLE_LAVALAND, ROLE_SENTIENCE) - if("teamantags") - joblist += list(ROLE_OPERATIVE, ROLE_REV, ROLE_CULTIST, ROLE_SERVANT_OF_RATVAR, ROLE_ABDUCTOR, ROLE_ALIEN, ROLE_GANG) - if("convertantags") - joblist += list(ROLE_REV, ROLE_CULTIST, ROLE_SERVANT_OF_RATVAR, ROLE_ALIEN) - if("otherroles") - joblist += list(ROLE_MIND_TRANSFER) - else - joblist += href_list["jobban3"] - - //Create a list of unbanned jobs within joblist - var/list/notbannedlist = list() - for(var/job in joblist) - if(!jobban_isbanned(M, job)) - notbannedlist += job - - //Banning comes first - if(notbannedlist.len) //at least 1 unbanned job exists in joblist so we have stuff to ban. - var/severity = null - switch(alert("Temporary Ban for [M.key]?",,"Yes","No", "Cancel")) - if("Yes") - var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null - if(mins <= 0) - to_chat(usr, "[mins] is not a valid duration.") - return - var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null - if(!reason) - return - severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None") - if(!severity) - return - var/msg - for(var/job in notbannedlist) - if(!DB_ban_record(BANTYPE_JOB_TEMP, M, mins, reason, job)) - to_chat(usr, "Failed to apply ban.") - return - if(M.client) - jobban_buildcache(M.client) - ban_unban_log_save("[key_name(usr)] temp-jobbanned [key_name(M)] from [job] for [mins] minutes. reason: [reason]") - log_admin_private("[key_name(usr)] temp-jobbanned [key_name(M)] from [job] for [mins] minutes.") - if(!msg) - msg = job - else - msg += ", [job]" - create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0, severity) - message_admins("[key_name_admin(usr)] banned [key_name_admin(M)] from [msg] for [mins] minutes.") - to_chat(M, "You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg].") - to_chat(M, "The reason is: [reason]") - to_chat(M, "This jobban will be lifted in [mins] minutes.") - href_list["jobban2"] = 1 // lets it fall through and refresh - return 1 - if("No") - var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null - severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None") - if(!severity) - return - if(reason) - var/msg - for(var/job in notbannedlist) - if(!DB_ban_record(BANTYPE_JOB_PERMA, M, -1, reason, job)) - to_chat(usr, "Failed to apply ban.") - return - if(M.client) - jobban_buildcache(M.client) - ban_unban_log_save("[key_name(usr)] perma-jobbanned [key_name(M)] from [job]. reason: [reason]") - log_admin_private("[key_name(usr)] perma-banned [key_name(M)] from [job]") - if(!msg) - msg = job - else - msg += ", [job]" - create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0, severity) - message_admins("[key_name_admin(usr)] banned [key_name_admin(M)] from [msg].") - to_chat(M, "You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg].") - to_chat(M, "The reason is: [reason]") - to_chat(M, "Jobban can be lifted only upon request.") - href_list["jobban2"] = 1 // lets it fall through and refresh - return 1 - if("Cancel") - return - - //Unbanning joblist - //all jobs in joblist are banned already OR we didn't give a reason (implying they shouldn't be banned) - if(joblist.len) //at least 1 banned job exists in joblist so we have stuff to unban. - var/msg - for(var/job in joblist) - var/reason = jobban_isbanned(M, job) - if(!reason) - continue //skip if it isn't jobbanned anyway - switch(alert("Job: '[job]' Reason: '[reason]' Un-jobban?","Please Confirm","Yes","No")) - if("Yes") - ban_unban_log_save("[key_name(usr)] unjobbanned [key_name(M)] from [job]") - log_admin_private("[key_name(usr)] unbanned [key_name(M)] from [job]") - DB_ban_unban(M.ckey, BANTYPE_ANY_JOB, job) - if(M.client) - jobban_buildcache(M.client) - if(!msg) - msg = job - else - msg += ", [job]" - else - continue - if(msg) - message_admins("[key_name_admin(usr)] unbanned [key_name_admin(M)] from [msg].") - to_chat(M, "You have been un-jobbanned by [usr.client.key] from [msg].") - href_list["jobban2"] = 1 // lets it fall through and refresh - return 1 - return 0 //we didn't do anything! - - else if(href_list["boot2"]) - if(!check_rights(R_ADMIN)) - return - var/mob/M = locate(href_list["boot2"]) - if(ismob(M)) - if(!check_if_greater_rights_than(M.client)) - to_chat(usr, "Error: They have more rights than you do.") - return - if(alert(usr, "Kick [key_name(M)]?", "Confirm", "Yes", "No") != "Yes") - return - if(!M) - to_chat(usr, "Error: [M] no longer exists!") - return - if(!M.client) - to_chat(usr, "Error: [M] no longer has a client!") - return - to_chat(M, "You have been kicked from the server by [usr.client.holder.fakekey ? "an Administrator" : "[usr.client.key]"].") - log_admin("[key_name(usr)] kicked [key_name(M)].") - message_admins("[key_name_admin(usr)] kicked [key_name_admin(M)].") - qdel(M.client) - - else if(href_list["addmessage"]) - if(!check_rights(R_ADMIN)) - return - var/target_key = href_list["addmessage"] - create_message("message", target_key, secret = 0) - - else if(href_list["addnote"]) - if(!check_rights(R_ADMIN)) - return - var/target_key = href_list["addnote"] - create_message("note", target_key) - - else if(href_list["addwatch"]) - if(!check_rights(R_ADMIN)) - return - var/target_key = href_list["addwatch"] - create_message("watchlist entry", target_key, secret = 1) - - else if(href_list["addmemo"]) - if(!check_rights(R_ADMIN)) - return - create_message("memo", secret = 0, browse = 1) - - else if(href_list["addmessageempty"]) - if(!check_rights(R_ADMIN)) - return - create_message("message", secret = 0) - - else if(href_list["addnoteempty"]) - if(!check_rights(R_ADMIN)) - return - create_message("note") - - else if(href_list["addwatchempty"]) - if(!check_rights(R_ADMIN)) - return - create_message("watchlist entry", secret = 1) - - else if(href_list["deletemessage"]) - if(!check_rights(R_ADMIN)) - return - var/safety = alert("Delete message/note?",,"Yes","No"); - if (safety == "Yes") - var/message_id = href_list["deletemessage"] - delete_message(message_id) - - else if(href_list["deletemessageempty"]) - if(!check_rights(R_ADMIN)) - return - var/safety = alert("Delete message/note?",,"Yes","No"); - if (safety == "Yes") - var/message_id = href_list["deletemessageempty"] - delete_message(message_id, browse = TRUE) - - else if(href_list["editmessage"]) - if(!check_rights(R_ADMIN)) - return - var/message_id = href_list["editmessage"] - edit_message(message_id) - - else if(href_list["editmessageempty"]) - if(!check_rights(R_ADMIN)) - return - var/message_id = href_list["editmessageempty"] - edit_message(message_id, browse = 1) - - else if(href_list["editmessageexpiry"]) - if(!check_rights(R_ADMIN)) - return - var/message_id = href_list["editmessageexpiry"] - edit_message_expiry(message_id) - - else if(href_list["editmessageexpiryempty"]) - if(!check_rights(R_ADMIN)) - return - var/message_id = href_list["editmessageexpiryempty"] - edit_message_expiry(message_id, browse = 1) - - else if(href_list["editmessageseverity"]) - if(!check_rights(R_ADMIN)) - return - var/message_id = href_list["editmessageseverity"] - edit_message_severity(message_id) - - else if(href_list["secretmessage"]) - if(!check_rights(R_ADMIN)) - return - var/message_id = href_list["secretmessage"] - toggle_message_secrecy(message_id) - - else if(href_list["searchmessages"]) - if(!check_rights(R_ADMIN)) - return - var/target = href_list["searchmessages"] - browse_messages(index = target) - - else if(href_list["nonalpha"]) - if(!check_rights(R_ADMIN)) - return - var/target = href_list["nonalpha"] - target = text2num(target) - browse_messages(index = target) - - else if(href_list["showmessages"]) - if(!check_rights(R_ADMIN)) - return - var/target = href_list["showmessages"] - browse_messages(index = target) - - else if(href_list["showmemo"]) - if(!check_rights(R_ADMIN)) - return - browse_messages("memo") - - else if(href_list["showwatch"]) - if(!check_rights(R_ADMIN)) - return - browse_messages("watchlist entry") - - else if(href_list["showwatchfilter"]) - if(!check_rights(R_ADMIN)) - return - browse_messages("watchlist entry", filter = 1) - - else if(href_list["showmessageckey"]) - if(!check_rights(R_ADMIN)) - return - var/target = href_list["showmessageckey"] - var/agegate = TRUE - if (href_list["showall"]) - agegate = FALSE - browse_messages(target_ckey = target, agegate = agegate) - - else if(href_list["showmessageckeylinkless"]) - var/target = href_list["showmessageckeylinkless"] - browse_messages(target_ckey = target, linkless = 1) - - else if(href_list["messageedits"]) - if(!check_rights(R_ADMIN)) - return - var/message_id = sanitizeSQL("[href_list["messageedits"]]") - var/datum/DBQuery/query_get_message_edits = SSdbcore.NewQuery("SELECT edits FROM [format_table_name("messages")] WHERE id = '[message_id]'") - if(!query_get_message_edits.warn_execute()) - qdel(query_get_message_edits) - return - if(query_get_message_edits.NextRow()) - var/edit_log = query_get_message_edits.item[1] - if(!QDELETED(usr)) - var/datum/browser/browser = new(usr, "Note edits", "Note edits") - browser.set_content(jointext(edit_log, "")) - browser.open() - qdel(query_get_message_edits) - - else if(href_list["newban"]) - if(!check_rights(R_BAN)) - return - - var/mob/M = locate(href_list["newban"]) - if(!ismob(M)) - return - - if(M.client && M.client.holder) - return //admins cannot be banned. Even if they could, the ban doesn't affect them anyway - - switch(alert("Temporary Ban for [M.key]?",,"Yes","No", "Cancel")) - if("Yes") - var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null - if(mins <= 0) - to_chat(usr, "[mins] is not a valid duration.") - return - var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null - if(!reason) - return - if(!DB_ban_record(BANTYPE_TEMP, M, mins, reason)) - to_chat(usr, "Failed to apply ban.") - return - AddBan(M.ckey, M.computer_id, reason, usr.ckey, 1, mins) - ban_unban_log_save("[key_name(usr)] has banned [key_name(M)]. - Reason: [reason] - This will be removed in [mins] minutes.") - to_chat(M, "You have been banned by [usr.client.key].\nReason: [reason]") - to_chat(M, "This is a temporary ban, it will be removed in [mins] minutes. The round ID is [GLOB.round_id].") - var/bran = CONFIG_GET(string/banappeals) - if(bran) - to_chat(M, "To try to resolve this matter head to [bran]") - else - to_chat(M, "No ban appeals URL has been set.") - log_admin_private("[key_name(usr)] has banned [key_name(M)].\nReason: [key_name(M)]\nThis will be removed in [mins] minutes.") - var/msg = "[key_name_admin(usr)] has banned [key_name_admin(M)].\nReason: [reason]\nThis will be removed in [mins] minutes." - message_admins(msg) - var/datum/admin_help/AH = M.client ? M.client.current_ticket : null - if(AH) - AH.Resolve() - qdel(M.client) - if("No") - var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null - if(!reason) - return - switch(alert(usr,"IP ban?",,"Yes","No","Cancel")) - if("Cancel") - return - if("Yes") - AddBan(M.ckey, M.computer_id, reason, usr.ckey, 0, 0, M.lastKnownIP) - if("No") - AddBan(M.ckey, M.computer_id, reason, usr.ckey, 0, 0) - to_chat(M, "You have been banned by [usr.client.key].\nReason: [reason]") - to_chat(M, "This is a permanent ban. The round ID is [GLOB.round_id].") - var/bran = CONFIG_GET(string/banappeals) - if(bran) - to_chat(M, "To try to resolve this matter head to [bran]") - else - to_chat(M, "No ban appeals URL has been set.") - if(!DB_ban_record(BANTYPE_PERMA, M, -1, reason)) - to_chat(usr, "Failed to apply ban.") - return - ban_unban_log_save("[key_name(usr)] has permabanned [key_name(M)]. - Reason: [reason] - This is a permanent ban.") - log_admin_private("[key_name(usr)] has banned [key_name(M)].\nReason: [reason]\nThis is a permanent ban.") - var/msg = "[key_name_admin(usr)] has banned [key_name_admin(M)].\nReason: [reason]\nThis is a permanent ban." - message_admins(msg) - var/datum/admin_help/AH = M.client ? M.client.current_ticket : null - if(AH) - AH.Resolve() - qdel(M.client) - if("Cancel") - return - - else if(href_list["mute"]) - if(!check_rights(R_ADMIN)) - return - cmd_admin_mute(href_list["mute"], text2num(href_list["mute_type"])) - - else if(href_list["c_mode"]) - return HandleCMode() - - else if(href_list["f_secret"]) - return HandleFSecret() - -//Dynamic mode - else if(href_list["f_dynamic_roundstart"]) - if(!check_rights(R_ADMIN)) - return - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode.", null, null, null, null) - var/roundstart_rules = list() - for (var/rule in subtypesof(/datum/dynamic_ruleset/roundstart)) - var/datum/dynamic_ruleset/roundstart/newrule = new rule() - roundstart_rules[newrule.name] = newrule - var/added_rule = input(usr,"What ruleset do you want to force? This will bypass threat level and population restrictions.", "Rigging Roundstart", null) as null|anything in roundstart_rules - if (added_rule) - GLOB.dynamic_forced_roundstart_ruleset += roundstart_rules[added_rule] - log_admin("[key_name(usr)] set [added_rule] to be a forced roundstart ruleset.") - message_admins("[key_name(usr)] set [added_rule] to be a forced roundstart ruleset.", 1) - Game() - - else if(href_list["f_dynamic_roundstart_clear"]) - if(!check_rights(R_ADMIN)) - return - GLOB.dynamic_forced_roundstart_ruleset = list() - Game() - log_admin("[key_name(usr)] cleared the rigged roundstart rulesets. The mode will pick them as normal.") - message_admins("[key_name(usr)] cleared the rigged roundstart rulesets. The mode will pick them as normal.", 1) - - else if(href_list["f_dynamic_roundstart_remove"]) - if(!check_rights(R_ADMIN)) - return - var/datum/dynamic_ruleset/roundstart/rule = locate(href_list["f_dynamic_roundstart_remove"]) - GLOB.dynamic_forced_roundstart_ruleset -= rule - Game() - log_admin("[key_name(usr)] removed [rule] from the forced roundstart rulesets.") - message_admins("[key_name(usr)] removed [rule] from the forced roundstart rulesets.", 1) - - else if(href_list["f_dynamic_latejoin"]) - if(!check_rights(R_ADMIN)) - return - if(!SSticker || !SSticker.mode) - return alert(usr, "The game must start first.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - var/latejoin_rules = list() - for (var/rule in subtypesof(/datum/dynamic_ruleset/latejoin)) - var/datum/dynamic_ruleset/latejoin/newrule = new rule() - latejoin_rules[newrule.name] = newrule - var/added_rule = input(usr,"What ruleset do you want to force upon the next latejoiner? This will bypass threat level and population restrictions.", "Rigging Latejoin", null) as null|anything in latejoin_rules - if (added_rule) - var/datum/game_mode/dynamic/mode = SSticker.mode - mode.forced_latejoin_rule = latejoin_rules[added_rule] - log_admin("[key_name(usr)] set [added_rule] to proc on the next latejoin.") - message_admins("[key_name(usr)] set [added_rule] to proc on the next latejoin.", 1) - Game() - - else if(href_list["f_dynamic_latejoin_clear"]) - if(!check_rights(R_ADMIN)) - return - if (SSticker && SSticker.mode && istype(SSticker.mode,/datum/game_mode/dynamic)) - var/datum/game_mode/dynamic/mode = SSticker.mode - mode.forced_latejoin_rule = null - Game() - log_admin("[key_name(usr)] cleared the forced latejoin ruleset.") - message_admins("[key_name(usr)] cleared the forced latejoin ruleset.", 1) - - else if(href_list["f_dynamic_midround"]) - if(!check_rights(R_ADMIN)) - return - if(!SSticker || !SSticker.mode) - return alert(usr, "The game must start first.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - var/midround_rules = list() - for (var/rule in subtypesof(/datum/dynamic_ruleset/midround)) - var/datum/dynamic_ruleset/midround/newrule = new rule() - midround_rules[newrule.name] = rule - var/added_rule = input(usr,"What ruleset do you want to force right now? This will bypass threat level and population restrictions.", "Execute Ruleset", null) as null|anything in midround_rules - if (added_rule) - var/datum/game_mode/dynamic/mode = SSticker.mode - log_admin("[key_name(usr)] executed the [added_rule] ruleset.") - message_admins("[key_name(usr)] executed the [added_rule] ruleset.", 1) - mode.picking_specific_rule(midround_rules[added_rule],1) - - else if (href_list["f_dynamic_options"]) - if(!check_rights(R_ADMIN)) - return - - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_roundstart_centre"]) - if(!check_rights(R_ADMIN)) - return - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - var/new_centre = input(usr,"Change the centre of the dynamic mode threat curve. A negative value will give a more peaceful round ; a positive value, a round with higher threat. Any number between -5 and +5 is allowed.", "Change curve centre", null) as num - if (new_centre < -5 || new_centre > 5) - return alert(usr, "Only values between -5 and +5 are allowed.", null, null, null, null) - - log_admin("[key_name(usr)] changed the distribution curve center to [new_centre].") - message_admins("[key_name(usr)] changed the distribution curve center to [new_centre]", 1) - GLOB.dynamic_curve_centre = new_centre - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_roundstart_width"]) - if(!check_rights(R_ADMIN)) - return - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - var/new_width = input(usr,"Change the width of the dynamic mode threat curve. A higher value will favour extreme rounds ; a lower value, a round closer to the average. Any Number between 0.5 and 4 are allowed.", "Change curve width", null) as num - if (new_width < 0.5 || new_width > 4) - return alert(usr, "Only values between 0.5 and +2.5 are allowed.", null, null, null, null) - - log_admin("[key_name(usr)] changed the distribution curve width to [new_width].") - message_admins("[key_name(usr)] changed the distribution curve width to [new_width]", 1) - GLOB.dynamic_curve_width = new_width - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_roundstart_latejoin_min"]) - if(!check_rights(R_ADMIN)) - return - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - var/new_min = input(usr,"Change the minimum delay of latejoin injection in minutes.", "Change latejoin injection delay minimum", null) as num - if(new_min <= 0) - return alert(usr, "The minimum can't be zero or lower.", null, null, null, null) - if((new_min MINUTES) > GLOB.dynamic_latejoin_delay_max) - return alert(usr, "The minimum must be lower than the maximum.", null, null, null, null) - - log_admin("[key_name(usr)] changed the latejoin injection minimum delay to [new_min] minutes.") - message_admins("[key_name(usr)] changed the latejoin injection minimum delay to [new_min] minutes", 1) - GLOB.dynamic_latejoin_delay_min = (new_min MINUTES) - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_roundstart_latejoin_max"]) - if(!check_rights(R_ADMIN)) - return - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - var/new_max = input(usr,"Change the maximum delay of latejoin injection in minutes.", "Change latejoin injection delay maximum", null) as num - if(new_max <= 0) - return alert(usr, "The maximum can't be zero or lower.", null, null, null, null) - if((new_max MINUTES) < GLOB.dynamic_latejoin_delay_min) - return alert(usr, "The maximum must be higher than the minimum.", null, null, null, null) - - log_admin("[key_name(usr)] changed the latejoin injection maximum delay to [new_max] minutes.") - message_admins("[key_name(usr)] changed the latejoin injection maximum delay to [new_max] minutes", 1) - GLOB.dynamic_latejoin_delay_max = (new_max MINUTES) - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_roundstart_midround_min"]) - if(!check_rights(R_ADMIN)) - return - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - var/new_min = input(usr,"Change the minimum delay of midround injection in minutes.", "Change midround injection delay minimum", null) as num - if(new_min <= 0) - return alert(usr, "The minimum can't be zero or lower.", null, null, null, null) - if((new_min MINUTES) > GLOB.dynamic_midround_delay_max) - return alert(usr, "The minimum must be lower than the maximum.", null, null, null, null) - - log_admin("[key_name(usr)] changed the midround injection minimum delay to [new_min] minutes.") - message_admins("[key_name(usr)] changed the midround injection minimum delay to [new_min] minutes", 1) - GLOB.dynamic_midround_delay_min = (new_min MINUTES) - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_roundstart_midround_max"]) - if(!check_rights(R_ADMIN)) - return - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - var/new_max = input(usr,"Change the maximum delay of midround injection in minutes.", "Change midround injection delay maximum", null) as num - if(new_max <= 0) - return alert(usr, "The maximum can't be zero or lower.", null, null, null, null) - if((new_max MINUTES) > GLOB.dynamic_midround_delay_max) - return alert(usr, "The maximum must be higher than the minimum.", null, null, null, null) - - log_admin("[key_name(usr)] changed the midround injection maximum delay to [new_max] minutes.") - message_admins("[key_name(usr)] changed the midround injection maximum delay to [new_max] minutes", 1) - GLOB.dynamic_midround_delay_max = (new_max MINUTES) - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_force_extended"]) - if(!check_rights(R_ADMIN)) - return - - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - GLOB.dynamic_forced_extended = !GLOB.dynamic_forced_extended - log_admin("[key_name(usr)] set 'forced_extended' to [GLOB.dynamic_forced_extended].") - message_admins("[key_name(usr)] set 'forced_extended' to [GLOB.dynamic_forced_extended].") - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_no_stacking"]) - if(!check_rights(R_ADMIN)) - return - - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - GLOB.dynamic_no_stacking = !GLOB.dynamic_no_stacking - log_admin("[key_name(usr)] set 'no_stacking' to [GLOB.dynamic_no_stacking].") - message_admins("[key_name(usr)] set 'no_stacking' to [GLOB.dynamic_no_stacking].") - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_classic_secret"]) - if(!check_rights(R_ADMIN)) - return - - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - GLOB.dynamic_classic_secret = !GLOB.dynamic_classic_secret - log_admin("[key_name(usr)] set 'classic_secret' to [GLOB.dynamic_classic_secret].") - message_admins("[key_name(usr)] set 'classic_secret' to [GLOB.dynamic_classic_secret].") - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_stacking_limit"]) - if(!check_rights(R_ADMIN)) - return - - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - GLOB.dynamic_stacking_limit = input(usr,"Change the threat limit at which round-endings rulesets will start to stack.", "Change stacking limit", null) as num - log_admin("[key_name(usr)] set 'stacking_limit' to [GLOB.dynamic_stacking_limit].") - message_admins("[key_name(usr)] set 'stacking_limit' to [GLOB.dynamic_stacking_limit].") - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_high_pop_limit"]) - if(!check_rights(R_ADMIN)) - return - - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - var/new_value = input(usr, "Enter the high-pop override threshold for dynamic mode.", "High pop override") as num - if (new_value < 0) - return alert(usr, "Only positive values allowed!", null, null, null, null) - GLOB.dynamic_high_pop_limit = new_value - - log_admin("[key_name(usr)] set 'high_pop_limit' to [GLOB.dynamic_high_pop_limit].") - message_admins("[key_name(usr)] set 'high_pop_limit' to [GLOB.dynamic_high_pop_limit].") - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_forced_threat"]) - if(!check_rights(R_ADMIN)) - return - - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - var/new_value = input(usr, "Enter the forced threat level for dynamic mode.", "Forced threat level") as num - if (new_value > 100) - return alert(usr, "The value must be be under 100.", null, null, null, null) - GLOB.dynamic_forced_threat_level = new_value - - log_admin("[key_name(usr)] set 'forced_threat_level' to [GLOB.dynamic_forced_threat_level].") - message_admins("[key_name(usr)] set 'forced_threat_level' to [GLOB.dynamic_forced_threat_level].") - dynamic_mode_options(usr) - - else if(href_list["f_dynamic_chaos_level"]) - if(!check_rights(R_ADMIN)) - return - - if(SSticker && SSticker.mode) - return alert(usr, "The game has already started.", null, null, null, null) - - if(GLOB.master_mode != "dynamic") - return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) - - var/new_value = input(usr, "Enter the chaos level for dynamic mode.", "Chaos level") as num - if (new_value > 5 || new_value < 0) - return alert(usr, "The value must be between 0 and 5.", null, null, null, null) - GLOB.dynamic_chaos_level = new_value - - log_admin("[key_name(usr)] set 'dynamic_chaos_level' to [GLOB.dynamic_chaos_level].") - message_admins("[key_name(usr)] set 'dynamic_chaos_level' to [GLOB.dynamic_chaos_level].") - dynamic_mode_options(usr) -//End Dynamic mode - - else if(href_list["c_mode2"]) - if(!check_rights(R_ADMIN|R_SERVER)) - return - - if (SSticker.HasRoundStarted()) - return alert(usr, "The game has already started.", null, null, null, null) - GLOB.master_mode = href_list["c_mode2"] - log_admin("[key_name(usr)] set the mode as [GLOB.master_mode].") - message_admins("[key_name_admin(usr)] set the mode as [GLOB.master_mode].") - to_chat(world, "The mode is now: [GLOB.master_mode]") - Game() // updates the main game menu - SSticker.save_mode(GLOB.master_mode) - HandleCMode() - - else if(href_list["f_secret2"]) - if(!check_rights(R_ADMIN|R_SERVER)) - return - - if(SSticker.HasRoundStarted()) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "secret") - return alert(usr, "The game mode has to be secret!", null, null, null, null) - GLOB.secret_force_mode = href_list["f_secret2"] - log_admin("[key_name(usr)] set the forced secret mode as [GLOB.secret_force_mode].") - message_admins("[key_name_admin(usr)] set the forced secret mode as [GLOB.secret_force_mode].") - Game() // updates the main game menu - HandleFSecret() - - else if(href_list["monkeyone"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/living/carbon/human/H = locate(href_list["monkeyone"]) - if(!istype(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") - return - - log_admin("[key_name(usr)] attempting to monkeyize [key_name(H)].") - message_admins("[key_name_admin(usr)] attempting to monkeyize [key_name_admin(H)].") - H.monkeyize() - - else if(href_list["humanone"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/living/carbon/monkey/Mo = locate(href_list["humanone"]) - if(!istype(Mo)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/monkey.") - return - - log_admin("[key_name(usr)] attempting to humanize [key_name(Mo)].") - message_admins("[key_name_admin(usr)] attempting to humanize [key_name_admin(Mo)].") - Mo.humanize() - - else if(href_list["corgione"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/living/carbon/human/H = locate(href_list["corgione"]) - if(!istype(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") - return - - log_admin("[key_name(usr)] attempting to corgize [key_name(H)].") - message_admins("[key_name_admin(usr)] attempting to corgize [key_name_admin(H)].") - H.corgize() - - - else if(href_list["forcespeech"]) - if(!check_rights(R_FUN)) - return - - var/mob/M = locate(href_list["forcespeech"]) - if(!ismob(M)) - to_chat(usr, "this can only be used on instances of type /mob.") - - var/speech = input("What will [key_name(M)] say?", "Force speech", "")// Don't need to sanitize, since it does that in say(), we also trust our admins. - if(!speech) - return - M.say(speech, forced = "admin speech") - speech = sanitize(speech) // Nah, we don't trust them - log_admin("[key_name(usr)] forced [key_name(M)] to say: [speech]") - message_admins("[key_name_admin(usr)] forced [key_name_admin(M)] to say: [speech]") - - else if(href_list["makeeligible"]) - if(!check_rights(R_ADMIN)) - return - var/mob/M = locate(href_list["makeeligible"]) - if(!ismob(M)) - to_chat(usr, "this can only be used on instances of type /mob.") - if(M.ckey in GLOB.client_ghost_timeouts) - GLOB.client_ghost_timeouts -= M.ckey - - else if(href_list["sendtoprison"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["sendtoprison"]) - if(!ismob(M)) - to_chat(usr, "This can only be used on instances of type /mob.") - return - if(isAI(M)) - to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") - return - - if(alert(usr, "Send [key_name(M)] to Prison?", "Message", "Yes", "No") != "Yes") - return - - M.forceMove(pick(GLOB.prisonwarp)) - to_chat(M, "You have been sent to Prison!") - - log_admin("[key_name(usr)] has sent [key_name(M)] to Prison!") - message_admins("[key_name_admin(usr)] has sent [key_name_admin(M)] to Prison!") - - else if(href_list["sendbacktolobby"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["sendbacktolobby"]) - - if(!isobserver(M)) - to_chat(usr, "You can only send ghost players back to the Lobby.") - return - - if(!M.client) - to_chat(usr, "[M] doesn't seem to have an active client.") - return - - if(alert(usr, "Send [key_name(M)] back to Lobby?", "Message", "Yes", "No") != "Yes") - return - - log_admin("[key_name(usr)] has sent [key_name(M)] back to the Lobby.") - message_admins("[key_name(usr)] has sent [key_name(M)] back to the Lobby.") - - var/mob/dead/new_player/NP = new() - NP.ckey = M.ckey - qdel(M) - - else if(href_list["tdome1"]) - if(!check_rights(R_FUN)) - return - - if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") - return - - var/mob/M = locate(href_list["tdome1"]) - if(!isliving(M)) - to_chat(usr, "This can only be used on instances of type /mob/living.") - return - if(isAI(M)) - to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") - return - var/mob/living/L = M - - for(var/obj/item/I in L) - L.dropItemToGround(I, TRUE) - - L.Unconscious(100) - sleep(5) - L.forceMove(pick(GLOB.tdome1)) - spawn(50) - to_chat(L, "You have been sent to the Thunderdome.") - log_admin("[key_name(usr)] has sent [key_name(L)] to the thunderdome. (Team 1)") - message_admins("[key_name_admin(usr)] has sent [key_name_admin(L)] to the thunderdome. (Team 1)") - - else if(href_list["tdome2"]) - if(!check_rights(R_FUN)) - return - - if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") - return - - var/mob/M = locate(href_list["tdome2"]) - if(!isliving(M)) - to_chat(usr, "This can only be used on instances of type /mob/living.") - return - if(isAI(M)) - to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") - return - var/mob/living/L = M - - for(var/obj/item/I in L) - L.dropItemToGround(I, TRUE) - - L.Unconscious(100) - sleep(5) - L.forceMove(pick(GLOB.tdome2)) - spawn(50) - to_chat(L, "You have been sent to the Thunderdome.") - log_admin("[key_name(usr)] has sent [key_name(L)] to the thunderdome. (Team 2)") - message_admins("[key_name_admin(usr)] has sent [key_name_admin(L)] to the thunderdome. (Team 2)") - - else if(href_list["tdomeadmin"]) - if(!check_rights(R_FUN)) - return - - if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") - return - - var/mob/M = locate(href_list["tdomeadmin"]) - if(!isliving(M)) - to_chat(usr, "This can only be used on instances of type /mob/living.") - return - if(isAI(M)) - to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") - return - var/mob/living/L = M - - L.Unconscious(100) - sleep(5) - L.forceMove(pick(GLOB.tdomeadmin)) - spawn(50) - to_chat(L, "You have been sent to the Thunderdome.") - log_admin("[key_name(usr)] has sent [key_name(L)] to the thunderdome. (Admin.)") - message_admins("[key_name_admin(usr)] has sent [key_name_admin(L)] to the thunderdome. (Admin.)") - - else if(href_list["tdomeobserve"]) - if(!check_rights(R_FUN)) - return - - if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") - return - - var/mob/M = locate(href_list["tdomeobserve"]) - if(!isliving(M)) - to_chat(usr, "This can only be used on instances of type /mob/living.") - return - if(isAI(M)) - to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") - return - var/mob/living/L = M - - for(var/obj/item/I in L) - L.dropItemToGround(I, TRUE) - - if(ishuman(L)) - var/mob/living/carbon/human/observer = L - observer.equip_to_slot_or_del(new /obj/item/clothing/under/suit_jacket(observer), SLOT_W_UNIFORM) - observer.equip_to_slot_or_del(new /obj/item/clothing/shoes/sneakers/black(observer), SLOT_SHOES) - L.Unconscious(100) - sleep(5) - L.forceMove(pick(GLOB.tdomeobserve)) - spawn(50) - to_chat(L, "You have been sent to the Thunderdome.") - log_admin("[key_name(usr)] has sent [key_name(L)] to the thunderdome. (Observer.)") - message_admins("[key_name_admin(usr)] has sent [key_name_admin(L)] to the thunderdome. (Observer.)") - - else if(href_list["revive"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/living/L = locate(href_list["revive"]) - if(!istype(L)) - to_chat(usr, "This can only be used on instances of type /mob/living.") - return - - L.revive(full_heal = 1, admin_revive = 1) - message_admins("Admin [key_name_admin(usr)] healed / revived [key_name_admin(L)]!") - log_admin("[key_name(usr)] healed / Revived [key_name(L)].") - - else if(href_list["makeai"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/living/carbon/human/H = locate(href_list["makeai"]) - if(!istype(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") - return - - message_admins("Admin [key_name_admin(usr)] AIized [key_name_admin(H)]!") - log_admin("[key_name(usr)] AIized [key_name(H)].") - H.AIize() - - else if(href_list["makealien"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/living/carbon/human/H = locate(href_list["makealien"]) - if(!istype(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") - return - - usr.client.cmd_admin_alienize(H) - - else if(href_list["makeslime"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/living/carbon/human/H = locate(href_list["makeslime"]) - if(!istype(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") - return - - usr.client.cmd_admin_slimeize(H) - - else if(href_list["makeblob"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/living/carbon/human/H = locate(href_list["makeblob"]) - if(!istype(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") - return - - usr.client.cmd_admin_blobize(H) - - - else if(href_list["makerobot"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/living/carbon/human/H = locate(href_list["makerobot"]) - if(!istype(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") - return - - usr.client.cmd_admin_robotize(H) - - else if(href_list["makeanimal"]) - if(!check_rights(R_SPAWN)) - return - - var/mob/M = locate(href_list["makeanimal"]) - if(isnewplayer(M)) - to_chat(usr, "This cannot be used on instances of type /mob/dead/new_player.") - return - - usr.client.cmd_admin_animalize(M) - - else if(href_list["adminplayeropts"]) - var/mob/M = locate(href_list["adminplayeropts"]) - show_player_panel(M) - - else if(href_list["adminplayerobservefollow"]) - if(!isobserver(usr) && !check_rights(R_ADMIN)) - return - - var/atom/movable/AM = locate(href_list["adminplayerobservefollow"]) - - var/client/C = usr.client - if(!isobserver(usr)) - C.admin_ghost() - var/mob/dead/observer/A = C.mob - A.ManualFollow(AM) - - else if(href_list["admingetmovable"]) - if(!check_rights(R_ADMIN)) - return - - var/atom/movable/AM = locate(href_list["admingetmovable"]) - if(QDELETED(AM)) - return - AM.forceMove(get_turf(usr)) - - else if(href_list["adminplayerobservecoodjump"]) - if(!isobserver(usr) && !check_rights(R_ADMIN)) - return - - var/x = text2num(href_list["X"]) - var/y = text2num(href_list["Y"]) - var/z = text2num(href_list["Z"]) - - var/client/C = usr.client - if(!isobserver(usr)) - C.admin_ghost() - sleep(2) - C.jumptocoord(x,y,z) - - else if(href_list["adminchecklaws"]) - if(!check_rights(R_ADMIN)) - return - output_ai_laws() - - else if(href_list["admincheckdevilinfo"]) - if(!check_rights(R_ADMIN)) - return - var/mob/M = locate(href_list["admincheckdevilinfo"]) - output_devil_info(M) - - else if(href_list["adminmoreinfo"]) - var/mob/M = locate(href_list["adminmoreinfo"]) in GLOB.mob_list - if(!ismob(M)) - to_chat(usr, "This can only be used on instances of type /mob.") - return - - var/location_description = "" - var/special_role_description = "" - var/health_description = "" - var/gender_description = "" - var/turf/T = get_turf(M) - - //Location - if(isturf(T)) - if(isarea(T.loc)) - location_description = "([M.loc == T ? "at coordinates " : "in [M.loc] at coordinates "] [T.x], [T.y], [T.z] in area [T.loc])" - else - location_description = "([M.loc == T ? "at coordinates " : "in [M.loc] at coordinates "] [T.x], [T.y], [T.z])" - - //Job + antagonist - if(M.mind) - special_role_description = "Role: [M.mind.assigned_role]; Antagonist: [M.mind.special_role]" - else - special_role_description = "Role: Mind datum missing Antagonist: Mind datum missing" - - //Health - if(isliving(M)) - var/mob/living/L = M - var/status - switch (M.stat) - if(CONSCIOUS) - status = "Alive" - if(SOFT_CRIT) - status = "Dying" - if(UNCONSCIOUS) - status = "[L.InCritical() ? "Unconscious and Dying" : "Unconscious"]" - if(DEAD) - status = "Dead" - health_description = "Status = [status]" - health_description += "
    Oxy: [L.getOxyLoss()] - Tox: [L.getToxLoss()] - Fire: [L.getFireLoss()] - Brute: [L.getBruteLoss()] - Clone: [L.getCloneLoss()] - Brain: [L.getOrganLoss(ORGAN_SLOT_BRAIN)] - Stamina: [L.getStaminaLoss()]" - else - health_description = "This mob type has no health to speak of." - - //Gender - switch(M.gender) - if(MALE,FEMALE) - gender_description = "[M.gender]" - else - gender_description = "[M.gender]" - - to_chat(src.owner, "Info about [M.name]: ") - to_chat(src.owner, "Mob type = [M.type]; Gender = [gender_description] Damage = [health_description]") - to_chat(src.owner, "Name = [M.name]; Real_name = [M.real_name]; Mind_name = [M.mind?"[M.mind.name]":""]; Key = [M.key];") - to_chat(src.owner, "Location = [location_description];") - to_chat(src.owner, "[special_role_description]") - to_chat(src.owner, ADMIN_FULLMONTY_NONAME(M)) - - else if(href_list["addjobslot"]) - if(!check_rights(R_ADMIN)) - return - - var/Add = href_list["addjobslot"] - - for(var/datum/job/job in SSjob.occupations) - if(job.title == Add) - job.total_positions += 1 - break - - src.manage_free_slots() - - - else if(href_list["customjobslot"]) - if(!check_rights(R_ADMIN)) - return - - var/Add = href_list["customjobslot"] - - for(var/datum/job/job in SSjob.occupations) - if(job.title == Add) - var/newtime = null - newtime = input(usr, "How many jebs do you want?", "Add wanted posters", "[newtime]") as num|null - if(!newtime) - to_chat(src.owner, "Setting to amount of positions filled for the job") - job.total_positions = job.current_positions - break - job.total_positions = newtime - - src.manage_free_slots() - - else if(href_list["removejobslot"]) - if(!check_rights(R_ADMIN)) - return - - var/Remove = href_list["removejobslot"] - - for(var/datum/job/job in SSjob.occupations) - if(job.title == Remove && job.total_positions - job.current_positions > 0) - job.total_positions -= 1 - break - - src.manage_free_slots() - - else if(href_list["unlimitjobslot"]) - if(!check_rights(R_ADMIN)) - return - - var/Unlimit = href_list["unlimitjobslot"] - - for(var/datum/job/job in SSjob.occupations) - if(job.title == Unlimit) - job.total_positions = -1 - break - - src.manage_free_slots() - - else if(href_list["limitjobslot"]) - if(!check_rights(R_ADMIN)) - return - - var/Limit = href_list["limitjobslot"] - - for(var/datum/job/job in SSjob.occupations) - if(job.title == Limit) - job.total_positions = job.current_positions - break - - src.manage_free_slots() - - - else if(href_list["adminspawncookie"]) - if(!check_rights(R_ADMIN|R_FUN)) - return - - var/mob/living/carbon/human/H = locate(href_list["adminspawncookie"]) - if(!ishuman(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") - return - - var/obj/item/reagent_containers/food/snacks/cookie/cookie = new(H) - if(H.put_in_hands(cookie)) - H.update_inv_hands() - else - qdel(cookie) - log_admin("[key_name(H)] has their hands full, so they did not receive their cookie, spawned by [key_name(src.owner)].") - message_admins("[key_name(H)] has their hands full, so they did not receive their cookie, spawned by [key_name(src.owner)].") - return - - log_admin("[key_name(H)] got their cookie, spawned by [key_name(src.owner)].") - message_admins("[key_name(H)] got their cookie, spawned by [key_name(src.owner)].") - SSblackbox.record_feedback("amount", "admin_cookies_spawned", 1) - to_chat(H, "Your prayers have been answered!! You received the best cookie!") - SEND_SOUND(H, sound('sound/effects/pray_chaplain.ogg')) - - else if(href_list["adminsmite"]) - if(!check_rights(R_ADMIN|R_FUN)) - return - - var/mob/living/carbon/human/H = locate(href_list["adminsmite"]) in GLOB.mob_list - if(!H || !istype(H)) - to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human") - return - - usr.client.smite(H) - - else if(href_list["CentComReply"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["CentComReply"]) - usr.client.admin_headset_message(M, RADIO_CHANNEL_CENTCOM) - - else if(href_list["SyndicateReply"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["SyndicateReply"]) - usr.client.admin_headset_message(M, RADIO_CHANNEL_SYNDICATE) - - else if(href_list["HeadsetMessage"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["HeadsetMessage"]) - usr.client.admin_headset_message(M) - - else if(href_list["reject_custom_name"]) - if(!check_rights(R_ADMIN)) - return - var/obj/item/station_charter/charter = locate(href_list["reject_custom_name"]) - if(istype(charter)) - charter.reject_proposed(usr) - else if(href_list["jumpto"]) - if(!isobserver(usr) && !check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["jumpto"]) - usr.client.jumptomob(M) - - else if(href_list["getmob"]) - if(!check_rights(R_ADMIN)) - return - - if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") - return - var/mob/M = locate(href_list["getmob"]) - usr.client.Getmob(M) - - else if(href_list["sendmob"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["sendmob"]) - usr.client.sendmob(M) - - else if(href_list["narrateto"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["narrateto"]) - usr.client.cmd_admin_direct_narrate(M) - - else if(href_list["subtlemessage"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["subtlemessage"]) - usr.client.cmd_admin_subtle_message(M) - - else if(href_list["individuallog"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["individuallog"]) in GLOB.mob_list - if(!ismob(M)) - to_chat(usr, "This can only be used on instances of type /mob.") - return - - show_individual_logging_panel(M, href_list["log_src"], href_list["log_type"]) - else if(href_list["languagemenu"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["languagemenu"]) in GLOB.mob_list - if(!ismob(M)) - to_chat(usr, "This can only be used on instances of type /mob.") - return - var/datum/language_holder/H = M.get_language_holder() - H.open_language_menu(usr) - - else if(href_list["traitor"]) - if(!check_rights(R_ADMIN)) - return - - if(!SSticker.HasRoundStarted()) - alert("The game hasn't started yet!") - return - - var/mob/M = locate(href_list["traitor"]) - if(!ismob(M)) - var/datum/mind/D = M - if(!istype(D)) - to_chat(usr, "This can only be used on instances of type /mob and /mind") - return - else - D.traitor_panel() - else - show_traitor_panel(M) - - else if(href_list["borgpanel"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["borgpanel"]) - if(!iscyborg(M)) - to_chat(usr, "This can only be used on cyborgs") - else - open_borgopanel(M) - - else if(href_list["initmind"]) - if(!check_rights(R_ADMIN)) - return - var/mob/M = locate(href_list["initmind"]) - if(!ismob(M) || M.mind) - to_chat(usr, "This can only be used on instances on mindless mobs") - return - M.mind_initialize() - - else if(href_list["create_object"]) - if(!check_rights(R_SPAWN)) - return - return create_object(usr) - - else if(href_list["quick_create_object"]) - if(!check_rights(R_SPAWN)) - return - return quick_create_object(usr) - - else if(href_list["create_turf"]) - if(!check_rights(R_SPAWN)) - return - return create_turf(usr) - - else if(href_list["create_mob"]) - if(!check_rights(R_SPAWN)) - return - return create_mob(usr) - - else if(href_list["dupe_marked_datum"]) - if(!check_rights(R_SPAWN)) - return - return DuplicateObject(marked_datum, perfectcopy=1, newloc=get_turf(usr)) - - else if(href_list["object_list"]) //this is the laggiest thing ever - if(!check_rights(R_SPAWN)) - return - - var/atom/loc = usr.loc - - var/dirty_paths - if (istext(href_list["object_list"])) - dirty_paths = list(href_list["object_list"]) - else if (istype(href_list["object_list"], /list)) - dirty_paths = href_list["object_list"] - - var/paths = list() - - for(var/dirty_path in dirty_paths) - var/path = text2path(dirty_path) - if(!path) - continue - else if(!ispath(path, /obj) && !ispath(path, /turf) && !ispath(path, /mob)) - continue - paths += path - - if(!paths) - alert("The path list you sent is empty.") - return - if(length(paths) > 5) - alert("Select fewer object types, (max 5).") - return - - var/list/offset = splittext(href_list["offset"],",") - var/number = CLAMP(text2num(href_list["object_count"]), 1, 100) - var/X = offset.len > 0 ? text2num(offset[1]) : 0 - var/Y = offset.len > 1 ? text2num(offset[2]) : 0 - var/Z = offset.len > 2 ? text2num(offset[3]) : 0 - var/obj_dir = text2num(href_list["object_dir"]) - if(obj_dir && !(obj_dir in list(1,2,4,8,5,6,9,10))) - obj_dir = null - var/obj_name = sanitize(href_list["object_name"]) - - - var/atom/target //Where the object will be spawned - var/where = href_list["object_where"] - if (!( where in list("onfloor","inhand","inmarked") )) - where = "onfloor" - - - switch(where) - if("inhand") - if (!iscarbon(usr) && !iscyborg(usr)) - to_chat(usr, "Can only spawn in hand when you're a carbon mob or cyborg.") - where = "onfloor" - target = usr - - if("onfloor") - switch(href_list["offset_type"]) - if ("absolute") - target = locate(0 + X,0 + Y,0 + Z) - if ("relative") - target = locate(loc.x + X,loc.y + Y,loc.z + Z) - if("inmarked") - if(!marked_datum) - to_chat(usr, "You don't have any object marked. Abandoning spawn.") - return - else if(!istype(marked_datum, /atom)) - to_chat(usr, "The object you have marked cannot be used as a target. Target must be of type /atom. Abandoning spawn.") - return - else - target = marked_datum - - if(target) - for (var/path in paths) - for (var/i = 0; i < number; i++) - if(path in typesof(/turf)) - var/turf/O = target - var/turf/N = O.ChangeTurf(path) - if(N && obj_name) - N.name = obj_name - else - var/atom/O = new path(target) - if(!QDELETED(O)) - O.flags_1 |= ADMIN_SPAWNED_1 - if(obj_dir) - O.setDir(obj_dir) - if(obj_name) - O.name = obj_name - if(ismob(O)) - var/mob/M = O - M.real_name = obj_name - if(where == "inhand" && isliving(usr) && isitem(O)) - var/mob/living/L = usr - var/obj/item/I = O - L.put_in_hands(I) - if(iscyborg(L)) - var/mob/living/silicon/robot/R = L - if(R.module) - R.module.add_module(I, TRUE, TRUE) - R.activate_module(I) - - - if (number == 1) - log_admin("[key_name(usr)] created a [english_list(paths)]") - for(var/path in paths) - if(ispath(path, /mob)) - message_admins("[key_name_admin(usr)] created a [english_list(paths)]") - break - else - log_admin("[key_name(usr)] created [number]ea [english_list(paths)]") - for(var/path in paths) - if(ispath(path, /mob)) - message_admins("[key_name_admin(usr)] created [number]ea [english_list(paths)]") - break - return - - else if(href_list["secrets"]) - Secrets_topic(href_list["secrets"],href_list) - - else if(href_list["ac_view_wanted"]) //Admin newscaster Topic() stuff be here - if(!check_rights(R_ADMIN)) - return - src.admincaster_screen = 18 //The ac_ prefix before the hrefs stands for AdminCaster. - src.access_news_network() - - else if(href_list["ac_set_channel_name"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_feed_channel.channel_name = stripped_input(usr, "Provide a Feed Channel Name.", "Network Channel Handler", "") - while (findtext(src.admincaster_feed_channel.channel_name," ") == 1) - src.admincaster_feed_channel.channel_name = copytext(src.admincaster_feed_channel.channel_name,2,length(src.admincaster_feed_channel.channel_name)+1) - src.access_news_network() - - else if(href_list["ac_set_channel_lock"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_feed_channel.locked = !src.admincaster_feed_channel.locked - src.access_news_network() - - else if(href_list["ac_submit_new_channel"]) - if(!check_rights(R_ADMIN)) - return - var/check = 0 - for(var/datum/newscaster/feed_channel/FC in GLOB.news_network.network_channels) - if(FC.channel_name == src.admincaster_feed_channel.channel_name) - check = 1 - break - if(src.admincaster_feed_channel.channel_name == "" || src.admincaster_feed_channel.channel_name == "\[REDACTED\]" || check ) - src.admincaster_screen=7 - else - var/choice = alert("Please confirm Feed channel creation.","Network Channel Handler","Confirm","Cancel") - if(choice=="Confirm") - GLOB.news_network.CreateFeedChannel(src.admincaster_feed_channel.channel_name, src.admin_signature, src.admincaster_feed_channel.locked, 1) - SSblackbox.record_feedback("tally", "newscaster_channels", 1, src.admincaster_feed_channel.channel_name) - log_admin("[key_name(usr)] created command feed channel: [src.admincaster_feed_channel.channel_name]!") - src.admincaster_screen=5 - src.access_news_network() - - else if(href_list["ac_set_channel_receiving"]) - if(!check_rights(R_ADMIN)) - return - var/list/available_channels = list() - for(var/datum/newscaster/feed_channel/F in GLOB.news_network.network_channels) - available_channels += F.channel_name - src.admincaster_feed_channel.channel_name = adminscrub(input(usr, "Choose receiving Feed Channel.", "Network Channel Handler") in available_channels ) - src.access_news_network() - - else if(href_list["ac_set_new_message"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_feed_message.body = adminscrub(input(usr, "Write your Feed story.", "Network Channel Handler", "")) - while (findtext(src.admincaster_feed_message.returnBody(-1)," ") == 1) - src.admincaster_feed_message.body = copytext(src.admincaster_feed_message.returnBody(-1),2,length(src.admincaster_feed_message.returnBody(-1))+1) - src.access_news_network() - - else if(href_list["ac_submit_new_message"]) - if(!check_rights(R_ADMIN)) - return - if(src.admincaster_feed_message.returnBody(-1) =="" || src.admincaster_feed_message.returnBody(-1) =="\[REDACTED\]" || src.admincaster_feed_channel.channel_name == "" ) - src.admincaster_screen = 6 - else - GLOB.news_network.SubmitArticle(src.admincaster_feed_message.returnBody(-1), src.admin_signature, src.admincaster_feed_channel.channel_name, null, 1) - SSblackbox.record_feedback("amount", "newscaster_stories", 1) - src.admincaster_screen=4 - - for(var/obj/machinery/newscaster/NEWSCASTER in GLOB.allCasters) - NEWSCASTER.newsAlert(src.admincaster_feed_channel.channel_name) - - log_admin("[key_name(usr)] submitted a feed story to channel: [src.admincaster_feed_channel.channel_name]!") - src.access_news_network() - - else if(href_list["ac_create_channel"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_screen=2 - src.access_news_network() - - else if(href_list["ac_create_feed_story"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_screen=3 - src.access_news_network() - - else if(href_list["ac_menu_censor_story"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_screen=10 - src.access_news_network() - - else if(href_list["ac_menu_censor_channel"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_screen=11 - src.access_news_network() - - else if(href_list["ac_menu_wanted"]) - if(!check_rights(R_ADMIN)) - return - var/already_wanted = 0 - if(GLOB.news_network.wanted_issue.active) - already_wanted = 1 - - if(already_wanted) - src.admincaster_wanted_message.criminal = GLOB.news_network.wanted_issue.criminal - src.admincaster_wanted_message.body = GLOB.news_network.wanted_issue.body - src.admincaster_screen = 14 - src.access_news_network() - - else if(href_list["ac_set_wanted_name"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_wanted_message.criminal = adminscrub(input(usr, "Provide the name of the Wanted person.", "Network Security Handler", "")) - while(findtext(src.admincaster_wanted_message.criminal," ") == 1) - src.admincaster_wanted_message.criminal = copytext(admincaster_wanted_message.criminal,2,length(admincaster_wanted_message.criminal)+1) - src.access_news_network() - - else if(href_list["ac_set_wanted_desc"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_wanted_message.body = adminscrub(input(usr, "Provide the a description of the Wanted person and any other details you deem important.", "Network Security Handler", "")) - while (findtext(src.admincaster_wanted_message.body," ") == 1) - src.admincaster_wanted_message.body = copytext(src.admincaster_wanted_message.body,2,length(src.admincaster_wanted_message.body)+1) - src.access_news_network() - - else if(href_list["ac_submit_wanted"]) - if(!check_rights(R_ADMIN)) - return - var/input_param = text2num(href_list["ac_submit_wanted"]) - if(src.admincaster_wanted_message.criminal == "" || src.admincaster_wanted_message.body == "") - src.admincaster_screen = 16 - else - var/choice = alert("Please confirm Wanted Issue [(input_param==1) ? ("creation.") : ("edit.")]","Network Security Handler","Confirm","Cancel") - if(choice=="Confirm") - if(input_param==1) //If input_param == 1 we're submitting a new wanted issue. At 2 we're just editing an existing one. See the else below - GLOB.news_network.submitWanted(admincaster_wanted_message.criminal, admincaster_wanted_message.body, admin_signature, null, 1, 1) - src.admincaster_screen = 15 - else - GLOB.news_network.submitWanted(admincaster_wanted_message.criminal, admincaster_wanted_message.body, admin_signature) - src.admincaster_screen = 19 - log_admin("[key_name(usr)] issued a Station-wide Wanted Notification for [src.admincaster_wanted_message.criminal]!") - src.access_news_network() - - else if(href_list["ac_cancel_wanted"]) - if(!check_rights(R_ADMIN)) - return - var/choice = alert("Please confirm Wanted Issue removal.","Network Security Handler","Confirm","Cancel") - if(choice=="Confirm") - GLOB.news_network.deleteWanted() - src.admincaster_screen=17 - src.access_news_network() - - else if(href_list["ac_censor_channel_author"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_channel/FC = locate(href_list["ac_censor_channel_author"]) - FC.toggleCensorAuthor() - src.access_news_network() - - else if(href_list["ac_censor_channel_story_author"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_message/MSG = locate(href_list["ac_censor_channel_story_author"]) - MSG.toggleCensorAuthor() - src.access_news_network() - - else if(href_list["ac_censor_channel_story_body"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_message/MSG = locate(href_list["ac_censor_channel_story_body"]) - MSG.toggleCensorBody() - src.access_news_network() - - else if(href_list["ac_pick_d_notice"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_channel/FC = locate(href_list["ac_pick_d_notice"]) - src.admincaster_feed_channel = FC - src.admincaster_screen=13 - src.access_news_network() - - else if(href_list["ac_toggle_d_notice"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_channel/FC = locate(href_list["ac_toggle_d_notice"]) - FC.toggleCensorDclass() - src.access_news_network() - - else if(href_list["ac_view"]) - if(!check_rights(R_ADMIN)) - return - src.admincaster_screen=1 - src.access_news_network() - - else if(href_list["ac_setScreen"]) //Brings us to the main menu and resets all fields~ - if(!check_rights(R_ADMIN)) - return - src.admincaster_screen = text2num(href_list["ac_setScreen"]) - if (src.admincaster_screen == 0) - if(src.admincaster_feed_channel) - src.admincaster_feed_channel = new /datum/newscaster/feed_channel - if(src.admincaster_feed_message) - src.admincaster_feed_message = new /datum/newscaster/feed_message - if(admincaster_wanted_message) - admincaster_wanted_message = new /datum/newscaster/wanted_message - src.access_news_network() - - else if(href_list["ac_show_channel"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_channel/FC = locate(href_list["ac_show_channel"]) - src.admincaster_feed_channel = FC - src.admincaster_screen = 9 - src.access_news_network() - - else if(href_list["ac_pick_censor_channel"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_channel/FC = locate(href_list["ac_pick_censor_channel"]) - src.admincaster_feed_channel = FC - src.admincaster_screen = 12 - src.access_news_network() - - else if(href_list["ac_refresh"]) - if(!check_rights(R_ADMIN)) - return - src.access_news_network() - - else if(href_list["ac_set_signature"]) - if(!check_rights(R_ADMIN)) - return - src.admin_signature = adminscrub(input(usr, "Provide your desired signature.", "Network Identity Handler", "")) - src.access_news_network() - - else if(href_list["ac_del_comment"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_comment/FC = locate(href_list["ac_del_comment"]) - var/datum/newscaster/feed_message/FM = locate(href_list["ac_del_comment_msg"]) - FM.comments -= FC - qdel(FC) - src.access_news_network() - - else if(href_list["ac_lock_comment"]) - if(!check_rights(R_ADMIN)) - return - var/datum/newscaster/feed_message/FM = locate(href_list["ac_lock_comment"]) - FM.locked ^= 1 - src.access_news_network() - - else if(href_list["check_antagonist"]) - if(!check_rights(R_ADMIN)) - return - usr.client.check_antagonists() - - else if(href_list["kick_all_from_lobby"]) - if(!check_rights(R_ADMIN)) - return - if(SSticker.IsRoundInProgress()) - var/afkonly = text2num(href_list["afkonly"]) - if(alert("Are you sure you want to kick all [afkonly ? "AFK" : ""] clients from the lobby??","Message","Yes","Cancel") != "Yes") - to_chat(usr, "Kick clients from lobby aborted") - return - var/list/listkicked = kick_clients_in_lobby("You were kicked from the lobby by [usr.client.holder.fakekey ? "an Administrator" : "[usr.client.key]"].", afkonly) - - var/strkicked = "" - for(var/name in listkicked) - strkicked += "[name], " - message_admins("[key_name_admin(usr)] has kicked [afkonly ? "all AFK" : "all"] clients from the lobby. [length(listkicked)] clients kicked: [strkicked ? strkicked : "--"]") - log_admin("[key_name(usr)] has kicked [afkonly ? "all AFK" : "all"] clients from the lobby. [length(listkicked)] clients kicked: [strkicked ? strkicked : "--"]") - else - to_chat(usr, "You may only use this when the game is running.") - - else if(href_list["create_outfit"]) - if(!check_rights(R_ADMIN)) - return - - var/datum/outfit/O = new /datum/outfit - //swap this for js dropdowns sometime - O.name = href_list["outfit_name"] - O.uniform = text2path(href_list["outfit_uniform"]) - O.shoes = text2path(href_list["outfit_shoes"]) - O.gloves = text2path(href_list["outfit_gloves"]) - O.suit = text2path(href_list["outfit_suit"]) - O.head = text2path(href_list["outfit_head"]) - O.back = text2path(href_list["outfit_back"]) - O.mask = text2path(href_list["outfit_mask"]) - O.glasses = text2path(href_list["outfit_glasses"]) - O.r_hand = text2path(href_list["outfit_r_hand"]) - O.l_hand = text2path(href_list["outfit_l_hand"]) - O.suit_store = text2path(href_list["outfit_s_store"]) - O.l_pocket = text2path(href_list["outfit_l_pocket"]) - O.r_pocket = text2path(href_list["outfit_r_pocket"]) - O.id = text2path(href_list["outfit_id"]) - O.belt = text2path(href_list["outfit_belt"]) - O.ears = text2path(href_list["outfit_ears"]) - - GLOB.custom_outfits.Add(O) - message_admins("[key_name(usr)] created \"[O.name]\" outfit!") - - else if(href_list["set_selfdestruct_code"]) - if(!check_rights(R_ADMIN)) - return - var/code = random_nukecode() - for(var/obj/machinery/nuclearbomb/selfdestruct/SD in GLOB.nuke_list) - SD.r_code = code - message_admins("[key_name_admin(usr)] has set the self-destruct \ - code to \"[code]\".") - - else if(href_list["add_station_goal"]) - if(!check_rights(R_ADMIN)) - return - var/list/type_choices = typesof(/datum/station_goal) - var/picked = input("Choose goal type") in type_choices|null - if(!picked) - return - var/datum/station_goal/G = new picked() - if(picked == /datum/station_goal) - var/newname = input("Enter goal name:") as text|null - if(!newname) - return - G.name = newname - var/description = input("Enter CentCom message contents:") as message|null - if(!description) - return - G.report_message = description - message_admins("[key_name(usr)] created \"[G.name]\" station goal.") - SSticker.mode.station_goals += G - modify_goals() - - else if(href_list["viewruntime"]) - var/datum/error_viewer/error_viewer = locate(href_list["viewruntime"]) - if(!istype(error_viewer)) - to_chat(usr, "That runtime viewer no longer exists.") - return - - if(href_list["viewruntime_backto"]) - error_viewer.show_to(owner, locate(href_list["viewruntime_backto"]), href_list["viewruntime_linear"]) - else - error_viewer.show_to(owner, null, href_list["viewruntime_linear"]) - - else if(href_list["showrelatedacc"]) - if(!check_rights(R_ADMIN)) - return - var/client/C = locate(href_list["client"]) in GLOB.clients - var/thing_to_check - if(href_list["showrelatedacc"] == "cid") - thing_to_check = C.related_accounts_cid - else - thing_to_check = C.related_accounts_ip - thing_to_check = splittext(thing_to_check, ", ") - - - var/list/dat = list("Related accounts by [uppertext(href_list["showrelatedacc"])]:") - dat += thing_to_check - - usr << browse(dat.Join("
    "), "window=related_[C];size=420x300") - else if(href_list["centcomlookup"]) - if(!check_rights(R_ADMIN)) - return - - if(!CONFIG_GET(string/centcom_ban_db)) - to_chat(usr, "Centcom Galactic Ban DB is disabled!") - return - - var/ckey = href_list["centcomlookup"] - - // Make the request - var/datum/http_request/request = new() - request.prepare(RUSTG_HTTP_METHOD_GET, "[CONFIG_GET(string/centcom_ban_db)]/[ckey]", "", "") - request.begin_async() - UNTIL(request.is_complete() || !usr) - if (!usr) - return - var/datum/http_response/response = request.into_response() - - var/list/bans - - var/list/dat = list("") - - if(response.errored) - dat += "
    Failed to connect to CentCom." - else if(response.status_code != 200) - dat += "
    Failed to connect to CentCom. Status code: [response.status_code]" - else - if(response.body == "[]") - dat += "
    0 bans detected for [ckey]
    " - else - bans = json_decode(response["body"]) - dat += "
    [bans.len] ban\s detected for [ckey]
    " - for(var/list/ban in bans) - dat += "Server: [sanitize(ban["sourceName"])]
    " - dat += "RP Level: [sanitize(ban["sourceRoleplayLevel"])]
    " - dat += "Type: [sanitize(ban["type"])]
    " - dat += "Banned By: [sanitize(ban["bannedBy"])]
    " - dat += "Reason: [sanitize(ban["reason"])]
    " - dat += "Datetime: [sanitize(ban["bannedOn"])]
    " - var/expiration = ban["expires"] - dat += "Expires: [expiration ? "[sanitize(expiration)]" : "Permanent"]
    " - if(ban["type"] == "job") - dat += "Jobs: " - var/list/jobs = ban["jobs"] - dat += sanitize(jobs.Join(", ")) - dat += "
    " - dat += "
    " - - dat += "
    " - var/datum/browser/popup = new(usr, "centcomlookup-[ckey]", "
    Central Command Galactic Ban Database
    ", 700, 600) - popup.set_content(dat.Join()) - popup.open(0) - - - else if(href_list["modantagrep"]) - if(!check_rights(R_ADMIN)) - return - - var/mob/M = locate(href_list["mob"]) in GLOB.mob_list - var/client/C = M.client - usr.client.cmd_admin_mod_antag_rep(C, href_list["modantagrep"]) - show_player_panel(M) - - else if(href_list["slowquery"]) - if(!check_rights(R_ADMIN)) - return - var/answer = href_list["slowquery"] - if(answer == "yes") - log_query_debug("[usr.key] | Reported a server hang") - if(alert(usr, "Had you just press any admin buttons?", "Query server hang report", "Yes", "No") == "Yes") - var/response = input(usr,"What were you just doing?","Query server hang report") as null|text - if(response) - log_query_debug("[usr.key] | [response]") - else if(answer == "no") - log_query_debug("[usr.key] | Reported no server hang") - -/datum/admins/proc/HandleCMode() - if(!check_rights(R_ADMIN)) - return - - if(SSticker.HasRoundStarted()) - return alert(usr, "The game has already started.", null, null, null, null) - var/dat = {"What mode do you wish to play?
    "} - for(var/mode in config.modes) - dat += {"[config.mode_names[mode]]
    "} - dat += {"Secret
    "} - dat += {"Random
    "} - dat += {"Now: [GLOB.master_mode]"} - usr << browse(dat, "window=c_mode") - -/datum/admins/proc/HandleFSecret() - if(!check_rights(R_ADMIN)) - return - - if(SSticker.HasRoundStarted()) - return alert(usr, "The game has already started.", null, null, null, null) - if(GLOB.master_mode != "secret") - return alert(usr, "The game mode has to be secret!", null, null, null, null) - var/dat = {"What game mode do you want to force secret to be? Use this if you want to change the game mode, but want the players to believe it's secret. This will only work if the current game mode is secret.
    "} - for(var/mode in config.modes) - dat += {"[config.mode_names[mode]]
    "} - dat += {"Random (default)
    "} - dat += {"Now: [GLOB.secret_force_mode]"} - usr << browse(dat, "window=f_secret") - -/datum/admins/proc/makeMentor(ckey) - if(!usr.client) - return - if (!check_rights(0)) - return - if(!ckey) - return - var/client/C = GLOB.directory[ckey] - if(C) - if(check_rights_for(C, R_ADMIN,0)) - to_chat(usr, "The client chosen is an admin! Cannot mentorize.") - return - if(SSdbcore.Connect()) - var/datum/DBQuery/query_get_mentor = SSdbcore.NewQuery("SELECT id FROM [format_table_name("mentor")] WHERE ckey = '[ckey]'") - if(query_get_mentor.NextRow()) - to_chat(usr, "[ckey] is already a mentor.") - return - var/datum/DBQuery/query_add_mentor = SSdbcore.NewQuery("INSERT INTO `[format_table_name("mentor")]` (`id`, `ckey`) VALUES (null, '[ckey]')") - if(!query_add_mentor.warn_execute()) - return - var/datum/DBQuery/query_add_admin_log = SSdbcore.NewQuery("INSERT INTO `[format_table_name("admin_log")]` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Added new mentor [ckey]');") - if(!query_add_admin_log.warn_execute()) - return - else - to_chat(usr, "Failed to establish database connection. The changes will last only for the current round.") - new /datum/mentors(ckey) - to_chat(usr, "New mentor added.") - -/datum/admins/proc/removeMentor(ckey) - if(!usr.client) - return - if (!check_rights(0)) - return - if(!ckey) - return - var/client/C = GLOB.directory[ckey] - if(C) - if(check_rights_for(C, R_ADMIN,0)) - to_chat(usr, "The client chosen is an admin, not a mentor! Cannot de-mentorize.") - return - C.remove_mentor_verbs() - C.mentor_datum = null - GLOB.mentors -= C - if(SSdbcore.Connect()) - var/datum/DBQuery/query_remove_mentor = SSdbcore.NewQuery("DELETE FROM [format_table_name("mentor")] WHERE ckey = '[ckey]'") - if(!query_remove_mentor.warn_execute()) - return - var/datum/DBQuery/query_add_admin_log = SSdbcore.NewQuery("INSERT INTO `[format_table_name("admin_log")]` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Removed mentor [ckey]');") - if(!query_add_admin_log.warn_execute()) - return - else - to_chat(usr, "Failed to establish database connection. The changes will last only for the current round.") - to_chat(usr, "Mentor removed.") +/datum/admins/proc/CheckAdminHref(href, href_list) + var/auth = href_list["admin_token"] + . = auth && (auth == href_token || auth == GLOB.href_token) + if(.) + return + var/msg = !auth ? "no" : "a bad" + message_admins("[key_name_admin(usr)] clicked an href with [msg] authorization key!") + if(CONFIG_GET(flag/debug_admin_hrefs)) + message_admins("Debug mode enabled, call not blocked. Please ask your coders to review this round's logs.") + log_world("UAH: [href]") + return TRUE + log_admin_private("[key_name(usr)] clicked an href with [msg] authorization key! [href]") + +/datum/admins/Topic(href, href_list) + ..() + + if(usr.client != src.owner || !check_rights(0)) + message_admins("[usr.key] tried to use the admin panel without authorization.") + log_admin("[key_name(usr)] tried to use the admin panel without authorization.") + return + + if(!CheckAdminHref(href, href_list)) + return + + if(href_list["makementor"]) + makeMentor(href_list["makementor"]) + else if(href_list["removementor"]) + removeMentor(href_list["removementor"]) + + if(href_list["ahelp"]) + if(!check_rights(R_ADMIN, TRUE)) + return + + var/ahelp_ref = href_list["ahelp"] + var/datum/admin_help/AH = locate(ahelp_ref) + if(AH) + AH.Action(href_list["ahelp_action"]) + else + to_chat(usr, "Ticket [ahelp_ref] has been deleted!") + + else if(href_list["ahelp_tickets"]) + GLOB.ahelp_tickets.BrowseTickets(text2num(href_list["ahelp_tickets"])) + + else if(href_list["stickyban"]) + stickyban(href_list["stickyban"],href_list) + + else if(href_list["getplaytimewindow"]) + if(!check_rights(R_ADMIN)) + return + var/mob/M = locate(href_list["getplaytimewindow"]) in GLOB.mob_list + if(!M) + to_chat(usr, "ERROR: Mob not found.") + return + cmd_show_exp_panel(M.client) + + else if(href_list["toggleexempt"]) + if(!check_rights(R_ADMIN)) + return + var/client/C = locate(href_list["toggleexempt"]) in GLOB.clients + if(!C) + to_chat(usr, "ERROR: Client not found.") + return + toggle_exempt_status(C) + + else if(href_list["makeAntag"]) + if(!check_rights(R_ADMIN)) + return + if (!SSticker.mode) + to_chat(usr, "Not until the round starts!") + return + switch(href_list["makeAntag"]) + if("traitors") + if(src.makeTraitors()) + message_admins("[key_name_admin(usr)] created traitors.") + log_admin("[key_name(usr)] created traitors.") + else + message_admins("[key_name_admin(usr)] tried to create traitors. Unfortunately, there were no candidates available.") + log_admin("[key_name(usr)] failed to create traitors.") + if("changelings") + if(src.makeChangelings()) + message_admins("[key_name(usr)] created changelings.") + log_admin("[key_name(usr)] created changelings.") + else + message_admins("[key_name_admin(usr)] tried to create changelings. Unfortunately, there were no candidates available.") + log_admin("[key_name(usr)] failed to create changelings.") + if("revs") + if(src.makeRevs()) + message_admins("[key_name(usr)] started a revolution.") + log_admin("[key_name(usr)] started a revolution.") + else + message_admins("[key_name_admin(usr)] tried to start a revolution. Unfortunately, there were no candidates available.") + log_admin("[key_name(usr)] failed to start a revolution.") + if("cult") + if(src.makeCult()) + message_admins("[key_name(usr)] started a cult.") + log_admin("[key_name(usr)] started a cult.") + else + message_admins("[key_name_admin(usr)] tried to start a cult. Unfortunately, there were no candidates available.") + log_admin("[key_name(usr)] failed to start a cult.") + if("wizard") + message_admins("[key_name(usr)] is creating a wizard...") + if(src.makeWizard()) + message_admins("[key_name(usr)] created a wizard.") + log_admin("[key_name(usr)] created a wizard.") + else + message_admins("[key_name_admin(usr)] tried to create a wizard. Unfortunately, there were no candidates available.") + log_admin("[key_name(usr)] failed to create a wizard.") + if("nukeops") + message_admins("[key_name(usr)] is creating a nuke team...") + if(src.makeNukeTeam()) + message_admins("[key_name(usr)] created a nuke team.") + log_admin("[key_name(usr)] created a nuke team.") + else + message_admins("[key_name_admin(usr)] tried to create a nuke team. Unfortunately, there were not enough candidates available.") + log_admin("[key_name(usr)] failed to create a nuke team.") + if("ninja") + message_admins("[key_name(usr)] spawned a ninja.") + log_admin("[key_name(usr)] spawned a ninja.") + src.makeSpaceNinja() + if("aliens") + message_admins("[key_name(usr)] started an alien infestation.") + log_admin("[key_name(usr)] started an alien infestation.") + src.makeAliens() + if("deathsquad") + message_admins("[key_name(usr)] is creating a death squad...") + if(src.makeDeathsquad()) + message_admins("[key_name(usr)] created a death squad.") + log_admin("[key_name(usr)] created a death squad.") + else + message_admins("[key_name_admin(usr)] tried to create a death squad. Unfortunately, there were not enough candidates available.") + log_admin("[key_name(usr)] failed to create a death squad.") + if("blob") + var/strength = input("Set Blob Resource Gain Rate","Set Resource Rate",1) as num|null + if(!strength) + return + message_admins("[key_name(usr)] spawned a blob with base resource gain [strength].") + log_admin("[key_name(usr)] spawned a blob with base resource gain [strength].") + new/datum/round_event/ghost_role/blob(TRUE, strength) + if("centcom") + message_admins("[key_name(usr)] is creating a CentCom response team...") + if(src.makeEmergencyresponseteam()) + message_admins("[key_name(usr)] created a CentCom response team.") + log_admin("[key_name(usr)] created a CentCom response team.") + else + message_admins("[key_name_admin(usr)] tried to create a CentCom response team. Unfortunately, there were not enough candidates available.") + log_admin("[key_name(usr)] failed to create a CentCom response team.") + if("abductors") + message_admins("[key_name(usr)] is creating an abductor team...") + if(src.makeAbductorTeam()) + message_admins("[key_name(usr)] created an abductor team.") + log_admin("[key_name(usr)] created an abductor team.") + else + message_admins("[key_name_admin(usr)] tried to create an abductor team. Unfortunatly there were not enough candidates available.") + log_admin("[key_name(usr)] failed to create an abductor team.") + if("clockcult") + if(src.makeClockCult()) + message_admins("[key_name(usr)] started a clockwork cult.") + log_admin("[key_name(usr)] started a clockwork cult.") + else + message_admins("[key_name_admin(usr)] tried to start a clockwork cult. Unfortunately, there were no candidates available.") + log_admin("[key_name(usr)] failed to start a clockwork cult.") + if("revenant") + if(src.makeRevenant()) + message_admins("[key_name(usr)] created a revenant.") + log_admin("[key_name(usr)] created a revenant.") + else + message_admins("[key_name_admin(usr)] tried to create a revenant. Unfortunately, there were no candidates available.") + log_admin("[key_name(usr)] failed to create a revenant.") + //Hyper + if("lewdtraitors") + if(src.makeLewdtraitors()) + message_admins("[key_name(usr)] created a lewd traitor.") + log_admin("[key_name(usr)] created a lewd traitor.") + else + message_admins("[key_name_admin(usr)] tried to create a lewd traitor. Unfortunately, there were no candidates available.") + log_admin("[key_name(usr)] failed to create a lewd traitor.") + + else if(href_list["forceevent"]) + if(!check_rights(R_FUN)) + return + var/datum/round_event_control/E = locate(href_list["forceevent"]) in SSevents.control + if(E) + E.admin_setup(usr) + var/datum/round_event/event = E.runEvent() + if(event.announceWhen>0) + event.processing = FALSE + var/prompt = alert(usr, "Would you like to alert the crew?", "Alert", "Yes", "No", "Cancel") + switch(prompt) + if("Cancel") + event.kill() + return + if("No") + event.announceWhen = -1 + event.processing = TRUE + message_admins("[key_name_admin(usr)] has triggered an event. ([E.name])") + log_admin("[key_name(usr)] has triggered an event. ([E.name])") + return + + else if(href_list["dbsearchckey"] || href_list["dbsearchadmin"] || href_list["dbsearchip"] || href_list["dbsearchcid"]) + var/adminckey = href_list["dbsearchadmin"] + var/playerckey = href_list["dbsearchckey"] + var/ip = href_list["dbsearchip"] + var/cid = href_list["dbsearchcid"] + var/page = href_list["dbsearchpage"] + + DB_ban_panel(playerckey, adminckey, ip, cid, page) + return + + else if(href_list["dbbanedit"]) + var/banedit = href_list["dbbanedit"] + var/banid = text2num(href_list["dbbanid"]) + if(!banedit || !banid) + return + + DB_ban_edit(banid, banedit) + return + + else if(href_list["dbbanaddtype"]) + if(!check_rights(R_BAN)) + return + var/bantype = text2num(href_list["dbbanaddtype"]) + var/bankey = href_list["dbbanaddkey"] + var/banckey = ckey(bankey) + var/banip = href_list["dbbanaddip"] + var/bancid = href_list["dbbanaddcid"] + var/banduration = text2num(href_list["dbbaddduration"]) + var/banjob = href_list["dbbanaddjob"] + var/banreason = href_list["dbbanreason"] + var/banseverity = href_list["dbbanaddseverity"] + + switch(bantype) + if(BANTYPE_PERMA) + if(!banckey || !banreason || !banseverity) + to_chat(usr, "Not enough parameters (Requires ckey, severity, and reason).") + return + banduration = null + banjob = null + if(BANTYPE_TEMP) + if(!banckey || !banreason || !banduration || !banseverity) + to_chat(usr, "Not enough parameters (Requires ckey, reason, severity and duration).") + return + banjob = null + if(BANTYPE_JOB_PERMA) + if(!banckey || !banreason || !banjob || !banseverity) + to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and job).") + return + banduration = null + if(BANTYPE_JOB_TEMP) + if(!banckey || !banreason || !banjob || !banduration || !banseverity) + to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and job).") + return + if(BANTYPE_ADMIN_PERMA) + if(!banckey || !banreason || !banseverity) + to_chat(usr, "Not enough parameters (Requires ckey, severity and reason).") + return + banduration = null + banjob = null + if(BANTYPE_ADMIN_TEMP) + if(!banckey || !banreason || !banduration || !banseverity) + to_chat(usr, "Not enough parameters (Requires ckey, severity, reason and duration).") + return + banjob = null + + var/mob/playermob + + for(var/mob/M in GLOB.player_list) + if(M.ckey == banckey) + playermob = M + break + + + banreason = "(MANUAL BAN) "+banreason + + if(!playermob) + if(banip) + banreason = "[banreason] (CUSTOM IP)" + if(bancid) + banreason = "[banreason] (CUSTOM CID)" + else + message_admins("Ban process: A mob matching [playermob.key] was found at location [playermob.x], [playermob.y], [playermob.z]. Custom ip and computer id fields replaced with the ip and computer id from the located mob.") + + if(!DB_ban_record(bantype, playermob, banduration, banreason, banjob, bankey, banip, bancid )) + to_chat(usr, "Failed to apply ban.") + return + create_message("note", bankey, null, banreason, null, null, 0, 0, null, 0, banseverity) + + else if(href_list["editrightsbrowser"]) + edit_admin_permissions(0) + + else if(href_list["editrightsbrowserlog"]) + edit_admin_permissions(1, href_list["editrightstarget"], href_list["editrightsoperation"], href_list["editrightspage"]) + + if(href_list["editrightsbrowsermanage"]) + if(href_list["editrightschange"]) + change_admin_rank(ckey(href_list["editrightschange"]), href_list["editrightschange"], TRUE) + else if(href_list["editrightsremove"]) + remove_admin(ckey(href_list["editrightsremove"]), href_list["editrightsremove"], TRUE) + else if(href_list["editrightsremoverank"]) + remove_rank(href_list["editrightsremoverank"]) + edit_admin_permissions(2) + + else if(href_list["editrights"]) + edit_rights_topic(href_list) + + else if(href_list["gamemode_panel"]) + if(!check_rights(R_ADMIN)) + return + SSticker.mode.admin_panel() + + + else if(href_list["call_shuttle"]) + if(!check_rights(R_ADMIN)) + return + + + switch(href_list["call_shuttle"]) + if("1") + if(EMERGENCY_AT_LEAST_DOCKED) + return + SSshuttle.emergency.request() + log_admin("[key_name(usr)] called the Emergency Shuttle.") + message_admins("[key_name_admin(usr)] called the Emergency Shuttle to the station.") + + if("2") + if(EMERGENCY_AT_LEAST_DOCKED) + return + switch(SSshuttle.emergency.mode) + if(SHUTTLE_CALL) + SSshuttle.emergency.cancel() + log_admin("[key_name(usr)] sent the Emergency Shuttle back.") + message_admins("[key_name_admin(usr)] sent the Emergency Shuttle back.") + else + SSshuttle.emergency.cancel() + log_admin("[key_name(usr)] called the Emergency Shuttle.") + message_admins("[key_name_admin(usr)] called the Emergency Shuttle to the station.") + + + href_list["secrets"] = "check_antagonist" + + else if(href_list["edit_shuttle_time"]) + if(!check_rights(R_SERVER)) + return + + var/timer = input("Enter new shuttle duration (seconds):","Edit Shuttle Timeleft", SSshuttle.emergency.timeLeft() ) as num|null + if(!timer) + return + SSshuttle.emergency.setTimer(timer*10) + log_admin("[key_name(usr)] edited the Emergency Shuttle's timeleft to [timer] seconds.") + minor_announce("The emergency shuttle will reach its destination in [round(SSshuttle.emergency.timeLeft(600))] minutes.") + message_admins("[key_name_admin(usr)] edited the Emergency Shuttle's timeleft to [timer] seconds.") + href_list["secrets"] = "check_antagonist" + else if(href_list["trigger_centcom_recall"]) + if(!check_rights(R_ADMIN)) + return + + usr.client.trigger_centcom_recall() + + else if(href_list["toggle_continuous"]) + if(!check_rights(R_ADMIN)) + return + var/list/continuous = CONFIG_GET(keyed_list/continuous) + if(!continuous[SSticker.mode.config_tag]) + continuous[SSticker.mode.config_tag] = TRUE + else + continuous[SSticker.mode.config_tag] = FALSE + + message_admins("[key_name_admin(usr)] toggled the round to [continuous[SSticker.mode.config_tag] ? "continue if all antagonists die" : "end with the antagonists"].") + check_antagonists() + + else if(href_list["toggle_midround_antag"]) + if(!check_rights(R_ADMIN)) + return + + var/list/midround_antag = CONFIG_GET(keyed_list/midround_antag) + if(!midround_antag[SSticker.mode.config_tag]) + midround_antag[SSticker.mode.config_tag] = TRUE + else + midround_antag[SSticker.mode.config_tag] = FALSE + + message_admins("[key_name_admin(usr)] toggled the round to [midround_antag[SSticker.mode.config_tag] ? "use" : "skip"] the midround antag system.") + check_antagonists() + + else if(href_list["alter_midround_time_limit"]) + if(!check_rights(R_ADMIN)) + return + + var/timer = input("Enter new maximum time",, CONFIG_GET(number/midround_antag_time_check)) as num|null + if(!timer) + return + CONFIG_SET(number/midround_antag_time_check, timer) + message_admins("[key_name_admin(usr)] edited the maximum midround antagonist time to [timer] minutes.") + check_antagonists() + + else if(href_list["alter_midround_life_limit"]) + if(!check_rights(R_ADMIN)) + return + + var/ratio = input("Enter new life ratio",, CONFIG_GET(number/midround_antag_life_check) * 100) as num + if(!ratio) + return + CONFIG_SET(number/midround_antag_life_check, ratio / 100) + + message_admins("[key_name_admin(usr)] edited the midround antagonist living crew ratio to [ratio]% alive.") + check_antagonists() + + else if(href_list["toggle_noncontinuous_behavior"]) + if(!check_rights(R_ADMIN)) + return + + if(!SSticker.mode.round_ends_with_antag_death) + SSticker.mode.round_ends_with_antag_death = 1 + else + SSticker.mode.round_ends_with_antag_death = 0 + + message_admins("[key_name_admin(usr)] edited the midround antagonist system to [SSticker.mode.round_ends_with_antag_death ? "end the round" : "continue as extended"] upon failure.") + check_antagonists() + + else if(href_list["delay_round_end"]) + if(!check_rights(R_SERVER)) + return + if(!SSticker.delay_end) + SSticker.admin_delay_notice = input(usr, "Enter a reason for delaying the round end", "Round Delay Reason") as null|text + if(isnull(SSticker.admin_delay_notice)) + return + else + SSticker.admin_delay_notice = null + SSticker.delay_end = !SSticker.delay_end + var/reason = SSticker.delay_end ? "for reason: [SSticker.admin_delay_notice]" : "."//laziness + var/msg = "[SSticker.delay_end ? "delayed" : "undelayed"] the round end [reason]" + log_admin("[key_name(usr)] [msg]") + message_admins("[key_name_admin(usr)] [msg]") + href_list["secrets"] = "check_antagonist" + if(SSticker.ready_for_reboot && !SSticker.delay_end) //we undelayed after standard reboot would occur + SSticker.standard_reboot() + + else if(href_list["end_round"]) + if(!check_rights(R_ADMIN)) + return + + message_admins("[key_name_admin(usr)] is considering ending the round.") + if(alert(usr, "This will end the round, are you SURE you want to do this?", "Confirmation", "Yes", "No") == "Yes") + if(alert(usr, "Final Confirmation: End the round NOW?", "Confirmation", "Yes", "No") == "Yes") + message_admins("[key_name_admin(usr)] has ended the round.") + SSticker.force_ending = 1 //Yeah there we go APC destroyed mission accomplished + return + else + message_admins("[key_name_admin(usr)] decided against ending the round.") + else + message_admins("[key_name_admin(usr)] decided against ending the round.") + + else if(href_list["simplemake"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/M = locate(href_list["mob"]) + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob.") + return + + var/delmob = 0 + switch(alert("Delete old mob?","Message","Yes","No","Cancel")) + if("Cancel") + return + if("Yes") + delmob = 1 + + log_admin("[key_name(usr)] has used rudimentary transformation on [key_name(M)]. Transforming to [href_list["simplemake"]].; deletemob=[delmob]") + message_admins("[key_name_admin(usr)] has used rudimentary transformation on [key_name_admin(M)]. Transforming to [href_list["simplemake"]].; deletemob=[delmob]") + switch(href_list["simplemake"]) + if("observer") + M.change_mob_type( /mob/dead/observer , null, null, delmob ) + if("drone") + M.change_mob_type( /mob/living/carbon/alien/humanoid/drone , null, null, delmob ) + if("hunter") + M.change_mob_type( /mob/living/carbon/alien/humanoid/hunter , null, null, delmob ) + if("queen") + M.change_mob_type( /mob/living/carbon/alien/humanoid/royal/queen , null, null, delmob ) + if("praetorian") + M.change_mob_type( /mob/living/carbon/alien/humanoid/royal/praetorian , null, null, delmob ) + if("sentinel") + M.change_mob_type( /mob/living/carbon/alien/humanoid/sentinel , null, null, delmob ) + if("larva") + M.change_mob_type( /mob/living/carbon/alien/larva , null, null, delmob ) + if("human") + var/posttransformoutfit = usr.client.robust_dress_shop() + var/mob/living/carbon/human/newmob = M.change_mob_type( /mob/living/carbon/human , null, null, delmob ) + if(posttransformoutfit && istype(newmob)) + newmob.equipOutfit(posttransformoutfit) + if("slime") + M.change_mob_type( /mob/living/simple_animal/slime , null, null, delmob ) + if("monkey") + M.change_mob_type( /mob/living/carbon/monkey , null, null, delmob ) + if("robot") + M.change_mob_type( /mob/living/silicon/robot , null, null, delmob ) + if("cat") + M.change_mob_type( /mob/living/simple_animal/pet/cat , null, null, delmob ) + if("runtime") + M.change_mob_type( /mob/living/simple_animal/pet/cat/Runtime , null, null, delmob ) + if("corgi") + M.change_mob_type( /mob/living/simple_animal/pet/dog/corgi , null, null, delmob ) + if("ian") + M.change_mob_type( /mob/living/simple_animal/pet/dog/corgi/Ian , null, null, delmob ) + if("pug") + M.change_mob_type( /mob/living/simple_animal/pet/dog/pug , null, null, delmob ) + if("crab") + M.change_mob_type( /mob/living/simple_animal/crab , null, null, delmob ) + if("coffee") + M.change_mob_type( /mob/living/simple_animal/crab/Coffee , null, null, delmob ) + if("parrot") + M.change_mob_type( /mob/living/simple_animal/parrot , null, null, delmob ) + if("polyparrot") + M.change_mob_type( /mob/living/simple_animal/parrot/Poly , null, null, delmob ) + if("constructarmored") + M.change_mob_type( /mob/living/simple_animal/hostile/construct/armored , null, null, delmob ) + if("constructbuilder") + M.change_mob_type( /mob/living/simple_animal/hostile/construct/builder , null, null, delmob ) + if("constructwraith") + M.change_mob_type( /mob/living/simple_animal/hostile/construct/wraith , null, null, delmob ) + if("shade") + M.change_mob_type( /mob/living/simple_animal/shade , null, null, delmob ) + + + /////////////////////////////////////new ban stuff + else if(href_list["unbanf"]) + if(!check_rights(R_BAN)) + return + + var/banfolder = href_list["unbanf"] + GLOB.Banlist.cd = "/base/[banfolder]" + var/key = GLOB.Banlist["key"] + if(alert(usr, "Are you sure you want to unban [key]?", "Confirmation", "Yes", "No") == "Yes") + if(RemoveBan(banfolder)) + unbanpanel() + else + alert(usr, "This ban has already been lifted / does not exist.", "Error", "Ok") + unbanpanel() + + else if(href_list["unbane"]) + if(!check_rights(R_BAN)) + return + + UpdateTime() + var/reason + + var/banfolder = href_list["unbane"] + GLOB.Banlist.cd = "/base/[banfolder]" + var/reason2 = GLOB.Banlist["reason"] + var/temp = GLOB.Banlist["temp"] + + var/minutes = GLOB.Banlist["minutes"] + + var/banned_key = GLOB.Banlist["key"] + GLOB.Banlist.cd = "/base" + + var/duration + + switch(alert("Temporary Ban for [banned_key]?",,"Yes","No")) + if("Yes") + temp = 1 + var/mins = 0 + if(minutes > GLOB.CMinutes) + mins = minutes - GLOB.CMinutes + mins = input(usr,"How long (in minutes)? (Default: 1440)","Ban time",mins ? mins : 1440) as num|null + if(mins <= 0) + to_chat(usr, "[mins] is not a valid duration.") + return + minutes = GLOB.CMinutes + mins + duration = GetExp(minutes) + reason = input(usr,"Please State Reason For Banning [banned_key].","Reason",reason2) as message|null + if(!reason) + return + if("No") + temp = 0 + duration = "Perma" + reason = input(usr,"Please State Reason For Banning [banned_key].","Reason",reason2) as message|null + if(!reason) + return + + log_admin_private("[key_name(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]") + ban_unban_log_save("[key_name(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]") + message_admins("[key_name_admin(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]") + GLOB.Banlist.cd = "/base/[banfolder]" + WRITE_FILE(GLOB.Banlist["reason"], reason) + WRITE_FILE(GLOB.Banlist["temp"], temp) + WRITE_FILE(GLOB.Banlist["minutes"], minutes) + WRITE_FILE(GLOB.Banlist["bannedby"], usr.ckey) + GLOB.Banlist.cd = "/base" + unbanpanel() + + /////////////////////////////////////new ban stuff + + else if(href_list["appearanceban"]) + if(!check_rights(R_BAN)) + return + var/mob/M = locate(href_list["appearanceban"]) + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob") + return + if(!M.ckey) //sanity + to_chat(usr, "This mob has no ckey") + return + + + if(jobban_isbanned(M, "appearance")) + switch(alert("Remove appearance ban?","Please Confirm","Yes","No")) + if("Yes") + ban_unban_log_save("[key_name(usr)] removed [key_name(M)]'s appearance ban.") + log_admin_private("[key_name(usr)] removed [key_name(M)]'s appearance ban.") + DB_ban_unban(M.ckey, BANTYPE_ANY_JOB, "appearance") + if(M.client) + jobban_buildcache(M.client) + message_admins("[key_name_admin(usr)] removed [key_name_admin(M)]'s appearance ban.") + to_chat(M, "[usr.client.key] has removed your appearance ban.") + + else switch(alert("Appearance ban [M.key]?",,"Yes","No", "Cancel")) + if("Yes") + var/reason = input(usr,"Please State Reason.","Reason") as message|null + if(!reason) + return + var/severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None") + if(!severity) + return + if(!DB_ban_record(BANTYPE_JOB_PERMA, M, -1, reason, "appearance")) + to_chat(usr, "Failed to apply ban.") + return + if(M.client) + jobban_buildcache(M.client) + ban_unban_log_save("[key_name(usr)] appearance banned [key_name(M)]. reason: [reason]") + log_admin_private("[key_name(usr)] appearance banned [key_name(M)]. \nReason: [reason]") + create_message("note", M.key, null, "Appearance banned - [reason]", null, null, 0, 0, null, 0, severity) + message_admins("[key_name_admin(usr)] appearance banned [key_name_admin(M)].") + to_chat(M, "You have been appearance banned by [usr.client.key].") + to_chat(M, "The reason is: [reason]") + to_chat(M, "Appearance ban can be lifted only upon request.") + var/bran = CONFIG_GET(string/banappeals) + if(bran) + to_chat(M, "To try to resolve this matter head to [bran]") + else + to_chat(M, "No ban appeals URL has been set.") + if("No") + return + + else if(href_list["jobban2"]) + if(!check_rights(R_BAN)) + return + var/mob/M = locate(href_list["jobban2"]) + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob.") + return + + if(!M.ckey) //sanity + to_chat(usr, "This mob has no ckey.") + return + + var/dat = "Job-Ban Panel: [key_name(M)]" + + /***********************************WARNING!************************************ + The jobban stuff looks mangled and disgusting + But it looks beautiful in-game + -Nodrak + ************************************WARNING!***********************************/ + var/counter = 0 +//Regular jobs + //Command (Blue) + dat += "" + dat += "" + for(var/jobPos in GLOB.command_positions) + if(!jobPos) + continue + if(jobban_isbanned(M, jobPos)) + dat += "" + counter++ + else + dat += "" + counter++ + + if(counter >= 6) //So things dont get squiiiiished! + dat += "" + counter = 0 + dat += "
    Command Positions
    [jobPos][jobPos]
    " + + //Security (Red) + counter = 0 + dat += "" + dat += "" + for(var/jobPos in GLOB.security_positions) + if(!jobPos) + continue + if(jobban_isbanned(M, jobPos)) + dat += "" + counter++ + else + dat += "" + counter++ + + if(counter >= 5) //So things dont get squiiiiished! + dat += "" + counter = 0 + dat += "
    Security Positions
    [jobPos][jobPos]
    " + + //Engineering (Yellow) + counter = 0 + dat += "" + dat += "" + for(var/jobPos in GLOB.engineering_positions) + if(!jobPos) + continue + if(jobban_isbanned(M, jobPos)) + dat += "" + counter++ + else + dat += "" + counter++ + + if(counter >= 5) //So things dont get squiiiiished! + dat += "" + counter = 0 + dat += "
    Engineering Positions
    [jobPos][jobPos]
    " + + //Medical (White) + counter = 0 + dat += "" + dat += "" + for(var/jobPos in GLOB.medical_positions) + if(!jobPos) + continue + if(jobban_isbanned(M, jobPos)) + dat += "" + counter++ + else + dat += "" + counter++ + + if(counter >= 5) //So things dont get squiiiiished! + dat += "" + counter = 0 + dat += "
    Medical Positions
    [jobPos][jobPos]
    " + + //Science (Purple) + counter = 0 + dat += "" + dat += "" + for(var/jobPos in GLOB.science_positions) + if(!jobPos) + continue + if(jobban_isbanned(M, jobPos)) + dat += "" + counter++ + else + dat += "" + counter++ + + if(counter >= 5) //So things dont get squiiiiished! + dat += "" + counter = 0 + dat += "
    Science Positions
    [jobPos][jobPos]
    " + + //Supply (Brown) + counter = 0 + dat += "" + dat += "" + for(var/jobPos in GLOB.supply_positions) + if(!jobPos) + continue + if(jobban_isbanned(M, jobPos)) + dat += "" + counter++ + else + dat += "" + counter++ + + if(counter >= 5) //So things dont get COPYPASTE! + dat += "" + counter = 0 + dat += "
    Supply Positions
    [jobPos][jobPos]
    " + + //Civilian (Grey) + counter = 0 + dat += "" + dat += "" + for(var/jobPos in GLOB.civilian_positions) + if(!jobPos) + continue + if(jobban_isbanned(M, jobPos)) + dat += "" + counter++ + else + dat += "" + counter++ + + if(counter >= 5) //So things dont get squiiiiished! + dat += "" + counter = 0 + dat += "
    Civilian Positions
    [jobPos][jobPos]
    " + + //Non-Human (Green) + counter = 0 + dat += "" + dat += "" + for(var/jobPos in GLOB.nonhuman_positions) + if(!jobPos) + continue + if(jobban_isbanned(M, jobPos)) + dat += "" + counter++ + else + dat += "" + counter++ + + if(counter >= 5) //So things dont get squiiiiished! + dat += "" + counter = 0 + + dat += "
    Non-human Positions
    [jobPos][jobPos]
    " + + //Ghost Roles (light light gray) + dat += "" + dat += "" + + //pAI + if(jobban_isbanned(M, ROLE_PAI)) + dat += "" + else + dat += "" + + + //Drones + if(jobban_isbanned(M, ROLE_DRONE)) + dat += "" + else + dat += "" + + + //Positronic Brains + if(jobban_isbanned(M, ROLE_POSIBRAIN)) + dat += "" + else + dat += "" + + //Sentience Potion Spawn + if(jobban_isbanned(M, ROLE_SENTIENCE)) + dat += "" + else + dat += "" + + //Deathsquad + if(jobban_isbanned(M, ROLE_DEATHSQUAD)) + dat += "" + else + dat += "" + + //Lavaland roles + if(jobban_isbanned(M, ROLE_LAVALAND)) + dat += "" + else + dat += "" + + dat += "
    Ghost Roles
    pAIpAIDroneDronePosibrainPosibrainSentience Potion SpawnSentience Potion SpawnDeathsquadDeathsquadLavalandLavaland
    " + + //Antagonist (Orange) + var/isbanned_dept = jobban_isbanned(M, ROLE_SYNDICATE) + dat += "" + dat += "" + + //Traitor + if(jobban_isbanned(M, ROLE_TRAITOR) || isbanned_dept) + dat += "" + else + dat += "" + + //Changeling + if(jobban_isbanned(M, ROLE_CHANGELING) || isbanned_dept) + dat += "" + else + dat += "" + + //Nuke Operative + if(jobban_isbanned(M, ROLE_OPERATIVE) || isbanned_dept) + dat += "" + else + dat += "" + + //Revolutionary + if(jobban_isbanned(M, ROLE_REV) || isbanned_dept) + dat += "" + else + dat += "" + + //Cultist + if(jobban_isbanned(M, ROLE_CULTIST) || isbanned_dept) + dat += "" + else + dat += "" + + dat += "" //So things dont get squished. + + //Servant of Ratvar + if(jobban_isbanned(M, ROLE_SERVANT_OF_RATVAR) || isbanned_dept) + dat += "" + else + dat += "" + + //Wizard + if(jobban_isbanned(M, ROLE_WIZARD) || isbanned_dept) + dat += "" + else + dat += "" + + //Abductor + if(jobban_isbanned(M, ROLE_ABDUCTOR) || isbanned_dept) + dat += "" + else + dat += "" + + //Alien + if(jobban_isbanned(M, ROLE_ALIEN) || isbanned_dept) + dat += "" + else + dat += "" + + //Gang + if(jobban_isbanned(M, ROLE_GANG) || isbanned_dept) + dat += "" + else + dat += "" + + + //Other Roles (black) + dat += "
    Antagonist Positions | " + dat += "Team Antagonists | " + dat += "Conversion Antagonists
    TraitorTraitorChangelingChangelingNuke OperativeNuke OperativeRevolutionaryRevolutionaryCultistCultist
    ServantServantWizardWizardAbductorAbductorAlienAlienGangGang
    " + dat += "" + + //Mind Transfer Potion + if(jobban_isbanned(M, ROLE_MIND_TRANSFER)) + dat += "" + else + dat += "" + + dat += "
    Other Roles
    Mind Transfer PotionMind Transfer Potion
    " + usr << browse(dat, "window=jobban2;size=800x450") + return + + //JOBBAN'S INNARDS + else if(href_list["jobban3"]) + if(!check_rights(R_BAN)) + return + var/mob/M = locate(href_list["jobban4"]) + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob") + return + if(!SSjob) + to_chat(usr, "Jobs subsystem not initialized yet!") + return + //get jobs for department if specified, otherwise just return the one job in a list. + var/list/joblist = list() + switch(href_list["jobban3"]) + if("commanddept") + for(var/jobPos in GLOB.command_positions) + if(!jobPos) + continue + joblist += jobPos + if("securitydept") + for(var/jobPos in GLOB.security_positions) + if(!jobPos) + continue + joblist += jobPos + if("engineeringdept") + for(var/jobPos in GLOB.engineering_positions) + if(!jobPos) + continue + joblist += jobPos + if("medicaldept") + for(var/jobPos in GLOB.medical_positions) + if(!jobPos) + continue + joblist += jobPos + if("sciencedept") + for(var/jobPos in GLOB.science_positions) + if(!jobPos) + continue + joblist += jobPos + if("supplydept") + for(var/jobPos in GLOB.supply_positions) + if(!jobPos) + continue + joblist += jobPos + if("civiliandept") + for(var/jobPos in GLOB.civilian_positions) + if(!jobPos) + continue + joblist += jobPos + if("nonhumandept") + for(var/jobPos in GLOB.nonhuman_positions) + if(!jobPos) + continue + joblist += jobPos + if("ghostroles") + joblist += list(ROLE_PAI, ROLE_POSIBRAIN, ROLE_DRONE , ROLE_DEATHSQUAD, ROLE_LAVALAND, ROLE_SENTIENCE) + if("teamantags") + joblist += list(ROLE_OPERATIVE, ROLE_REV, ROLE_CULTIST, ROLE_SERVANT_OF_RATVAR, ROLE_ABDUCTOR, ROLE_ALIEN, ROLE_GANG) + if("convertantags") + joblist += list(ROLE_REV, ROLE_CULTIST, ROLE_SERVANT_OF_RATVAR, ROLE_ALIEN) + if("otherroles") + joblist += list(ROLE_MIND_TRANSFER) + else + joblist += href_list["jobban3"] + + //Create a list of unbanned jobs within joblist + var/list/notbannedlist = list() + for(var/job in joblist) + if(!jobban_isbanned(M, job)) + notbannedlist += job + + //Banning comes first + if(notbannedlist.len) //at least 1 unbanned job exists in joblist so we have stuff to ban. + var/severity = null + switch(alert("Temporary Ban for [M.key]?",,"Yes","No", "Cancel")) + if("Yes") + var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null + if(mins <= 0) + to_chat(usr, "[mins] is not a valid duration.") + return + var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null + if(!reason) + return + severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None") + if(!severity) + return + var/msg + for(var/job in notbannedlist) + if(!DB_ban_record(BANTYPE_JOB_TEMP, M, mins, reason, job)) + to_chat(usr, "Failed to apply ban.") + return + if(M.client) + jobban_buildcache(M.client) + ban_unban_log_save("[key_name(usr)] temp-jobbanned [key_name(M)] from [job] for [mins] minutes. reason: [reason]") + log_admin_private("[key_name(usr)] temp-jobbanned [key_name(M)] from [job] for [mins] minutes.") + if(!msg) + msg = job + else + msg += ", [job]" + create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0, severity) + message_admins("[key_name_admin(usr)] banned [key_name_admin(M)] from [msg] for [mins] minutes.") + to_chat(M, "You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg].") + to_chat(M, "The reason is: [reason]") + to_chat(M, "This jobban will be lifted in [mins] minutes.") + href_list["jobban2"] = 1 // lets it fall through and refresh + return 1 + if("No") + var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null + severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None") + if(!severity) + return + if(reason) + var/msg + for(var/job in notbannedlist) + if(!DB_ban_record(BANTYPE_JOB_PERMA, M, -1, reason, job)) + to_chat(usr, "Failed to apply ban.") + return + if(M.client) + jobban_buildcache(M.client) + ban_unban_log_save("[key_name(usr)] perma-jobbanned [key_name(M)] from [job]. reason: [reason]") + log_admin_private("[key_name(usr)] perma-banned [key_name(M)] from [job]") + if(!msg) + msg = job + else + msg += ", [job]" + create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0, severity) + message_admins("[key_name_admin(usr)] banned [key_name_admin(M)] from [msg].") + to_chat(M, "You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg].") + to_chat(M, "The reason is: [reason]") + to_chat(M, "Jobban can be lifted only upon request.") + href_list["jobban2"] = 1 // lets it fall through and refresh + return 1 + if("Cancel") + return + + //Unbanning joblist + //all jobs in joblist are banned already OR we didn't give a reason (implying they shouldn't be banned) + if(joblist.len) //at least 1 banned job exists in joblist so we have stuff to unban. + var/msg + for(var/job in joblist) + var/reason = jobban_isbanned(M, job) + if(!reason) + continue //skip if it isn't jobbanned anyway + switch(alert("Job: '[job]' Reason: '[reason]' Un-jobban?","Please Confirm","Yes","No")) + if("Yes") + ban_unban_log_save("[key_name(usr)] unjobbanned [key_name(M)] from [job]") + log_admin_private("[key_name(usr)] unbanned [key_name(M)] from [job]") + DB_ban_unban(M.ckey, BANTYPE_ANY_JOB, job) + if(M.client) + jobban_buildcache(M.client) + if(!msg) + msg = job + else + msg += ", [job]" + else + continue + if(msg) + message_admins("[key_name_admin(usr)] unbanned [key_name_admin(M)] from [msg].") + to_chat(M, "You have been un-jobbanned by [usr.client.key] from [msg].") + href_list["jobban2"] = 1 // lets it fall through and refresh + return 1 + return 0 //we didn't do anything! + + else if(href_list["boot2"]) + if(!check_rights(R_ADMIN)) + return + var/mob/M = locate(href_list["boot2"]) + if(ismob(M)) + if(!check_if_greater_rights_than(M.client)) + to_chat(usr, "Error: They have more rights than you do.") + return + if(alert(usr, "Kick [key_name(M)]?", "Confirm", "Yes", "No") != "Yes") + return + if(!M) + to_chat(usr, "Error: [M] no longer exists!") + return + if(!M.client) + to_chat(usr, "Error: [M] no longer has a client!") + return + to_chat(M, "You have been kicked from the server by [usr.client.holder.fakekey ? "an Administrator" : "[usr.client.key]"].") + log_admin("[key_name(usr)] kicked [key_name(M)].") + message_admins("[key_name_admin(usr)] kicked [key_name_admin(M)].") + qdel(M.client) + + else if(href_list["addmessage"]) + if(!check_rights(R_ADMIN)) + return + var/target_key = href_list["addmessage"] + create_message("message", target_key, secret = 0) + + else if(href_list["addnote"]) + if(!check_rights(R_ADMIN)) + return + var/target_key = href_list["addnote"] + create_message("note", target_key) + + else if(href_list["addwatch"]) + if(!check_rights(R_ADMIN)) + return + var/target_key = href_list["addwatch"] + create_message("watchlist entry", target_key, secret = 1) + + else if(href_list["addmemo"]) + if(!check_rights(R_ADMIN)) + return + create_message("memo", secret = 0, browse = 1) + + else if(href_list["addmessageempty"]) + if(!check_rights(R_ADMIN)) + return + create_message("message", secret = 0) + + else if(href_list["addnoteempty"]) + if(!check_rights(R_ADMIN)) + return + create_message("note") + + else if(href_list["addwatchempty"]) + if(!check_rights(R_ADMIN)) + return + create_message("watchlist entry", secret = 1) + + else if(href_list["deletemessage"]) + if(!check_rights(R_ADMIN)) + return + var/safety = alert("Delete message/note?",,"Yes","No"); + if (safety == "Yes") + var/message_id = href_list["deletemessage"] + delete_message(message_id) + + else if(href_list["deletemessageempty"]) + if(!check_rights(R_ADMIN)) + return + var/safety = alert("Delete message/note?",,"Yes","No"); + if (safety == "Yes") + var/message_id = href_list["deletemessageempty"] + delete_message(message_id, browse = TRUE) + + else if(href_list["editmessage"]) + if(!check_rights(R_ADMIN)) + return + var/message_id = href_list["editmessage"] + edit_message(message_id) + + else if(href_list["editmessageempty"]) + if(!check_rights(R_ADMIN)) + return + var/message_id = href_list["editmessageempty"] + edit_message(message_id, browse = 1) + + else if(href_list["editmessageexpiry"]) + if(!check_rights(R_ADMIN)) + return + var/message_id = href_list["editmessageexpiry"] + edit_message_expiry(message_id) + + else if(href_list["editmessageexpiryempty"]) + if(!check_rights(R_ADMIN)) + return + var/message_id = href_list["editmessageexpiryempty"] + edit_message_expiry(message_id, browse = 1) + + else if(href_list["editmessageseverity"]) + if(!check_rights(R_ADMIN)) + return + var/message_id = href_list["editmessageseverity"] + edit_message_severity(message_id) + + else if(href_list["secretmessage"]) + if(!check_rights(R_ADMIN)) + return + var/message_id = href_list["secretmessage"] + toggle_message_secrecy(message_id) + + else if(href_list["searchmessages"]) + if(!check_rights(R_ADMIN)) + return + var/target = href_list["searchmessages"] + browse_messages(index = target) + + else if(href_list["nonalpha"]) + if(!check_rights(R_ADMIN)) + return + var/target = href_list["nonalpha"] + target = text2num(target) + browse_messages(index = target) + + else if(href_list["showmessages"]) + if(!check_rights(R_ADMIN)) + return + var/target = href_list["showmessages"] + browse_messages(index = target) + + else if(href_list["showmemo"]) + if(!check_rights(R_ADMIN)) + return + browse_messages("memo") + + else if(href_list["showwatch"]) + if(!check_rights(R_ADMIN)) + return + browse_messages("watchlist entry") + + else if(href_list["showwatchfilter"]) + if(!check_rights(R_ADMIN)) + return + browse_messages("watchlist entry", filter = 1) + + else if(href_list["showmessageckey"]) + if(!check_rights(R_ADMIN)) + return + var/target = href_list["showmessageckey"] + var/agegate = TRUE + if (href_list["showall"]) + agegate = FALSE + browse_messages(target_ckey = target, agegate = agegate) + + else if(href_list["showmessageckeylinkless"]) + var/target = href_list["showmessageckeylinkless"] + browse_messages(target_ckey = target, linkless = 1) + + else if(href_list["messageedits"]) + if(!check_rights(R_ADMIN)) + return + var/message_id = sanitizeSQL("[href_list["messageedits"]]") + var/datum/DBQuery/query_get_message_edits = SSdbcore.NewQuery("SELECT edits FROM [format_table_name("messages")] WHERE id = '[message_id]'") + if(!query_get_message_edits.warn_execute()) + qdel(query_get_message_edits) + return + if(query_get_message_edits.NextRow()) + var/edit_log = query_get_message_edits.item[1] + if(!QDELETED(usr)) + var/datum/browser/browser = new(usr, "Note edits", "Note edits") + browser.set_content(jointext(edit_log, "")) + browser.open() + qdel(query_get_message_edits) + + else if(href_list["newban"]) + if(!check_rights(R_BAN)) + return + + var/mob/M = locate(href_list["newban"]) + if(!ismob(M)) + return + + if(M.client && M.client.holder) + return //admins cannot be banned. Even if they could, the ban doesn't affect them anyway + + switch(alert("Temporary Ban for [M.key]?",,"Yes","No", "Cancel")) + if("Yes") + var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null + if(mins <= 0) + to_chat(usr, "[mins] is not a valid duration.") + return + var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null + if(!reason) + return + if(!DB_ban_record(BANTYPE_TEMP, M, mins, reason)) + to_chat(usr, "Failed to apply ban.") + return + AddBan(M.ckey, M.computer_id, reason, usr.ckey, 1, mins) + ban_unban_log_save("[key_name(usr)] has banned [key_name(M)]. - Reason: [reason] - This will be removed in [mins] minutes.") + to_chat(M, "You have been banned by [usr.client.key].\nReason: [reason]") + to_chat(M, "This is a temporary ban, it will be removed in [mins] minutes. The round ID is [GLOB.round_id].") + var/bran = CONFIG_GET(string/banappeals) + if(bran) + to_chat(M, "To try to resolve this matter head to [bran]") + else + to_chat(M, "No ban appeals URL has been set.") + log_admin_private("[key_name(usr)] has banned [key_name(M)].\nReason: [key_name(M)]\nThis will be removed in [mins] minutes.") + var/msg = "[key_name_admin(usr)] has banned [key_name_admin(M)].\nReason: [reason]\nThis will be removed in [mins] minutes." + message_admins(msg) + var/datum/admin_help/AH = M.client ? M.client.current_ticket : null + if(AH) + AH.Resolve() + qdel(M.client) + if("No") + var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null + if(!reason) + return + switch(alert(usr,"IP ban?",,"Yes","No","Cancel")) + if("Cancel") + return + if("Yes") + AddBan(M.ckey, M.computer_id, reason, usr.ckey, 0, 0, M.lastKnownIP) + if("No") + AddBan(M.ckey, M.computer_id, reason, usr.ckey, 0, 0) + to_chat(M, "You have been banned by [usr.client.key].\nReason: [reason]") + to_chat(M, "This is a permanent ban. The round ID is [GLOB.round_id].") + var/bran = CONFIG_GET(string/banappeals) + if(bran) + to_chat(M, "To try to resolve this matter head to [bran]") + else + to_chat(M, "No ban appeals URL has been set.") + if(!DB_ban_record(BANTYPE_PERMA, M, -1, reason)) + to_chat(usr, "Failed to apply ban.") + return + ban_unban_log_save("[key_name(usr)] has permabanned [key_name(M)]. - Reason: [reason] - This is a permanent ban.") + log_admin_private("[key_name(usr)] has banned [key_name(M)].\nReason: [reason]\nThis is a permanent ban.") + var/msg = "[key_name_admin(usr)] has banned [key_name_admin(M)].\nReason: [reason]\nThis is a permanent ban." + message_admins(msg) + var/datum/admin_help/AH = M.client ? M.client.current_ticket : null + if(AH) + AH.Resolve() + qdel(M.client) + if("Cancel") + return + + else if(href_list["mute"]) + if(!check_rights(R_ADMIN)) + return + cmd_admin_mute(href_list["mute"], text2num(href_list["mute_type"])) + + else if(href_list["c_mode"]) + return HandleCMode() + + else if(href_list["f_secret"]) + return HandleFSecret() + +//Dynamic mode + else if(href_list["f_dynamic_roundstart"]) + if(!check_rights(R_ADMIN)) + return + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode.", null, null, null, null) + var/roundstart_rules = list() + for (var/rule in subtypesof(/datum/dynamic_ruleset/roundstart)) + var/datum/dynamic_ruleset/roundstart/newrule = new rule() + roundstart_rules[newrule.name] = newrule + var/added_rule = input(usr,"What ruleset do you want to force? This will bypass threat level and population restrictions.", "Rigging Roundstart", null) as null|anything in roundstart_rules + if (added_rule) + GLOB.dynamic_forced_roundstart_ruleset += roundstart_rules[added_rule] + log_admin("[key_name(usr)] set [added_rule] to be a forced roundstart ruleset.") + message_admins("[key_name(usr)] set [added_rule] to be a forced roundstart ruleset.", 1) + Game() + + else if(href_list["f_dynamic_roundstart_clear"]) + if(!check_rights(R_ADMIN)) + return + GLOB.dynamic_forced_roundstart_ruleset = list() + Game() + log_admin("[key_name(usr)] cleared the rigged roundstart rulesets. The mode will pick them as normal.") + message_admins("[key_name(usr)] cleared the rigged roundstart rulesets. The mode will pick them as normal.", 1) + + else if(href_list["f_dynamic_roundstart_remove"]) + if(!check_rights(R_ADMIN)) + return + var/datum/dynamic_ruleset/roundstart/rule = locate(href_list["f_dynamic_roundstart_remove"]) + GLOB.dynamic_forced_roundstart_ruleset -= rule + Game() + log_admin("[key_name(usr)] removed [rule] from the forced roundstart rulesets.") + message_admins("[key_name(usr)] removed [rule] from the forced roundstart rulesets.", 1) + + else if(href_list["f_dynamic_latejoin"]) + if(!check_rights(R_ADMIN)) + return + if(!SSticker || !SSticker.mode) + return alert(usr, "The game must start first.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + var/latejoin_rules = list() + for (var/rule in subtypesof(/datum/dynamic_ruleset/latejoin)) + var/datum/dynamic_ruleset/latejoin/newrule = new rule() + latejoin_rules[newrule.name] = newrule + var/added_rule = input(usr,"What ruleset do you want to force upon the next latejoiner? This will bypass threat level and population restrictions.", "Rigging Latejoin", null) as null|anything in latejoin_rules + if (added_rule) + var/datum/game_mode/dynamic/mode = SSticker.mode + mode.forced_latejoin_rule = latejoin_rules[added_rule] + log_admin("[key_name(usr)] set [added_rule] to proc on the next latejoin.") + message_admins("[key_name(usr)] set [added_rule] to proc on the next latejoin.", 1) + Game() + + else if(href_list["f_dynamic_latejoin_clear"]) + if(!check_rights(R_ADMIN)) + return + if (SSticker && SSticker.mode && istype(SSticker.mode,/datum/game_mode/dynamic)) + var/datum/game_mode/dynamic/mode = SSticker.mode + mode.forced_latejoin_rule = null + Game() + log_admin("[key_name(usr)] cleared the forced latejoin ruleset.") + message_admins("[key_name(usr)] cleared the forced latejoin ruleset.", 1) + + else if(href_list["f_dynamic_midround"]) + if(!check_rights(R_ADMIN)) + return + if(!SSticker || !SSticker.mode) + return alert(usr, "The game must start first.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + var/midround_rules = list() + for (var/rule in subtypesof(/datum/dynamic_ruleset/midround)) + var/datum/dynamic_ruleset/midround/newrule = new rule() + midround_rules[newrule.name] = rule + var/added_rule = input(usr,"What ruleset do you want to force right now? This will bypass threat level and population restrictions.", "Execute Ruleset", null) as null|anything in midround_rules + if (added_rule) + var/datum/game_mode/dynamic/mode = SSticker.mode + log_admin("[key_name(usr)] executed the [added_rule] ruleset.") + message_admins("[key_name(usr)] executed the [added_rule] ruleset.", 1) + mode.picking_specific_rule(midround_rules[added_rule],1) + + else if (href_list["f_dynamic_options"]) + if(!check_rights(R_ADMIN)) + return + + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_roundstart_centre"]) + if(!check_rights(R_ADMIN)) + return + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + var/new_centre = input(usr,"Change the centre of the dynamic mode threat curve. A negative value will give a more peaceful round ; a positive value, a round with higher threat. Any number between -5 and +5 is allowed.", "Change curve centre", null) as num + if (new_centre < -5 || new_centre > 5) + return alert(usr, "Only values between -5 and +5 are allowed.", null, null, null, null) + + log_admin("[key_name(usr)] changed the distribution curve center to [new_centre].") + message_admins("[key_name(usr)] changed the distribution curve center to [new_centre]", 1) + GLOB.dynamic_curve_centre = new_centre + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_roundstart_width"]) + if(!check_rights(R_ADMIN)) + return + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + var/new_width = input(usr,"Change the width of the dynamic mode threat curve. A higher value will favour extreme rounds ; a lower value, a round closer to the average. Any Number between 0.5 and 4 are allowed.", "Change curve width", null) as num + if (new_width < 0.5 || new_width > 4) + return alert(usr, "Only values between 0.5 and +2.5 are allowed.", null, null, null, null) + + log_admin("[key_name(usr)] changed the distribution curve width to [new_width].") + message_admins("[key_name(usr)] changed the distribution curve width to [new_width]", 1) + GLOB.dynamic_curve_width = new_width + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_roundstart_latejoin_min"]) + if(!check_rights(R_ADMIN)) + return + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + var/new_min = input(usr,"Change the minimum delay of latejoin injection in minutes.", "Change latejoin injection delay minimum", null) as num + if(new_min <= 0) + return alert(usr, "The minimum can't be zero or lower.", null, null, null, null) + if((new_min MINUTES) > GLOB.dynamic_latejoin_delay_max) + return alert(usr, "The minimum must be lower than the maximum.", null, null, null, null) + + log_admin("[key_name(usr)] changed the latejoin injection minimum delay to [new_min] minutes.") + message_admins("[key_name(usr)] changed the latejoin injection minimum delay to [new_min] minutes", 1) + GLOB.dynamic_latejoin_delay_min = (new_min MINUTES) + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_roundstart_latejoin_max"]) + if(!check_rights(R_ADMIN)) + return + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + var/new_max = input(usr,"Change the maximum delay of latejoin injection in minutes.", "Change latejoin injection delay maximum", null) as num + if(new_max <= 0) + return alert(usr, "The maximum can't be zero or lower.", null, null, null, null) + if((new_max MINUTES) < GLOB.dynamic_latejoin_delay_min) + return alert(usr, "The maximum must be higher than the minimum.", null, null, null, null) + + log_admin("[key_name(usr)] changed the latejoin injection maximum delay to [new_max] minutes.") + message_admins("[key_name(usr)] changed the latejoin injection maximum delay to [new_max] minutes", 1) + GLOB.dynamic_latejoin_delay_max = (new_max MINUTES) + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_roundstart_midround_min"]) + if(!check_rights(R_ADMIN)) + return + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + var/new_min = input(usr,"Change the minimum delay of midround injection in minutes.", "Change midround injection delay minimum", null) as num + if(new_min <= 0) + return alert(usr, "The minimum can't be zero or lower.", null, null, null, null) + if((new_min MINUTES) > GLOB.dynamic_midround_delay_max) + return alert(usr, "The minimum must be lower than the maximum.", null, null, null, null) + + log_admin("[key_name(usr)] changed the midround injection minimum delay to [new_min] minutes.") + message_admins("[key_name(usr)] changed the midround injection minimum delay to [new_min] minutes", 1) + GLOB.dynamic_midround_delay_min = (new_min MINUTES) + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_roundstart_midround_max"]) + if(!check_rights(R_ADMIN)) + return + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + var/new_max = input(usr,"Change the maximum delay of midround injection in minutes.", "Change midround injection delay maximum", null) as num + if(new_max <= 0) + return alert(usr, "The maximum can't be zero or lower.", null, null, null, null) + if((new_max MINUTES) > GLOB.dynamic_midround_delay_max) + return alert(usr, "The maximum must be higher than the minimum.", null, null, null, null) + + log_admin("[key_name(usr)] changed the midround injection maximum delay to [new_max] minutes.") + message_admins("[key_name(usr)] changed the midround injection maximum delay to [new_max] minutes", 1) + GLOB.dynamic_midround_delay_max = (new_max MINUTES) + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_force_extended"]) + if(!check_rights(R_ADMIN)) + return + + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + GLOB.dynamic_forced_extended = !GLOB.dynamic_forced_extended + log_admin("[key_name(usr)] set 'forced_extended' to [GLOB.dynamic_forced_extended].") + message_admins("[key_name(usr)] set 'forced_extended' to [GLOB.dynamic_forced_extended].") + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_no_stacking"]) + if(!check_rights(R_ADMIN)) + return + + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + GLOB.dynamic_no_stacking = !GLOB.dynamic_no_stacking + log_admin("[key_name(usr)] set 'no_stacking' to [GLOB.dynamic_no_stacking].") + message_admins("[key_name(usr)] set 'no_stacking' to [GLOB.dynamic_no_stacking].") + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_classic_secret"]) + if(!check_rights(R_ADMIN)) + return + + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + GLOB.dynamic_classic_secret = !GLOB.dynamic_classic_secret + log_admin("[key_name(usr)] set 'classic_secret' to [GLOB.dynamic_classic_secret].") + message_admins("[key_name(usr)] set 'classic_secret' to [GLOB.dynamic_classic_secret].") + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_stacking_limit"]) + if(!check_rights(R_ADMIN)) + return + + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + GLOB.dynamic_stacking_limit = input(usr,"Change the threat limit at which round-endings rulesets will start to stack.", "Change stacking limit", null) as num + log_admin("[key_name(usr)] set 'stacking_limit' to [GLOB.dynamic_stacking_limit].") + message_admins("[key_name(usr)] set 'stacking_limit' to [GLOB.dynamic_stacking_limit].") + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_high_pop_limit"]) + if(!check_rights(R_ADMIN)) + return + + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + var/new_value = input(usr, "Enter the high-pop override threshold for dynamic mode.", "High pop override") as num + if (new_value < 0) + return alert(usr, "Only positive values allowed!", null, null, null, null) + GLOB.dynamic_high_pop_limit = new_value + + log_admin("[key_name(usr)] set 'high_pop_limit' to [GLOB.dynamic_high_pop_limit].") + message_admins("[key_name(usr)] set 'high_pop_limit' to [GLOB.dynamic_high_pop_limit].") + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_forced_threat"]) + if(!check_rights(R_ADMIN)) + return + + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + var/new_value = input(usr, "Enter the forced threat level for dynamic mode.", "Forced threat level") as num + if (new_value > 100) + return alert(usr, "The value must be be under 100.", null, null, null, null) + GLOB.dynamic_forced_threat_level = new_value + + log_admin("[key_name(usr)] set 'forced_threat_level' to [GLOB.dynamic_forced_threat_level].") + message_admins("[key_name(usr)] set 'forced_threat_level' to [GLOB.dynamic_forced_threat_level].") + dynamic_mode_options(usr) + + else if(href_list["f_dynamic_chaos_level"]) + if(!check_rights(R_ADMIN)) + return + + if(SSticker && SSticker.mode) + return alert(usr, "The game has already started.", null, null, null, null) + + if(GLOB.master_mode != "dynamic") + return alert(usr, "The game mode has to be dynamic mode!", null, null, null, null) + + var/new_value = input(usr, "Enter the chaos level for dynamic mode.", "Chaos level") as num + if (new_value > 5 || new_value < 0) + return alert(usr, "The value must be between 0 and 5.", null, null, null, null) + GLOB.dynamic_chaos_level = new_value + + log_admin("[key_name(usr)] set 'dynamic_chaos_level' to [GLOB.dynamic_chaos_level].") + message_admins("[key_name(usr)] set 'dynamic_chaos_level' to [GLOB.dynamic_chaos_level].") + dynamic_mode_options(usr) +//End Dynamic mode + + else if(href_list["c_mode2"]) + if(!check_rights(R_ADMIN|R_SERVER)) + return + + if (SSticker.HasRoundStarted()) + return alert(usr, "The game has already started.", null, null, null, null) + GLOB.master_mode = href_list["c_mode2"] + log_admin("[key_name(usr)] set the mode as [GLOB.master_mode].") + message_admins("[key_name_admin(usr)] set the mode as [GLOB.master_mode].") + to_chat(world, "The mode is now: [GLOB.master_mode]") + Game() // updates the main game menu + SSticker.save_mode(GLOB.master_mode) + HandleCMode() + + else if(href_list["f_secret2"]) + if(!check_rights(R_ADMIN|R_SERVER)) + return + + if(SSticker.HasRoundStarted()) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "secret") + return alert(usr, "The game mode has to be secret!", null, null, null, null) + GLOB.secret_force_mode = href_list["f_secret2"] + log_admin("[key_name(usr)] set the forced secret mode as [GLOB.secret_force_mode].") + message_admins("[key_name_admin(usr)] set the forced secret mode as [GLOB.secret_force_mode].") + Game() // updates the main game menu + HandleFSecret() + + else if(href_list["monkeyone"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/living/carbon/human/H = locate(href_list["monkeyone"]) + if(!istype(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") + return + + log_admin("[key_name(usr)] attempting to monkeyize [key_name(H)].") + message_admins("[key_name_admin(usr)] attempting to monkeyize [key_name_admin(H)].") + H.monkeyize() + + else if(href_list["humanone"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/living/carbon/monkey/Mo = locate(href_list["humanone"]) + if(!istype(Mo)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/monkey.") + return + + log_admin("[key_name(usr)] attempting to humanize [key_name(Mo)].") + message_admins("[key_name_admin(usr)] attempting to humanize [key_name_admin(Mo)].") + Mo.humanize() + + else if(href_list["corgione"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/living/carbon/human/H = locate(href_list["corgione"]) + if(!istype(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") + return + + log_admin("[key_name(usr)] attempting to corgize [key_name(H)].") + message_admins("[key_name_admin(usr)] attempting to corgize [key_name_admin(H)].") + H.corgize() + + + else if(href_list["forcespeech"]) + if(!check_rights(R_FUN)) + return + + var/mob/M = locate(href_list["forcespeech"]) + if(!ismob(M)) + to_chat(usr, "this can only be used on instances of type /mob.") + + var/speech = input("What will [key_name(M)] say?", "Force speech", "")// Don't need to sanitize, since it does that in say(), we also trust our admins. + if(!speech) + return + M.say(speech, forced = "admin speech") + speech = sanitize(speech) // Nah, we don't trust them + log_admin("[key_name(usr)] forced [key_name(M)] to say: [speech]") + message_admins("[key_name_admin(usr)] forced [key_name_admin(M)] to say: [speech]") + + else if(href_list["makeeligible"]) + if(!check_rights(R_ADMIN)) + return + var/mob/M = locate(href_list["makeeligible"]) + if(!ismob(M)) + to_chat(usr, "this can only be used on instances of type /mob.") + if(M.ckey in GLOB.client_ghost_timeouts) + GLOB.client_ghost_timeouts -= M.ckey + + else if(href_list["sendtoprison"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["sendtoprison"]) + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob.") + return + if(isAI(M)) + to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") + return + + if(alert(usr, "Send [key_name(M)] to Prison?", "Message", "Yes", "No") != "Yes") + return + + M.forceMove(pick(GLOB.prisonwarp)) + to_chat(M, "You have been sent to Prison!") + + log_admin("[key_name(usr)] has sent [key_name(M)] to Prison!") + message_admins("[key_name_admin(usr)] has sent [key_name_admin(M)] to Prison!") + + else if(href_list["sendbacktolobby"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["sendbacktolobby"]) + + if(!isobserver(M)) + to_chat(usr, "You can only send ghost players back to the Lobby.") + return + + if(!M.client) + to_chat(usr, "[M] doesn't seem to have an active client.") + return + + if(alert(usr, "Send [key_name(M)] back to Lobby?", "Message", "Yes", "No") != "Yes") + return + + log_admin("[key_name(usr)] has sent [key_name(M)] back to the Lobby.") + message_admins("[key_name(usr)] has sent [key_name(M)] back to the Lobby.") + + var/mob/dead/new_player/NP = new() + NP.ckey = M.ckey + qdel(M) + + else if(href_list["tdome1"]) + if(!check_rights(R_FUN)) + return + + if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") + return + + var/mob/M = locate(href_list["tdome1"]) + if(!isliving(M)) + to_chat(usr, "This can only be used on instances of type /mob/living.") + return + if(isAI(M)) + to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") + return + var/mob/living/L = M + + for(var/obj/item/I in L) + L.dropItemToGround(I, TRUE) + + L.Unconscious(100) + sleep(5) + L.forceMove(pick(GLOB.tdome1)) + spawn(50) + to_chat(L, "You have been sent to the Thunderdome.") + log_admin("[key_name(usr)] has sent [key_name(L)] to the thunderdome. (Team 1)") + message_admins("[key_name_admin(usr)] has sent [key_name_admin(L)] to the thunderdome. (Team 1)") + + else if(href_list["tdome2"]) + if(!check_rights(R_FUN)) + return + + if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") + return + + var/mob/M = locate(href_list["tdome2"]) + if(!isliving(M)) + to_chat(usr, "This can only be used on instances of type /mob/living.") + return + if(isAI(M)) + to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") + return + var/mob/living/L = M + + for(var/obj/item/I in L) + L.dropItemToGround(I, TRUE) + + L.Unconscious(100) + sleep(5) + L.forceMove(pick(GLOB.tdome2)) + spawn(50) + to_chat(L, "You have been sent to the Thunderdome.") + log_admin("[key_name(usr)] has sent [key_name(L)] to the thunderdome. (Team 2)") + message_admins("[key_name_admin(usr)] has sent [key_name_admin(L)] to the thunderdome. (Team 2)") + + else if(href_list["tdomeadmin"]) + if(!check_rights(R_FUN)) + return + + if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") + return + + var/mob/M = locate(href_list["tdomeadmin"]) + if(!isliving(M)) + to_chat(usr, "This can only be used on instances of type /mob/living.") + return + if(isAI(M)) + to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") + return + var/mob/living/L = M + + L.Unconscious(100) + sleep(5) + L.forceMove(pick(GLOB.tdomeadmin)) + spawn(50) + to_chat(L, "You have been sent to the Thunderdome.") + log_admin("[key_name(usr)] has sent [key_name(L)] to the thunderdome. (Admin.)") + message_admins("[key_name_admin(usr)] has sent [key_name_admin(L)] to the thunderdome. (Admin.)") + + else if(href_list["tdomeobserve"]) + if(!check_rights(R_FUN)) + return + + if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") + return + + var/mob/M = locate(href_list["tdomeobserve"]) + if(!isliving(M)) + to_chat(usr, "This can only be used on instances of type /mob/living.") + return + if(isAI(M)) + to_chat(usr, "This cannot be used on instances of type /mob/living/silicon/ai.") + return + var/mob/living/L = M + + for(var/obj/item/I in L) + L.dropItemToGround(I, TRUE) + + if(ishuman(L)) + var/mob/living/carbon/human/observer = L + observer.equip_to_slot_or_del(new /obj/item/clothing/under/suit_jacket(observer), SLOT_W_UNIFORM) + observer.equip_to_slot_or_del(new /obj/item/clothing/shoes/sneakers/black(observer), SLOT_SHOES) + L.Unconscious(100) + sleep(5) + L.forceMove(pick(GLOB.tdomeobserve)) + spawn(50) + to_chat(L, "You have been sent to the Thunderdome.") + log_admin("[key_name(usr)] has sent [key_name(L)] to the thunderdome. (Observer.)") + message_admins("[key_name_admin(usr)] has sent [key_name_admin(L)] to the thunderdome. (Observer.)") + + else if(href_list["revive"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/living/L = locate(href_list["revive"]) + if(!istype(L)) + to_chat(usr, "This can only be used on instances of type /mob/living.") + return + + L.revive(full_heal = 1, admin_revive = 1) + message_admins("Admin [key_name_admin(usr)] healed / revived [key_name_admin(L)]!") + log_admin("[key_name(usr)] healed / Revived [key_name(L)].") + + else if(href_list["makeai"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/living/carbon/human/H = locate(href_list["makeai"]) + if(!istype(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") + return + + message_admins("Admin [key_name_admin(usr)] AIized [key_name_admin(H)]!") + log_admin("[key_name(usr)] AIized [key_name(H)].") + H.AIize() + + else if(href_list["makealien"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/living/carbon/human/H = locate(href_list["makealien"]) + if(!istype(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") + return + + usr.client.cmd_admin_alienize(H) + + else if(href_list["makeslime"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/living/carbon/human/H = locate(href_list["makeslime"]) + if(!istype(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") + return + + usr.client.cmd_admin_slimeize(H) + + else if(href_list["makeblob"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/living/carbon/human/H = locate(href_list["makeblob"]) + if(!istype(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") + return + + usr.client.cmd_admin_blobize(H) + + + else if(href_list["makerobot"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/living/carbon/human/H = locate(href_list["makerobot"]) + if(!istype(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") + return + + usr.client.cmd_admin_robotize(H) + + else if(href_list["makeanimal"]) + if(!check_rights(R_SPAWN)) + return + + var/mob/M = locate(href_list["makeanimal"]) + if(isnewplayer(M)) + to_chat(usr, "This cannot be used on instances of type /mob/dead/new_player.") + return + + usr.client.cmd_admin_animalize(M) + + else if(href_list["adminplayeropts"]) + var/mob/M = locate(href_list["adminplayeropts"]) + show_player_panel(M) + + else if(href_list["adminplayerobservefollow"]) + if(!isobserver(usr) && !check_rights(R_ADMIN)) + return + + var/atom/movable/AM = locate(href_list["adminplayerobservefollow"]) + + var/client/C = usr.client + if(!isobserver(usr)) + C.admin_ghost() + var/mob/dead/observer/A = C.mob + A.ManualFollow(AM) + + else if(href_list["admingetmovable"]) + if(!check_rights(R_ADMIN)) + return + + var/atom/movable/AM = locate(href_list["admingetmovable"]) + if(QDELETED(AM)) + return + AM.forceMove(get_turf(usr)) + + else if(href_list["adminplayerobservecoodjump"]) + if(!isobserver(usr) && !check_rights(R_ADMIN)) + return + + var/x = text2num(href_list["X"]) + var/y = text2num(href_list["Y"]) + var/z = text2num(href_list["Z"]) + + var/client/C = usr.client + if(!isobserver(usr)) + C.admin_ghost() + sleep(2) + C.jumptocoord(x,y,z) + + else if(href_list["adminchecklaws"]) + if(!check_rights(R_ADMIN)) + return + output_ai_laws() + + else if(href_list["admincheckdevilinfo"]) + if(!check_rights(R_ADMIN)) + return + var/mob/M = locate(href_list["admincheckdevilinfo"]) + output_devil_info(M) + + else if(href_list["adminmoreinfo"]) + var/mob/M = locate(href_list["adminmoreinfo"]) in GLOB.mob_list + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob.") + return + + var/location_description = "" + var/special_role_description = "" + var/health_description = "" + var/gender_description = "" + var/turf/T = get_turf(M) + + //Location + if(isturf(T)) + if(isarea(T.loc)) + location_description = "([M.loc == T ? "at coordinates " : "in [M.loc] at coordinates "] [T.x], [T.y], [T.z] in area [T.loc])" + else + location_description = "([M.loc == T ? "at coordinates " : "in [M.loc] at coordinates "] [T.x], [T.y], [T.z])" + + //Job + antagonist + if(M.mind) + special_role_description = "Role: [M.mind.assigned_role]; Antagonist: [M.mind.special_role]" + else + special_role_description = "Role: Mind datum missing Antagonist: Mind datum missing" + + //Health + if(isliving(M)) + var/mob/living/L = M + var/status + switch (M.stat) + if(CONSCIOUS) + status = "Alive" + if(SOFT_CRIT) + status = "Dying" + if(UNCONSCIOUS) + status = "[L.InCritical() ? "Unconscious and Dying" : "Unconscious"]" + if(DEAD) + status = "Dead" + health_description = "Status = [status]" + health_description += "
    Oxy: [L.getOxyLoss()] - Tox: [L.getToxLoss()] - Fire: [L.getFireLoss()] - Brute: [L.getBruteLoss()] - Clone: [L.getCloneLoss()] - Brain: [L.getOrganLoss(ORGAN_SLOT_BRAIN)] - Stamina: [L.getStaminaLoss()]" + else + health_description = "This mob type has no health to speak of." + + //Gender + switch(M.gender) + if(MALE,FEMALE) + gender_description = "[M.gender]" + else + gender_description = "[M.gender]" + + to_chat(src.owner, "Info about [M.name]: ") + to_chat(src.owner, "Mob type = [M.type]; Gender = [gender_description] Damage = [health_description]") + to_chat(src.owner, "Name = [M.name]; Real_name = [M.real_name]; Mind_name = [M.mind?"[M.mind.name]":""]; Key = [M.key];") + to_chat(src.owner, "Location = [location_description];") + to_chat(src.owner, "[special_role_description]") + to_chat(src.owner, ADMIN_FULLMONTY_NONAME(M)) + + else if(href_list["addjobslot"]) + if(!check_rights(R_ADMIN)) + return + + var/Add = href_list["addjobslot"] + + for(var/datum/job/job in SSjob.occupations) + if(job.title == Add) + job.total_positions += 1 + break + + src.manage_free_slots() + + + else if(href_list["customjobslot"]) + if(!check_rights(R_ADMIN)) + return + + var/Add = href_list["customjobslot"] + + for(var/datum/job/job in SSjob.occupations) + if(job.title == Add) + var/newtime = null + newtime = input(usr, "How many jebs do you want?", "Add wanted posters", "[newtime]") as num|null + if(!newtime) + to_chat(src.owner, "Setting to amount of positions filled for the job") + job.total_positions = job.current_positions + break + job.total_positions = newtime + + src.manage_free_slots() + + else if(href_list["removejobslot"]) + if(!check_rights(R_ADMIN)) + return + + var/Remove = href_list["removejobslot"] + + for(var/datum/job/job in SSjob.occupations) + if(job.title == Remove && job.total_positions - job.current_positions > 0) + job.total_positions -= 1 + break + + src.manage_free_slots() + + else if(href_list["unlimitjobslot"]) + if(!check_rights(R_ADMIN)) + return + + var/Unlimit = href_list["unlimitjobslot"] + + for(var/datum/job/job in SSjob.occupations) + if(job.title == Unlimit) + job.total_positions = -1 + break + + src.manage_free_slots() + + else if(href_list["limitjobslot"]) + if(!check_rights(R_ADMIN)) + return + + var/Limit = href_list["limitjobslot"] + + for(var/datum/job/job in SSjob.occupations) + if(job.title == Limit) + job.total_positions = job.current_positions + break + + src.manage_free_slots() + + + else if(href_list["adminspawncookie"]) + if(!check_rights(R_ADMIN|R_FUN)) + return + + var/mob/living/carbon/human/H = locate(href_list["adminspawncookie"]) + if(!ishuman(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human.") + return + + var/obj/item/reagent_containers/food/snacks/cookie/cookie = new(H) + if(H.put_in_hands(cookie)) + H.update_inv_hands() + else + qdel(cookie) + log_admin("[key_name(H)] has their hands full, so they did not receive their cookie, spawned by [key_name(src.owner)].") + message_admins("[key_name(H)] has their hands full, so they did not receive their cookie, spawned by [key_name(src.owner)].") + return + + log_admin("[key_name(H)] got their cookie, spawned by [key_name(src.owner)].") + message_admins("[key_name(H)] got their cookie, spawned by [key_name(src.owner)].") + SSblackbox.record_feedback("amount", "admin_cookies_spawned", 1) + to_chat(H, "Your prayers have been answered!! You received the best cookie!") + SEND_SOUND(H, sound('sound/effects/pray_chaplain.ogg')) + + else if(href_list["adminsmite"]) + if(!check_rights(R_ADMIN|R_FUN)) + return + + var/mob/living/carbon/human/H = locate(href_list["adminsmite"]) in GLOB.mob_list + if(!H || !istype(H)) + to_chat(usr, "This can only be used on instances of type /mob/living/carbon/human") + return + + usr.client.smite(H) + + else if(href_list["CentComReply"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["CentComReply"]) + usr.client.admin_headset_message(M, RADIO_CHANNEL_CENTCOM) + + else if(href_list["SyndicateReply"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["SyndicateReply"]) + usr.client.admin_headset_message(M, RADIO_CHANNEL_SYNDICATE) + + else if(href_list["HeadsetMessage"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["HeadsetMessage"]) + usr.client.admin_headset_message(M) + + else if(href_list["reject_custom_name"]) + if(!check_rights(R_ADMIN)) + return + var/obj/item/station_charter/charter = locate(href_list["reject_custom_name"]) + if(istype(charter)) + charter.reject_proposed(usr) + else if(href_list["jumpto"]) + if(!isobserver(usr) && !check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["jumpto"]) + usr.client.jumptomob(M) + + else if(href_list["getmob"]) + if(!check_rights(R_ADMIN)) + return + + if(alert(usr, "Confirm?", "Message", "Yes", "No") != "Yes") + return + var/mob/M = locate(href_list["getmob"]) + usr.client.Getmob(M) + + else if(href_list["sendmob"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["sendmob"]) + usr.client.sendmob(M) + + else if(href_list["narrateto"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["narrateto"]) + usr.client.cmd_admin_direct_narrate(M) + + else if(href_list["subtlemessage"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["subtlemessage"]) + usr.client.cmd_admin_subtle_message(M) + + else if(href_list["individuallog"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["individuallog"]) in GLOB.mob_list + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob.") + return + + show_individual_logging_panel(M, href_list["log_src"], href_list["log_type"]) + else if(href_list["languagemenu"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["languagemenu"]) in GLOB.mob_list + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob.") + return + var/datum/language_holder/H = M.get_language_holder() + H.open_language_menu(usr) + + else if(href_list["traitor"]) + if(!check_rights(R_ADMIN)) + return + + if(!SSticker.HasRoundStarted()) + alert("The game hasn't started yet!") + return + + var/mob/M = locate(href_list["traitor"]) + if(!ismob(M)) + var/datum/mind/D = M + if(!istype(D)) + to_chat(usr, "This can only be used on instances of type /mob and /mind") + return + else + D.traitor_panel() + else + show_traitor_panel(M) + + else if(href_list["borgpanel"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["borgpanel"]) + if(!iscyborg(M)) + to_chat(usr, "This can only be used on cyborgs") + else + open_borgopanel(M) + + else if(href_list["initmind"]) + if(!check_rights(R_ADMIN)) + return + var/mob/M = locate(href_list["initmind"]) + if(!ismob(M) || M.mind) + to_chat(usr, "This can only be used on instances on mindless mobs") + return + M.mind_initialize() + + else if(href_list["create_object"]) + if(!check_rights(R_SPAWN)) + return + return create_object(usr) + + else if(href_list["quick_create_object"]) + if(!check_rights(R_SPAWN)) + return + return quick_create_object(usr) + + else if(href_list["create_turf"]) + if(!check_rights(R_SPAWN)) + return + return create_turf(usr) + + else if(href_list["create_mob"]) + if(!check_rights(R_SPAWN)) + return + return create_mob(usr) + + else if(href_list["dupe_marked_datum"]) + if(!check_rights(R_SPAWN)) + return + return DuplicateObject(marked_datum, perfectcopy=1, newloc=get_turf(usr)) + + else if(href_list["object_list"]) //this is the laggiest thing ever + if(!check_rights(R_SPAWN)) + return + + var/atom/loc = usr.loc + + var/dirty_paths + if (istext(href_list["object_list"])) + dirty_paths = list(href_list["object_list"]) + else if (istype(href_list["object_list"], /list)) + dirty_paths = href_list["object_list"] + + var/paths = list() + + for(var/dirty_path in dirty_paths) + var/path = text2path(dirty_path) + if(!path) + continue + else if(!ispath(path, /obj) && !ispath(path, /turf) && !ispath(path, /mob)) + continue + paths += path + + if(!paths) + alert("The path list you sent is empty.") + return + if(length(paths) > 5) + alert("Select fewer object types, (max 5).") + return + + var/list/offset = splittext(href_list["offset"],",") + var/number = CLAMP(text2num(href_list["object_count"]), 1, 100) + var/X = offset.len > 0 ? text2num(offset[1]) : 0 + var/Y = offset.len > 1 ? text2num(offset[2]) : 0 + var/Z = offset.len > 2 ? text2num(offset[3]) : 0 + var/obj_dir = text2num(href_list["object_dir"]) + if(obj_dir && !(obj_dir in list(1,2,4,8,5,6,9,10))) + obj_dir = null + var/obj_name = sanitize(href_list["object_name"]) + + + var/atom/target //Where the object will be spawned + var/where = href_list["object_where"] + if (!( where in list("onfloor","inhand","inmarked") )) + where = "onfloor" + + + switch(where) + if("inhand") + if (!iscarbon(usr) && !iscyborg(usr)) + to_chat(usr, "Can only spawn in hand when you're a carbon mob or cyborg.") + where = "onfloor" + target = usr + + if("onfloor") + switch(href_list["offset_type"]) + if ("absolute") + target = locate(0 + X,0 + Y,0 + Z) + if ("relative") + target = locate(loc.x + X,loc.y + Y,loc.z + Z) + if("inmarked") + if(!marked_datum) + to_chat(usr, "You don't have any object marked. Abandoning spawn.") + return + else if(!istype(marked_datum, /atom)) + to_chat(usr, "The object you have marked cannot be used as a target. Target must be of type /atom. Abandoning spawn.") + return + else + target = marked_datum + + if(target) + for (var/path in paths) + for (var/i = 0; i < number; i++) + if(path in typesof(/turf)) + var/turf/O = target + var/turf/N = O.ChangeTurf(path) + if(N && obj_name) + N.name = obj_name + else + var/atom/O = new path(target) + if(!QDELETED(O)) + O.flags_1 |= ADMIN_SPAWNED_1 + if(obj_dir) + O.setDir(obj_dir) + if(obj_name) + O.name = obj_name + if(ismob(O)) + var/mob/M = O + M.real_name = obj_name + if(where == "inhand" && isliving(usr) && isitem(O)) + var/mob/living/L = usr + var/obj/item/I = O + L.put_in_hands(I) + if(iscyborg(L)) + var/mob/living/silicon/robot/R = L + if(R.module) + R.module.add_module(I, TRUE, TRUE) + R.activate_module(I) + + + if (number == 1) + log_admin("[key_name(usr)] created a [english_list(paths)]") + for(var/path in paths) + if(ispath(path, /mob)) + message_admins("[key_name_admin(usr)] created a [english_list(paths)]") + break + else + log_admin("[key_name(usr)] created [number]ea [english_list(paths)]") + for(var/path in paths) + if(ispath(path, /mob)) + message_admins("[key_name_admin(usr)] created [number]ea [english_list(paths)]") + break + return + + else if(href_list["secrets"]) + Secrets_topic(href_list["secrets"],href_list) + + else if(href_list["ac_view_wanted"]) //Admin newscaster Topic() stuff be here + if(!check_rights(R_ADMIN)) + return + src.admincaster_screen = 18 //The ac_ prefix before the hrefs stands for AdminCaster. + src.access_news_network() + + else if(href_list["ac_set_channel_name"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_feed_channel.channel_name = stripped_input(usr, "Provide a Feed Channel Name.", "Network Channel Handler", "") + src.access_news_network() + + else if(href_list["ac_set_channel_lock"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_feed_channel.locked = !src.admincaster_feed_channel.locked + src.access_news_network() + + else if(href_list["ac_submit_new_channel"]) + if(!check_rights(R_ADMIN)) + return + var/check = 0 + for(var/datum/newscaster/feed_channel/FC in GLOB.news_network.network_channels) + if(FC.channel_name == src.admincaster_feed_channel.channel_name) + check = 1 + break + if(src.admincaster_feed_channel.channel_name == "" || src.admincaster_feed_channel.channel_name == "\[REDACTED\]" || check ) + src.admincaster_screen=7 + else + var/choice = alert("Please confirm Feed channel creation.","Network Channel Handler","Confirm","Cancel") + if(choice=="Confirm") + GLOB.news_network.CreateFeedChannel(src.admincaster_feed_channel.channel_name, src.admin_signature, src.admincaster_feed_channel.locked, 1) + SSblackbox.record_feedback("tally", "newscaster_channels", 1, src.admincaster_feed_channel.channel_name) + log_admin("[key_name(usr)] created command feed channel: [src.admincaster_feed_channel.channel_name]!") + src.admincaster_screen=5 + src.access_news_network() + + else if(href_list["ac_set_channel_receiving"]) + if(!check_rights(R_ADMIN)) + return + var/list/available_channels = list() + for(var/datum/newscaster/feed_channel/F in GLOB.news_network.network_channels) + available_channels += F.channel_name + src.admincaster_feed_channel.channel_name = adminscrub(input(usr, "Choose receiving Feed Channel.", "Network Channel Handler") in available_channels ) + src.access_news_network() + + else if(href_list["ac_set_new_message"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_feed_message.body = adminscrub(stripped_input(usr, "Write your Feed story.", "Network Channel Handler", "")) + src.access_news_network() + + else if(href_list["ac_submit_new_message"]) + if(!check_rights(R_ADMIN)) + return + if(src.admincaster_feed_message.returnBody(-1) =="" || src.admincaster_feed_message.returnBody(-1) =="\[REDACTED\]" || src.admincaster_feed_channel.channel_name == "" ) + src.admincaster_screen = 6 + else + GLOB.news_network.SubmitArticle(src.admincaster_feed_message.returnBody(-1), src.admin_signature, src.admincaster_feed_channel.channel_name, null, 1) + SSblackbox.record_feedback("amount", "newscaster_stories", 1) + src.admincaster_screen=4 + + for(var/obj/machinery/newscaster/NEWSCASTER in GLOB.allCasters) + NEWSCASTER.newsAlert(src.admincaster_feed_channel.channel_name) + + log_admin("[key_name(usr)] submitted a feed story to channel: [src.admincaster_feed_channel.channel_name]!") + src.access_news_network() + + else if(href_list["ac_create_channel"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_screen=2 + src.access_news_network() + + else if(href_list["ac_create_feed_story"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_screen=3 + src.access_news_network() + + else if(href_list["ac_menu_censor_story"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_screen=10 + src.access_news_network() + + else if(href_list["ac_menu_censor_channel"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_screen=11 + src.access_news_network() + + else if(href_list["ac_menu_wanted"]) + if(!check_rights(R_ADMIN)) + return + var/already_wanted = 0 + if(GLOB.news_network.wanted_issue.active) + already_wanted = 1 + + if(already_wanted) + src.admincaster_wanted_message.criminal = GLOB.news_network.wanted_issue.criminal + src.admincaster_wanted_message.body = GLOB.news_network.wanted_issue.body + src.admincaster_screen = 14 + src.access_news_network() + + else if(href_list["ac_set_wanted_name"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_wanted_message.criminal = adminscrub(stripped_input(usr, "Provide the name of the Wanted person.", "Network Security Handler", "")) + src.access_news_network() + + else if(href_list["ac_set_wanted_desc"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_wanted_message.body = adminscrub(stripped_input(usr, "Provide the a description of the Wanted person and any other details you deem important.", "Network Security Handler", "")) + src.access_news_network() + + else if(href_list["ac_submit_wanted"]) + if(!check_rights(R_ADMIN)) + return + var/input_param = text2num(href_list["ac_submit_wanted"]) + if(src.admincaster_wanted_message.criminal == "" || src.admincaster_wanted_message.body == "") + src.admincaster_screen = 16 + else + var/choice = alert("Please confirm Wanted Issue [(input_param==1) ? ("creation.") : ("edit.")]","Network Security Handler","Confirm","Cancel") + if(choice=="Confirm") + if(input_param==1) //If input_param == 1 we're submitting a new wanted issue. At 2 we're just editing an existing one. See the else below + GLOB.news_network.submitWanted(admincaster_wanted_message.criminal, admincaster_wanted_message.body, admin_signature, null, 1, 1) + src.admincaster_screen = 15 + else + GLOB.news_network.submitWanted(admincaster_wanted_message.criminal, admincaster_wanted_message.body, admin_signature) + src.admincaster_screen = 19 + log_admin("[key_name(usr)] issued a Station-wide Wanted Notification for [src.admincaster_wanted_message.criminal]!") + src.access_news_network() + + else if(href_list["ac_cancel_wanted"]) + if(!check_rights(R_ADMIN)) + return + var/choice = alert("Please confirm Wanted Issue removal.","Network Security Handler","Confirm","Cancel") + if(choice=="Confirm") + GLOB.news_network.deleteWanted() + src.admincaster_screen=17 + src.access_news_network() + + else if(href_list["ac_censor_channel_author"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_channel/FC = locate(href_list["ac_censor_channel_author"]) + FC.toggleCensorAuthor() + src.access_news_network() + + else if(href_list["ac_censor_channel_story_author"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_message/MSG = locate(href_list["ac_censor_channel_story_author"]) + MSG.toggleCensorAuthor() + src.access_news_network() + + else if(href_list["ac_censor_channel_story_body"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_message/MSG = locate(href_list["ac_censor_channel_story_body"]) + MSG.toggleCensorBody() + src.access_news_network() + + else if(href_list["ac_pick_d_notice"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_channel/FC = locate(href_list["ac_pick_d_notice"]) + src.admincaster_feed_channel = FC + src.admincaster_screen=13 + src.access_news_network() + + else if(href_list["ac_toggle_d_notice"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_channel/FC = locate(href_list["ac_toggle_d_notice"]) + FC.toggleCensorDclass() + src.access_news_network() + + else if(href_list["ac_view"]) + if(!check_rights(R_ADMIN)) + return + src.admincaster_screen=1 + src.access_news_network() + + else if(href_list["ac_setScreen"]) //Brings us to the main menu and resets all fields~ + if(!check_rights(R_ADMIN)) + return + src.admincaster_screen = text2num(href_list["ac_setScreen"]) + if (src.admincaster_screen == 0) + if(src.admincaster_feed_channel) + src.admincaster_feed_channel = new /datum/newscaster/feed_channel + if(src.admincaster_feed_message) + src.admincaster_feed_message = new /datum/newscaster/feed_message + if(admincaster_wanted_message) + admincaster_wanted_message = new /datum/newscaster/wanted_message + src.access_news_network() + + else if(href_list["ac_show_channel"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_channel/FC = locate(href_list["ac_show_channel"]) + src.admincaster_feed_channel = FC + src.admincaster_screen = 9 + src.access_news_network() + + else if(href_list["ac_pick_censor_channel"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_channel/FC = locate(href_list["ac_pick_censor_channel"]) + src.admincaster_feed_channel = FC + src.admincaster_screen = 12 + src.access_news_network() + + else if(href_list["ac_refresh"]) + if(!check_rights(R_ADMIN)) + return + src.access_news_network() + + else if(href_list["ac_set_signature"]) + if(!check_rights(R_ADMIN)) + return + src.admin_signature = adminscrub(input(usr, "Provide your desired signature.", "Network Identity Handler", "")) + src.access_news_network() + + else if(href_list["ac_del_comment"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_comment/FC = locate(href_list["ac_del_comment"]) + var/datum/newscaster/feed_message/FM = locate(href_list["ac_del_comment_msg"]) + FM.comments -= FC + qdel(FC) + src.access_news_network() + + else if(href_list["ac_lock_comment"]) + if(!check_rights(R_ADMIN)) + return + var/datum/newscaster/feed_message/FM = locate(href_list["ac_lock_comment"]) + FM.locked ^= 1 + src.access_news_network() + + else if(href_list["check_antagonist"]) + if(!check_rights(R_ADMIN)) + return + usr.client.check_antagonists() + + else if(href_list["kick_all_from_lobby"]) + if(!check_rights(R_ADMIN)) + return + if(SSticker.IsRoundInProgress()) + var/afkonly = text2num(href_list["afkonly"]) + if(alert("Are you sure you want to kick all [afkonly ? "AFK" : ""] clients from the lobby??","Message","Yes","Cancel") != "Yes") + to_chat(usr, "Kick clients from lobby aborted") + return + var/list/listkicked = kick_clients_in_lobby("You were kicked from the lobby by [usr.client.holder.fakekey ? "an Administrator" : "[usr.client.key]"].", afkonly) + + var/strkicked = "" + for(var/name in listkicked) + strkicked += "[name], " + message_admins("[key_name_admin(usr)] has kicked [afkonly ? "all AFK" : "all"] clients from the lobby. [length(listkicked)] clients kicked: [strkicked ? strkicked : "--"]") + log_admin("[key_name(usr)] has kicked [afkonly ? "all AFK" : "all"] clients from the lobby. [length(listkicked)] clients kicked: [strkicked ? strkicked : "--"]") + else + to_chat(usr, "You may only use this when the game is running.") + + else if(href_list["create_outfit"]) + if(!check_rights(R_ADMIN)) + return + + var/datum/outfit/O = new /datum/outfit + //swap this for js dropdowns sometime + O.name = href_list["outfit_name"] + O.uniform = text2path(href_list["outfit_uniform"]) + O.shoes = text2path(href_list["outfit_shoes"]) + O.gloves = text2path(href_list["outfit_gloves"]) + O.suit = text2path(href_list["outfit_suit"]) + O.head = text2path(href_list["outfit_head"]) + O.back = text2path(href_list["outfit_back"]) + O.mask = text2path(href_list["outfit_mask"]) + O.glasses = text2path(href_list["outfit_glasses"]) + O.r_hand = text2path(href_list["outfit_r_hand"]) + O.l_hand = text2path(href_list["outfit_l_hand"]) + O.suit_store = text2path(href_list["outfit_s_store"]) + O.l_pocket = text2path(href_list["outfit_l_pocket"]) + O.r_pocket = text2path(href_list["outfit_r_pocket"]) + O.id = text2path(href_list["outfit_id"]) + O.belt = text2path(href_list["outfit_belt"]) + O.ears = text2path(href_list["outfit_ears"]) + + GLOB.custom_outfits.Add(O) + message_admins("[key_name(usr)] created \"[O.name]\" outfit!") + + else if(href_list["set_selfdestruct_code"]) + if(!check_rights(R_ADMIN)) + return + var/code = random_nukecode() + for(var/obj/machinery/nuclearbomb/selfdestruct/SD in GLOB.nuke_list) + SD.r_code = code + message_admins("[key_name_admin(usr)] has set the self-destruct \ + code to \"[code]\".") + + else if(href_list["add_station_goal"]) + if(!check_rights(R_ADMIN)) + return + var/list/type_choices = typesof(/datum/station_goal) + var/picked = input("Choose goal type") in type_choices|null + if(!picked) + return + var/datum/station_goal/G = new picked() + if(picked == /datum/station_goal) + var/newname = input("Enter goal name:") as text|null + if(!newname) + return + G.name = newname + var/description = input("Enter CentCom message contents:") as message|null + if(!description) + return + G.report_message = description + message_admins("[key_name(usr)] created \"[G.name]\" station goal.") + SSticker.mode.station_goals += G + modify_goals() + + else if(href_list["viewruntime"]) + var/datum/error_viewer/error_viewer = locate(href_list["viewruntime"]) + if(!istype(error_viewer)) + to_chat(usr, "That runtime viewer no longer exists.") + return + + if(href_list["viewruntime_backto"]) + error_viewer.show_to(owner, locate(href_list["viewruntime_backto"]), href_list["viewruntime_linear"]) + else + error_viewer.show_to(owner, null, href_list["viewruntime_linear"]) + + else if(href_list["showrelatedacc"]) + if(!check_rights(R_ADMIN)) + return + var/client/C = locate(href_list["client"]) in GLOB.clients + var/thing_to_check + if(href_list["showrelatedacc"] == "cid") + thing_to_check = C.related_accounts_cid + else + thing_to_check = C.related_accounts_ip + thing_to_check = splittext(thing_to_check, ", ") + + + var/list/dat = list("Related accounts by [uppertext(href_list["showrelatedacc"])]:") + dat += thing_to_check + + usr << browse(dat.Join("
    "), "window=related_[C];size=420x300") + else if(href_list["centcomlookup"]) + if(!check_rights(R_ADMIN)) + return + + if(!CONFIG_GET(string/centcom_ban_db)) + to_chat(usr, "Centcom Galactic Ban DB is disabled!") + return + + var/ckey = href_list["centcomlookup"] + + // Make the request + var/datum/http_request/request = new() + request.prepare(RUSTG_HTTP_METHOD_GET, "[CONFIG_GET(string/centcom_ban_db)]/[ckey]", "", "") + request.begin_async() + UNTIL(request.is_complete() || !usr) + if (!usr) + return + var/datum/http_response/response = request.into_response() + + var/list/bans + + var/list/dat = list("") + + if(response.errored) + dat += "
    Failed to connect to CentCom." + else if(response.status_code != 200) + dat += "
    Failed to connect to CentCom. Status code: [response.status_code]" + else + if(response.body == "[]") + dat += "
    0 bans detected for [ckey]
    " + else + bans = json_decode(response["body"]) + dat += "
    [bans.len] ban\s detected for [ckey]
    " + for(var/list/ban in bans) + dat += "Server: [sanitize(ban["sourceName"])]
    " + dat += "RP Level: [sanitize(ban["sourceRoleplayLevel"])]
    " + dat += "Type: [sanitize(ban["type"])]
    " + dat += "Banned By: [sanitize(ban["bannedBy"])]
    " + dat += "Reason: [sanitize(ban["reason"])]
    " + dat += "Datetime: [sanitize(ban["bannedOn"])]
    " + var/expiration = ban["expires"] + dat += "Expires: [expiration ? "[sanitize(expiration)]" : "Permanent"]
    " + if(ban["type"] == "job") + dat += "Jobs: " + var/list/jobs = ban["jobs"] + dat += sanitize(jobs.Join(", ")) + dat += "
    " + dat += "
    " + + dat += "
    " + var/datum/browser/popup = new(usr, "centcomlookup-[ckey]", "
    Central Command Galactic Ban Database
    ", 700, 600) + popup.set_content(dat.Join()) + popup.open(0) + + + else if(href_list["modantagrep"]) + if(!check_rights(R_ADMIN)) + return + + var/mob/M = locate(href_list["mob"]) in GLOB.mob_list + var/client/C = M.client + usr.client.cmd_admin_mod_antag_rep(C, href_list["modantagrep"]) + show_player_panel(M) + + else if(href_list["slowquery"]) + if(!check_rights(R_ADMIN)) + return + var/answer = href_list["slowquery"] + if(answer == "yes") + log_query_debug("[usr.key] | Reported a server hang") + if(alert(usr, "Had you just press any admin buttons?", "Query server hang report", "Yes", "No") == "Yes") + var/response = input(usr,"What were you just doing?","Query server hang report") as null|text + if(response) + log_query_debug("[usr.key] | [response]") + else if(answer == "no") + log_query_debug("[usr.key] | Reported no server hang") + +/datum/admins/proc/HandleCMode() + if(!check_rights(R_ADMIN)) + return + + if(SSticker.HasRoundStarted()) + return alert(usr, "The game has already started.", null, null, null, null) + var/dat = {"What mode do you wish to play?
    "} + for(var/mode in config.modes) + dat += {"[config.mode_names[mode]]
    "} + dat += {"Secret
    "} + dat += {"Random
    "} + dat += {"Now: [GLOB.master_mode]"} + usr << browse(dat, "window=c_mode") + +/datum/admins/proc/HandleFSecret() + if(!check_rights(R_ADMIN)) + return + + if(SSticker.HasRoundStarted()) + return alert(usr, "The game has already started.", null, null, null, null) + if(GLOB.master_mode != "secret") + return alert(usr, "The game mode has to be secret!", null, null, null, null) + var/dat = {"What game mode do you want to force secret to be? Use this if you want to change the game mode, but want the players to believe it's secret. This will only work if the current game mode is secret.
    "} + for(var/mode in config.modes) + dat += {"[config.mode_names[mode]]
    "} + dat += {"Random (default)
    "} + dat += {"Now: [GLOB.secret_force_mode]"} + usr << browse(dat, "window=f_secret") + +/datum/admins/proc/makeMentor(ckey) + if(!usr.client) + return + if (!check_rights(0)) + return + if(!ckey) + return + var/client/C = GLOB.directory[ckey] + if(C) + if(check_rights_for(C, R_ADMIN,0)) + to_chat(usr, "The client chosen is an admin! Cannot mentorize.") + return + if(SSdbcore.Connect()) + var/datum/DBQuery/query_get_mentor = SSdbcore.NewQuery("SELECT id FROM [format_table_name("mentor")] WHERE ckey = '[ckey]'") + if(query_get_mentor.NextRow()) + to_chat(usr, "[ckey] is already a mentor.") + return + var/datum/DBQuery/query_add_mentor = SSdbcore.NewQuery("INSERT INTO `[format_table_name("mentor")]` (`id`, `ckey`) VALUES (null, '[ckey]')") + if(!query_add_mentor.warn_execute()) + return + var/datum/DBQuery/query_add_admin_log = SSdbcore.NewQuery("INSERT INTO `[format_table_name("admin_log")]` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Added new mentor [ckey]');") + if(!query_add_admin_log.warn_execute()) + return + else + to_chat(usr, "Failed to establish database connection. The changes will last only for the current round.") + new /datum/mentors(ckey) + to_chat(usr, "New mentor added.") + +/datum/admins/proc/removeMentor(ckey) + if(!usr.client) + return + if (!check_rights(0)) + return + if(!ckey) + return + var/client/C = GLOB.directory[ckey] + if(C) + if(check_rights_for(C, R_ADMIN,0)) + to_chat(usr, "The client chosen is an admin, not a mentor! Cannot de-mentorize.") + return + C.remove_mentor_verbs() + C.mentor_datum = null + GLOB.mentors -= C + if(SSdbcore.Connect()) + var/datum/DBQuery/query_remove_mentor = SSdbcore.NewQuery("DELETE FROM [format_table_name("mentor")] WHERE ckey = '[ckey]'") + if(!query_remove_mentor.warn_execute()) + return + var/datum/DBQuery/query_add_admin_log = SSdbcore.NewQuery("INSERT INTO `[format_table_name("admin_log")]` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Removed mentor [ckey]');") + if(!query_add_admin_log.warn_execute()) + return + else + to_chat(usr, "Failed to establish database connection. The changes will last only for the current round.") + to_chat(usr, "Mentor removed.") diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2.dm b/code/modules/admin/verbs/SDQL2/SDQL_2.dm index f5075b57..41496b35 100644 --- a/code/modules/admin/verbs/SDQL2/SDQL_2.dm +++ b/code/modules/admin/verbs/SDQL2/SDQL_2.dm @@ -862,8 +862,8 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null else if(ispath(expression[i])) val = expression[i] - else if(copytext(expression[i], 1, 2) in list("'", "\"")) - val = copytext(expression[i], 2, length(expression[i])) + else if(expression[i][1] in list("'", "\"")) + val = copytext_char(expression[i], 2, -1) else if(expression[i] == "\[") var/list/expressions_list = expression[++i] @@ -954,11 +954,11 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null if(is_proper_datum(object)) D = object - if (object == world && (!long || expression[start + 1] == ".") && !(expression[start] in exclude)) + if (object == world && (!long || expression[start + 1] == ".") && !(expression[start] in exclude)) //3 == length("SS") + 1 to_chat(usr, "World variables are not allowed to be accessed. Use global.") return null - else if(expression [start] == "{" && long) + else if(expression [start] == "{" && long) //3 == length("0x") + 1 if(lowertext(copytext(expression[start + 1], 1, 3)) != "0x") to_chat(usr, "Invalid pointer syntax: [expression[start + 1]]") return null @@ -1063,9 +1063,10 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null var/word = "" var/list/query_list = list() var/len = length(query_text) + var/char = "" - for(var/i = 1, i <= len, i++) - var/char = copytext(query_text, i, i + 1) + for(var/i = 1, i <= len, i += length(char)) + char = query_text[i] if(char in whitespace) if(word != "") @@ -1084,7 +1085,7 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null query_list += word word = "" - var/char2 = copytext(query_text, i + 1, i + 2) + var/char2 = query_text[i + length(char)] if(char2 in multi[char]) query_list += "[char][char2]" @@ -1100,13 +1101,13 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null word = "'" - for(i++, i <= len, i++) - char = copytext(query_text, i, i + 1) + for(i += length(char), i <= len, i += length(char)) + char = query_text[i] if(char == "'") - if(copytext(query_text, i + 1, i + 2) == "'") + if(query_text[i + length(char)] == "'") word += "'" - i++ + i += length(query_text[i + length(char)]) else break @@ -1128,13 +1129,13 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null word = "\"" - for(i++, i <= len, i++) - char = copytext(query_text, i, i + 1) + for(i += length(char), i <= len, i += length(char)) + char = query_text[i] if(char == "\"") - if(copytext(query_text, i + 1, i + 2) == "'") + if(query_text[i + length(char)] == "'") word += "\"" - i++ + i += length(query_text[i + length(char)]) else break diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm b/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm index 272bf83c..64d0c000 100644 --- a/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm +++ b/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm @@ -256,7 +256,7 @@ node += "*" i++ - else if (copytext(token(i), 1, 2) == "/") + else if(token(i)[1] == "/") i = object_type(i, node) else @@ -377,7 +377,7 @@ //object_type: /datum/SDQL_parser/proc/object_type(i, list/node) - if (copytext(token(i), 1, 2) != "/") + if(token(i)[1] != "/") return parse_error("Expected type, but it didn't begin with /") var/path = text2path(token(i)) @@ -416,7 +416,7 @@ //string: ''' ''' | '"' '"' /datum/SDQL_parser/proc/string(i, list/node) - if(copytext(token(i), 1, 2) in list("'", "\"")) + if(token(i)[1] in list("'", "\"")) node += token(i) else @@ -427,7 +427,7 @@ //array: '[' expression, expression, ... ']' /datum/SDQL_parser/proc/array(var/i, var/list/node) // Arrays get turned into this: list("[", list(exp_1a = exp_1b, ...), ...), "[" is to mark the next node as an array. - if(copytext(token(i), 1, 2) != "\[") + if(token(i)[1] != "\[") parse_error("Expected an array but found '[token(i)]'") return i + 1 @@ -613,7 +613,7 @@ node += "null" i++ - else if(lowertext(copytext(token(i), 1, 3)) == "0x" && isnum(hex2num(copytext(token(i), 3)))) + else if(lowertext(copytext(token(i), 1, 3)) == "0x" && isnum(hex2num(copytext(token(i), 3))))//3 == length("0x") + 1 node += hex2num(copytext(token(i), 3)) i++ @@ -621,12 +621,12 @@ node += text2num(token(i)) i++ - else if(copytext(token(i), 1, 2) in list("'", "\"")) + else if(token(i)[1] in list("'", "\"")) i = string(i, node) - else if(copytext(token(i), 1, 2) == "\[") // Start a list. + else if(token(i)[1] == "\[") // Start a list. i = array(i, node) - else if(copytext(token(i), 1, 2) == "/") + else if(token(i)[1] == "/") i = object_type(i, node) else i = variable(i, node) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index c1e91ccd..b24ce6d1 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -165,7 +165,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new) //is_bwoink is TRUE if this ticket was started by an admin PM /datum/admin_help/New(msg, client/C, is_bwoink) //clean the input msg - msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN)) + msg = sanitize(copytext_char(msg,1,MAX_MESSAGE_LEN)) if(!msg || !C || !C.mob) qdel(src) return diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index e2b994f7..bbd6b55e 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -41,7 +41,7 @@ return var/client/C if(istext(whom)) - if(cmptext(copytext(whom,1,2),"@")) + if(whom[1] == "@") whom = findStealthKey(whom) C = GLOB.directory[whom] else if(istype(whom, /client)) @@ -76,7 +76,7 @@ var/client/recipient var/irc = 0 if(istext(whom)) - if(cmptext(copytext(whom,1,2),"@")) + if(whom[1] == "@") whom = findStealthKey(whom) if(whom == "IRCKEY") irc = 1 @@ -133,7 +133,7 @@ //clean the message if it's not sent by a high-rank admin if(!check_rights(R_SERVER|R_DEBUG,0)||irc)//no sending html to the poor bots - msg = trim(sanitize(copytext(msg,1,MAX_MESSAGE_LEN))) + msg = trim(sanitize(msg), MAX_MESSAGE_LEN) if(!msg) return @@ -287,7 +287,7 @@ if(!stealthkey) stealthkey = GenIrcStealthKey() - msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN)) + msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN)) if(!msg) return "Error: No message" diff --git a/code/modules/admin/verbs/adminsay.dm b/code/modules/admin/verbs/adminsay.dm index 1ebd632c..9081357e 100644 --- a/code/modules/admin/verbs/adminsay.dm +++ b/code/modules/admin/verbs/adminsay.dm @@ -5,7 +5,7 @@ if(!check_rights(0)) return - msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN) + msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN) if(!msg) return msg = emoji_parse(msg) diff --git a/code/modules/admin/verbs/deadsay.dm b/code/modules/admin/verbs/deadsay.dm index 52c5284c..4df6f226 100644 --- a/code/modules/admin/verbs/deadsay.dm +++ b/code/modules/admin/verbs/deadsay.dm @@ -14,7 +14,7 @@ if (src.handle_spam_prevention(msg,MUTE_DEADCHAT)) return - msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN) + msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN) mob.log_talk(msg, LOG_DSAY) if (!msg) diff --git a/code/modules/admin/verbs/map_template_loadverb.dm b/code/modules/admin/verbs/map_template_loadverb.dm index c5c9a0da..d71cdca9 100644 --- a/code/modules/admin/verbs/map_template_loadverb.dm +++ b/code/modules/admin/verbs/map_template_loadverb.dm @@ -33,7 +33,7 @@ var/map = input(src, "Choose a Map Template to upload to template storage","Upload Map Template") as null|file if(!map) return - if(copytext("[map]",-4) != ".dmm") + if(copytext("[map]", -4) != ".dmm")//4 == length(".dmm") to_chat(src, "Filename must end in '.dmm': [map]") return var/datum/map_template/M diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm index 9daa417a..cc7bde68 100644 --- a/code/modules/admin/verbs/modifyvariables.dm +++ b/code/modules/admin/verbs/modifyvariables.dm @@ -1,644 +1,644 @@ -GLOBAL_LIST_INIT(VVlocked, list("vars", "datum_flags", "client", "virus", "viruses", "cuffed", "last_eaten", "unlock_content", "force_ending")) -GLOBAL_PROTECT(VVlocked) -GLOBAL_LIST_INIT(VVicon_edit_lock, list("icon", "icon_state", "overlays", "underlays", "resize")) -GLOBAL_PROTECT(VVicon_edit_lock) -GLOBAL_LIST_INIT(VVckey_edit, list("key", "ckey")) -GLOBAL_PROTECT(VVckey_edit) -GLOBAL_LIST_INIT(VVpixelmovement, list("step_x", "step_y", "bound_height", "bound_width", "bound_x", "bound_y")) -GLOBAL_PROTECT(VVpixelmovement) - - -/client/proc/vv_get_class(var/var_name, var/var_value) - if(isnull(var_value)) - . = VV_NULL - - else if (isnum(var_value)) - if (var_name in GLOB.bitfields) - . = VV_BITFIELD - else - . = VV_NUM - - else if (istext(var_value)) - if (findtext(var_value, "\n")) - . = VV_MESSAGE - else - . = VV_TEXT - - else if (isicon(var_value)) - . = VV_ICON - - else if (ismob(var_value)) - . = VV_MOB_REFERENCE - - else if (isloc(var_value)) - . = VV_ATOM_REFERENCE - - else if (istype(var_value, /client)) - . = VV_CLIENT - - else if (istype(var_value, /datum)) - . = VV_DATUM_REFERENCE - - else if (ispath(var_value)) - if (ispath(var_value, /atom)) - . = VV_ATOM_TYPE - else if (ispath(var_value, /datum)) - . = VV_DATUM_TYPE - else - . = VV_TYPE - - else if (islist(var_value)) - . = VV_LIST - - else if (isfile(var_value)) - . = VV_FILE - else - . = VV_NULL - -/client/proc/vv_get_value(class, default_class, current_value, list/restricted_classes, list/extra_classes, list/classes, var_name) - . = list("class" = class, "value" = null) - if (!class) - if (!classes) - classes = list ( - VV_NUM, - VV_TEXT, - VV_MESSAGE, - VV_ICON, - VV_ATOM_REFERENCE, - VV_DATUM_REFERENCE, - VV_MOB_REFERENCE, - VV_CLIENT, - VV_ATOM_TYPE, - VV_DATUM_TYPE, - VV_TYPE, - VV_FILE, - VV_NEW_ATOM, - VV_NEW_DATUM, - VV_NEW_TYPE, - VV_NEW_LIST, - VV_NULL, - VV_RESTORE_DEFAULT - ) - - if(holder && holder.marked_datum && !(VV_MARKED_DATUM in restricted_classes)) - classes += "[VV_MARKED_DATUM] ([holder.marked_datum.type])" - if (restricted_classes) - classes -= restricted_classes - - if (extra_classes) - classes += extra_classes - - .["class"] = input(src, "What kind of data?", "Variable Type", default_class) as null|anything in classes - if (holder && holder.marked_datum && .["class"] == "[VV_MARKED_DATUM] ([holder.marked_datum.type])") - .["class"] = VV_MARKED_DATUM - - - switch(.["class"]) - if (VV_TEXT) - .["value"] = input("Enter new text:", "Text", current_value) as null|text - if (.["value"] == null) - .["class"] = null - return - if (VV_MESSAGE) - .["value"] = input("Enter new text:", "Text", current_value) as null|message - if (.["value"] == null) - .["class"] = null - return - - - if (VV_NUM) - .["value"] = input("Enter new number:", "Num", current_value) as null|num - if (.["value"] == null) - .["class"] = null - return - - if (VV_BITFIELD) - .["value"] = input_bitfield(usr, "Editing bitfield: [var_name]", var_name, current_value) - if (.["value"] == null) - .["class"] = null - return - - if (VV_ATOM_TYPE) - .["value"] = pick_closest_path(FALSE) - if (.["value"] == null) - .["class"] = null - return - - if (VV_DATUM_TYPE) - .["value"] = pick_closest_path(FALSE, get_fancy_list_of_datum_types()) - if (.["value"] == null) - .["class"] = null - return - - if (VV_TYPE) - var/type = current_value - var/error = "" - do - type = input("Enter type:[error]", "Type", type) as null|text - if (!type) - break - type = text2path(type) - error = "\nType not found, Please try again" - while(!type) - if (!type) - .["class"] = null - return - .["value"] = type - - - if (VV_ATOM_REFERENCE) - var/type = pick_closest_path(FALSE) - var/subtypes = vv_subtype_prompt(type) - if (subtypes == null) - .["class"] = null - return - var/list/things = vv_reference_list(type, subtypes) - var/value = input("Select reference:", "Reference", current_value) as null|anything in things - if (!value) - .["class"] = null - return - .["value"] = things[value] - - if (VV_DATUM_REFERENCE) - var/type = pick_closest_path(FALSE, get_fancy_list_of_datum_types()) - var/subtypes = vv_subtype_prompt(type) - if (subtypes == null) - .["class"] = null - return - var/list/things = vv_reference_list(type, subtypes) - var/value = input("Select reference:", "Reference", current_value) as null|anything in things - if (!value) - .["class"] = null - return - .["value"] = things[value] - - if (VV_MOB_REFERENCE) - var/type = pick_closest_path(FALSE, make_types_fancy(typesof(/mob))) - var/subtypes = vv_subtype_prompt(type) - if (subtypes == null) - .["class"] = null - return - var/list/things = vv_reference_list(type, subtypes) - var/value = input("Select reference:", "Reference", current_value) as null|anything in things - if (!value) - .["class"] = null - return - .["value"] = things[value] - - - - if (VV_CLIENT) - .["value"] = input("Select reference:", "Reference", current_value) as null|anything in GLOB.clients - if (.["value"] == null) - .["class"] = null - return - - - if (VV_FILE) - .["value"] = input("Pick file:", "File") as null|file - if (.["value"] == null) - .["class"] = null - return - - - if (VV_ICON) - .["value"] = input("Pick icon:", "Icon") as null|icon - if (.["value"] == null) - .["class"] = null - return - - - if (VV_MARKED_DATUM) - .["value"] = holder.marked_datum - if (.["value"] == null) - .["class"] = null - return - - - if (VV_NEW_ATOM) - var/type = pick_closest_path(FALSE) - if (!type) - .["class"] = null - return - .["type"] = type - var/atom/newguy = new type() - newguy.datum_flags |= DF_VAR_EDITED - .["value"] = newguy - - if (VV_NEW_DATUM) - var/type = pick_closest_path(FALSE, get_fancy_list_of_datum_types()) - if (!type) - .["class"] = null - return - .["type"] = type - var/datum/newguy = new type() - newguy.datum_flags |= DF_VAR_EDITED - .["value"] = newguy - - if (VV_NEW_TYPE) - var/type = current_value - var/error = "" - do - type = input("Enter type:[error]", "Type", type) as null|text - if (!type) - break - type = text2path(type) - error = "\nType not found, Please try again" - while(!type) - if (!type) - .["class"] = null - return - .["type"] = type - var/datum/newguy = new type() - if(istype(newguy)) - newguy.datum_flags |= DF_VAR_EDITED - .["value"] = newguy - - - if (VV_NEW_LIST) - .["value"] = list() - .["type"] = /list - -/client/proc/vv_parse_text(O, new_var) - if(O && findtext(new_var,"\[")) - var/process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No") - if(process_vars == "Yes") - . = string2listofvars(new_var, O) - -//do they want you to include subtypes? -//FALSE = no subtypes, strict exact type pathing (or the type doesn't have subtypes) -//TRUE = Yes subtypes -//NULL = User cancelled at the prompt or invalid type given -/client/proc/vv_subtype_prompt(var/type) - if (!ispath(type)) - return - var/list/subtypes = subtypesof(type) - if (!subtypes || !subtypes.len) - return FALSE - if (subtypes && subtypes.len) - switch(alert("Strict object type detection?", "Type detection", "Strictly this type","This type and subtypes", "Cancel")) - if("Strictly this type") - return FALSE - if("This type and subtypes") - return TRUE - else - return - -/client/proc/vv_reference_list(type, subtypes) - . = list() - var/list/types = list(type) - if (subtypes) - types = typesof(type) - - var/list/fancytypes = make_types_fancy(types) - - for(var/fancytype in fancytypes) //swap the assoication - types[fancytypes[fancytype]] = fancytype - - var/things = get_all_of_type(type, subtypes) - - var/i = 0 - for(var/thing in things) - var/datum/D = thing - i++ - //try one of 3 methods to shorten the type text: - // fancy type, - // fancy type with the base type removed from the begaining, - // the type with the base type removed from the begaining - var/fancytype = types[D.type] - if (findtext(fancytype, types[type])) - fancytype = copytext(fancytype, length(types[type])+1) - var/shorttype = copytext("[D.type]", length("[type]")+1) - if (length(shorttype) > length(fancytype)) - shorttype = fancytype - if (!length(shorttype)) - shorttype = "/" - - .["[D]([shorttype])[REF(D)]#[i]"] = D - -/client/proc/mod_list_add_ass(atom/O) //hehe - - var/list/L = vv_get_value(restricted_classes = list(VV_RESTORE_DEFAULT)) - var/class = L["class"] - if (!class) - return - var/var_value = L["value"] - - if(class == VV_TEXT || class == VV_MESSAGE) - var/list/varsvars = vv_parse_text(O, var_value) - for(var/V in varsvars) - var_value = replacetext(var_value,"\[[V]]","[O.vars[V]]") - - return var_value - - -/client/proc/mod_list_add(list/L, atom/O, original_name, objectvar) - var/list/LL = vv_get_value(restricted_classes = list(VV_RESTORE_DEFAULT)) - var/class = LL["class"] - if (!class) - return - var/var_value = LL["value"] - - if(class == VV_TEXT || class == VV_MESSAGE) - var/list/varsvars = vv_parse_text(O, var_value) - for(var/V in varsvars) - var_value = replacetext(var_value,"\[[V]]","[O.vars[V]]") - - if (O) - L = L.Copy() - - L += var_value - - switch(alert("Would you like to associate a value with the list entry?",,"Yes","No")) - if("Yes") - L[var_value] = mod_list_add_ass(O) //hehe - if (O) - if (O.vv_edit_var(objectvar, L) == FALSE) - to_chat(src, "Your edit was rejected by the object.") - return - log_world("### ListVarEdit by [src]: [(O ? O.type : "/list")] [objectvar]: ADDED=[var_value]") - log_admin("[key_name(src)] modified [original_name]'s [objectvar]: ADDED=[var_value]") - message_admins("[key_name_admin(src)] modified [original_name]'s [objectvar]: ADDED=[var_value]") - -/client/proc/mod_list(list/L, atom/O, original_name, objectvar, index, autodetect_class = FALSE) - if(!check_rights(R_VAREDIT)) - return - if(!istype(L, /list)) - to_chat(src, "Not a List.") - return - - if(L.len > 1000) - var/confirm = alert(src, "The list you're trying to edit is very long, continuing may crash the server.", "Warning", "Continue", "Abort") - if(confirm != "Continue") - return - - - - var/list/names = list() - for (var/i in 1 to L.len) - var/key = L[i] - var/value - if (IS_NORMAL_LIST(L) && !isnum(key)) - value = L[key] - if (value == null) - value = "null" - names["#[i] [key] = [value]"] = i - if (!index) - var/variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)" + "(CLEAR NULLS)" + "(CLEAR DUPES)" + "(SHUFFLE)" - - if(variable == null) - return - - if(variable == "(ADD VAR)") - mod_list_add(L, O, original_name, objectvar) - return - - if(variable == "(CLEAR NULLS)") - L = L.Copy() - listclearnulls(L) - if (!O.vv_edit_var(objectvar, L)) - to_chat(src, "Your edit was rejected by the object.") - return - log_world("### ListVarEdit by [src]: [O.type] [objectvar]: CLEAR NULLS") - log_admin("[key_name(src)] modified [original_name]'s [objectvar]: CLEAR NULLS") - message_admins("[key_name_admin(src)] modified [original_name]'s list [objectvar]: CLEAR NULLS") - return - - if(variable == "(CLEAR DUPES)") - L = uniqueList(L) - if (!O.vv_edit_var(objectvar, L)) - to_chat(src, "Your edit was rejected by the object.") - return - log_world("### ListVarEdit by [src]: [O.type] [objectvar]: CLEAR DUPES") - log_admin("[key_name(src)] modified [original_name]'s [objectvar]: CLEAR DUPES") - message_admins("[key_name_admin(src)] modified [original_name]'s list [objectvar]: CLEAR DUPES") - return - - if(variable == "(SHUFFLE)") - L = shuffle(L) - if (!O.vv_edit_var(objectvar, L)) - to_chat(src, "Your edit was rejected by the object.") - return - log_world("### ListVarEdit by [src]: [O.type] [objectvar]: SHUFFLE") - log_admin("[key_name(src)] modified [original_name]'s [objectvar]: SHUFFLE") - message_admins("[key_name_admin(src)] modified [original_name]'s list [objectvar]: SHUFFLE") - return - - index = names[variable] - - - var/assoc_key - if (index == null) - return - var/assoc = 0 - var/prompt = alert(src, "Do you want to edit the key or its assigned value?", "Associated List", "Key", "Assigned Value", "Cancel") - if (prompt == "Cancel") - return - if (prompt == "Assigned Value") - assoc = 1 - assoc_key = L[index] - var/default - var/variable - if (assoc) - variable = L[assoc_key] - else - variable = L[index] - - default = vv_get_class(objectvar, variable) - - to_chat(src, "Variable appears to be [uppertext(default)].") - - to_chat(src, "Variable contains: [variable]") - - if(default == VV_NUM) - var/dir_text = "" - var/tdir = variable - if(tdir > 0 && tdir < 16) - if(tdir & 1) - dir_text += "NORTH" - if(tdir & 2) - dir_text += "SOUTH" - if(tdir & 4) - dir_text += "EAST" - if(tdir & 8) - dir_text += "WEST" - - if(dir_text) - to_chat(usr, "If a direction, direction is: [dir_text]") - - var/original_var = variable - - if (O) - L = L.Copy() - var/class - if(autodetect_class) - if (default == VV_TEXT) - default = VV_MESSAGE - class = default - var/list/LL = vv_get_value(default_class = default, current_value = original_var, restricted_classes = list(VV_RESTORE_DEFAULT), extra_classes = list(VV_LIST, "DELETE FROM LIST")) - class = LL["class"] - if (!class) - return - var/new_var = LL["value"] - - if(class == VV_MESSAGE) - class = VV_TEXT - - switch(class) //Spits a runtime error if you try to modify an entry in the contents list. Dunno how to fix it, yet. - if(VV_LIST) - mod_list(variable, O, original_name, objectvar) - - if("DELETE FROM LIST") - L.Cut(index, index+1) - if (O) - if (O.vv_edit_var(objectvar, L)) - to_chat(src, "Your edit was rejected by the object.") - return - log_world("### ListVarEdit by [src]: [O.type] [objectvar]: REMOVED=[html_encode("[original_var]")]") - log_admin("[key_name(src)] modified [original_name]'s [objectvar]: REMOVED=[original_var]") - message_admins("[key_name_admin(src)] modified [original_name]'s [objectvar]: REMOVED=[original_var]") - return - - if(VV_TEXT) - var/list/varsvars = vv_parse_text(O, new_var) - for(var/V in varsvars) - new_var = replacetext(new_var,"\[[V]]","[O.vars[V]]") - - - if(assoc) - L[assoc_key] = new_var - else - L[index] = new_var - if (O) - if (O.vv_edit_var(objectvar, L) == FALSE) - to_chat(src, "Your edit was rejected by the object.") - return - log_world("### ListVarEdit by [src]: [(O ? O.type : "/list")] [objectvar]: [original_var]=[new_var]") - log_admin("[key_name(src)] modified [original_name]'s [objectvar]: [original_var]=[new_var]") - message_admins("[key_name_admin(src)] modified [original_name]'s varlist [objectvar]: [original_var]=[new_var]") - -/proc/vv_varname_lockcheck(param_var_name) - if(param_var_name in GLOB.VVlocked) - if(!check_rights(R_DEBUG)) - return FALSE - if(param_var_name in GLOB.VVckey_edit) - if(!check_rights(R_SPAWN|R_DEBUG)) - return FALSE - if(param_var_name in GLOB.VVicon_edit_lock) - if(!check_rights(R_FUN|R_DEBUG)) - return FALSE - if(param_var_name in GLOB.VVpixelmovement) - if(!check_rights(R_DEBUG)) - return FALSE - var/prompt = alert(usr, "Editing this var may irreparably break tile gliding for the rest of the round. THIS CAN'T BE UNDONE", "DANGER", "ABORT ", "Continue", " ABORT") - if (prompt != "Continue") - return FALSE - return TRUE - - -/client/proc/modify_variables(atom/O, param_var_name = null, autodetect_class = 0) - if(!check_rights(R_VAREDIT)) - return - - var/class - var/variable - var/var_value - - if(param_var_name) - if(!param_var_name in O.vars) - to_chat(src, "A variable with this name ([param_var_name]) doesn't exist in this datum ([O])") - return - variable = param_var_name - - else - var/list/names = list() - for (var/V in O.vars) - names += V - - names = sortList(names) - - variable = input("Which var?","Var") as null|anything in names - if(!variable) - return - - if(!O.can_vv_get(variable)) - return - - var_value = O.vars[variable] - if(!vv_varname_lockcheck(variable)) - return - if(istype(O, /datum/armor)) - var/prompt = alert(src, "Editing this var changes this value on potentially thousands of items that share the same combination of armor values. If you want to edit the armor of just one item, use the \"Modify armor values\" dropdown item", "DANGER", "ABORT ", "Continue", " ABORT") - if (prompt != "Continue") - return - - - var/default = vv_get_class(variable, var_value) - - if(isnull(default)) - to_chat(src, "Unable to determine variable type.") - else - to_chat(src, "Variable appears to be [uppertext(default)].") - - to_chat(src, "Variable contains: [var_value]") - - if(default == VV_NUM) - var/dir_text = "" - if(var_value > 0 && var_value < 16) - if(var_value & 1) - dir_text += "NORTH" - if(var_value & 2) - dir_text += "SOUTH" - if(var_value & 4) - dir_text += "EAST" - if(var_value & 8) - dir_text += "WEST" - - if(dir_text) - to_chat(src, "If a direction, direction is: [dir_text]") - - if(autodetect_class && default != VV_NULL) - if (default == VV_TEXT) - default = VV_MESSAGE - class = default - - var/list/value = vv_get_value(class, default, var_value, extra_classes = list(VV_LIST), var_name = variable) - class = value["class"] - - if (!class) - return - var/var_new = value["value"] - - if(class == VV_MESSAGE) - class = VV_TEXT - - var/original_name = "[O]" - - switch(class) - if(VV_LIST) - if(!islist(var_value)) - mod_list(list(), O, original_name, variable) - - mod_list(var_value, O, original_name, variable) - return - - if(VV_RESTORE_DEFAULT) - var_new = initial(O.vars[variable]) - - if(VV_TEXT) - var/list/varsvars = vv_parse_text(O, var_new) - for(var/V in varsvars) - var_new = replacetext(var_new,"\[[V]]","[O.vars[V]]") - - - if (O.vv_edit_var(variable, var_new) == FALSE) - to_chat(src, "Your edit was rejected by the object.") - return - vv_update_display(O, "varedited", VV_MSG_EDITED) - SEND_GLOBAL_SIGNAL(COMSIG_GLOB_VAR_EDIT, args) - log_world("### VarEdit by [key_name(src)]: [O.type] [variable]=[var_value] => [var_new]") - log_admin("[key_name(src)] modified [original_name]'s [variable] from [html_encode("[var_value]")] to [html_encode("[var_new]")]") - var/msg = "[key_name_admin(src)] modified [original_name]'s [variable] from [var_value] to [var_new]" - message_admins(msg) - admin_ticket_log(O, msg) +GLOBAL_LIST_INIT(VVlocked, list("vars", "datum_flags", "client", "virus", "viruses", "cuffed", "last_eaten", "unlock_content", "force_ending")) +GLOBAL_PROTECT(VVlocked) +GLOBAL_LIST_INIT(VVicon_edit_lock, list("icon", "icon_state", "overlays", "underlays", "resize")) +GLOBAL_PROTECT(VVicon_edit_lock) +GLOBAL_LIST_INIT(VVckey_edit, list("key", "ckey")) +GLOBAL_PROTECT(VVckey_edit) +GLOBAL_LIST_INIT(VVpixelmovement, list("step_x", "step_y", "bound_height", "bound_width", "bound_x", "bound_y")) +GLOBAL_PROTECT(VVpixelmovement) + + +/client/proc/vv_get_class(var/var_name, var/var_value) + if(isnull(var_value)) + . = VV_NULL + + else if (isnum(var_value)) + if (var_name in GLOB.bitfields) + . = VV_BITFIELD + else + . = VV_NUM + + else if (istext(var_value)) + if (findtext(var_value, "\n")) + . = VV_MESSAGE + else + . = VV_TEXT + + else if (isicon(var_value)) + . = VV_ICON + + else if (ismob(var_value)) + . = VV_MOB_REFERENCE + + else if (isloc(var_value)) + . = VV_ATOM_REFERENCE + + else if (istype(var_value, /client)) + . = VV_CLIENT + + else if (istype(var_value, /datum)) + . = VV_DATUM_REFERENCE + + else if (ispath(var_value)) + if (ispath(var_value, /atom)) + . = VV_ATOM_TYPE + else if (ispath(var_value, /datum)) + . = VV_DATUM_TYPE + else + . = VV_TYPE + + else if (islist(var_value)) + . = VV_LIST + + else if (isfile(var_value)) + . = VV_FILE + else + . = VV_NULL + +/client/proc/vv_get_value(class, default_class, current_value, list/restricted_classes, list/extra_classes, list/classes, var_name) + . = list("class" = class, "value" = null) + if (!class) + if (!classes) + classes = list ( + VV_NUM, + VV_TEXT, + VV_MESSAGE, + VV_ICON, + VV_ATOM_REFERENCE, + VV_DATUM_REFERENCE, + VV_MOB_REFERENCE, + VV_CLIENT, + VV_ATOM_TYPE, + VV_DATUM_TYPE, + VV_TYPE, + VV_FILE, + VV_NEW_ATOM, + VV_NEW_DATUM, + VV_NEW_TYPE, + VV_NEW_LIST, + VV_NULL, + VV_RESTORE_DEFAULT + ) + + if(holder && holder.marked_datum && !(VV_MARKED_DATUM in restricted_classes)) + classes += "[VV_MARKED_DATUM] ([holder.marked_datum.type])" + if (restricted_classes) + classes -= restricted_classes + + if (extra_classes) + classes += extra_classes + + .["class"] = input(src, "What kind of data?", "Variable Type", default_class) as null|anything in classes + if (holder && holder.marked_datum && .["class"] == "[VV_MARKED_DATUM] ([holder.marked_datum.type])") + .["class"] = VV_MARKED_DATUM + + + switch(.["class"]) + if (VV_TEXT) + .["value"] = input("Enter new text:", "Text", current_value) as null|text + if (.["value"] == null) + .["class"] = null + return + if (VV_MESSAGE) + .["value"] = input("Enter new text:", "Text", current_value) as null|message + if (.["value"] == null) + .["class"] = null + return + + + if (VV_NUM) + .["value"] = input("Enter new number:", "Num", current_value) as null|num + if (.["value"] == null) + .["class"] = null + return + + if (VV_BITFIELD) + .["value"] = input_bitfield(usr, "Editing bitfield: [var_name]", var_name, current_value) + if (.["value"] == null) + .["class"] = null + return + + if (VV_ATOM_TYPE) + .["value"] = pick_closest_path(FALSE) + if (.["value"] == null) + .["class"] = null + return + + if (VV_DATUM_TYPE) + .["value"] = pick_closest_path(FALSE, get_fancy_list_of_datum_types()) + if (.["value"] == null) + .["class"] = null + return + + if (VV_TYPE) + var/type = current_value + var/error = "" + do + type = input("Enter type:[error]", "Type", type) as null|text + if (!type) + break + type = text2path(type) + error = "\nType not found, Please try again" + while(!type) + if (!type) + .["class"] = null + return + .["value"] = type + + + if (VV_ATOM_REFERENCE) + var/type = pick_closest_path(FALSE) + var/subtypes = vv_subtype_prompt(type) + if (subtypes == null) + .["class"] = null + return + var/list/things = vv_reference_list(type, subtypes) + var/value = input("Select reference:", "Reference", current_value) as null|anything in things + if (!value) + .["class"] = null + return + .["value"] = things[value] + + if (VV_DATUM_REFERENCE) + var/type = pick_closest_path(FALSE, get_fancy_list_of_datum_types()) + var/subtypes = vv_subtype_prompt(type) + if (subtypes == null) + .["class"] = null + return + var/list/things = vv_reference_list(type, subtypes) + var/value = input("Select reference:", "Reference", current_value) as null|anything in things + if (!value) + .["class"] = null + return + .["value"] = things[value] + + if (VV_MOB_REFERENCE) + var/type = pick_closest_path(FALSE, make_types_fancy(typesof(/mob))) + var/subtypes = vv_subtype_prompt(type) + if (subtypes == null) + .["class"] = null + return + var/list/things = vv_reference_list(type, subtypes) + var/value = input("Select reference:", "Reference", current_value) as null|anything in things + if (!value) + .["class"] = null + return + .["value"] = things[value] + + + + if (VV_CLIENT) + .["value"] = input("Select reference:", "Reference", current_value) as null|anything in GLOB.clients + if (.["value"] == null) + .["class"] = null + return + + + if (VV_FILE) + .["value"] = input("Pick file:", "File") as null|file + if (.["value"] == null) + .["class"] = null + return + + + if (VV_ICON) + .["value"] = input("Pick icon:", "Icon") as null|icon + if (.["value"] == null) + .["class"] = null + return + + + if (VV_MARKED_DATUM) + .["value"] = holder.marked_datum + if (.["value"] == null) + .["class"] = null + return + + + if (VV_NEW_ATOM) + var/type = pick_closest_path(FALSE) + if (!type) + .["class"] = null + return + .["type"] = type + var/atom/newguy = new type() + newguy.datum_flags |= DF_VAR_EDITED + .["value"] = newguy + + if (VV_NEW_DATUM) + var/type = pick_closest_path(FALSE, get_fancy_list_of_datum_types()) + if (!type) + .["class"] = null + return + .["type"] = type + var/datum/newguy = new type() + newguy.datum_flags |= DF_VAR_EDITED + .["value"] = newguy + + if (VV_NEW_TYPE) + var/type = current_value + var/error = "" + do + type = input("Enter type:[error]", "Type", type) as null|text + if (!type) + break + type = text2path(type) + error = "\nType not found, Please try again" + while(!type) + if (!type) + .["class"] = null + return + .["type"] = type + var/datum/newguy = new type() + if(istype(newguy)) + newguy.datum_flags |= DF_VAR_EDITED + .["value"] = newguy + + + if (VV_NEW_LIST) + .["value"] = list() + .["type"] = /list + +/client/proc/vv_parse_text(O, new_var) + if(O && findtext(new_var,"\[")) + var/process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No") + if(process_vars == "Yes") + . = string2listofvars(new_var, O) + +//do they want you to include subtypes? +//FALSE = no subtypes, strict exact type pathing (or the type doesn't have subtypes) +//TRUE = Yes subtypes +//NULL = User cancelled at the prompt or invalid type given +/client/proc/vv_subtype_prompt(var/type) + if (!ispath(type)) + return + var/list/subtypes = subtypesof(type) + if (!subtypes || !subtypes.len) + return FALSE + if (subtypes && subtypes.len) + switch(alert("Strict object type detection?", "Type detection", "Strictly this type","This type and subtypes", "Cancel")) + if("Strictly this type") + return FALSE + if("This type and subtypes") + return TRUE + else + return + +/client/proc/vv_reference_list(type, subtypes) + . = list() + var/list/types = list(type) + if (subtypes) + types = typesof(type) + + var/list/fancytypes = make_types_fancy(types) + + for(var/fancytype in fancytypes) //swap the assoication + types[fancytypes[fancytype]] = fancytype + + var/things = get_all_of_type(type, subtypes) + + var/i = 0 + for(var/thing in things) + var/datum/D = thing + i++ + //try one of 3 methods to shorten the type text: + // fancy type, + // fancy type with the base type removed from the begaining, + // the type with the base type removed from the begaining + var/fancytype = types[D.type] + if (findtext(fancytype, types[type])) + fancytype = copytext(fancytype, length(types[type]) + 1) + var/shorttype = copytext("[D.type]", length("[type]") + 1) + if (length_char(shorttype) > length_char(fancytype)) + shorttype = fancytype + if (!length(shorttype)) + shorttype = "/" + + .["[D]([shorttype])[REF(D)]#[i]"] = D + +/client/proc/mod_list_add_ass(atom/O) //hehe + + var/list/L = vv_get_value(restricted_classes = list(VV_RESTORE_DEFAULT)) + var/class = L["class"] + if (!class) + return + var/var_value = L["value"] + + if(class == VV_TEXT || class == VV_MESSAGE) + var/list/varsvars = vv_parse_text(O, var_value) + for(var/V in varsvars) + var_value = replacetext(var_value,"\[[V]]","[O.vars[V]]") + + return var_value + + +/client/proc/mod_list_add(list/L, atom/O, original_name, objectvar) + var/list/LL = vv_get_value(restricted_classes = list(VV_RESTORE_DEFAULT)) + var/class = LL["class"] + if (!class) + return + var/var_value = LL["value"] + + if(class == VV_TEXT || class == VV_MESSAGE) + var/list/varsvars = vv_parse_text(O, var_value) + for(var/V in varsvars) + var_value = replacetext(var_value,"\[[V]]","[O.vars[V]]") + + if (O) + L = L.Copy() + + L += var_value + + switch(alert("Would you like to associate a value with the list entry?",,"Yes","No")) + if("Yes") + L[var_value] = mod_list_add_ass(O) //hehe + if (O) + if (O.vv_edit_var(objectvar, L) == FALSE) + to_chat(src, "Your edit was rejected by the object.") + return + log_world("### ListVarEdit by [src]: [(O ? O.type : "/list")] [objectvar]: ADDED=[var_value]") + log_admin("[key_name(src)] modified [original_name]'s [objectvar]: ADDED=[var_value]") + message_admins("[key_name_admin(src)] modified [original_name]'s [objectvar]: ADDED=[var_value]") + +/client/proc/mod_list(list/L, atom/O, original_name, objectvar, index, autodetect_class = FALSE) + if(!check_rights(R_VAREDIT)) + return + if(!istype(L, /list)) + to_chat(src, "Not a List.") + return + + if(L.len > 1000) + var/confirm = alert(src, "The list you're trying to edit is very long, continuing may crash the server.", "Warning", "Continue", "Abort") + if(confirm != "Continue") + return + + + + var/list/names = list() + for (var/i in 1 to L.len) + var/key = L[i] + var/value + if (IS_NORMAL_LIST(L) && !isnum(key)) + value = L[key] + if (value == null) + value = "null" + names["#[i] [key] = [value]"] = i + if (!index) + var/variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)" + "(CLEAR NULLS)" + "(CLEAR DUPES)" + "(SHUFFLE)" + + if(variable == null) + return + + if(variable == "(ADD VAR)") + mod_list_add(L, O, original_name, objectvar) + return + + if(variable == "(CLEAR NULLS)") + L = L.Copy() + listclearnulls(L) + if (!O.vv_edit_var(objectvar, L)) + to_chat(src, "Your edit was rejected by the object.") + return + log_world("### ListVarEdit by [src]: [O.type] [objectvar]: CLEAR NULLS") + log_admin("[key_name(src)] modified [original_name]'s [objectvar]: CLEAR NULLS") + message_admins("[key_name_admin(src)] modified [original_name]'s list [objectvar]: CLEAR NULLS") + return + + if(variable == "(CLEAR DUPES)") + L = uniqueList(L) + if (!O.vv_edit_var(objectvar, L)) + to_chat(src, "Your edit was rejected by the object.") + return + log_world("### ListVarEdit by [src]: [O.type] [objectvar]: CLEAR DUPES") + log_admin("[key_name(src)] modified [original_name]'s [objectvar]: CLEAR DUPES") + message_admins("[key_name_admin(src)] modified [original_name]'s list [objectvar]: CLEAR DUPES") + return + + if(variable == "(SHUFFLE)") + L = shuffle(L) + if (!O.vv_edit_var(objectvar, L)) + to_chat(src, "Your edit was rejected by the object.") + return + log_world("### ListVarEdit by [src]: [O.type] [objectvar]: SHUFFLE") + log_admin("[key_name(src)] modified [original_name]'s [objectvar]: SHUFFLE") + message_admins("[key_name_admin(src)] modified [original_name]'s list [objectvar]: SHUFFLE") + return + + index = names[variable] + + + var/assoc_key + if (index == null) + return + var/assoc = 0 + var/prompt = alert(src, "Do you want to edit the key or its assigned value?", "Associated List", "Key", "Assigned Value", "Cancel") + if (prompt == "Cancel") + return + if (prompt == "Assigned Value") + assoc = 1 + assoc_key = L[index] + var/default + var/variable + if (assoc) + variable = L[assoc_key] + else + variable = L[index] + + default = vv_get_class(objectvar, variable) + + to_chat(src, "Variable appears to be [uppertext(default)].") + + to_chat(src, "Variable contains: [variable]") + + if(default == VV_NUM) + var/dir_text = "" + var/tdir = variable + if(tdir > 0 && tdir < 16) + if(tdir & 1) + dir_text += "NORTH" + if(tdir & 2) + dir_text += "SOUTH" + if(tdir & 4) + dir_text += "EAST" + if(tdir & 8) + dir_text += "WEST" + + if(dir_text) + to_chat(usr, "If a direction, direction is: [dir_text]") + + var/original_var = variable + + if (O) + L = L.Copy() + var/class + if(autodetect_class) + if (default == VV_TEXT) + default = VV_MESSAGE + class = default + var/list/LL = vv_get_value(default_class = default, current_value = original_var, restricted_classes = list(VV_RESTORE_DEFAULT), extra_classes = list(VV_LIST, "DELETE FROM LIST")) + class = LL["class"] + if (!class) + return + var/new_var = LL["value"] + + if(class == VV_MESSAGE) + class = VV_TEXT + + switch(class) //Spits a runtime error if you try to modify an entry in the contents list. Dunno how to fix it, yet. + if(VV_LIST) + mod_list(variable, O, original_name, objectvar) + + if("DELETE FROM LIST") + L.Cut(index, index+1) + if (O) + if (O.vv_edit_var(objectvar, L)) + to_chat(src, "Your edit was rejected by the object.") + return + log_world("### ListVarEdit by [src]: [O.type] [objectvar]: REMOVED=[html_encode("[original_var]")]") + log_admin("[key_name(src)] modified [original_name]'s [objectvar]: REMOVED=[original_var]") + message_admins("[key_name_admin(src)] modified [original_name]'s [objectvar]: REMOVED=[original_var]") + return + + if(VV_TEXT) + var/list/varsvars = vv_parse_text(O, new_var) + for(var/V in varsvars) + new_var = replacetext(new_var,"\[[V]]","[O.vars[V]]") + + + if(assoc) + L[assoc_key] = new_var + else + L[index] = new_var + if (O) + if (O.vv_edit_var(objectvar, L) == FALSE) + to_chat(src, "Your edit was rejected by the object.") + return + log_world("### ListVarEdit by [src]: [(O ? O.type : "/list")] [objectvar]: [original_var]=[new_var]") + log_admin("[key_name(src)] modified [original_name]'s [objectvar]: [original_var]=[new_var]") + message_admins("[key_name_admin(src)] modified [original_name]'s varlist [objectvar]: [original_var]=[new_var]") + +/proc/vv_varname_lockcheck(param_var_name) + if(param_var_name in GLOB.VVlocked) + if(!check_rights(R_DEBUG)) + return FALSE + if(param_var_name in GLOB.VVckey_edit) + if(!check_rights(R_SPAWN|R_DEBUG)) + return FALSE + if(param_var_name in GLOB.VVicon_edit_lock) + if(!check_rights(R_FUN|R_DEBUG)) + return FALSE + if(param_var_name in GLOB.VVpixelmovement) + if(!check_rights(R_DEBUG)) + return FALSE + var/prompt = alert(usr, "Editing this var may irreparably break tile gliding for the rest of the round. THIS CAN'T BE UNDONE", "DANGER", "ABORT ", "Continue", " ABORT") + if (prompt != "Continue") + return FALSE + return TRUE + + +/client/proc/modify_variables(atom/O, param_var_name = null, autodetect_class = 0) + if(!check_rights(R_VAREDIT)) + return + + var/class + var/variable + var/var_value + + if(param_var_name) + if(!param_var_name in O.vars) + to_chat(src, "A variable with this name ([param_var_name]) doesn't exist in this datum ([O])") + return + variable = param_var_name + + else + var/list/names = list() + for (var/V in O.vars) + names += V + + names = sortList(names) + + variable = input("Which var?","Var") as null|anything in names + if(!variable) + return + + if(!O.can_vv_get(variable)) + return + + var_value = O.vars[variable] + if(!vv_varname_lockcheck(variable)) + return + if(istype(O, /datum/armor)) + var/prompt = alert(src, "Editing this var changes this value on potentially thousands of items that share the same combination of armor values. If you want to edit the armor of just one item, use the \"Modify armor values\" dropdown item", "DANGER", "ABORT ", "Continue", " ABORT") + if (prompt != "Continue") + return + + + var/default = vv_get_class(variable, var_value) + + if(isnull(default)) + to_chat(src, "Unable to determine variable type.") + else + to_chat(src, "Variable appears to be [uppertext(default)].") + + to_chat(src, "Variable contains: [var_value]") + + if(default == VV_NUM) + var/dir_text = "" + if(var_value > 0 && var_value < 16) + if(var_value & 1) + dir_text += "NORTH" + if(var_value & 2) + dir_text += "SOUTH" + if(var_value & 4) + dir_text += "EAST" + if(var_value & 8) + dir_text += "WEST" + + if(dir_text) + to_chat(src, "If a direction, direction is: [dir_text]") + + if(autodetect_class && default != VV_NULL) + if (default == VV_TEXT) + default = VV_MESSAGE + class = default + + var/list/value = vv_get_value(class, default, var_value, extra_classes = list(VV_LIST), var_name = variable) + class = value["class"] + + if (!class) + return + var/var_new = value["value"] + + if(class == VV_MESSAGE) + class = VV_TEXT + + var/original_name = "[O]" + + switch(class) + if(VV_LIST) + if(!islist(var_value)) + mod_list(list(), O, original_name, variable) + + mod_list(var_value, O, original_name, variable) + return + + if(VV_RESTORE_DEFAULT) + var_new = initial(O.vars[variable]) + + if(VV_TEXT) + var/list/varsvars = vv_parse_text(O, var_new) + for(var/V in varsvars) + var_new = replacetext(var_new,"\[[V]]","[O.vars[V]]") + + + if (O.vv_edit_var(variable, var_new) == FALSE) + to_chat(src, "Your edit was rejected by the object.") + return + vv_update_display(O, "varedited", VV_MSG_EDITED) + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_VAR_EDIT, args) + log_world("### VarEdit by [key_name(src)]: [O.type] [variable]=[var_value] => [var_new]") + log_admin("[key_name(src)] modified [original_name]'s [variable] from [html_encode("[var_value]")] to [html_encode("[var_new]")]") + var/msg = "[key_name_admin(src)] modified [original_name]'s [variable] from [var_value] to [var_new]" + message_admins(msg) + admin_ticket_log(O, msg) return TRUE \ No newline at end of file diff --git a/code/modules/admin/verbs/pray.dm b/code/modules/admin/verbs/pray.dm index 0555f6b4..f3da1954 100644 --- a/code/modules/admin/verbs/pray.dm +++ b/code/modules/admin/verbs/pray.dm @@ -6,7 +6,7 @@ to_chat(usr, "Speech is currently admin-disabled.") return - msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN) + msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN) if(!msg) return log_prayer("[src.key]/([src.name]): [msg]") @@ -54,21 +54,21 @@ //log_admin("HELP: [key_name(src)]: [msg]") /proc/CentCom_announce(text , mob/Sender) - var/msg = copytext(sanitize(text), 1, MAX_MESSAGE_LEN) + var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN) msg = "CENTCOM:[ADMIN_FULLMONTY(Sender)] [ADMIN_CENTCOM_REPLY(Sender)]: [msg]" to_chat(GLOB.admins, msg) for(var/obj/machinery/computer/communications/C in GLOB.machines) C.overrideCooldown() /proc/Syndicate_announce(text , mob/Sender) - var/msg = copytext(sanitize(text), 1, MAX_MESSAGE_LEN) + var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN) msg = "SYNDICATE:[ADMIN_FULLMONTY(Sender)] [ADMIN_SYNDICATE_REPLY(Sender)]: [msg]" to_chat(GLOB.admins, msg) for(var/obj/machinery/computer/communications/C in GLOB.machines) C.overrideCooldown() /proc/Nuke_request(text , mob/Sender) - var/msg = copytext(sanitize(text), 1, MAX_MESSAGE_LEN) + var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN) msg = "NUKE CODE REQUEST:[ADMIN_FULLMONTY(Sender)] [ADMIN_CENTCOM_REPLY(Sender)] [ADMIN_SET_SD_CODE]: [msg]" to_chat(GLOB.admins, msg) for(var/obj/machinery/computer/communications/C in GLOB.machines) diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm index aa91af1d..818a2b98 100644 --- a/code/modules/antagonists/_common/antag_datum.dm +++ b/code/modules/antagonists/_common/antag_datum.dm @@ -211,7 +211,7 @@ GLOBAL_LIST_EMPTY(antagonists) return /datum/antagonist/proc/edit_memory(mob/user) - var/new_memo = copytext(trim(input(user,"Write new memory", "Memory", antag_memory) as null|message),1,MAX_MESSAGE_LEN) + var/new_memo = stripped_multiline_input(user, "Write new memory", "Memory", antag_memory, MAX_MESSAGE_LEN) if (isnull(new_memo)) return antag_memory = new_memo diff --git a/code/modules/antagonists/blob/blob/overmind.dm b/code/modules/antagonists/blob/blob/overmind.dm index 33e8497e..01882821 100644 --- a/code/modules/antagonists/blob/blob/overmind.dm +++ b/code/modules/antagonists/blob/blob/overmind.dm @@ -203,7 +203,7 @@ GLOBAL_LIST_EMPTY(blob_nodes) /mob/camera/blob/proc/blob_talk(message) - message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN)) + message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)) if (!message) return diff --git a/code/modules/antagonists/bloodsucker/datum_hunter.dm b/code/modules/antagonists/bloodsucker/datum_hunter.dm index 4f7bd8df..708fd8d3 100644 --- a/code/modules/antagonists/bloodsucker/datum_hunter.dm +++ b/code/modules/antagonists/bloodsucker/datum_hunter.dm @@ -220,8 +220,8 @@ streak = "" restraining = 0 streak = streak+element - if(length(streak) > max_streak_length) - streak = copytext(streak,2) + if(length_char(streak) > max_streak_length) + streak = streak[1] return /datum/martial_art/hunter/basic_hit(mob/living/carbon/human/A,mob/living/carbon/human/D) var/damage = rand(A.dna.species.punchdamagelow, A.dna.species.punchdamagehigh) diff --git a/code/modules/antagonists/clockcult/clock_mobs/_eminence.dm b/code/modules/antagonists/clockcult/clock_mobs/_eminence.dm index 86099d8c..e4722dbc 100644 --- a/code/modules/antagonists/clockcult/clock_mobs/_eminence.dm +++ b/code/modules/antagonists/clockcult/clock_mobs/_eminence.dm @@ -83,7 +83,7 @@ return if(client.handle_spam_prevention(message,MUTE_IC)) return - message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN)) + message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)) if(!message) return src.log_talk(message, LOG_SAY, tag="clockwork eminence") diff --git a/code/modules/antagonists/wizard/wizard.dm b/code/modules/antagonists/wizard/wizard.dm index a0f360fc..bf061cb2 100644 --- a/code/modules/antagonists/wizard/wizard.dm +++ b/code/modules/antagonists/wizard/wizard.dm @@ -113,7 +113,7 @@ var/wizard_name_second = pick(GLOB.wizard_second) var/randomname = "[wizard_name_first] [wizard_name_second]" var/mob/living/wiz_mob = owner.current - var/newname = copytext(sanitize(input(wiz_mob, "You are the [name]. Would you like to change your name to something else?", "Name change", randomname) as null|text),1,MAX_NAME_LEN) + var/newname = reject_bad_name(stripped_input(wiz_mob, "You are the [name]. Would you like to change your name to something else?", "Name change", randomname, MAX_NAME_LEN)) if (!newname) newname = randomname diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm index 744fb78b..d4c9fdbe 100644 --- a/code/modules/awaymissions/zlevel.dm +++ b/code/modules/awaymissions/zlevel.dm @@ -43,7 +43,7 @@ GLOBAL_LIST_INIT(potentialRandomZlevels, generateMapList(filename = "[global.con t = trim(t) if (length(t) == 0) continue - else if (copytext(t, 1, 2) == "#") + else if (t[1] == "#") continue var/pos = findtext(t, " ") diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index e283ebc0..2f173b18 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -411,7 +411,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls) winset(src, "[child]", "[entries[child]]") if (!ispath(child, /datum/verbs/menu)) var/atom/verb/verbpath = child - if (copytext(verbpath.name,1,2) != "@") + if (verbpath.name[1] != "@") new child(src) for (var/thing in prefs.menuoptions) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 6606a846..816dc2b9 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -225,7 +225,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/auto_fit_viewport = TRUE var/uplink_spawn_loc = UPLINK_PDA - + var/sprint_spacebar = FALSE var/sprint_toggle = FALSE @@ -1684,9 +1684,9 @@ GLOBAL_LIST_EMPTY(preferences_datums) medical_records = rec if("flavor_text") - var/msg = stripped_multiline_input(usr, "Set the flavor text in your 'examine' verb. This can also be used for OOC notes and preferences!", "Flavor Text", html_decode(features["flavor_text"]), MAX_MESSAGE_LEN*2, TRUE) - if(!isnull(msg)) - msg = copytext(msg, 1, MAX_MESSAGE_LEN*2) + var/msg = stripped_multiline_input(usr, "Set the flavor text in your 'examine' verb. This can also be used for OOC notes and preferences!", "Flavor Text", html_decode(features["flavor_text"]), MAX_MESSAGE_LEN, TRUE) + if(msg) + msg = msg features["flavor_text"] = msg if("hair") diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 76c98014..8a3efdc7 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -60,7 +60,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car /datum/preferences/proc/load_path(ckey,filename="preferences.sav") if(!ckey) return - path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/[filename]" + path = "data/player_saves/[ckey[1]]/[ckey]/[filename]" /datum/preferences/proc/load_preferences() if(!path) diff --git a/code/modules/client/verbs/aooc.dm b/code/modules/client/verbs/aooc.dm index 311c2295..72429fa7 100644 --- a/code/modules/client/verbs/aooc.dm +++ b/code/modules/client/verbs/aooc.dm @@ -31,7 +31,7 @@ GLOBAL_VAR_INIT(normal_aooc_colour, "#ce254f") if(QDELETED(src)) return - msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN) + msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN) var/raw_msg = msg if(!msg) diff --git a/code/modules/client/verbs/looc.dm b/code/modules/client/verbs/looc.dm index 84d1c3af..b97a184a 100644 --- a/code/modules/client/verbs/looc.dm +++ b/code/modules/client/verbs/looc.dm @@ -16,7 +16,7 @@ GLOBAL_VAR_INIT(normal_looc_colour, "#6699CC") to_chat(src, "Guests may not use OOC.") return - msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN) + msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN) if(!msg) return diff --git a/code/modules/client/verbs/ooc.dm b/code/modules/client/verbs/ooc.dm index c79eb418..1465a0c9 100644 --- a/code/modules/client/verbs/ooc.dm +++ b/code/modules/client/verbs/ooc.dm @@ -28,7 +28,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8") if(QDELETED(src)) return - msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN) + msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN) var/raw_msg = msg if(!msg) @@ -36,7 +36,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8") msg = emoji_parse(msg) - if((copytext(msg, 1, 2) in list(".",";",":","#")) || (findtext(lowertext(copytext(msg, 1, 5)), "say"))) + if((msg[1] in list(".",";",":","#")) || findtext_char(msg, "say", 1, 5)) if(alert("Your message \"[raw_msg]\" looks like it was meant for in game communication, say it in OOC?", "Meant for OOC?", "No", "Yes") != "Yes") return diff --git a/code/modules/clothing/neck/_neck.dm b/code/modules/clothing/neck/_neck.dm index 43b13f40..a4200acc 100644 --- a/code/modules/clothing/neck/_neck.dm +++ b/code/modules/clothing/neck/_neck.dm @@ -190,7 +190,7 @@ var/tagname = null /obj/item/clothing/neck/petcollar/attack_self(mob/user) - tagname = copytext(sanitize(input(user, "Would you like to change the name on the tag?", "Name your new pet", "Spot") as null|text),1,MAX_NAME_LEN) + tagname = stripped_input(user, "Would you like to change the name on the tag?", "Name your new pet", "Spot", MAX_NAME_LEN) name = "[initial(name)] - [tagname]" /obj/item/clothing/neck/petcollar/worn_overlays(isinhands, icon_file) diff --git a/code/modules/emoji/emoji_parse.dm b/code/modules/emoji/emoji_parse.dm index 2f4a84c6..3ae24181 100644 --- a/code/modules/emoji/emoji_parse.dm +++ b/code/modules/emoji/emoji_parse.dm @@ -12,14 +12,14 @@ parsed += copytext(text, pos, search) if(search) pos = search - search = findtext(text, ":", pos+1) + search = findtext(text, ":", pos + length(text[pos])) if(search) - emoji = lowertext(copytext(text, pos+1, search)) + emoji = lowertext(copytext(text, pos + length(text[pos]), search)) var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/goonchat) var/tag = sheet.icon_tag("emoji-[emoji]") if(tag) parsed += tag - pos = search + 1 + pos = search + length(text[pos]) else parsed += copytext(text, pos, search) pos = search @@ -30,3 +30,24 @@ break return parsed +/proc/emoji_sanitize(text) //cuts any text that would not be parsed as an emoji + . = text + if(!CONFIG_GET(flag/emojis)) + return + var/static/list/emojis = icon_states(icon('icons/emoji.dmi')) + var/final = "" //only tags are added to this + var/pos = 1 + var/search = 0 + while(1) + search = findtext(text, ":", pos) + if(search) + pos = search + search = findtext(text, ":", pos + length(text[pos])) + if(search) + var/word = lowertext(copytext(text, pos + length(text[pos]), search)) + if(word in emojis) + final += lowertext(copytext(text, pos, search + length(text[search]))) + pos = search + length(text[search]) + continue + break + return final diff --git a/code/modules/error_handler/error_handler.dm b/code/modules/error_handler/error_handler.dm index 8b410130..418b75e1 100644 --- a/code/modules/error_handler/error_handler.dm +++ b/code/modules/error_handler/error_handler.dm @@ -12,7 +12,7 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0) return ..() //this is snowflake because of a byond bug (ID:2306577), do not attempt to call non-builtin procs in this if - if(copytext(E.name,1,32) == "Maximum recursion level reached") + if(copytext(E.name, 1, 32) == "Maximum recursion level reached")//32 == length() of that string + 1 //log to world while intentionally triggering the byond bug. log_world("runtime error: [E.name]\n[E.desc]") //if we got to here without silently ending, the byond bug has been fixed. @@ -102,7 +102,7 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0) usrinfo = null continue // Our usr info is better, replace it - if(copytext(line, 1, 3) != " ") + if(copytext(line, 1, 3) != " ")//3 == length(" ") + 1 desclines += (" " + line) // Pad any unpadded lines, so they look pretty else desclines += line diff --git a/code/modules/goonchat/browserOutput.dm b/code/modules/goonchat/browserOutput.dm index a0696e1f..7367c7ca 100644 --- a/code/modules/goonchat/browserOutput.dm +++ b/code/modules/goonchat/browserOutput.dm @@ -62,8 +62,8 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("tmp/iconCache.sav")) //Cache of ico // Arguments are in the form "param[paramname]=thing" var/list/params = list() for(var/key in href_list) - if(length(key) > 7 && findtext(key, "param")) // 7 is the amount of characters in the basic param key template. - var/param_name = copytext(key, 7, -1) + if(length_char(key) > 7 && findtext(key, "param")) // 7 is the amount of characters in the basic param key template. + var/param_name = copytext_char(key, 7, -1) var/item = href_list[key] params[param_name] = item diff --git a/code/modules/holiday/holidays.dm b/code/modules/holiday/holidays.dm index 301b07e8..8012cf7f 100644 --- a/code/modules/holiday/holidays.dm +++ b/code/modules/holiday/holidays.dm @@ -23,8 +23,8 @@ // Returns special prefixes for the station name on certain days. You wind up with names like "Christmas Object Epsilon". See new_station_name() /datum/holiday/proc/getStationPrefix() //get the first word of the Holiday and use that - var/i = findtext(name," ",1,0) - return copytext(name,1,i) + var/i = findtext(name," ") + return copytext(name, 1, i) // Return 1 if this holidy should be celebrated today /datum/holiday/proc/shouldCelebrate(dd, mm, yy, ww, ddd) diff --git a/code/modules/hydroponics/gene_modder.dm b/code/modules/hydroponics/gene_modder.dm index ec023728..1d34d15c 100644 --- a/code/modules/hydroponics/gene_modder.dm +++ b/code/modules/hydroponics/gene_modder.dm @@ -401,7 +401,7 @@ /obj/machinery/plantgenes/proc/repaint_seed() if(!seed) return - if(copytext(seed.name, 1, 13) == "experimental") + if(copytext(seed.name, 1, 13) == "experimental")//13 == length("experimental") + 1 return // Already modded name and icon seed.name = "experimental " + seed.name seed.icon_state = "seed-x" diff --git a/code/modules/integrated_electronics/core/special_pins/color_pin.dm b/code/modules/integrated_electronics/core/special_pins/color_pin.dm index 30b0a189..64e41143 100644 --- a/code/modules/integrated_electronics/core/special_pins/color_pin.dm +++ b/code/modules/integrated_electronics/core/special_pins/color_pin.dm @@ -15,11 +15,11 @@ new_data = uppertext(new_data) if(length(new_data) != 7) // We can hex if we want to, we can leave your strings behind return // Cause your strings don't hex and if they don't hex - var/friends = copytext(new_data, 2, 8) // Well they're are no strings of mine + var/friends = copytext_char(new_data, 2, 8) // Well they're are no strings of mine // I say, we can go where we want to, a place where they will never find var/safety_dance = 1 while(safety_dance >= 7) // And we can act like we come from out of this world.log - var/hex = copytext(friends, safety_dance, safety_dance+1) + var/hex = copytext_char(friends, safety_dance, safety_dance+1) if(!(hex in list("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"))) return // Leave the fake one far behind, safety_dance++ diff --git a/code/modules/integrated_electronics/subtypes/converters.dm b/code/modules/integrated_electronics/subtypes/converters.dm index c323718c..8c752965 100644 --- a/code/modules/integrated_electronics/subtypes/converters.dm +++ b/code/modules/integrated_electronics/subtypes/converters.dm @@ -224,8 +224,8 @@ var/split = min(index+1, length(text)) - var/before_text = copytext(text, 1, split) - var/after_text = copytext(text, split, 0) + var/before_text = copytext_char(text, 1, split) + var/after_text = copytext_char(text, split) set_pin_data(IC_OUTPUT, 1, before_text) set_pin_data(IC_OUTPUT, 2, after_text) @@ -331,7 +331,7 @@ var/strin = get_pin_data(IC_INPUT, 1) var/delimiter = get_pin_data(IC_INPUT, 2) if(delimiter == null) - set_pin_data(IC_OUTPUT, 1, string2charlist(strin)) + set_pin_data(IC_OUTPUT, 1, text2charlist(strin)) else set_pin_data(IC_OUTPUT, 1, splittext(strin, delimiter)) push_data() diff --git a/code/modules/language/codespeak.dm b/code/modules/language/codespeak.dm index a7f8c728..be325d14 100644 --- a/code/modules/language/codespeak.dm +++ b/code/modules/language/codespeak.dm @@ -13,13 +13,13 @@ . = "" var/list/words = list() - while(length(.) < length(input)) + while(length_char(.) < length_char(input)) words += generate_code_phrase(return_list=TRUE) . = jointext(words, ", ") . = capitalize(.) - var/input_ending = copytext(input, length(input)) + var/input_ending = copytext_char(input, -1) var/static/list/endings if(!endings) diff --git a/code/modules/language/language.dm b/code/modules/language/language.dm index a2508785..1d20b63e 100644 --- a/code/modules/language/language.dm +++ b/code/modules/language/language.dm @@ -81,11 +81,11 @@ if(lookup) return lookup - var/input_size = length(input) + var/input_size = length_char(input) var/scrambled_text = "" var/capitalize = TRUE - while(length(scrambled_text) < input_size) + while(length_char(scrambled_text) < input_size) var/next = pick(syllables) if(capitalize) next = capitalize(next) @@ -99,10 +99,10 @@ scrambled_text += " " scrambled_text = trim(scrambled_text) - var/ending = copytext(scrambled_text, length(scrambled_text)) + var/ending = copytext_char(scrambled_text, -1) if(ending == ".") - scrambled_text = copytext(scrambled_text,1,length(scrambled_text)-1) - var/input_ending = copytext(input, input_size) + scrambled_text = copytext_char(scrambled_text, 1, -2) + var/input_ending = copytext_char(input, -1) if(input_ending in list("!","?",".")) scrambled_text += input_ending diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index b6238baa..de17a35e 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -384,9 +384,9 @@ GLOBAL_LIST(cachedbooks) // List of our cached book datums if(checkoutperiod < 1) checkoutperiod = 1 if(href_list["editbook"]) - buffer_book = copytext(sanitize(input("Enter the book's title:") as text|null),1,MAX_MESSAGE_LEN) + buffer_book = stripped_input(usr, "Enter the book's title:") if(href_list["editmob"]) - buffer_mob = copytext(sanitize(input("Enter the recipient's name:") as text|null),1,MAX_NAME_LEN) + buffer_mob = stripped_input(usr, "Enter the recipient's name:", max_length = MAX_NAME_LEN) if(href_list["checkout"]) var/datum/borrowbook/b = new /datum/borrowbook b.bookname = sanitize(buffer_book) @@ -403,7 +403,7 @@ GLOBAL_LIST(cachedbooks) // List of our cached book datums if(b && istype(b)) inventory.Remove(b) if(href_list["setauthor"]) - var/newauthor = copytext(sanitize(input("Enter the author's name: ") as text|null),1,MAX_MESSAGE_LEN) + var/newauthor = stripped_input(usr, "Enter the author's name: ") if(newauthor) scanner.cache.author = newauthor if(href_list["setcategory"]) diff --git a/code/modules/library/soapstone.dm b/code/modules/library/soapstone.dm index 84edffa4..bc06e35e 100644 --- a/code/modules/library/soapstone.dm +++ b/code/modules/library/soapstone.dm @@ -150,7 +150,7 @@ /obj/structure/chisel_message/update_icon() ..() var/hash = md5(hidden_message) - var/newcolor = copytext(hash, 1, 7) + var/newcolor = copytext_char(hash, 1, 7) add_atom_colour("#[newcolor]", FIXED_COLOUR_PRIORITY) light_color = "#[newcolor]" light_power = 0.3 diff --git a/code/modules/mapping/reader.dm b/code/modules/mapping/reader.dm index 9b27691d..86b501c4 100644 --- a/code/modules/mapping/reader.dm +++ b/code/modules/mapping/reader.dm @@ -241,7 +241,8 @@ var/variables_start = findtext(full_def, "{") var/path_text = trim_text(copytext(full_def, 1, variables_start)) var/atom_def = text2path(path_text) //path definition, e.g /obj/foo/bar - old_position = dpos + 1 + if(dpos) + old_position = dpos + length(model[dpos]) if(!ispath(atom_def, /atom)) // Skip the item if the path does not exist. Fix your crap, mappers! if(bad_paths) @@ -253,7 +254,7 @@ var/list/fields = list() if(variables_start)//if there's any variable - full_def = copytext(full_def,variables_start+1,length(full_def))//removing the last '}' + full_def = copytext(full_def, variables_start + length(full_def[variables_start]), -length(copytext_char(full_def, -1))) //removing the last '}' fields = readlist(full_def, ";") if(fields.len) if(!trim(fields[fields.len])) @@ -423,12 +424,13 @@ var/trim_left = trim_text(copytext(text,old_position,(equal_position ? equal_position : position))) var/left_constant = delimiter == ";" ? trim_left : parse_constant(trim_left) - old_position = position + 1 + if(position) + old_position = position + length(text[position]) if(equal_position && !isnum(left_constant)) // Associative var, so do the association. // Note that numbers cannot be keys - the RHS is dropped if so. - var/trim_right = trim_text(copytext(text,equal_position+1,position)) + var/trim_right = trim_text(copytext(text, equal_position + length(text[equal_position]), position)) var/right_constant = parse_constant(trim_right) .[left_constant] = right_constant @@ -442,12 +444,12 @@ return num // string - if(findtext(text,"\"",1,2)) - return copytext(text,2,findtext(text,"\"",3,0)) + if(text[1] == "\"") + return copytext(text, length(text[1]) + 1, findtext(text, "\"", length(text[1]) + 1)) // list - if(copytext(text,1,6) == "list(") - return readlist(copytext(text,6,length(text))) + if(copytext(text, 1, 6) == "list(")//6 == length("list(") + 1 + return readlist(copytext(text, 6, -1)) // typepath var/path = text2path(text) @@ -455,8 +457,8 @@ return path // file - if(copytext(text,1,2) == "'") - return file(copytext(text,2,length(text))) + if(text[1] == "'") + return file(copytext_char(text, 2, -1)) // null if(text == "null") diff --git a/code/modules/mapping/verify.dm b/code/modules/mapping/verify.dm index a9834e37..1f071aae 100644 --- a/code/modules/mapping/verify.dm +++ b/code/modules/mapping/verify.dm @@ -60,8 +60,9 @@ // build_cache will check bad paths for us var/list/modelCache = build_cache(TRUE, report.bad_paths) + var/static/regex/area_or_turf = regex(@"/(turf|area)/") for(var/path in report.bad_paths) - if(copytext(path, 1, 7) == "/turf/" || copytext(path, 1, 7) == "/area/") + if(area_or_turf.Find("[path]", 1, 1)) report.loadable = FALSE // check for tiles with the wrong number of turfs or areas diff --git a/code/modules/mining/abandoned_crates.dm b/code/modules/mining/abandoned_crates.dm index b0e6d873..c89c547e 100644 --- a/code/modules/mining/abandoned_crates.dm +++ b/code/modules/mining/abandoned_crates.dm @@ -157,19 +157,22 @@ var/input = input(usr, "Enter [codelen] digits. All digits must be unique.", "Deca-Code Lock", "") as text if(user.canUseTopic(src, BE_CLOSE)) var/list/sanitised = list() - var/sanitycheck = 1 - for(var/i=1,i<=length(input),i++) //put the guess into a list - sanitised += text2num(copytext(input,i,i+1)) - for(var/i=1,i<=(length(input)-1),i++) //compare each digit in the guess to all those following it - for(var/j=(i+1),j<=length(input),j++) + var/sanitycheck = TRUE + var/char = "" + var/length_input = length(input) + for(var/i = 1, i <= length_input, i += length(char)) //put the guess into a list + char = input[i] + sanitised += text2num(char) + for(var/i = 1, i <= length(sanitised) - 1, i++) //compare each digit in the guess to all those following it + for(var/j = i + 1, j <= length(sanitised), j++) if(sanitised[i] == sanitised[j]) - sanitycheck = null //if a digit is repeated, reject the input - if (input == code) + sanitycheck = FALSE //if a digit is repeated, reject the input + if(input == code) to_chat(user, "The crate unlocks!") locked = FALSE cut_overlays() add_overlay("securecrateg") - else if (input == null || sanitycheck == null || length(input) != codelen) + else if(!input || !sanitycheck || length(sanitised) != codelen) to_chat(user, "You leave the crate alone.") else to_chat(user, "A red light flashes.") @@ -195,20 +198,27 @@ else to_chat(user, "* Anti-Tamper Bomb will activate after [attempts] failed access attempts.") if(lastattempt != null) - var/list/guess = list() - var/list/answer = list() - var/bulls = 0 - var/cows = 0 - for(var/i=1,i<=length(lastattempt),i++) - guess += text2num(copytext(lastattempt,i,i+1)) - for(var/i=1,i<=length(lastattempt),i++) - answer += text2num(copytext(code,i,i+1)) - for(var/i = 1, i < codelen + 1, i++) // Go through list and count matches - if( answer.Find(guess[i],1,codelen+1)) - ++cows - if( answer[i] == guess[i]) + var/bulls = 0 //right position, right number + var/cows = 0 //wrong position but in the puzzle + + var/lastattempt_char = "" + var/length_lastattempt = length(lastattempt) + var/lastattempt_it = 1 + + var/code_char = "" + var/length_code = length(code) + var/code_it = 1 + + while(lastattempt_it <= length_lastattempt && code_it <= length_code) // Go through list and count matches + lastattempt_char = lastattempt[lastattempt_it] + code_char = code[code_it] + if(lastattempt_char == code_char) ++bulls - --cows + else if(findtext(code, lastattempt_char)) + ++cows + + lastattempt_it += length(lastattempt_char) + code_it += length(code_char) to_chat(user, "Last code attempt, [lastattempt], had [bulls] correct digits at correct positions and [cows] correct digits at incorrect positions.") return diff --git a/code/modules/mining/machine_silo.dm b/code/modules/mining/machine_silo.dm index e0a8b9b5..246106be 100644 --- a/code/modules/mining/machine_silo.dm +++ b/code/modules/mining/machine_silo.dm @@ -230,5 +230,5 @@ GLOBAL_LIST_EMPTY(silo_access_logs) var/val = round(materials[key]) / MINERAL_MATERIAL_AMOUNT msg += sep sep = ", " - msg += "[amount < 0 ? "-" : "+"][val] [copytext(key, 2)]" + msg += "[amount < 0 ? "-" : "+"][val] [copytext(key, length(key[1]) + 1)]" formatted = msg.Join() diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index bc4e5a0d..2284e5f6 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -232,14 +232,16 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER) var/b_val var/g_val var/color_format = length(input_color) + if(color_format != length_char(input_color)) + return 0 if(color_format == 3) - r_val = hex2num(copytext(input_color, 1, 2))*16 - g_val = hex2num(copytext(input_color, 2, 3))*16 - b_val = hex2num(copytext(input_color, 3, 0))*16 + r_val = hex2num(copytext(input_color, 1, 2)) * 16 + g_val = hex2num(copytext(input_color, 2, 3)) * 16 + b_val = hex2num(copytext(input_color, 3, 0)) * 16 else if(color_format == 6) r_val = hex2num(copytext(input_color, 1, 3)) g_val = hex2num(copytext(input_color, 3, 5)) - b_val = hex2num(copytext(input_color, 5, 0)) + b_val = hex2num(copytext(input_color, 5, 7)) else return 0 //If the color format is not 3 or 6, you're using an unexpected way to represent a color. @@ -253,7 +255,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER) if(b_val > 255) b_val = 255 - return num2hex(r_val, 2) + num2hex(g_val, 2) + num2hex(b_val, 2) + return copytext(rgb(r_val, g_val, b_val), 2) /* Transfer_mind is there to check if mob is being deleted/not going to have a body. @@ -262,7 +264,7 @@ Works together with spawning an observer, noted above. /mob/proc/ghostize(can_reenter_corpse = TRUE, special = FALSE, penalize = FALSE) penalize = suiciding || penalize // suicide squad. - if(!key || cmptext(copytext(key,1,2),"@") || (SEND_SIGNAL(src, COMSIG_MOB_GHOSTIZE, can_reenter_corpse, special, penalize) & COMPONENT_BLOCK_GHOSTING)) + if(!key || key[1] == "@" || (SEND_SIGNAL(src, COMSIG_MOB_GHOSTIZE, can_reenter_corpse, special, penalize) & COMPONENT_BLOCK_GHOSTING)) return //mob has no key, is an aghost or some component hijacked. stop_sound_channel(CHANNEL_HEARTBEAT) //Stop heartbeat sounds because You Are A Ghost Now var/mob/dead/observer/ghost = new(src) // Transfer safety to observer spawning proc. @@ -357,7 +359,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp if(!can_reenter_corpse) to_chat(src, "You cannot re-enter your body.") return - if(mind.current.key && copytext(mind.current.key,1,2)!="@") //makes sure we don't accidentally kick any clients + if(mind.current.key && mind.current.key[1] != "@") //makes sure we don't accidentally kick any clients to_chat(usr, "Another consciousness is in your body...It is resisting you.") return client.change_view(CONFIG_GET(string/default_view)) diff --git a/code/modules/mob/dead/observer/say.dm b/code/modules/mob/dead/observer/say.dm index 0d626d67..d039ed6e 100644 --- a/code/modules/mob/dead/observer/say.dm +++ b/code/modules/mob/dead/observer/say.dm @@ -1,43 +1,42 @@ -/mob/dead/observer/say(message, bubble_type, var/list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null) - message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN)) - if (!message) - return - - var/message_mode = get_message_mode(message) - if(client && (message_mode == MODE_ADMIN || message_mode == MODE_DEADMIN)) - message = copytext(message, 3) - if(findtext(message, " ", 1, 2)) - message = copytext(message, 2) - - if(message_mode == MODE_ADMIN) - client.cmd_admin_say(message) - else if(message_mode == MODE_DEADMIN) - client.dsay(message) - return - - src.log_talk(message, LOG_SAY, tag="ghost") - - if(check_emote(message)) - return - - . = say_dead(message) - -/mob/dead/observer/Hear(message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, message_mode, atom/movable/source) - . = ..() - var/atom/movable/to_follow = speaker - if(radio_freq) - var/atom/movable/virtualspeaker/V = speaker - - if(isAI(V.source)) - var/mob/living/silicon/ai/S = V.source - to_follow = S.eyeobj - else - to_follow = V.source - var/link = FOLLOW_LINK(src, to_follow) - // Create map text prior to modifying message for goonchat - if (client?.prefs.chat_on_map && (client.prefs.see_chat_non_mob || ismob(speaker))) - create_chat_message(speaker, message_language, raw_message, spans, message_mode) - // Recompose the message, because it's scrambled by default - message = compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mode, FALSE, source) - to_chat(src, "[link] [message]") - +/mob/dead/observer/say(message, bubble_type, var/list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null) + message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)) + if (!message) + return + + var/message_mode = get_message_mode(message) + if(client && (message_mode == MODE_ADMIN || message_mode == MODE_DEADMIN)) + message = copytext_char(message, 3) + message = trim_left(message) + + if(message_mode == MODE_ADMIN) + client.cmd_admin_say(message) + else if(message_mode == MODE_DEADMIN) + client.dsay(message) + return + + src.log_talk(message, LOG_SAY, tag="ghost") + + if(check_emote(message)) + return + + . = say_dead(message) + +/mob/dead/observer/Hear(message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, message_mode, atom/movable/source) + . = ..() + var/atom/movable/to_follow = speaker + if(radio_freq) + var/atom/movable/virtualspeaker/V = speaker + + if(isAI(V.source)) + var/mob/living/silicon/ai/S = V.source + to_follow = S.eyeobj + else + to_follow = V.source + var/link = FOLLOW_LINK(src, to_follow) + // Create map text prior to modifying message for goonchat + if (client?.prefs.chat_on_map && (client.prefs.see_chat_non_mob || ismob(speaker))) + create_chat_message(speaker, message_language, raw_message, spans, message_mode) + // Recompose the message, because it's scrambled by default + message = compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mode, FALSE, source) + to_chat(src, "[link] [message]") + diff --git a/code/modules/mob/emote.dm b/code/modules/mob/emote.dm index 4b04c3f2..1d7e76f1 100644 --- a/code/modules/mob/emote.dm +++ b/code/modules/mob/emote.dm @@ -4,7 +4,7 @@ var/param = message var/custom_param = findchar(act, " ") if(custom_param) - param = copytext(act, custom_param + 1, length(act) + 1) + param = copytext(act, custom_param + length(act[custom_param])) act = copytext(act, 1, custom_param) var/datum/emote/E diff --git a/code/modules/mob/living/blood.dm b/code/modules/mob/living/blood.dm index 5887d10e..968df0c0 100644 --- a/code/modules/mob/living/blood.dm +++ b/code/modules/mob/living/blood.dm @@ -185,7 +185,7 @@ var/datum/disease/D = thing blood_data["viruses"] += D.Copy() - blood_data["blood_DNA"] = copytext(dna.unique_enzymes,1,0) + blood_data["blood_DNA"] = dna.unique_enzymes blood_data["bloodcolor"] = bloodtype_to_color(dna.blood_type) if(disease_resistances && disease_resistances.len) blood_data["resistances"] = disease_resistances.Copy() @@ -204,7 +204,7 @@ if(!suiciding) blood_data["cloneable"] = 1 - blood_data["blood_type"] = copytext(dna.blood_type,1,0) + blood_data["blood_type"] = dna.blood_type blood_data["gender"] = gender blood_data["real_name"] = real_name blood_data["features"] = dna.features diff --git a/code/modules/mob/living/carbon/alien/alien.dm b/code/modules/mob/living/carbon/alien/alien.dm index f7fdd2d3..bd24a4b4 100644 --- a/code/modules/mob/living/carbon/alien/alien.dm +++ b/code/modules/mob/living/carbon/alien/alien.dm @@ -120,7 +120,8 @@ Des: Removes all infected images from the alien. /mob/living/carbon/alien/proc/RemoveInfectionImages() if (client) for(var/image/I in client.images) - if(dd_hasprefix_case(I.icon_state, "infected")) + var/searchfor = "infected" + if(findtext(I.icon_state, searchfor, 1, length(searchfor) + 1)) qdel(I) return diff --git a/code/modules/mob/living/carbon/alien/special/alien_embryo.dm b/code/modules/mob/living/carbon/alien/special/alien_embryo.dm index 4ada8834..539ff48f 100644 --- a/code/modules/mob/living/carbon/alien/special/alien_embryo.dm +++ b/code/modules/mob/living/carbon/alien/special/alien_embryo.dm @@ -1,137 +1,138 @@ -// This is to replace the previous datum/disease/alien_embryo for slightly improved handling and maintainability -// It functions almost identically (see code/datums/diseases/alien_embryo.dm) -/obj/item/organ/body_egg/alien_embryo - name = "alien embryo" - icon = 'icons/mob/alien.dmi' - icon_state = "larva0_dead" - var/stage = 0 - var/bursting = FALSE - -/obj/item/organ/body_egg/alien_embryo/on_find(mob/living/finder) - ..() - if(stage < 4) - to_chat(finder, "It's small and weak, barely the size of a foetus.") - else - to_chat(finder, "It's grown quite large, and writhes slightly as you look at it.") - if(prob(10)) - AttemptGrow(0) - -/obj/item/organ/body_egg/alien_embryo/prepare_eat() - var/obj/S = ..() - S.reagents.add_reagent(/datum/reagent/toxin/acid, 10) - return S - -/obj/item/organ/body_egg/alien_embryo/on_life() - .=..() - switch(stage) - if(2, 3) - if(prob(2)) - owner.emote("sneeze") - if(prob(2)) - owner.emote("cough") - if(prob(2)) - to_chat(owner, "Your throat feels sore.") - if(prob(2)) - to_chat(owner, "Mucous runs down the back of your throat.") - if(4) - if(prob(2)) - owner.emote("sneeze") - if(prob(2)) - owner.emote("cough") - if(prob(4)) - to_chat(owner, "Your muscles ache.") - if(prob(20)) - owner.take_bodypart_damage(1) - if(prob(4)) - to_chat(owner, "Your stomach hurts.") - if(prob(20)) - owner.adjustToxLoss(1) - if(5) - to_chat(owner, "You feel something tearing its way out of your stomach...") - owner.adjustToxLoss(10) - -/obj/item/organ/body_egg/alien_embryo/egg_process() - if(stage < 5 && prob(3)) - stage++ - INVOKE_ASYNC(src, .proc/RefreshInfectionImage) - - if(stage == 5 && prob(50)) - for(var/datum/surgery/S in owner.surgeries) - if(S.location == BODY_ZONE_CHEST && istype(S.get_surgery_step(), /datum/surgery_step/manipulate_organs)) - AttemptGrow(0) - return - AttemptGrow() - - - -/obj/item/organ/body_egg/alien_embryo/proc/AttemptGrow(var/kill_on_sucess=TRUE) - if(!owner || bursting) - return - - bursting = TRUE - - var/list/candidates = pollGhostCandidates("Do you want to play as an alien larva that will burst out of [owner]?", ROLE_ALIEN, null, ROLE_ALIEN, 100, POLL_IGNORE_ALIEN_LARVA) - - if(QDELETED(src) || QDELETED(owner)) - return - - if(!candidates.len || !owner) - bursting = FALSE - stage = 4 - return - - var/mob/dead/observer/ghost = pick(candidates) - - var/mutable_appearance/overlay = mutable_appearance('icons/mob/alien.dmi', "burst_lie") - owner.add_overlay(overlay) - - var/atom/xeno_loc = get_turf(owner) - var/mob/living/carbon/alien/larva/new_xeno = new(xeno_loc) - new_xeno.key = ghost.key - SEND_SOUND(new_xeno, sound('sound/voice/hiss5.ogg',0,0,0,100)) //To get the player's attention - new_xeno.canmove = 0 //so we don't move during the bursting animation - new_xeno.notransform = 1 - new_xeno.invisibility = INVISIBILITY_MAXIMUM - - sleep(6) - - if(QDELETED(src) || QDELETED(owner)) - return - - if(new_xeno) - new_xeno.canmove = 1 - new_xeno.notransform = 0 - new_xeno.invisibility = 0 - - if(kill_on_sucess) //ITS TOO LATE - new_xeno.visible_message("[new_xeno] bursts out of [owner]!", "You exit [owner], your previous host.", "You hear organic matter ripping and tearing!") - owner.apply_damage(rand(100,300),BRUTE,zone,FALSE) //Random high damage to torso so health sensors don't metagame. - owner.spill_organs(TRUE,FALSE,TRUE) //Lets still make the death gruesome and impossible to just simply defib someone. - owner.death(FALSE) //Just in case some freak occurance occurs where you somehow survive all your organs being removed from you and the 100-300 brute damage. - else //When it is removed via surgery at a late stage, rather than forced. - new_xeno.visible_message("[new_xeno] wriggles out of [owner]!", "You exit [owner], your previous host.") - owner.adjustBruteLoss(40) - owner.cut_overlay(overlay) - qdel(src) - - -/*---------------------------------------- -Proc: AddInfectionImages(C) -Des: Adds the infection image to all aliens for this embryo -----------------------------------------*/ -/obj/item/organ/body_egg/alien_embryo/AddInfectionImages() - for(var/mob/living/carbon/alien/alien in GLOB.player_list) - if(alien.client) - var/I = image('icons/mob/alien.dmi', loc = owner, icon_state = "infected[stage]") - alien.client.images += I - -/*---------------------------------------- -Proc: RemoveInfectionImage(C) -Des: Removes all images from the mob infected by this embryo -----------------------------------------*/ -/obj/item/organ/body_egg/alien_embryo/RemoveInfectionImages() - for(var/mob/living/carbon/alien/alien in GLOB.player_list) - if(alien.client) - for(var/image/I in alien.client.images) - if(dd_hasprefix_case(I.icon_state, "infected") && I.loc == owner) - qdel(I) +// This is to replace the previous datum/disease/alien_embryo for slightly improved handling and maintainability +// It functions almost identically (see code/datums/diseases/alien_embryo.dm) +/obj/item/organ/body_egg/alien_embryo + name = "alien embryo" + icon = 'icons/mob/alien.dmi' + icon_state = "larva0_dead" + var/stage = 0 + var/bursting = FALSE + +/obj/item/organ/body_egg/alien_embryo/on_find(mob/living/finder) + ..() + if(stage < 4) + to_chat(finder, "It's small and weak, barely the size of a foetus.") + else + to_chat(finder, "It's grown quite large, and writhes slightly as you look at it.") + if(prob(10)) + AttemptGrow(0) + +/obj/item/organ/body_egg/alien_embryo/prepare_eat() + var/obj/S = ..() + S.reagents.add_reagent(/datum/reagent/toxin/acid, 10) + return S + +/obj/item/organ/body_egg/alien_embryo/on_life() + .=..() + switch(stage) + if(2, 3) + if(prob(2)) + owner.emote("sneeze") + if(prob(2)) + owner.emote("cough") + if(prob(2)) + to_chat(owner, "Your throat feels sore.") + if(prob(2)) + to_chat(owner, "Mucous runs down the back of your throat.") + if(4) + if(prob(2)) + owner.emote("sneeze") + if(prob(2)) + owner.emote("cough") + if(prob(4)) + to_chat(owner, "Your muscles ache.") + if(prob(20)) + owner.take_bodypart_damage(1) + if(prob(4)) + to_chat(owner, "Your stomach hurts.") + if(prob(20)) + owner.adjustToxLoss(1) + if(5) + to_chat(owner, "You feel something tearing its way out of your stomach...") + owner.adjustToxLoss(10) + +/obj/item/organ/body_egg/alien_embryo/egg_process() + if(stage < 5 && prob(3)) + stage++ + INVOKE_ASYNC(src, .proc/RefreshInfectionImage) + + if(stage == 5 && prob(50)) + for(var/datum/surgery/S in owner.surgeries) + if(S.location == BODY_ZONE_CHEST && istype(S.get_surgery_step(), /datum/surgery_step/manipulate_organs)) + AttemptGrow(0) + return + AttemptGrow() + + + +/obj/item/organ/body_egg/alien_embryo/proc/AttemptGrow(var/kill_on_sucess=TRUE) + if(!owner || bursting) + return + + bursting = TRUE + + var/list/candidates = pollGhostCandidates("Do you want to play as an alien larva that will burst out of [owner]?", ROLE_ALIEN, null, ROLE_ALIEN, 100, POLL_IGNORE_ALIEN_LARVA) + + if(QDELETED(src) || QDELETED(owner)) + return + + if(!candidates.len || !owner) + bursting = FALSE + stage = 4 + return + + var/mob/dead/observer/ghost = pick(candidates) + + var/mutable_appearance/overlay = mutable_appearance('icons/mob/alien.dmi', "burst_lie") + owner.add_overlay(overlay) + + var/atom/xeno_loc = get_turf(owner) + var/mob/living/carbon/alien/larva/new_xeno = new(xeno_loc) + new_xeno.key = ghost.key + SEND_SOUND(new_xeno, sound('sound/voice/hiss5.ogg',0,0,0,100)) //To get the player's attention + new_xeno.canmove = 0 //so we don't move during the bursting animation + new_xeno.notransform = 1 + new_xeno.invisibility = INVISIBILITY_MAXIMUM + + sleep(6) + + if(QDELETED(src) || QDELETED(owner)) + return + + if(new_xeno) + new_xeno.canmove = 1 + new_xeno.notransform = 0 + new_xeno.invisibility = 0 + + if(kill_on_sucess) //ITS TOO LATE + new_xeno.visible_message("[new_xeno] bursts out of [owner]!", "You exit [owner], your previous host.", "You hear organic matter ripping and tearing!") + owner.apply_damage(rand(100,300),BRUTE,zone,FALSE) //Random high damage to torso so health sensors don't metagame. + owner.spill_organs(TRUE,FALSE,TRUE) //Lets still make the death gruesome and impossible to just simply defib someone. + owner.death(FALSE) //Just in case some freak occurance occurs where you somehow survive all your organs being removed from you and the 100-300 brute damage. + else //When it is removed via surgery at a late stage, rather than forced. + new_xeno.visible_message("[new_xeno] wriggles out of [owner]!", "You exit [owner], your previous host.") + owner.adjustBruteLoss(40) + owner.cut_overlay(overlay) + qdel(src) + + +/*---------------------------------------- +Proc: AddInfectionImages(C) +Des: Adds the infection image to all aliens for this embryo +----------------------------------------*/ +/obj/item/organ/body_egg/alien_embryo/AddInfectionImages() + for(var/mob/living/carbon/alien/alien in GLOB.player_list) + if(alien.client) + var/I = image('icons/mob/alien.dmi', loc = owner, icon_state = "infected[stage]") + alien.client.images += I + +/*---------------------------------------- +Proc: RemoveInfectionImage(C) +Des: Removes all images from the mob infected by this embryo +----------------------------------------*/ +/obj/item/organ/body_egg/alien_embryo/RemoveInfectionImages() + for(var/mob/living/carbon/alien/alien in GLOB.player_list) + if(alien.client) + for(var/image/I in alien.client.images) + var/searchfor = "infected" + if(I.loc == owner && findtext(I.icon_state, searchfor, 1, length(searchfor) + 1)) + qdel(I) diff --git a/code/modules/mob/living/carbon/human/say.dm b/code/modules/mob/living/carbon/human/say.dm index c54f4101..29597344 100644 --- a/code/modules/mob/living/carbon/human/say.dm +++ b/code/modules/mob/living/carbon/human/say.dm @@ -1,116 +1,108 @@ -/mob/living/carbon/human/say_mod(input, message_mode) - verb_say = dna.species.say_mod - . = ..() - if(message_mode != MODE_CUSTOM_SAY && message_mode != MODE_WHISPER_CRIT) - switch(slurring) - if(10 to 25) - return "jumbles" - if(25 to 50) - return "slurs" - if(50 to INFINITY) - return "garbles" - -/mob/living/carbon/human/GetVoice() - if(istype(wear_mask, /obj/item/clothing/mask/chameleon)) - var/obj/item/clothing/mask/chameleon/V = wear_mask - if(V.vchange && wear_id) - var/obj/item/card/id/idcard = wear_id.GetID() - if(istype(idcard)) - return idcard.registered_name - else - return real_name - else - return real_name - if(mind) - var/datum/antagonist/changeling/changeling = mind.has_antag_datum(/datum/antagonist/changeling) - if(changeling && changeling.mimicing ) - return changeling.mimicing - if(GetSpecialVoice()) - return GetSpecialVoice() - return real_name - -/mob/living/carbon/human/IsVocal() - // how do species that don't breathe talk? magic, that's what. - if(!HAS_TRAIT_FROM(src, TRAIT_NOBREATH, SPECIES_TRAIT) && !getorganslot(ORGAN_SLOT_LUNGS)) - return FALSE - if(mind) - return !mind.miming - return TRUE - -/mob/living/carbon/human/proc/SetSpecialVoice(new_voice) - if(new_voice) - special_voice = new_voice - return - -/mob/living/carbon/human/proc/UnsetSpecialVoice() - special_voice = "" - return - -/mob/living/carbon/human/proc/GetSpecialVoice() - return special_voice - -/mob/living/carbon/human/binarycheck() - if(ears) - var/obj/item/radio/headset/dongle = ears - if(!istype(dongle)) - return FALSE - if(dongle.translate_binary) - return TRUE - -/mob/living/carbon/human/radio(message, message_mode, list/spans, language) - . = ..() - if(.) - return - - switch(message_mode) - if(MODE_HEADSET) - if (ears) - ears.talk_into(src, message, , spans, language) - return ITALICS | REDUCE_RANGE - - if(MODE_DEPARTMENT) - if (ears) - ears.talk_into(src, message, message_mode, spans, language) - return ITALICS | REDUCE_RANGE - - if(message_mode in GLOB.radiochannels) - if(ears) - ears.talk_into(src, message, message_mode, spans, language) - return ITALICS | REDUCE_RANGE - - return 0 - -/mob/living/carbon/human/get_alt_name() - if(name != GetVoice()) - return " (as [get_id_name("Unknown")])" - -/mob/living/carbon/human/proc/forcesay(list/append) //this proc is at the bottom of the file because quote fuckery makes notepad++ cri - if(stat == CONSCIOUS) - if(client) - var/virgin = 1 //has the text been modified yet? - var/temp = winget(client, "input", "text") - if(findtextEx(temp, "Say \"", 1, 7) && length(temp) > 5) //"case sensitive means - - temp = replacetext(temp, ";", "") //general radio - - if(findtext(trim_left(temp), ":", 6, 7)) //dept radio - temp = copytext(trim_left(temp), 8) - virgin = 0 - - if(virgin) - temp = copytext(trim_left(temp), 6) //normal speech - virgin = 0 - - while(findtext(trim_left(temp), ":", 1, 2)) //dept radio again (necessary) - temp = copytext(trim_left(temp), 3) - - if(findtext(temp, "*", 1, 2)) //emotes - return - - var/trimmed = trim_left(temp) - if(length(trimmed)) - if(append) - temp += pick(append) - - say(temp) - winset(client, "input", "text=[null]") +/mob/living/carbon/human/say_mod(input, message_mode) + verb_say = dna.species.say_mod + . = ..() + if(message_mode != MODE_CUSTOM_SAY && message_mode != MODE_WHISPER_CRIT) + switch(slurring) + if(10 to 25) + return "jumbles" + if(25 to 50) + return "slurs" + if(50 to INFINITY) + return "garbles" + +/mob/living/carbon/human/GetVoice() + if(istype(wear_mask, /obj/item/clothing/mask/chameleon)) + var/obj/item/clothing/mask/chameleon/V = wear_mask + if(V.vchange && wear_id) + var/obj/item/card/id/idcard = wear_id.GetID() + if(istype(idcard)) + return idcard.registered_name + else + return real_name + else + return real_name + if(mind) + var/datum/antagonist/changeling/changeling = mind.has_antag_datum(/datum/antagonist/changeling) + if(changeling && changeling.mimicing ) + return changeling.mimicing + if(GetSpecialVoice()) + return GetSpecialVoice() + return real_name + +/mob/living/carbon/human/IsVocal() + // how do species that don't breathe talk? magic, that's what. + if(!HAS_TRAIT_FROM(src, TRAIT_NOBREATH, SPECIES_TRAIT) && !getorganslot(ORGAN_SLOT_LUNGS)) + return FALSE + if(mind) + return !mind.miming + return TRUE + +/mob/living/carbon/human/proc/SetSpecialVoice(new_voice) + if(new_voice) + special_voice = new_voice + return + +/mob/living/carbon/human/proc/UnsetSpecialVoice() + special_voice = "" + return + +/mob/living/carbon/human/proc/GetSpecialVoice() + return special_voice + +/mob/living/carbon/human/binarycheck() + if(ears) + var/obj/item/radio/headset/dongle = ears + if(!istype(dongle)) + return FALSE + if(dongle.translate_binary) + return TRUE + +/mob/living/carbon/human/radio(message, message_mode, list/spans, language) + . = ..() + if(.) + return + + switch(message_mode) + if(MODE_HEADSET) + if (ears) + ears.talk_into(src, message, , spans, language) + return ITALICS | REDUCE_RANGE + + if(MODE_DEPARTMENT) + if (ears) + ears.talk_into(src, message, message_mode, spans, language) + return ITALICS | REDUCE_RANGE + + if(message_mode in GLOB.radiochannels) + if(ears) + ears.talk_into(src, message, message_mode, spans, language) + return ITALICS | REDUCE_RANGE + + return 0 + +/mob/living/carbon/human/get_alt_name() + if(name != GetVoice()) + return " (as [get_id_name("Unknown")])" + +/mob/living/carbon/human/proc/forcesay(list/append) //this proc is at the bottom of the file because quote fuckery makes notepad++ cri + if(stat == CONSCIOUS) + if(client) + var/temp = winget(client, "input", "text") + var/say_starter = "Say \"" //" + if(findtextEx(temp, say_starter, 1, length(say_starter) + 1) && length(temp) > length(say_starter)) //case sensitive means + + temp = trim_left(copytext(temp, length(say_starter + 1))) + temp = replacetext(temp, ";", "", 1, 2) //general radio + while(trim_left(temp)[1] == ":") //dept radio again (necessary) + temp = copytext_char(trim_left(temp), 3) + + if(temp[1] == "*") //emotes + return + + var/trimmed = trim_left(temp) + if(length(trimmed)) + if(append) + trimmed += pick(append) + + say(trimmed) + winset(client, "input", "text=[null]") diff --git a/code/modules/mob/living/emote.dm b/code/modules/mob/living/emote.dm index 2fc3bc0c..2892ab5c 100644 --- a/code/modules/mob/living/emote.dm +++ b/code/modules/mob/living/emote.dm @@ -1,519 +1,512 @@ - -/* EMOTE DATUMS */ -/datum/emote/living - mob_type_allowed_typecache = /mob/living - mob_type_blacklist_typecache = list(/mob/living/simple_animal/slime, /mob/living/brain) - -/datum/emote/living/blush - key = "blush" - key_third_person = "blushes" - message = "blushes." - -/datum/emote/living/bow - key = "bow" - key_third_person = "bows" - message = "bows." - message_param = "bows to %t." - restraint_check = TRUE - -/datum/emote/living/burp - key = "burp" - key_third_person = "burps" - message = "burps." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/choke - key = "choke" - key_third_person = "chokes" - message = "chokes!" - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/cross - key = "cross" - key_third_person = "crosses" - message = "crosses their arms." - restraint_check = TRUE - -/datum/emote/living/chuckle - key = "chuckle" - key_third_person = "chuckles" - message = "chuckles." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/collapse - key = "collapse" - key_third_person = "collapses" - message = "collapses!" - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/collapse/run_emote(mob/user, params) - . = ..() - if(. && isliving(user)) - var/mob/living/L = user - L.Unconscious(40) - -/datum/emote/living/cough - key = "cough" - key_third_person = "coughs" - message = "coughs!" - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/cough/can_run_emote(mob/user, status_check = TRUE , intentional) - . = ..() - if(HAS_TRAIT(user, TRAIT_SOOTHED_THROAT)) - return FALSE - -/datum/emote/living/dance - key = "dance" - key_third_person = "dances" - message = "dances around happily." - restraint_check = TRUE - -/datum/emote/living/deathgasp - key = "deathgasp" - key_third_person = "deathgasps" - message = "seizes up and falls limp, their eyes dead and lifeless..." - message_robot = "shudders violently for a moment before falling still, its eyes slowly darkening." - message_AI = "lets out a flurry of sparks, its screen flickering as its systems slowly halt." - message_alien = "lets out a waning guttural screech, green blood bubbling from its maw..." - message_larva = "lets out a sickly hiss of air and falls limply to the floor..." - message_monkey = "lets out a faint chimper as it collapses and stops moving..." - message_simple = "stops moving..." - stat_allowed = UNCONSCIOUS - -/datum/emote/living/deathgasp/run_emote(mob/user, params) - var/mob/living/simple_animal/S = user - if(istype(S) && S.deathmessage) - message_simple = S.deathmessage - . = ..() - message_simple = initial(message_simple) - if(. && isalienadult(user)) - playsound(user.loc, 'sound/voice/hiss6.ogg', 80, 1, 1) - -/datum/emote/living/drool - key = "drool" - key_third_person = "drools" - message = "drools." - -/datum/emote/living/faint - key = "faint" - key_third_person = "faints" - message = "faints." - -/datum/emote/living/faint/run_emote(mob/user, params) - . = ..() - if(. && isliving(user)) - var/mob/living/L = user - L.SetSleeping(200) - -/datum/emote/living/flap - key = "flap" - key_third_person = "flaps" - message = "flaps their wings." - restraint_check = TRUE - var/wing_time = 20 - -/datum/emote/living/flap/run_emote(mob/user, params) - . = ..() - if(. && ishuman(user)) - var/mob/living/carbon/human/H = user - var/open = FALSE - if(H.dna.features["wings"] != "None") - if("wingsopen" in H.dna.species.mutant_bodyparts) - open = TRUE - H.CloseWings() - else - H.OpenWings() - addtimer(CALLBACK(H, open ? /mob/living/carbon/human.proc/OpenWings : /mob/living/carbon/human.proc/CloseWings), wing_time) - -/datum/emote/living/flap/aflap - key = "aflap" - key_third_person = "aflaps" - message = "flaps their wings ANGRILY!" - restraint_check = TRUE - wing_time = 10 - -/datum/emote/living/frown - key = "frown" - key_third_person = "frowns" - message = "frowns." - -/datum/emote/living/gag - key = "gag" - key_third_person = "gags" - message = "gags." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/gasp - key = "gasp" - key_third_person = "gasps" - message = "gasps!" - emote_type = EMOTE_AUDIBLE - stat_allowed = UNCONSCIOUS - -/datum/emote/living/giggle - key = "giggle" - key_third_person = "giggles" - message = "giggles." - message_mime = "giggles silently!" - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/glare - key = "glare" - key_third_person = "glares" - message = "glares." - message_param = "glares at %t." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/grin - key = "grin" - key_third_person = "grins" - message = "grins." - -/datum/emote/living/groan - key = "groan" - key_third_person = "groans" - message = "groans!" - message_mime = "appears to groan!" - -/datum/emote/living/grimace - key = "grimace" - key_third_person = "grimaces" - message = "grimaces." - -/datum/emote/living/jump - key = "jump" - key_third_person = "jumps" - message = "jumps!" - restraint_check = TRUE - -/datum/emote/living/kiss - key = "kiss" - key_third_person = "kisses" - message = "blows a kiss." - message_param = "blows a kiss to %t." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/laugh - key = "laugh" - key_third_person = "laughs" - message = "laughs." - message_mime = "laughs silently!" - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/laugh/can_run_emote(mob/living/user, status_check = TRUE) - . = ..() - if(. && iscarbon(user)) - var/mob/living/carbon/C = user - return !C.silent - -/datum/emote/living/laugh/run_emote(mob/user, params) - . = ..() - if(. && iscarbon(user)) //Citadel Edit because this is hilarious - var/mob/living/carbon/C = user - if(!C.mind || C.mind.miming) - return - if(iscatperson(C)) //we ask for is cat first because they're a subtype that tests true for ishumanbasic because HERESY - playsound(C, pick('sound/voice/catpeople/nyahaha1.ogg', - 'sound/voice/catpeople/nyahaha2.ogg', - 'sound/voice/catpeople/nyaha.ogg', - 'sound/voice/catpeople/nyahehe.ogg'), - 50, 1) - return - if(ishumanbasic(C)) - if(user.gender == FEMALE) - playsound(C, 'sound/voice/human/womanlaugh.ogg', 50, 1) - else - playsound(C, pick('sound/voice/human/manlaugh1.ogg', 'sound/voice/human/manlaugh2.ogg'), 50, 1) - -/datum/emote/living/look - key = "look" - key_third_person = "looks" - message = "looks." - message_param = "looks at %t." - -/datum/emote/living/nod - key = "nod" - key_third_person = "nods" - message = "nods." - message_param = "nods at %t." - -/datum/emote/living/point - key = "point" - key_third_person = "points" - message = "points." - message_param = "points at %t." - restraint_check = TRUE - -/datum/emote/living/point/run_emote(mob/user, params) - message_param = initial(message_param) // reset - if(ishuman(user)) - var/mob/living/carbon/human/H = user - if(H.get_num_arms() == 0) - if(H.get_num_legs() != 0) - message_param = "tries to point at %t with a leg, falling down in the process!" - H.Knockdown(20) - else - message_param = "bumps [user.p_their()] head on the ground trying to motion towards %t." - H.adjustOrganLoss(ORGAN_SLOT_BRAIN, 5) - ..() - -/datum/emote/living/pout - key = "pout" - key_third_person = "pouts" - message = "pouts." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/scream - key = "scream" - key_third_person = "screams" - message = "screams." - message_mime = "acts out a scream!" - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/scowl - key = "scowl" - key_third_person = "scowls" - message = "scowls." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/shake - key = "shake" - key_third_person = "shakes" - message = "shakes their head." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/shiver - key = "shiver" - key_third_person = "shiver" - message = "shivers." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/sigh - key = "sigh" - key_third_person = "sighs" - message = "sighs." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/sit - key = "sit" - key_third_person = "sits" - message = "sits down." - -/datum/emote/living/smile - key = "smile" - key_third_person = "smiles" - message = "smiles." - -/datum/emote/living/sneeze - key = "sneeze" - key_third_person = "sneezes" - message = "sneezes." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/smug - key = "smug" - key_third_person = "smugs" - message = "grins smugly." - -/datum/emote/living/sniff - key = "sniff" - key_third_person = "sniffs" - message = "sniffs." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/snore - key = "snore" - key_third_person = "snores" - message = "snores." - message_mime = "sleeps soundly." - emote_type = EMOTE_AUDIBLE - stat_allowed = UNCONSCIOUS - -/datum/emote/living/stare - key = "stare" - key_third_person = "stares" - message = "stares." - message_param = "stares at %t." - -/datum/emote/living/strech - key = "stretch" - key_third_person = "stretches" - message = "stretches their arms." - -/datum/emote/living/sulk - key = "sulk" - key_third_person = "sulks" - message = "sulks down sadly." - -/datum/emote/living/surrender - key = "surrender" - key_third_person = "surrenders" - message = "puts their hands on their head and falls to the ground, they surrender!" - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/surrender/run_emote(mob/user, params) - . = ..() - if(. && isliving(user)) - var/mob/living/L = user - L.Knockdown(200) - -/datum/emote/living/sway - key = "sway" - key_third_person = "sways" - message = "sways around dizzily." - -/datum/emote/living/tremble - key = "tremble" - key_third_person = "trembles" - message = "trembles in fear!" - -/datum/emote/living/twitch - key = "twitch" - key_third_person = "twitches" - message = "twitches violently." - -/datum/emote/living/twitch_s - key = "twitch_s" - message = "twitches." - -/datum/emote/living/wave - key = "wave" - key_third_person = "waves" - message = "waves." - -/datum/emote/living/whimper - key = "whimper" - key_third_person = "whimpers" - message = "whimpers." - message_mime = "appears hurt." - -/datum/emote/living/wsmile - key = "wsmile" - key_third_person = "wsmiles" - message = "smiles weakly." - -/datum/emote/living/yawn - key = "yawn" - key_third_person = "yawns" - message = "yawns." - emote_type = EMOTE_AUDIBLE - -/datum/emote/living/custom - key = "me" - key_third_person = "custom" - message = null - -/datum/emote/living/custom/proc/check_invalid(mob/user, input) - . = TRUE - if(copytext(input,1,5) == "says") - to_chat(user, "Invalid emote.") - else if(copytext(input,1,9) == "exclaims") - to_chat(user, "Invalid emote.") - else if(copytext(input,1,6) == "yells") - to_chat(user, "Invalid emote.") - else if(copytext(input,1,5) == "asks") - to_chat(user, "Invalid emote.") - else - . = FALSE - -/datum/emote/living/custom/run_emote(mob/user, params, type_override = null) - if(jobban_isbanned(user, "emote")) - to_chat(user, "You cannot send custom emotes (banned).") - return FALSE - else if(QDELETED(user)) - return FALSE - else if(user.client && user.client.prefs.muted & MUTE_IC) - to_chat(user, "You cannot send IC messages (muted).") - return FALSE - else if(!params) - var/custom_emote = copytext(sanitize(input("Choose an emote to display.") as message|null), 1, MAX_MESSAGE_LEN) //CIT CHANGE - expands emote textbox - if(custom_emote && !check_invalid(user, custom_emote)) - var/type = input("Is this a visible or hearable emote?") as null|anything in list("Visible", "Hearable") - switch(type) - if("Visible") - emote_type = EMOTE_VISIBLE - if("Hearable") - emote_type = EMOTE_AUDIBLE - else - alert("Unable to use this emote, must be either hearable or visible.") - return - message = custom_emote - else - message = params - if(type_override) - emote_type = type_override - message = user.say_emphasis(message) - . = ..() - message = null - emote_type = EMOTE_VISIBLE - -/datum/emote/living/custom/replace_pronoun(mob/user, message) - return message - -/datum/emote/living/help - key = "help" - -/datum/emote/living/help/run_emote(mob/user, params) - var/list/keys = list() - var/list/message = list("Available emotes, you can use them with say \"*emote\": ") - - var/datum/emote/E - var/list/emote_list = E.emote_list - for(var/e in emote_list) - if(e in keys) - continue - E = emote_list[e] - if(E.can_run_emote(user, status_check = FALSE)) - keys += E.key - - keys = sortList(keys) - - for(var/emote in keys) - if(LAZYLEN(message) > 1) - message += ", [emote]" - else - message += "[emote]" - - message += "." - - message = jointext(message, "") - - to_chat(user, message) - -/datum/emote/sound/beep - key = "beep" - key_third_person = "beeps" - message = "beeps." - message_param = "beeps at %t." - sound = 'sound/machines/twobeep.ogg' - mob_type_allowed_typecache = list(/mob/living/brain, /mob/living/silicon, /mob/living/carbon/human) - -/datum/emote/living/circle - key = "circle" - key_third_person = "circles" - restraint_check = TRUE - -/datum/emote/living/circle/run_emote(mob/user, params) - . = ..() - var/obj/item/circlegame/N = new(user) - if(user.put_in_hands(N)) - to_chat(user, "You make a circle with your hand.") - else - qdel(N) - to_chat(user, "You don't have any free hands to make a circle with.") - -/datum/emote/living/slap - key = "slap" - key_third_person = "slaps" - restraint_check = TRUE - -/datum/emote/living/slap/run_emote(mob/user, params) - . = ..() - if(!.) - return - var/obj/item/slapper/N = new(user) - if(user.put_in_hands(N)) - to_chat(user, "You ready your slapping hand.") - else - to_chat(user, "You're incapable of slapping in your current state.") + +/* EMOTE DATUMS */ +/datum/emote/living + mob_type_allowed_typecache = /mob/living + mob_type_blacklist_typecache = list(/mob/living/simple_animal/slime, /mob/living/brain) + +/datum/emote/living/blush + key = "blush" + key_third_person = "blushes" + message = "blushes." + +/datum/emote/living/bow + key = "bow" + key_third_person = "bows" + message = "bows." + message_param = "bows to %t." + restraint_check = TRUE + +/datum/emote/living/burp + key = "burp" + key_third_person = "burps" + message = "burps." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/choke + key = "choke" + key_third_person = "chokes" + message = "chokes!" + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/cross + key = "cross" + key_third_person = "crosses" + message = "crosses their arms." + restraint_check = TRUE + +/datum/emote/living/chuckle + key = "chuckle" + key_third_person = "chuckles" + message = "chuckles." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/collapse + key = "collapse" + key_third_person = "collapses" + message = "collapses!" + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/collapse/run_emote(mob/user, params) + . = ..() + if(. && isliving(user)) + var/mob/living/L = user + L.Unconscious(40) + +/datum/emote/living/cough + key = "cough" + key_third_person = "coughs" + message = "coughs!" + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/cough/can_run_emote(mob/user, status_check = TRUE , intentional) + . = ..() + if(HAS_TRAIT(user, TRAIT_SOOTHED_THROAT)) + return FALSE + +/datum/emote/living/dance + key = "dance" + key_third_person = "dances" + message = "dances around happily." + restraint_check = TRUE + +/datum/emote/living/deathgasp + key = "deathgasp" + key_third_person = "deathgasps" + message = "seizes up and falls limp, their eyes dead and lifeless..." + message_robot = "shudders violently for a moment before falling still, its eyes slowly darkening." + message_AI = "lets out a flurry of sparks, its screen flickering as its systems slowly halt." + message_alien = "lets out a waning guttural screech, green blood bubbling from its maw..." + message_larva = "lets out a sickly hiss of air and falls limply to the floor..." + message_monkey = "lets out a faint chimper as it collapses and stops moving..." + message_simple = "stops moving..." + stat_allowed = UNCONSCIOUS + +/datum/emote/living/deathgasp/run_emote(mob/user, params) + var/mob/living/simple_animal/S = user + if(istype(S) && S.deathmessage) + message_simple = S.deathmessage + . = ..() + message_simple = initial(message_simple) + if(. && isalienadult(user)) + playsound(user.loc, 'sound/voice/hiss6.ogg', 80, 1, 1) + +/datum/emote/living/drool + key = "drool" + key_third_person = "drools" + message = "drools." + +/datum/emote/living/faint + key = "faint" + key_third_person = "faints" + message = "faints." + +/datum/emote/living/faint/run_emote(mob/user, params) + . = ..() + if(. && isliving(user)) + var/mob/living/L = user + L.SetSleeping(200) + +/datum/emote/living/flap + key = "flap" + key_third_person = "flaps" + message = "flaps their wings." + restraint_check = TRUE + var/wing_time = 20 + +/datum/emote/living/flap/run_emote(mob/user, params) + . = ..() + if(. && ishuman(user)) + var/mob/living/carbon/human/H = user + var/open = FALSE + if(H.dna.features["wings"] != "None") + if("wingsopen" in H.dna.species.mutant_bodyparts) + open = TRUE + H.CloseWings() + else + H.OpenWings() + addtimer(CALLBACK(H, open ? /mob/living/carbon/human.proc/OpenWings : /mob/living/carbon/human.proc/CloseWings), wing_time) + +/datum/emote/living/flap/aflap + key = "aflap" + key_third_person = "aflaps" + message = "flaps their wings ANGRILY!" + restraint_check = TRUE + wing_time = 10 + +/datum/emote/living/frown + key = "frown" + key_third_person = "frowns" + message = "frowns." + +/datum/emote/living/gag + key = "gag" + key_third_person = "gags" + message = "gags." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/gasp + key = "gasp" + key_third_person = "gasps" + message = "gasps!" + emote_type = EMOTE_AUDIBLE + stat_allowed = UNCONSCIOUS + +/datum/emote/living/giggle + key = "giggle" + key_third_person = "giggles" + message = "giggles." + message_mime = "giggles silently!" + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/glare + key = "glare" + key_third_person = "glares" + message = "glares." + message_param = "glares at %t." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/grin + key = "grin" + key_third_person = "grins" + message = "grins." + +/datum/emote/living/groan + key = "groan" + key_third_person = "groans" + message = "groans!" + message_mime = "appears to groan!" + +/datum/emote/living/grimace + key = "grimace" + key_third_person = "grimaces" + message = "grimaces." + +/datum/emote/living/jump + key = "jump" + key_third_person = "jumps" + message = "jumps!" + restraint_check = TRUE + +/datum/emote/living/kiss + key = "kiss" + key_third_person = "kisses" + message = "blows a kiss." + message_param = "blows a kiss to %t." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/laugh + key = "laugh" + key_third_person = "laughs" + message = "laughs." + message_mime = "laughs silently!" + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/laugh/can_run_emote(mob/living/user, status_check = TRUE) + . = ..() + if(. && iscarbon(user)) + var/mob/living/carbon/C = user + return !C.silent + +/datum/emote/living/laugh/run_emote(mob/user, params) + . = ..() + if(. && iscarbon(user)) //Citadel Edit because this is hilarious + var/mob/living/carbon/C = user + if(!C.mind || C.mind.miming) + return + if(iscatperson(C)) //we ask for is cat first because they're a subtype that tests true for ishumanbasic because HERESY + playsound(C, pick('sound/voice/catpeople/nyahaha1.ogg', + 'sound/voice/catpeople/nyahaha2.ogg', + 'sound/voice/catpeople/nyaha.ogg', + 'sound/voice/catpeople/nyahehe.ogg'), + 50, 1) + return + if(ishumanbasic(C)) + if(user.gender == FEMALE) + playsound(C, 'sound/voice/human/womanlaugh.ogg', 50, 1) + else + playsound(C, pick('sound/voice/human/manlaugh1.ogg', 'sound/voice/human/manlaugh2.ogg'), 50, 1) + +/datum/emote/living/look + key = "look" + key_third_person = "looks" + message = "looks." + message_param = "looks at %t." + +/datum/emote/living/nod + key = "nod" + key_third_person = "nods" + message = "nods." + message_param = "nods at %t." + +/datum/emote/living/point + key = "point" + key_third_person = "points" + message = "points." + message_param = "points at %t." + restraint_check = TRUE + +/datum/emote/living/point/run_emote(mob/user, params) + message_param = initial(message_param) // reset + if(ishuman(user)) + var/mob/living/carbon/human/H = user + if(H.get_num_arms() == 0) + if(H.get_num_legs() != 0) + message_param = "tries to point at %t with a leg, falling down in the process!" + H.Knockdown(20) + else + message_param = "bumps [user.p_their()] head on the ground trying to motion towards %t." + H.adjustOrganLoss(ORGAN_SLOT_BRAIN, 5) + ..() + +/datum/emote/living/pout + key = "pout" + key_third_person = "pouts" + message = "pouts." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/scream + key = "scream" + key_third_person = "screams" + message = "screams." + message_mime = "acts out a scream!" + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/scowl + key = "scowl" + key_third_person = "scowls" + message = "scowls." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/shake + key = "shake" + key_third_person = "shakes" + message = "shakes their head." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/shiver + key = "shiver" + key_third_person = "shiver" + message = "shivers." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/sigh + key = "sigh" + key_third_person = "sighs" + message = "sighs." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/sit + key = "sit" + key_third_person = "sits" + message = "sits down." + +/datum/emote/living/smile + key = "smile" + key_third_person = "smiles" + message = "smiles." + +/datum/emote/living/sneeze + key = "sneeze" + key_third_person = "sneezes" + message = "sneezes." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/smug + key = "smug" + key_third_person = "smugs" + message = "grins smugly." + +/datum/emote/living/sniff + key = "sniff" + key_third_person = "sniffs" + message = "sniffs." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/snore + key = "snore" + key_third_person = "snores" + message = "snores." + message_mime = "sleeps soundly." + emote_type = EMOTE_AUDIBLE + stat_allowed = UNCONSCIOUS + +/datum/emote/living/stare + key = "stare" + key_third_person = "stares" + message = "stares." + message_param = "stares at %t." + +/datum/emote/living/strech + key = "stretch" + key_third_person = "stretches" + message = "stretches their arms." + +/datum/emote/living/sulk + key = "sulk" + key_third_person = "sulks" + message = "sulks down sadly." + +/datum/emote/living/surrender + key = "surrender" + key_third_person = "surrenders" + message = "puts their hands on their head and falls to the ground, they surrender!" + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/surrender/run_emote(mob/user, params) + . = ..() + if(. && isliving(user)) + var/mob/living/L = user + L.Knockdown(200) + +/datum/emote/living/sway + key = "sway" + key_third_person = "sways" + message = "sways around dizzily." + +/datum/emote/living/tremble + key = "tremble" + key_third_person = "trembles" + message = "trembles in fear!" + +/datum/emote/living/twitch + key = "twitch" + key_third_person = "twitches" + message = "twitches violently." + +/datum/emote/living/twitch_s + key = "twitch_s" + message = "twitches." + +/datum/emote/living/wave + key = "wave" + key_third_person = "waves" + message = "waves." + +/datum/emote/living/whimper + key = "whimper" + key_third_person = "whimpers" + message = "whimpers." + message_mime = "appears hurt." + +/datum/emote/living/wsmile + key = "wsmile" + key_third_person = "wsmiles" + message = "smiles weakly." + +/datum/emote/living/yawn + key = "yawn" + key_third_person = "yawns" + message = "yawns." + emote_type = EMOTE_AUDIBLE + +/datum/emote/living/custom + key = "me" + key_third_person = "custom" + message = null + +/datum/emote/living/custom/proc/check_invalid(mob/user, input) + if(stop_bad_mime.Find(input, 1, 1)) + to_chat(user, "Invalid emote.") + return TRUE + return FALSE + +/datum/emote/living/custom/run_emote(mob/user, params, type_override = null) + if(jobban_isbanned(user, "emote")) + to_chat(user, "You cannot send custom emotes (banned).") + return FALSE + else if(QDELETED(user)) + return FALSE + else if(user.client && user.client.prefs.muted & MUTE_IC) + to_chat(user, "You cannot send IC messages (muted).") + return FALSE + else if(!params) + var/custom_emote = stripped_multiline_input("Choose an emote to display.", "Custom Emote", null, MAX_MESSAGE_LEN) + if(custom_emote && !check_invalid(user, custom_emote)) + var/type = input("Is this a visible or hearable emote?") as null|anything in list("Visible", "Hearable") + switch(type) + if("Visible") + emote_type = EMOTE_VISIBLE + if("Hearable") + emote_type = EMOTE_AUDIBLE + else + alert("Unable to use this emote, must be either hearable or visible.") + return + message = custom_emote + else + message = params + if(type_override) + emote_type = type_override + message = user.say_emphasis(message) + . = ..() + message = null + emote_type = EMOTE_VISIBLE + +/datum/emote/living/custom/replace_pronoun(mob/user, message) + return message + +/datum/emote/living/help + key = "help" + +/datum/emote/living/help/run_emote(mob/user, params) + var/list/keys = list() + var/list/message = list("Available emotes, you can use them with say \"*emote\": ") + + var/datum/emote/E + var/list/emote_list = E.emote_list + for(var/e in emote_list) + if(e in keys) + continue + E = emote_list[e] + if(E.can_run_emote(user, status_check = FALSE)) + keys += E.key + + keys = sortList(keys) + + for(var/emote in keys) + if(LAZYLEN(message) > 1) + message += ", [emote]" + else + message += "[emote]" + + message += "." + + message = jointext(message, "") + + to_chat(user, message) + +/datum/emote/sound/beep + key = "beep" + key_third_person = "beeps" + message = "beeps." + message_param = "beeps at %t." + sound = 'sound/machines/twobeep.ogg' + mob_type_allowed_typecache = list(/mob/living/brain, /mob/living/silicon, /mob/living/carbon/human) + +/datum/emote/living/circle + key = "circle" + key_third_person = "circles" + restraint_check = TRUE + +/datum/emote/living/circle/run_emote(mob/user, params) + . = ..() + var/obj/item/circlegame/N = new(user) + if(user.put_in_hands(N)) + to_chat(user, "You make a circle with your hand.") + else + qdel(N) + to_chat(user, "You don't have any free hands to make a circle with.") + +/datum/emote/living/slap + key = "slap" + key_third_person = "slaps" + restraint_check = TRUE + +/datum/emote/living/slap/run_emote(mob/user, params) + . = ..() + if(!.) + return + var/obj/item/slapper/N = new(user) + if(user.put_in_hands(N)) + to_chat(user, "You ready your slapping hand.") + else + to_chat(user, "You're incapable of slapping in your current state.") diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index 6e3ed2e3..6176ca93 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -1,437 +1,435 @@ -GLOBAL_LIST_INIT(department_radio_prefixes, list(":", ".")) - -GLOBAL_LIST_INIT(department_radio_keys, list( - // Location - MODE_KEY_R_HAND = MODE_R_HAND, - MODE_KEY_L_HAND = MODE_L_HAND, - MODE_KEY_INTERCOM = MODE_INTERCOM, - - // Department - MODE_KEY_DEPARTMENT = MODE_DEPARTMENT, - RADIO_KEY_COMMAND = RADIO_CHANNEL_COMMAND, - RADIO_KEY_SCIENCE = RADIO_CHANNEL_SCIENCE, - RADIO_KEY_MEDICAL = RADIO_CHANNEL_MEDICAL, - RADIO_KEY_ENGINEERING = RADIO_CHANNEL_ENGINEERING, - RADIO_KEY_SECURITY = RADIO_CHANNEL_SECURITY, - RADIO_KEY_SUPPLY = RADIO_CHANNEL_SUPPLY, - RADIO_KEY_SERVICE = RADIO_CHANNEL_SERVICE, - - // Faction - RADIO_KEY_SYNDICATE = RADIO_CHANNEL_SYNDICATE, - RADIO_KEY_CENTCOM = RADIO_CHANNEL_CENTCOM, - - // Admin - MODE_KEY_ADMIN = MODE_ADMIN, - MODE_KEY_DEADMIN = MODE_DEADMIN, - - // Misc - RADIO_KEY_AI_PRIVATE = RADIO_CHANNEL_AI_PRIVATE, // AI Upload channel - MODE_KEY_VOCALCORDS = MODE_VOCALCORDS, // vocal cords, used by Voice of God - - - //kinda localization -- rastaf0 - //same keys as above, but on russian keyboard layout. This file uses cp1251 as encoding. - // Location - "ê" = MODE_R_HAND, - "ä" = MODE_L_HAND, - "ø" = MODE_INTERCOM, - - // Department - "ð" = MODE_DEPARTMENT, - "ñ" = RADIO_CHANNEL_COMMAND, - "ò" = RADIO_CHANNEL_SCIENCE, - "ü" = RADIO_CHANNEL_MEDICAL, - "ó" = RADIO_CHANNEL_ENGINEERING, - "û" = RADIO_CHANNEL_SECURITY, - "ã" = RADIO_CHANNEL_SUPPLY, - "ì" = RADIO_CHANNEL_SERVICE, - - // Faction - "å" = RADIO_CHANNEL_SYNDICATE, - "í" = RADIO_CHANNEL_CENTCOM, - - // Admin - "ç" = MODE_ADMIN, - "â" = MODE_ADMIN, - - // Misc - "ù" = RADIO_CHANNEL_AI_PRIVATE, - "÷" = MODE_VOCALCORDS -)) - -/mob/living/proc/Ellipsis(original_msg, chance = 50, keep_words) - if(chance <= 0) - return "..." - if(chance >= 100) - return original_msg - - var/list/words = splittext(original_msg," ") - var/list/new_words = list() - - var/new_msg = "" - - for(var/w in words) - if(prob(chance)) - new_words += "..." - if(!keep_words) - continue - new_words += w - - new_msg = jointext(new_words," ") - - return new_msg - -/mob/living/say(message, bubble_type,var/list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null) - var/static/list/crit_allowed_modes = list(MODE_WHISPER = TRUE, MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE) - var/static/list/unconscious_allowed_modes = list(MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE) - var/talk_key = get_key(message) - - var/static/list/one_character_prefix = list(MODE_HEADSET = TRUE, MODE_ROBOT = TRUE, MODE_WHISPER = TRUE, MODE_SING = TRUE) - - if(sanitize) - message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN)) - if(!message || message == "") - return - - var/datum/saymode/saymode = SSradio.saymodes[talk_key] - var/message_mode = get_message_mode(message) - var/original_message = message - var/in_critical = InCritical() - - if(one_character_prefix[message_mode]) - message = copytext(message, 2) - else if(message_mode || saymode) - message = copytext(message, 3) - if(findtext(message, " ", 1, 2)) - message = copytext(message, 2) - - if(message_mode == MODE_ADMIN) - if(client) - client.cmd_admin_say(message) - return - - if(message_mode == MODE_DEADMIN) - if(client) - client.dsay(message) - return - - if(stat == DEAD) - say_dead(original_message) - return - - if(check_emote(original_message) || !can_speak_basic(original_message, ignore_spam)) - return - - if(in_critical) - if(!(crit_allowed_modes[message_mode])) - return - else if(stat == UNCONSCIOUS) - if(!(unconscious_allowed_modes[message_mode])) - return - - // language comma detection. - var/datum/language/message_language = get_message_language(message) - if(message_language) - // No, you cannot speak in xenocommon just because you know the key - if(can_speak_in_language(message_language)) - language = message_language - message = copytext(message, 3) - - // Trim the space if they said ",0 I LOVE LANGUAGES" - if(findtext(message, " ", 1, 2)) - message = copytext(message, 2) - - if(!language) - language = get_default_language() - - // Detection of language needs to be before inherent channels, because - // AIs use inherent channels for the holopad. Most inherent channels - // ignore the language argument however. - - if(saymode && !saymode.handle_message(src, message, language)) - return - - if(!can_speak_vocal(message)) - to_chat(src, "You find yourself unable to speak!") - return - - var/message_range = 7 - - var/succumbed = FALSE - - var/fullcrit = InFullCritical() - if((InCritical() && !fullcrit) || message_mode == MODE_WHISPER) - message_range = 1 - message_mode = MODE_WHISPER - src.log_talk(message, LOG_WHISPER) - if(fullcrit) - var/health_diff = round(-HEALTH_THRESHOLD_DEAD + health) - // If we cut our message short, abruptly end it with a-.. - var/message_len = length(message) - message = copytext(message, 1, health_diff) + "[message_len > health_diff ? "-.." : "..."]" - message = Ellipsis(message, 10, 1) - message_mode = MODE_WHISPER_CRIT - succumbed = TRUE - else - src.log_talk(message, LOG_SAY, forced_by=forced) - - message = treat_message(message) // unfortunately we still need this - var/sigreturn = SEND_SIGNAL(src, COMSIG_MOB_SAY, args) - if (sigreturn & COMPONENT_UPPERCASE_SPEECH) - message = uppertext(message) - if(!message) - return - - last_words = message - - spans |= speech_span - - if(language) - var/datum/language/L = GLOB.language_datum_instances[language] - spans |= L.spans - - if(message_mode == MODE_SING) - #if DM_VERSION < 513 - var/randomnote = "~" - #else - var/randomnote = pick("\u2669", "\u266A", "\u266B") - #endif - spans |= SPAN_SINGING - message = "[randomnote] [message] [randomnote]" - - var/radio_return = radio(message, message_mode, spans, language) - if(radio_return & ITALICS) - spans |= SPAN_ITALICS - if(radio_return & REDUCE_RANGE) - message_range = 1 - if(radio_return & NOPASS) - return 1 - - //No screams in space, unless you're next to someone. - var/turf/T = get_turf(src) - var/datum/gas_mixture/environment = T.return_air() - var/pressure = (environment)? environment.return_pressure() : 0 - if(pressure < SOUND_MINIMUM_PRESSURE) - message_range = 1 - - if(pressure < ONE_ATMOSPHERE*0.4) //Thin air, let's italicise the message - spans |= SPAN_ITALICS - - send_speech(message, message_range, src, bubble_type, spans, language, message_mode) - - if(succumbed) - succumb() - to_chat(src, compose_message(src, language, message, null, spans, message_mode)) - - return 1 - -/mob/living/compose_message(atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, message_mode, face_name = FALSE, atom/movable/source) - . = ..() - if(isliving(speaker)) - var/turf/sourceturf = get_turf(source) - var/turf/T = get_turf(src) - if(sourceturf && T && !(sourceturf in get_hear(5, T))) - . = "[.]" - -/mob/living/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, message_mode, atom/movable/source) - . = ..() - if(!client) - return - var/deaf_message - var/deaf_type - if(speaker != src) - if(!radio_freq) //These checks have to be seperate, else people talking on the radio will make "You can't hear yourself!" appear when hearing people over the radio while deaf. - deaf_message = "[speaker] [speaker.verb_say] something but you cannot hear [speaker.p_them()]." - deaf_type = 1 - else - deaf_message = "You can't hear yourself!" - deaf_type = 2 // Since you should be able to hear yourself without looking - // Create map text prior to modifying message for goonchat - if (client?.prefs.chat_on_map && stat != UNCONSCIOUS && (client.prefs.see_chat_non_mob || ismob(speaker)) && can_hear()) - create_chat_message(speaker, message_language, raw_message, spans, message_mode) - if (client?.prefs.radiosounds && stat != UNCONSCIOUS && can_hear() && radio_freq) - playsound_local(src,'sound/voice/radio.ogg', 30, 1) - - // Recompose message for AI hrefs, language incomprehension. - message = compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mode, FALSE, source) - message = hear_intercept(message, speaker, message_language, raw_message, radio_freq, spans, message_mode, FALSE, source) - - show_message(message, MSG_AUDIBLE, deaf_message, deaf_type) - return message - -/mob/living/proc/hear_intercept(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, message_mode) - return message - -/mob/living/send_speech(message, message_range = 6, obj/source = src, bubble_type = bubble_icon, list/spans, datum/language/message_language=null, message_mode) - var/static/list/eavesdropping_modes = list(MODE_WHISPER = TRUE, MODE_WHISPER_CRIT = TRUE) - var/eavesdrop_range = 0 - if(eavesdropping_modes[message_mode]) - eavesdrop_range = EAVESDROP_EXTRA_RANGE - var/list/listening = get_hearers_in_view(message_range+eavesdrop_range, source) - var/list/the_dead = list() - var/list/yellareas //CIT CHANGE - adds the ability for yelling to penetrate walls and echo throughout areas - if(!eavesdrop_range && say_test(message) == "2") //CIT CHANGE - ditto - yellareas = get_areas_in_range(message_range*0.5, source) //CIT CHANGE - ditto - for(var/_M in GLOB.player_list) - var/mob/M = _M - if(M.stat != DEAD) //not dead, not important - if(yellareas) //CIT CHANGE - see above. makes yelling penetrate walls - var/area/A = get_area(M) //CIT CHANGE - ditto - if(istype(A) && A.ambientsounds != SPACE && A in yellareas) //CIT CHANGE - ditto - listening |= M //CIT CHANGE - ditto - continue - if(!M.client || !client) //client is so that ghosts don't have to listen to mice - continue - if(get_dist(M, source) > 7 || M.z != z) //they're out of range of normal hearing - if(eavesdropping_modes[message_mode] && !(M.client.prefs.chat_toggles & CHAT_GHOSTWHISPER)) //they're whispering and we have hearing whispers at any range off - continue - if(!(M.client.prefs.chat_toggles & CHAT_GHOSTEARS)) //they're talking normally and we have hearing at any range off - continue - listening |= M - the_dead[M] = TRUE - - var/eavesdropping - var/eavesrendered - if(eavesdrop_range) - eavesdropping = stars(message) - eavesrendered = compose_message(src, message_language, eavesdropping, null, spans, message_mode, FALSE, source) - - var/rendered = compose_message(src, message_language, message, null, spans, message_mode, FALSE, source) - for(var/_AM in listening) - var/atom/movable/AM = _AM - if(eavesdrop_range && get_dist(source, AM) > message_range && !(the_dead[AM])) - AM.Hear(eavesrendered, src, message_language, eavesdropping, null, spans, message_mode, source) - else - AM.Hear(rendered, src, message_language, message, null, spans, message_mode, source) - SEND_GLOBAL_SIGNAL(COMSIG_GLOB_LIVING_SAY_SPECIAL, src, message) - - //speech bubble - var/list/speech_bubble_recipients = list() - for(var/mob/M in listening) - if(M.client && !M.client.prefs.chat_on_map) - speech_bubble_recipients.Add(M.client) - var/image/I = image('icons/mob/talk.dmi', src, "[bubble_type][say_test(message)]", FLY_LAYER) - I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA - INVOKE_ASYNC(GLOBAL_PROC, /.proc/flick_overlay, I, speech_bubble_recipients, 30) - -/mob/proc/binarycheck() - return FALSE - -/mob/living/can_speak(message) //For use outside of Say() - if(can_speak_basic(message) && can_speak_vocal(message)) - return 1 - -/mob/living/proc/can_speak_basic(message, ignore_spam = FALSE) //Check BEFORE handling of xeno and ling channels - if(client) - if(client.prefs.muted & MUTE_IC) - to_chat(src, "You cannot speak in IC (muted).") - return 0 - if(!ignore_spam && client.handle_spam_prevention(message,MUTE_IC)) - return 0 - - return 1 - -/mob/living/proc/can_speak_vocal(message) //Check AFTER handling of xeno and ling channels - if(HAS_TRAIT(src, TRAIT_MUTE)) - return 0 - - if(is_muzzled()) - return 0 - - if(!IsVocal()) - return 0 - - return 1 - -/mob/living/proc/get_key(message) - var/key = copytext(message, 1, 2) - if(key in GLOB.department_radio_prefixes) - return lowertext(copytext(message, 2, 3)) - -/mob/living/proc/get_message_language(message) - if(copytext(message, 1, 2) == ",") - var/key = copytext(message, 2, 3) - for(var/ld in GLOB.all_languages) - var/datum/language/LD = ld - if(initial(LD.key) == key) - return LD - return null - -/mob/living/proc/treat_message(message) - - if(HAS_TRAIT(src, TRAIT_UNINTELLIGIBLE_SPEECH)) - message = unintelligize(message) - - if(derpspeech) - message = derpspeech(message, stuttering) - - if(stuttering) - message = stutter(message) - - if(slurring) - message = slur(message,slurring) - - if(cultslurring) - message = cultslur(message) - - message = capitalize(message) - - return message - -/mob/living/proc/radio(message, message_mode, list/spans, language) - var/obj/item/implant/radio/imp = locate() in implants - if(imp?.radio.on) - if(message_mode == MODE_HEADSET) - imp.radio.talk_into(src, message, , spans, language) - return ITALICS | REDUCE_RANGE - if(message_mode == MODE_DEPARTMENT || message_mode in GLOB.radiochannels) - imp.radio.talk_into(src, message, message_mode, spans, language) - return ITALICS | REDUCE_RANGE - - switch(message_mode) - if(MODE_WHISPER) - return ITALICS - if(MODE_R_HAND) - for(var/obj/item/r_hand in get_held_items_for_side("r", all = TRUE)) - if (r_hand) - return r_hand.talk_into(src, message, , spans, language) - return ITALICS | REDUCE_RANGE - if(MODE_L_HAND) - for(var/obj/item/l_hand in get_held_items_for_side("l", all = TRUE)) - if (l_hand) - return l_hand.talk_into(src, message, , spans, language) - return ITALICS | REDUCE_RANGE - - if(MODE_INTERCOM) - for (var/obj/item/radio/intercom/I in view(1, null)) - I.talk_into(src, message, , spans, language) - return ITALICS | REDUCE_RANGE - - if(MODE_BINARY) - return ITALICS | REDUCE_RANGE //Does not return 0 since this is only reached by humans, not borgs or AIs. - - return 0 - -/mob/living/say_mod(input, message_mode) - . = ..() - if(message_mode == MODE_WHISPER_CRIT) - . = "[verb_whisper] in [p_their()] last breath" - else if(message_mode != MODE_CUSTOM_SAY) - if(message_mode == MODE_WHISPER) - . = verb_whisper - else if(stuttering) - . = "stammers" - else if(derpspeech) - . = "gibbers" - -/mob/living/whisper(message, bubble_type, list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null) - say("#[message]", bubble_type, spans, sanitize, language, ignore_spam, forced) - -/mob/living/get_language_holder(shadow=TRUE) - if(mind && shadow) - // Mind language holders shadow mob holders. - . = mind.get_language_holder() - if(.) - return . - - . = ..() +GLOBAL_LIST_INIT(department_radio_prefixes, list(":", ".")) + +GLOBAL_LIST_INIT(department_radio_keys, list( + // Location + MODE_KEY_R_HAND = MODE_R_HAND, + MODE_KEY_L_HAND = MODE_L_HAND, + MODE_KEY_INTERCOM = MODE_INTERCOM, + + // Department + MODE_KEY_DEPARTMENT = MODE_DEPARTMENT, + RADIO_KEY_COMMAND = RADIO_CHANNEL_COMMAND, + RADIO_KEY_SCIENCE = RADIO_CHANNEL_SCIENCE, + RADIO_KEY_MEDICAL = RADIO_CHANNEL_MEDICAL, + RADIO_KEY_ENGINEERING = RADIO_CHANNEL_ENGINEERING, + RADIO_KEY_SECURITY = RADIO_CHANNEL_SECURITY, + RADIO_KEY_SUPPLY = RADIO_CHANNEL_SUPPLY, + RADIO_KEY_SERVICE = RADIO_CHANNEL_SERVICE, + + // Faction + RADIO_KEY_SYNDICATE = RADIO_CHANNEL_SYNDICATE, + RADIO_KEY_CENTCOM = RADIO_CHANNEL_CENTCOM, + + // Admin + MODE_KEY_ADMIN = MODE_ADMIN, + MODE_KEY_DEADMIN = MODE_DEADMIN, + + // Misc + RADIO_KEY_AI_PRIVATE = RADIO_CHANNEL_AI_PRIVATE, // AI Upload channel + MODE_KEY_VOCALCORDS = MODE_VOCALCORDS, // vocal cords, used by Voice of God + + + //kinda localization -- rastaf0 + //same keys as above, but on russian keyboard layout. This file uses cp1251 as encoding. + // Location + "ê" = MODE_R_HAND, + "ä" = MODE_L_HAND, + "ø" = MODE_INTERCOM, + + // Department + "ð" = MODE_DEPARTMENT, + "ñ" = RADIO_CHANNEL_COMMAND, + "ò" = RADIO_CHANNEL_SCIENCE, + "ü" = RADIO_CHANNEL_MEDICAL, + "ó" = RADIO_CHANNEL_ENGINEERING, + "û" = RADIO_CHANNEL_SECURITY, + "ã" = RADIO_CHANNEL_SUPPLY, + "ì" = RADIO_CHANNEL_SERVICE, + + // Faction + "å" = RADIO_CHANNEL_SYNDICATE, + "í" = RADIO_CHANNEL_CENTCOM, + + // Admin + "ç" = MODE_ADMIN, + "â" = MODE_ADMIN, + + // Misc + "ù" = RADIO_CHANNEL_AI_PRIVATE, + "÷" = MODE_VOCALCORDS +)) + +/mob/living/proc/Ellipsis(original_msg, chance = 50, keep_words) + if(chance <= 0) + return "..." + if(chance >= 100) + return original_msg + + var/list/words = splittext(original_msg," ") + var/list/new_words = list() + + var/new_msg = "" + + for(var/w in words) + if(prob(chance)) + new_words += "..." + if(!keep_words) + continue + new_words += w + + new_msg = jointext(new_words," ") + + return new_msg + +/mob/living/say(message, bubble_type,var/list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null) + var/static/list/crit_allowed_modes = list(MODE_WHISPER = TRUE, MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE) + var/static/list/unconscious_allowed_modes = list(MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE) + var/talk_key = get_key(message) + + var/static/list/one_character_prefix = list(MODE_HEADSET = TRUE, MODE_ROBOT = TRUE, MODE_WHISPER = TRUE, MODE_SING = TRUE) + + if(sanitize) + message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)) + if(!message || message == "") + return + + var/datum/saymode/saymode = SSradio.saymodes[talk_key] + var/message_mode = get_message_mode(message) + var/original_message = message + var/in_critical = InCritical() + + if(one_character_prefix[message_mode]) + message = copytext_char(message, 2) + else if(message_mode || saymode) + message = copytext_char(message, 3) + message = trim_left(message) + + if(message_mode == MODE_ADMIN) + if(client) + client.cmd_admin_say(message) + return + + if(message_mode == MODE_DEADMIN) + if(client) + client.dsay(message) + return + + if(stat == DEAD) + say_dead(original_message) + return + + if(check_emote(original_message) || !can_speak_basic(original_message, ignore_spam)) + return + + if(in_critical) + if(!(crit_allowed_modes[message_mode])) + return + else if(stat == UNCONSCIOUS) + if(!(unconscious_allowed_modes[message_mode])) + return + + // language comma detection. + var/datum/language/message_language = get_message_language(message) + if(message_language) + // No, you cannot speak in xenocommon just because you know the key + if(can_speak_in_language(message_language)) + language = message_language + message = copytext_char(message, 3) + + // Trim the space if they said ",0 I LOVE LANGUAGES" + message = trim_left(message) + + if(!language) + language = get_default_language() + + // Detection of language needs to be before inherent channels, because + // AIs use inherent channels for the holopad. Most inherent channels + // ignore the language argument however. + + if(saymode && !saymode.handle_message(src, message, language)) + return + + if(!can_speak_vocal(message)) + to_chat(src, "You find yourself unable to speak!") + return + + var/message_range = 7 + + var/succumbed = FALSE + + var/fullcrit = InFullCritical() + if((InCritical() && !fullcrit) || message_mode == MODE_WHISPER) + message_range = 1 + message_mode = MODE_WHISPER + src.log_talk(message, LOG_WHISPER) + if(fullcrit) + var/health_diff = round(-HEALTH_THRESHOLD_DEAD + health) + // If we cut our message short, abruptly end it with a-.. + var/message_len = length_char(message) + message = copytext_char(message, 1, health_diff) + "[message_len > health_diff ? "-.." : "..."]" + message = Ellipsis(message, 10, 1) + message_mode = MODE_WHISPER_CRIT + succumbed = TRUE + else + src.log_talk(message, LOG_SAY, forced_by=forced) + + message = treat_message(message) // unfortunately we still need this + var/sigreturn = SEND_SIGNAL(src, COMSIG_MOB_SAY, args) + if (sigreturn & COMPONENT_UPPERCASE_SPEECH) + message = uppertext(message) + if(!message) + return + + last_words = message + + spans |= speech_span + + if(language) + var/datum/language/L = GLOB.language_datum_instances[language] + spans |= L.spans + + if(message_mode == MODE_SING) + #if DM_VERSION < 513 + var/randomnote = "~" + #else + var/randomnote = pick("\u2669", "\u266A", "\u266B") + #endif + spans |= SPAN_SINGING + message = "[randomnote] [message] [randomnote]" + + var/radio_return = radio(message, message_mode, spans, language) + if(radio_return & ITALICS) + spans |= SPAN_ITALICS + if(radio_return & REDUCE_RANGE) + message_range = 1 + if(radio_return & NOPASS) + return 1 + + //No screams in space, unless you're next to someone. + var/turf/T = get_turf(src) + var/datum/gas_mixture/environment = T.return_air() + var/pressure = (environment)? environment.return_pressure() : 0 + if(pressure < SOUND_MINIMUM_PRESSURE) + message_range = 1 + + if(pressure < ONE_ATMOSPHERE*0.4) //Thin air, let's italicise the message + spans |= SPAN_ITALICS + + send_speech(message, message_range, src, bubble_type, spans, language, message_mode) + + if(succumbed) + succumb() + to_chat(src, compose_message(src, language, message, null, spans, message_mode)) + + return 1 + +/mob/living/compose_message(atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, message_mode, face_name = FALSE, atom/movable/source) + . = ..() + if(isliving(speaker)) + var/turf/sourceturf = get_turf(source) + var/turf/T = get_turf(src) + if(sourceturf && T && !(sourceturf in get_hear(5, T))) + . = "[.]" + +/mob/living/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, message_mode, atom/movable/source) + . = ..() + if(!client) + return + var/deaf_message + var/deaf_type + if(speaker != src) + if(!radio_freq) //These checks have to be seperate, else people talking on the radio will make "You can't hear yourself!" appear when hearing people over the radio while deaf. + deaf_message = "[speaker] [speaker.verb_say] something but you cannot hear [speaker.p_them()]." + deaf_type = 1 + else + deaf_message = "You can't hear yourself!" + deaf_type = 2 // Since you should be able to hear yourself without looking + // Create map text prior to modifying message for goonchat + if (client?.prefs.chat_on_map && stat != UNCONSCIOUS && (client.prefs.see_chat_non_mob || ismob(speaker)) && can_hear()) + create_chat_message(speaker, message_language, raw_message, spans, message_mode) + if (client?.prefs.radiosounds && stat != UNCONSCIOUS && can_hear() && radio_freq) + playsound_local(src,'sound/voice/radio.ogg', 30, 1) + + // Recompose message for AI hrefs, language incomprehension. + message = compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mode, FALSE, source) + message = hear_intercept(message, speaker, message_language, raw_message, radio_freq, spans, message_mode, FALSE, source) + + show_message(message, MSG_AUDIBLE, deaf_message, deaf_type) + return message + +/mob/living/proc/hear_intercept(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, message_mode) + return message + +/mob/living/send_speech(message, message_range = 6, obj/source = src, bubble_type = bubble_icon, list/spans, datum/language/message_language=null, message_mode) + var/static/list/eavesdropping_modes = list(MODE_WHISPER = TRUE, MODE_WHISPER_CRIT = TRUE) + var/eavesdrop_range = 0 + if(eavesdropping_modes[message_mode]) + eavesdrop_range = EAVESDROP_EXTRA_RANGE + var/list/listening = get_hearers_in_view(message_range+eavesdrop_range, source) + var/list/the_dead = list() + var/list/yellareas //CIT CHANGE - adds the ability for yelling to penetrate walls and echo throughout areas + if(!eavesdrop_range && say_test(message) == "2") //CIT CHANGE - ditto + yellareas = get_areas_in_range(message_range*0.5, source) //CIT CHANGE - ditto + for(var/_M in GLOB.player_list) + var/mob/M = _M + if(M.stat != DEAD) //not dead, not important + if(yellareas) //CIT CHANGE - see above. makes yelling penetrate walls + var/area/A = get_area(M) //CIT CHANGE - ditto + if(istype(A) && A.ambientsounds != SPACE && A in yellareas) //CIT CHANGE - ditto + listening |= M //CIT CHANGE - ditto + continue + if(!M.client || !client) //client is so that ghosts don't have to listen to mice + continue + if(get_dist(M, source) > 7 || M.z != z) //they're out of range of normal hearing + if(eavesdropping_modes[message_mode] && !(M.client.prefs.chat_toggles & CHAT_GHOSTWHISPER)) //they're whispering and we have hearing whispers at any range off + continue + if(!(M.client.prefs.chat_toggles & CHAT_GHOSTEARS)) //they're talking normally and we have hearing at any range off + continue + listening |= M + the_dead[M] = TRUE + + var/eavesdropping + var/eavesrendered + if(eavesdrop_range) + eavesdropping = stars(message) + eavesrendered = compose_message(src, message_language, eavesdropping, null, spans, message_mode, FALSE, source) + + var/rendered = compose_message(src, message_language, message, null, spans, message_mode, FALSE, source) + for(var/_AM in listening) + var/atom/movable/AM = _AM + if(eavesdrop_range && get_dist(source, AM) > message_range && !(the_dead[AM])) + AM.Hear(eavesrendered, src, message_language, eavesdropping, null, spans, message_mode, source) + else + AM.Hear(rendered, src, message_language, message, null, spans, message_mode, source) + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_LIVING_SAY_SPECIAL, src, message) + + //speech bubble + var/list/speech_bubble_recipients = list() + for(var/mob/M in listening) + if(M.client && !M.client.prefs.chat_on_map) + speech_bubble_recipients.Add(M.client) + var/image/I = image('icons/mob/talk.dmi', src, "[bubble_type][say_test(message)]", FLY_LAYER) + I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA + INVOKE_ASYNC(GLOBAL_PROC, /.proc/flick_overlay, I, speech_bubble_recipients, 30) + +/mob/proc/binarycheck() + return FALSE + +/mob/living/can_speak(message) //For use outside of Say() + if(can_speak_basic(message) && can_speak_vocal(message)) + return 1 + +/mob/living/proc/can_speak_basic(message, ignore_spam = FALSE) //Check BEFORE handling of xeno and ling channels + if(client) + if(client.prefs.muted & MUTE_IC) + to_chat(src, "You cannot speak in IC (muted).") + return 0 + if(!ignore_spam && client.handle_spam_prevention(message,MUTE_IC)) + return 0 + + return 1 + +/mob/living/proc/can_speak_vocal(message) //Check AFTER handling of xeno and ling channels + if(HAS_TRAIT(src, TRAIT_MUTE)) + return 0 + + if(is_muzzled()) + return 0 + + if(!IsVocal()) + return 0 + + return 1 + +/mob/living/proc/get_key(message) + var/key = message[1] + if(key in GLOB.department_radio_prefixes) + return lowertext(message[1 + length(key)]) + +/mob/living/proc/get_message_language(message) + if(message[1] == ",") + var/key = message[1 + length(message[1])] + for(var/ld in GLOB.all_languages) + var/datum/language/LD = ld + if(initial(LD.key) == key) + return LD + return null + +/mob/living/proc/treat_message(message) + + if(HAS_TRAIT(src, TRAIT_UNINTELLIGIBLE_SPEECH)) + message = unintelligize(message) + + if(derpspeech) + message = derpspeech(message, stuttering) + + if(stuttering) + message = stutter(message) + + if(slurring) + message = slur(message,slurring) + + if(cultslurring) + message = cultslur(message) + + message = capitalize(message) + + return message + +/mob/living/proc/radio(message, message_mode, list/spans, language) + var/obj/item/implant/radio/imp = locate() in implants + if(imp?.radio.on) + if(message_mode == MODE_HEADSET) + imp.radio.talk_into(src, message, , spans, language) + return ITALICS | REDUCE_RANGE + if(message_mode == MODE_DEPARTMENT || message_mode in GLOB.radiochannels) + imp.radio.talk_into(src, message, message_mode, spans, language) + return ITALICS | REDUCE_RANGE + + switch(message_mode) + if(MODE_WHISPER) + return ITALICS + if(MODE_R_HAND) + for(var/obj/item/r_hand in get_held_items_for_side("r", all = TRUE)) + if (r_hand) + return r_hand.talk_into(src, message, , spans, language) + return ITALICS | REDUCE_RANGE + if(MODE_L_HAND) + for(var/obj/item/l_hand in get_held_items_for_side("l", all = TRUE)) + if (l_hand) + return l_hand.talk_into(src, message, , spans, language) + return ITALICS | REDUCE_RANGE + + if(MODE_INTERCOM) + for (var/obj/item/radio/intercom/I in view(1, null)) + I.talk_into(src, message, , spans, language) + return ITALICS | REDUCE_RANGE + + if(MODE_BINARY) + return ITALICS | REDUCE_RANGE //Does not return 0 since this is only reached by humans, not borgs or AIs. + + return 0 + +/mob/living/say_mod(input, message_mode) + . = ..() + if(message_mode == MODE_WHISPER_CRIT) + . = "[verb_whisper] in [p_their()] last breath" + else if(message_mode != MODE_CUSTOM_SAY) + if(message_mode == MODE_WHISPER) + . = verb_whisper + else if(stuttering) + . = "stammers" + else if(derpspeech) + . = "gibbers" + +/mob/living/whisper(message, bubble_type, list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null) + say("#[message]", bubble_type, spans, sanitize, language, ignore_spam, forced) + +/mob/living/get_language_holder(shadow=TRUE) + if(mind && shadow) + // Mind language holders shadow mob holders. + . = mind.get_language_holder() + if(.) + return . + + . = ..() diff --git a/code/modules/mob/living/silicon/ai/say.dm b/code/modules/mob/living/silicon/ai/say.dm index e36b946c..7668310d 100644 --- a/code/modules/mob/living/silicon/ai/say.dm +++ b/code/modules/mob/living/silicon/ai/say.dm @@ -26,7 +26,8 @@ ..() /mob/living/silicon/ai/get_message_mode(message) - if(copytext(message, 1, 3) in list(":h", ":H", ".h", ".H", "#h", "#H")) + var/static/regex/holopad_finder = regex(@"[:.#][hH]") + if(holopad_finder.Find(message, 1, 1)) return MODE_HOLOPAD else return ..() diff --git a/code/modules/mob/living/silicon/pai/personality.dm b/code/modules/mob/living/silicon/pai/personality.dm index acb2273c..62f2ed70 100644 --- a/code/modules/mob/living/silicon/pai/personality.dm +++ b/code/modules/mob/living/silicon/pai/personality.dm @@ -8,7 +8,7 @@ */ /datum/paiCandidate/proc/savefile_path(mob/user) - return "data/player_saves/[copytext(user.ckey, 1, 2)]/[user.ckey]/pai.sav" + return "data/player_saves/[user.ckey[1]]/[user.ckey]/pai.sav" /datum/paiCandidate/proc/savefile_save(mob/user) if(IsGuestKey(user.key)) diff --git a/code/modules/mob/living/simple_animal/parrot.dm b/code/modules/mob/living/simple_animal/parrot.dm index d303f6a8..acf695a7 100644 --- a/code/modules/mob/living/simple_animal/parrot.dm +++ b/code/modules/mob/living/simple_animal/parrot.dm @@ -1,1019 +1,1019 @@ -/* Parrots! - * Contains - * Defines - * Inventory (headset stuff) - * Attack responces - * AI - * Procs / Verbs (usable by players) - * Sub-types - * Hear & say (the things we do for gimmicks) - */ - -/* - * Defines - */ - -//Only a maximum of one action and one intent should be active at any given time. -//Actions -#define PARROT_PERCH (1<<0) //Sitting/sleeping, not moving -#define PARROT_SWOOP (1<<1) //Moving towards or away from a target -#define PARROT_WANDER (1<<2) //Moving without a specific target in mind - -//Intents -#define PARROT_STEAL (1<<3) //Flying towards a target to steal it/from it -#define PARROT_ATTACK (1<<4) //Flying towards a target to attack it -#define PARROT_RETURN (1<<5) //Flying towards its perch -#define PARROT_FLEE (1<<6) //Flying away from its attacker - - -/mob/living/simple_animal/parrot - name = "parrot" - desc = "The parrot squaks, \"It's a Parrot! BAWWK!\"" //' - icon = 'icons/mob/animal.dmi' - icon_state = "parrot_fly" - icon_living = "parrot_fly" - icon_dead = "parrot_dead" - var/icon_sit = "parrot_sit" - density = FALSE - health = 80 - maxHealth = 80 - pass_flags = PASSTABLE | PASSMOB - - speak = list("Hi!","Hello!","Cracker?","BAWWWWK george mellons griffing me!") - speak_emote = list("squawks","says","yells") - emote_hear = list("squawks.","bawks!") - emote_see = list("flutters its wings.") - - speak_chance = 1 //1% (1 in 100) chance every tick; So about once per 150 seconds, assuming an average tick is 1.5s - turns_per_move = 5 - butcher_results = list(/obj/item/reagent_containers/food/snacks/cracker/ = 1) - melee_damage_upper = 10 - melee_damage_lower = 5 - - response_help = "pets" - response_disarm = "gently moves aside" - response_harm = "swats" - stop_automated_movement = 1 - a_intent = INTENT_HARM //parrots now start "aggressive" since only player parrots will nuzzle. - attacktext = "chomps" - friendly = "grooms" - mob_size = MOB_SIZE_SMALL - movement_type = FLYING - gold_core_spawnable = FRIENDLY_SPAWN - - var/parrot_damage_upper = 10 - var/parrot_state = PARROT_WANDER //Hunt for a perch when created - var/parrot_sleep_max = 25 //The time the parrot sits while perched before looking around. Mosly a way to avoid the parrot's AI in life() being run every single tick. - var/parrot_sleep_dur = 25 //Same as above, this is the var that physically counts down - var/parrot_dam_zone = list(BODY_ZONE_CHEST, BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_ARM, BODY_ZONE_R_LEG) //For humans, select a bodypart to attack - - var/parrot_speed = 5 //"Delay in world ticks between movement." according to byond. Yeah, that's BS but it does directly affect movement. Higher number = slower. - var/parrot_lastmove = null //Updates/Stores position of the parrot while it's moving - var/parrot_stuck = 0 //If parrot_lastmove hasnt changed, this will increment until it reaches parrot_stuck_threshold - var/parrot_stuck_threshold = 10 //if this == parrot_stuck, it'll force the parrot back to wandering - - var/list/speech_buffer = list() - var/speech_shuffle_rate = 20 - var/list/available_channels = list() - - //Headset for Poly to yell at engineers :) - var/obj/item/radio/headset/ears = null - - //The thing the parrot is currently interested in. This gets used for items the parrot wants to pick up, mobs it wants to steal from, - //mobs it wants to attack or mobs that have attacked it - var/atom/movable/parrot_interest = null - - //Parrots will generally sit on their perch unless something catches their eye. - //These vars store their preffered perch and if they dont have one, what they can use as a perch - var/obj/parrot_perch = null - var/obj/desired_perches = list(/obj/structure/frame/computer, /obj/structure/displaycase, \ - /obj/structure/filingcabinet, /obj/machinery/teleport, \ - /obj/machinery/computer, /obj/machinery/clonepod, \ - /obj/machinery/dna_scannernew, /obj/machinery/telecomms, \ - /obj/machinery/nuclearbomb, /obj/machinery/particle_accelerator, \ - /obj/machinery/recharge_station, /obj/machinery/smartfridge, \ - /obj/machinery/suit_storage_unit) - - //Parrots are kleptomaniacs. This variable ... stores the item a parrot is holding. - var/obj/item/held_item = null - - -/mob/living/simple_animal/parrot/Initialize() - . = ..() - if(!ears) - var/headset = pick(/obj/item/radio/headset/headset_sec, \ - /obj/item/radio/headset/headset_eng, \ - /obj/item/radio/headset/headset_med, \ - /obj/item/radio/headset/headset_sci, \ - /obj/item/radio/headset/headset_cargo) - ears = new headset(src) - - parrot_sleep_dur = parrot_sleep_max //In case someone decides to change the max without changing the duration var - - verbs.Add(/mob/living/simple_animal/parrot/proc/steal_from_ground, \ - /mob/living/simple_animal/parrot/proc/steal_from_mob, \ - /mob/living/simple_animal/parrot/verb/drop_held_item_player, \ - /mob/living/simple_animal/parrot/proc/perch_player, \ - /mob/living/simple_animal/parrot/proc/toggle_mode, - /mob/living/simple_animal/parrot/proc/perch_mob_player) - - -/mob/living/simple_animal/parrot/examine(mob/user) - . = ..() - if(stat) - . += pick("This parrot is no more.", "This is a late parrot.", "This is an ex-parrot.") - -/mob/living/simple_animal/parrot/death(gibbed) - if(held_item) - held_item.forceMove(drop_location()) - held_item = null - walk(src,0) - - if(buckled) - buckled.unbuckle_mob(src,force=1) - buckled = null - pixel_x = initial(pixel_x) - pixel_y = initial(pixel_y) - - ..(gibbed) - -/mob/living/simple_animal/parrot/Stat() - ..() - if(statpanel("Status")) - stat("Held Item", held_item) - stat("Mode",a_intent) - -/mob/living/simple_animal/parrot/Hear(message, atom/movable/speaker, message_langs, raw_message, radio_freq, list/spans, message_mode, atom/movable/source) - . = ..() - if(speaker != src && prob(50)) //Dont imitate ourselves - if(!radio_freq || prob(10)) - if(speech_buffer.len >= 500) - speech_buffer -= pick(speech_buffer) - speech_buffer |= html_decode(raw_message) - if(speaker == src && !client) //If a parrot squawks in the woods and no one is around to hear it, does it make a sound? This code says yes! - return message - -/mob/living/simple_animal/parrot/radio(message, message_mode, list/spans, language) //literally copied from human/radio(), but there's no other way to do this. at least it's better than it used to be. - . = ..() - if(. != 0) - return . - - switch(message_mode) - if(MODE_HEADSET) - if (ears) - ears.talk_into(src, message, , spans, language) - return ITALICS | REDUCE_RANGE - - if(MODE_DEPARTMENT) - if (ears) - ears.talk_into(src, message, message_mode, spans, language) - return ITALICS | REDUCE_RANGE - - if(message_mode in GLOB.radiochannels) - if(ears) - ears.talk_into(src, message, message_mode, spans, language) - return ITALICS | REDUCE_RANGE - - return 0 - -/* - * Inventory - */ -/mob/living/simple_animal/parrot/show_inv(mob/user) - user.set_machine(src) - - var/dat = "
    Inventory of [name]

    " - dat += "
    Headset: [ears]" : "add_inv=ears'>Nothing"]" - - user << browse(dat, "window=mob[REF(src)];size=325x500") - onclose(user, "window=mob[REF(src)]") - - -/mob/living/simple_animal/parrot/Topic(href, href_list) - if(!(iscarbon(usr) || iscyborg(usr)) || !usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) - usr << browse(null, "window=mob[REF(src)]") - usr.unset_machine() - return - - //Removing from inventory - if(href_list["remove_inv"]) - var/remove_from = href_list["remove_inv"] - switch(remove_from) - if("ears") - if(!ears) - to_chat(usr, "There is nothing to remove from its [remove_from]!") - return - if(!stat) - say("[available_channels.len ? "[pick(available_channels)] " : null]BAWWWWWK LEAVE THE HEADSET BAWKKKKK!") - ears.forceMove(drop_location()) - ears = null - for(var/possible_phrase in speak) - if(copytext(possible_phrase,1,3) in GLOB.department_radio_keys) - possible_phrase = copytext(possible_phrase,3) - - //Adding things to inventory - else if(href_list["add_inv"]) - var/add_to = href_list["add_inv"] - if(!usr.get_active_held_item()) - to_chat(usr, "You have nothing in your hand to put on its [add_to]!") - return - switch(add_to) - if("ears") - if(ears) - to_chat(usr, "It's already wearing something!") - return - else - var/obj/item/item_to_add = usr.get_active_held_item() - if(!item_to_add) - return - - if( !istype(item_to_add, /obj/item/radio/headset) ) - to_chat(usr, "This object won't fit!") - return - - var/obj/item/radio/headset/headset_to_add = item_to_add - - if(!usr.transferItemToLoc(headset_to_add, src)) - return - ears = headset_to_add - to_chat(usr, "You fit the headset onto [src].") - - clearlist(available_channels) - for(var/ch in headset_to_add.channels) - switch(ch) - if(RADIO_CHANNEL_ENGINEERING) - available_channels.Add(RADIO_TOKEN_ENGINEERING) - if(RADIO_CHANNEL_COMMAND) - available_channels.Add(RADIO_TOKEN_COMMAND) - if(RADIO_CHANNEL_SECURITY) - available_channels.Add(RADIO_TOKEN_SECURITY) - if(RADIO_CHANNEL_SCIENCE) - available_channels.Add(RADIO_TOKEN_SCIENCE) - if(RADIO_CHANNEL_MEDICAL) - available_channels.Add(RADIO_TOKEN_MEDICAL) - if(RADIO_CHANNEL_SUPPLY) - available_channels.Add(RADIO_TOKEN_SUPPLY) - if(RADIO_CHANNEL_SERVICE) - available_channels.Add(RADIO_TOKEN_SERVICE) - - if(headset_to_add.translate_binary) - available_channels.Add(MODE_TOKEN_BINARY) - else - return ..() - - -/* - * Attack responces - */ -//Humans, monkeys, aliens -/mob/living/simple_animal/parrot/attack_hand(mob/living/carbon/M) - ..() - if(client) - return - if(!stat && M.a_intent == INTENT_HARM) - - icon_state = icon_living //It is going to be flying regardless of whether it flees or attacks - - if(parrot_state == PARROT_PERCH) - parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched - - parrot_interest = M - parrot_state = PARROT_SWOOP //The parrot just got hit, it WILL move, now to pick a direction.. - - if(health > 30) //Let's get in there and squawk it up! - parrot_state |= PARROT_ATTACK - else - parrot_state |= PARROT_FLEE //Otherwise, fly like a bat out of hell! - drop_held_item(0) - if(stat != DEAD && M.a_intent == INTENT_HELP) - handle_automated_speech(1) //assured speak/emote - return - -/mob/living/simple_animal/parrot/attack_paw(mob/living/carbon/monkey/M) - return attack_hand(M) - -/mob/living/simple_animal/parrot/attack_alien(mob/living/carbon/alien/M) - return attack_hand(M) - -//Simple animals -/mob/living/simple_animal/parrot/attack_animal(mob/living/simple_animal/M) - . = ..() //goodbye immortal parrots - - if(client) - return - - if(parrot_state == PARROT_PERCH) - parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched - - if(M.melee_damage_upper > 0 && !stat) - parrot_interest = M - parrot_state = PARROT_SWOOP | PARROT_ATTACK //Attack other animals regardless - icon_state = icon_living - -//Mobs with objects -/mob/living/simple_animal/parrot/attackby(obj/item/O, mob/living/user, params) - if(!stat && !client && !istype(O, /obj/item/stack/medical) && !istype(O, /obj/item/reagent_containers/food/snacks/cracker)) - if(O.force) - if(parrot_state == PARROT_PERCH) - parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched - - parrot_interest = user - parrot_state = PARROT_SWOOP - if(health > 30) //Let's get in there and squawk it up! - parrot_state |= PARROT_ATTACK - else - parrot_state |= PARROT_FLEE - icon_state = icon_living - drop_held_item(0) - else if(istype(O, /obj/item/reagent_containers/food/snacks/cracker)) //Poly wants a cracker. - qdel(O) - if(health < maxHealth) - adjustBruteLoss(-10) - speak_chance *= 1.27 // 20 crackers to go from 1% to 100% - speech_shuffle_rate += 10 - to_chat(user, "[src] eagerly devours the cracker.") - return // the cracker was deleted - return ..() - -//Bullets -/mob/living/simple_animal/parrot/bullet_act(obj/item/projectile/Proj) - ..() - if(!stat && !client) - if(parrot_state == PARROT_PERCH) - parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched - - parrot_interest = null - parrot_state = PARROT_WANDER | PARROT_FLEE //Been shot and survived! RUN LIKE HELL! - //parrot_been_shot += 5 - icon_state = icon_living - drop_held_item(0) - return - - -/* - * AI - Not really intelligent, but I'm calling it AI anyway. - */ -/mob/living/simple_animal/parrot/Life() - ..() - - //Sprite update for when a parrot gets pulled - if(pulledby && !stat && parrot_state != PARROT_WANDER) - if(buckled) - buckled.unbuckle_mob(src, TRUE) - buckled = null - icon_state = icon_living - parrot_state = PARROT_WANDER - pixel_x = initial(pixel_x) - pixel_y = initial(pixel_y) - return - - -//-----SPEECH - /* Parrot speech mimickry! - Phrases that the parrot Hear()s get added to speach_buffer. - Every once in a while, the parrot picks one of the lines from the buffer and replaces an element of the 'speech' list. */ -/mob/living/simple_animal/parrot/handle_automated_speech() - ..() - if(speech_buffer.len && prob(speech_shuffle_rate)) //shuffle out a phrase and add in a new one - if(speak.len) - speak.Remove(pick(speak)) - - speak.Add(pick(speech_buffer)) - - -/mob/living/simple_animal/parrot/handle_automated_movement() - if(!isturf(src.loc) || !canmove || buckled) - return //If it can't move, dont let it move. (The buckled check probably isn't necessary thanks to canmove) - - if(client && stat == CONSCIOUS && parrot_state != icon_living) - icon_state = icon_living - //Because the most appropriate place to set icon_state is movement_delay(), clearly - -//-----SLEEPING - if(parrot_state == PARROT_PERCH) - if(parrot_perch && parrot_perch.loc != src.loc) //Make sure someone hasnt moved our perch on us - if(parrot_perch in view(src)) - parrot_state = PARROT_SWOOP | PARROT_RETURN - icon_state = icon_living - return - else - parrot_state = PARROT_WANDER - icon_state = icon_living - return - - if(--parrot_sleep_dur) //Zzz - return - - else - //This way we only call the stuff below once every [sleep_max] ticks. - parrot_sleep_dur = parrot_sleep_max - - //Cycle through message modes for the headset - if(speak.len) - var/list/newspeak = list() - - if(available_channels.len && src.ears) - for(var/possible_phrase in speak) - - //50/50 chance to not use the radio at all - var/useradio = 0 - if(prob(50)) - useradio = 1 - - if((copytext(possible_phrase,1,2) in GLOB.department_radio_prefixes) && (copytext(possible_phrase,2,3) in GLOB.department_radio_keys)) - possible_phrase = "[useradio?pick(available_channels):""][copytext(possible_phrase,3)]" //crop out the channel prefix - else - possible_phrase = "[useradio?pick(available_channels):""][possible_phrase]" - - newspeak.Add(possible_phrase) - - else //If we have no headset or channels to use, dont try to use any! - for(var/possible_phrase in speak) - if((copytext(possible_phrase,1,2) in GLOB.department_radio_prefixes) && (copytext(possible_phrase,2,3) in GLOB.department_radio_keys)) - possible_phrase = copytext(possible_phrase,3) //crop out the channel prefix - newspeak.Add(possible_phrase) - speak = newspeak - - //Search for item to steal - parrot_interest = search_for_item() - if(parrot_interest) - emote("me", 1, "looks in [parrot_interest]'s direction and takes flight.") - parrot_state = PARROT_SWOOP | PARROT_STEAL - icon_state = icon_living - return - -//-----WANDERING - This is basically a 'I dont know what to do yet' state - else if(parrot_state == PARROT_WANDER) - //Stop movement, we'll set it later - walk(src, 0) - parrot_interest = null - - //Wander around aimlessly. This will help keep the loops from searches down - //and possibly move the mob into a new are in view of something they can use - if(prob(90)) - step(src, pick(GLOB.cardinals)) - return - - if(!held_item && !parrot_perch) //If we've got nothing to do.. look for something to do. - var/atom/movable/AM = search_for_perch_and_item() //This handles checking through lists so we know it's either a perch or stealable item - if(AM) - if(istype(AM, /obj/item) || isliving(AM)) //If stealable item - parrot_interest = AM - emote("me", 1, "turns and flies towards [parrot_interest].") - parrot_state = PARROT_SWOOP | PARROT_STEAL - return - else //Else it's a perch - parrot_perch = AM - parrot_state = PARROT_SWOOP | PARROT_RETURN - return - return - - if(parrot_interest && parrot_interest in view(src)) - parrot_state = PARROT_SWOOP | PARROT_STEAL - return - - if(parrot_perch && parrot_perch in view(src)) - parrot_state = PARROT_SWOOP | PARROT_RETURN - return - - else //Have an item but no perch? Find one! - parrot_perch = search_for_perch() - if(parrot_perch) - parrot_state = PARROT_SWOOP | PARROT_RETURN - return -//-----STEALING - else if(parrot_state == (PARROT_SWOOP | PARROT_STEAL)) - walk(src,0) - if(!parrot_interest || held_item) - parrot_state = PARROT_SWOOP | PARROT_RETURN - return - - if(!(parrot_interest in view(src))) - parrot_state = PARROT_SWOOP | PARROT_RETURN - return - - if(Adjacent(parrot_interest)) - - if(isliving(parrot_interest)) - steal_from_mob() - - else //This should ensure that we only grab the item we want, and make sure it's not already collected on our perch - if(!parrot_perch || parrot_interest.loc != parrot_perch.loc) - held_item = parrot_interest - parrot_interest.forceMove(src) - visible_message("[src] grabs [held_item]!", "You grab [held_item]!", "You hear the sounds of wings flapping furiously.") - - parrot_interest = null - parrot_state = PARROT_SWOOP | PARROT_RETURN - return - - walk_to(src, parrot_interest, 1, parrot_speed) - if(isStuck()) - return - - return - -//-----RETURNING TO PERCH - else if(parrot_state == (PARROT_SWOOP | PARROT_RETURN)) - walk(src, 0) - if(!parrot_perch || !isturf(parrot_perch.loc)) //Make sure the perch exists and somehow isnt inside of something else. - parrot_perch = null - parrot_state = PARROT_WANDER - return - - if(Adjacent(parrot_perch)) - forceMove(parrot_perch.loc) - drop_held_item() - parrot_state = PARROT_PERCH - icon_state = icon_sit - return - - walk_to(src, parrot_perch, 1, parrot_speed) - if(isStuck()) - return - - return - -//-----FLEEING - else if(parrot_state == (PARROT_SWOOP | PARROT_FLEE)) - walk(src,0) - if(!parrot_interest || !isliving(parrot_interest)) //Sanity - parrot_state = PARROT_WANDER - - walk_away(src, parrot_interest, 1, parrot_speed) - if(isStuck()) - return - - return - -//-----ATTACKING - else if(parrot_state == (PARROT_SWOOP | PARROT_ATTACK)) - - //If we're attacking a nothing, an object, a turf or a ghost for some stupid reason, switch to wander - if(!parrot_interest || !isliving(parrot_interest)) - parrot_interest = null - parrot_state = PARROT_WANDER - return - - var/mob/living/L = parrot_interest - if(melee_damage_upper == 0) - melee_damage_upper = parrot_damage_upper - a_intent = INTENT_HARM - - //If the mob is close enough to interact with - if(Adjacent(parrot_interest)) - - //If the mob we've been chasing/attacking dies or falls into crit, check for loot! - if(L.stat) - parrot_interest = null - if(!held_item) - held_item = steal_from_ground() - if(!held_item) - held_item = steal_from_mob() //Apparently it's possible for dead mobs to hang onto items in certain circumstances. - if(parrot_perch in view(src)) //If we have a home nearby, go to it, otherwise find a new home - parrot_state = PARROT_SWOOP | PARROT_RETURN - else - parrot_state = PARROT_WANDER - return - - attacktext = pick("claws at", "chomps") - L.attack_animal(src)//Time for the hurt to begin! - //Otherwise, fly towards the mob! - else - walk_to(src, parrot_interest, 1, parrot_speed) - if(isStuck()) - return - - return -//-----STATE MISHAP - else //This should not happen. If it does lets reset everything and try again - walk(src,0) - parrot_interest = null - parrot_perch = null - drop_held_item() - parrot_state = PARROT_WANDER - return - -/* - * Procs - */ - -/mob/living/simple_animal/parrot/proc/isStuck() - //Check to see if the parrot is stuck due to things like windows or doors or windowdoors - if(parrot_lastmove) - if(parrot_lastmove == src.loc) - if(parrot_stuck_threshold >= ++parrot_stuck) //If it has been stuck for a while, go back to wander. - parrot_state = PARROT_WANDER - parrot_stuck = 0 - parrot_lastmove = null - return 1 - else - parrot_lastmove = null - else - parrot_lastmove = src.loc - return 0 - -/mob/living/simple_animal/parrot/proc/search_for_item() - var/item - for(var/atom/movable/AM in view(src)) - //Skip items we already stole or are wearing or are too big - if(parrot_perch && AM.loc == parrot_perch.loc || AM.loc == src) - continue - if(istype(AM, /obj/item)) - var/obj/item/I = AM - if(I.w_class < WEIGHT_CLASS_SMALL) - item = I - else if(iscarbon(AM)) - var/mob/living/carbon/C = AM - for(var/obj/item/I in C.held_items) - if(I.w_class <= WEIGHT_CLASS_SMALL) - item = I - break - if(item) - if(!AStar(src, get_turf(item), /turf/proc/Distance_cardinal)) - item = null - continue - return item - - return null - -/mob/living/simple_animal/parrot/proc/search_for_perch() - for(var/obj/O in view(src)) - for(var/path in desired_perches) - if(istype(O, path)) - return O - return null - -//This proc was made to save on doing two 'in view' loops seperatly -/mob/living/simple_animal/parrot/proc/search_for_perch_and_item() - for(var/atom/movable/AM in view(src)) - for(var/perch_path in desired_perches) - if(istype(AM, perch_path)) - return AM - - //Skip items we already stole or are wearing or are too big - if(parrot_perch && AM.loc == parrot_perch.loc || AM.loc == src) - continue - - if(istype(AM, /obj/item)) - var/obj/item/I = AM - if(I.w_class <= WEIGHT_CLASS_SMALL) - return I - - if(iscarbon(AM)) - var/mob/living/carbon/C = AM - for(var/obj/item/I in C.held_items) - if(I.w_class <= WEIGHT_CLASS_SMALL) - return C - return null - - -/* - * Verbs - These are actually procs, but can be used as verbs by player-controlled parrots. - */ -/mob/living/simple_animal/parrot/proc/steal_from_ground() - set name = "Steal from ground" - set category = "Parrot" - set desc = "Grabs a nearby item." - - if(stat) - return -1 - - if(held_item) - to_chat(src, "You are already holding [held_item]!") - return 1 - - for(var/obj/item/I in view(1,src)) - //Make sure we're not already holding it and it's small enough - if(I.loc != src && I.w_class <= WEIGHT_CLASS_SMALL) - - //If we have a perch and the item is sitting on it, continue - if(!client && parrot_perch && I.loc == parrot_perch.loc) - continue - - held_item = I - I.forceMove(src) - visible_message("[src] grabs [held_item]!", "You grab [held_item]!", "You hear the sounds of wings flapping furiously.") - return held_item - - to_chat(src, "There is nothing of interest to take!") - return 0 - -/mob/living/simple_animal/parrot/proc/steal_from_mob() - set name = "Steal from mob" - set category = "Parrot" - set desc = "Steals an item right out of a person's hand!" - - if(stat) - return -1 - - if(held_item) - to_chat(src, "You are already holding [held_item]!") - return 1 - - var/obj/item/stolen_item = null - - for(var/mob/living/carbon/C in view(1,src)) - for(var/obj/item/I in C.held_items) - if(I.w_class <= WEIGHT_CLASS_SMALL) - stolen_item = I - break - - if(stolen_item) - C.transferItemToLoc(stolen_item, src, TRUE) - held_item = stolen_item - visible_message("[src] grabs [held_item] out of [C]'s hand!", "You snag [held_item] out of [C]'s hand!", "You hear the sounds of wings flapping furiously.") - return held_item - - to_chat(src, "There is nothing of interest to take!") - return 0 - -/mob/living/simple_animal/parrot/verb/drop_held_item_player() - set name = "Drop held item" - set category = "Parrot" - set desc = "Drop the item you're holding." - - if(stat) - return - - src.drop_held_item() - - return - -/mob/living/simple_animal/parrot/proc/drop_held_item(drop_gently = 1) - set name = "Drop held item" - set category = "Parrot" - set desc = "Drop the item you're holding." - - if(stat) - return -1 - - if(!held_item) - if(src == usr) //So that other mobs wont make this message appear when they're bludgeoning you. - to_chat(src, "You have nothing to drop!") - return 0 - - -//parrots will eat crackers instead of dropping them - if(istype(held_item, /obj/item/reagent_containers/food/snacks/cracker) && (drop_gently)) - qdel(held_item) - held_item = null - if(health < maxHealth) - adjustBruteLoss(-10) - emote("me", 1, "[src] eagerly downs the cracker.") - return 1 - - - if(!drop_gently) - if(istype(held_item, /obj/item/grenade)) - var/obj/item/grenade/G = held_item - G.forceMove(drop_location()) - G.prime() - to_chat(src, "You let go of [held_item]!") - held_item = null - return 1 - - to_chat(src, "You drop [held_item].") - - held_item.forceMove(drop_location()) - held_item = null - return 1 - -/mob/living/simple_animal/parrot/proc/perch_player() - set name = "Sit" - set category = "Parrot" - set desc = "Sit on a nice comfy perch." - - if(stat || !client) - return - - if(icon_state == icon_living) - for(var/atom/movable/AM in view(src,1)) - for(var/perch_path in desired_perches) - if(istype(AM, perch_path)) - src.forceMove(AM.loc) - icon_state = icon_sit - parrot_state = PARROT_PERCH - return - to_chat(src, "There is no perch nearby to sit on!") - return - -/mob/living/simple_animal/parrot/Moved(oldLoc, dir) - . = ..() - if(. && !stat && client && parrot_state == PARROT_PERCH) - parrot_state = PARROT_WANDER - icon_state = icon_living - pixel_x = initial(pixel_x) - pixel_y = initial(pixel_y) - -/mob/living/simple_animal/parrot/proc/perch_mob_player() - set name = "Sit on Human's Shoulder" - set category = "Parrot" - set desc = "Sit on a nice comfy human being!" - - if(stat || !client) - return - - if(!buckled) - for(var/mob/living/carbon/human/H in view(src,1)) - if(H.has_buckled_mobs() && H.buckled_mobs.len >= H.max_buckled_mobs) //Already has a parrot, or is being eaten by a slime - continue - perch_on_human(H) - return - to_chat(src, "There is nobody nearby that you can sit on!") - else - icon_state = icon_living - parrot_state = PARROT_WANDER - if(buckled) - to_chat(src, "You are no longer sitting on [buckled]'s shoulder.") - buckled.unbuckle_mob(src, TRUE) - buckled = null - pixel_x = initial(pixel_x) - pixel_y = initial(pixel_y) - - - -/mob/living/simple_animal/parrot/proc/perch_on_human(mob/living/carbon/human/H) - if(!H) - return - forceMove(get_turf(H)) - if(H.buckle_mob(src, TRUE)) - pixel_y = 9 - pixel_x = pick(-8,8) //pick left or right shoulder - icon_state = icon_sit - parrot_state = PARROT_PERCH - to_chat(src, "You sit on [H]'s shoulder.") - - -/mob/living/simple_animal/parrot/proc/toggle_mode() - set name = "Toggle mode" - set category = "Parrot" - set desc = "Time to bear those claws!" - - if(stat || !client) - return - - if(a_intent != INTENT_HELP) - melee_damage_upper = 0 - a_intent = INTENT_HELP - else - melee_damage_upper = parrot_damage_upper - a_intent = INTENT_HARM - to_chat(src, "You will now [a_intent] others.") - return - -/* - * Sub-types - */ -/mob/living/simple_animal/parrot/Poly - name = "Poly" - desc = "Poly the Parrot. An expert on quantum cracker theory." - speak = list("Poly wanna cracker!", ":e Check the crystal, you chucklefucks!",":e Wire the solars, you lazy bums!",":e WHO TOOK THE DAMN HARDSUITS?",":e OH GOD ITS ABOUT TO DELAMINATE CALL THE SHUTTLE") - gold_core_spawnable = NO_SPAWN - speak_chance = 3 - var/memory_saved = FALSE - var/rounds_survived = 0 - var/longest_survival = 0 - var/longest_deathstreak = 0 - -/mob/living/simple_animal/parrot/Poly/Initialize() - ears = new /obj/item/radio/headset/headset_eng(src) - available_channels = list(":e") - Read_Memory() - if(rounds_survived == longest_survival) - speak += pick("...[longest_survival].", "The things I've seen!", "I have lived many lives!", "What are you before me?") - desc += " Old as sin, and just as loud. Claimed to be [rounds_survived]." - speak_chance = 20 //His hubris has made him more annoying/easier to justify killing - add_atom_colour("#EEEE22", FIXED_COLOUR_PRIORITY) - else if(rounds_survived == longest_deathstreak) - speak += pick("What are you waiting for!", "Violence breeds violence!", "Blood! Blood!", "Strike me down if you dare!") - desc += " The squawks of [-rounds_survived] dead parrots ring out in your ears..." - add_atom_colour("#BB7777", FIXED_COLOUR_PRIORITY) - else if(rounds_survived > 0) - speak += pick("...again?", "No, It was over!", "Let me out!", "It never ends!") - desc += " Over [rounds_survived] shifts without a \"terrible\" \"accident\"!" - else - speak += pick("...alive?", "This isn't parrot heaven!", "I live, I die, I live again!", "The void fades!") - - . = ..() - -/mob/living/simple_animal/parrot/Poly/Life() - if(!stat && SSticker.current_state == GAME_STATE_FINISHED && !memory_saved) - Write_Memory(FALSE) - memory_saved = TRUE - ..() - -/mob/living/simple_animal/parrot/Poly/death(gibbed) - if(!memory_saved) - Write_Memory(TRUE) - if(rounds_survived == longest_survival || rounds_survived == longest_deathstreak || prob(0.666)) - var/mob/living/simple_animal/parrot/Poly/ghost/G = new(loc) - if(mind) - mind.transfer_to(G) - else - G.key = key - ..(gibbed) - -/mob/living/simple_animal/parrot/Poly/proc/Read_Memory() - if(fexists("data/npc_saves/Poly.sav")) //legacy compatability to convert old format to new - var/savefile/S = new /savefile("data/npc_saves/Poly.sav") - S["phrases"] >> speech_buffer - S["roundssurvived"] >> rounds_survived - S["longestsurvival"] >> longest_survival - S["longestdeathstreak"] >> longest_deathstreak - fdel("data/npc_saves/Poly.sav") - else - var/json_file = file("data/npc_saves/Poly.json") - if(!fexists(json_file)) - return - var/list/json = json_decode(file2text(json_file)) - speech_buffer = json["phrases"] - rounds_survived = json["roundssurvived"] - longest_survival = json["longestsurvival"] - longest_deathstreak = json["longestdeathstreak"] - if(!islist(speech_buffer)) - speech_buffer = list() - -/mob/living/simple_animal/parrot/Poly/proc/Write_Memory(dead) - var/json_file = file("data/npc_saves/Poly.json") - var/list/file_data = list() - if(islist(speech_buffer)) - file_data["phrases"] = speech_buffer - if(dead) - file_data["roundssurvived"] = min(rounds_survived - 1, 0) - file_data["longestsurvival"] = longest_survival - if(rounds_survived - 1 < longest_deathstreak) - file_data["longestdeathstreak"] = rounds_survived - 1 - else - file_data["longestdeathstreak"] = longest_deathstreak - else - file_data["roundssurvived"] = rounds_survived + 1 - if(rounds_survived + 1 > longest_survival) - file_data["longestsurvival"] = rounds_survived + 1 - else - file_data["longestsurvival"] = longest_survival - file_data["longestdeathstreak"] = longest_deathstreak - fdel(json_file) - WRITE_FILE(json_file, json_encode(file_data)) - -/mob/living/simple_animal/parrot/Poly/ratvar_act() - playsound(src, 'sound/magic/clockwork/fellowship_armory.ogg', 75, TRUE) - var/mob/living/simple_animal/parrot/clock_hawk/H = new(loc) - H.setDir(dir) - qdel(src) - -/mob/living/simple_animal/parrot/Poly/ghost - name = "The Ghost of Poly" - desc = "Doomed to squawk the Earth." - color = "#FFFFFF77" - speak_chance = 20 - status_flags = GODMODE - incorporeal_move = INCORPOREAL_MOVE_BASIC - butcher_results = list(/obj/item/ectoplasm = 1) - -/mob/living/simple_animal/parrot/Poly/ghost/Initialize() - memory_saved = TRUE //At this point nothing is saved - . = ..() - -/mob/living/simple_animal/parrot/Poly/ghost/handle_automated_speech() - if(ismob(loc)) - return - ..() - -/mob/living/simple_animal/parrot/Poly/ghost/handle_automated_movement() - if(isliving(parrot_interest)) - if(!ishuman(parrot_interest)) - parrot_interest = null - else if(parrot_state == (PARROT_SWOOP | PARROT_ATTACK) && Adjacent(parrot_interest)) - walk_to(src, parrot_interest, 0, parrot_speed) - Possess(parrot_interest) - ..() - -/mob/living/simple_animal/parrot/Poly/ghost/proc/Possess(mob/living/carbon/human/H) - if(!ishuman(H)) - return - var/datum/disease/parrot_possession/P = new - P.parrot = src - forceMove(H) - H.ForceContractDisease(P) - parrot_interest = null - H.visible_message("[src] dive bombs into [H]'s chest and vanishes!", "[src] dive bombs into your chest, vanishing! This can't be good!") - - -/mob/living/simple_animal/parrot/clock_hawk - name = "clock hawk" - desc = "Cbyl jnaan penpxre! Fdhnnnjx!" - icon_state = "clock_hawk_fly" - icon_living = "clock_hawk_fly" - icon_sit = "clock_hawk_sit" - speak = list("Penpxre!", "Ratvar vf n qhzo anzr naljnl!") - speak_emote = list("squawks rustily", "says crassly", "yells brassly") - emote_hear = list("squawks rustily.", "bawks metallically!") - emote_see = list("flutters its metal wings.") - faction = list("ratvar") - gold_core_spawnable = NO_SPAWN - del_on_death = TRUE - death_sound = 'sound/magic/clockwork/anima_fragment_death.ogg' - -/mob/living/simple_animal/parrot/clock_hawk/ratvar_act() - return +/* Parrots! + * Contains + * Defines + * Inventory (headset stuff) + * Attack responces + * AI + * Procs / Verbs (usable by players) + * Sub-types + * Hear & say (the things we do for gimmicks) + */ + +/* + * Defines + */ + +//Only a maximum of one action and one intent should be active at any given time. +//Actions +#define PARROT_PERCH (1<<0) //Sitting/sleeping, not moving +#define PARROT_SWOOP (1<<1) //Moving towards or away from a target +#define PARROT_WANDER (1<<2) //Moving without a specific target in mind + +//Intents +#define PARROT_STEAL (1<<3) //Flying towards a target to steal it/from it +#define PARROT_ATTACK (1<<4) //Flying towards a target to attack it +#define PARROT_RETURN (1<<5) //Flying towards its perch +#define PARROT_FLEE (1<<6) //Flying away from its attacker + + +/mob/living/simple_animal/parrot + name = "parrot" + desc = "The parrot squaks, \"It's a Parrot! BAWWK!\"" //' + icon = 'icons/mob/animal.dmi' + icon_state = "parrot_fly" + icon_living = "parrot_fly" + icon_dead = "parrot_dead" + var/icon_sit = "parrot_sit" + density = FALSE + health = 80 + maxHealth = 80 + pass_flags = PASSTABLE | PASSMOB + + speak = list("Hi!","Hello!","Cracker?","BAWWWWK george mellons griffing me!") + speak_emote = list("squawks","says","yells") + emote_hear = list("squawks.","bawks!") + emote_see = list("flutters its wings.") + + speak_chance = 1 //1% (1 in 100) chance every tick; So about once per 150 seconds, assuming an average tick is 1.5s + turns_per_move = 5 + butcher_results = list(/obj/item/reagent_containers/food/snacks/cracker/ = 1) + melee_damage_upper = 10 + melee_damage_lower = 5 + + response_help = "pets" + response_disarm = "gently moves aside" + response_harm = "swats" + stop_automated_movement = 1 + a_intent = INTENT_HARM //parrots now start "aggressive" since only player parrots will nuzzle. + attacktext = "chomps" + friendly = "grooms" + mob_size = MOB_SIZE_SMALL + movement_type = FLYING + gold_core_spawnable = FRIENDLY_SPAWN + + var/parrot_damage_upper = 10 + var/parrot_state = PARROT_WANDER //Hunt for a perch when created + var/parrot_sleep_max = 25 //The time the parrot sits while perched before looking around. Mosly a way to avoid the parrot's AI in life() being run every single tick. + var/parrot_sleep_dur = 25 //Same as above, this is the var that physically counts down + var/parrot_dam_zone = list(BODY_ZONE_CHEST, BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_ARM, BODY_ZONE_R_LEG) //For humans, select a bodypart to attack + + var/parrot_speed = 5 //"Delay in world ticks between movement." according to byond. Yeah, that's BS but it does directly affect movement. Higher number = slower. + var/parrot_lastmove = null //Updates/Stores position of the parrot while it's moving + var/parrot_stuck = 0 //If parrot_lastmove hasnt changed, this will increment until it reaches parrot_stuck_threshold + var/parrot_stuck_threshold = 10 //if this == parrot_stuck, it'll force the parrot back to wandering + + var/list/speech_buffer = list() + var/speech_shuffle_rate = 20 + var/list/available_channels = list() + + //Headset for Poly to yell at engineers :) + var/obj/item/radio/headset/ears = null + + //The thing the parrot is currently interested in. This gets used for items the parrot wants to pick up, mobs it wants to steal from, + //mobs it wants to attack or mobs that have attacked it + var/atom/movable/parrot_interest = null + + //Parrots will generally sit on their perch unless something catches their eye. + //These vars store their preffered perch and if they dont have one, what they can use as a perch + var/obj/parrot_perch = null + var/obj/desired_perches = list(/obj/structure/frame/computer, /obj/structure/displaycase, \ + /obj/structure/filingcabinet, /obj/machinery/teleport, \ + /obj/machinery/computer, /obj/machinery/clonepod, \ + /obj/machinery/dna_scannernew, /obj/machinery/telecomms, \ + /obj/machinery/nuclearbomb, /obj/machinery/particle_accelerator, \ + /obj/machinery/recharge_station, /obj/machinery/smartfridge, \ + /obj/machinery/suit_storage_unit) + + //Parrots are kleptomaniacs. This variable ... stores the item a parrot is holding. + var/obj/item/held_item = null + + +/mob/living/simple_animal/parrot/Initialize() + . = ..() + if(!ears) + var/headset = pick(/obj/item/radio/headset/headset_sec, \ + /obj/item/radio/headset/headset_eng, \ + /obj/item/radio/headset/headset_med, \ + /obj/item/radio/headset/headset_sci, \ + /obj/item/radio/headset/headset_cargo) + ears = new headset(src) + + parrot_sleep_dur = parrot_sleep_max //In case someone decides to change the max without changing the duration var + + verbs.Add(/mob/living/simple_animal/parrot/proc/steal_from_ground, \ + /mob/living/simple_animal/parrot/proc/steal_from_mob, \ + /mob/living/simple_animal/parrot/verb/drop_held_item_player, \ + /mob/living/simple_animal/parrot/proc/perch_player, \ + /mob/living/simple_animal/parrot/proc/toggle_mode, + /mob/living/simple_animal/parrot/proc/perch_mob_player) + + +/mob/living/simple_animal/parrot/examine(mob/user) + . = ..() + if(stat) + . += pick("This parrot is no more.", "This is a late parrot.", "This is an ex-parrot.") + +/mob/living/simple_animal/parrot/death(gibbed) + if(held_item) + held_item.forceMove(drop_location()) + held_item = null + walk(src,0) + + if(buckled) + buckled.unbuckle_mob(src,force=1) + buckled = null + pixel_x = initial(pixel_x) + pixel_y = initial(pixel_y) + + ..(gibbed) + +/mob/living/simple_animal/parrot/Stat() + ..() + if(statpanel("Status")) + stat("Held Item", held_item) + stat("Mode",a_intent) + +/mob/living/simple_animal/parrot/Hear(message, atom/movable/speaker, message_langs, raw_message, radio_freq, list/spans, message_mode, atom/movable/source) + . = ..() + if(speaker != src && prob(50)) //Dont imitate ourselves + if(!radio_freq || prob(10)) + if(speech_buffer.len >= 500) + speech_buffer -= pick(speech_buffer) + speech_buffer |= html_decode(raw_message) + if(speaker == src && !client) //If a parrot squawks in the woods and no one is around to hear it, does it make a sound? This code says yes! + return message + +/mob/living/simple_animal/parrot/radio(message, message_mode, list/spans, language) //literally copied from human/radio(), but there's no other way to do this. at least it's better than it used to be. + . = ..() + if(. != 0) + return . + + switch(message_mode) + if(MODE_HEADSET) + if (ears) + ears.talk_into(src, message, , spans, language) + return ITALICS | REDUCE_RANGE + + if(MODE_DEPARTMENT) + if (ears) + ears.talk_into(src, message, message_mode, spans, language) + return ITALICS | REDUCE_RANGE + + if(message_mode in GLOB.radiochannels) + if(ears) + ears.talk_into(src, message, message_mode, spans, language) + return ITALICS | REDUCE_RANGE + + return 0 + +/* + * Inventory + */ +/mob/living/simple_animal/parrot/show_inv(mob/user) + user.set_machine(src) + + var/dat = "

    Inventory of [name]

    " + dat += "
    Headset: [ears]" : "add_inv=ears'>Nothing"]" + + user << browse(dat, "window=mob[REF(src)];size=325x500") + onclose(user, "window=mob[REF(src)]") + + +/mob/living/simple_animal/parrot/Topic(href, href_list) + if(!(iscarbon(usr) || iscyborg(usr)) || !usr.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) + usr << browse(null, "window=mob[REF(src)]") + usr.unset_machine() + return + + //Removing from inventory + if(href_list["remove_inv"]) + var/remove_from = href_list["remove_inv"] + switch(remove_from) + if("ears") + if(!ears) + to_chat(usr, "There is nothing to remove from its [remove_from]!") + return + if(!stat) + say("[available_channels.len ? "[pick(available_channels)] " : null]BAWWWWWK LEAVE THE HEADSET BAWKKKKK!") + ears.forceMove(drop_location()) + ears = null + for(var/possible_phrase in speak) + if(copytext_char(possible_phrase, 2, 3) in GLOB.department_radio_keys) + possible_phrase = copytext_char(possible_phrase, 3) + + //Adding things to inventory + else if(href_list["add_inv"]) + var/add_to = href_list["add_inv"] + if(!usr.get_active_held_item()) + to_chat(usr, "You have nothing in your hand to put on its [add_to]!") + return + switch(add_to) + if("ears") + if(ears) + to_chat(usr, "It's already wearing something!") + return + else + var/obj/item/item_to_add = usr.get_active_held_item() + if(!item_to_add) + return + + if( !istype(item_to_add, /obj/item/radio/headset) ) + to_chat(usr, "This object won't fit!") + return + + var/obj/item/radio/headset/headset_to_add = item_to_add + + if(!usr.transferItemToLoc(headset_to_add, src)) + return + ears = headset_to_add + to_chat(usr, "You fit the headset onto [src].") + + clearlist(available_channels) + for(var/ch in headset_to_add.channels) + switch(ch) + if(RADIO_CHANNEL_ENGINEERING) + available_channels.Add(RADIO_TOKEN_ENGINEERING) + if(RADIO_CHANNEL_COMMAND) + available_channels.Add(RADIO_TOKEN_COMMAND) + if(RADIO_CHANNEL_SECURITY) + available_channels.Add(RADIO_TOKEN_SECURITY) + if(RADIO_CHANNEL_SCIENCE) + available_channels.Add(RADIO_TOKEN_SCIENCE) + if(RADIO_CHANNEL_MEDICAL) + available_channels.Add(RADIO_TOKEN_MEDICAL) + if(RADIO_CHANNEL_SUPPLY) + available_channels.Add(RADIO_TOKEN_SUPPLY) + if(RADIO_CHANNEL_SERVICE) + available_channels.Add(RADIO_TOKEN_SERVICE) + + if(headset_to_add.translate_binary) + available_channels.Add(MODE_TOKEN_BINARY) + else + return ..() + + +/* + * Attack responces + */ +//Humans, monkeys, aliens +/mob/living/simple_animal/parrot/attack_hand(mob/living/carbon/M) + ..() + if(client) + return + if(!stat && M.a_intent == INTENT_HARM) + + icon_state = icon_living //It is going to be flying regardless of whether it flees or attacks + + if(parrot_state == PARROT_PERCH) + parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched + + parrot_interest = M + parrot_state = PARROT_SWOOP //The parrot just got hit, it WILL move, now to pick a direction.. + + if(health > 30) //Let's get in there and squawk it up! + parrot_state |= PARROT_ATTACK + else + parrot_state |= PARROT_FLEE //Otherwise, fly like a bat out of hell! + drop_held_item(0) + if(stat != DEAD && M.a_intent == INTENT_HELP) + handle_automated_speech(1) //assured speak/emote + return + +/mob/living/simple_animal/parrot/attack_paw(mob/living/carbon/monkey/M) + return attack_hand(M) + +/mob/living/simple_animal/parrot/attack_alien(mob/living/carbon/alien/M) + return attack_hand(M) + +//Simple animals +/mob/living/simple_animal/parrot/attack_animal(mob/living/simple_animal/M) + . = ..() //goodbye immortal parrots + + if(client) + return + + if(parrot_state == PARROT_PERCH) + parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched + + if(M.melee_damage_upper > 0 && !stat) + parrot_interest = M + parrot_state = PARROT_SWOOP | PARROT_ATTACK //Attack other animals regardless + icon_state = icon_living + +//Mobs with objects +/mob/living/simple_animal/parrot/attackby(obj/item/O, mob/living/user, params) + if(!stat && !client && !istype(O, /obj/item/stack/medical) && !istype(O, /obj/item/reagent_containers/food/snacks/cracker)) + if(O.force) + if(parrot_state == PARROT_PERCH) + parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched + + parrot_interest = user + parrot_state = PARROT_SWOOP + if(health > 30) //Let's get in there and squawk it up! + parrot_state |= PARROT_ATTACK + else + parrot_state |= PARROT_FLEE + icon_state = icon_living + drop_held_item(0) + else if(istype(O, /obj/item/reagent_containers/food/snacks/cracker)) //Poly wants a cracker. + qdel(O) + if(health < maxHealth) + adjustBruteLoss(-10) + speak_chance *= 1.27 // 20 crackers to go from 1% to 100% + speech_shuffle_rate += 10 + to_chat(user, "[src] eagerly devours the cracker.") + return // the cracker was deleted + return ..() + +//Bullets +/mob/living/simple_animal/parrot/bullet_act(obj/item/projectile/Proj) + ..() + if(!stat && !client) + if(parrot_state == PARROT_PERCH) + parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched + + parrot_interest = null + parrot_state = PARROT_WANDER | PARROT_FLEE //Been shot and survived! RUN LIKE HELL! + //parrot_been_shot += 5 + icon_state = icon_living + drop_held_item(0) + return + + +/* + * AI - Not really intelligent, but I'm calling it AI anyway. + */ +/mob/living/simple_animal/parrot/Life() + ..() + + //Sprite update for when a parrot gets pulled + if(pulledby && !stat && parrot_state != PARROT_WANDER) + if(buckled) + buckled.unbuckle_mob(src, TRUE) + buckled = null + icon_state = icon_living + parrot_state = PARROT_WANDER + pixel_x = initial(pixel_x) + pixel_y = initial(pixel_y) + return + + +//-----SPEECH + /* Parrot speech mimickry! + Phrases that the parrot Hear()s get added to speach_buffer. + Every once in a while, the parrot picks one of the lines from the buffer and replaces an element of the 'speech' list. */ +/mob/living/simple_animal/parrot/handle_automated_speech() + ..() + if(speech_buffer.len && prob(speech_shuffle_rate)) //shuffle out a phrase and add in a new one + if(speak.len) + speak.Remove(pick(speak)) + + speak.Add(pick(speech_buffer)) + + +/mob/living/simple_animal/parrot/handle_automated_movement() + if(!isturf(src.loc) || !canmove || buckled) + return //If it can't move, dont let it move. (The buckled check probably isn't necessary thanks to canmove) + + if(client && stat == CONSCIOUS && parrot_state != icon_living) + icon_state = icon_living + //Because the most appropriate place to set icon_state is movement_delay(), clearly + +//-----SLEEPING + if(parrot_state == PARROT_PERCH) + if(parrot_perch && parrot_perch.loc != src.loc) //Make sure someone hasnt moved our perch on us + if(parrot_perch in view(src)) + parrot_state = PARROT_SWOOP | PARROT_RETURN + icon_state = icon_living + return + else + parrot_state = PARROT_WANDER + icon_state = icon_living + return + + if(--parrot_sleep_dur) //Zzz + return + + else + //This way we only call the stuff below once every [sleep_max] ticks. + parrot_sleep_dur = parrot_sleep_max + + //Cycle through message modes for the headset + if(speak.len) + var/list/newspeak = list() + + if(available_channels.len && src.ears) + for(var/possible_phrase in speak) + + //50/50 chance to not use the radio at all + var/useradio = 0 + if(prob(50)) + useradio = 1 + + if((possible_phrase[1] in GLOB.department_radio_prefixes) && (copytext_char(possible_phrase, 2, 3) in GLOB.department_radio_keys)) + possible_phrase = "[useradio?pick(available_channels):""][copytext_char(possible_phrase, 3)]" //crop out the channel prefix + else + possible_phrase = "[useradio?pick(available_channels):""][possible_phrase]" + + newspeak.Add(possible_phrase) + + else //If we have no headset or channels to use, dont try to use any! + for(var/possible_phrase in speak) + if((possible_phrase[1] in GLOB.department_radio_prefixes) && (copytext_char(possible_phrase, 2, 3) in GLOB.department_radio_keys)) + possible_phrase = copytext_char(possible_phrase, 3) //crop out the channel prefix + newspeak.Add(possible_phrase) + speak = newspeak + + //Search for item to steal + parrot_interest = search_for_item() + if(parrot_interest) + emote("me", 1, "looks in [parrot_interest]'s direction and takes flight.") + parrot_state = PARROT_SWOOP | PARROT_STEAL + icon_state = icon_living + return + +//-----WANDERING - This is basically a 'I dont know what to do yet' state + else if(parrot_state == PARROT_WANDER) + //Stop movement, we'll set it later + walk(src, 0) + parrot_interest = null + + //Wander around aimlessly. This will help keep the loops from searches down + //and possibly move the mob into a new are in view of something they can use + if(prob(90)) + step(src, pick(GLOB.cardinals)) + return + + if(!held_item && !parrot_perch) //If we've got nothing to do.. look for something to do. + var/atom/movable/AM = search_for_perch_and_item() //This handles checking through lists so we know it's either a perch or stealable item + if(AM) + if(istype(AM, /obj/item) || isliving(AM)) //If stealable item + parrot_interest = AM + emote("me", 1, "turns and flies towards [parrot_interest].") + parrot_state = PARROT_SWOOP | PARROT_STEAL + return + else //Else it's a perch + parrot_perch = AM + parrot_state = PARROT_SWOOP | PARROT_RETURN + return + return + + if(parrot_interest && parrot_interest in view(src)) + parrot_state = PARROT_SWOOP | PARROT_STEAL + return + + if(parrot_perch && parrot_perch in view(src)) + parrot_state = PARROT_SWOOP | PARROT_RETURN + return + + else //Have an item but no perch? Find one! + parrot_perch = search_for_perch() + if(parrot_perch) + parrot_state = PARROT_SWOOP | PARROT_RETURN + return +//-----STEALING + else if(parrot_state == (PARROT_SWOOP | PARROT_STEAL)) + walk(src,0) + if(!parrot_interest || held_item) + parrot_state = PARROT_SWOOP | PARROT_RETURN + return + + if(!(parrot_interest in view(src))) + parrot_state = PARROT_SWOOP | PARROT_RETURN + return + + if(Adjacent(parrot_interest)) + + if(isliving(parrot_interest)) + steal_from_mob() + + else //This should ensure that we only grab the item we want, and make sure it's not already collected on our perch + if(!parrot_perch || parrot_interest.loc != parrot_perch.loc) + held_item = parrot_interest + parrot_interest.forceMove(src) + visible_message("[src] grabs [held_item]!", "You grab [held_item]!", "You hear the sounds of wings flapping furiously.") + + parrot_interest = null + parrot_state = PARROT_SWOOP | PARROT_RETURN + return + + walk_to(src, parrot_interest, 1, parrot_speed) + if(isStuck()) + return + + return + +//-----RETURNING TO PERCH + else if(parrot_state == (PARROT_SWOOP | PARROT_RETURN)) + walk(src, 0) + if(!parrot_perch || !isturf(parrot_perch.loc)) //Make sure the perch exists and somehow isnt inside of something else. + parrot_perch = null + parrot_state = PARROT_WANDER + return + + if(Adjacent(parrot_perch)) + forceMove(parrot_perch.loc) + drop_held_item() + parrot_state = PARROT_PERCH + icon_state = icon_sit + return + + walk_to(src, parrot_perch, 1, parrot_speed) + if(isStuck()) + return + + return + +//-----FLEEING + else if(parrot_state == (PARROT_SWOOP | PARROT_FLEE)) + walk(src,0) + if(!parrot_interest || !isliving(parrot_interest)) //Sanity + parrot_state = PARROT_WANDER + + walk_away(src, parrot_interest, 1, parrot_speed) + if(isStuck()) + return + + return + +//-----ATTACKING + else if(parrot_state == (PARROT_SWOOP | PARROT_ATTACK)) + + //If we're attacking a nothing, an object, a turf or a ghost for some stupid reason, switch to wander + if(!parrot_interest || !isliving(parrot_interest)) + parrot_interest = null + parrot_state = PARROT_WANDER + return + + var/mob/living/L = parrot_interest + if(melee_damage_upper == 0) + melee_damage_upper = parrot_damage_upper + a_intent = INTENT_HARM + + //If the mob is close enough to interact with + if(Adjacent(parrot_interest)) + + //If the mob we've been chasing/attacking dies or falls into crit, check for loot! + if(L.stat) + parrot_interest = null + if(!held_item) + held_item = steal_from_ground() + if(!held_item) + held_item = steal_from_mob() //Apparently it's possible for dead mobs to hang onto items in certain circumstances. + if(parrot_perch in view(src)) //If we have a home nearby, go to it, otherwise find a new home + parrot_state = PARROT_SWOOP | PARROT_RETURN + else + parrot_state = PARROT_WANDER + return + + attacktext = pick("claws at", "chomps") + L.attack_animal(src)//Time for the hurt to begin! + //Otherwise, fly towards the mob! + else + walk_to(src, parrot_interest, 1, parrot_speed) + if(isStuck()) + return + + return +//-----STATE MISHAP + else //This should not happen. If it does lets reset everything and try again + walk(src,0) + parrot_interest = null + parrot_perch = null + drop_held_item() + parrot_state = PARROT_WANDER + return + +/* + * Procs + */ + +/mob/living/simple_animal/parrot/proc/isStuck() + //Check to see if the parrot is stuck due to things like windows or doors or windowdoors + if(parrot_lastmove) + if(parrot_lastmove == src.loc) + if(parrot_stuck_threshold >= ++parrot_stuck) //If it has been stuck for a while, go back to wander. + parrot_state = PARROT_WANDER + parrot_stuck = 0 + parrot_lastmove = null + return 1 + else + parrot_lastmove = null + else + parrot_lastmove = src.loc + return 0 + +/mob/living/simple_animal/parrot/proc/search_for_item() + var/item + for(var/atom/movable/AM in view(src)) + //Skip items we already stole or are wearing or are too big + if(parrot_perch && AM.loc == parrot_perch.loc || AM.loc == src) + continue + if(istype(AM, /obj/item)) + var/obj/item/I = AM + if(I.w_class < WEIGHT_CLASS_SMALL) + item = I + else if(iscarbon(AM)) + var/mob/living/carbon/C = AM + for(var/obj/item/I in C.held_items) + if(I.w_class <= WEIGHT_CLASS_SMALL) + item = I + break + if(item) + if(!AStar(src, get_turf(item), /turf/proc/Distance_cardinal)) + item = null + continue + return item + + return null + +/mob/living/simple_animal/parrot/proc/search_for_perch() + for(var/obj/O in view(src)) + for(var/path in desired_perches) + if(istype(O, path)) + return O + return null + +//This proc was made to save on doing two 'in view' loops seperatly +/mob/living/simple_animal/parrot/proc/search_for_perch_and_item() + for(var/atom/movable/AM in view(src)) + for(var/perch_path in desired_perches) + if(istype(AM, perch_path)) + return AM + + //Skip items we already stole or are wearing or are too big + if(parrot_perch && AM.loc == parrot_perch.loc || AM.loc == src) + continue + + if(istype(AM, /obj/item)) + var/obj/item/I = AM + if(I.w_class <= WEIGHT_CLASS_SMALL) + return I + + if(iscarbon(AM)) + var/mob/living/carbon/C = AM + for(var/obj/item/I in C.held_items) + if(I.w_class <= WEIGHT_CLASS_SMALL) + return C + return null + + +/* + * Verbs - These are actually procs, but can be used as verbs by player-controlled parrots. + */ +/mob/living/simple_animal/parrot/proc/steal_from_ground() + set name = "Steal from ground" + set category = "Parrot" + set desc = "Grabs a nearby item." + + if(stat) + return -1 + + if(held_item) + to_chat(src, "You are already holding [held_item]!") + return 1 + + for(var/obj/item/I in view(1,src)) + //Make sure we're not already holding it and it's small enough + if(I.loc != src && I.w_class <= WEIGHT_CLASS_SMALL) + + //If we have a perch and the item is sitting on it, continue + if(!client && parrot_perch && I.loc == parrot_perch.loc) + continue + + held_item = I + I.forceMove(src) + visible_message("[src] grabs [held_item]!", "You grab [held_item]!", "You hear the sounds of wings flapping furiously.") + return held_item + + to_chat(src, "There is nothing of interest to take!") + return 0 + +/mob/living/simple_animal/parrot/proc/steal_from_mob() + set name = "Steal from mob" + set category = "Parrot" + set desc = "Steals an item right out of a person's hand!" + + if(stat) + return -1 + + if(held_item) + to_chat(src, "You are already holding [held_item]!") + return 1 + + var/obj/item/stolen_item = null + + for(var/mob/living/carbon/C in view(1,src)) + for(var/obj/item/I in C.held_items) + if(I.w_class <= WEIGHT_CLASS_SMALL) + stolen_item = I + break + + if(stolen_item) + C.transferItemToLoc(stolen_item, src, TRUE) + held_item = stolen_item + visible_message("[src] grabs [held_item] out of [C]'s hand!", "You snag [held_item] out of [C]'s hand!", "You hear the sounds of wings flapping furiously.") + return held_item + + to_chat(src, "There is nothing of interest to take!") + return 0 + +/mob/living/simple_animal/parrot/verb/drop_held_item_player() + set name = "Drop held item" + set category = "Parrot" + set desc = "Drop the item you're holding." + + if(stat) + return + + src.drop_held_item() + + return + +/mob/living/simple_animal/parrot/proc/drop_held_item(drop_gently = 1) + set name = "Drop held item" + set category = "Parrot" + set desc = "Drop the item you're holding." + + if(stat) + return -1 + + if(!held_item) + if(src == usr) //So that other mobs wont make this message appear when they're bludgeoning you. + to_chat(src, "You have nothing to drop!") + return 0 + + +//parrots will eat crackers instead of dropping them + if(istype(held_item, /obj/item/reagent_containers/food/snacks/cracker) && (drop_gently)) + qdel(held_item) + held_item = null + if(health < maxHealth) + adjustBruteLoss(-10) + emote("me", 1, "[src] eagerly downs the cracker.") + return 1 + + + if(!drop_gently) + if(istype(held_item, /obj/item/grenade)) + var/obj/item/grenade/G = held_item + G.forceMove(drop_location()) + G.prime() + to_chat(src, "You let go of [held_item]!") + held_item = null + return 1 + + to_chat(src, "You drop [held_item].") + + held_item.forceMove(drop_location()) + held_item = null + return 1 + +/mob/living/simple_animal/parrot/proc/perch_player() + set name = "Sit" + set category = "Parrot" + set desc = "Sit on a nice comfy perch." + + if(stat || !client) + return + + if(icon_state == icon_living) + for(var/atom/movable/AM in view(src,1)) + for(var/perch_path in desired_perches) + if(istype(AM, perch_path)) + src.forceMove(AM.loc) + icon_state = icon_sit + parrot_state = PARROT_PERCH + return + to_chat(src, "There is no perch nearby to sit on!") + return + +/mob/living/simple_animal/parrot/Moved(oldLoc, dir) + . = ..() + if(. && !stat && client && parrot_state == PARROT_PERCH) + parrot_state = PARROT_WANDER + icon_state = icon_living + pixel_x = initial(pixel_x) + pixel_y = initial(pixel_y) + +/mob/living/simple_animal/parrot/proc/perch_mob_player() + set name = "Sit on Human's Shoulder" + set category = "Parrot" + set desc = "Sit on a nice comfy human being!" + + if(stat || !client) + return + + if(!buckled) + for(var/mob/living/carbon/human/H in view(src,1)) + if(H.has_buckled_mobs() && H.buckled_mobs.len >= H.max_buckled_mobs) //Already has a parrot, or is being eaten by a slime + continue + perch_on_human(H) + return + to_chat(src, "There is nobody nearby that you can sit on!") + else + icon_state = icon_living + parrot_state = PARROT_WANDER + if(buckled) + to_chat(src, "You are no longer sitting on [buckled]'s shoulder.") + buckled.unbuckle_mob(src, TRUE) + buckled = null + pixel_x = initial(pixel_x) + pixel_y = initial(pixel_y) + + + +/mob/living/simple_animal/parrot/proc/perch_on_human(mob/living/carbon/human/H) + if(!H) + return + forceMove(get_turf(H)) + if(H.buckle_mob(src, TRUE)) + pixel_y = 9 + pixel_x = pick(-8,8) //pick left or right shoulder + icon_state = icon_sit + parrot_state = PARROT_PERCH + to_chat(src, "You sit on [H]'s shoulder.") + + +/mob/living/simple_animal/parrot/proc/toggle_mode() + set name = "Toggle mode" + set category = "Parrot" + set desc = "Time to bear those claws!" + + if(stat || !client) + return + + if(a_intent != INTENT_HELP) + melee_damage_upper = 0 + a_intent = INTENT_HELP + else + melee_damage_upper = parrot_damage_upper + a_intent = INTENT_HARM + to_chat(src, "You will now [a_intent] others.") + return + +/* + * Sub-types + */ +/mob/living/simple_animal/parrot/Poly + name = "Poly" + desc = "Poly the Parrot. An expert on quantum cracker theory." + speak = list("Poly wanna cracker!", ":e Check the crystal, you chucklefucks!",":e Wire the solars, you lazy bums!",":e WHO TOOK THE DAMN HARDSUITS?",":e OH GOD ITS ABOUT TO DELAMINATE CALL THE SHUTTLE") + gold_core_spawnable = NO_SPAWN + speak_chance = 3 + var/memory_saved = FALSE + var/rounds_survived = 0 + var/longest_survival = 0 + var/longest_deathstreak = 0 + +/mob/living/simple_animal/parrot/Poly/Initialize() + ears = new /obj/item/radio/headset/headset_eng(src) + available_channels = list(":e") + Read_Memory() + if(rounds_survived == longest_survival) + speak += pick("...[longest_survival].", "The things I've seen!", "I have lived many lives!", "What are you before me?") + desc += " Old as sin, and just as loud. Claimed to be [rounds_survived]." + speak_chance = 20 //His hubris has made him more annoying/easier to justify killing + add_atom_colour("#EEEE22", FIXED_COLOUR_PRIORITY) + else if(rounds_survived == longest_deathstreak) + speak += pick("What are you waiting for!", "Violence breeds violence!", "Blood! Blood!", "Strike me down if you dare!") + desc += " The squawks of [-rounds_survived] dead parrots ring out in your ears..." + add_atom_colour("#BB7777", FIXED_COLOUR_PRIORITY) + else if(rounds_survived > 0) + speak += pick("...again?", "No, It was over!", "Let me out!", "It never ends!") + desc += " Over [rounds_survived] shifts without a \"terrible\" \"accident\"!" + else + speak += pick("...alive?", "This isn't parrot heaven!", "I live, I die, I live again!", "The void fades!") + + . = ..() + +/mob/living/simple_animal/parrot/Poly/Life() + if(!stat && SSticker.current_state == GAME_STATE_FINISHED && !memory_saved) + Write_Memory(FALSE) + memory_saved = TRUE + ..() + +/mob/living/simple_animal/parrot/Poly/death(gibbed) + if(!memory_saved) + Write_Memory(TRUE) + if(rounds_survived == longest_survival || rounds_survived == longest_deathstreak || prob(0.666)) + var/mob/living/simple_animal/parrot/Poly/ghost/G = new(loc) + if(mind) + mind.transfer_to(G) + else + G.key = key + ..(gibbed) + +/mob/living/simple_animal/parrot/Poly/proc/Read_Memory() + if(fexists("data/npc_saves/Poly.sav")) //legacy compatability to convert old format to new + var/savefile/S = new /savefile("data/npc_saves/Poly.sav") + S["phrases"] >> speech_buffer + S["roundssurvived"] >> rounds_survived + S["longestsurvival"] >> longest_survival + S["longestdeathstreak"] >> longest_deathstreak + fdel("data/npc_saves/Poly.sav") + else + var/json_file = file("data/npc_saves/Poly.json") + if(!fexists(json_file)) + return + var/list/json = json_decode(file2text(json_file)) + speech_buffer = json["phrases"] + rounds_survived = json["roundssurvived"] + longest_survival = json["longestsurvival"] + longest_deathstreak = json["longestdeathstreak"] + if(!islist(speech_buffer)) + speech_buffer = list() + +/mob/living/simple_animal/parrot/Poly/proc/Write_Memory(dead) + var/json_file = file("data/npc_saves/Poly.json") + var/list/file_data = list() + if(islist(speech_buffer)) + file_data["phrases"] = speech_buffer + if(dead) + file_data["roundssurvived"] = min(rounds_survived - 1, 0) + file_data["longestsurvival"] = longest_survival + if(rounds_survived - 1 < longest_deathstreak) + file_data["longestdeathstreak"] = rounds_survived - 1 + else + file_data["longestdeathstreak"] = longest_deathstreak + else + file_data["roundssurvived"] = rounds_survived + 1 + if(rounds_survived + 1 > longest_survival) + file_data["longestsurvival"] = rounds_survived + 1 + else + file_data["longestsurvival"] = longest_survival + file_data["longestdeathstreak"] = longest_deathstreak + fdel(json_file) + WRITE_FILE(json_file, json_encode(file_data)) + +/mob/living/simple_animal/parrot/Poly/ratvar_act() + playsound(src, 'sound/magic/clockwork/fellowship_armory.ogg', 75, TRUE) + var/mob/living/simple_animal/parrot/clock_hawk/H = new(loc) + H.setDir(dir) + qdel(src) + +/mob/living/simple_animal/parrot/Poly/ghost + name = "The Ghost of Poly" + desc = "Doomed to squawk the Earth." + color = "#FFFFFF77" + speak_chance = 20 + status_flags = GODMODE + incorporeal_move = INCORPOREAL_MOVE_BASIC + butcher_results = list(/obj/item/ectoplasm = 1) + +/mob/living/simple_animal/parrot/Poly/ghost/Initialize() + memory_saved = TRUE //At this point nothing is saved + . = ..() + +/mob/living/simple_animal/parrot/Poly/ghost/handle_automated_speech() + if(ismob(loc)) + return + ..() + +/mob/living/simple_animal/parrot/Poly/ghost/handle_automated_movement() + if(isliving(parrot_interest)) + if(!ishuman(parrot_interest)) + parrot_interest = null + else if(parrot_state == (PARROT_SWOOP | PARROT_ATTACK) && Adjacent(parrot_interest)) + walk_to(src, parrot_interest, 0, parrot_speed) + Possess(parrot_interest) + ..() + +/mob/living/simple_animal/parrot/Poly/ghost/proc/Possess(mob/living/carbon/human/H) + if(!ishuman(H)) + return + var/datum/disease/parrot_possession/P = new + P.parrot = src + forceMove(H) + H.ForceContractDisease(P) + parrot_interest = null + H.visible_message("[src] dive bombs into [H]'s chest and vanishes!", "[src] dive bombs into your chest, vanishing! This can't be good!") + + +/mob/living/simple_animal/parrot/clock_hawk + name = "clock hawk" + desc = "Cbyl jnaan penpxre! Fdhnnnjx!" + icon_state = "clock_hawk_fly" + icon_living = "clock_hawk_fly" + icon_sit = "clock_hawk_sit" + speak = list("Penpxre!", "Ratvar vf n qhzo anzr naljnl!") + speak_emote = list("squawks rustily", "says crassly", "yells brassly") + emote_hear = list("squawks rustily.", "bawks metallically!") + emote_see = list("flutters its metal wings.") + faction = list("ratvar") + gold_core_spawnable = NO_SPAWN + del_on_death = TRUE + death_sound = 'sound/magic/clockwork/anima_fragment_death.ogg' + +/mob/living/simple_animal/parrot/clock_hawk/ratvar_act() + return diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index b0cd6080..af91754b 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -84,7 +84,7 @@ if(!client) return - msg = copytext(msg, 1, MAX_MESSAGE_LEN) + msg = copytext_char(msg, 1, MAX_MESSAGE_LEN) if(type) if(type & MSG_VISUAL && eye_blind )//Vision related @@ -418,7 +418,7 @@ mob/visible_message(message, self_message, blind_message, vision_distance = DEFA set name = "Add Note" set category = "IC" - msg = copytext(msg, 1, MAX_MESSAGE_LEN) + msg = copytext_char(msg, 1, MAX_MESSAGE_LEN) msg = sanitize(msg) if(mind) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index b504f96d..76732918 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -1,537 +1,530 @@ - -// see _DEFINES/is_helpers.dm for mob type checks - -/mob/proc/lowest_buckled_mob() - . = src - if(buckled && ismob(buckled)) - var/mob/Buckled = buckled - . = Buckled.lowest_buckled_mob() - -/proc/check_zone(zone) - if(!zone) - return BODY_ZONE_CHEST - switch(zone) - if(BODY_ZONE_PRECISE_EYES) - zone = BODY_ZONE_HEAD - if(BODY_ZONE_PRECISE_MOUTH) - zone = BODY_ZONE_HEAD - if(BODY_ZONE_PRECISE_L_HAND) - zone = BODY_ZONE_L_ARM - if(BODY_ZONE_PRECISE_R_HAND) - zone = BODY_ZONE_R_ARM - if(BODY_ZONE_PRECISE_L_FOOT) - zone = BODY_ZONE_L_LEG - if(BODY_ZONE_PRECISE_R_FOOT) - zone = BODY_ZONE_R_LEG - if(BODY_ZONE_PRECISE_GROIN) - zone = BODY_ZONE_CHEST - return zone - - -/proc/ran_zone(zone, probability = 80) - if(prob(probability)) - zone = check_zone(zone) - else - zone = pickweight(list(BODY_ZONE_HEAD = 6, BODY_ZONE_CHEST = 6, BODY_ZONE_L_ARM = 22, BODY_ZONE_R_ARM = 22, BODY_ZONE_L_LEG = 22, BODY_ZONE_R_LEG = 22)) - return zone - -/proc/above_neck(zone) - var/list/zones = list(BODY_ZONE_HEAD, BODY_ZONE_PRECISE_MOUTH, BODY_ZONE_PRECISE_EYES) - if(zones.Find(zone)) - return 1 - else - return 0 - -/proc/stars(n, pr) - n = html_encode(n) - if (pr == null) - pr = 25 - if (pr <= 0) - return null - else - if (pr >= 100) - return n - var/te = n - var/t = "" - n = length(n) - var/p = null - p = 1 - while(p <= n) - if ((copytext(te, p, p + 1) == " " || prob(pr))) - t = text("[][]", t, copytext(te, p, p + 1)) - else - t = text("[]*", t) - p++ - return sanitize(t) - -/proc/slur(n,var/strength=50) - strength = min(strength,50) - var/phrase = html_decode(n) - var/leng = length(phrase) - var/counter=length(phrase) - var/newphrase="" - var/newletter="" - while(counter>=1) - newletter=copytext(phrase,(leng-counter)+1,(leng-counter)+2) - if(rand(1,100)<=strength*0.5) - if(lowertext(newletter)=="o") - newletter="u" - if(lowertext(newletter)=="s") - newletter="ch" - if(lowertext(newletter)=="a") - newletter="ah" - if(lowertext(newletter)=="u") - newletter="oo" - if(lowertext(newletter)=="c") - newletter="k" - if(rand(1,100) <= strength*0.25) - if(newletter==" ") - newletter="...huuuhhh..." - if(newletter==".") - newletter=" BURP!" - if(rand(1,100) <= strength*0.5) - if(rand(1,5) == 1) - newletter+="'" - if(rand(1,5) == 1) - newletter+="[newletter]" - if(rand(1,5) == 1) - newletter+="[newletter][newletter]" - newphrase+="[newletter]";counter-=1 - return newphrase - - -/proc/cultslur(n) // Inflicted on victims of a stun talisman - var/phrase = html_decode(n) - var/leng = length(phrase) - var/counter=length(phrase) - var/newphrase="" - var/newletter="" - while(counter>=1) - newletter=copytext(phrase,(leng-counter)+1,(leng-counter)+2) - if(rand(1,2)==2) - if(lowertext(newletter)=="o") - newletter="u" - if(lowertext(newletter)=="t") - newletter="ch" - if(lowertext(newletter)=="a") - newletter="ah" - if(lowertext(newletter)=="u") - newletter="oo" - if(lowertext(newletter)=="c") - newletter=" NAR " - if(lowertext(newletter)=="s") - newletter=" SIE " - if(rand(1,4)==4) - if(newletter==" ") - newletter=" no hope... " - if(newletter=="H") - newletter=" IT COMES... " - - switch(rand(1,15)) - if(1) - newletter="'" - if(2) - newletter+="agn" - if(3) - newletter="fth" - if(4) - newletter="nglu" - if(5) - newletter="glor" - newphrase+="[newletter]";counter-=1 - return newphrase - - -/proc/stutter(n) - var/te = html_decode(n) - var/t = ""//placed before the message. Not really sure what it's for. - n = length(n)//length of the entire word - var/p = null - p = 1//1 is the start of any word - while(p <= n)//while P, which starts at 1 is less or equal to N which is the length. - var/n_letter = copytext(te, p, p + 1)//copies text from a certain distance. In this case, only one letter at a time. - if (prob(80) && (ckey(n_letter) in list("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"))) - if (prob(10)) - n_letter = text("[n_letter]-[n_letter]-[n_letter]-[n_letter]")//replaces the current letter with this instead. - else - if (prob(20)) - n_letter = text("[n_letter]-[n_letter]-[n_letter]") - else - if (prob(5)) - n_letter = null - else - n_letter = text("[n_letter]-[n_letter]") - t = text("[t][n_letter]")//since the above is ran through for each letter, the text just adds up back to the original word. - p++//for each letter p is increased to find where the next letter will be. - return copytext(sanitize(t),1,MAX_MESSAGE_LEN) - -/proc/derpspeech(message, stuttering) - message = replacetext(message, " am ", " ") - message = replacetext(message, " is ", " ") - message = replacetext(message, " are ", " ") - message = replacetext(message, "you", "u") - message = replacetext(message, "help", "halp") - message = replacetext(message, "grief", "grife") - message = replacetext(message, "space", "spess") - message = replacetext(message, "carp", "crap") - message = replacetext(message, "reason", "raisin") - if(prob(50)) - message = uppertext(message) - message += "[stutter(pick("!", "!!", "!!!"))]" - if(!stuttering && prob(15)) - message = stutter(message) - return message - - -/proc/Gibberish(t, p)//t is the inputted message, and any value higher than 70 for p will cause letters to be replaced instead of added - /* Turn text into complete gibberish! */ - var/returntext = "" - for(var/i = 1, i <= length(t), i++) - - var/letter = copytext(t, i, i+1) - if(prob(50)) - if(p >= 70) - letter = "" - - for(var/j = 1, j <= rand(0, 2), j++) - letter += pick("#","@","*","&","%","$","/", "<", ">", ";","*","*","*","*","*","*","*") - - returntext += letter - - return returntext - - -/proc/ninjaspeak(n) //NINJACODE -/* -The difference with stutter is that this proc can stutter more than 1 letter -The issue here is that anything that does not have a space is treated as one word (in many instances). For instance, "LOOKING," is a word, including the comma. -It's fairly easy to fix if dealing with single letters but not so much with compounds of letters./N -*/ - var/te = html_decode(n) - var/t = "" - n = length(n) - var/p = 1 - while(p <= n) - var/n_letter - var/n_mod = rand(1,4) - if(p+n_mod>n+1) - n_letter = copytext(te, p, n+1) - else - n_letter = copytext(te, p, p+n_mod) - if (prob(50)) - if (prob(30)) - n_letter = text("[n_letter]-[n_letter]-[n_letter]") - else - n_letter = text("[n_letter]-[n_letter]") - else - n_letter = text("[n_letter]") - t = text("[t][n_letter]") - p=p+n_mod - return copytext(sanitize(t),1,MAX_MESSAGE_LEN) - - -/proc/shake_camera(mob/M, duration, strength=1) - if(!M || !M.client || duration < 1) - return - var/client/C = M.client - var/oldx = C.pixel_x - var/oldy = C.pixel_y - var/max = strength*world.icon_size - var/min = -(strength*world.icon_size) - - for(var/i in 0 to duration-1) - if (i == 0) - animate(C, pixel_x=rand(min,max), pixel_y=rand(min,max), time=1) - else - animate(pixel_x=rand(min,max), pixel_y=rand(min,max), time=1) - animate(pixel_x=oldx, pixel_y=oldy, time=1) - - - -/proc/findname(msg) - if(!istext(msg)) - msg = "[msg]" - for(var/i in GLOB.mob_list) - var/mob/M = i - if(M.real_name == msg) - return M - return 0 - -/mob/proc/first_name() - var/static/regex/firstname = new("^\[^\\s-\]+") //First word before whitespace or "-" - firstname.Find(real_name) - return firstname.match - - -//change a mob's act-intent. Input the intent as a string such as "help" or use "right"/"left -/mob/verb/a_intent_change(input as text) - set name = "a-intent" - set hidden = 1 - - if(!possible_a_intents || !possible_a_intents.len) - return - - if(input in possible_a_intents) - a_intent = input - else - var/current_intent = possible_a_intents.Find(a_intent) - - if(!current_intent) - // Failsafe. Just in case some badmin was playing with VV. - current_intent = 1 - - if(input == INTENT_HOTKEY_RIGHT) - current_intent += 1 - if(input == INTENT_HOTKEY_LEFT) - current_intent -= 1 - - // Handle looping - if(current_intent < 1) - current_intent = possible_a_intents.len - if(current_intent > possible_a_intents.len) - current_intent = 1 - - a_intent = possible_a_intents[current_intent] - - if(hud_used && hud_used.action_intent) - hud_used.action_intent.icon_state = "[a_intent]" - - -/proc/is_blind(A) - if(ismob(A)) - var/mob/B = A - return B.eye_blind - return FALSE - -/mob/proc/hallucinating() - return FALSE - -/proc/is_special_character(mob/M) // returns 1 for special characters and 2 for heroes of gamemode //moved out of admins.dm because things other than admin procs were calling this. - if(!SSticker.HasRoundStarted()) - return FALSE - if(!istype(M)) - return FALSE - if(issilicon(M)) - if(iscyborg(M)) //For cyborgs, returns 1 if the cyborg has a law 0 and special_role. Returns 0 if the borg is merely slaved to an AI traitor. - return FALSE - else if(isAI(M)) - var/mob/living/silicon/ai/A = M - if(A.laws && A.laws.zeroth && A.mind && A.mind.special_role) - return TRUE - return FALSE - if(M.mind && M.mind.special_role)//If they have a mind and special role, they are some type of traitor or antagonist. - switch(SSticker.mode.config_tag) - if("revolution") - if(is_revolutionary(M)) - return 2 - if("cult") - if(M.mind in SSticker.mode.cult) - return 2 - if("nuclear") - if(M.mind.has_antag_datum(/datum/antagonist/nukeop,TRUE)) - return 2 - if("changeling") - if(M.mind.has_antag_datum(/datum/antagonist/changeling,TRUE)) - return 2 - if("wizard") - if(iswizard(M)) - return 2 - if("apprentice") - if(M.mind in SSticker.mode.apprentices) - return 2 - if("monkey") - if(isliving(M)) - var/mob/living/L = M - if(L.diseases && (locate(/datum/disease/transformation/jungle_fever) in L.diseases)) - return 2 - return TRUE - if(M.mind && LAZYLEN(M.mind.antag_datums)) //they have an antag datum! - return TRUE - return FALSE - -/mob/proc/reagent_check(datum/reagent/R) // utilized in the species code - return 1 - -/proc/notify_ghosts(var/message, var/ghost_sound = null, var/enter_link = null, var/atom/source = null, var/mutable_appearance/alert_overlay = null, var/action = NOTIFY_JUMP, flashwindow = TRUE, ignore_mapload = TRUE, ignore_key) //Easy notification of ghosts. - if(ignore_mapload && SSatoms.initialized != INITIALIZATION_INNEW_REGULAR) //don't notify for objects created during a map load - return - for(var/mob/dead/observer/O in GLOB.player_list) - if(O.client) - if (ignore_key && O.ckey in GLOB.poll_ignore[ignore_key]) - continue - to_chat(O, "[message][(enter_link) ? " [enter_link]" : ""]") - if(ghost_sound) - SEND_SOUND(O, sound(ghost_sound)) - if(flashwindow) - window_flash(O.client) - if(source) - var/obj/screen/alert/notify_action/A = O.throw_alert("[REF(source)]_notify_action", /obj/screen/alert/notify_action) - if(A) - if(O.client.prefs && O.client.prefs.UI_style) - A.icon = ui_style2icon(O.client.prefs.UI_style) - A.desc = message - A.action = action - A.target = source - if(!alert_overlay) - alert_overlay = new(source) - alert_overlay.layer = FLOAT_LAYER - alert_overlay.plane = FLOAT_PLANE - A.add_overlay(alert_overlay) - -/proc/item_heal_robotic(mob/living/carbon/human/H, mob/user, brute_heal, burn_heal) - var/obj/item/bodypart/affecting = H.get_bodypart(check_zone(user.zone_selected)) - if(affecting && affecting.status == BODYPART_ROBOTIC) - var/dam //changes repair text based on how much brute/burn was supplied - if(brute_heal > burn_heal) - dam = 1 - else - dam = 0 - if((brute_heal > 0 && affecting.brute_dam > 0) || (burn_heal > 0 && affecting.burn_dam > 0)) - if(affecting.heal_damage(brute_heal, burn_heal, 0, TRUE, FALSE)) - H.update_damage_overlays() - user.visible_message("[user] has fixed some of the [dam ? "dents on" : "burnt wires in"] [H]'s [affecting.name].", \ - "You fix some of the [dam ? "dents on" : "burnt wires in"] [H]'s [affecting.name].") - return 1 //successful heal - else - to_chat(user, "[affecting] is already in good condition!") - - -/proc/IsAdminGhost(var/mob/user) - if(!user) //Are they a mob? Auto interface updates call this with a null src - return - if(!user.client) // Do they have a client? - return - if(!isobserver(user)) // Are they a ghost? - return - if(!check_rights_for(user.client, R_ADMIN)) // Are they allowed? - return - if(!user.client.AI_Interact) // Do they have it enabled? - return - return TRUE - -/proc/offer_control(mob/M) - to_chat(M, "Control of your mob has been offered to dead players.") - if(usr) - log_admin("[key_name(usr)] has offered control of ([key_name(M)]) to ghosts.") - message_admins("[key_name_admin(usr)] has offered control of ([ADMIN_LOOKUPFLW(M)]) to ghosts") - var/poll_message = "Do you want to play as [M.real_name]?" - if(M.mind && M.mind.assigned_role) - poll_message = "[poll_message] Job:[M.mind.assigned_role]." - if(M.mind && M.mind.special_role) - poll_message = "[poll_message] Status:[M.mind.special_role]." - else if(M.mind) - var/datum/antagonist/A = M.mind.has_antag_datum(/datum/antagonist/) - if(A) - poll_message = "[poll_message] Status:[A.name]." - var/list/mob/dead/observer/candidates = pollCandidatesForMob(poll_message, ROLE_PAI, null, FALSE, 100, M) - - if(LAZYLEN(candidates)) - var/mob/dead/observer/C = pick(candidates) - to_chat(M, "Your mob has been taken over by a ghost!") - message_admins("[key_name_admin(C)] has taken control of ([key_name_admin(M)])") - M.ghostize(0) - M.key = C.key - return TRUE - else - to_chat(M, "There were no ghosts willing to take control.") - message_admins("No ghosts were willing to take control of [ADMIN_LOOKUPFLW(M)])") - return FALSE - -/mob/proc/is_flying(mob/M = src) - if(M.movement_type & FLYING) - return 1 - else - return 0 - -/mob/proc/click_random_mob() - var/list/nearby_mobs = list() - for(var/mob/living/L in range(1, src)) - if(L!=src) - nearby_mobs |= L - if(nearby_mobs.len) - var/mob/living/T = pick(nearby_mobs) - ClickOn(T) - -// Logs a message in a mob's individual log, and in the global logs as well if log_globally is true -/mob/log_message(message, message_type, color=null, log_globally = TRUE) - if(!LAZYLEN(message)) - stack_trace("Empty message") - return - - // Cannot use the list as a map if the key is a number, so we stringify it (thank you BYOND) - var/smessage_type = num2text(message_type) - - if(client) - if(!islist(client.player_details.logging[smessage_type])) - client.player_details.logging[smessage_type] = list() - - if(!islist(logging[smessage_type])) - logging[smessage_type] = list() - - var/colored_message = message - if(color) - if(color[1] == "#") - colored_message = "[message]" - else - colored_message = "[message]" - - var/list/timestamped_message = list("[LAZYLEN(logging[smessage_type]) + 1]\[[TIME_STAMP("hh:mm:ss", FALSE)]\] [key_name(src)] [loc_name(src)]" = colored_message) - - logging[smessage_type] += timestamped_message - - if(client) - client.player_details.logging[smessage_type] += timestamped_message - - ..() - -/mob/proc/can_hear() - . = TRUE - -//Examine text for traits shared by multiple types. I wish examine was less copypasted. -/mob/proc/common_trait_examine() - if(HAS_TRAIT(src, TRAIT_DISSECTED)) - var/dissectionmsg = "" - if(HAS_TRAIT_FROM(src, TRAIT_DISSECTED,"Extraterrestrial Dissection")) - dissectionmsg = " via Extraterrestrial Dissection. It is no longer worth experimenting on" - else if(HAS_TRAIT_FROM(src, TRAIT_DISSECTED,"Experimental Dissection")) - dissectionmsg = " via Experimental Dissection" - else if(HAS_TRAIT_FROM(src, TRAIT_DISSECTED,"Thorough Dissection")) - dissectionmsg = " via Thorough Dissection" - . += "This body has been dissected and analyzed[dissectionmsg].
    " -/proc/bloodtype_to_color(var/type) - . = BLOOD_COLOR_HUMAN - switch(type) - if("U")//Universal blood; a bit orange - . = BLOOD_COLOR_UNIVERSAL - if("SY")//Synthetics blood; blue - . = BLOOD_COLOR_SYNTHETIC - if("L")//lizard, a bit pink/purple - . = BLOOD_COLOR_LIZARD - if("X*")//xeno blood; greenish yellow - . = BLOOD_COLOR_XENO - if("HF")// Oil/Hydraulic blood. something something why not. reee - . = BLOOD_COLOR_OIL - if("GEL")// slimepeople blood, rgb 0, 255, 144 - . = BLOOD_COLOR_SLIME - if("BUG")// yellowish, like, y'know bug guts I guess. - . = BLOOD_COLOR_BUG - //add more stuff to the switch if you have more blood colors for different types - // the defines are in _DEFINES/misc.dm - -//gets ID card object from special clothes slot or null. -/mob/proc/get_idcard(hand_first = TRUE) - var/obj/item/held_item = get_active_held_item() - . = held_item?.GetID() - if(!.) //If so, then check the inactive hand - held_item = get_inactive_held_item() - . = held_item?.GetID() - -/mob/proc/get_id_in_hand() - var/obj/item/held_item = get_active_held_item() - if(!held_item) - return - return held_item.GetID() - -//Can the mob see reagents inside of containers? -/mob/proc/can_see_reagents() - return stat == DEAD || has_unlimited_silicon_privilege //Dead guys and silicons can always see reagents + +// see _DEFINES/is_helpers.dm for mob type checks + +/mob/proc/lowest_buckled_mob() + . = src + if(buckled && ismob(buckled)) + var/mob/Buckled = buckled + . = Buckled.lowest_buckled_mob() + +/proc/check_zone(zone) + if(!zone) + return BODY_ZONE_CHEST + switch(zone) + if(BODY_ZONE_PRECISE_EYES) + zone = BODY_ZONE_HEAD + if(BODY_ZONE_PRECISE_MOUTH) + zone = BODY_ZONE_HEAD + if(BODY_ZONE_PRECISE_L_HAND) + zone = BODY_ZONE_L_ARM + if(BODY_ZONE_PRECISE_R_HAND) + zone = BODY_ZONE_R_ARM + if(BODY_ZONE_PRECISE_L_FOOT) + zone = BODY_ZONE_L_LEG + if(BODY_ZONE_PRECISE_R_FOOT) + zone = BODY_ZONE_R_LEG + if(BODY_ZONE_PRECISE_GROIN) + zone = BODY_ZONE_CHEST + return zone + + +/proc/ran_zone(zone, probability = 80) + if(prob(probability)) + zone = check_zone(zone) + else + zone = pickweight(list(BODY_ZONE_HEAD = 6, BODY_ZONE_CHEST = 6, BODY_ZONE_L_ARM = 22, BODY_ZONE_R_ARM = 22, BODY_ZONE_L_LEG = 22, BODY_ZONE_R_LEG = 22)) + return zone + +/proc/above_neck(zone) + var/list/zones = list(BODY_ZONE_HEAD, BODY_ZONE_PRECISE_MOUTH, BODY_ZONE_PRECISE_EYES) + if(zones.Find(zone)) + return 1 + else + return 0 + +/** + * Convert random parts of a passed in message to stars + * + * * phrase - the string to convert + * * probability - probability any character gets changed + * + * This proc is dangerously laggy, avoid it or die + */ +/proc/stars(phrase, probability = 25) + if(probability <= 0) + return phrase + phrase = html_decode(phrase) + var/leng = length(phrase) + . = "" + var/char = "" + for(var/i = 1, i <= leng, i += length(char)) + char = phrase[i] + if(char == " " || !prob(probability)) + . += char + else + . += "*" + return sanitize(.) + +/** + * Makes you speak like you're drunk + */ +/proc/slur(phrase, strength = 50) + strength = min(50, strength) + phrase = html_decode(phrase) + var/leng = length(phrase) + . = "" + var/newletter = "" + var/rawchar = "" + for(var/i = 1, i <= leng, i += length(rawchar)) + rawchar = newletter = phrase[i] + if(rand(1,100)<=strength * 0.5) + var/lowerletter = lowertext(newletter) + if(lowerletter == "o") + newletter = "u" + else if(lowerletter == "s") + newletter = "ch" + else if(lowerletter == "a") + newletter = "ah" + else if(lowerletter == "u") + newletter = "oo" + else if(lowerletter == "c") + newletter = "k" + if(rand(1,100) <= strength * 0.25) + if(newletter == " ") + newletter = "...huuuhhh..." + else if(newletter == ".") + newletter = " *BURP*." + switch(rand(1,100) <= strength * 0.5) + if(1) + newletter += "'" + if(10) + newletter += "[newletter]" + if(20) + newletter += "[newletter][newletter]" + . += "[newletter]" + return sanitize(.) + +/// Makes you talk like you got cult stunned, which is slurring but with some dark messages +/proc/cultslur(phrase) // Inflicted on victims of a stun talisman + phrase = html_decode(phrase) + var/leng = length(phrase) + . = "" + var/newletter = "" + var/rawchar = "" + for(var/i = 1, i <= leng, i += length(rawchar)) + rawchar = newletter = phrase[i] + if(rand(1, 2) == 2) + var/lowerletter = lowertext(newletter) + if(lowerletter == "o") + newletter = "u" + else if(lowerletter == "t") + newletter = "ch" + else if(lowerletter == "a") + newletter = "ah" + else if(lowerletter == "u") + newletter = "oo" + else if(lowerletter == "c") + newletter = " NAR " + else if(lowerletter == "s") + newletter = " SIE " + if(rand(1, 4) == 4) + if(newletter == " ") + newletter = " no hope... " + else if(newletter == "H") + newletter = " IT COMES... " + + switch(rand(1, 15)) + if(1) + newletter = "'" + if(2) + newletter += "agn" + if(3) + newletter = "fth" + if(4) + newletter = "nglu" + if(5) + newletter = "glor" + . += newletter + return sanitize(.) + +///Adds stuttering to the message passed in +/proc/stutter(phrase) + phrase = html_decode(phrase) + var/leng = length(phrase) + . = "" + var/newletter = "" + var/rawchar + for(var/i = 1, i <= leng, i += length(rawchar)) + rawchar = newletter = phrase[i] + if(prob(80) && !(lowertext(newletter) in list("a", "e", "i", "o", "u", " "))) + if(prob(10)) + newletter = "[newletter]-[newletter]-[newletter]-[newletter]" + else if(prob(20)) + newletter = "[newletter]-[newletter]-[newletter]" + else if (prob(5)) + newletter = "" + else + newletter = "[newletter]-[newletter]" + . += newletter + return sanitize(.) + +/proc/derpspeech(message, stuttering) + message = replacetext(message, " am ", " ") + message = replacetext(message, " is ", " ") + message = replacetext(message, " are ", " ") + message = replacetext(message, "you", "u") + message = replacetext(message, "help", "halp") + message = replacetext(message, "grief", "grife") + message = replacetext(message, "space", "spess") + message = replacetext(message, "carp", "crap") + message = replacetext(message, "reason", "raisin") + if(prob(50)) + message = uppertext(message) + message += "[stutter(pick("!", "!!", "!!!"))]" + if(!stuttering && prob(15)) + message = stutter(message) + return message + + +/proc/Gibberish(text, replace_characters = FALSE, chance = 50) + text = html_decode(text) + . = "" + var/rawchar = "" + var/letter = "" + var/lentext = length(text) + for(var/i = 1, i <= lentext, i += length(rawchar)) + rawchar = letter = text[i] + if(prob(chance)) + if(replace_characters) + letter = "" + for(var/j in 1 to rand(0, 2)) + letter += pick("#", "@", "*", "&", "%", "$", "/", "<", ">", ";", "*", "*", "*", "*", "*", "*", "*") + . += letter + return sanitize(.) + +/* +The difference with stutter is that this proc can stutter more than 1 letter +The issue here is that anything that does not have a space is treated as one word (in many instances). For instance, "LOOKING," is a word, including the comma. +It's fairly easy to fix if dealing with single letters but not so much with compounds of letters./N +*/ +/proc/ninjaspeak(phrase) //NINJACODE + . = "" + var/lentext = length_char(phrase) + var/rawchars = "" + var/letter = "" + for(var/i = 1, i <= lentext, i += length_char(rawchars)) + var/end = i + rand(1,4) + letter = rawchars = copytext_char(phrase, i, end > lentext ? 0 : end) + if (prob(50)) + if (prob(30)) + letter = "[letter]-[letter]-[letter]" + else + letter = "[letter]-[letter]" + . += letter + return copytext_char(sanitize(.),1,MAX_MESSAGE_LEN) + +/proc/shake_camera(mob/M, duration, strength=1) + if(!M || !M.client || duration < 1) + return + var/client/C = M.client + var/oldx = C.pixel_x + var/oldy = C.pixel_y + var/max = strength*world.icon_size + var/min = -(strength*world.icon_size) + + for(var/i in 0 to duration-1) + if (i == 0) + animate(C, pixel_x=rand(min,max), pixel_y=rand(min,max), time=1) + else + animate(pixel_x=rand(min,max), pixel_y=rand(min,max), time=1) + animate(pixel_x=oldx, pixel_y=oldy, time=1) + + + +/proc/findname(msg) + if(!istext(msg)) + msg = "[msg]" + for(var/i in GLOB.mob_list) + var/mob/M = i + if(M.real_name == msg) + return M + return 0 + +/mob/proc/first_name() + var/static/regex/firstname = new("^\[^\\s-\]+") //First word before whitespace or "-" + firstname.Find(real_name) + return firstname.match + + +//change a mob's act-intent. Input the intent as a string such as "help" or use "right"/"left +/mob/verb/a_intent_change(input as text) + set name = "a-intent" + set hidden = 1 + + if(!possible_a_intents || !possible_a_intents.len) + return + + if(input in possible_a_intents) + a_intent = input + else + var/current_intent = possible_a_intents.Find(a_intent) + + if(!current_intent) + // Failsafe. Just in case some badmin was playing with VV. + current_intent = 1 + + if(input == INTENT_HOTKEY_RIGHT) + current_intent += 1 + if(input == INTENT_HOTKEY_LEFT) + current_intent -= 1 + + // Handle looping + if(current_intent < 1) + current_intent = possible_a_intents.len + if(current_intent > possible_a_intents.len) + current_intent = 1 + + a_intent = possible_a_intents[current_intent] + + if(hud_used && hud_used.action_intent) + hud_used.action_intent.icon_state = "[a_intent]" + + +/proc/is_blind(A) + if(ismob(A)) + var/mob/B = A + return B.eye_blind + return FALSE + +/mob/proc/hallucinating() + return FALSE + +/proc/is_special_character(mob/M) // returns 1 for special characters and 2 for heroes of gamemode //moved out of admins.dm because things other than admin procs were calling this. + if(!SSticker.HasRoundStarted()) + return FALSE + if(!istype(M)) + return FALSE + if(issilicon(M)) + if(iscyborg(M)) //For cyborgs, returns 1 if the cyborg has a law 0 and special_role. Returns 0 if the borg is merely slaved to an AI traitor. + return FALSE + else if(isAI(M)) + var/mob/living/silicon/ai/A = M + if(A.laws && A.laws.zeroth && A.mind && A.mind.special_role) + return TRUE + return FALSE + if(M.mind && M.mind.special_role)//If they have a mind and special role, they are some type of traitor or antagonist. + switch(SSticker.mode.config_tag) + if("revolution") + if(is_revolutionary(M)) + return 2 + if("cult") + if(M.mind in SSticker.mode.cult) + return 2 + if("nuclear") + if(M.mind.has_antag_datum(/datum/antagonist/nukeop,TRUE)) + return 2 + if("changeling") + if(M.mind.has_antag_datum(/datum/antagonist/changeling,TRUE)) + return 2 + if("wizard") + if(iswizard(M)) + return 2 + if("apprentice") + if(M.mind in SSticker.mode.apprentices) + return 2 + if("monkey") + if(isliving(M)) + var/mob/living/L = M + if(L.diseases && (locate(/datum/disease/transformation/jungle_fever) in L.diseases)) + return 2 + return TRUE + if(M.mind && LAZYLEN(M.mind.antag_datums)) //they have an antag datum! + return TRUE + return FALSE + +/mob/proc/reagent_check(datum/reagent/R) // utilized in the species code + return 1 + +/proc/notify_ghosts(var/message, var/ghost_sound = null, var/enter_link = null, var/atom/source = null, var/mutable_appearance/alert_overlay = null, var/action = NOTIFY_JUMP, flashwindow = TRUE, ignore_mapload = TRUE, ignore_key) //Easy notification of ghosts. + if(ignore_mapload && SSatoms.initialized != INITIALIZATION_INNEW_REGULAR) //don't notify for objects created during a map load + return + for(var/mob/dead/observer/O in GLOB.player_list) + if(O.client) + if (ignore_key && O.ckey in GLOB.poll_ignore[ignore_key]) + continue + to_chat(O, "[message][(enter_link) ? " [enter_link]" : ""]") + if(ghost_sound) + SEND_SOUND(O, sound(ghost_sound)) + if(flashwindow) + window_flash(O.client) + if(source) + var/obj/screen/alert/notify_action/A = O.throw_alert("[REF(source)]_notify_action", /obj/screen/alert/notify_action) + if(A) + if(O.client.prefs && O.client.prefs.UI_style) + A.icon = ui_style2icon(O.client.prefs.UI_style) + A.desc = message + A.action = action + A.target = source + if(!alert_overlay) + alert_overlay = new(source) + alert_overlay.layer = FLOAT_LAYER + alert_overlay.plane = FLOAT_PLANE + A.add_overlay(alert_overlay) + +/proc/item_heal_robotic(mob/living/carbon/human/H, mob/user, brute_heal, burn_heal) + var/obj/item/bodypart/affecting = H.get_bodypart(check_zone(user.zone_selected)) + if(affecting && affecting.status == BODYPART_ROBOTIC) + var/dam //changes repair text based on how much brute/burn was supplied + if(brute_heal > burn_heal) + dam = 1 + else + dam = 0 + if((brute_heal > 0 && affecting.brute_dam > 0) || (burn_heal > 0 && affecting.burn_dam > 0)) + if(affecting.heal_damage(brute_heal, burn_heal, 0, TRUE, FALSE)) + H.update_damage_overlays() + user.visible_message("[user] has fixed some of the [dam ? "dents on" : "burnt wires in"] [H]'s [affecting.name].", \ + "You fix some of the [dam ? "dents on" : "burnt wires in"] [H]'s [affecting.name].") + return 1 //successful heal + else + to_chat(user, "[affecting] is already in good condition!") + + +/proc/IsAdminGhost(var/mob/user) + if(!user) //Are they a mob? Auto interface updates call this with a null src + return + if(!user.client) // Do they have a client? + return + if(!isobserver(user)) // Are they a ghost? + return + if(!check_rights_for(user.client, R_ADMIN)) // Are they allowed? + return + if(!user.client.AI_Interact) // Do they have it enabled? + return + return TRUE + +/proc/offer_control(mob/M) + to_chat(M, "Control of your mob has been offered to dead players.") + if(usr) + log_admin("[key_name(usr)] has offered control of ([key_name(M)]) to ghosts.") + message_admins("[key_name_admin(usr)] has offered control of ([ADMIN_LOOKUPFLW(M)]) to ghosts") + var/poll_message = "Do you want to play as [M.real_name]?" + if(M.mind && M.mind.assigned_role) + poll_message = "[poll_message] Job:[M.mind.assigned_role]." + if(M.mind && M.mind.special_role) + poll_message = "[poll_message] Status:[M.mind.special_role]." + else if(M.mind) + var/datum/antagonist/A = M.mind.has_antag_datum(/datum/antagonist/) + if(A) + poll_message = "[poll_message] Status:[A.name]." + var/list/mob/dead/observer/candidates = pollCandidatesForMob(poll_message, ROLE_PAI, null, FALSE, 100, M) + + if(LAZYLEN(candidates)) + var/mob/dead/observer/C = pick(candidates) + to_chat(M, "Your mob has been taken over by a ghost!") + message_admins("[key_name_admin(C)] has taken control of ([key_name_admin(M)])") + M.ghostize(0) + M.key = C.key + return TRUE + else + to_chat(M, "There were no ghosts willing to take control.") + message_admins("No ghosts were willing to take control of [ADMIN_LOOKUPFLW(M)])") + return FALSE + +/mob/proc/is_flying(mob/M = src) + if(M.movement_type & FLYING) + return 1 + else + return 0 + +/mob/proc/click_random_mob() + var/list/nearby_mobs = list() + for(var/mob/living/L in range(1, src)) + if(L!=src) + nearby_mobs |= L + if(nearby_mobs.len) + var/mob/living/T = pick(nearby_mobs) + ClickOn(T) + +// Logs a message in a mob's individual log, and in the global logs as well if log_globally is true +/mob/log_message(message, message_type, color=null, log_globally = TRUE) + if(!LAZYLEN(message)) + stack_trace("Empty message") + return + + // Cannot use the list as a map if the key is a number, so we stringify it (thank you BYOND) + var/smessage_type = num2text(message_type) + + if(client) + if(!islist(client.player_details.logging[smessage_type])) + client.player_details.logging[smessage_type] = list() + + if(!islist(logging[smessage_type])) + logging[smessage_type] = list() + + var/colored_message = message + if(color) + if(color[1] == "#") + colored_message = "[message]" + else + colored_message = "[message]" + + var/list/timestamped_message = list("[LAZYLEN(logging[smessage_type]) + 1]\[[TIME_STAMP("hh:mm:ss", FALSE)]\] [key_name(src)] [loc_name(src)]" = colored_message) + + logging[smessage_type] += timestamped_message + + if(client) + client.player_details.logging[smessage_type] += timestamped_message + + ..() + +/mob/proc/can_hear() + . = TRUE + +//Examine text for traits shared by multiple types. I wish examine was less copypasted. +/mob/proc/common_trait_examine() + if(HAS_TRAIT(src, TRAIT_DISSECTED)) + var/dissectionmsg = "" + if(HAS_TRAIT_FROM(src, TRAIT_DISSECTED,"Extraterrestrial Dissection")) + dissectionmsg = " via Extraterrestrial Dissection. It is no longer worth experimenting on" + else if(HAS_TRAIT_FROM(src, TRAIT_DISSECTED,"Experimental Dissection")) + dissectionmsg = " via Experimental Dissection" + else if(HAS_TRAIT_FROM(src, TRAIT_DISSECTED,"Thorough Dissection")) + dissectionmsg = " via Thorough Dissection" + . += "This body has been dissected and analyzed[dissectionmsg].
    " +/proc/bloodtype_to_color(var/type) + . = BLOOD_COLOR_HUMAN + switch(type) + if("U")//Universal blood; a bit orange + . = BLOOD_COLOR_UNIVERSAL + if("SY")//Synthetics blood; blue + . = BLOOD_COLOR_SYNTHETIC + if("L")//lizard, a bit pink/purple + . = BLOOD_COLOR_LIZARD + if("X*")//xeno blood; greenish yellow + . = BLOOD_COLOR_XENO + if("HF")// Oil/Hydraulic blood. something something why not. reee + . = BLOOD_COLOR_OIL + if("GEL")// slimepeople blood, rgb 0, 255, 144 + . = BLOOD_COLOR_SLIME + if("BUG")// yellowish, like, y'know bug guts I guess. + . = BLOOD_COLOR_BUG + //add more stuff to the switch if you have more blood colors for different types + // the defines are in _DEFINES/misc.dm + +//gets ID card object from special clothes slot or null. +/mob/proc/get_idcard(hand_first = TRUE) + var/obj/item/held_item = get_active_held_item() + . = held_item?.GetID() + if(!.) //If so, then check the inactive hand + held_item = get_inactive_held_item() + . = held_item?.GetID() + +/mob/proc/get_id_in_hand() + var/obj/item/held_item = get_active_held_item() + if(!held_item) + return + return held_item.GetID() + +//Can the mob see reagents inside of containers? +/mob/proc/can_see_reagents() + return stat == DEAD || has_unlimited_silicon_privilege //Dead guys and silicons can always see reagents diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm index 3061ea60..8c7fc687 100644 --- a/code/modules/mob/say.dm +++ b/code/modules/mob/say.dm @@ -1,138 +1,138 @@ -//Speech verbs. -// the _keybind verbs uses "as text" versus "as text|null" to force a popup when pressed by a keybind. -/mob/verb/say_typing_indicator() - set name = "say_indicator" - set hidden = TRUE - set category = "IC" - display_typing_indicator() - var/message = input(usr, "", "say") as text|null - // If they don't type anything just drop the message. - clear_typing_indicator() // clear it immediately! - if(!length(message)) - return - return say_verb(message) - -/mob/verb/say_verb(message as text) - set name = "say" - set category = "IC" - if(!length(message)) - return - if(GLOB.say_disabled) //This is here to try to identify lag problems - to_chat(usr, "Speech is currently admin-disabled.") - return - clear_typing_indicator() // clear it immediately! - say(message) - -/mob/say_mod(input, message_mode) - var/customsayverb = findtext(input, "*") - if(customsayverb && message_mode != MODE_WHISPER_CRIT) - message_mode = MODE_CUSTOM_SAY - return lowertext(copytext(input, 1, customsayverb)) - else - return ..() - -/mob/verb/me_typing_indicator() - set name = "me_indicator" - set hidden = TRUE - set category = "IC" - display_typing_indicator() - var/message = input(usr, "", "me") as message|null - // If they don't type anything just drop the message. - clear_typing_indicator() // clear it immediately! - if(!length(message)) - return - return me_verb(message) - -/mob/verb/me_verb(message as message) - set name = "me" - set category = "IC" - if(!length(message)) - return - if(GLOB.say_disabled) //This is here to try to identify lag problems - to_chat(usr, "Speech is currently admin-disabled.") - return - - message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)) - clear_typing_indicator() // clear it immediately! - - usr.emote("me",1,message,TRUE) - - -/mob/verb/whisper_verb(message as text) - set name = "Whisper" - set category = "IC" - if(!length(message)) - return - if(GLOB.say_disabled) //This is here to try to identify lag problems - to_chat(usr, "Speech is currently admin-disabled.") - return - whisper(message) - -/mob/proc/whisper(message, datum/language/language=null) - say(message, language) //only living mobs actually whisper, everything else just talks - -/mob/proc/say_dead(var/message) - var/name = real_name - var/alt_name = "" - - if(GLOB.say_disabled) //This is here to try to identify lag problems - to_chat(usr, "Speech is currently admin-disabled.") - return - - var/jb = jobban_isbanned(src, "OOC") - if(QDELETED(src)) - return - - if(jb) - to_chat(src, "You have been banned from deadchat.") - return - - - - if (src.client) - if(src.client.prefs.muted & MUTE_DEADCHAT) - to_chat(src, "You cannot talk in deadchat (muted).") - return - - if(src.client.handle_spam_prevention(message,MUTE_DEADCHAT)) - return - - var/mob/dead/observer/O = src - if(isobserver(src) && O.deadchat_name) - name = "[O.deadchat_name]" - else - if(mind && mind.name) - name = "[mind.name]" - else - name = real_name - if(name != real_name) - alt_name = " (died as [real_name])" - - var/spanned = say_quote(say_emphasis(message)) - message = emoji_parse(message) - var/rendered = "DEAD: [name][alt_name] [emoji_parse(spanned)]" - log_talk(message, LOG_SAY, tag="DEAD") - deadchat_broadcast(rendered, follow_target = src, speaker_key = key) - -/mob/proc/check_emote(message) - if(copytext(message, 1, 2) == "*") - emote(copytext(message, 2), intentional = TRUE) - return 1 - -/mob/proc/hivecheck() - return 0 - -/mob/proc/lingcheck() - return LINGHIVE_NONE - -/mob/proc/get_message_mode(message) - var/key = copytext(message, 1, 2) - if(key == "#") - return MODE_WHISPER - else if(key == "%") - return MODE_SING - else if(key == ";") - return MODE_HEADSET - else if(length(message) > 2 && (key in GLOB.department_radio_prefixes)) - var/key_symbol = lowertext(copytext(message, 2, 3)) - return GLOB.department_radio_keys[key_symbol] +//Speech verbs. +// the _keybind verbs uses "as text" versus "as text|null" to force a popup when pressed by a keybind. +/mob/verb/say_typing_indicator() + set name = "say_indicator" + set hidden = TRUE + set category = "IC" + display_typing_indicator() + var/message = input(usr, "", "say") as text|null + // If they don't type anything just drop the message. + clear_typing_indicator() // clear it immediately! + if(!length(message)) + return + return say_verb(message) + +/mob/verb/say_verb(message as text) + set name = "say" + set category = "IC" + if(!length(message)) + return + if(GLOB.say_disabled) //This is here to try to identify lag problems + to_chat(usr, "Speech is currently admin-disabled.") + return + clear_typing_indicator() // clear it immediately! + say(message) + +/mob/say_mod(input, message_mode) + var/customsayverb = findtext(input, "*") + if(customsayverb && message_mode != MODE_WHISPER_CRIT) + message_mode = MODE_CUSTOM_SAY + return lowertext(copytext_char(input, 1, customsayverb)) + else + return ..() + +/mob/verb/me_typing_indicator() + set name = "me_indicator" + set hidden = TRUE + set category = "IC" + display_typing_indicator() + var/message = input(usr, "", "me") as message|null + // If they don't type anything just drop the message. + clear_typing_indicator() // clear it immediately! + if(!length(message)) + return + return me_verb(message) + +/mob/verb/me_verb(message as message) + set name = "me" + set category = "IC" + if(!length(message)) + return + if(GLOB.say_disabled) //This is here to try to identify lag problems + to_chat(usr, "Speech is currently admin-disabled.") + return + + message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)) + clear_typing_indicator() // clear it immediately! + + usr.emote("me",1,message,TRUE) + + +/mob/verb/whisper_verb(message as text) + set name = "Whisper" + set category = "IC" + if(!length(message)) + return + if(GLOB.say_disabled) //This is here to try to identify lag problems + to_chat(usr, "Speech is currently admin-disabled.") + return + whisper(message) + +/mob/proc/whisper(message, datum/language/language=null) + say(message, language) //only living mobs actually whisper, everything else just talks + +/mob/proc/say_dead(var/message) + var/name = real_name + var/alt_name = "" + + if(GLOB.say_disabled) //This is here to try to identify lag problems + to_chat(usr, "Speech is currently admin-disabled.") + return + + var/jb = jobban_isbanned(src, "OOC") + if(QDELETED(src)) + return + + if(jb) + to_chat(src, "You have been banned from deadchat.") + return + + + + if (src.client) + if(src.client.prefs.muted & MUTE_DEADCHAT) + to_chat(src, "You cannot talk in deadchat (muted).") + return + + if(src.client.handle_spam_prevention(message,MUTE_DEADCHAT)) + return + + var/mob/dead/observer/O = src + if(isobserver(src) && O.deadchat_name) + name = "[O.deadchat_name]" + else + if(mind && mind.name) + name = "[mind.name]" + else + name = real_name + if(name != real_name) + alt_name = " (died as [real_name])" + + var/spanned = say_quote(say_emphasis(message)) + message = emoji_parse(message) + var/rendered = "DEAD: [name][alt_name] [emoji_parse(spanned)]" + log_talk(message, LOG_SAY, tag="DEAD") + deadchat_broadcast(rendered, follow_target = src, speaker_key = key) + +/mob/proc/check_emote(message) + if(message[1] == "*") + emote(copytext(message, length(message[1]) + 1), intentional = TRUE) + return TRUE + +/mob/proc/hivecheck() + return 0 + +/mob/proc/lingcheck() + return LINGHIVE_NONE + +/mob/proc/get_message_mode(message) + var/key = message[1] + if(key == "#") + return MODE_WHISPER + else if(key == "%") + return MODE_SING + else if(key == ";") + return MODE_HEADSET + else if((length(message) > (length(key) + 1)) && (key in GLOB.department_radio_prefixes)) + var/key_symbol = lowertext(message[length(key) + 1]) + return GLOB.department_radio_keys[key_symbol] diff --git a/code/modules/mob/say_vr.dm b/code/modules/mob/say_vr.dm index 6ee1ec69..6d2afa89 100644 --- a/code/modules/mob/say_vr.dm +++ b/code/modules/mob/say_vr.dm @@ -6,11 +6,10 @@ set src in usr if(usr != src) to_chat(usr, "No.") - var/msg = stripped_multiline_input(usr, "Set the flavor text in your 'examine' verb. This can also be used for OOC notes and preferences!", "Flavor Text", html_decode(flavor_text), MAX_MESSAGE_LEN*2, TRUE) + var/msg = stripped_multiline_input(usr, "Set the flavor text in your 'examine' verb. This can also be used for OOC notes and preferences!", "Flavor Text", html_decode(flavor_text), MAX_MESSAGE_LEN, TRUE) - if(!isnull(msg)) - msg = copytext(msg, 1, MAX_MESSAGE_LEN) - msg = html_encode(msg) + if(msg) + flavor_text = html_encode(msg) flavor_text = msg @@ -23,10 +22,10 @@ if(flavor_text && flavor_text != "") // We are decoding and then encoding to not only get correct amount of characters, but also to prevent partial escaping characters being shown. var/msg = html_decode(replacetext(flavor_text, "\n", " ")) - if(length(msg) <= 40) + if(length_char(msg) <= 40) return "[html_encode(msg)]" else - return "[html_encode(copytext(msg, 1, 37))]... More..." + return "[html_encode(copytext_char(msg, 1, 37))]... More..." /mob/proc/get_top_level_mob() if(istype(src.loc,/mob)&&src.loc!=src) @@ -53,17 +52,10 @@ proc/get_top_level_mob(var/mob/S) mob_type_blacklist_typecache = list(/mob/living/brain) /datum/emote/living/subtle/proc/check_invalid(mob/user, input) - . = TRUE - if(copytext(input,1,5) == "says") + if(stop_bad_mime.Find(input, 1, 1)) to_chat(user, "Invalid emote.") - else if(copytext(input,1,9) == "exclaims") - to_chat(user, "Invalid emote.") - else if(copytext(input,1,6) == "yells") - to_chat(user, "Invalid emote.") - else if(copytext(input,1,5) == "asks") - to_chat(user, "Invalid emote.") - else - . = FALSE + return TRUE + return FALSE /datum/emote/living/subtle/run_emote(mob/user, params, type_override = null) if(jobban_isbanned(user, "emote")) @@ -73,7 +65,7 @@ proc/get_top_level_mob(var/mob/S) to_chat(user, "You cannot send IC messages (muted).") return FALSE else if(!params) - var/subtle_emote = copytext(sanitize(input("Choose an emote to display.") as message|null), 1, MAX_MESSAGE_LEN) + var/subtle_emote = stripped_multiline_input("Choose an emote to display.", "Subtle", null, MAX_MESSAGE_LEN) if(subtle_emote && !check_invalid(user, subtle_emote)) var/type = input("Is this a visible or hearable emote?") as null|anything in list("Visible", "Hearable") switch(type) @@ -124,17 +116,10 @@ proc/get_top_level_mob(var/mob/S) /datum/emote/living/subtler/proc/check_invalid(mob/user, input) - . = TRUE - if(copytext(input,1,5) == "says") + if(stop_bad_mime.Find(input, 1, 1)) to_chat(user, "Invalid emote.") - else if(copytext(input,1,9) == "exclaims") - to_chat(user, "Invalid emote.") - else if(copytext(input,1,6) == "yells") - to_chat(user, "Invalid emote.") - else if(copytext(input,1,5) == "asks") - to_chat(user, "Invalid emote.") - else - . = FALSE + return TRUE + return FALSE /datum/emote/living/subtler/run_emote(mob/user, params, type_override = null) if(jobban_isbanned(user, "emote")) @@ -144,7 +129,7 @@ proc/get_top_level_mob(var/mob/S) to_chat(user, "You cannot send IC messages (muted).") return FALSE else if(!params) - var/subtle_emote = copytext(sanitize(input("Choose an emote to display.") as message|null), 1, MAX_MESSAGE_LEN) + var/subtle_emote = stripped_multiline_input(user, "Choose an emote to display.", "Subtler" , null, MAX_MESSAGE_LEN) if(subtle_emote && !check_invalid(user, subtle_emote)) var/type = input("Is this a visible or hearable emote?") as null|anything in list("Visible", "Hearable") switch(type) diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm index 65947711..590b8058 100644 --- a/code/modules/mob/transform_procs.dm +++ b/code/modules/mob/transform_procs.dm @@ -42,8 +42,8 @@ // hash the original name? if(tr_flags & TR_HASHNAME) - O.name = "monkey ([copytext(md5(real_name), 2, 6)])" - O.real_name = "monkey ([copytext(md5(real_name), 2, 6)])" + O.name = "monkey ([copytext_char(md5(real_name), 2, 6)])" + O.real_name = "monkey ([copytext_char(md5(real_name), 2, 6)])" //handle DNA and other attributes dna.transfer_identity(O) @@ -201,7 +201,7 @@ dna.transfer_identity(O) O.updateappearance(mutcolor_update=1) - if(cmptext("monkey",copytext(O.dna.real_name,1,7))) + if(findtext(O.dna.real_name, "monkey", 1, 7)) //7 == length("monkey") + 1 O.real_name = random_unique_name(O.gender) O.dna.generate_unique_enzymes(O) else diff --git a/code/modules/paperwork/folders.dm b/code/modules/paperwork/folders.dm index 4518d9eb..41ee7f63 100644 --- a/code/modules/paperwork/folders.dm +++ b/code/modules/paperwork/folders.dm @@ -44,9 +44,11 @@ if(!user.is_literate()) to_chat(user, "You scribble illegibly on the cover of [src]!") return - var/n_name = copytext(sanitize(input(user, "What would you like to label the folder?", "Folder Labelling", null) as text), 1, MAX_NAME_LEN) + var/inputvalue = stripped_input(user, "What would you like to label the folder?", "Folder Labelling", "", MAX_NAME_LEN) + if(!inputvalue) + return if(user.canUseTopic(src, BE_CLOSE)) - name = "folder[(n_name ? " - '[n_name]'" : null)]" + name = "folder - '[inputvalue]'" /obj/item/folder/attack_self(mob/user) diff --git a/code/modules/paperwork/handlabeler.dm b/code/modules/paperwork/handlabeler.dm index 7c0edf3f..d054e5ff 100644 --- a/code/modules/paperwork/handlabeler.dm +++ b/code/modules/paperwork/handlabeler.dm @@ -70,7 +70,7 @@ if(mode) to_chat(user, "You turn on [src].") //Now let them chose the text. - var/str = copytext(reject_bad_text(input(user,"Label text?","Set label","")),1,MAX_NAME_LEN) + var/str = reject_bad_text(stripped_input(user, "Label text?", "Set label","", MAX_NAME_LEN)) if(!str || !length(str)) to_chat(user, "Invalid text!") return diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index cb8a2648..3ecbac0d 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -152,7 +152,10 @@ if(istart == 0) return //No field found with matching id - laststart = istart+1 + if(links) + laststart = istart + length(info_links[istart]) + else + laststart = istart + length(info[istart]) locid++ if(locid == id) var/iend = 1 diff --git a/code/modules/photography/_pictures.dm b/code/modules/photography/_pictures.dm index 62fc01ef..f667e18f 100644 --- a/code/modules/photography/_pictures.dm +++ b/code/modules/photography/_pictures.dm @@ -111,9 +111,9 @@ if(data.len < 5) return null var/timestamp = data[2] - var/year = copytext(timestamp, 1, 5) - var/month = copytext(timestamp, 5, 7) - var/day = copytext(timestamp, 7, 9) + var/year = copytext_char(timestamp, 1, 5) + var/month = copytext_char(timestamp, 5, 7) + var/day = copytext_char(timestamp, 7, 9) var/round = data[4] . += "[year]/[month]/[day]/round-[round]" if("O") diff --git a/code/modules/photography/photos/photo.dm b/code/modules/photography/photos/photo.dm index 08ac3015..fc50f764 100644 --- a/code/modules/photography/photos/photo.dm +++ b/code/modules/photography/photos/photo.dm @@ -1,93 +1,92 @@ -/* - * Photo - */ -/obj/item/photo - name = "photo" - icon = 'icons/obj/items_and_weapons.dmi' - icon_state = "photo" - item_state = "paper" - w_class = WEIGHT_CLASS_TINY - resistance_flags = FLAMMABLE - max_integrity = 50 - grind_results = list(/datum/reagent/iodine = 4) - var/datum/picture/picture - var/scribble //Scribble on the back. - -/obj/item/photo/Initialize(mapload, datum/picture/P, datum_name = TRUE, datum_desc = TRUE) - set_picture(P, datum_name, datum_desc, TRUE) - return ..() - -/obj/item/photo/proc/set_picture(datum/picture/P, setname, setdesc, name_override = FALSE) - if(!istype(P)) - return - picture = P - update_icon() - if(P.caption) - scribble = P.caption - if(setname && P.picture_name) - if(name_override) - name = P.picture_name - else - name = "photo - [P.picture_name]" - if(setdesc && P.picture_desc) - desc = P.picture_desc - -/obj/item/photo/update_icon() - if(!istype(picture) || !picture.picture_image) - return - var/icon/I = picture.get_small_icon() - if(I) - icon = I - -/obj/item/photo/suicide_act(mob/living/carbon/user) - user.visible_message("[user] is taking one last look at \the [src]! It looks like [user.p_theyre()] giving in to death!")//when you wanna look at photo of waifu one last time before you die... - if (user.gender == MALE) - playsound(user, 'sound/voice/human/manlaugh1.ogg', 50, 1)//EVERY TIME I DO IT MAKES ME LAUGH - else if (user.gender == FEMALE) - playsound(user, 'sound/voice/human/womanlaugh.ogg', 50, 1) - return OXYLOSS - -/obj/item/photo/attack_self(mob/user) - user.examinate(src) - -/obj/item/photo/attackby(obj/item/P, mob/user, params) - if(istype(P, /obj/item/pen) || istype(P, /obj/item/toy/crayon)) - if(!user.is_literate()) - to_chat(user, "You scribble illegibly on [src]!") - return - var/txt = sanitize(input(user, "What would you like to write on the back?", "Photo Writing", null) as text) - txt = copytext(txt, 1, 128) - if(user.canUseTopic(src, BE_CLOSE)) - scribble = txt - ..() - -/obj/item/photo/examine(mob/user) - . = ..() - - if(in_range(src, user)) - show(user) - else - . += "You need to get closer to get a good look at this photo!" - -/obj/item/photo/proc/show(mob/user) - if(!istype(picture) || !picture.picture_image) - to_chat(user, "[src] seems to be blank...") - return - user << browse_rsc(picture.picture_image, "tmp_photo.png") - user << browse("[name]" \ - + "" \ - + "" \ - + "[scribble ? "
    Written on the back:
    [scribble]" : ""]"\ - + "", "window=photo_showing;size=480x608") - onclose(user, "[name]") - -/obj/item/photo/verb/rename() - set name = "Rename photo" - set category = "Object" - set src in usr - - var/n_name = copytext(sanitize(input(usr, "What would you like to label the photo?", "Photo Labelling", null) as text), 1, MAX_NAME_LEN) - //loc.loc check is for making possible renaming photos in clipboards - if((loc == usr || loc.loc && loc.loc == usr) && usr.stat == CONSCIOUS && usr.canmove && !usr.restrained()) - name = "photo[(n_name ? text("- '[n_name]'") : null)]" - add_fingerprint(usr) +/* + * Photo + */ +/obj/item/photo + name = "photo" + icon = 'icons/obj/items_and_weapons.dmi' + icon_state = "photo" + item_state = "paper" + w_class = WEIGHT_CLASS_TINY + resistance_flags = FLAMMABLE + max_integrity = 50 + grind_results = list(/datum/reagent/iodine = 4) + var/datum/picture/picture + var/scribble //Scribble on the back. + +/obj/item/photo/Initialize(mapload, datum/picture/P, datum_name = TRUE, datum_desc = TRUE) + set_picture(P, datum_name, datum_desc, TRUE) + return ..() + +/obj/item/photo/proc/set_picture(datum/picture/P, setname, setdesc, name_override = FALSE) + if(!istype(P)) + return + picture = P + update_icon() + if(P.caption) + scribble = P.caption + if(setname && P.picture_name) + if(name_override) + name = P.picture_name + else + name = "photo - [P.picture_name]" + if(setdesc && P.picture_desc) + desc = P.picture_desc + +/obj/item/photo/update_icon() + if(!istype(picture) || !picture.picture_image) + return + var/icon/I = picture.get_small_icon() + if(I) + icon = I + +/obj/item/photo/suicide_act(mob/living/carbon/user) + user.visible_message("[user] is taking one last look at \the [src]! It looks like [user.p_theyre()] giving in to death!")//when you wanna look at photo of waifu one last time before you die... + if (user.gender == MALE) + playsound(user, 'sound/voice/human/manlaugh1.ogg', 50, 1)//EVERY TIME I DO IT MAKES ME LAUGH + else if (user.gender == FEMALE) + playsound(user, 'sound/voice/human/womanlaugh.ogg', 50, 1) + return OXYLOSS + +/obj/item/photo/attack_self(mob/user) + user.examinate(src) + +/obj/item/photo/attackby(obj/item/P, mob/user, params) + if(istype(P, /obj/item/pen) || istype(P, /obj/item/toy/crayon)) + if(!user.is_literate()) + to_chat(user, "You scribble illegibly on [src]!") + return + var/txt = stripped_input(user, "What would you like to write on the back?", "Photo Writing", "", 128) + if(txt && user.canUseTopic(src, BE_CLOSE)) + scribble = txt + ..() + +/obj/item/photo/examine(mob/user) + . = ..() + + if(in_range(src, user)) + show(user) + else + . += "You need to get closer to get a good look at this photo!" + +/obj/item/photo/proc/show(mob/user) + if(!istype(picture) || !picture.picture_image) + to_chat(user, "[src] seems to be blank...") + return + user << browse_rsc(picture.picture_image, "tmp_photo.png") + user << browse("[name]" \ + + "" \ + + "" \ + + "[scribble ? "
    Written on the back:
    [scribble]" : ""]"\ + + "", "window=photo_showing;size=480x608") + onclose(user, "[name]") + +/obj/item/photo/verb/rename() + set name = "Rename photo" + set category = "Object" + set src in usr + + var/n_name = stripped_input(usr, "What would you like to label the photo?", "Photo Labelling", "", MAX_NAME_LEN) + //loc.loc check is for making possible renaming photos in clipboards + if(n_name && (loc == usr || loc.loc && loc.loc == usr) && usr.stat == CONSCIOUS && usr.canmove && !usr.restrained()) + name = "photo[(n_name ? text("- '[n_name]'") : null)]" + add_fingerprint(usr) diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index 3c926ef4..d2f8631b 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -85,8 +85,8 @@ By design, d1 is the smallest direction and d2 is the highest if(isnull(_d1) || isnull(_d2)) // ensure d1 & d2 reflect the icon_state for entering and exiting cable var/dash = findtext(icon_state, "-") - d1 = text2num( copytext( icon_state, 1, dash ) ) - d2 = text2num( copytext( icon_state, dash+1 ) ) + d1 = text2num(copytext(icon_state, 1, dash)) + d2 = text2num(copytext(icon_state, dash + length(icon_state[dash]))) else d1 = _d1 d2 = _d2 diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index 3f7fdc45..712eee94 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -79,7 +79,7 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne return main_part.attackby(I, user) /obj/machinery/gravity_generator/part/get_status() - return main_part.get_status() + return main_part?.get_status() /obj/machinery/gravity_generator/part/attack_hand(mob/user) return main_part.attack_hand(user) diff --git a/code/modules/procedural_mapping/mapGenerator.dm b/code/modules/procedural_mapping/mapGenerator.dm index 4c9e1ddd..f509c409 100644 --- a/code/modules/procedural_mapping/mapGenerator.dm +++ b/code/modules/procedural_mapping/mapGenerator.dm @@ -30,7 +30,7 @@ /datum/mapGenerator/New() ..() if(buildmode_name == "Undocumented") - buildmode_name = copytext("[type]", 20) // / d a t u m / m a p g e n e r a t o r / = 20 characters. + buildmode_name = copytext_char("[type]", 20) // / d a t u m / m a p g e n e r a t o r / = 20 characters. initialiseModules() //Defines the region the map represents, sets map diff --git a/code/modules/reagents/chem_wiki_render.dm b/code/modules/reagents/chem_wiki_render.dm index e24da70d..018161b0 100644 --- a/code/modules/reagents/chem_wiki_render.dm +++ b/code/modules/reagents/chem_wiki_render.dm @@ -196,7 +196,7 @@ return "" - var/outstring = "|

    !\[[R.color]\](https://placehold.it/15/[copytext(R.color, 2, 8)]/000000?text=+)[R.name]
    pH: [R.pH] | " + var/outstring = "|
    !\[[R.color]\](https://placehold.it/15/[copytext_char(R.color, 2, 8)]/000000?text=+)[R.name]
    pH: [R.pH] | " var/datum/reagent/R3 if(CR) outstring += "
      " diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index 33cf85c4..06325bbc 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -553,9 +553,13 @@ if(MUTCOLORS in N.dna.species.species_traits) //take current alien color and darken it slightly var/newcolor = "" - var/len = length(N.dna.features["mcolor"]) - for(var/i=1, i<=len, i+=1) - var/ascii = text2ascii(N.dna.features["mcolor"],i) + var/string = N.dna.features["mcolor"] + var/len = length(string) + var/char = "" + var/ascii = 0 + for(var/i=1, i<=len, i += length(char)) + char = string[i] + ascii = text2ascii(char) switch(ascii) if(48) newcolor += "0" @@ -566,7 +570,7 @@ if(98 to 102) newcolor += ascii2text(ascii-1) //letters b to f lowercase if(65) - newcolor +="9" + newcolor += "9" if(66 to 70) newcolor += ascii2text(ascii+31) //letters B to F - translates to lowercase else diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index b2be2bd8..198d9b36 100644 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -36,7 +36,7 @@ if(!user.is_literate()) to_chat(user, "You scribble illegibly on the side of [src]!") return - var/str = copytext(sanitize(input(user,"Label text?","Set label","")),1,MAX_NAME_LEN) + var/str = stripped_input(user, "Label text?", "Set label", "", MAX_NAME_LEN) if(!user.canUseTopic(src, BE_CLOSE)) return if(!str || !length(str)) @@ -122,7 +122,7 @@ if(!user.is_literate()) to_chat(user, "You scribble illegibly on the side of [src]!") return - var/str = copytext(sanitize(input(user,"Label text?","Set label","")),1,MAX_NAME_LEN) + var/str = stripped_input(user, "Label text?", "Set label", "", MAX_NAME_LEN) if(!user.canUseTopic(src, BE_CLOSE)) return if(!str || !length(str)) diff --git a/code/modules/research/nanites/nanite_programs/suppression.dm b/code/modules/research/nanites/nanite_programs/suppression.dm index a6225fd3..a0df4dc6 100644 --- a/code/modules/research/nanites/nanite_programs/suppression.dm +++ b/code/modules/research/nanites/nanite_programs/suppression.dm @@ -130,7 +130,7 @@ var/new_sentence = stripped_input(user, "Choose the sentence that the host will be forced to say.", "Sentence", sentence, MAX_MESSAGE_LEN) if(!new_sentence) return - if(copytext(new_sentence, 1, 2) == "*") //emotes are abusable, like surrender + if(new_sentence[1] == "*") //emotes are abusable, like surrender return sentence = new_sentence diff --git a/code/modules/research/rdconsole.dm b/code/modules/research/rdconsole.dm index 709258e9..f0bea36c 100644 --- a/code/modules/research/rdconsole.dm +++ b/code/modules/research/rdconsole.dm @@ -1,1131 +1,1131 @@ - -/* -Research and Development (R&D) Console - -This is the main work horse of the R&D system. It contains the menus/controls for the Destructive Analyzer, Protolathe, and Circuit -imprinter. - -Basic use: When it first is created, it will attempt to link up to related devices within 3 squares. It'll only link up if they -aren't already linked to another console. Any consoles it cannot link up with (either because all of a certain type are already -linked or there aren't any in range), you'll just not have access to that menu. In the settings menu, there are menu options that -allow a player to attempt to re-sync with nearby consoles. You can also force it to disconnect from a specific console. - -The only thing that requires toxins access is locking and unlocking the console on the settings menu. -Nothing else in the console has ID requirements. - -*/ -/obj/machinery/computer/rdconsole - name = "R&D Console" - desc = "A console used to interface with R&D tools." - icon_screen = "rdcomp" - icon_keyboard = "rd_key" - var/datum/techweb/stored_research //Reference to global science techweb. - var/obj/item/disk/tech_disk/t_disk //Stores the technology disk. - var/obj/item/disk/design_disk/d_disk //Stores the design disk. - circuit = /obj/item/circuitboard/computer/rdconsole - - var/obj/machinery/rnd/destructive_analyzer/linked_destroy //Linked Destructive Analyzer - var/obj/machinery/rnd/production/protolathe/linked_lathe //Linked Protolathe - var/obj/machinery/rnd/production/circuit_imprinter/linked_imprinter //Linked Circuit Imprinter - - req_access = list(ACCESS_TOX) //lA AND SETTING MANIPULATION REQUIRES SCIENTIST ACCESS. - - //UI VARS - var/screen = RDSCREEN_MENU - var/back = RDSCREEN_MENU - var/locked = FALSE - var/tdisk_uple = FALSE - var/ddisk_uple = FALSE - var/datum/techweb_node/selected_node - var/datum/design/selected_design - var/selected_category - var/list/datum/design/matching_designs - var/disk_slot_selected - var/searchstring = "" - var/searchtype = "" - var/ui_mode = RDCONSOLE_UI_MODE_NORMAL - - var/research_control = TRUE - -/obj/machinery/computer/rdconsole/production - circuit = /obj/item/circuitboard/computer/rdconsole/production - research_control = FALSE - -/proc/CallMaterialName(ID) - if (copytext(ID, 1, 2) == "$" && GLOB.materials_list[ID]) - var/datum/material/material = GLOB.materials_list[ID] - return material.name - - else if(GLOB.chemical_reagents_list[ID]) - var/datum/reagent/reagent = GLOB.chemical_reagents_list[ID] - return reagent.name - return "ERROR: Report This" - -/obj/machinery/computer/rdconsole/proc/SyncRDevices() //Makes sure it is properly sync'ed up with the devices attached to it (if any). - for(var/obj/machinery/rnd/D in oview(3,src)) - if(D.linked_console != null || D.disabled || D.panel_open) - continue - if(istype(D, /obj/machinery/rnd/destructive_analyzer)) - if(linked_destroy == null) - linked_destroy = D - D.linked_console = src - else if(istype(D, /obj/machinery/rnd/production/protolathe)) - if(linked_lathe == null) - var/obj/machinery/rnd/production/protolathe/P = D - if(!P.console_link) - continue - linked_lathe = D - D.linked_console = src - else if(istype(D, /obj/machinery/rnd/production/circuit_imprinter)) - if(linked_imprinter == null) - var/obj/machinery/rnd/production/circuit_imprinter/C = D - if(!C.console_link) - continue - linked_imprinter = D - D.linked_console = src - -/obj/machinery/computer/rdconsole/Initialize() - . = ..() - stored_research = SSresearch.science_tech - stored_research.consoles_accessing[src] = TRUE - matching_designs = list() - SyncRDevices() - -/obj/machinery/computer/rdconsole/Destroy() - if(stored_research) - stored_research.consoles_accessing -= src - if(linked_destroy) - linked_destroy.linked_console = null - linked_destroy = null - if(linked_lathe) - linked_lathe.linked_console = null - linked_lathe = null - if(linked_imprinter) - linked_imprinter.linked_console = null - linked_imprinter = null - if(t_disk) - t_disk.forceMove(get_turf(src)) - t_disk = null - if(d_disk) - d_disk.forceMove(get_turf(src)) - d_disk = null - matching_designs = null - selected_node = null - selected_design = null - return ..() - -/obj/machinery/computer/rdconsole/attackby(obj/item/D, mob/user, params) - //Loading a disk into it. - if(istype(D, /obj/item/disk)) - if(istype(D, /obj/item/disk/tech_disk)) - if(t_disk) - to_chat(user, "A technology disk is already loaded!") - return - if(!user.transferItemToLoc(D, src)) - to_chat(user, "[D] is stuck to your hand!") - return - t_disk = D - else if (istype(D, /obj/item/disk/design_disk)) - if(d_disk) - to_chat(user, "A design disk is already loaded!") - return - if(!user.transferItemToLoc(D, src)) - to_chat(user, "[D] is stuck to your hand!") - return - d_disk = D - else - to_chat(user, "Machine cannot accept disks in that format.") - return - to_chat(user, "You insert [D] into \the [src]!") - else if(!(linked_destroy && linked_destroy.busy) && !(linked_lathe && linked_lathe.busy) && !(linked_imprinter && linked_imprinter.busy)) - . = ..() - -/obj/machinery/computer/rdconsole/proc/research_node(id, mob/user) - if(!stored_research.available_nodes[id] || stored_research.researched_nodes[id]) - say("Node unlock failed: Either already researched or not available!") - return FALSE - var/datum/techweb_node/TN = SSresearch.techweb_nodes[id] - if(!istype(TN)) - say("Node unlock failed: Unknown error.") - return FALSE - var/list/price = TN.get_price(stored_research) - if(stored_research.can_afford(price)) - investigate_log("[key_name(user)] researched [id]([json_encode(price)]) on techweb id [stored_research.id].", INVESTIGATE_RESEARCH) - if(stored_research == SSresearch.science_tech) - SSblackbox.record_feedback("associative", "science_techweb_unlock", 1, list("id" = "[id]", "name" = TN.display_name, "price" = "[json_encode(price)]", "time" = SQLtime())) - if(stored_research.research_node(SSresearch.techweb_nodes[id])) - say("Successfully researched [TN.display_name].") - var/logname = "Unknown" - if(isAI(user)) - logname = "AI: [user.name]" - else if(iscyborg(user)) - logname = "Cyborg: [user.name]" - else if(isliving(user)) - var/mob/living/L = user - logname = L.get_visible_name() - stored_research.research_logs += "[logname] researched node id [id] with cost [json_encode(price)] at [COORD(src)]." - return TRUE - else - say("Failed to research node: Internal database error!") - return FALSE - say("Not enough research points...") - return FALSE - -/obj/machinery/computer/rdconsole/on_deconstruction() - if(linked_destroy) - linked_destroy.linked_console = null - linked_destroy = null - if(linked_lathe) - linked_lathe.linked_console = null - linked_lathe = null - if(linked_imprinter) - linked_imprinter.linked_console = null - linked_imprinter = null - ..() - -/obj/machinery/computer/rdconsole/emag_act(mob/user) - if(!(obj_flags & EMAGGED)) - to_chat(user, "You disable the security protocols[locked? " and unlock the console":""].") - playsound(src, "sparks", 75, 1) - obj_flags |= EMAGGED - locked = FALSE - return ..() - -/obj/machinery/computer/rdconsole/multitool_act(mob/user, obj/item/multitool/I) - var/lathe = linked_lathe && linked_lathe.multitool_act(user, I) - var/print = linked_imprinter && linked_imprinter.multitool_act(user, I) - return lathe || print - -/obj/machinery/computer/rdconsole/proc/list_categories(list/categories, menu_num as num) - if(!categories) - return - - var/line_length = 1 - var/list/l = "" - - for(var/C in categories) - if(line_length > 2) - l += "" - line_length = 1 - - l += "" - line_length++ - - l += "
      [C]
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_header() - var/list/l = list() - var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/research_designs) - l += "[sheet.css_tag()][RDSCREEN_NOBREAK]" - l += "
      [stored_research.organization] Research and Development Network" - l += "Available points:
      [techweb_point_display_rdconsole(stored_research.research_points, stored_research.last_bitcoins)]" - l += "Security protocols: [obj_flags & EMAGGED ? "Disabled" : "Enabled"]" - l += "Main Menu | Back
      [RDSCREEN_NOBREAK]" - l += "[ui_mode == 1? "Normal View" : "Normal View"] | [ui_mode == 2? "Expert View" : "Expert View"] | [ui_mode == 3? "List View" : "List View"]" - return l - -/obj/machinery/computer/rdconsole/proc/ui_main_menu() - var/list/l = list() - if(research_control) - l += "

      Technology" - if(d_disk) - l += "
      Design Disk" - if(t_disk) - l += "
      Tech Disk" - if(linked_destroy) - l += "
      Destructive Analyzer" - if(linked_lathe) - l += "
      Protolathe" - if(linked_imprinter) - l += "
      Circuit Imprinter" - l += "
      Settings

      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_locked() - return list("

      SYSTEM LOCKED


      ") - -/obj/machinery/computer/rdconsole/proc/ui_settings() - var/list/l = list() - l += "

      R&D Console Settings:

      " - l += "Device Linkage Menu" - l += "Lock Console
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_device_linking() - var/list/l = list() - l += "Settings Menu
      " - l += "

      R&D Console Device Linkage Menu:

      " - l += "Re-sync with Nearby Devices" - l += "

      Linked Devices:

      " - l += linked_destroy? "* Destructive Analyzer Disconnect" : "* No Destructive Analyzer Linked" - l += linked_lathe? "* Protolathe Disconnect" : "* No Protolathe Linked" - l += linked_imprinter? "* Circuit Imprinter Disconnect" : "* No Circuit Imprinter Linked" - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_protolathe_header() - var/list/l = list() - l += "
      Protolathe Menu" - if(linked_lathe.materials.mat_container) - l += "Material Amount: [linked_lathe.materials.format_amount()]" - else - l += "No material storage connected, please contact the quartermaster." - l += "Chemical volume: [linked_lathe.reagents.total_volume] / [linked_lathe.reagents.maximum_volume]
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_protolathe_category_view() //Legacy code - RDSCREEN_UI_LATHE_CHECK - var/list/l = list() - l += ui_protolathe_header() - l += "

      Browsing [selected_category]:

      " - for(var/v in stored_research.researched_designs) - var/datum/design/D = stored_research.researched_designs[v] - if(!(selected_category in D.category)|| !(D.build_type & PROTOLATHE)) - continue - if(!(isnull(linked_lathe.allowed_department_flags) || (D.departmental_flags & linked_lathe.allowed_department_flags))) - continue - var/temp_material - var/c = 50 - var/coeff = linked_lathe.efficiency_coeff - if(!linked_lathe.efficient_with(D.build_path)) - coeff = 1 - - var/all_materials = D.materials + D.reagents_list - for(var/M in all_materials) - var/t = linked_lathe.check_mat(D, M) - temp_material += " | " - if (t < 1) - temp_material += "[all_materials[M]/coeff] [CallMaterialName(M)]" - else - temp_material += " [all_materials[M]/coeff] [CallMaterialName(M)]" - c = min(c,t) - - if (c >= 1) - l += "[D.name][RDSCREEN_NOBREAK]" - if(c >= 5) - l += "x5[RDSCREEN_NOBREAK]" - if(c >= 10) - l += "x10[RDSCREEN_NOBREAK]" - l += "[temp_material][RDSCREEN_NOBREAK]" - else - l += "[D.name][temp_material][RDSCREEN_NOBREAK]" - l += "" - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_protolathe() //Legacy code - RDSCREEN_UI_LATHE_CHECK - var/list/l = list() - l += ui_protolathe_header() - - l += "
      \ - \ - \ - \ - \ - \ -

      " - - l += list_categories(linked_lathe.categories, RDSCREEN_PROTOLATHE_CATEGORY_VIEW) - - return l - -/obj/machinery/computer/rdconsole/proc/ui_protolathe_search() //Legacy code - RDSCREEN_UI_LATHE_CHECK - var/list/l = list() - l += ui_protolathe_header() - for(var/datum/design/D in matching_designs) - if(!(isnull(linked_lathe.allowed_department_flags) || (D.departmental_flags & linked_lathe.allowed_department_flags))) - continue - var/temp_material - var/c = 50 - var/all_materials = D.materials + D.reagents_list - var/coeff = linked_lathe.efficiency_coeff - if(!linked_lathe.efficient_with(D.build_path)) - coeff = 1 - for(var/M in all_materials) - var/t = linked_lathe.check_mat(D, M) - temp_material += " | " - if (t < 1) - temp_material += "[all_materials[M]/coeff] [CallMaterialName(M)]" - else - temp_material += " [all_materials[M]/coeff] [CallMaterialName(M)]" - c = min(c,t) - - if (c >= 1) - l += "[D.name][RDSCREEN_NOBREAK]" - if(c >= 5) - l += "x5[RDSCREEN_NOBREAK]" - if(c >= 10) - l += "x10[RDSCREEN_NOBREAK]" - l += "[temp_material][RDSCREEN_NOBREAK]" - else - l += "[D.name][temp_material][RDSCREEN_NOBREAK]" - l += "" - l += "" - return l - -/obj/machinery/computer/rdconsole/proc/ui_protolathe_materials() //Legacy code - RDSCREEN_UI_LATHE_CHECK - var/datum/component/material_container/mat_container = linked_lathe.materials.mat_container - if (!mat_container) - screen = RDSCREEN_PROTOLATHE - return ui_protolathe() - var/list/l = list() - l += ui_protolathe_header() - l += "

      Material Storage:

      " - for(var/mat_id in mat_container.materials) - var/datum/material/M = mat_container.materials[mat_id] - l += "* [M.amount] of [M.name]: " - if(M.amount >= MINERAL_MATERIAL_AMOUNT) l += "Eject [RDSCREEN_NOBREAK]" - if(M.amount >= MINERAL_MATERIAL_AMOUNT*5) l += "5x [RDSCREEN_NOBREAK]" - if(M.amount >= MINERAL_MATERIAL_AMOUNT) l += "All[RDSCREEN_NOBREAK]" - l += "" - l += "
      [RDSCREEN_NOBREAK]" - return l - -/obj/machinery/computer/rdconsole/proc/ui_protolathe_chemicals() //Legacy code - RDSCREEN_UI_LATHE_CHECK - var/list/l = list() - l += ui_protolathe_header() - l += "
      Disposal All Chemicals in Storage" - l += "

      Chemical Storage:

      " - for(var/datum/reagent/R in linked_lathe.reagents.reagent_list) - l += "[R.name]: [R.volume]" - l += "Purge" - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_circuit_header() //Legacy Code - var/list/l = list() - l += "
      Circuit Imprinter Menu" - if (linked_imprinter.materials.mat_container) - l += "Material Amount: [linked_imprinter.materials.format_amount()]" - else - l += "No material storage connected, please contact the quartermaster." - l += "Chemical volume: [linked_imprinter.reagents.total_volume] / [linked_imprinter.reagents.maximum_volume]
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_circuit() //Legacy code - RDSCREEN_UI_IMPRINTER_CHECK - var/list/l = list() - l += ui_circuit_header() - l += "

      Circuit Imprinter Menu:

      " - - l += "
      \ - \ - \ - \ - \ - \ -

      " - - l += list_categories(linked_imprinter.categories, RDSCREEN_IMPRINTER_CATEGORY_VIEW) - return l - -/obj/machinery/computer/rdconsole/proc/ui_circuit_category_view() //Legacy code - RDSCREEN_UI_IMPRINTER_CHECK - var/list/l = list() - l += ui_circuit_header() - l += "

      Browsing [selected_category]:

      " - - for(var/v in stored_research.researched_designs) - var/datum/design/D = stored_research.researched_designs[v] - if(!(selected_category in D.category) || !(D.build_type & IMPRINTER)) - continue - if(!(isnull(linked_imprinter.allowed_department_flags) || (D.departmental_flags & linked_imprinter.allowed_department_flags))) - continue - var/temp_materials - var/check_materials = TRUE - - var/all_materials = D.materials + D.reagents_list - var/coeff = linked_imprinter.efficiency_coeff - if(!linked_imprinter.efficient_with(D.build_path)) - coeff = 1 - - for(var/M in all_materials) - temp_materials += " | " - if (!linked_imprinter.check_mat(D, M)) - check_materials = FALSE - temp_materials += " [all_materials[M]/coeff] [CallMaterialName(M)]" - else - temp_materials += " [all_materials[M]/coeff] [CallMaterialName(M)]" - if (check_materials) - l += "[D.name][temp_materials]" - else - l += "[D.name][temp_materials]" - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_circuit_search() //Legacy code - RDSCREEN_UI_IMPRINTER_CHECK - var/list/l = list() - l += ui_circuit_header() - l += "

      Search results:

      " - - for(var/datum/design/D in matching_designs) - if(!(isnull(linked_imprinter.allowed_department_flags) || (D.departmental_flags & linked_imprinter.allowed_department_flags))) - continue - var/temp_materials - var/check_materials = TRUE - var/all_materials = D.materials + D.reagents_list - var/coeff = linked_imprinter.efficiency_coeff - if(!linked_imprinter.efficient_with(D.build_path)) - coeff = 1 - for(var/M in all_materials) - temp_materials += " | " - if (!linked_imprinter.check_mat(D, M)) - check_materials = FALSE - temp_materials += " [all_materials[M]/coeff] [CallMaterialName(M)]" - else - temp_materials += " [all_materials[M]/coeff] [CallMaterialName(M)]" - if (check_materials) - l += "[D.name][temp_materials]" - else - l += "[D.name][temp_materials]" - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_circuit_chemicals() //legacy code - RDSCREEN_UI_IMPRINTER_CHECK - var/list/l = list() - l += ui_circuit_header() - l += "Disposal All Chemicals in Storage
      " - l += "

      Chemical Storage:

      " - for(var/datum/reagent/R in linked_imprinter.reagents.reagent_list) - l += "[R.name]: [R.volume]" - l += "Purge" - return l - -/obj/machinery/computer/rdconsole/proc/ui_circuit_materials() //Legacy code! - RDSCREEN_UI_IMPRINTER_CHECK - var/datum/component/material_container/mat_container = linked_imprinter.materials.mat_container - if (!mat_container) - screen = RDSCREEN_IMPRINTER - return ui_circuit() - var/list/l = list() - l += ui_circuit_header() - l += "

      Material Storage:

      " - for(var/mat_id in mat_container.materials) - var/datum/material/M = mat_container.materials[mat_id] - l += "* [M.amount] of [M.name]: " - if(M.amount >= MINERAL_MATERIAL_AMOUNT) l += "Eject [RDSCREEN_NOBREAK]" - if(M.amount >= MINERAL_MATERIAL_AMOUNT*5) l += "5x [RDSCREEN_NOBREAK]" - if(M.amount >= MINERAL_MATERIAL_AMOUNT) l += "All[RDSCREEN_NOBREAK]
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_techdisk() //Legacy code - RDSCREEN_UI_TDISK_CHECK - var/list/l = list() - l += "
      Disk Operations: Clear Disk" - l += "Eject Disk" - l += "Upload All" - l += "Load Technology to Disk
      " - l += "

      Stored Technology Nodes:

      " - for(var/i in t_disk.stored_research.researched_nodes) - var/datum/techweb_node/N = t_disk.stored_research.researched_nodes[i] - l += "[N.display_name]" - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_designdisk() //Legacy code - RDSCREEN_UI_DDISK_CHECK - var/list/l = list() - l += "Disk Operations: Clear DiskUpload AllEject Disk" - for(var/i in 1 to d_disk.max_blueprints) - l += "
      " - if(d_disk.blueprints[i]) - var/datum/design/D = d_disk.blueprints[i] - l += "[D.name]" - l += "Operations: Upload to database Clear Slot" - else - l += "Empty Slot Operations: Load Design to Slot" - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_designdisk_upload() //Legacy code - RDSCREEN_UI_DDISK_CHECK - var/list/l = list() - l += "Return to Disk Operations
      " - l += "

      Load Design to Disk:

      " - for(var/v in stored_research.researched_designs) - var/datum/design/D = stored_research.researched_designs[v] - l += "[D.name] " - l += "Copy to Disk" - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_deconstruct() //Legacy code - RDSCREEN_UI_DECONSTRUCT_CHECK - var/list/l = list() - if(!linked_destroy.loaded_item) - l += "
      No item loaded. Standing-by...
      " - else - l += "
      [RDSCREEN_NOBREAK]" - l += "
      [icon2html(linked_destroy.loaded_item, usr)][linked_destroy.loaded_item.name] Eject
      [RDSCREEN_NOBREAK]" - l += "Select a node to boost by deconstructing this item. This item can boost:" - - var/anything = FALSE - var/list/boostable_nodes = techweb_item_boost_check(linked_destroy.loaded_item) - for(var/id in boostable_nodes) - anything = TRUE - var/list/worth = boostable_nodes[id] - var/datum/techweb_node/N = get_techweb_node_by_id(id) - - l += "
      [RDSCREEN_NOBREAK]" - if (stored_research.researched_nodes[N.id]) // already researched - l += "[N.display_name]" - l += "This node has already been researched." - else if(!length(worth)) // reveal only - if (stored_research.hidden_nodes[N.id]) - l += "[N.display_name]" - l += "This node will be revealed." - else - l += "[N.display_name]" - l += "This node has already been revealed." - else // boost by the difference - var/list/differences = list() - var/list/already_boosted = stored_research.boosted_nodes[N.id] - for(var/i in worth) - var/already_boosted_amount = already_boosted? stored_research.boosted_nodes[N.id][i] : 0 - var/amt = min(worth[i], N.research_costs[i]) - already_boosted_amount - if(amt > 0) - differences[i] = amt - if (length(differences)) - l += "[N.display_name]" - l += "This node will be boosted with the following:
      [techweb_point_display_generic(differences)]" - else - l += "[N.display_name]" - l += "This node has already been boosted." - l += "
      [RDSCREEN_NOBREAK]" - - // point deconstruction and material reclamation use the same ID to prevent accidentally missing the points - var/list/point_values = techweb_item_point_check(linked_destroy.loaded_item) - if(point_values) - anything = TRUE - l += "
      [RDSCREEN_NOBREAK]" - if (stored_research.deconstructed_items[linked_destroy.loaded_item.type]) - l += "Point Deconstruction" - l += "This item's points have already been claimed." - else - l += "Point Deconstruction" - l += "This item is worth:
      [techweb_point_display_generic(point_values)]!" - l += "
      [RDSCREEN_NOBREAK]" - - if(!(linked_destroy.loaded_item.resistance_flags & INDESTRUCTIBLE)) - var/list/materials = linked_destroy.loaded_item.materials - l += "
      [materials.len? "Material Reclamation" : "Destroy Item"]" - for (var/M in materials) - l += "* [CallMaterialName(M)] x [materials[M]]" - l += "
      [RDSCREEN_NOBREAK]" - anything = TRUE - - if (!anything) - l += "Nothing!" - - l += "
      " - return l - -/obj/machinery/computer/rdconsole/proc/ui_techweb() - var/list/l = list() - if(islist(stored_research.research_logs) && stored_research.research_logs.len) - l += "Last action: [stored_research.research_logs[stored_research.research_logs.len]]" - if(ui_mode != RDCONSOLE_UI_MODE_LIST) - var/list/columns = list() - var/max_tier = 0 - for (var/node_ in stored_research.tiers) - var/datum/techweb_node/node = node_ - var/tier = stored_research.tiers[node] - LAZYINITLIST(columns["[tier]"]) // String hackery to make the numbers associative - columns["[tier]"] += ui_techweb_single_node(node, minimal=(tier != 1)) - max_tier = max(max_tier, tier) - - l += "[RDSCREEN_NOBREAK]" - for(var/tier in 0 to max_tier) - l += "[RDSCREEN_NOBREAK]" - l += "
      ResearchedAvailableFuture
      [RDSCREEN_NOBREAK]" - l += columns["[tier]"] - l += "
      [RDSCREEN_NOBREAK]" - else - var/list/avail = list() //This could probably be optimized a bit later. - var/list/unavail = list() - var/list/res = list() - for(var/v in stored_research.researched_nodes) - res += stored_research.researched_nodes[v] - for(var/v in stored_research.available_nodes) - if(stored_research.researched_nodes[v]) - continue - avail += stored_research.available_nodes[v] - for(var/v in stored_research.visible_nodes) - if(stored_research.available_nodes[v]) - continue - unavail += stored_research.visible_nodes[v] - l += "

      Technology Nodes:

      [RDSCREEN_NOBREAK]" - l += "

      Available for Research:

      " - for(var/datum/techweb_node/N in avail) - var/not_unlocked = (stored_research.available_nodes[N.id] && !stored_research.researched_nodes[N.id]) - var/has_points = (stored_research.can_afford(N.get_price(stored_research))) - var/research_href = not_unlocked? (has_points? "Research" : "Not Enough Points") : null - l += "[N.display_name][research_href]" - l += "

      Locked Nodes:

      " - for(var/datum/techweb_node/N in unavail) - l += "[N.display_name]" - l += "

      Researched Nodes:

      " - for(var/datum/techweb_node/N in res) - l += "[N.display_name]" - l += "
      [RDSCREEN_NOBREAK]" - return l - -/obj/machinery/computer/rdconsole/proc/machine_icon(atom/item) - return icon2html(initial(item.icon), usr, initial(item.icon_state), SOUTH) - -/obj/machinery/computer/rdconsole/proc/ui_techweb_single_node(datum/techweb_node/node, selflink=TRUE, minimal=FALSE) - var/list/l = list() - if (stored_research.hidden_nodes[node.id]) - return l - var/display_name = node.display_name - if (selflink) - display_name = "[display_name]" - l += "
      [display_name] [RDSCREEN_NOBREAK]" - if(minimal) - l += "
      [node.description]" - else - if(stored_research.researched_nodes[node.id]) - l += "Researched" - else if(stored_research.available_nodes[node.id]) - if(stored_research.can_afford(node.get_price(stored_research))) - l += "
      [node.price_display(stored_research)]" - else - l += "
      [node.price_display(stored_research)]" // gray - too expensive - else - l += "
      [node.price_display(stored_research)]" // red - missing prereqs - if(ui_mode == RDCONSOLE_UI_MODE_NORMAL) - l += "[node.description]" - for(var/i in node.designs) - var/datum/design/D = node.designs[i] - l += "[D.icon_html(usr)][RDSCREEN_NOBREAK]" - l += "
      [RDSCREEN_NOBREAK]" - return l - -/obj/machinery/computer/rdconsole/proc/ui_techweb_nodeview() - RDSCREEN_UI_SNODE_CHECK - var/list/l = list() - if(stored_research.hidden_nodes[selected_node.id]) - l += "

      ERROR: RESEARCH NODE UNKNOWN.

      " - return - - l += "[RDSCREEN_NOBREAK]" - if (length(selected_node.prerequisites)) - l += "[RDSCREEN_NOBREAK]" - l += "[RDSCREEN_NOBREAK]" - if (length(selected_node.unlocks)) - l += "[RDSCREEN_NOBREAK]" - - l += "[RDSCREEN_NOBREAK]" - if (length(selected_node.prerequisites)) - l += "[RDSCREEN_NOBREAK]" - l += "[RDSCREEN_NOBREAK]" - if (length(selected_node.unlocks)) - l += "[RDSCREEN_NOBREAK]" - - l += "
      RequiresCurrent NodeUnlocks
      [RDSCREEN_NOBREAK]" - for (var/i in selected_node.prerequisites) - l += ui_techweb_single_node(selected_node.prerequisites[i]) - l += "[RDSCREEN_NOBREAK]" - l += ui_techweb_single_node(selected_node, selflink=FALSE) - l += "[RDSCREEN_NOBREAK]" - for (var/i in selected_node.unlocks) - l += ui_techweb_single_node(selected_node.unlocks[i]) - l += "
      [RDSCREEN_NOBREAK]" - return l - -/obj/machinery/computer/rdconsole/proc/ui_techweb_designview() //Legacy code - RDSCREEN_UI_SDESIGN_CHECK - var/list/l = list() - var/datum/design/D = selected_design - l += "
      [D.icon_html(usr)][D.name]
      [RDSCREEN_NOBREAK]" - if(D.build_type) - var/lathes = list() - if(D.build_type & IMPRINTER) - lathes += "[machine_icon(/obj/machinery/rnd/production/circuit_imprinter)][RDSCREEN_NOBREAK]" - if (linked_imprinter && D.id in stored_research.researched_designs) - l += "Imprint" - if(D.build_type & PROTOLATHE) - lathes += "[machine_icon(/obj/machinery/rnd/production/protolathe)][RDSCREEN_NOBREAK]" - if (linked_lathe && D.id in stored_research.researched_designs) - l += "Construct" - if(D.build_type & AUTOLATHE) - lathes += "[machine_icon(/obj/machinery/autolathe)][RDSCREEN_NOBREAK]" - if(D.build_type & MECHFAB) - lathes += "[machine_icon(/obj/machinery/mecha_part_fabricator)][RDSCREEN_NOBREAK]" - if(D.build_type & BIOGENERATOR) - lathes += "[machine_icon(/obj/machinery/biogenerator)][RDSCREEN_NOBREAK]" - if(D.build_type & LIMBGROWER) - lathes += "[machine_icon(/obj/machinery/limbgrower)][RDSCREEN_NOBREAK]" - if(D.build_type & SMELTER) - lathes += "[machine_icon(/obj/machinery/mineral/processing_unit)][RDSCREEN_NOBREAK]" - l += "Construction types:" - l += lathes - l += "" - l += "Required materials:" - var/all_mats = D.materials + D.reagents_list - for(var/M in all_mats) - l += "* [CallMaterialName(M)] x [all_mats[M]]" - l += "Unlocked by:" - for (var/node in D.unlocked_by) - l += ui_techweb_single_node(node) - l += "[RDSCREEN_NOBREAK]
      " - return l - -//Fuck TGUI. -/obj/machinery/computer/rdconsole/proc/generate_ui() - var/list/ui = list() - ui += ui_header() - if(locked) - ui += ui_locked() - else - switch(screen) - if(RDSCREEN_MENU) - ui += ui_main_menu() - if(RDSCREEN_TECHWEB) - ui += ui_techweb() - if(RDSCREEN_TECHWEB_NODEVIEW) - ui += ui_techweb_nodeview() - if(RDSCREEN_TECHWEB_DESIGNVIEW) - ui += ui_techweb_designview() - if(RDSCREEN_DESIGNDISK) - ui += ui_designdisk() - if(RDSCREEN_DESIGNDISK_UPLOAD) - ui += ui_designdisk_upload() - if(RDSCREEN_TECHDISK) - ui += ui_techdisk() - if(RDSCREEN_DECONSTRUCT) - ui += ui_deconstruct() - if(RDSCREEN_PROTOLATHE) - ui += ui_protolathe() - if(RDSCREEN_PROTOLATHE_CATEGORY_VIEW) - ui += ui_protolathe_category_view() - if(RDSCREEN_PROTOLATHE_MATERIALS) - ui += ui_protolathe_materials() - if(RDSCREEN_PROTOLATHE_CHEMICALS) - ui += ui_protolathe_chemicals() - if(RDSCREEN_PROTOLATHE_SEARCH) - ui += ui_protolathe_search() - if(RDSCREEN_IMPRINTER) - ui += ui_circuit() - if(RDSCREEN_IMPRINTER_CATEGORY_VIEW) - ui += ui_circuit_category_view() - if(RDSCREEN_IMPRINTER_MATERIALS) - ui += ui_circuit_materials() - if(RDSCREEN_IMPRINTER_CHEMICALS) - ui += ui_circuit_chemicals() - if(RDSCREEN_IMPRINTER_SEARCH) - ui += ui_circuit_search() - if(RDSCREEN_SETTINGS) - ui += ui_settings() - if(RDSCREEN_DEVICE_LINKING) - ui += ui_device_linking() - for(var/i in 1 to length(ui)) - if(!findtextEx(ui[i], RDSCREEN_NOBREAK)) - ui[i] += "
      " - ui[i] = replacetextEx(ui[i], RDSCREEN_NOBREAK, "") - return ui.Join("") - -/obj/machinery/computer/rdconsole/Topic(raw, ls) - if(..()) - return - add_fingerprint(usr) - usr.set_machine(src) - if(ls["switch_screen"]) - back = screen - screen = text2num(ls["switch_screen"]) - if(ls["ui_mode"]) - ui_mode = text2num(ls["ui_mode"]) - if(ls["lock_console"]) - if(obj_flags & EMAGGED) - to_chat(usr, "Security protocol error: Unable to lock.") - return - if(allowed(usr)) - lock_console(usr) - else - to_chat(usr, "Unauthorized Access.") - if(ls["unlock_console"]) - if(allowed(usr)) - unlock_console(usr) - else - to_chat(usr, "Unauthorized Access.") - if(ls["find_device"]) - SyncRDevices() - say("Resynced with nearby devices.") - if(ls["back_screen"]) - back = text2num(ls["back_screen"]) - if(ls["build"]) //Causes the Protolathe to build something. - if(QDELETED(linked_lathe)) - say("No Protolathe Linked!") - return - if(linked_lathe.busy) - say("Warning: Protolathe busy!") - else - linked_lathe.user_try_print_id(ls["build"], ls["amount"]) - if(ls["imprint"]) - if(QDELETED(linked_imprinter)) - say("No Circuit Imprinter Linked!") - return - if(linked_imprinter.busy) - say("Warning: Imprinter busy!") - else - linked_imprinter.user_try_print_id(ls["imprint"]) - if(ls["category"]) - selected_category = ls["category"] - if(ls["disconnect"]) //The R&D console disconnects with a specific device. - switch(ls["disconnect"]) - if("destroy") - if(QDELETED(linked_destroy)) - say("No Destructive Analyzer Linked!") - return - linked_destroy.linked_console = null - linked_destroy = null - if("lathe") - if(QDELETED(linked_lathe)) - say("No Protolathe Linked!") - return - linked_lathe.linked_console = null - linked_lathe = null - if("imprinter") - if(QDELETED(linked_imprinter)) - say("No Circuit Imprinter Linked!") - return - linked_imprinter.linked_console = null - linked_imprinter = null - if(ls["eject_design"]) //Eject the design disk. - eject_disk("design") - screen = RDSCREEN_MENU - say("Ejecting Design Disk") - if(ls["eject_tech"]) //Eject the technology disk. - eject_disk("tech") - screen = RDSCREEN_MENU - say("Ejecting Technology Disk") - if(ls["deconstruct"]) - if(QDELETED(linked_destroy)) - say("No Destructive Analyzer Linked!") - return - if(!linked_destroy.user_try_decon_id(ls["deconstruct"], usr)) - say("Destructive analysis failed!") - //Protolathe Materials - if(ls["disposeP"]) //Causes the protolathe to dispose of a single reagent (all of it) - if(QDELETED(linked_lathe)) - say("No Protolathe Linked!") - return - linked_lathe.reagents.del_reagent(ls["disposeP"]) - if(ls["disposeallP"]) //Causes the protolathe to dispose of all it's reagents. - if(QDELETED(linked_lathe)) - say("No Protolathe Linked!") - return - linked_lathe.reagents.clear_reagents() - if(ls["ejectsheet"]) //Causes the protolathe to eject a sheet of material - if(QDELETED(linked_lathe)) - say("No Protolathe Linked!") - return - if(!linked_lathe.materials.mat_container) - say("No material storage linked to protolathe!") - return - linked_lathe.eject_sheets(ls["ejectsheet"], ls["eject_amt"]) - //Circuit Imprinter Materials - if(ls["disposeI"]) //Causes the circuit imprinter to dispose of a single reagent (all of it) - if(QDELETED(linked_imprinter)) - say("No Circuit Imprinter Linked!") - return - linked_imprinter.reagents.del_reagent(ls["disposeI"]) - if(ls["disposeallI"]) //Causes the circuit imprinter to dispose of all it's reagents. - if(QDELETED(linked_imprinter)) - say("No Circuit Imprinter Linked!") - return - linked_imprinter.reagents.clear_reagents() - if(ls["imprinter_ejectsheet"]) //Causes the imprinter to eject a sheet of material - if(QDELETED(linked_imprinter)) - say("No Circuit Imprinter Linked!") - return - if(!linked_imprinter.materials.mat_container) - say("No material storage linked to circuit imprinter!") - return - linked_imprinter.eject_sheets(ls["imprinter_ejectsheet"], ls["eject_amt"]) - if(ls["disk_slot"]) - disk_slot_selected = text2num(ls["disk_slot"]) - if(ls["research_node"]) - if(!research_control) - return //honestly should call them out for href exploiting :^) - if(!SSresearch.science_tech.available_nodes[ls["research_node"]]) - return //Nope! - research_node(ls["research_node"], usr) - if(ls["clear_tech"]) //Erase la on the technology disk. - if(QDELETED(t_disk)) - say("No Technology Disk Inserted!") - return - qdel(t_disk.stored_research) - t_disk.stored_research = new - say("Wiping technology disk.") - if(ls["copy_tech"]) //Copy some technology la from the research holder to the disk. - if(QDELETED(t_disk)) - say("No Technology Disk Inserted!") - return - stored_research.copy_research_to(t_disk.stored_research) - screen = RDSCREEN_TECHDISK - say("Downloading to technology disk.") - if(ls["clear_design"]) //Erases la on the design disk. - if(QDELETED(d_disk)) - say("No Design Disk Inserted!") - return - var/n = text2num(ls["clear_design"]) - if(!n) - for(var/i in 1 to d_disk.max_blueprints) - d_disk.blueprints[i] = null - say("Wiping design disk.") - else - var/datum/design/D = d_disk.blueprints[n] - say("Wiping design [D.name] from design disk.") - d_disk.blueprints[n] = null - if(ls["search"]) //Search for designs with name matching pattern - searchstring = ls["to_search"] - searchtype = ls["type"] - rescan_views() - if(searchtype == "proto") - screen = RDSCREEN_PROTOLATHE_SEARCH - else - screen = RDSCREEN_IMPRINTER_SEARCH - if(ls["updt_tech"]) //Uple the research holder with information from the technology disk. - if(QDELETED(t_disk)) - say("No Technology Disk Inserted!") - return - say("Uploading technology disk.") - t_disk.stored_research.copy_research_to(stored_research) - if(ls["copy_design"]) //Copy design la from the research holder to the design disk. - if(QDELETED(d_disk)) - say("No Design Disk Inserted!") - return - var/slot = text2num(ls["copy_design"]) - var/datum/design/D = stored_research.researched_designs[ls["copy_design_ID"]] - if(D) - var/autolathe_friendly = TRUE - if(D.reagents_list.len) - autolathe_friendly = FALSE - D.category -= "Imported" - else - for(var/x in D.materials) - if( !(x in list(MAT_METAL, MAT_GLASS))) - autolathe_friendly = FALSE - D.category -= "Imported" - - if(D.build_type & (AUTOLATHE|PROTOLATHE|CRAFTLATHE)) // Specifically excludes circuit imprinter and mechfab - D.build_type = autolathe_friendly ? (D.build_type | AUTOLATHE) : D.build_type - D.category |= "Imported" - d_disk.blueprints[slot] = D - screen = RDSCREEN_DESIGNDISK - if(ls["eject_item"]) //Eject the item inside the destructive analyzer. - if(QDELETED(linked_destroy)) - say("No Destructive Analyzer Linked!") - return - if(linked_destroy.busy) - to_chat(usr, "The destructive analyzer is busy at the moment.") - else if(linked_destroy.loaded_item) - linked_destroy.unload_item() - screen = RDSCREEN_MENU - if(ls["view_node"]) - selected_node = SSresearch.techweb_nodes[ls["view_node"]] - screen = RDSCREEN_TECHWEB_NODEVIEW - if(ls["view_design"]) - selected_design = SSresearch.techweb_designs[ls["view_design"]] - screen = RDSCREEN_TECHWEB_DESIGNVIEW - if(ls["updt_design"]) //Uples the research holder with design la from the design disk. - if(QDELETED(d_disk)) - say("No design disk found.") - return - var/n = text2num(ls["updt_design"]) - if(!n) - for(var/D in d_disk.blueprints) - if(D) - stored_research.add_design(D) - else - stored_research.add_design(d_disk.blueprints[n]) - - updateUsrDialog() - -/obj/machinery/computer/rdconsole/ui_interact(mob/user) - . = ..() - var/datum/browser/popup = new(user, "rndconsole", name, 900, 600) - popup.add_stylesheet("techwebs", 'html/browser/techwebs.css') - popup.set_content(generate_ui()) - popup.open() - -/obj/machinery/computer/rdconsole/proc/tdisk_uple_complete() - tdisk_uple = FALSE - updateUsrDialog() - -/obj/machinery/computer/rdconsole/proc/ddisk_uple_complete() - ddisk_uple = FALSE - updateUsrDialog() - -/obj/machinery/computer/rdconsole/proc/eject_disk(type) - if(type == "design") - d_disk.forceMove(get_turf(src)) - d_disk = null - if(type == "tech") - t_disk.forceMove(get_turf(src)) - t_disk = null - -/obj/machinery/computer/rdconsole/proc/rescan_views() - var/compare - matching_designs.Cut() - if(searchtype == "proto") - compare = PROTOLATHE - else if(searchtype == "imprint") - compare = IMPRINTER - for(var/v in stored_research.researched_designs) - var/datum/design/D = stored_research.researched_designs[v] - if(!(D.build_type & compare)) - continue - if(findtext(D.name,searchstring)) - matching_designs.Add(D) - -/obj/machinery/computer/rdconsole/proc/check_canprint(datum/design/D, buildtype) - var/amount = 50 - if(buildtype == IMPRINTER) - if(QDELETED(linked_imprinter)) - return FALSE - for(var/M in D.materials + D.reagents_list) - amount = min(amount, linked_imprinter.check_mat(D, M)) - if(amount < 1) - return FALSE - else if(buildtype == PROTOLATHE) - if(QDELETED(linked_lathe)) - return FALSE - for(var/M in D.materials + D.reagents_list) - amount = min(amount, linked_lathe.check_mat(D, M)) - if(amount < 1) - return FALSE - else - return FALSE - return amount - -/obj/machinery/computer/rdconsole/proc/lock_console(mob/user) - locked = TRUE - -/obj/machinery/computer/rdconsole/proc/unlock_console(mob/user) - locked = FALSE - -/obj/machinery/computer/rdconsole/robotics - name = "Robotics R&D Console" - req_access = null - req_access_txt = "29" - -/obj/machinery/computer/rdconsole/robotics/Initialize() - . = ..() - if(circuit) - circuit.name = "R&D Console - Robotics (Computer Board)" - circuit.build_path = /obj/machinery/computer/rdconsole/robotics - -/obj/machinery/computer/rdconsole/core - name = "Core R&D Console" - -/obj/machinery/computer/rdconsole/experiment - name = "E.X.P.E.R.I-MENTOR R&D Console" + +/* +Research and Development (R&D) Console + +This is the main work horse of the R&D system. It contains the menus/controls for the Destructive Analyzer, Protolathe, and Circuit +imprinter. + +Basic use: When it first is created, it will attempt to link up to related devices within 3 squares. It'll only link up if they +aren't already linked to another console. Any consoles it cannot link up with (either because all of a certain type are already +linked or there aren't any in range), you'll just not have access to that menu. In the settings menu, there are menu options that +allow a player to attempt to re-sync with nearby consoles. You can also force it to disconnect from a specific console. + +The only thing that requires toxins access is locking and unlocking the console on the settings menu. +Nothing else in the console has ID requirements. + +*/ +/obj/machinery/computer/rdconsole + name = "R&D Console" + desc = "A console used to interface with R&D tools." + icon_screen = "rdcomp" + icon_keyboard = "rd_key" + var/datum/techweb/stored_research //Reference to global science techweb. + var/obj/item/disk/tech_disk/t_disk //Stores the technology disk. + var/obj/item/disk/design_disk/d_disk //Stores the design disk. + circuit = /obj/item/circuitboard/computer/rdconsole + + var/obj/machinery/rnd/destructive_analyzer/linked_destroy //Linked Destructive Analyzer + var/obj/machinery/rnd/production/protolathe/linked_lathe //Linked Protolathe + var/obj/machinery/rnd/production/circuit_imprinter/linked_imprinter //Linked Circuit Imprinter + + req_access = list(ACCESS_TOX) //lA AND SETTING MANIPULATION REQUIRES SCIENTIST ACCESS. + + //UI VARS + var/screen = RDSCREEN_MENU + var/back = RDSCREEN_MENU + var/locked = FALSE + var/tdisk_uple = FALSE + var/ddisk_uple = FALSE + var/datum/techweb_node/selected_node + var/datum/design/selected_design + var/selected_category + var/list/datum/design/matching_designs + var/disk_slot_selected + var/searchstring = "" + var/searchtype = "" + var/ui_mode = RDCONSOLE_UI_MODE_NORMAL + + var/research_control = TRUE + +/obj/machinery/computer/rdconsole/production + circuit = /obj/item/circuitboard/computer/rdconsole/production + research_control = FALSE + +/proc/CallMaterialName(ID) + if (ID[1] == "$" && GLOB.materials_list[ID]) + var/datum/material/material = GLOB.materials_list[ID] + return material.name + + else if(GLOB.chemical_reagents_list[ID]) + var/datum/reagent/reagent = GLOB.chemical_reagents_list[ID] + return reagent.name + return "ERROR: Report This" + +/obj/machinery/computer/rdconsole/proc/SyncRDevices() //Makes sure it is properly sync'ed up with the devices attached to it (if any). + for(var/obj/machinery/rnd/D in oview(3,src)) + if(D.linked_console != null || D.disabled || D.panel_open) + continue + if(istype(D, /obj/machinery/rnd/destructive_analyzer)) + if(linked_destroy == null) + linked_destroy = D + D.linked_console = src + else if(istype(D, /obj/machinery/rnd/production/protolathe)) + if(linked_lathe == null) + var/obj/machinery/rnd/production/protolathe/P = D + if(!P.console_link) + continue + linked_lathe = D + D.linked_console = src + else if(istype(D, /obj/machinery/rnd/production/circuit_imprinter)) + if(linked_imprinter == null) + var/obj/machinery/rnd/production/circuit_imprinter/C = D + if(!C.console_link) + continue + linked_imprinter = D + D.linked_console = src + +/obj/machinery/computer/rdconsole/Initialize() + . = ..() + stored_research = SSresearch.science_tech + stored_research.consoles_accessing[src] = TRUE + matching_designs = list() + SyncRDevices() + +/obj/machinery/computer/rdconsole/Destroy() + if(stored_research) + stored_research.consoles_accessing -= src + if(linked_destroy) + linked_destroy.linked_console = null + linked_destroy = null + if(linked_lathe) + linked_lathe.linked_console = null + linked_lathe = null + if(linked_imprinter) + linked_imprinter.linked_console = null + linked_imprinter = null + if(t_disk) + t_disk.forceMove(get_turf(src)) + t_disk = null + if(d_disk) + d_disk.forceMove(get_turf(src)) + d_disk = null + matching_designs = null + selected_node = null + selected_design = null + return ..() + +/obj/machinery/computer/rdconsole/attackby(obj/item/D, mob/user, params) + //Loading a disk into it. + if(istype(D, /obj/item/disk)) + if(istype(D, /obj/item/disk/tech_disk)) + if(t_disk) + to_chat(user, "A technology disk is already loaded!") + return + if(!user.transferItemToLoc(D, src)) + to_chat(user, "[D] is stuck to your hand!") + return + t_disk = D + else if (istype(D, /obj/item/disk/design_disk)) + if(d_disk) + to_chat(user, "A design disk is already loaded!") + return + if(!user.transferItemToLoc(D, src)) + to_chat(user, "[D] is stuck to your hand!") + return + d_disk = D + else + to_chat(user, "Machine cannot accept disks in that format.") + return + to_chat(user, "You insert [D] into \the [src]!") + else if(!(linked_destroy && linked_destroy.busy) && !(linked_lathe && linked_lathe.busy) && !(linked_imprinter && linked_imprinter.busy)) + . = ..() + +/obj/machinery/computer/rdconsole/proc/research_node(id, mob/user) + if(!stored_research.available_nodes[id] || stored_research.researched_nodes[id]) + say("Node unlock failed: Either already researched or not available!") + return FALSE + var/datum/techweb_node/TN = SSresearch.techweb_nodes[id] + if(!istype(TN)) + say("Node unlock failed: Unknown error.") + return FALSE + var/list/price = TN.get_price(stored_research) + if(stored_research.can_afford(price)) + investigate_log("[key_name(user)] researched [id]([json_encode(price)]) on techweb id [stored_research.id].", INVESTIGATE_RESEARCH) + if(stored_research == SSresearch.science_tech) + SSblackbox.record_feedback("associative", "science_techweb_unlock", 1, list("id" = "[id]", "name" = TN.display_name, "price" = "[json_encode(price)]", "time" = SQLtime())) + if(stored_research.research_node(SSresearch.techweb_nodes[id])) + say("Successfully researched [TN.display_name].") + var/logname = "Unknown" + if(isAI(user)) + logname = "AI: [user.name]" + else if(iscyborg(user)) + logname = "Cyborg: [user.name]" + else if(isliving(user)) + var/mob/living/L = user + logname = L.get_visible_name() + stored_research.research_logs += "[logname] researched node id [id] with cost [json_encode(price)] at [COORD(src)]." + return TRUE + else + say("Failed to research node: Internal database error!") + return FALSE + say("Not enough research points...") + return FALSE + +/obj/machinery/computer/rdconsole/on_deconstruction() + if(linked_destroy) + linked_destroy.linked_console = null + linked_destroy = null + if(linked_lathe) + linked_lathe.linked_console = null + linked_lathe = null + if(linked_imprinter) + linked_imprinter.linked_console = null + linked_imprinter = null + ..() + +/obj/machinery/computer/rdconsole/emag_act(mob/user) + if(!(obj_flags & EMAGGED)) + to_chat(user, "You disable the security protocols[locked? " and unlock the console":""].") + playsound(src, "sparks", 75, 1) + obj_flags |= EMAGGED + locked = FALSE + return ..() + +/obj/machinery/computer/rdconsole/multitool_act(mob/user, obj/item/multitool/I) + var/lathe = linked_lathe && linked_lathe.multitool_act(user, I) + var/print = linked_imprinter && linked_imprinter.multitool_act(user, I) + return lathe || print + +/obj/machinery/computer/rdconsole/proc/list_categories(list/categories, menu_num as num) + if(!categories) + return + + var/line_length = 1 + var/list/l = "" + + for(var/C in categories) + if(line_length > 2) + l += "" + line_length = 1 + + l += "" + line_length++ + + l += "
      [C]
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_header() + var/list/l = list() + var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/research_designs) + l += "[sheet.css_tag()][RDSCREEN_NOBREAK]" + l += "
      [stored_research.organization] Research and Development Network" + l += "Available points:
      [techweb_point_display_rdconsole(stored_research.research_points, stored_research.last_bitcoins)]" + l += "Security protocols: [obj_flags & EMAGGED ? "Disabled" : "Enabled"]" + l += "Main Menu | Back
      [RDSCREEN_NOBREAK]" + l += "[ui_mode == 1? "Normal View" : "Normal View"] | [ui_mode == 2? "Expert View" : "Expert View"] | [ui_mode == 3? "List View" : "List View"]" + return l + +/obj/machinery/computer/rdconsole/proc/ui_main_menu() + var/list/l = list() + if(research_control) + l += "

      Technology" + if(d_disk) + l += "
      Design Disk" + if(t_disk) + l += "
      Tech Disk" + if(linked_destroy) + l += "
      Destructive Analyzer" + if(linked_lathe) + l += "
      Protolathe" + if(linked_imprinter) + l += "
      Circuit Imprinter" + l += "
      Settings

      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_locked() + return list("

      SYSTEM LOCKED


      ") + +/obj/machinery/computer/rdconsole/proc/ui_settings() + var/list/l = list() + l += "

      R&D Console Settings:

      " + l += "Device Linkage Menu" + l += "Lock Console
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_device_linking() + var/list/l = list() + l += "Settings Menu
      " + l += "

      R&D Console Device Linkage Menu:

      " + l += "Re-sync with Nearby Devices" + l += "

      Linked Devices:

      " + l += linked_destroy? "* Destructive Analyzer Disconnect" : "* No Destructive Analyzer Linked" + l += linked_lathe? "* Protolathe Disconnect" : "* No Protolathe Linked" + l += linked_imprinter? "* Circuit Imprinter Disconnect" : "* No Circuit Imprinter Linked" + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_protolathe_header() + var/list/l = list() + l += "
      Protolathe Menu" + if(linked_lathe.materials.mat_container) + l += "Material Amount: [linked_lathe.materials.format_amount()]" + else + l += "No material storage connected, please contact the quartermaster." + l += "Chemical volume: [linked_lathe.reagents.total_volume] / [linked_lathe.reagents.maximum_volume]
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_protolathe_category_view() //Legacy code + RDSCREEN_UI_LATHE_CHECK + var/list/l = list() + l += ui_protolathe_header() + l += "

      Browsing [selected_category]:

      " + for(var/v in stored_research.researched_designs) + var/datum/design/D = stored_research.researched_designs[v] + if(!(selected_category in D.category)|| !(D.build_type & PROTOLATHE)) + continue + if(!(isnull(linked_lathe.allowed_department_flags) || (D.departmental_flags & linked_lathe.allowed_department_flags))) + continue + var/temp_material + var/c = 50 + var/coeff = linked_lathe.efficiency_coeff + if(!linked_lathe.efficient_with(D.build_path)) + coeff = 1 + + var/all_materials = D.materials + D.reagents_list + for(var/M in all_materials) + var/t = linked_lathe.check_mat(D, M) + temp_material += " | " + if (t < 1) + temp_material += "[all_materials[M]/coeff] [CallMaterialName(M)]" + else + temp_material += " [all_materials[M]/coeff] [CallMaterialName(M)]" + c = min(c,t) + + if (c >= 1) + l += "[D.name][RDSCREEN_NOBREAK]" + if(c >= 5) + l += "x5[RDSCREEN_NOBREAK]" + if(c >= 10) + l += "x10[RDSCREEN_NOBREAK]" + l += "[temp_material][RDSCREEN_NOBREAK]" + else + l += "[D.name][temp_material][RDSCREEN_NOBREAK]" + l += "" + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_protolathe() //Legacy code + RDSCREEN_UI_LATHE_CHECK + var/list/l = list() + l += ui_protolathe_header() + + l += "
      \ + \ + \ + \ + \ + \ +

      " + + l += list_categories(linked_lathe.categories, RDSCREEN_PROTOLATHE_CATEGORY_VIEW) + + return l + +/obj/machinery/computer/rdconsole/proc/ui_protolathe_search() //Legacy code + RDSCREEN_UI_LATHE_CHECK + var/list/l = list() + l += ui_protolathe_header() + for(var/datum/design/D in matching_designs) + if(!(isnull(linked_lathe.allowed_department_flags) || (D.departmental_flags & linked_lathe.allowed_department_flags))) + continue + var/temp_material + var/c = 50 + var/all_materials = D.materials + D.reagents_list + var/coeff = linked_lathe.efficiency_coeff + if(!linked_lathe.efficient_with(D.build_path)) + coeff = 1 + for(var/M in all_materials) + var/t = linked_lathe.check_mat(D, M) + temp_material += " | " + if (t < 1) + temp_material += "[all_materials[M]/coeff] [CallMaterialName(M)]" + else + temp_material += " [all_materials[M]/coeff] [CallMaterialName(M)]" + c = min(c,t) + + if (c >= 1) + l += "[D.name][RDSCREEN_NOBREAK]" + if(c >= 5) + l += "x5[RDSCREEN_NOBREAK]" + if(c >= 10) + l += "x10[RDSCREEN_NOBREAK]" + l += "[temp_material][RDSCREEN_NOBREAK]" + else + l += "[D.name][temp_material][RDSCREEN_NOBREAK]" + l += "" + l += "" + return l + +/obj/machinery/computer/rdconsole/proc/ui_protolathe_materials() //Legacy code + RDSCREEN_UI_LATHE_CHECK + var/datum/component/material_container/mat_container = linked_lathe.materials.mat_container + if (!mat_container) + screen = RDSCREEN_PROTOLATHE + return ui_protolathe() + var/list/l = list() + l += ui_protolathe_header() + l += "

      Material Storage:

      " + for(var/mat_id in mat_container.materials) + var/datum/material/M = mat_container.materials[mat_id] + l += "* [M.amount] of [M.name]: " + if(M.amount >= MINERAL_MATERIAL_AMOUNT) l += "Eject [RDSCREEN_NOBREAK]" + if(M.amount >= MINERAL_MATERIAL_AMOUNT*5) l += "5x [RDSCREEN_NOBREAK]" + if(M.amount >= MINERAL_MATERIAL_AMOUNT) l += "All[RDSCREEN_NOBREAK]" + l += "" + l += "
      [RDSCREEN_NOBREAK]" + return l + +/obj/machinery/computer/rdconsole/proc/ui_protolathe_chemicals() //Legacy code + RDSCREEN_UI_LATHE_CHECK + var/list/l = list() + l += ui_protolathe_header() + l += "
      Disposal All Chemicals in Storage" + l += "

      Chemical Storage:

      " + for(var/datum/reagent/R in linked_lathe.reagents.reagent_list) + l += "[R.name]: [R.volume]" + l += "Purge" + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_circuit_header() //Legacy Code + var/list/l = list() + l += "
      Circuit Imprinter Menu" + if (linked_imprinter.materials.mat_container) + l += "Material Amount: [linked_imprinter.materials.format_amount()]" + else + l += "No material storage connected, please contact the quartermaster." + l += "Chemical volume: [linked_imprinter.reagents.total_volume] / [linked_imprinter.reagents.maximum_volume]
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_circuit() //Legacy code + RDSCREEN_UI_IMPRINTER_CHECK + var/list/l = list() + l += ui_circuit_header() + l += "

      Circuit Imprinter Menu:

      " + + l += "
      \ + \ + \ + \ + \ + \ +

      " + + l += list_categories(linked_imprinter.categories, RDSCREEN_IMPRINTER_CATEGORY_VIEW) + return l + +/obj/machinery/computer/rdconsole/proc/ui_circuit_category_view() //Legacy code + RDSCREEN_UI_IMPRINTER_CHECK + var/list/l = list() + l += ui_circuit_header() + l += "

      Browsing [selected_category]:

      " + + for(var/v in stored_research.researched_designs) + var/datum/design/D = stored_research.researched_designs[v] + if(!(selected_category in D.category) || !(D.build_type & IMPRINTER)) + continue + if(!(isnull(linked_imprinter.allowed_department_flags) || (D.departmental_flags & linked_imprinter.allowed_department_flags))) + continue + var/temp_materials + var/check_materials = TRUE + + var/all_materials = D.materials + D.reagents_list + var/coeff = linked_imprinter.efficiency_coeff + if(!linked_imprinter.efficient_with(D.build_path)) + coeff = 1 + + for(var/M in all_materials) + temp_materials += " | " + if (!linked_imprinter.check_mat(D, M)) + check_materials = FALSE + temp_materials += " [all_materials[M]/coeff] [CallMaterialName(M)]" + else + temp_materials += " [all_materials[M]/coeff] [CallMaterialName(M)]" + if (check_materials) + l += "[D.name][temp_materials]" + else + l += "[D.name][temp_materials]" + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_circuit_search() //Legacy code + RDSCREEN_UI_IMPRINTER_CHECK + var/list/l = list() + l += ui_circuit_header() + l += "

      Search results:

      " + + for(var/datum/design/D in matching_designs) + if(!(isnull(linked_imprinter.allowed_department_flags) || (D.departmental_flags & linked_imprinter.allowed_department_flags))) + continue + var/temp_materials + var/check_materials = TRUE + var/all_materials = D.materials + D.reagents_list + var/coeff = linked_imprinter.efficiency_coeff + if(!linked_imprinter.efficient_with(D.build_path)) + coeff = 1 + for(var/M in all_materials) + temp_materials += " | " + if (!linked_imprinter.check_mat(D, M)) + check_materials = FALSE + temp_materials += " [all_materials[M]/coeff] [CallMaterialName(M)]" + else + temp_materials += " [all_materials[M]/coeff] [CallMaterialName(M)]" + if (check_materials) + l += "[D.name][temp_materials]" + else + l += "[D.name][temp_materials]" + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_circuit_chemicals() //legacy code + RDSCREEN_UI_IMPRINTER_CHECK + var/list/l = list() + l += ui_circuit_header() + l += "Disposal All Chemicals in Storage
      " + l += "

      Chemical Storage:

      " + for(var/datum/reagent/R in linked_imprinter.reagents.reagent_list) + l += "[R.name]: [R.volume]" + l += "Purge" + return l + +/obj/machinery/computer/rdconsole/proc/ui_circuit_materials() //Legacy code! + RDSCREEN_UI_IMPRINTER_CHECK + var/datum/component/material_container/mat_container = linked_imprinter.materials.mat_container + if (!mat_container) + screen = RDSCREEN_IMPRINTER + return ui_circuit() + var/list/l = list() + l += ui_circuit_header() + l += "

      Material Storage:

      " + for(var/mat_id in mat_container.materials) + var/datum/material/M = mat_container.materials[mat_id] + l += "* [M.amount] of [M.name]: " + if(M.amount >= MINERAL_MATERIAL_AMOUNT) l += "Eject [RDSCREEN_NOBREAK]" + if(M.amount >= MINERAL_MATERIAL_AMOUNT*5) l += "5x [RDSCREEN_NOBREAK]" + if(M.amount >= MINERAL_MATERIAL_AMOUNT) l += "All[RDSCREEN_NOBREAK]
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_techdisk() //Legacy code + RDSCREEN_UI_TDISK_CHECK + var/list/l = list() + l += "
      Disk Operations: Clear Disk" + l += "Eject Disk" + l += "Upload All" + l += "Load Technology to Disk
      " + l += "

      Stored Technology Nodes:

      " + for(var/i in t_disk.stored_research.researched_nodes) + var/datum/techweb_node/N = t_disk.stored_research.researched_nodes[i] + l += "[N.display_name]" + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_designdisk() //Legacy code + RDSCREEN_UI_DDISK_CHECK + var/list/l = list() + l += "Disk Operations: Clear DiskUpload AllEject Disk" + for(var/i in 1 to d_disk.max_blueprints) + l += "
      " + if(d_disk.blueprints[i]) + var/datum/design/D = d_disk.blueprints[i] + l += "[D.name]" + l += "Operations: Upload to database Clear Slot" + else + l += "Empty Slot Operations: Load Design to Slot" + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_designdisk_upload() //Legacy code + RDSCREEN_UI_DDISK_CHECK + var/list/l = list() + l += "Return to Disk Operations
      " + l += "

      Load Design to Disk:

      " + for(var/v in stored_research.researched_designs) + var/datum/design/D = stored_research.researched_designs[v] + l += "[D.name] " + l += "Copy to Disk" + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_deconstruct() //Legacy code + RDSCREEN_UI_DECONSTRUCT_CHECK + var/list/l = list() + if(!linked_destroy.loaded_item) + l += "
      No item loaded. Standing-by...
      " + else + l += "
      [RDSCREEN_NOBREAK]" + l += "
      [icon2html(linked_destroy.loaded_item, usr)][linked_destroy.loaded_item.name] Eject
      [RDSCREEN_NOBREAK]" + l += "Select a node to boost by deconstructing this item. This item can boost:" + + var/anything = FALSE + var/list/boostable_nodes = techweb_item_boost_check(linked_destroy.loaded_item) + for(var/id in boostable_nodes) + anything = TRUE + var/list/worth = boostable_nodes[id] + var/datum/techweb_node/N = get_techweb_node_by_id(id) + + l += "
      [RDSCREEN_NOBREAK]" + if (stored_research.researched_nodes[N.id]) // already researched + l += "[N.display_name]" + l += "This node has already been researched." + else if(!length(worth)) // reveal only + if (stored_research.hidden_nodes[N.id]) + l += "[N.display_name]" + l += "This node will be revealed." + else + l += "[N.display_name]" + l += "This node has already been revealed." + else // boost by the difference + var/list/differences = list() + var/list/already_boosted = stored_research.boosted_nodes[N.id] + for(var/i in worth) + var/already_boosted_amount = already_boosted? stored_research.boosted_nodes[N.id][i] : 0 + var/amt = min(worth[i], N.research_costs[i]) - already_boosted_amount + if(amt > 0) + differences[i] = amt + if (length(differences)) + l += "[N.display_name]" + l += "This node will be boosted with the following:
      [techweb_point_display_generic(differences)]" + else + l += "[N.display_name]" + l += "This node has already been boosted." + l += "
      [RDSCREEN_NOBREAK]" + + // point deconstruction and material reclamation use the same ID to prevent accidentally missing the points + var/list/point_values = techweb_item_point_check(linked_destroy.loaded_item) + if(point_values) + anything = TRUE + l += "
      [RDSCREEN_NOBREAK]" + if (stored_research.deconstructed_items[linked_destroy.loaded_item.type]) + l += "Point Deconstruction" + l += "This item's points have already been claimed." + else + l += "Point Deconstruction" + l += "This item is worth:
      [techweb_point_display_generic(point_values)]!" + l += "
      [RDSCREEN_NOBREAK]" + + if(!(linked_destroy.loaded_item.resistance_flags & INDESTRUCTIBLE)) + var/list/materials = linked_destroy.loaded_item.materials + l += "
      [materials.len? "Material Reclamation" : "Destroy Item"]" + for (var/M in materials) + l += "* [CallMaterialName(M)] x [materials[M]]" + l += "
      [RDSCREEN_NOBREAK]" + anything = TRUE + + if (!anything) + l += "Nothing!" + + l += "
      " + return l + +/obj/machinery/computer/rdconsole/proc/ui_techweb() + var/list/l = list() + if(islist(stored_research.research_logs) && stored_research.research_logs.len) + l += "Last action: [stored_research.research_logs[stored_research.research_logs.len]]" + if(ui_mode != RDCONSOLE_UI_MODE_LIST) + var/list/columns = list() + var/max_tier = 0 + for (var/node_ in stored_research.tiers) + var/datum/techweb_node/node = node_ + var/tier = stored_research.tiers[node] + LAZYINITLIST(columns["[tier]"]) // String hackery to make the numbers associative + columns["[tier]"] += ui_techweb_single_node(node, minimal=(tier != 1)) + max_tier = max(max_tier, tier) + + l += "[RDSCREEN_NOBREAK]" + for(var/tier in 0 to max_tier) + l += "[RDSCREEN_NOBREAK]" + l += "
      ResearchedAvailableFuture
      [RDSCREEN_NOBREAK]" + l += columns["[tier]"] + l += "
      [RDSCREEN_NOBREAK]" + else + var/list/avail = list() //This could probably be optimized a bit later. + var/list/unavail = list() + var/list/res = list() + for(var/v in stored_research.researched_nodes) + res += stored_research.researched_nodes[v] + for(var/v in stored_research.available_nodes) + if(stored_research.researched_nodes[v]) + continue + avail += stored_research.available_nodes[v] + for(var/v in stored_research.visible_nodes) + if(stored_research.available_nodes[v]) + continue + unavail += stored_research.visible_nodes[v] + l += "

      Technology Nodes:

      [RDSCREEN_NOBREAK]" + l += "

      Available for Research:

      " + for(var/datum/techweb_node/N in avail) + var/not_unlocked = (stored_research.available_nodes[N.id] && !stored_research.researched_nodes[N.id]) + var/has_points = (stored_research.can_afford(N.get_price(stored_research))) + var/research_href = not_unlocked? (has_points? "Research" : "Not Enough Points") : null + l += "[N.display_name][research_href]" + l += "

      Locked Nodes:

      " + for(var/datum/techweb_node/N in unavail) + l += "[N.display_name]" + l += "

      Researched Nodes:

      " + for(var/datum/techweb_node/N in res) + l += "[N.display_name]" + l += "
      [RDSCREEN_NOBREAK]" + return l + +/obj/machinery/computer/rdconsole/proc/machine_icon(atom/item) + return icon2html(initial(item.icon), usr, initial(item.icon_state), SOUTH) + +/obj/machinery/computer/rdconsole/proc/ui_techweb_single_node(datum/techweb_node/node, selflink=TRUE, minimal=FALSE) + var/list/l = list() + if (stored_research.hidden_nodes[node.id]) + return l + var/display_name = node.display_name + if (selflink) + display_name = "[display_name]" + l += "
      [display_name] [RDSCREEN_NOBREAK]" + if(minimal) + l += "
      [node.description]" + else + if(stored_research.researched_nodes[node.id]) + l += "Researched" + else if(stored_research.available_nodes[node.id]) + if(stored_research.can_afford(node.get_price(stored_research))) + l += "
      [node.price_display(stored_research)]" + else + l += "
      [node.price_display(stored_research)]" // gray - too expensive + else + l += "
      [node.price_display(stored_research)]" // red - missing prereqs + if(ui_mode == RDCONSOLE_UI_MODE_NORMAL) + l += "[node.description]" + for(var/i in node.designs) + var/datum/design/D = node.designs[i] + l += "[D.icon_html(usr)][RDSCREEN_NOBREAK]" + l += "
      [RDSCREEN_NOBREAK]" + return l + +/obj/machinery/computer/rdconsole/proc/ui_techweb_nodeview() + RDSCREEN_UI_SNODE_CHECK + var/list/l = list() + if(stored_research.hidden_nodes[selected_node.id]) + l += "

      ERROR: RESEARCH NODE UNKNOWN.

      " + return + + l += "[RDSCREEN_NOBREAK]" + if (length(selected_node.prerequisites)) + l += "[RDSCREEN_NOBREAK]" + l += "[RDSCREEN_NOBREAK]" + if (length(selected_node.unlocks)) + l += "[RDSCREEN_NOBREAK]" + + l += "[RDSCREEN_NOBREAK]" + if (length(selected_node.prerequisites)) + l += "[RDSCREEN_NOBREAK]" + l += "[RDSCREEN_NOBREAK]" + if (length(selected_node.unlocks)) + l += "[RDSCREEN_NOBREAK]" + + l += "
      RequiresCurrent NodeUnlocks
      [RDSCREEN_NOBREAK]" + for (var/i in selected_node.prerequisites) + l += ui_techweb_single_node(selected_node.prerequisites[i]) + l += "[RDSCREEN_NOBREAK]" + l += ui_techweb_single_node(selected_node, selflink=FALSE) + l += "[RDSCREEN_NOBREAK]" + for (var/i in selected_node.unlocks) + l += ui_techweb_single_node(selected_node.unlocks[i]) + l += "
      [RDSCREEN_NOBREAK]" + return l + +/obj/machinery/computer/rdconsole/proc/ui_techweb_designview() //Legacy code + RDSCREEN_UI_SDESIGN_CHECK + var/list/l = list() + var/datum/design/D = selected_design + l += "
      [D.icon_html(usr)][D.name]
      [RDSCREEN_NOBREAK]" + if(D.build_type) + var/lathes = list() + if(D.build_type & IMPRINTER) + lathes += "[machine_icon(/obj/machinery/rnd/production/circuit_imprinter)][RDSCREEN_NOBREAK]" + if (linked_imprinter && D.id in stored_research.researched_designs) + l += "Imprint" + if(D.build_type & PROTOLATHE) + lathes += "[machine_icon(/obj/machinery/rnd/production/protolathe)][RDSCREEN_NOBREAK]" + if (linked_lathe && D.id in stored_research.researched_designs) + l += "Construct" + if(D.build_type & AUTOLATHE) + lathes += "[machine_icon(/obj/machinery/autolathe)][RDSCREEN_NOBREAK]" + if(D.build_type & MECHFAB) + lathes += "[machine_icon(/obj/machinery/mecha_part_fabricator)][RDSCREEN_NOBREAK]" + if(D.build_type & BIOGENERATOR) + lathes += "[machine_icon(/obj/machinery/biogenerator)][RDSCREEN_NOBREAK]" + if(D.build_type & LIMBGROWER) + lathes += "[machine_icon(/obj/machinery/limbgrower)][RDSCREEN_NOBREAK]" + if(D.build_type & SMELTER) + lathes += "[machine_icon(/obj/machinery/mineral/processing_unit)][RDSCREEN_NOBREAK]" + l += "Construction types:" + l += lathes + l += "" + l += "Required materials:" + var/all_mats = D.materials + D.reagents_list + for(var/M in all_mats) + l += "* [CallMaterialName(M)] x [all_mats[M]]" + l += "Unlocked by:" + for (var/node in D.unlocked_by) + l += ui_techweb_single_node(node) + l += "[RDSCREEN_NOBREAK]
      " + return l + +//Fuck TGUI. +/obj/machinery/computer/rdconsole/proc/generate_ui() + var/list/ui = list() + ui += ui_header() + if(locked) + ui += ui_locked() + else + switch(screen) + if(RDSCREEN_MENU) + ui += ui_main_menu() + if(RDSCREEN_TECHWEB) + ui += ui_techweb() + if(RDSCREEN_TECHWEB_NODEVIEW) + ui += ui_techweb_nodeview() + if(RDSCREEN_TECHWEB_DESIGNVIEW) + ui += ui_techweb_designview() + if(RDSCREEN_DESIGNDISK) + ui += ui_designdisk() + if(RDSCREEN_DESIGNDISK_UPLOAD) + ui += ui_designdisk_upload() + if(RDSCREEN_TECHDISK) + ui += ui_techdisk() + if(RDSCREEN_DECONSTRUCT) + ui += ui_deconstruct() + if(RDSCREEN_PROTOLATHE) + ui += ui_protolathe() + if(RDSCREEN_PROTOLATHE_CATEGORY_VIEW) + ui += ui_protolathe_category_view() + if(RDSCREEN_PROTOLATHE_MATERIALS) + ui += ui_protolathe_materials() + if(RDSCREEN_PROTOLATHE_CHEMICALS) + ui += ui_protolathe_chemicals() + if(RDSCREEN_PROTOLATHE_SEARCH) + ui += ui_protolathe_search() + if(RDSCREEN_IMPRINTER) + ui += ui_circuit() + if(RDSCREEN_IMPRINTER_CATEGORY_VIEW) + ui += ui_circuit_category_view() + if(RDSCREEN_IMPRINTER_MATERIALS) + ui += ui_circuit_materials() + if(RDSCREEN_IMPRINTER_CHEMICALS) + ui += ui_circuit_chemicals() + if(RDSCREEN_IMPRINTER_SEARCH) + ui += ui_circuit_search() + if(RDSCREEN_SETTINGS) + ui += ui_settings() + if(RDSCREEN_DEVICE_LINKING) + ui += ui_device_linking() + for(var/i in 1 to length(ui)) + if(!findtextEx(ui[i], RDSCREEN_NOBREAK)) + ui[i] += "
      " + ui[i] = replacetextEx(ui[i], RDSCREEN_NOBREAK, "") + return ui.Join("") + +/obj/machinery/computer/rdconsole/Topic(raw, ls) + if(..()) + return + add_fingerprint(usr) + usr.set_machine(src) + if(ls["switch_screen"]) + back = screen + screen = text2num(ls["switch_screen"]) + if(ls["ui_mode"]) + ui_mode = text2num(ls["ui_mode"]) + if(ls["lock_console"]) + if(obj_flags & EMAGGED) + to_chat(usr, "Security protocol error: Unable to lock.") + return + if(allowed(usr)) + lock_console(usr) + else + to_chat(usr, "Unauthorized Access.") + if(ls["unlock_console"]) + if(allowed(usr)) + unlock_console(usr) + else + to_chat(usr, "Unauthorized Access.") + if(ls["find_device"]) + SyncRDevices() + say("Resynced with nearby devices.") + if(ls["back_screen"]) + back = text2num(ls["back_screen"]) + if(ls["build"]) //Causes the Protolathe to build something. + if(QDELETED(linked_lathe)) + say("No Protolathe Linked!") + return + if(linked_lathe.busy) + say("Warning: Protolathe busy!") + else + linked_lathe.user_try_print_id(ls["build"], ls["amount"]) + if(ls["imprint"]) + if(QDELETED(linked_imprinter)) + say("No Circuit Imprinter Linked!") + return + if(linked_imprinter.busy) + say("Warning: Imprinter busy!") + else + linked_imprinter.user_try_print_id(ls["imprint"]) + if(ls["category"]) + selected_category = ls["category"] + if(ls["disconnect"]) //The R&D console disconnects with a specific device. + switch(ls["disconnect"]) + if("destroy") + if(QDELETED(linked_destroy)) + say("No Destructive Analyzer Linked!") + return + linked_destroy.linked_console = null + linked_destroy = null + if("lathe") + if(QDELETED(linked_lathe)) + say("No Protolathe Linked!") + return + linked_lathe.linked_console = null + linked_lathe = null + if("imprinter") + if(QDELETED(linked_imprinter)) + say("No Circuit Imprinter Linked!") + return + linked_imprinter.linked_console = null + linked_imprinter = null + if(ls["eject_design"]) //Eject the design disk. + eject_disk("design") + screen = RDSCREEN_MENU + say("Ejecting Design Disk") + if(ls["eject_tech"]) //Eject the technology disk. + eject_disk("tech") + screen = RDSCREEN_MENU + say("Ejecting Technology Disk") + if(ls["deconstruct"]) + if(QDELETED(linked_destroy)) + say("No Destructive Analyzer Linked!") + return + if(!linked_destroy.user_try_decon_id(ls["deconstruct"], usr)) + say("Destructive analysis failed!") + //Protolathe Materials + if(ls["disposeP"]) //Causes the protolathe to dispose of a single reagent (all of it) + if(QDELETED(linked_lathe)) + say("No Protolathe Linked!") + return + linked_lathe.reagents.del_reagent(ls["disposeP"]) + if(ls["disposeallP"]) //Causes the protolathe to dispose of all it's reagents. + if(QDELETED(linked_lathe)) + say("No Protolathe Linked!") + return + linked_lathe.reagents.clear_reagents() + if(ls["ejectsheet"]) //Causes the protolathe to eject a sheet of material + if(QDELETED(linked_lathe)) + say("No Protolathe Linked!") + return + if(!linked_lathe.materials.mat_container) + say("No material storage linked to protolathe!") + return + linked_lathe.eject_sheets(ls["ejectsheet"], ls["eject_amt"]) + //Circuit Imprinter Materials + if(ls["disposeI"]) //Causes the circuit imprinter to dispose of a single reagent (all of it) + if(QDELETED(linked_imprinter)) + say("No Circuit Imprinter Linked!") + return + linked_imprinter.reagents.del_reagent(ls["disposeI"]) + if(ls["disposeallI"]) //Causes the circuit imprinter to dispose of all it's reagents. + if(QDELETED(linked_imprinter)) + say("No Circuit Imprinter Linked!") + return + linked_imprinter.reagents.clear_reagents() + if(ls["imprinter_ejectsheet"]) //Causes the imprinter to eject a sheet of material + if(QDELETED(linked_imprinter)) + say("No Circuit Imprinter Linked!") + return + if(!linked_imprinter.materials.mat_container) + say("No material storage linked to circuit imprinter!") + return + linked_imprinter.eject_sheets(ls["imprinter_ejectsheet"], ls["eject_amt"]) + if(ls["disk_slot"]) + disk_slot_selected = text2num(ls["disk_slot"]) + if(ls["research_node"]) + if(!research_control) + return //honestly should call them out for href exploiting :^) + if(!SSresearch.science_tech.available_nodes[ls["research_node"]]) + return //Nope! + research_node(ls["research_node"], usr) + if(ls["clear_tech"]) //Erase la on the technology disk. + if(QDELETED(t_disk)) + say("No Technology Disk Inserted!") + return + qdel(t_disk.stored_research) + t_disk.stored_research = new + say("Wiping technology disk.") + if(ls["copy_tech"]) //Copy some technology la from the research holder to the disk. + if(QDELETED(t_disk)) + say("No Technology Disk Inserted!") + return + stored_research.copy_research_to(t_disk.stored_research) + screen = RDSCREEN_TECHDISK + say("Downloading to technology disk.") + if(ls["clear_design"]) //Erases la on the design disk. + if(QDELETED(d_disk)) + say("No Design Disk Inserted!") + return + var/n = text2num(ls["clear_design"]) + if(!n) + for(var/i in 1 to d_disk.max_blueprints) + d_disk.blueprints[i] = null + say("Wiping design disk.") + else + var/datum/design/D = d_disk.blueprints[n] + say("Wiping design [D.name] from design disk.") + d_disk.blueprints[n] = null + if(ls["search"]) //Search for designs with name matching pattern + searchstring = ls["to_search"] + searchtype = ls["type"] + rescan_views() + if(searchtype == "proto") + screen = RDSCREEN_PROTOLATHE_SEARCH + else + screen = RDSCREEN_IMPRINTER_SEARCH + if(ls["updt_tech"]) //Uple the research holder with information from the technology disk. + if(QDELETED(t_disk)) + say("No Technology Disk Inserted!") + return + say("Uploading technology disk.") + t_disk.stored_research.copy_research_to(stored_research) + if(ls["copy_design"]) //Copy design la from the research holder to the design disk. + if(QDELETED(d_disk)) + say("No Design Disk Inserted!") + return + var/slot = text2num(ls["copy_design"]) + var/datum/design/D = stored_research.researched_designs[ls["copy_design_ID"]] + if(D) + var/autolathe_friendly = TRUE + if(D.reagents_list.len) + autolathe_friendly = FALSE + D.category -= "Imported" + else + for(var/x in D.materials) + if( !(x in list(MAT_METAL, MAT_GLASS))) + autolathe_friendly = FALSE + D.category -= "Imported" + + if(D.build_type & (AUTOLATHE|PROTOLATHE|CRAFTLATHE)) // Specifically excludes circuit imprinter and mechfab + D.build_type = autolathe_friendly ? (D.build_type | AUTOLATHE) : D.build_type + D.category |= "Imported" + d_disk.blueprints[slot] = D + screen = RDSCREEN_DESIGNDISK + if(ls["eject_item"]) //Eject the item inside the destructive analyzer. + if(QDELETED(linked_destroy)) + say("No Destructive Analyzer Linked!") + return + if(linked_destroy.busy) + to_chat(usr, "The destructive analyzer is busy at the moment.") + else if(linked_destroy.loaded_item) + linked_destroy.unload_item() + screen = RDSCREEN_MENU + if(ls["view_node"]) + selected_node = SSresearch.techweb_nodes[ls["view_node"]] + screen = RDSCREEN_TECHWEB_NODEVIEW + if(ls["view_design"]) + selected_design = SSresearch.techweb_designs[ls["view_design"]] + screen = RDSCREEN_TECHWEB_DESIGNVIEW + if(ls["updt_design"]) //Uples the research holder with design la from the design disk. + if(QDELETED(d_disk)) + say("No design disk found.") + return + var/n = text2num(ls["updt_design"]) + if(!n) + for(var/D in d_disk.blueprints) + if(D) + stored_research.add_design(D) + else + stored_research.add_design(d_disk.blueprints[n]) + + updateUsrDialog() + +/obj/machinery/computer/rdconsole/ui_interact(mob/user) + . = ..() + var/datum/browser/popup = new(user, "rndconsole", name, 900, 600) + popup.add_stylesheet("techwebs", 'html/browser/techwebs.css') + popup.set_content(generate_ui()) + popup.open() + +/obj/machinery/computer/rdconsole/proc/tdisk_uple_complete() + tdisk_uple = FALSE + updateUsrDialog() + +/obj/machinery/computer/rdconsole/proc/ddisk_uple_complete() + ddisk_uple = FALSE + updateUsrDialog() + +/obj/machinery/computer/rdconsole/proc/eject_disk(type) + if(type == "design") + d_disk.forceMove(get_turf(src)) + d_disk = null + if(type == "tech") + t_disk.forceMove(get_turf(src)) + t_disk = null + +/obj/machinery/computer/rdconsole/proc/rescan_views() + var/compare + matching_designs.Cut() + if(searchtype == "proto") + compare = PROTOLATHE + else if(searchtype == "imprint") + compare = IMPRINTER + for(var/v in stored_research.researched_designs) + var/datum/design/D = stored_research.researched_designs[v] + if(!(D.build_type & compare)) + continue + if(findtext(D.name,searchstring)) + matching_designs.Add(D) + +/obj/machinery/computer/rdconsole/proc/check_canprint(datum/design/D, buildtype) + var/amount = 50 + if(buildtype == IMPRINTER) + if(QDELETED(linked_imprinter)) + return FALSE + for(var/M in D.materials + D.reagents_list) + amount = min(amount, linked_imprinter.check_mat(D, M)) + if(amount < 1) + return FALSE + else if(buildtype == PROTOLATHE) + if(QDELETED(linked_lathe)) + return FALSE + for(var/M in D.materials + D.reagents_list) + amount = min(amount, linked_lathe.check_mat(D, M)) + if(amount < 1) + return FALSE + else + return FALSE + return amount + +/obj/machinery/computer/rdconsole/proc/lock_console(mob/user) + locked = TRUE + +/obj/machinery/computer/rdconsole/proc/unlock_console(mob/user) + locked = FALSE + +/obj/machinery/computer/rdconsole/robotics + name = "Robotics R&D Console" + req_access = null + req_access_txt = "29" + +/obj/machinery/computer/rdconsole/robotics/Initialize() + . = ..() + if(circuit) + circuit.name = "R&D Console - Robotics (Computer Board)" + circuit.build_path = /obj/machinery/computer/rdconsole/robotics + +/obj/machinery/computer/rdconsole/core + name = "Core R&D Console" + +/obj/machinery/computer/rdconsole/experiment + name = "E.X.P.E.R.I-MENTOR R&D Console" diff --git a/code/modules/research/xenobiology/crossbreeding/stabilized.dm b/code/modules/research/xenobiology/crossbreeding/stabilized.dm index bcfe226e..69bd2c7e 100644 --- a/code/modules/research/xenobiology/crossbreeding/stabilized.dm +++ b/code/modules/research/xenobiology/crossbreeding/stabilized.dm @@ -134,7 +134,7 @@ Stabilized extracts: saved_mind = null START_PROCESSING(SSobj, src) if(choice == "Familiar Name") - var/newname = copytext(sanitize(input(user, "Would you like to change the name of [mob_name]", "Name change", mob_name) as null|text),1,MAX_NAME_LEN) + var/newname = reject_bad_name(stripped_input(user, "Would you like to change the name of [mob_name]", "Name change", mob_name, MAX_NAME_LEN), TRUE) if(newname) mob_name = newname to_chat(user, "You speak softly into [src], and it shakes slightly in response.") diff --git a/code/modules/research/xenobiology/xenobiology.dm b/code/modules/research/xenobiology/xenobiology.dm index 96dd104e..6bc9dbda 100644 --- a/code/modules/research/xenobiology/xenobiology.dm +++ b/code/modules/research/xenobiology/xenobiology.dm @@ -643,7 +643,7 @@ M.nutrition = 700 to_chat(M, "You absorb the potion and feel your intense desire to feed melt away.") to_chat(user, "You feed the slime the potion, removing its hunger and calming it.") - var/newname = copytext(sanitize(input(user, "Would you like to give the slime a name?", "Name your new pet", "pet slime") as null|text),1,MAX_NAME_LEN) + var/newname = reject_bad_name(stripped_input(user, "Would you like to give the slime a name?", "Name your new pet", "pet slime", MAX_NAME_LEN), TRUE) if (!newname) newname = "pet slime" diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 225ca1f8..44a70f53 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -660,7 +660,7 @@ if(timeleft > 1 HOURS) return "--:--" else if(timeleft > 0) - return "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]" + return "[add_leading(num2text((timeleft / 60) % 60), 2, "0")]:[add_leading(num2text(timeleft % 60), 2, " ")]" else return "00:00" diff --git a/code/modules/shuttle/supply.dm b/code/modules/shuttle/supply.dm index 2ac6df76..3403d90f 100644 --- a/code/modules/shuttle/supply.dm +++ b/code/modules/shuttle/supply.dm @@ -174,5 +174,6 @@ GLOBAL_LIST_INIT(cargo_shuttle_leave_behind_typecache, typecacheof(list( msg += "[value] credits: received [amount]u of [R.name].\n" SSshuttle.points += value + msg = copytext_char(msg, 1, MAX_MESSAGE_LEN) SSshuttle.centcom_message = msg investigate_log("Shuttle contents sold for [SSshuttle.points - presale_points] credits. Contents: [ex.exported_atoms || "none."] Message: [SSshuttle.centcom_message || "none."]", INVESTIGATE_CARGO) diff --git a/code/modules/spells/spell_types/mind_transfer.dm b/code/modules/spells/spell_types/mind_transfer.dm index 5c3cd0bd..5c0b5a2e 100644 --- a/code/modules/spells/spell_types/mind_transfer.dm +++ b/code/modules/spells/spell_types/mind_transfer.dm @@ -61,7 +61,7 @@ Also, you never added distance checking after target is selected. I've went ahea return var/datum/mind/TM = target.mind - if((target.anti_magic_check() || TM.has_antag_datum(/datum/antagonist/wizard) || TM.has_antag_datum(/datum/antagonist/cult) || TM.has_antag_datum(/datum/antagonist/clockcult) || TM.has_antag_datum(/datum/antagonist/changeling) || TM.has_antag_datum(/datum/antagonist/rev)) || cmptext(copytext(target.key,1,2),"@")) + if(target.anti_magic_check(TRUE, FALSE) || TM.has_antag_datum(/datum/antagonist/wizard) || TM.has_antag_datum(/datum/antagonist/cult) || TM.has_antag_datum(/datum/antagonist/clockcult) || TM.has_antag_datum(/datum/antagonist/changeling) || TM.has_antag_datum(/datum/antagonist/rev) || target.key[1] == "@") if(!silent) to_chat(user, "[target.p_their(TRUE)] mind is resisting your spell!") return diff --git a/code/modules/surgery/organs/eyes.dm b/code/modules/surgery/organs/eyes.dm index 9d1c0e0c..69057c60 100644 --- a/code/modules/surgery/organs/eyes.dm +++ b/code/modules/surgery/organs/eyes.dm @@ -202,7 +202,7 @@ /obj/item/organ/eyes/robotic/shield/emp_act(severity) return -#define RGB2EYECOLORSTRING(definitionvar) ("[copytext(definitionvar,2,3)][copytext(definitionvar,4,5)][copytext(definitionvar,6,7)]") +#define RGB2EYECOLORSTRING(definitionvar) ("[copytext_char(definitionvar, 2, 3)][copytext_char(definitionvar, 4, 5)][copytext_char(definitionvar, 6, 7)]") /obj/item/organ/eyes/robotic/glow name = "High Luminosity Eyes" diff --git a/code/modules/surgery/organs/tongue.dm b/code/modules/surgery/organs/tongue.dm index 864d5cda..e0facba3 100644 --- a/code/modules/surgery/organs/tongue.dm +++ b/code/modules/surgery/organs/tongue.dm @@ -165,7 +165,7 @@ var/insertpos = rand(1, message_list.len - 1) var/inserttext = message_list[insertpos] - if(!(copytext(inserttext, length(inserttext) - 2) == "...")) + if(!(copytext(inserttext, -3) == "..."))//3 == length("...") message_list[insertpos] = inserttext + "..." if(prob(20) && message_list.len > 3) @@ -273,7 +273,7 @@ /obj/item/organ/tongue/fluffy/handle_speech(datum/source, list/speech_args) var/message = speech_args[SPEECH_MESSAGE] - if(copytext(message, 1, 2) != "*") + if(message[1] != "*") message = replacetext(message, "ne", "nye") message = replacetext(message, "nu", "nyu") message = replacetext(message, "na", "nya") diff --git a/code/modules/surgery/organs/vocal_cords.dm b/code/modules/surgery/organs/vocal_cords.dm index f831ec4a..3f616d5a 100644 --- a/code/modules/surgery/organs/vocal_cords.dm +++ b/code/modules/surgery/organs/vocal_cords.dm @@ -189,19 +189,19 @@ listeners = list(L) //Devil names are unique. power_multiplier *= 5 //if you're a devil and god himself addressed you, you fucked up //Cut out the name so it doesn't trigger commands - message = copytext(message, 0, start)+copytext(message, start + length(devilinfo.truename), length(message) + 1) + message = copytext(message, 1, start) + copytext(message, start + length(devilinfo.truename)) break - else if(dd_hasprefix(message, L.real_name)) + else if(findtext(message, L.real_name, 1, length(L.real_name) + 1)) specific_listeners += L //focus on those with the specified name //Cut out the name so it doesn't trigger commands found_string = L.real_name - else if(dd_hasprefix(message, L.first_name())) + else if(findtext(message, L.first_name(), 1, length(L.first_name()) + 1)) specific_listeners += L //focus on those with the specified name //Cut out the name so it doesn't trigger commands found_string = L.first_name() - else if(L.mind && L.mind.assigned_role && dd_hasprefix(message, L.mind.assigned_role)) + else if(L.mind && L.mind.assigned_role && findtext(message, L.mind.assigned_role, 1, length(L.mind.assigned_role) + 1)) specific_listeners += L //focus on those with the specified job //Cut out the job so it doesn't trigger commands found_string = L.mind.assigned_role @@ -209,7 +209,7 @@ if(specific_listeners.len) listeners = specific_listeners power_multiplier *= (1 + (1/specific_listeners.len)) //2x on a single guy, 1.5x on two and so on - message = copytext(message, 0, 1)+copytext(message, 1 + length(found_string), length(message) + 1) + message = copytext(message, length(found_string) + 1) var/static/regex/stun_words = regex("stop|wait|stand still|hold on|halt") var/static/regex/knockdown_words = regex("drop|fall|trip|knockdown") @@ -718,19 +718,19 @@ for(var/V in listeners) var/mob/living/L = V - if(dd_hasprefix(message, L.real_name)) + if(findtext(message, L.real_name, 1, length(L.real_name) + 1)) specific_listeners += L //focus on those with the specified name //Cut out the name so it doesn't trigger commands found_string = L.real_name power_multiplier += 0.5 - else if(dd_hasprefix(message, L.first_name())) + else if(findtext(message, L.first_name(), 1, length(L.first_name()) + 1)) specific_listeners += L //focus on those with the specified name //Cut out the name so it doesn't trigger commands found_string = L.first_name() power_multiplier += 0.5 - else if(L.mind && L.mind.assigned_role && dd_hasprefix(message, L.mind.assigned_role)) + else if(L.mind && L.mind.assigned_role && findtext(message, L.mind.assigned_role, 1, length(L.mind.assigned_role) + 1)) specific_listeners += L //focus on those with the specified job //Cut out the job so it doesn't trigger commands found_string = L.mind.assigned_role @@ -739,7 +739,7 @@ if(specific_listeners.len) listeners = specific_listeners //power_multiplier *= (1 + (1/specific_listeners.len)) //Put this is if it becomes OP, power is judged internally on a thrall, so shouldn't be nessicary. - message = copytext(message, 0, 1)+copytext(message, 1 + length(found_string), length(message) + 1)//I have no idea what this does + message = copytext(message, length(found_string) + 1)//I have no idea what this does var/obj/item/organ/tongue/T = user.getorganslot(ORGAN_SLOT_TONGUE) if (T.name == "fluffy tongue") //If you sound hillarious, it's hard to take you seriously. This is a way for other players to combat/reduce their effectiveness. diff --git a/interface/menu.dm b/interface/menu.dm index 1f2ccde8..7771147d 100644 --- a/interface/menu.dm +++ b/interface/menu.dm @@ -69,8 +69,8 @@ GLOBAL_LIST_EMPTY(menulist) if (!verbpath || !(verbpath in typesof("[type]/verb"))) return - if (copytext(verbpath.name,1,2) == "@") - winset(C, null, list2params(list("command" = copytext(verbpath.name,2)))) + if (verbpath.name[1] == "@") + winset(C, null, list2params(list("command" = copytext(verbpath.name, length(verbpath.name[1]) + 1)))) else winset(C, null, list2params(list("command" = replacetext(verbpath.name, " ", "-")))) diff --git a/modular_citadel/code/modules/client/loadout/loadout.dm b/modular_citadel/code/modules/client/loadout/loadout.dm index 2e11519d..f0b80f65 100644 --- a/modular_citadel/code/modules/client/loadout/loadout.dm +++ b/modular_citadel/code/modules/client/loadout/loadout.dm @@ -13,7 +13,7 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids) LAZYINITLIST(GLOB.loadout_whitelist_ids) var/list/file_lines = world.file2list(loadout_config) for(var/line in file_lines) - if(!line || findtextEx(line,"#",1,2)) + if(!line || line[1] == "#") continue var/list/lineinfo = splittext(line, "|") var/lineID = lineinfo[1] @@ -21,7 +21,7 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids) var/sublinetypedef = findtext(subline, "=") if(sublinetypedef) var/sublinetype = copytext(subline, 1, sublinetypedef) - var/list/sublinecontent = splittext(copytext(subline, sublinetypedef+1), ",") + var/list/sublinecontent = splittext(copytext(subline, sublinetypedef+ length(sublinetypedef)), ",") if(sublinetype == "WHITELIST") GLOB.loadout_whitelist_ids["[lineID]"] = sublinecontent diff --git a/modular_citadel/code/modules/custom_loadout/read_from_file.dm b/modular_citadel/code/modules/custom_loadout/read_from_file.dm index 0ed38e8d..78124b03 100644 --- a/modular_citadel/code/modules/custom_loadout/read_from_file.dm +++ b/modular_citadel/code/modules/custom_loadout/read_from_file.dm @@ -13,18 +13,18 @@ GLOBAL_LIST(custom_item_list) GLOB.custom_item_list = list() var/list/file_lines = world.file2list(custom_filelist) for(var/line in file_lines) - if(length(line) == 0) //Emptyline, no one cares. + if(!length(line)) //Emptyline, no one cares. continue - if(copytext(line,1,3) == "//") //Commented line, ignore. + if(copytext(line,1,3) == "//") //Commented line, ignore. 3 == length("//") + 1 continue var/ckey_str_sep = findtext(line, "|") //Process our stuff.. - var/char_str_sep = findtext(line, "|", ckey_str_sep+1) - var/job_str_sep = findtext(line, "|", char_str_sep+1) - var/item_str_sep = findtext(line, "|", job_str_sep+1) + var/char_str_sep = findtext(line, "|", ckey_str_sep + length(ckey_str_sep)) + var/job_str_sep = findtext(line, "|", char_str_sep + length(char_str_sep)) + var/item_str_sep = findtext(line, "|", job_str_sep + length(job_str_sep)) var/ckey_str = ckey(copytext(line, 1, ckey_str_sep)) - var/char_str = copytext(line, ckey_str_sep+1, char_str_sep) - var/job_str = copytext(line, char_str_sep+1, job_str_sep) - var/item_str = copytext(line, job_str_sep+1, item_str_sep) + var/char_str = copytext(line, ckey_str_sep + length(ckey_str_sep), char_str_sep) + var/job_str = copytext(line, char_str_sep + length(char_str_sep), job_str_sep) + var/item_str = copytext(line, job_str_sep + length(job_str_sep), item_str_sep) if(!ckey_str || !char_str || !job_str || !item_str || !length(ckey_str) || !length(char_str) || !length(job_str) || !length(item_str)) log_admin("Errored custom_items_whitelist line: [line] - Component/separator missing!") if(!islist(GLOB.custom_item_list[ckey_str])) @@ -42,7 +42,7 @@ GLOBAL_LIST(custom_item_list) for(var/item_string in item_strings) var/path_str_sep = findtext(item_string, "=") var/path = copytext(item_string, 1, path_str_sep) //Path to spawn - var/amount = copytext(item_string, path_str_sep+1) //Amount to spawn + var/amount = copytext(item_string, path_str_sep + length(path_str_sep)) //Amount to spawn //world << "DEBUG: Item string [item_string] processed" amount = text2num(amount) path = text2path(path) diff --git a/modular_citadel/code/modules/mentor/mentorhelp.dm b/modular_citadel/code/modules/mentor/mentorhelp.dm index 87b05a3f..0d7fc8f6 100644 --- a/modular_citadel/code/modules/mentor/mentorhelp.dm +++ b/modular_citadel/code/modules/mentor/mentorhelp.dm @@ -10,9 +10,9 @@ spawn(300) verbs += /client/verb/mentorhelp // 30 second cool-down for mentorhelp - msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN)) - if(!msg) return - if(!mob) return //this doesn't happen + msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN)) + if(!msg || !mob) + return var/show_char = CONFIG_GET(flag/mentors_mobname_only) var/mentor_msg = "MENTORHELP: [key_name_mentor(src, 1, 0, 1, show_char)]: [msg]" diff --git a/modular_citadel/code/modules/mentor/mentorpm.dm b/modular_citadel/code/modules/mentor/mentorpm.dm index 4c9a4766..cb39f020 100644 --- a/modular_citadel/code/modules/mentor/mentorpm.dm +++ b/modular_citadel/code/modules/mentor/mentorpm.dm @@ -53,7 +53,7 @@ if (!C.is_mentor() && !is_mentor()) return - msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN)) + msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN)) if(!msg && is_mentor(whom)) to_chat(GLOB.admins | GLOB.mentors, "[src] has stopped their reply to [whom]'s mhelp.") return diff --git a/modular_citadel/code/modules/mentor/mentorsay.dm b/modular_citadel/code/modules/mentor/mentorsay.dm index 6baf9692..c13e3c6e 100644 --- a/modular_citadel/code/modules/mentor/mentorsay.dm +++ b/modular_citadel/code/modules/mentor/mentorsay.dm @@ -5,8 +5,9 @@ if(!is_mentor()) return - msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN) - if(!msg) return + msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN) + if(!msg) + return msg = emoji_parse(msg) log_mentor("MSAY: [key_name(src)] : [msg]") diff --git a/modular_citadel/code/modules/vore/eating/vore_vr.dm b/modular_citadel/code/modules/vore/eating/vore_vr.dm index dc813d70..992eb632 100644 --- a/modular_citadel/code/modules/vore/eating/vore_vr.dm +++ b/modular_citadel/code/modules/vore/eating/vore_vr.dm @@ -80,7 +80,7 @@ GLOBAL_LIST_EMPTY(vore_preferences_datums) // /datum/vore_preferences/proc/load_path(ckey,slot,filename="character",ext="json") if(!ckey || !slot) return - path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/vore/[filename][slot].[ext]" + path = "data/player_saves/[ckey[1]]/[ckey]/vore/[filename][slot].[ext]" /datum/vore_preferences/proc/load_vore() if(!client || !client_ckey)