Skip to content

Commit

Permalink
Succumb Code Touchup (#3711)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Touches up saycode related to succumbing just a little bit. Originally
was intended to actually solve a problem, but it didn't, and I figured
it was fine to add the tweaks I made anyways for the hell of it.

Also made the dramatic "last words" screen text a bit more consistent.
Yes, I know it was for drama reasons, but this is far better than having
to use an entire get_hearers call for it, and I doubt anyone will notice
a difference.

## Why It's Good For The Game
Succumb code was kind of a mess, so I cleaned it up. Honestly, I don't
think this should be in say() at all, but hey, I just work here.

## Changelog

:cl:
tweak: Whispering (as in, directly using the verb or typing `#` before
your message) will now skip the succumb confirmation prompt, while
normal talking will still continue to prompt if you want to succumb.
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
MarkSuckerberg authored Nov 14, 2024
1 parent c4bab6d commit cb28fae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
6 changes: 4 additions & 2 deletions code/_onclick/hud/alert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,11 @@ or shoot a gun to move around via Newton's 3rd Law of Motion."
return

if (length(last_whisper))
living_owner.dying_breath("[last_whisper]")
living_owner.say("#[last_whisper]")
living_owner.succumb(whispered = length(last_whisper) > 0)
//Say handles everything else for us
return

living_owner.succumb(FALSE)

//ALIENS

Expand Down
55 changes: 25 additions & 30 deletions code/modules/mob/living/living_say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
"÷" = MODE_VOCALCORDS
))

/mob/living/proc/Ellipsis(original_msg, chance = 50, keep_words)
/mob/living/proc/ellipsis(original_msg, chance = 50, keep_words)
if(chance <= 0)
return "..."
if(chance >= 100)
Expand All @@ -79,7 +79,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(

return new_msg

/mob/living/say(message, bubble_type,list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null)
/mob/living/say(message, bubble_type, list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null)
var/ic_blocked = FALSE
if(client && !forced && CHAT_FILTER_CHECK(message))
//The filter doesn't act on the sanitized message, but the raw message.
Expand Down Expand Up @@ -112,9 +112,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
client?.dsay(message)
return

// dead is the only state you can never emote
if(stat != DEAD && check_emote(original_message, forced))
return
var/succumbed = FALSE

switch(stat)
if(SOFT_CRIT)
Expand All @@ -123,12 +121,26 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
if(!(message_mods[MODE_CHANGELING] || message_mods[MODE_ALIEN]))
return
if(HARD_CRIT)
if(!(message_mods[WHISPER_MODE] || message_mods[MODE_CHANGELING] || message_mods[MODE_ALIEN]))
if(!(message_mods[MODE_CHANGELING] || message_mods[MODE_ALIEN]))
// If we cut our message short, abruptly end it with a-..
var/message_len = length_char(message)
var/health_diff = round(-HEALTH_THRESHOLD_DEAD + health)
message = copytext_char(message, 1, health_diff) + (message_len > health_diff ? "-.." : "...")
message = ellipsis(message, 10, 1)

//If the player didn't voluntarily whisper, we'll ask them to confirm their dying words
if(!message_mods[WHISPER_MODE] && (tgui_alert(src, "Your dying words will be \"[message]\", continue?", "Succumb", list("Cancel", "Continue"), 15 SECONDS) != "Continue"))
return

message_mods[WHISPER_MODE] = MODE_WHISPER_CRIT
succumbed = TRUE
if(DEAD)
say_dead(original_message)
return

if(check_emote(original_message, forced))
return

if(client && SSlag_switch.measures[SLOWMODE_SAY] && !HAS_TRAIT(src, TRAIT_BYPASS_MEASURES) && !forced && src == usr)
if(!COOLDOWN_FINISHED(client, say_slowmode))
to_chat(src, span_warning("Message not sent due to slowmode. Please wait [SSlag_switch.slowmode_cooldown/10] seconds between messages.\n\"[message]\""))
Expand All @@ -149,33 +161,20 @@ GLOBAL_LIST_INIT(department_radio_keys, list(

var/message_range = 7

var/succumbed = FALSE

if(message_mods[MODE_CUSTOM_SAY_EMOTE])
log_message(message_mods[MODE_CUSTOM_SAY_EMOTE], LOG_RADIO_EMOTE)

if(!message_mods[MODE_CUSTOM_SAY_ERASE_INPUT])
if(message_mods[WHISPER_MODE])
//Final words (MODE_WHISPER_CRIT) are already obfuscated, let them have full range
if(message_mods[WHISPER_MODE] == MODE_WHISPER)
if(saymode || message_mods[RADIO_EXTENSION]) //no radio while in crit
saymode = null
message_mods -= RADIO_EXTENSION
message_range = 1
var/logged_message = message
if(stat == HARD_CRIT) //This is cheaper than checking for MODE_WHISPER_CRIT message mod
var/health_diff = round(-HEALTH_THRESHOLD_DEAD + health)
// If we cut our message short, abruptly end it with a-..
var/message_len = length_char(message)
message = copytext_char(message, 1, health_diff) + "[message_len > health_diff ? "-.." : "..."]"
message = Ellipsis(message, 10, 1)
last_words = message
var/final_warning = alert(usr, "Your dying words will be \"[last_words]\", continue?", "Succumb", "Cancel", "Continue")
if(final_warning == "Cancel" || QDELETED(src))
return
message_mods[WHISPER_MODE] = MODE_WHISPER_CRIT
succumbed = TRUE
src.log_talk(logged_message, LOG_WHISPER, custom_say_emote = message_mods[MODE_CUSTOM_SAY_EMOTE])
src.log_talk(logged_message, LOG_WHISPER, forced_by = forced, custom_say_emote = message_mods[MODE_CUSTOM_SAY_EMOTE])
else
src.log_talk(message, LOG_SAY, forced_by=forced, custom_say_emote = message_mods[MODE_CUSTOM_SAY_EMOTE])
src.log_talk(message, LOG_SAY, forced_by = forced, custom_say_emote = message_mods[MODE_CUSTOM_SAY_EMOTE])

message = treat_message(message) // unfortunately we still need this
var/sigreturn = SEND_SIGNAL(src, COMSIG_MOB_SAY, args)
Expand Down Expand Up @@ -226,9 +225,8 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
send_speech(message, message_range, src, bubble_type, spans, language, message_mods)

if(succumbed)
succumb(1)
succumb(TRUE)
to_chat(src, compose_message(src, language, message, , spans, message_mods))
dying_breath(message)

return 1

Expand All @@ -249,6 +247,8 @@ GLOBAL_LIST_INIT(department_radio_keys, list(

// Create map text prior to modifying message for goonchat
if (client?.prefs.chat_on_map && !(stat == UNCONSCIOUS || stat == HARD_CRIT) && (client.prefs.see_chat_non_mob || ismob(speaker)) && can_hear())
if(message_mods[MODE_WHISPER] == MODE_WHISPER_CRIT)
play_screen_text("<i>message</i>")
if(message_mods[MODE_CUSTOM_SAY_ERASE_INPUT])
create_chat_message(speaker, null, message_mods[MODE_CUSTOM_SAY_EMOTE], spans, EMOTE_MESSAGE)
else
Expand Down Expand Up @@ -419,8 +419,3 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
if(get_minds && mind)
return mind.get_language_holder()
. = ..()

/mob/living/proc/dying_breath(message)
for(var/mob/M in get_hearers_in_view(7, src))
if(M.can_hear())
M.play_screen_text("<i>[message]")

0 comments on commit cb28fae

Please sign in to comment.