Silicon mob types can now speak languages

This commit is contained in:
mwerezak
2014-05-16 19:47:26 -04:00
parent 02dbe8a812
commit c643da6198
5 changed files with 40 additions and 31 deletions

View File

@@ -23,6 +23,7 @@ var/global/list/joblist = list() //list of all jobstypes, minus borg and AI
//Languages/species/whitelist. //Languages/species/whitelist.
var/global/list/all_species[0] var/global/list/all_species[0]
var/global/list/all_languages[0] var/global/list/all_languages[0]
var/global/list/language_keys[0] //table of say codes for all languages
var/global/list/whitelisted_species = list("Human") var/global/list/whitelisted_species = list("Human")
// Posters // Posters
@@ -100,6 +101,9 @@ var/global/list/backbaglist = list("Nothing", "Backpack", "Satchel", "Satchel Al
for(var/T in paths) for(var/T in paths)
var/datum/language/L = new T var/datum/language/L = new T
all_languages[L.name] = L all_languages[L.name] = L
for (var/datum/language/L in all_languages)
language_keys[L.key] = L
var/rkey = 0 var/rkey = 0
paths = typesof(/datum/species)-/datum/species paths = typesof(/datum/species)-/datum/species

View File

@@ -90,6 +90,11 @@
return 0 return 0
// Can we speak this language, as opposed to just understanding it?
/mob/proc/can_speak(datum/language/language)
return (universal_speak || language in src.languages)
//TBD //TBD
/mob/verb/check_languages() /mob/verb/check_languages()
set name = "Check Known Languages" set name = "Check Known Languages"

View File

@@ -24,10 +24,10 @@
alt_name = "(as [get_id_name("Unknown")])" alt_name = "(as [get_id_name("Unknown")])"
//parse the radio code and consume it //parse the radio code and consume it
var/message_mode = parse_message_mode(message) var/message_mode = parse_message_mode(message, "headset")
if (message_mode) if (message_mode)
if (message_mode == "headset") if (message_mode == "headset")
message = copytext(message,2) message = copytext(message,2) //it would be really nice if the parse procs could do this for us.
else else
message = copytext(message,3) message = copytext(message,3)

View File

@@ -60,27 +60,25 @@
return return
var/verb = say_quote(message) var/verb = say_quote(message)
var/message_mode = null
//parse radio key and consume it
var/message_mode = parse_message_mode(message, "general")
if(copytext(message,1,2) == ";") if (message_mode)
message_mode = "general" // I don't know why but regular radio = fuck you we ain't broadcasting, pAI mode was what was in old say code. if (message_mode == "general")
message = trim(copytext(message,2)) message = trim(copytext(message,2))
else
else if(length(message) >= 2) message = trim(copytext(message,3))
var/channel_prefix = copytext(message, 1 ,3)
if(!message_mode) if(message_mode && bot_type == IS_ROBOT && message_mode != "binary" && !R.is_component_functioning("radio"))
message_mode = department_radio_keys[channel_prefix] src << "\red Your radio isn't functional at this time."
return
if(message_mode && bot_type == IS_ROBOT)
if(message_mode != "binary" && !R.is_component_functioning("radio")) //parse language key and consume it
src << "\red Your radio isn't functional at this time." var/datum/language/speaking = parse_language(message)
return if (speaking)
verb = speaking.speech_verb
message = copytext(message,3)
if(message_mode && message_mode != "general")
message = trim(copytext(message,3))
switch(message_mode) switch(message_mode)
if("department") if("department")
switch(bot_type) switch(bot_type)
@@ -133,7 +131,7 @@
return return
return ..(message,null,verb) return ..(message,speaking,verb)
//For holopads only. Usable by AI. //For holopads only. Usable by AI.
/mob/living/silicon/ai/proc/holopad_talk(var/message) /mob/living/silicon/ai/proc/holopad_talk(var/message)

View File

@@ -143,11 +143,12 @@
return "2" return "2"
return "0" return "0"
//parses the message mode code (e.g. :h, ;) from text, such as that supplied to say. //parses the message mode code (e.g. :h, :w) from text, such as that supplied to say.
//returns the message mode string or null for no message mode. //returns the message mode string or null for no message mode.
/mob/proc/parse_message_mode(var/message) //standard mode is the mode returned for the special ';' radio code.
/mob/proc/parse_message_mode(var/message, var/standard_mode="headset")
if(length(message) >= 1 && copytext(message,1,2) == ";") if(length(message) >= 1 && copytext(message,1,2) == ";")
return "headset" return standard_mode
if(length(message) >= 2) if(length(message) >= 2)
var/channel_prefix = copytext(message, 1 ,3) var/channel_prefix = copytext(message, 1 ,3)
@@ -156,12 +157,13 @@
return null return null
//parses the language code (e.g. :j) from text, such as that supplied to say. //parses the language code (e.g. :j) from text, such as that supplied to say.
//returns the language object only if the code corresponds to a language that src knows, otherwise null. //returns the language object only if the code corresponds to a language that src can speak, otherwise null.
/mob/proc/parse_language(var/message) /mob/proc/parse_language(var/message)
if(length(message) >= 2) if(length(message) >= 2)
var/language_prefix = lowertext(copytext(message, 1 ,3)) var/language_prefix = lowertext(copytext(message, 1 ,3))
for(var/datum/language/L in src.languages) var/datum/language/L = language_keys[language_prefix]
if(language_prefix == ":[L.key]") if (can_speak(L))
return L return L
return null return null