From 67c09b497fb282a7edffd21abcb92ee288fd5e83 Mon Sep 17 00:00:00 2001 From: Ryll Ryll <3589655+Ryll-Ryll@users.noreply.github.com> Date: Mon, 5 Apr 2021 08:17:38 -0400 Subject: [PATCH] Stripping a disconnected player will tell them when they come back (#58129) --- code/__DEFINES/inventory.dm | 12 +++++++ code/datums/elements/strippable.dm | 14 +++++++++ .../mob/living/carbon/human/human_defines.dm | 2 ++ code/modules/mob/living/carbon/human/login.dm | 31 +++++++++++++++++++ tgstation.dme | 1 + 5 files changed, 60 insertions(+) create mode 100644 code/modules/mob/living/carbon/human/login.dm diff --git a/code/__DEFINES/inventory.dm b/code/__DEFINES/inventory.dm index ae88dd313b7..ed6b9b73fee 100644 --- a/code/__DEFINES/inventory.dm +++ b/code/__DEFINES/inventory.dm @@ -137,6 +137,18 @@ #define TINT_DARKENED 2 //Threshold of tint level to apply weld mask overlay #define TINT_BLIND 3 //Threshold of tint level to obscure vision fully +// defines for AFK theft +/// How many messages you can remember while logged out before you stop remembering new ones +#define AFK_THEFT_MAX_MESSAGES 10 +/// If someone logs back in and there are entries older than this, just tell them they can't remember who it was or when +#define AFK_THEFT_FORGET_DETAILS_TIME 5 MINUTES +/// The index of the entry in 'afk_thefts' with the person's visible name at the time +#define AFK_THEFT_NAME 1 +/// The index of the entry in 'afk_thefts' with the text +#define AFK_THEFT_MESSAGE 2 +/// The index of the entry in 'afk_thefts' with the time it happened +#define AFK_THEFT_TIME 3 + //Allowed equipment lists for security vests and hardsuits. GLOBAL_LIST_INIT(advanced_hardsuit_allowed, typecacheof(list( diff --git a/code/datums/elements/strippable.dm b/code/datums/elements/strippable.dm index edc4714d52f..50b1c8e2d3e 100644 --- a/code/datums/elements/strippable.dm +++ b/code/datums/elements/strippable.dm @@ -97,6 +97,13 @@ ignored_mobs = user, ) + if(ishuman(source)) + var/mob/living/carbon/human/victim_human = source + if(victim_human.key && !victim_human.client) // AKA braindead + if(victim_human.stat <= SOFT_CRIT && LAZYLEN(victim_human.afk_thefts) <= AFK_THEFT_MAX_MESSAGES) + var/list/new_entry = list(list(user.name, "tried equipping you with [equipping]", world.time)) + LAZYADD(victim_human.afk_thefts, new_entry) + to_chat(user, "You try to put [equipping] on [source]...") var/log = "[key_name(source)] is having [equipping] put on them by [key_name(user)]" @@ -145,6 +152,13 @@ user.log_message("[key_name(source)] is being stripped of [item] by [key_name(src)]", LOG_ATTACK, color="red", log_globally=FALSE) item.add_fingerprint(src) + if(ishuman(source)) + var/mob/living/carbon/human/victim_human = source + if(victim_human.key && !victim_human.client) // AKA braindead + if(victim_human.stat <= SOFT_CRIT && LAZYLEN(victim_human.afk_thefts) <= AFK_THEFT_MAX_MESSAGES) + var/list/new_entry = list(list(user.name, "tried unequipping your [item.name]", world.time)) + LAZYADD(victim_human.afk_thefts, new_entry) + return TRUE /// The proc that unequips the item from the source. This should not yield. diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index 6eb0d937ea3..49eecdb37bb 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -77,3 +77,5 @@ ///human specific screwyhuds from hallucinations (define key (bodypart) to int value (severity)) - see /datum/hallucination/fake_health_doll var/hal_screwydoll + /// When an braindead player has their equipment fiddled with, we log that info here for when they come back so they know who took their ID while they were DC'd for 30 seconds + var/list/afk_thefts diff --git a/code/modules/mob/living/carbon/human/login.dm b/code/modules/mob/living/carbon/human/login.dm new file mode 100644 index 00000000000..72e2f512306 --- /dev/null +++ b/code/modules/mob/living/carbon/human/login.dm @@ -0,0 +1,31 @@ +/mob/living/carbon/human/Login() + . = ..() + if(!LAZYLEN(afk_thefts)) + return + + var/list/print_msg = list() + print_msg += "*---------*" + print_msg += "As you snap back to consciousness, you recall people messing with your stuff..." + + afk_thefts = reverseRange(afk_thefts) + + for(var/list/iter_theft as anything in afk_thefts) + if(!islist(iter_theft) || LAZYLEN(iter_theft) != AFK_THEFT_TIME) + stack_trace("[src] ([ckey]) returned to their body and had a null/malformed afk_theft entry. Contents: [json_encode(iter_theft)]") + continue + + var/thief_name = iter_theft[AFK_THEFT_NAME] + var/theft_message = iter_theft[AFK_THEFT_MESSAGE] + var/time_since = world.time - iter_theft[AFK_THEFT_TIME] + + if(time_since > AFK_THEFT_FORGET_DETAILS_TIME) + print_msg += "\tSomeone [theft_message], but it was at least [DisplayTimeText(AFK_THEFT_FORGET_DETAILS_TIME)] ago." + else + print_msg += "\t[thief_name] [theft_message] roughly [DisplayTimeText(time_since, 10)] ago." + + if(LAZYLEN(afk_thefts) >= AFK_THEFT_MAX_MESSAGES) + print_msg += "There may have been more, but that's all you can remember..." + print_msg += "*---------*" + + to_chat(src, print_msg.Join("\n")) + LAZYNULL(afk_thefts) diff --git a/tgstation.dme b/tgstation.dme index 5f11d2b54cb..afe1cc216e3 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2525,6 +2525,7 @@ #include "code\modules\mob\living\carbon\human\human_update_icons.dm" #include "code\modules\mob\living\carbon\human\inventory.dm" #include "code\modules\mob\living\carbon\human\life.dm" +#include "code\modules\mob\living\carbon\human\login.dm" #include "code\modules\mob\living\carbon\human\physiology.dm" #include "code\modules\mob\living\carbon\human\species.dm" #include "code\modules\mob\living\carbon\human\status_procs.dm"