Files
Paradise/code/modules/mob/say.dm
Luc 747d8111ca Datumized Emotes (#17544)
* Add raw tg emote datums

* Some more initial implementation

* First (big) commit

* More reworks, most emotes seem to work but cooldowns are weird

* Add the remaining emote species

* Add simple mobs

* Update defines, add more comments

* Remove unnecessary intentional calls

* Fix some bugs, add more functionality
- Silicon mobs/bots can't use all the living emotes
- Sound volume can now be specified for emotes
- Added a define for emotes to not go thru runechat
- Reorganized some emotes
- Some human emotes that need breath will gasp
- IPCs can beep boop
- Restore power warn for robits
- Sneezing and coughing have sound effects

* Fixes emote species separation not working in *help

* Reorganize emotes based on what's available on paradise

* mouthful mode

* Update implants to use emote signals

* Update species whitelist to use a typecache

* Cleanups

* More small changes
- Remove old extraneous typecache
- Reconfigure drask emotes
- Make all mime emotes visible (since they're silent)

* Remove old emote functions

* Update emote sounds, volume

* Rework more emotes into EMOTE_VISIBLE

* *rumble*

* More slight testing and cleanup
- Drop audio emote cooldown from 10 to 5 seconds
- Change clapping behaivor slightly, putting it into run_emote
- Update some emote flags here and there
- Fix up johnny, though remind me why this one exists?

* Fix indentation, missing typecast

* fix some returns

* More review

* Rename emote files

* Add'l review

* Even more emote fixes!

- Move defines out into an emote define file
- Integrate audio and general emote cooldowns
- change some 1 and 2 into visible/audible
- Try to fix monkey screech

* Add ability for admins to mute users' emotes.

* Rename cooldowns, add general mob emote cooldown.

* Fix flip not always geting the right message

* Add some emote target handling, docs

* Fix admin rights, indentation

* Update emote.dm

set default mode to ANY

* General implant fixes

- The way implant triggers are handled is now improved, with separate checks for death and emotes instead of just checking deathgasp.
- Implants can choose to be triggered for the first death or for every death.
- Voice of God play dead now activates sad trombone

read: voice of god can now no longer lowtiergod nukies

* Bunch of other changes and bugfixes

- Adds number flag for behavior
- Reworks how muzzling/vocalizing emotes works
- Breaks out sound effects
- Drops cooldown to 1.5s

* Fix people being able to snore/nightmare while awake.

* Bump paralysis on living emotes

* First review pass

* Clean up implants (while we're here) and fix compile errors

* in living error

* More outstanding review fixes

* use more isx() checks

* Add pre-emote signal, try_run_emote()

* Prevent silicons from playing their deathgasp multiple times

* Add emote postfix behavior for adding parameters to non-message params.

Also adds a signal to intercept emote actions.

* Fix linter complaints

* Remove new player checks on GLOB.dead_mob_list

* Fix species emotes not being distinguished, remove weird legacy code

* monkey ball

* better docs == better code

* Fix audio cooldown, silicon emotes

* Fix ghost emotes (don't worry they're staying)

* Restore spin to 2 seconds

* oh johnny boy

* Make fainting last two seconds instead of .2 seconds

* Remove extra highfive message

* Tick friendly emotes

* Fix up friendly emotes, ghost emotes

* Add some emote message safeguards, prevent flip from showing twice

* Fix ghost vision message format

* Fix hands_use_check on non-carbon mobs

* Bring emotes in line with say re. oxyloss

* Add option for death implants to not trigger on gib

* Try adding some unit testing

* Include emote unit tests

* More attempts at unit testing

* More attempts at unit testing?

* forget it this is fine

* Housekeeping

* Little bit more

* Remove extra bolding from ghostsight emotes

* More sanity checks, fix snore

* Remove stack trace when unintentional emote fails

* Update code/modules/mob/living/silicon/silicon_emote.dm

oops

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

* More implant cleanups

* Oh I missed this

* Silence wagging, more review fixes

* Oops 2

* ensure everything can swear

* High-five fixes and status effect stuff
- Adds new on_timeout() function that gets triggered when a status effect expires
- Fixes up passing arguments to status effects
- Ensures high-five explosions don't kill the wizards

* More review stuff
- Add a stat to text to make things easier
- Make it harder to delete emotes
- BIG DANGER
- pose can no longer be set while unconscious

* Remove extra high five logic, godmode changes

* forgor

* Fix gasp not working

* Update docs for good measure

* Some review and custom emote fixes

* Fixes death alarms being broken

* Better handle stat_allowed, more review comments.

* ..() conventions

* This is why unit tests are nice

* Remove drone snowflake emote stuff

* Linting

* No more flipping on the ground

* Snap doesn't require hands free

* Does it make complete sense? no, but it's Fun

* Apply suggestions from code review

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

* Fix revenant messages, power warning

* epic webedit fail, laugh at this user

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
2022-06-14 23:06:24 +01:00

228 lines
7.6 KiB
Plaintext

#define ILLEGAL_CHARACTERS_LIST list("<" = "", ">" = "", \
"\[" = "", "]" = "", "{" = "", "}" = "")
#define USABLE_DEAD_EMOTES list("*flip", "*spin")
/mob/proc/say()
return
/mob/verb/whisper(message as text)
set name = "Whisper"
set category = "IC"
return
/mob/verb/say_verb(message as text)
set name = "Say"
set category = "IC"
//Let's try to make users fix their errors - we try to detect single, out-of-place letters and 'unintended' words
/*
var/first_letter = copytext(message,1,2)
if((copytext(message,2,3) == " " && first_letter != "I" && first_letter != "A" && first_letter != ";") || cmptext(copytext(message,1,5), "say ") || cmptext(copytext(message,1,4), "me ") || cmptext(copytext(message,1,6), "looc ") || cmptext(copytext(message,1,5), "ooc ") || cmptext(copytext(message,2,6), "say "))
var/response = alert(usr, "Do you really want to say this using the *say* verb?\n\n[message]\n", "Confirm your message", "Yes", "Edit message", "No")
if(response == "Edit message")
message = input(usr, "Please edit your message carefully:", "Edit message", message)
if(!message)
return
else if(response == "No")
return
*/
message = replace_characters(message, ILLEGAL_CHARACTERS_LIST)
set_typing_indicator(FALSE)
usr.say(message)
/mob/verb/me_verb(message as text)
set name = "Me"
set category = "IC"
message = strip_html_properly(message)
set_typing_indicator(FALSE, TRUE)
if(use_me)
custom_emote(usr.emote_type, message, intentional = TRUE)
else
usr.emote(message, intentional = TRUE)
/mob/proc/say_dead(message)
if(client)
if(!check_rights(R_ADMIN, FALSE))
if(!GLOB.dsay_enabled)
to_chat(src, "<span class='danger'>Deadchat is globally muted.</span>")
return
if(check_mute(client.ckey, MUTE_DEADCHAT))
to_chat(src, "<span class='warning'>You cannot talk in deadchat (muted).</span>")
return
if(!(client.prefs.toggles & PREFTOGGLE_CHAT_DEAD))
to_chat(src, "<span class='danger'>You have deadchat muted.</span>")
return
if(client.handle_spam_prevention(message, MUTE_DEADCHAT))
return
if(message in USABLE_DEAD_EMOTES)
emote(copytext(message, 2), intentional = TRUE)
log_emote(message, src)
create_log(DEADCHAT_LOG, message)
return
say_dead_direct("[pick("complains", "moans", "whines", "laments", "blubbers", "salts")], <span class='message'>\"[message]\"</span>", src)
create_log(DEADCHAT_LOG, message)
log_ghostsay(message, src)
/mob/proc/say_understands(mob/other, datum/language/speaking = null)
if(stat == DEAD)
return 1
//Universal speak makes everything understandable, for obvious reasons.
if(universal_speak || universal_understand)
return 1
//Languages are handled after.
if(!speaking)
if(!other)
return 1
if(other.universal_speak)
return 1
if(isAI(src) && ispAI(other))
return 1
if(istype(other, src.type) || istype(src, other.type))
return 1
return 0
if(speaking.flags & INNATE)
return 1
//Language check.
for(var/datum/language/L in languages)
if(speaking.name == L.name)
return 1
return 0
/mob/proc/say_quote(message, datum/language/speaking = null)
var/verb = "says"
var/ending = copytext(message, length(message))
if(speaking)
verb = speaking.get_spoken_verb(ending)
else
if(ending == "!")
verb = pick("exclaims", "shouts", "yells")
else if(ending == "?")
verb = "asks"
return verb
/mob/proc/get_ear()
// returns an atom representing a location on the map from which this
// mob can hear things
// should be overloaded for all mobs whose "ear" is separate from their "mob"
return get_turf(src)
/proc/say_test(text)
var/ending = copytext(text, length(text))
if(ending == "?")
return "1"
else if(ending == "!")
return "2"
return "0"
//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.
//standard mode is the mode returned for the special ';' radio code.
/mob/proc/parse_message_mode(message, standard_mode = "headset")
if(length(message) >= 1 && copytext(message, 1, 2) == ";")
return standard_mode
if(length(message) >= 2)
var/channel_prefix = copytext(message, 1 ,3)
return GLOB.department_radio_keys[channel_prefix]
return null
/datum/multilingual_say_piece
var/datum/language/speaking = null
var/message = ""
/datum/multilingual_say_piece/New(datum/language/new_speaking, new_message)
. = ..()
speaking = new_speaking
if(new_message)
message = new_message
/mob/proc/find_valid_prefixes(message)
var/list/prefixes = list() // [["Common", start, end], ["Gutter", start, end]]
for(var/i in 1 to length(message))
var/selection = trim_right(lowertext(copytext(message, i, i + 3)))
var/datum/language/L = GLOB.language_keys[selection]
if(L != null && can_speak_language(L)) // What the fuck... remove the L != null check if you ever find out what the fuck is adding `null` to the languages list on absolutely random mobs... seriously what the hell...
prefixes[++prefixes.len] = list(L, i, i + length(selection))
else if(!L && i == 1)
prefixes[++prefixes.len] = list(get_default_language(), i, i)
else
return prefixes
/proc/strip_prefixes(message)
. = ""
var/last_index = 1
for(var/i in 1 to length(message))
var/selection = trim_right(lowertext(copytext(message, i, i + 3)))
var/datum/language/L = GLOB.language_keys[selection]
if(L)
. += copytext(message, last_index, i)
last_index = i + 3
if(i + 1 > length(message))
. += copytext(message, last_index)
// this returns a structured message with language sections
// list(/datum/multilingual_say_piece(common, "hi"), /datum/multilingual_say_piece(farwa, "squik"), /datum/multilingual_say_piece(common, "meow!"))
/mob/proc/parse_languages(message)
. = list()
// Noise language is a snowflake
if(copytext(message, 1, 2) == "!" && length(message) > 1)
return list(new /datum/multilingual_say_piece(GLOB.all_languages["Noise"], trim(strip_prefixes(copytext(message, 2)))))
// Scan the message for prefixes
var/list/prefix_locations = find_valid_prefixes(message)
if(!LAZYLEN(prefix_locations)) // There are no prefixes... or at least, no _valid_ prefixes.
. += new /datum/multilingual_say_piece(get_default_language(), trim(strip_prefixes(message))) // So we'll just strip those pesky things and still make the message.
for(var/i in 1 to length(prefix_locations))
var/current = prefix_locations[i] // ["Common", keypos]
// There are a few things that will make us want to ignore all other languages in - namely, HIVEMIND languages.
var/datum/language/L = current[1]
if(L && L.flags & HIVEMIND)
. = new /datum/multilingual_say_piece(L, trim(strip_prefixes(message)))
break
if(i + 1 > length(prefix_locations)) // We are out of lookaheads, that means the rest of the message is in cur lang
var/spoke_message = handle_autohiss(trim(copytext(message, current[3])), L)
. += new /datum/multilingual_say_piece(current[1], spoke_message)
else
var/next = prefix_locations[i + 1] // We look ahead at the next message to see where we need to stop.
var/spoke_message = handle_autohiss(trim(copytext(message, current[3], next[2])), L)
. += new /datum/multilingual_say_piece(current[1], spoke_message)
/* These are here purely because it would be hell to try to convert everything over to using the multi-lingual system at once */
/proc/message_to_multilingual(message, datum/language/speaking = null)
. = list(new /datum/multilingual_say_piece(speaking, message))
/proc/multilingual_to_message(list/message_pieces)
. = ""
for(var/datum/multilingual_say_piece/S in message_pieces)
. += S.message + " "
. = trim_right(.)
#undef USABLE_DEAD_EMOTES
#undef ILLEGAL_CHARACTERS_LIST