Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offline mob/player indicator #18707

Closed
wants to merge 1 commit into from
Closed

offline mob/player indicator #18707

wants to merge 1 commit into from

Conversation

Xkeeper0
Copy link
Contributor

@Xkeeper0 Xkeeper0 commented May 2, 2024

About the PR

image image

adds a little indicator for people who have disconnected.

(after a few minutes it dims a bit to show they've been off for a while)

Why's this needed?

there's nothing like walking up to someone and going *wave howdy partner! how's it going! and then you notice they're not actually there and likely haven't been for the last 30 minutes. this solves that.

Changelog

(u)Zamujasa
(*)Players who disconnect now have a little "Zz" over their head.

@boring-cyborg boring-cyborg bot added the C-Sprites Automatically applied on any .dmi or icons folder change label May 2, 2024
@github-actions github-actions bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 2, 2024
@goonstation-issuebot goonstation-issuebot added the S-Testmerged [Dev Only] Testmerged for extended testing (applied by bot) label May 2, 2024
@Xkeeper0 Xkeeper0 added C-QoL A quality of life improvement that makes the game easier to play A-UI Modifies UI in some way. Automatically applied on a change to tgui/ labels May 2, 2024
@DisturbHerb
Copy link
Contributor

Kinda disagree with it being neon green, even if it pops out a lot easier from the background. Just a personal aesthetic quibble, but on the whole good feature.

@Sbmhawk
Copy link
Contributor

Sbmhawk commented May 2, 2024

^ I think light blue would be better personally

@Xkeeper0
Copy link
Contributor Author

Xkeeper0 commented May 2, 2024

this is 100% programmer art, haha. some kind of light blue will probably be better

@Glamurio
Copy link
Contributor

Glamurio commented May 2, 2024

Yes, this, please. This is genius.

@TobleroneSwordfish
Copy link
Contributor

I don't really like this because it's very meta and breaks a lot of admin gimmicks, buuut if we're going to have it then it should at least only be for humans so it doesn't mess with AIs, critters etc.

@Xkeeper0
Copy link
Contributor Author

Xkeeper0 commented May 2, 2024

the admin gimmicks thing is something that would be nice to change (could be like checking if the last ckey is an admin i guess)

it shouldn't mess with ais or critters other than showing when a living player was inside of it and no longer is, which i'm having trouble thinking of examples of this happening outside of disconnects. there's a "bug" where an ai that deploys to a shell makes the core show "Zz", but that one isn't intentional

it is very meta, though, and that's the intent -- helping people not have to alt-click on every person before they try interacting only to find out the person is offline

Copy link
Contributor

@Sovexe Sovexe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of these checks aren't needed and can be done away with a simple guard in logout on the mobs key which is only cleared on disconnect and not mob swap.

don't really need mutable appearances over images as you aren't actually doing any image manipulation to optimize in the first place. While they would work, this is only due to them being child types of image objects which should not be relied upon for future versions per the byond docs (yes I know we do rely on it elsewhere...one day it very well could bite us...)

instead of a signal we can just override death

art should also change imo, not big on static green Z's

@@ -37,6 +37,7 @@

var/move_laying = null
var/has_typing_indicator = FALSE
var/has_offline_indicator = FALSE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var/has_offline_indicator = FALSE

Comment on lines +1 to +77
#define OFFLINE_OVERLAY_KEY "offline_indicator"

// Singletons for offline indicators
// "this looks like the typing indicators" yes, and
var/mutable_appearance/offline_indicator = mutable_appearance('icons/mob/overhead_icons32x48.dmi', "offline")
var/mutable_appearance/offline_a_while_indicator = mutable_appearance('icons/mob/overhead_icons32x48.dmi', "offline_a_while")
/mob/proc/create_offline_indicator()
return

/mob/proc/remove_offline_indicator()
return

/mob/Login()
remove_offline_indicator()
. = ..()

/mob/living/Logout()
create_offline_indicator()
. = ..()


/mob/living/create_offline_indicator(force = FALSE)
// the only people who get offline indicators are
// - living
// - alive
// - has a ckey
if (!src.has_offline_indicator && isalive(src) && src.last_ckey != null)

if (!force)
// bodies of currently-virtual people don't count either
if (src.network_device)
return
// ai mainframes don't count, either.
// "ismainframe()"? no. totally different thing.
else if (istype(src, /mob/living/silicon/ai))
var/mob/living/silicon/ai/AI = src
if (AI.deployed_to_eyecam || AI.deployed_shell) // are you just moving elsewhere?
return // you arent disconnected, get outta here

else if (src.ckey)
// if you have a ckey still you're offline for real.
// check if you're an ai, since you deploy to shells and eyes
var/mob/living/silicon/ai/AI
if (isAIeye(src))
var/mob/living/intangible/aieye/EYE = src
AI = EYE.mainframe
else if (issilicon(src))
var/mob/living/silicon/S = src
AI = S.mainframe
if (AI)
// if you disconnect while in a shell or eye,
// update the ai mainframe to show you're out
AI.create_offline_indicator(TRUE)

if (isvirtual(src))
var/mob/living/carbon/human/virtual/V = src
V.body.create_offline_indicator(TRUE)

src.has_offline_indicator = TRUE
src.logout_at = TIME
var/logout_check = src.logout_at
src.UpdateOverlays(offline_indicator, OFFLINE_OVERLAY_KEY)
RegisterSignal(src, COMSIG_MOB_DEATH, PROC_REF(remove_offline_indicator))

SPAWN(5 MINUTES)
// check if they're still logged out after a while and update the overlay
if (src.has_offline_indicator == TRUE && logout_check == src.logout_at)
src.UpdateOverlays(offline_a_while_indicator, OFFLINE_OVERLAY_KEY)

/mob/living/remove_offline_indicator()
if (src.has_offline_indicator)
src.has_offline_indicator = FALSE
UnregisterSignal(src, COMSIG_MOB_DEATH)
src.UpdateOverlays(null, OFFLINE_OVERLAY_KEY)


#undef OFFLINE_OVERLAY_KEY
Copy link
Contributor

@Sovexe Sovexe May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define OFFLINE_OVERLAY_KEY "offline_indicator"
// Singletons for offline indicators
// "this looks like the typing indicators" yes, and
var/mutable_appearance/offline_indicator = mutable_appearance('icons/mob/overhead_icons32x48.dmi', "offline")
var/mutable_appearance/offline_a_while_indicator = mutable_appearance('icons/mob/overhead_icons32x48.dmi', "offline_a_while")
/mob/proc/create_offline_indicator()
return
/mob/proc/remove_offline_indicator()
return
/mob/Login()
remove_offline_indicator()
. = ..()
/mob/living/Logout()
create_offline_indicator()
. = ..()
/mob/living/create_offline_indicator(force = FALSE)
// the only people who get offline indicators are
// - living
// - alive
// - has a ckey
if (!src.has_offline_indicator && isalive(src) && src.last_ckey != null)
if (!force)
// bodies of currently-virtual people don't count either
if (src.network_device)
return
// ai mainframes don't count, either.
// "ismainframe()"? no. totally different thing.
else if (istype(src, /mob/living/silicon/ai))
var/mob/living/silicon/ai/AI = src
if (AI.deployed_to_eyecam || AI.deployed_shell) // are you just moving elsewhere?
return // you arent disconnected, get outta here
else if (src.ckey)
// if you have a ckey still you're offline for real.
// check if you're an ai, since you deploy to shells and eyes
var/mob/living/silicon/ai/AI
if (isAIeye(src))
var/mob/living/intangible/aieye/EYE = src
AI = EYE.mainframe
else if (issilicon(src))
var/mob/living/silicon/S = src
AI = S.mainframe
if (AI)
// if you disconnect while in a shell or eye,
// update the ai mainframe to show you're out
AI.create_offline_indicator(TRUE)
if (isvirtual(src))
var/mob/living/carbon/human/virtual/V = src
V.body.create_offline_indicator(TRUE)
src.has_offline_indicator = TRUE
src.logout_at = TIME
var/logout_check = src.logout_at
src.UpdateOverlays(offline_indicator, OFFLINE_OVERLAY_KEY)
RegisterSignal(src, COMSIG_MOB_DEATH, PROC_REF(remove_offline_indicator))
SPAWN(5 MINUTES)
// check if they're still logged out after a while and update the overlay
if (src.has_offline_indicator == TRUE && logout_check == src.logout_at)
src.UpdateOverlays(offline_a_while_indicator, OFFLINE_OVERLAY_KEY)
/mob/living/remove_offline_indicator()
if (src.has_offline_indicator)
src.has_offline_indicator = FALSE
UnregisterSignal(src, COMSIG_MOB_DEATH)
src.UpdateOverlays(null, OFFLINE_OVERLAY_KEY)
#undef OFFLINE_OVERLAY_KEY
#define OFFLINE_OVERLAY_KEY "offline_indicator"
// Singletons for offline indicators
var/image/offline_indicator = image('icons/mob/overhead_icons32x48.dmi', "offline")
var/image/offline_a_while_indicator = image('icons/mob/overhead_icons32x48.dmi', "offline_a_while")
/mob/proc/create_offline_indicator()
return
/mob/proc/remove_offline_indicator()
return
/mob/Login()
src.ClearSpecificOverlays(OFFLINE_OVERLAY_KEY)
. = ..()
/mob/living/Logout()
if (key) //disconnected clients don't wipe key. Mobswaps do.
create_offline_indicator()
. = ..()
/mob/death()
src.ClearSpecificOverlays(OFFLINE_OVERLAY_KEY)
. = ..()
/mob/living/create_offline_indicator(force = FALSE)
set waitfor = FALSE
if (isalive(src) || force)
var/mob/living/silicon/ai/AI
if (isAIeye(src))
var/mob/living/intangible/aieye/EYE = src
AI = EYE.mainframe
else if (issilicon(src))
var/mob/living/silicon/S = src
AI = S.mainframe
if (AI)
// if you disconnect while in a shell or eye,
// update the ai mainframe to show you're out
AI.create_offline_indicator(TRUE)
if (isvirtual(src))
var/mob/living/carbon/human/virtual/V = src
V.body.create_offline_indicator(TRUE)
//used to protect against rejoins and leaves from erroneously triggering long logout
src.logout_at = TIME
var/logout_check = src.logout_at
src.UpdateOverlays(offline_indicator, OFFLINE_OVERLAY_KEY)
SPAWN(5 MINUTES)
if (QDELETED(src)) return
// check if they're still logged out after a while and update the overlay
if (!client && key && logout_check == src.logout_at)
src.UpdateOverlays(offline_a_while_indicator, OFFLINE_OVERLAY_KEY)
#undef OFFLINE_OVERLAY_KEY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Modifies UI in some way. Automatically applied on a change to tgui/ C-QoL A quality of life improvement that makes the game easier to play C-Sprites Automatically applied on any .dmi or icons folder change size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants