From 4c3180ff211b775187cbf58d6bede476eaa8d7cd Mon Sep 17 00:00:00 2001
From: Contrabang <91113370+Contrabang@users.noreply.github.com>
Date: Mon, 17 Jul 2023 05:53:47 -0400
Subject: [PATCH] Migrates meson stuff FULLY to traits (#21609)
* fuckin TRAITS
* pickup -> equip
---
.../modules/clothing/glasses/engine_goggles.dm | 18 ++++++++----------
code/modules/clothing/glasses/glasses.dm | 14 ++++++++++++--
code/modules/clothing/head/helmet.dm | 11 ++++++++++-
.../power/engines/singularity/singularity.dm | 11 +++--------
.../power/engines/supermatter/supermatter.dm | 5 ++---
5 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/code/modules/clothing/glasses/engine_goggles.dm b/code/modules/clothing/glasses/engine_goggles.dm
index 2d9db5d9d1a..e489812f71f 100644
--- a/code/modules/clothing/glasses/engine_goggles.dm
+++ b/code/modules/clothing/glasses/engine_goggles.dm
@@ -12,8 +12,7 @@
item_state = "trayson-meson"
actions_types = list(/datum/action/item_action/toggle_mode)
origin_tech = "materials=3;magnets=3;engineering=3;plasmatech=3"
- vision_flags = NONE
- invis_view = SEE_INVISIBLE_LIVING
+ active_on_equip = FALSE
var/list/modes = list(MODE_NONE = MODE_MESON, MODE_MESON = MODE_TRAY, MODE_TRAY = MODE_RAD, MODE_RAD = MODE_NONE)
var/mode = MODE_NONE
@@ -32,14 +31,13 @@
mode = modes[mode]
to_chat(user, "[voluntary ? "You turn the goggles" : "The goggles turn"] [mode ? "to [mode] mode" : "off"][voluntary ? "." : "!"]")
- switch(mode)
- if(MODE_MESON)
- vision_flags = SEE_TURFS
- lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE
-
- if(MODE_TRAY) //undoes the last mode, meson
- vision_flags = NONE
- lighting_alpha = null
+ if(mode == MODE_MESON)
+ if(!HAS_TRAIT_FROM(user, TRAIT_MESON_VISION, "meson_glasses[UID()]"))
+ ADD_TRAIT(user, TRAIT_MESON_VISION, "meson_glasses[UID()]")
+ active_on_equip = TRUE
+ else
+ REMOVE_TRAIT(user, TRAIT_MESON_VISION, "meson_glasses[UID()]")
+ active_on_equip = FALSE
if(ishuman(user))
var/mob/living/carbon/human/H = user
diff --git a/code/modules/clothing/glasses/glasses.dm b/code/modules/clothing/glasses/glasses.dm
index 048dc8d686e..3ac1ba926b5 100644
--- a/code/modules/clothing/glasses/glasses.dm
+++ b/code/modules/clothing/glasses/glasses.dm
@@ -74,8 +74,6 @@
icon_state = "meson"
item_state = "meson"
origin_tech = "magnets=1;engineering=2"
- vision_flags = SEE_TURFS
- lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE
prescription_upgradable = TRUE
sprite_sheets = list(
@@ -86,6 +84,18 @@
"Kidan" = 'icons/mob/clothing/species/kidan/eyes.dmi'
)
+ var/active_on_equip = TRUE
+
+/obj/item/clothing/glasses/meson/equipped(mob/user, slot, initial)
+ . = ..()
+ if(active_on_equip && slot == slot_glasses)
+ ADD_TRAIT(user, TRAIT_MESON_VISION, "meson_glasses[UID()]")
+
+/obj/item/clothing/glasses/meson/dropped(mob/user)
+ . = ..()
+ if(user)
+ REMOVE_TRAIT(user, TRAIT_MESON_VISION, "meson_glasses[UID()]")
+
/obj/item/clothing/glasses/meson/night
name = "night vision optical meson scanner"
desc = "An optical meson scanner fitted with an amplified visible light spectrum overlay, providing greater visual clarity in darkness."
diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm
index 5e33b507b3f..dc67836abb3 100644
--- a/code/modules/clothing/head/helmet.dm
+++ b/code/modules/clothing/head/helmet.dm
@@ -54,7 +54,16 @@
name = "meson visor helmet"
desc = "A helmet with a built-in meson scanning visor."
icon_state = "helmetmesons"
- vision_flags = SEE_TURFS
+
+/obj/item/clothing/head/helmet/meson/equipped(mob/user, slot, initial)
+ . = ..()
+ if(slot == slot_head)
+ ADD_TRAIT(user, TRAIT_MESON_VISION, "meson_helmet[UID()]")
+
+/obj/item/clothing/head/helmet/meson/dropped(mob/user)
+ . = ..()
+ if(user)
+ REMOVE_TRAIT(user, TRAIT_MESON_VISION, "meson_helmet[UID()]")
/obj/item/clothing/head/helmet/material
name = "material visor helmet"
diff --git a/code/modules/power/engines/singularity/singularity.dm b/code/modules/power/engines/singularity/singularity.dm
index 42e59231282..4ce083c7276 100644
--- a/code/modules/power/engines/singularity/singularity.dm
+++ b/code/modules/power/engines/singularity/singularity.dm
@@ -454,14 +454,9 @@
if(isbrain(M)) //Ignore brains
continue
- if(M.stat == CONSCIOUS)
- if(ishuman(M))
- var/mob/living/carbon/human/H = M
- if(istype(H.glasses, /obj/item/clothing/glasses/meson))
- var/obj/item/clothing/glasses/meson/MS = H.glasses
- if(MS.vision_flags == SEE_TURFS)
- to_chat(H, "You look directly into [src], good thing you had your protective eyewear on!")
- return
+ if(HAS_TRAIT(M, TRAIT_MESON_VISION))
+ to_chat(M, "You look directly into [src], but your meson vision protects you!")
+ return
M.Stun(6 SECONDS)
M.visible_message("[M] stares blankly at [src]!", \
diff --git a/code/modules/power/engines/supermatter/supermatter.dm b/code/modules/power/engines/supermatter/supermatter.dm
index c2f6f145838..a4de8f13f46 100644
--- a/code/modules/power/engines/supermatter/supermatter.dm
+++ b/code/modules/power/engines/supermatter/supermatter.dm
@@ -240,8 +240,7 @@
. = ..()
var/mob/living/carbon/human/H = user
if(istype(H))
- var/immune = istype(H.glasses, /obj/item/clothing/glasses/meson)
- if(!immune && !HAS_TRAIT(H, TRAIT_MESON_VISION) && (get_dist(user, src) < HALLUCINATION_RANGE(power)))
+ if(!HAS_TRAIT(H, TRAIT_MESON_VISION) && (get_dist(user, src) < HALLUCINATION_RANGE(power)))
. += "You get headaches just from looking at it."
. += "When actived by an item hitting this awe-inspiring feat of engineering, it emits radiation and heat. This is the basis of the use of the pseudo-perpetual energy source, the supermatter crystal."
. +="Any object that touches [src] instantly turns to dust, be it complex as a human or as simple as a metal rod. These bursts of energy can cause hallucinations if meson scanners are not worn near the crystal."
@@ -551,7 +550,7 @@
//Makes em go mad and accumulate rads.
for(var/mob/living/carbon/human/l in view(src, HALLUCINATION_RANGE(power))) // If they can see it without mesons on. Bad on them.
- if(!istype(l.glasses, /obj/item/clothing/glasses/meson) && !HAS_TRAIT(l, TRAIT_MESON_VISION) && !HAS_TRAIT(l, SM_HALLUCINATION_IMMUNE))
+ if(!HAS_TRAIT(l, TRAIT_MESON_VISION) && !HAS_TRAIT(l, SM_HALLUCINATION_IMMUNE))
var/D = sqrt(1 / max(1, get_dist(l, src)))
var/hallucination_amount = power * hallucination_power * D
l.AdjustHallucinate(hallucination_amount, 0, 200 SECONDS)