From fdf9a1d8b877f6e6b6e511fd1f00ec036ae9f626 Mon Sep 17 00:00:00 2001 From: OctusGit Date: Tue, 5 Dec 2023 17:07:32 -0600 Subject: [PATCH] Examine More --- code/__DEFINES/mob_defines.dm | 5 +++++ code/game/atoms.dm | 6 ++++++ code/modules/client/client_defines.dm | 3 +++ code/modules/mob/mob.dm | 23 ++++++++++++++++++++++- 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/mob_defines.dm b/code/__DEFINES/mob_defines.dm index bde8ac4801d..91d72768634 100644 --- a/code/__DEFINES/mob_defines.dm +++ b/code/__DEFINES/mob_defines.dm @@ -199,6 +199,11 @@ #define INVISIBILITY_ABSTRACT 101 #define UNHEALING_EAR_DAMAGE 100 +/// How long it takes for an examined atom to be removed from recent_examines. Should be the max of the below time windows +#define RECENT_EXAMINE_MAX_WINDOW (2 SECONDS) +/// If you examine the same atom twice in this timeframe, we call examine_more() instead of examine() +#define EXAMINE_MORE_WINDOW (1 SECONDS) + //Human sub-species #define isabductor(A) (is_species(A, /datum/species/abductor)) #define isgolem(A) (is_species(A, /datum/species/golem)) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 2fc37b6c259..0810f2f9e3b 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -387,6 +387,12 @@ SEND_SIGNAL(src, COMSIG_PARENT_EXAMINE, user, .) +/atom/proc/examine_more(mob/user) + SHOULD_CALL_PARENT(TRUE) + RETURN_TYPE(/list) + + . = list() + /** * Updates the appearence of the icon * diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index 686f2eae34c..ed0268a6172 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -125,6 +125,9 @@ /// The client's movement keybindings to directions, which work regardless of modifiers. var/list/movement_kb_dirs = list() + ///A lazy list of atoms we've examined in the last RECENT_EXAMINE_MAX_WINDOW (default 2) seconds, so that we will call [/atom/proc/examine_more] instead of [/atom/proc/examine] on them when examining + var/list/recent_examines + /client/vv_edit_var(var_name, var_value) switch(var_name) // I know we will never be in a world where admins are editing client vars to let people bypass TOS diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index f7a600a1b44..a3bff9cd9e8 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -639,9 +639,30 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( \ return 1 face_atom(A) - var/list/result = A.examine(src) + var/list/result + if(client) + LAZYINITLIST(client.recent_examines) + var/ref_to_atom = ref(A) + var/examine_time = client.recent_examines[ref_to_atom] + if(examine_time && (world.time - examine_time < EXAMINE_MORE_WINDOW)) + result = A.examine_more(src) + if(!length(result)) + result += "You examine [A] closer, but find nothing of interest..." + else + result = A.examine(src) + client.recent_examines[ref_to_atom] = world.time // set to when we last normal examine'd them + addtimer(CALLBACK(src, PROC_REF(clear_from_recent_examines), ref_to_atom), RECENT_EXAMINE_MAX_WINDOW) + 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, chat_box_examine(result.Join("\n"))) +/mob/proc/clear_from_recent_examines(ref_to_clear) + SIGNAL_HANDLER + if(!client) + return + LAZYREMOVE(client.recent_examines, ref_to_clear) + /mob/proc/ret_grab(obj/effect/list_container/mobl/L as obj, flag) if((!istype(l_hand, /obj/item/grab) && !istype(r_hand, /obj/item/grab))) if(!L)