/var/datum/controller/subsystem/pai/SSpai /datum/controller/subsystem/pai name = "pAI" init_order = SS_INIT_MISC_FIRST flags = SS_NO_FIRE var/list/pai_software_by_key var/list/default_pai_software var/inquirer = null var/list/pai_candidates = list() var/list/asked = list() var/list/all_pai_devices = list() var/askDelay = 1 MINUTE /datum/controller/subsystem/pai/New() NEW_SS_GLOBAL(SSpai) LAZYINITLIST(pai_software_by_key) LAZYINITLIST(default_pai_software) /datum/controller/subsystem/pai/Initialize() // Initialize the pAI software list. for(var/type in subtypesof(/datum/pai_software)) var/datum/pai_software/P = new type() if(pai_software_by_key[P.id]) var/datum/pai_software/O = pai_software_by_key[P.id] world << "pAI software module [P.name] has the same key as [O.name]!" continue pai_software_by_key[P.id] = P if(P.default) default_pai_software[P.id] = P /datum/controller/subsystem/pai/Recover() pai_software_by_key = SSpai.pai_software_by_key default_pai_software = SSpai.default_pai_software /datum/controller/subsystem/pai/Topic(href, list/href_list) if(href_list["download"]) var/datum/paiCandidate/candidate = locate(href_list["candidate"]) var/obj/item/device/paicard/card = locate(href_list["device"]) if (!candidate in pai_candidates) return if(card.pai) return if(istype(card,/obj/item/device/paicard) && istype(candidate,/datum/paiCandidate)) var/mob/living/silicon/pai/pai = new(card) if(!candidate.name) pai.name = pick(ninja_names) else pai.name = candidate.name pai.real_name = pai.name pai.key = candidate.key card.setPersonality(pai) card.looking_for_personality = 0 if(pai.mind) update_antag_icons(pai.mind) pai_candidates -= candidate usr << browse(null, "window=findPai") if(href_list["new"]) var/datum/paiCandidate/candidate = locate(href_list["candidate"]) var/option = href_list["option"] var/t = "" switch(option) if("name") t = sanitizeSafe(input("Enter a name for your pAI", "pAI Name", candidate.name) as text, MAX_NAME_LEN) if(t) candidate.name = t if("desc") t = input("Enter a description for your pAI", "pAI Description", candidate.description) as message if(t) candidate.description = sanitize(t) if("role") t = input("Enter a role for your pAI", "pAI Role", candidate.role) as text if(t) candidate.role = sanitize(t) if("ooc") t = input("Enter any OOC comments", "pAI OOC Comments", candidate.comments) as message if(t) candidate.comments = sanitize(t) if("save") if (config.sql_saves) usr.client.prefs.save_preferences() else candidate.savefile_save(usr) if("load") if (config.sql_saves) usr.client.prefs.load_preferences() else candidate.savefile_load(usr) //In case people have saved unsanitized stuff. if(candidate.name) candidate.name = sanitizeSafe(candidate.name, MAX_NAME_LEN) if(candidate.description) candidate.description = sanitize(candidate.description) if(candidate.role) candidate.role = sanitize(candidate.role) if(candidate.comments) candidate.comments = sanitize(candidate.comments) if("submit") if(candidate) candidate.ready = 1 for(var/obj/item/device/paicard/p in all_pai_devices) if(p.looking_for_personality == 1) p.alertUpdate() usr << browse(null, "window=paiRecruit") return if (config.sql_saves) usr.client.prefs.save_preferences() else candidate.savefile_save(usr) recruitWindow(usr, href_list["allow_submit"] != "0") /datum/controller/subsystem/pai/proc/recruitWindow(mob/M as mob, allowSubmit = TRUE) var/datum/paiCandidate/candidate for(var/datum/paiCandidate/c in pai_candidates) if(!istype(c) || !istype(M)) break if(c.key == M.key) candidate = c if(!candidate) candidate = new /datum/paiCandidate() candidate.key = M.key pai_candidates.Add(candidate) // Load the data before displaying. if (!config.sql_saves) candidate.savefile_load(M) else M.client.prefs.load_preferences() var/dat = "" dat += {" "} dat += {" pAI Personality Configuration

Please configure your pAI personality's options. Remember, what you enter here could determine whether or not the user requesting a personality chooses you!

Name: [candidate.name] 
What you plan to call yourself. Suggestions: Any character name you would choose for a station character OR an AI.
Description: [candidate.description] 
What sort of pAI you typically play; your mannerisms, your quirks, etc. This can be as sparse or as detailed as you like.
Preferred Role: [candidate.role] 
Do you like to partner with sneaky social ninjas? Like to help security hunt down thugs? Enjoy watching an engineer's back while he saves the station yet again? This doesn't have to be limited to just station jobs. Pretty much any general descriptor for what you'd like to be doing works here.
OOC Comments: [candidate.comments] 
Anything you'd like to address specifically to the player reading this in an OOC manner. \"I prefer more serious RP.\", \"I'm still learning the interface!\", etc. Feel free to leave this blank if you want.

"} if(allowSubmit) dat += {"
Submit Personality

"} dat += {" "} M << browse(dat, "window=paiRecruit;size=580x580;") // TODO: Refactor the spaghetti above into NanoUI. /datum/controller/subsystem/pai/proc/findPAI(obj/item/device/paicard/p, mob/user) requestRecruits(user) var/list/available = list() for(var/datum/paiCandidate/c in SSpai.pai_candidates) if(c.ready) var/found = 0 for(var/mob/abstract/observer/o in player_list) if(o.key == c.key && o.MayRespawn()) found = 1 if(found) available.Add(c) var/dat = "" dat += {" pAI Availability List

"} dat += "

Displaying available AI personalities from central database... If there are no entries, or if a suitable entry is not listed, check again later as more personalities may be added.

" for(var/datum/paiCandidate/c in available) dat += {"
Name: [c.name]
Description: [c.description]
Preferred Role: [c.role]
OOC Comments: [c.comments]
Download [c.name]

"} dat += {" "} user << browse(dat, "window=findPai") /datum/controller/subsystem/pai/proc/requestRecruits(mob/user) inquirer = user for(var/mob/abstract/observer/O in player_list) if(!O.MayRespawn()) continue if(jobban_isbanned(O, "pAI")) continue if(asked.Find(O.key)) if(world.time < asked[O.key] + askDelay) continue else asked.Remove(O.key) if(O.client) if(BE_PAI in O.client.prefs.be_special_role) question(O.client) /datum/controller/subsystem/pai/proc/question(client/C) set waitfor = FALSE if(!C) return asked.Add(C.key) asked[C.key] = world.time var/response = alert(C, "[inquirer] is requesting a pAI personality. Would you like to play as a personal AI?", "pAI Request", "Yes", "No", "Never for this round") if(!C) return //handle logouts that happen whilst the alert is waiting for a response. if(response == "Yes") recruitWindow(C.mob) else if (response == "Never for this round") C.prefs.be_special_role -= BE_PAI /datum/paiCandidate var/name var/key var/description var/role var/comments var/ready = 0