From a135e67f71b30cb3a360b05884e514a8bba22723 Mon Sep 17 00:00:00 2001 From: Markolie Date: Tue, 29 Sep 2015 06:59:27 +0200 Subject: [PATCH] Add AI text announcements --- code/modules/mob/living/silicon/ai/ai.dm | 51 ++++++++++++++++------- code/modules/mob/living/silicon/ai/say.dm | 12 ++++-- 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 286b2eebd64..6de7b47779f 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -4,6 +4,7 @@ var/list/ai_list = list() var/list/ai_verbs_default = list( /mob/living/silicon/ai/proc/announcement, + /mob/living/silicon/ai/proc/ai_announcement_text, /mob/living/silicon/ai/proc/ai_call_shuttle, /mob/living/silicon/ai/proc/ai_camera_track, /mob/living/silicon/ai/proc/ai_camera_list, @@ -79,6 +80,7 @@ var/list/ai_verbs_default = list( var/last_paper_seen = null var/can_shunt = 1 var/last_announcement = "" + var/datum/announcement/priority/announcement var/obj/machinery/bot/Bot var/turf/waypoint //Holds the turf of the currently selected waypoint. var/waypoint_mode = 0 //Waypoint mode is for selecting a turf via clicking. @@ -97,6 +99,11 @@ var/list/ai_verbs_default = list( src.verbs -= silicon_subsystems /mob/living/silicon/ai/New(loc, var/datum/ai_laws/L, var/obj/item/device/mmi/B, var/safety = 0) + announcement = new() + announcement.title = "A.I. Announcement" + announcement.announcement_type = "A.I. Announcement" + announcement.newscast = 1 + var/list/possibleNames = ai_names var/pickedName = null @@ -325,15 +332,35 @@ var/list/ai_verbs_default = list( set name = "Show Crew Manifest" set category = "AI Commands" show_station_manifest() + +/mob/living/silicon/ai/var/message_cooldown = 0 +/mob/living/silicon/ai/proc/ai_announcement_text() + set category = "AI Commands" + set name = "Make Station Announcement" + + if(check_unable(AI_CHECK_WIRELESS | AI_CHECK_RADIO)) + return + + if(message_cooldown) + src << "Please allow one minute to pass between announcements." + return + + var/input = input(usr, "Please write a message to announce to the station crew.", "A.I. Announcement") as text|null + if(!input) + return + + if(check_unable(AI_CHECK_WIRELESS | AI_CHECK_RADIO)) + return + + announcement.Announce(input) + message_cooldown = 1 + spawn(600)//One minute cooldown + message_cooldown = 0 /mob/living/silicon/ai/proc/ai_call_shuttle() set name = "Call Emergency Shuttle" set category = "AI Commands" - if(src.stat == DEAD) - src << "You can't call the shuttle because you are dead!" - return - if(check_unable(AI_CHECK_WIRELESS)) return @@ -356,11 +383,7 @@ var/list/ai_verbs_default = list( /mob/living/silicon/ai/proc/ai_cancel_call() set name = "Recall Emergency Shuttle" set category = "AI Commands" - - if(src.stat == 2) - src << "You can't send the shuttle back because you are dead!" - return - + if(check_unable(AI_CHECK_WIRELESS)) return @@ -394,10 +417,6 @@ var/list/ai_verbs_default = list( set desc = "Create a vocal announcement by typing in the available words to create a sentence." set category = "AI Commands" - if(src.stat == 2) - src << "You can't call make an announcement because you are dead!" - return - if(check_unable(AI_CHECK_WIRELESS | AI_CHECK_RADIO)) return @@ -949,14 +968,14 @@ var/list/ai_verbs_default = list( /mob/living/silicon/ai/proc/check_unable(var/flags = 0) if(stat == DEAD) - usr << "\red You are dead!" + usr << "You are dead!" return 1 if((flags & AI_CHECK_WIRELESS) && src.control_disabled) - usr << "\red Wireless control is disabled!" + usr << "Wireless control is disabled!" return 1 if((flags & AI_CHECK_RADIO) && src.aiRadio.disabledAi) - src << "\red System Error - Transceiver Disabled!" + src << "System Error - Transceiver Disabled!" return 1 return 0 diff --git a/code/modules/mob/living/silicon/ai/say.dm b/code/modules/mob/living/silicon/ai/say.dm index 96954d82d25..acf3a2db3c0 100644 --- a/code/modules/mob/living/silicon/ai/say.dm +++ b/code/modules/mob/living/silicon/ai/say.dm @@ -28,13 +28,19 @@ var/const/VOX_PATH = "sound/vox_fem/" popup.open() /mob/living/silicon/ai/proc/ai_announcement() + if(check_unable(AI_CHECK_WIRELESS | AI_CHECK_RADIO)) + return + if(announcing_vox > world.time) - src << "Please wait [round((announcing_vox - world.time) / 10)] seconds." + src << "Please wait [round((announcing_vox - world.time) / 10)] seconds." return - var/message = input(src, "WARNING: Misuse of this verb can result in you being job banned. More help is available in 'Announcement Help'", "Announcement", src.last_announcement) as text + var/message = input(src, "WARNING: Misuse of this verb can result in you being job banned. More help is available in 'Announcement Help'", "Announcement", last_announcement) as text|null last_announcement = message + + if(check_unable(AI_CHECK_WIRELESS | AI_CHECK_RADIO)) + return if(!message || announcing_vox > world.time) return @@ -54,7 +60,7 @@ var/const/VOX_PATH = "sound/vox_fem/" incorrect_words += word if(incorrect_words.len) - src << "These words are not available on the announcement system: [english_list(incorrect_words)]." + src << "These words are not available on the announcement system: [english_list(incorrect_words)]." return announcing_vox = world.time + VOX_DELAY