Fixing positional custom emotes. (#9011)

* Fixing positional custom emotes.

* see_emote cleanup.

* Further refinement work on custom emotes.

* Cleaning up some custom_emote() calls.
This commit is contained in:
MistakeNot4892
2023-03-08 19:33:25 -08:00
committed by GitHub
parent 75577bd3ca
commit 642348983f
23 changed files with 99 additions and 113 deletions
+1 -1
View File
@@ -147,7 +147,7 @@ var/global/list/overminds = list()
//Handle nonverbal languages here
for(var/datum/multilingual_say_piece/S in message_pieces)
if(S.speaking.flags & NONVERBAL)
custom_emote(1, "[pick(S.speaking.signlang_verb)].")
custom_emote(VISIBLE_MESSAGE, "[pick(S.speaking.signlang_verb)].")
for(var/mob/M in listening)
spawn()
+38 -47
View File
@@ -48,10 +48,6 @@
return custom_emote(m_type, message)
if(act == "custom")
if(!message)
message = sanitize(input("Enter an emote to display.") as text|null)
if(!message)
return
if (!m_type)
if(alert(src, "Is this an audible emote?", "Emote", "Yes", "No") == "No")
m_type = VISIBLE_MESSAGE
@@ -101,7 +97,7 @@
message = html_decode(message)
name_anchor = findtext(message, "*")
if(name_anchor > 0) // User supplied emote with visible_emote token (default ^)
if(name_anchor > 0) // User supplied emote with visible_emote token
pretext = copytext(message, 1, name_anchor)
subtext = copytext(message, name_anchor + 1, length(message) + 1)
else
@@ -145,60 +141,55 @@
set waitfor = FALSE // Due to input() below and this being used in Life() procs.
if((usr && stat) || (!use_me && usr == src))
if(stat != CONSCIOUS || (!use_me && usr == src))
to_chat(src, "You are unable to emote.")
return
var/input
if(!message)
input = sanitize(input(src,"Choose an emote to display.") as text|null)
else
input = message
message = input(usr, "Please enter an emote to display. You can use \"*\" to reposition your character name within the emote.") as text|null
// Recheck due to input()
if(stat != CONSCIOUS || (!use_me && usr == src))
to_chat(src, "You are unable to emote.")
return
message = sanitize(message, encode = FALSE) // This is getting double-encoded somewhere along the line.
if(!message)
return
var/turf/T = get_turf(src)
if(!T)
return
var/list/formatted
var/runemessage
if(input)
formatted = format_emote(src, message)
message = formatted["pretext"] + formatted["nametext"] + formatted["subtext"]
runemessage = formatted["subtext"]
// This is just personal preference (but I'm objectively right) that custom emotes shouldn't have periods at the end in runechat
runemessage = replacetext(runemessage,".","",length(runemessage),length(runemessage)+1)
formatted = format_emote(src, message)
var/pretext = formatted["pretext"]
var/nametext = formatted["nametext"]
var/subtext = formatted["subtext"]
if(pretext) // If we have a split emote we need to show the pretext and name.
runemessage = "[pretext][nametext][subtext]"
else
return
runemessage = subtext
// This is just personal preference (but I'm objectively right) that custom emotes shouldn't have periods at the end in runechat
runemessage = replacetext(runemessage,".","",length(runemessage),length(runemessage)+1)
if(input)
log_emote(message,src) //Log before we add junk
message = "<span class='emote'><B>[src]</B> [input]</span>"
else
return
log_emote("[pretext][nametext][subtext]", src) //Log before we add junk
message = encode_html_emphasis("<span class='emote'>[pretext]<b>[nametext]</b>[subtext]</span>")
if(message)
message = encode_html_emphasis(message)
// Hearing gasp and such every five seconds is not good emotes were not global for a reason.
// Maybe some people are okay with that.
var/turf/T = get_turf(src)
if(!T) return
var/list/in_range = get_mobs_and_objs_in_view_fast(T,range,2,remote_ghosts = client ? TRUE : FALSE)
var/list/m_viewers = in_range["mobs"]
var/list/o_viewers = in_range["objs"]
for(var/mob in m_viewers)
var/mob/M = mob
spawn(0) // It's possible that it could be deleted in the meantime, or that it runtimes.
if(M)
if(isobserver(M))
message = "<span class='emote'><B>[src]</B> ([ghost_follow_link(src, M)]) [input]</span>"
M.show_message(message, m_type)
M.create_chat_message(src, "[runemessage]", FALSE, list("emote"), (m_type == AUDIBLE_MESSAGE))
for(var/obj in o_viewers)
var/obj/O = obj
spawn(0)
if(O)
O.see_emote(src, message, m_type)
var/list/in_range = get_mobs_and_objs_in_view_fast(T,range,2,remote_ghosts = client ? TRUE : FALSE)
var/list/m_viewers = in_range["mobs"]
var/list/o_viewers = in_range["objs"]
for(var/mob/M as anything in m_viewers)
if(isobserver(M))
M.show_message("<span class='emote'>[pretext]<b>[ghost_follow_link(src, M, nametext)]</b>[subtext]</span>", m_type)
else
M.show_message(message, m_type)
M.create_chat_message(src, "[runemessage]", FALSE, list("emote"), (m_type == AUDIBLE_MESSAGE))
for(var/obj/O as anything in o_viewers)
O.see_emote(src, message, m_type)
// Specific mob type exceptions below.
/mob/living/carbon/human/emote(act, m_type, message)
-2
View File
@@ -89,9 +89,7 @@
for(var/datum/reagent/re in Bait.reagents.reagent_list)
if(re.id == "nutriment" || re.id == "protein" || re.id == "glucose" || re.id == "fishbait")
foodvolume += re.volume
toolspeed = initial(toolspeed) * min(0.75, (0.5 / max(0.5, (foodvolume / Bait.reagents.maximum_volume))))
else
toolspeed = initial(toolspeed)
+1 -1
View File
@@ -243,7 +243,7 @@
bitecount++
spawn(5)
if(!src && !user.client)
user.custom_emote(1,"[pick("burps", "cries for more", "burps twice", "looks at the area where the food was")]")
user.custom_emote(VISIBLE_MESSAGE,"[pick("burps", "cries for more", "burps twice", "looks at the area where the food was")]")
qdel(src)
if(!QDELETED(src))
On_Consume(user)
+4 -3
View File
@@ -864,9 +864,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(mind && mind.current)
return "|<a href='byond://?src=\ref[ghost];track=\ref[mind.current]'>body</a>"
/proc/ghost_follow_link(var/atom/target, var/atom/ghost)
if((!target) || (!ghost)) return
. = "<a href='byond://?src=\ref[ghost];track=\ref[target]'>follow</a>"
/proc/ghost_follow_link(var/atom/target, var/atom/ghost, var/link_text = "follow")
if(!target || !ghost)
return
. = "<a href='byond://?src=\ref[ghost];track=\ref[target]'>[link_text]</a>"
. += target.extra_ghost_link(ghost)
//Culted Ghosts
+2 -2
View File
@@ -27,7 +27,7 @@
/mob/living/bot/cleanbot/handleIdle()
if(!wet_floors && !spray_blood && vocal && prob(2))
custom_emote(2, "makes an excited booping sound!")
custom_emote(AUDIBLE_MESSAGE, "makes an excited booping sound!")
playsound(src, 'sound/machines/synth_yes.ogg', 50, 0)
if(wet_floors && prob(5)) // Make a mess
@@ -111,7 +111,7 @@
busy = 1
if(prob(20))
custom_emote(2, "begins to clean up \the [D]")
custom_emote(AUDIBLE_MESSAGE, "begins to clean up \the [D]")
update_icons()
var/cleantime = istype(D, /obj/effect/decal/cleanable/dirt) ? 10 : 50
if(do_after(src, cleantime))
+2 -2
View File
@@ -26,7 +26,7 @@
/mob/living/bot/cleanbot/edCLN/handleIdle()
if(vocal && prob(10))
custom_emote(2, "makes a less than thrilled beeping sound.")
custom_emote(AUDIBLE_MESSAGE, "makes a less than thrilled beeping sound.")
playsound(src, 'sound/machines/synth_yes.ogg', 50, 0)
if(red_switch && !blue_switch && !green_switch && prob(10) || src.emagged)
@@ -212,4 +212,4 @@
user.drop_item()
qdel(W)
user.drop_from_inventory(src)
qdel(src)
qdel(src)
+1 -1
View File
@@ -115,7 +115,7 @@
addTiles(1)
if(vocal && prob(1))
custom_emote(2, "makes an excited beeping sound!")
custom_emote(AUDIBLE_MESSAGE, "makes an excited beeping sound!")
playsound(src, 'sound/machines/twobeep.ogg', 50, 0)
/mob/living/bot/floorbot/handleAdjacentTarget()
+1 -1
View File
@@ -121,7 +121,7 @@
var/message = pick(message_options)
say(message)
playsound(src, message_options[message], 50, 0)
custom_emote(1, "points at [H.name].")
custom_emote(VISIBLE_MESSAGE, "points at [H.name].")
last_newpatient_speak = world.time
break
+3 -3
View File
@@ -188,13 +188,13 @@
update_icons()
/mob/living/bot/mulebot/handleFrustrated(has_target)
custom_emote(2, "makes a sighing buzz.")
custom_emote(AUDIBLE_MESSAGE, "makes a sighing buzz.")
playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0)
..()
/mob/living/bot/mulebot/handleAdjacentTarget()
if(target == src.loc)
custom_emote(2, "makes a chiming sound.")
custom_emote(AUDIBLE_MESSAGE, "makes a chiming sound.")
playsound(src, 'sound/machines/chime.ogg', 50, 0)
UnarmedAttack(target)
resetTarget()
@@ -283,7 +283,7 @@
return
if(crates_only && !istype(C,/obj/structure/closet/crate))
custom_emote(2, "makes a sighing buzz.")
custom_emote(AUDIBLE_MESSAGE, "makes a sighing buzz.")
playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 0)
return
+3 -3
View File
@@ -114,7 +114,7 @@
/mob/living/bot/secbot/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return
add_fingerprint(usr)
switch(action)
@@ -234,7 +234,7 @@
target = M
awaiting_surrender = 0
say("Level [threat] infraction alert!")
custom_emote(1, "points at [M.name]!")
custom_emote(VISIBLE_MESSAGE, "points at [M.name]!")
playsound(src, pick(threat_found_sounds), 50)
return
@@ -462,4 +462,4 @@
return
if(!in_range(src, user) && loc != user)
return
created_name = t
created_name = t
@@ -118,7 +118,7 @@
if(!(lying || resting))
if(limb_pain)
emote("scream")
custom_emote(1, "collapses!")
custom_emote(VISIBLE_MESSAGE, "collapses!")
Weaken(5) //can't emote while weakened, apparently.
/mob/living/carbon/human/proc/handle_grasp()
@@ -199,7 +199,7 @@
/mob/living/carbon/human/proc/set_gender(var/g)
if(g != gender)
gender = g
if(dna.GetUIState(DNA_UI_GENDER) ^ gender == FEMALE) // XOR will catch both cases where they do not match
dna.SetUIState(DNA_UI_GENDER, gender == FEMALE)
sync_organ_dna(dna)
sync_organ_dna(dna)
+2 -2
View File
@@ -153,7 +153,7 @@ var/global/list/channel_to_radio_key = new
//Maybe they are using say/whisper to do a quick emote, so do those
switch(copytext(message, 1, 2))
if("*") return emote(copytext(message, 2))
if("^") return custom_emote(1, copytext(message, 2))
if("^") return custom_emote(VISIBLE_MESSAGE, copytext(message, 2))
//Parse the radio code and consume it
if(message_mode)
@@ -264,7 +264,7 @@ var/global/list/channel_to_radio_key = new
//Handle nonverbal languages here
for(var/datum/multilingual_say_piece/S in message_pieces)
if(S.speaking.flags & NONVERBAL)
custom_emote(1, "[pick(S.speaking.signlang_verb)].")
custom_emote(VISIBLE_MESSAGE, "[pick(S.speaking.signlang_verb)].")
//These will contain the main receivers of the message
var/list/listening = list()
+3 -6
View File
@@ -99,12 +99,9 @@
if(M)
M.show_message(rendered, 2)
for(var/obj/O in o_viewers)
if(O == T)
continue
spawn(0)
if(O)
O.see_emote(src, message)
for(var/obj/O as anything in o_viewers)
if(O != T)
O.see_emote(src, message)
log_emote("(HPAD) [message]", src)
@@ -37,7 +37,7 @@
/mob/living/simple_mob/proc/do_help_interaction(var/atom/A)
if(isliving(A))
custom_emote(1,"[pick(friendly)] \the [A]!")
custom_emote(VISIBLE_MESSAGE,"[pick(friendly)] \the [A]!")
return TRUE
return FALSE
@@ -45,7 +45,7 @@
if(can_special_attack(A) && special_attack_target(A))
return
else if(melee_damage_upper == 0 && istype(A,/mob/living))
custom_emote(1,"[pick(friendly)] \the [A]!")
custom_emote(VISIBLE_MESSAGE,"[pick(friendly)] \the [A]!")
else
attack_target(A)
+1 -1
View File
@@ -46,7 +46,7 @@
return ..()
/mob/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
set waitfor = FALSE
if(!client && !teleop) return
if (type)
+2 -2
View File
@@ -137,7 +137,7 @@
desc += " This one has already been used."
cut_overlays()
target.adjust_nutrition(amount)
user.custom_emote(message = "connects \the [src] to [user == target ? "their" : "[target]'s"] charging port, expending it.")
user.custom_emote(VISIBLE_MESSAGE, "connects \the [src] to [user == target ? "their" : "[target]'s"] charging port, expending it.")
/obj/item/cell/emergency_light
name = "miniature power cell"
@@ -150,4 +150,4 @@
. = ..()
var/area/A = get_area(src)
if(!A.lightswitch || !A.light_power)
charge = 0 //For naturally depowered areas, we start with no power
charge = 0 //For naturally depowered areas, we start with no power