Skip to content

Commit

Permalink
vehicle compat pt 2
Browse files Browse the repository at this point in the history
  • Loading branch information
X0-11 committed Jun 18, 2023
1 parent c7f53b7 commit a7c6681
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
18 changes: 13 additions & 5 deletions code/datums/chatmessage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@
* * target - The target atom to display the overlay at
* * owner - The mob that owns this overlay, only this mob will be able to view it
* * extra_classes - Extra classes to apply to the span that holds the text
* * messageloc_override - Put the message above this item, instead.
* * lifespan - The lifespan of the message in deciseconds
*/
/datum/chatmessage/New(text, atom/target, mob/owner, list/extra_classes = null, lifespan = CHAT_MESSAGE_LIFESPAN)
/datum/chatmessage/New(text, atom/target, mob/owner, list/extra_classes = null, messageloc_override = null, lifespan = CHAT_MESSAGE_LIFESPAN)
. = ..()
if (!istype(target))
CRASH("Invalid target given for chatmessage")
if(QDELETED(owner) || !istype(owner) || !owner.client)
stack_trace("/datum/chatmessage created with [isnull(owner) ? "null" : "invalid"] mob owner")
qdel(src)
return
if(messageloc_override)
message_loc = messageloc_override
INVOKE_ASYNC(src, .proc/generate_image, text, target, owner, extra_classes, lifespan)

/datum/chatmessage/Destroy()
Expand Down Expand Up @@ -125,7 +128,8 @@
approx_lines = max(1, mheight / CHAT_MESSAGE_APPROX_LHEIGHT)

// Translate any existing messages upwards, apply exponential decay factors to timers
message_loc = target
if(!message_loc) //For overriding line in-vehicles and whatnot.
message_loc = target
if (owned_by.seen_messages)
var/idx = 1
var/combined_height = approx_lines
Expand Down Expand Up @@ -190,15 +194,19 @@
spans = spans?.Copy()

var/atom/movable/originalSpeaker = speaker
var/messageloc_override = null

// Ignore virtual speaker (most often radio messages) from ourself
if (originalSpeaker != src && speaker == src)
return
if(istype(speaker.loc,/obj/vehicles) || istype(speaker.loc,/obj/structure/closet))
speaker = originalSpeaker.loc
if(speaker.z != src.z) //We'll assume that speech from people we can't see is radio-speech.
return //They don't want to see non-z (radio) messages.

if(istype(originalSpeaker.loc,/obj/vehicles) || istype(originalSpeaker.loc,/obj/structure/closet))
messageloc_override = originalSpeaker.loc

// Display visual above source
new /datum/chatmessage(capitalize(raw_message), speaker, src, spans)
new /datum/chatmessage(capitalize(raw_message), speaker, src, spans, messageloc_override)


// Tweak these defines to change the available color ranges
Expand Down
7 changes: 3 additions & 4 deletions code/modules/mob/hear_say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@
else
if(language)
on_hear_say("<span class='game say'><span class='name'>[speaker_name]</span>[alt_name] [track][language.format_message(message, verb)]</span>")
if(speaker && speaker.z == src.z) //I don't think we should go through the whole rigamarole for people we can't even see or won't see any time soon.
if(speaker.client && speaker.client.prefs && !(speaker.client.prefs.chat_on_map))
return
create_chat_message(speaker, language, message, list(), null)
if(client && client.prefs && !(client.prefs.chat_on_map))
return
create_chat_message(speaker, language, message, list(), null)
else
on_hear_say("<span class='game say'><span class='name'>[speaker_name]</span>[alt_name] [track][verb], <span class='message'><span class='body'>\"[message]\"</span></span></span>")
if (speech_sound && (get_dist(speaker, src) <= world.view && src.z == speaker.z))
Expand Down

0 comments on commit a7c6681

Please sign in to comment.