From cf27199e7ecefcf4e1ba4bc626c982a7512c9fa8 Mon Sep 17 00:00:00 2001
From: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Date: Tue, 7 May 2024 18:12:48 -0500
Subject: [PATCH] Reading a photo with blueprints now requires squinting
(#82984)
## About The Pull Request
To see the wires in a photo of blueprints you first must squint at them.
## Why It's Good For The Game
Realism, a picture of blueprints taken from across the room makes it
difficult to see what's up
## Changelog
:cl: Melbert
balance: To see wires in photos of blueprints, you first must squint at
the photo.
/:cl:
---
code/datums/wires/_wires.dm | 43 +++++++++++++++++++++++++++++++++----
1 file changed, 39 insertions(+), 4 deletions(-)
diff --git a/code/datums/wires/_wires.dm b/code/datums/wires/_wires.dm
index 4b7bfd2d08f..c3c8a1c0e93 100644
--- a/code/datums/wires/_wires.dm
+++ b/code/datums/wires/_wires.dm
@@ -41,6 +41,9 @@
/// If every instance of these wires should be random. Prevents wires from showing up in station blueprints.
var/randomize = FALSE
+ /// Lazy assoc list of refs to mobs to refs to photos they have studied for wires
+ var/list/studied_photos
+
/datum/wires/New(atom/holder)
..()
if(!istype(holder, holder_type))
@@ -261,10 +264,10 @@
if(!randomize)
if(user.is_holding_item_of_type(/obj/item/blueprints))
return TRUE
- for(var/obj/item/photo/photo in user.held_items)
- if(!photo.picture || !photo.picture.has_blueprints)
- continue
- return TRUE
+ if(!isnull(user.mind))
+ for(var/obj/item/photo/photo in user.held_items)
+ if(LAZYACCESS(studied_photos, REF(user.mind)) == REF(photo))
+ return TRUE
return FALSE
@@ -279,6 +282,37 @@
/datum/wires/proc/always_reveal_wire(color)
return FALSE
+#define STUDY_INTERACTION_KEY "studying_photo"
+
+/**
+ * Attempts to study a photo for blueprints.
+ */
+/datum/wires/proc/try_study_photo(mob/user)
+ if(randomize)
+ return
+ if(isnull(user.mind))
+ return
+ if(DOING_INTERACTION(user, STUDY_INTERACTION_KEY))
+ return
+ if(LAZYACCESS(studied_photos, REF(user.mind)))
+ return
+ for(var/obj/item/photo/photo in user.held_items)
+ if(!photo.picture?.has_blueprints)
+ continue
+
+ var/study_length = 1 SECONDS * floor(min(photo.picture.psize_x, photo.picture.psize_y) / 32)
+ if(study_length >= 4 SECONDS)
+ to_chat(user, span_notice("You squint [photo]... Hey, there's blueprints in the frame! Really wish the photo was zoomed in, though. \
+ It's rather difficult to make out the wires."))
+ else
+ to_chat(user, span_notice("You glance at [photo], looking for wires in the pictured blueprints."))
+
+ if(do_after(user, study_length, holder, interaction_key = STUDY_INTERACTION_KEY, hidden = TRUE))
+ LAZYSET(studied_photos, REF(user.mind), REF(photo))
+ return
+
+#undef STUDY_INTERACTION_KEY
+
/datum/wires/ui_host()
return holder
@@ -295,6 +329,7 @@
if (!ui)
ui = new(user, src, "Wires", "[holder.name] Wires")
ui.open()
+ try_study_photo(user)
/datum/wires/ui_data(mob/user)
var/list/data = list()