Skip to content

Commit 7e9ee0f

Browse files
authored
Small tweak to examine (#1045)
* i didnt tesdt this * i tested it
1 parent 17a9f82 commit 7e9ee0f

File tree

3 files changed

+60
-11
lines changed

3 files changed

+60
-11
lines changed

code/game/atoms.dm

+3-11
Original file line numberDiff line numberDiff line change
@@ -764,17 +764,9 @@
764764
else
765765
. += span_alert("It looks empty.")
766766

767-
if(isliving(user) && !ismovable(loc) && !ismob(src))
768-
var/mob/living/living_user = user
769-
if(living_user.stats.cooldown_finished("examine_forensic_evidence_present_[REF(src)]") && !return_blood_DNA() && (return_fibers() || return_fingerprints() || return_trace_DNA() || return_gunshot_residue()))
770-
var/datum/roll_result/result = living_user.stat_roll(15, /datum/rpg_skill/forensics)
771-
switch(result.outcome)
772-
if(CRIT_SUCCESS, SUCCESS)
773-
spawn(0)
774-
var/text = isitem(src) ? "someone has held this item in the past" : "someone has been here before"
775-
to_chat(living_user, result.create_tooltip("Perhaps it is a stray particle of dust, or a smudge on the surface. Whatever it is, you are certain [text]."))
776-
777-
living_user.stats.set_cooldown("examine_forensic_evidence_present_[REF(src)]", INFINITY)
767+
if(ishuman(user) && !ismovable(loc) && !ismob(src))
768+
var/mob/living/carbon/human/human_user = user
769+
human_user.forensic_analysis_roll(src)
778770

779771
SEND_SIGNAL(src, COMSIG_PARENT_EXAMINE, user, .)
780772

code/modules/detectivework/detective_work.dm

+54
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,57 @@
195195
*/
196196
/atom/proc/transfer_gunshot_residue_to(atom/transfer_to)
197197
transfer_to.add_gunshot_residue(return_gunshot_residue())
198+
199+
/// On examine, players have a chance to find forensic evidence. This can only happen once per object.
200+
/mob/living/carbon/human/proc/forensic_analysis_roll(atom/examined)
201+
if(!stats.cooldown_finished("examine_forensic_analysis"))
202+
return
203+
204+
// Already gotten the good rng on this one
205+
if(stats.examined_object_weakrefs[WEAKREF(examined)])
206+
return
207+
208+
if(examined.return_blood_DNA())
209+
return // This is kind of obvious
210+
211+
var/list/fingerprints = examined.return_fingerprints()?.Copy()
212+
var/list/trace_dna = examined.return_trace_DNA()?.Copy()
213+
var/list/residue = examined.return_gunshot_residue()
214+
215+
// Exclude our own prints
216+
if(length(fingerprints))
217+
var/obj/item/bodypart/arm/left_arm = get_bodypart(BODY_ZONE_L_ARM)
218+
var/obj/item/bodypart/arm/right_arm = get_bodypart(BODY_ZONE_R_ARM)
219+
220+
if(left_arm)
221+
fingerprints -= get_fingerprints(TRUE, left_arm)
222+
if(right_arm)
223+
fingerprints -= get_fingerprints(TRUE, right_arm)
224+
225+
// Exclude our DNA
226+
if(length(trace_dna))
227+
trace_dna -= get_trace_dna()
228+
229+
// Do nothing if theres no evidence.
230+
if(!(length(fingerprints) || length(trace_dna) || length(residue)))
231+
return
232+
233+
var/datum/roll_result/result = stat_roll(16, /datum/rpg_skill/forensics)
234+
235+
switch(result.outcome)
236+
if(FAILURE, CRIT_FAILURE)
237+
stats.set_cooldown("examine_forensic_analysis", 15 SECONDS)
238+
return
239+
240+
stats.examined_object_weakrefs[WEAKREF(examined)] = TRUE
241+
stats.set_cooldown("examine_forensic_analysis", 15 MINUTES)
242+
243+
// Spawn 0 so this displays *after* the examine block.
244+
spawn(0)
245+
if(length(residue))
246+
to_chat(src, result.create_tooltip("A remnant of past events flashes into your mind, the booming crack of a firearm."))
247+
248+
else if(length(fingerprints) || length(trace_dna))
249+
var/text = isitem(examined) ? "someone else has held this item in the past" : "someone else has been here before"
250+
to_chat(src, result.create_tooltip("Perhaps it is a stray particle of dust, or a smudge on the surface. Whatever it may be, you are certain [text]."))
251+

code/modules/three_dsix/stats.dm

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
VAR_PRIVATE/list/stat_cooldowns = list()
1212

13+
/// A list of weakrefs to examined objects. Used for forensic rolls. THIS DOES JUST KEEP GETTING BIGGER, SO, CAREFUL.
14+
var/list/examined_object_weakrefs = list()
15+
1316
/datum/stats/New(owner)
1417
. = ..()
1518
src.owner = owner

0 commit comments

Comments
 (0)