Optimizes some functions (#24049)

* Optimizes some functions

* Update code/__HELPERS/unsorted.dm

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>

* Cached per AI now

* no more 80k character jumpscares

* parent functions exist

* I need a new keyboard

* Update code/modules/surgery/organs/vocal_cords.dm

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>

* Update code/modules/mob/living/silicon/ai/ai_say.dm

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>

* Update code/__HELPERS/game.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* Update code/__HELPERS/game.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

---------

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com>
This commit is contained in:
GDN
2024-04-03 12:51:39 -05:00
committed by GitHub
parent 176e12ff04
commit cc0eee4b4d
16 changed files with 77 additions and 77 deletions
@@ -135,6 +135,9 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
/mob/living/silicon/proc/subsystem_law_manager,
/mob/living/silicon/proc/subsystem_power_monitor)
/// The cached AI annoucement help menu.
var/ai_announcement_string_menu
/mob/living/silicon/ai/proc/add_ai_verbs()
add_verb(src, GLOB.ai_verbs_default)
add_verb(src, silicon_subsystems)
@@ -1545,6 +1548,13 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
var/mob/dead/observer/ghost = .
ghost.forceMove(old_turf)
/mob/living/silicon/ai/can_vv_get(var_name)
if(!..())
return FALSE
if(var_name == "ai_announcement_string_menu") // This single var has over 80 thousand characters in it. Not something you really want when VVing the AI
return FALSE
return TRUE
/mob/living/silicon/ai/proc/blurb_it()
addtimer(CALLBACK(src, TYPE_PROC_REF(/mob/living/silicon/ai, show_ai_blurb)), 1 SECONDS)
+18 -18
View File
@@ -74,24 +74,25 @@ GLOBAL_VAR_INIT(announcing_vox, 0) // Stores the time of the last announcement
set desc = "Display a list of vocal words to announce to the crew."
set category = "AI Commands"
var/list/dat = list()
if(!ai_announcement_string_menu)
var/list/dat = list()
dat += "Here is a list of words you can type into the 'Announcement' button to create sentences to vocally announce to everyone on the same level at you.<BR> \
<UL><LI>You can also click on the word to preview it.</LI>\
<LI>You can only say 30 words for every announcement.</LI>\
<LI>Do not use punctuation as you would normally, if you want a pause you can use the full stop and comma characters by separating them with spaces, like so: 'Alpha . Test , Bravo'.</LI></UL>\
<font class='bad'>WARNING:</font><BR>Misuse of the announcement system will get you job banned.<HR>"
dat += "Here is a list of words you can type into the 'Announcement' button to create sentences to vocally announce to everyone on the same level at you.<br> \
<ul><li>You can also click on the word to preview it.</li>\
<li>You can only say 30 words for every announcement.</li>\
<li>Do not use punctuation as you would normally, if you want a pause you can use the full stop and comma characters by separating them with spaces, like so: 'Alpha . Test , Bravo'.</li></ul>\
<font class='bad'>WARNING:</font><br>Misuse of the announcement system will get you job banned.<hr>"
// Show alert and voice sounds separately
var/vox_words = GLOB.vox_sounds - GLOB.vox_alerts
dat += help_format(GLOB.vox_alerts)
dat += "<hr>"
dat += help_format(vox_words)
// Show alert and voice sounds separately
var/vox_words = GLOB.vox_sounds - GLOB.vox_alerts
dat += help_format(GLOB.vox_alerts)
dat += "<hr>"
dat += help_format(vox_words)
var/string_dat = dat.Join("")
ai_announcement_string_menu = dat.Join("")
var/datum/browser/popup = new(src, "announce_help", "Announcement Help", 500, 400)
popup.set_content(string_dat)
popup.set_content(ai_announcement_string_menu)
popup.open()
/mob/living/silicon/ai/proc/help_format(word_list)
@@ -122,8 +123,8 @@ GLOBAL_VAR_INIT(announcing_vox, 0) // Stores the time of the last announcement
var/list/words = splittext(trim(message), " ")
var/list/incorrect_words = list()
if(words.len > 30)
words.len = 30
if(length(words) > 30)
words.Cut(31)
for(var/word in words)
word = lowertext(trim(word))
@@ -133,7 +134,7 @@ GLOBAL_VAR_INIT(announcing_vox, 0) // Stores the time of the last announcement
if(!GLOB.vox_sounds[word])
incorrect_words += word
if(incorrect_words.len)
if(length(incorrect_words))
to_chat(src, "<span class='warning'>These words are not available on the announcement system: [english_list(incorrect_words)].</span>")
return
@@ -143,11 +144,10 @@ GLOBAL_VAR_INIT(announcing_vox, 0) // Stores the time of the last announcement
message_admins("[key_name_admin(src)] made a vocal announcement: [message].")
for(var/word in words)
play_vox_word(word, src.z, null)
play_vox_word(word, z, null)
ai_voice_announcement_to_text(words)
/mob/living/silicon/ai/proc/ai_voice_announcement_to_text(words)
var/words_string = jointext(words, " ")
// Don't go through .Announce because we need to filter by clients which have TTS enabled
+5 -5
View File
@@ -139,7 +139,7 @@
/mob/visible_message(message, self_message, blind_message)
if(!isturf(loc)) // mobs inside objects (such as lockers) shouldn't have their actions visible to those outside the object
for(var/mob/M in get_mobs_in_view(3, src))
for(var/mob/M as anything in get_mobs_in_view(3, src))
if(M.see_invisible < invisibility)
continue //can't view the invisible
var/msg = message
@@ -151,7 +151,7 @@
msg = blind_message
M.show_message(msg, EMOTE_VISIBLE, blind_message, EMOTE_AUDIBLE)
return
for(var/mob/M in get_mobs_in_view(7, src))
for(var/mob/M as anything in get_mobs_in_view(7, src))
if(M.see_invisible < invisibility)
continue //can't view the invisible
var/msg = message
@@ -164,7 +164,7 @@
// message is output to anyone who can see, e.g. "The [src] does something!"
// blind_message (optional) is what blind people will hear e.g. "You hear something!"
/atom/proc/visible_message(message, blind_message)
for(var/mob/M in get_mobs_in_view(7, src))
for(var/mob/M as anything in get_mobs_in_view(7, src))
if(!M.client)
continue
M.show_message(message, EMOTE_VISIBLE, blind_message, EMOTE_AUDIBLE)
@@ -180,7 +180,7 @@
if(hearing_distance)
range = hearing_distance
var/msg = message
for(var/mob/M in get_mobs_in_view(range, src))
for(var/mob/M as anything in get_mobs_in_view(range, src))
M.show_message(msg, EMOTE_AUDIBLE, deaf_message, EMOTE_VISIBLE)
// based on say code
@@ -206,7 +206,7 @@
var/range = 7
if(hearing_distance)
range = hearing_distance
for(var/mob/M in get_mobs_in_view(range, src))
for(var/mob/M as anything in get_mobs_in_view(range, src))
M.show_message(message, EMOTE_AUDIBLE, deaf_message, EMOTE_VISIBLE)
/mob/proc/findname(msg)