Merge pull request #12720 from timothyteakettle/eye-contact

port examines and eye contact
This commit is contained in:
silicons
2020-07-11 00:14:47 -07:00
committed by GitHub
10 changed files with 172 additions and 13 deletions
+2
View File
@@ -119,6 +119,8 @@
/// Messages currently seen by this client
var/list/seen_messages
///A lazy list of atoms we've examined in the last EXAMINE_MORE_TIME (default 1.5) seconds, so that we will call [atom/proc/examine_more()] instead of [atom/proc/examine()] on them when examining
var/list/recent_examines
///When was the last time we warned them about not cryoing without an ahelp, set to -5 minutes so that rounstart cryo still warns
var/cryo_warned = -5 MINUTES
+60 -9
View File
@@ -287,8 +287,14 @@ mob/visible_message(message, self_message, blind_message, vision_distance = DEFA
. = view(dist, src)
SEND_SIGNAL(src, COMSIG_MOB_FOV_VIEW, .)
//mob verbs are faster than object verbs. See https://secure.byond.com/forum/?post=1326139&page=2#comment8198716 for why this isn't atom/verb/examine()
/mob/verb/examinate(atom/A as mob|obj|turf in fov_view()) //It used to be oview(12), but I can't really say why
/**
* Examine a mob
*
* mob verbs are faster than object verbs. See
* [this byond forum post](https://secure.byond.com/forum/?post=1326139&page=2#comment8198716)
* for why this isn't atom/verb/examine()
*/
/mob/verb/examinate(atom/A as mob|obj|turf in view()) //It used to be oview(12), but I can't really say why
set name = "Examine"
set category = "IC"
@@ -296,18 +302,63 @@ mob/visible_message(message, self_message, blind_message, vision_distance = DEFA
// shift-click catcher may issue examinate() calls for out-of-sight turfs
return
if(is_blind(src))
if(is_blind())
to_chat(src, "<span class='warning'>Something is there but you can't see it!</span>")
return
face_atom(A)
var/flags = SEND_SIGNAL(src, COMSIG_MOB_EXAMINATE, A)
if(flags & COMPONENT_DENY_EXAMINATE)
if(flags & COMPONENT_EXAMINATE_BLIND)
to_chat(src, "<span class='warning'>Something is there but you can't see it!</span>")
return
var/list/result = A.examine(src)
var/list/result
if(client)
LAZYINITLIST(client.recent_examines)
if(isnull(client.recent_examines[A]) || client.recent_examines[A] < world.time)
result = A.examine(src)
client.recent_examines[A] = world.time + EXAMINE_MORE_TIME // set the value to when the examine cooldown ends
RegisterSignal(A, COMSIG_PARENT_QDELETING, .proc/clear_from_recent_examines, override=TRUE) // to flush the value if deleted early
addtimer(CALLBACK(src, .proc/clear_from_recent_examines, A), EXAMINE_MORE_TIME)
handle_eye_contact(A)
else
result = A.examine_more(src)
else
result = A.examine(src) // if a tree is examined but no client is there to see it, did the tree ever really exist?
to_chat(src, result.Join("\n"))
SEND_SIGNAL(src, COMSIG_MOB_EXAMINATE, A)
/mob/proc/clear_from_recent_examines(atom/A)
if(!client)
return
UnregisterSignal(A, COMSIG_PARENT_QDELETING)
LAZYREMOVE(client.recent_examines, A)
/**
* handle_eye_contact() is called when we examine() something. If we examine an alive mob with a mind who has examined us in the last second within 5 tiles, we make eye contact!
*
* Note that if either party has their face obscured, the other won't get the notice about the eye contact
* Also note that examine_more() doesn't proc this or extend the timer, just because it's simpler this way and doesn't lose much.
* The nice part about relying on examining is that we don't bother checking visibility, because we already know they were both visible to each other within the last second, and the one who triggers it is currently seeing them
*/
/mob/proc/handle_eye_contact(mob/living/examined_mob)
return
/mob/living/handle_eye_contact(mob/living/examined_mob)
if(!istype(examined_mob) || src == examined_mob || examined_mob.stat >= UNCONSCIOUS || !client || !examined_mob.client?.recent_examines || !(src in examined_mob.client.recent_examines))
return
if(get_dist(src, examined_mob) > EYE_CONTACT_RANGE)
return
var/mob/living/carbon/examined_carbon = examined_mob
// check to see if their face is blocked (or if they're not a carbon, in which case they can't block their face anyway)
if(!istype(examined_carbon) || (!(examined_carbon.wear_mask && examined_carbon.wear_mask.flags_inv & HIDEFACE) && !(examined_carbon.head && examined_carbon.head.flags_inv & HIDEFACE)))
if(SEND_SIGNAL(src, COMSIG_MOB_EYECONTACT, examined_mob, TRUE) != COMSIG_BLOCK_EYECONTACT)
var/msg = "<span class='smallnotice'>You make eye contact with [examined_mob].</span>"
addtimer(CALLBACK(GLOBAL_PROC, .proc/to_chat, src, msg), 3) // so the examine signal has time to fire and this will print after
var/mob/living/carbon/us_as_carbon = src // i know >casting as subtype, but this isn't really an inheritable check
if(!istype(us_as_carbon) || (!(us_as_carbon.wear_mask && us_as_carbon.wear_mask.flags_inv & HIDEFACE) && !(us_as_carbon.head && us_as_carbon.head.flags_inv & HIDEFACE)))
if(SEND_SIGNAL(examined_mob, COMSIG_MOB_EYECONTACT, src, FALSE) != COMSIG_BLOCK_EYECONTACT)
var/msg = "<span class='smallnotice'>[src] makes eye contact with you.</span>"
addtimer(CALLBACK(GLOBAL_PROC, .proc/to_chat, examined_mob, msg), 3)
//same as above
//note: ghosts can point, this is intended
+3
View File
@@ -96,6 +96,9 @@
else
. += "<span class='warning'>You're too far away to read it!</span>"
/obj/item/paper/examine_more(mob/user)
ui_interact(user)
/obj/item/paper/proc/show_content(mob/user)
user.examinate(src)