Adds announcer mob and uses it for autosay instead of the full-blown AI (#10474)

* Adds announcer mob and uses it for autosay instead of AI

Also fixes a runtime when we can't get accent icon.

* Makes it gib and dust
This commit is contained in:
Jiří Barouš
2020-11-13 19:33:44 +01:00
committed by GitHub
parent 804d27b2e9
commit ed2a052409
9 changed files with 167 additions and 32 deletions
+121
View File
@@ -0,0 +1,121 @@
// This mob is a lie. Similar to /mob/abstract it's not really supposed to do much.
// It is used as a fake announcer so that we have a lightweight mob to pass to radio broadcasts.
// To use it simply instantiate it, store a reference to it - it can be reused, so no reason
// to delete it immediately. Just before a broadcast call PrepareBroadcast with desired arguments,
// then right after the broadcast call ResetAfterBroadcast so you can re-use the mob without issues next time.
/mob/living/announcer
name = "Announcer"
voice_name = "synthesized voice"
accent = ACCENT_TTS
icon = 'icons/mob/AI.dmi'
icon_state = "ai"
gender = NEUTER
status_flags = GODMODE|NO_ANTAG|NOFALL
invisibility = INVISIBILITY_ABSTRACT
mob_thinks = FALSE
universal_understand = TRUE
can_have_vision_cone = FALSE
tesla_ignore = TRUE
stop_sight_update = TRUE
density = FALSE
burn_mod = 0
brute_mod = 0
/mob/living/announcer/Initialize()
// we specifically do not call parent Initialize here because this mob should not need it and its point is to be lightweight
SHOULD_CALL_PARENT(FALSE)
if(initialized)
crash_with("Warning: [src]([type]) initialized multiple times!")
initialized = TRUE
for(var/K in all_languages)
add_language(K)
default_language = all_languages[LANGUAGE_TCB]
/mob/living/announcer/Destroy()
// again not calling parent because it shouldn't be needed and makes this faster
SHOULD_CALL_PARENT(FALSE)
for(var/C in contents)
qdel(C)
/mob/living/announcer/proc/PrepareBroadcast(var/name = "", var/datum/language/lang = null, var/voice_name = null, var/accent = null)
src.name = name
if(!isnull(lang))
src.default_language = lang
if(!isnull(voice_name))
src.voice_name = voice_name
if(!isnull(accent))
src.accent = accent
/mob/living/announcer/proc/ResetAfterBroadcast()
src.name = initial(name)
src.default_language = all_languages[LANGUAGE_TCB]
src.voice_name = initial(voice_name)
src.accent = initial(accent)
/mob/living/announcer/Life()
return
/mob/living/announcer/Move()
return
/mob/living/announcer/zMove()
return
/mob/living/announcer/getBruteLoss()
return 0
/mob/living/announcer/burn_skin()
return FALSE
/mob/living/announcer/adjustBodyTemp()
return FALSE
/mob/living/announcer/get_contents()
return list()
/mob/living/announcer/check_contents_for()
return FALSE
/mob/living/announcer/can_inject()
return FALSE
/mob/living/announcer/seizure()
return FALSE
/mob/living/announcer/InStasis()
return FALSE
/mob/living/announcer/apply_radiation_effects()
return FALSE
/mob/living/announcer/flash_eyes()
return FALSE
/mob/living/announcer/dust()
qdel(src)
/mob/living/announcer/gib()
qdel(src)
/mob/living/announcer/can_fall()
return FALSE
/mob/living/announcer/conveyor_act()
return
/mob/living/announcer/ex_act()
return
/mob/living/announcer/singularity_act()
return
/mob/living/announcer/singularity_pull()
return
/mob/living/announcer/singuloCanEat()
return FALSE
+9 -7
View File
@@ -30,25 +30,27 @@
say(temp)
winset(client, "input", "text=[null]")
/mob/living/carbon/human/say_understands(var/mob/other,var/datum/language/speaking = null)
/mob/living/carbon/human/say_understands(var/mob/other, var/datum/language/speaking = null)
if(has_brain_worms()) //Brain worms translate everything. Even rat and alien speak.
return 1
return TRUE
if(species.can_understand(other))
return 1
return TRUE
//These only pertain to common. Languages are handled by mob/say_understands()
if (!speaking)
if (istype(other, /mob/living/carbon/alien/diona))
if(other.languages.len >= 2) //They've sucked down some blood and can speak common now.
return 1
return TRUE
if (istype(other, /mob/living/silicon))
return 1
return TRUE
if (istype(other, /mob/living/announcer))
return TRUE
if (istype(other, /mob/living/carbon/brain))
return 1
return TRUE
if (istype(other, /mob/living/carbon/slime))
return 1
return TRUE
//This is already covered by mob/say_understands()
//if (istype(other, /mob/living/simple_animal))
+2
View File
@@ -74,6 +74,8 @@
return TRUE
if(istype(other, /mob/living/silicon))
return TRUE
if (istype(other, /mob/living/announcer))
return TRUE
if(istype(other, /mob/living/carbon/brain))
return TRUE
return ..()
+5 -4
View File
@@ -1174,9 +1174,10 @@ proc/is_blind(A)
var/used_accent = force_accent ? force_accent : accent
if(used_accent && speaking?.allow_accents)
var/datum/accent/a = SSrecords.accents[used_accent]
var/final_icon = a.tag_icon
var/datum/asset/spritesheet/S = get_asset_datum(/datum/asset/spritesheet/goonchat)
return S.icon_tag(final_icon)
if(istype(a))
var/final_icon = a.tag_icon
var/datum/asset/spritesheet/S = get_asset_datum(/datum/asset/spritesheet/goonchat)
return S.icon_tag(final_icon)
/mob/proc/flash_eyes(intensity = FLASH_PROTECTION_MODERATE, override_blindness_check = FALSE, affect_silicon = FALSE, visual = FALSE, type = /obj/screen/fullscreen/flash)
for(var/mob/M in contents)
@@ -1185,4 +1186,4 @@ proc/is_blind(A)
/mob/assign_player(var/mob/user)
ckey = user.ckey
return src
return src
+10 -10
View File
@@ -73,33 +73,33 @@
/mob/proc/say_understands(var/mob/other,var/datum/language/speaking = null)
if (src.stat == 2) //Dead
return 1
return TRUE
//Universal speak makes everything understandable, for obvious reasons.
else if(src.universal_speak || src.universal_understand)
return 1
return TRUE
//Languages are handled after.
if (!speaking)
if(!other)
return 1
return TRUE
if(other.universal_speak)
return 1
return TRUE
if(isAI(src) && ispAI(other))
return 1
return TRUE
if (istype(other, src.type) || istype(src, other.type))
return 1
return 0
return TRUE
return FALSE
if(speaking.flags & INNATE)
return 1
return TRUE
//Language check.
for(var/datum/language/L in src.languages)
if(speaking.name == L.name)
return 1
return TRUE
return 0
return FALSE
/*
***Deprecated***