From 9677bb5104a1ae9a32c8a68189353ea5ccee617f Mon Sep 17 00:00:00 2001 From: Lin Date: Wed, 25 Dec 2019 19:03:42 +0000 Subject: [PATCH] Merge pull request #10242 from Ghommie/Ghommie-cit483 Ports "Refactors can_see_reagents" --- code/__DEFINES/is_helpers.dm | 2 ++ code/__DEFINES/obj_flags.dm | 14 +++++++------ code/_globalvars/bitfields.dm | 2 ++ code/modules/clothing/clothing.dm | 1 - code/modules/clothing/glasses/_glasses.dm | 6 +++--- code/modules/clothing/spacesuits/hardsuit.dm | 6 +++--- code/modules/mob/living/carbon/carbon.dm | 11 ++++++++++ .../mob/living/carbon/human/human_helpers.dm | 10 ++++++++-- .../simple_animal/friendly/drone/_drone.dm | 9 +++++++++ code/modules/mob/mob.dm | 20 ------------------- code/modules/mob/mob_helpers.dm | 4 ++++ .../modules/clothing/spacesuits/hardsuit.dm | 1 - 12 files changed, 50 insertions(+), 36 deletions(-) diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index 5f5903e2..9ecde198 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -233,6 +233,8 @@ GLOBAL_LIST_INIT(heavyfootmob, typecacheof(list( #define isorgan(A) (istype(A, /obj/item/organ)) +#define isclothing(A) (istype(A, /obj/item/clothing)) + GLOBAL_LIST_INIT(pointed_types, typecacheof(list( /obj/item/pen, /obj/item/screwdriver, diff --git a/code/__DEFINES/obj_flags.dm b/code/__DEFINES/obj_flags.dm index 508071e3..2083a0cd 100644 --- a/code/__DEFINES/obj_flags.dm +++ b/code/__DEFINES/obj_flags.dm @@ -34,12 +34,14 @@ #define LAVAPROTECT (1<<0) #define STOPSPRESSUREDAMAGE (1<<1) //SUIT and HEAD items which stop pressure damage. To stop you taking all pressure damage you must have both a suit and head item with this flag. -#define BLOCK_GAS_SMOKE_EFFECT (1<<2) // blocks the effect that chemical clouds would have on a mob --glasses, mask and helmets ONLY! -#define ALLOWINTERNALS (1<<3) // mask allows internals -#define NOSLIP (1<<4) //prevents from slipping on wet floors, in space etc -#define THICKMATERIAL (1<<5) //prevents syringes, parapens and hypos if the external suit or helmet (if targeting head) has this flag. Example: space suits, biosuit, bombsuits, thick suits that cover your body. -#define VOICEBOX_TOGGLABLE (1<<6) // The voicebox in this clothing can be toggled. -#define VOICEBOX_DISABLED (1<<7) // The voicebox is currently turned off. +#define BLOCK_GAS_SMOKE_EFFECT (1<<2) //blocks the effect that chemical clouds would have on a mob --glasses, mask and helmets ONLY! +#define ALLOWINTERNALS (1<<3) //mask allows internals +#define NOSLIP (1<<4) //prevents from slipping on wet floors, in space etc +#define THICKMATERIAL (1<<5) //prevents syringes, parapens and hypos if the external suit or helmet (if targeting head) has this flag. Example: space suits, biosuit, bombsuits, thick suits that cover your body. +#define VOICEBOX_TOGGLABLE (1<<6) //The voicebox in this clothing can be toggled. +#define VOICEBOX_DISABLED (1<<7) //The voicebox is currently turned off. +#define IGNORE_HAT_TOSS (1<<8) //Hats with negative effects when worn (i.e the tinfoil hat). +#define SCAN_REAGENTS (1<<9) // Allows helmets and glasses to scan reagents. // Flags for the organ_flags var on /obj/item/organ diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index 6e87c4a5..f0b16b9d 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -144,6 +144,8 @@ GLOBAL_LIST_INIT(bitfields, list( "THICKMATERIAL" = THICKMATERIAL, "VOICEBOX_TOGGLABLE" = VOICEBOX_TOGGLABLE, "VOICEBOX_DISABLED" = VOICEBOX_DISABLED, + "IGNORE_HAT_TOSS" = IGNORE_HAT_TOSS, + "SCAN_REAGENTS" = SCAN_REAGENTS ), "tesla_flags" = list( "TESLA_MOB_DAMAGE" = TESLA_MOB_DAMAGE, diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index d8a61400..9829d3b3 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -22,7 +22,6 @@ var/cooldown = 0 var/obj/item/flashlight/F = null var/can_flashlight = 0 - var/scan_reagents = 0 //Can the wearer see reagents while it's equipped? var/blocks_shove_knockdown = FALSE //Whether wearing the clothing item blocks the ability for shove to knock down. diff --git a/code/modules/clothing/glasses/_glasses.dm b/code/modules/clothing/glasses/_glasses.dm index 12cca53b..aa072f92 100644 --- a/code/modules/clothing/glasses/_glasses.dm +++ b/code/modules/clothing/glasses/_glasses.dm @@ -98,7 +98,7 @@ desc = "A pair of snazzy goggles used to protect against chemical spills. Fitted with an analyzer for scanning items and reagents." icon_state = "purple" item_state = "glasses" - scan_reagents = TRUE //You can see reagents while wearing science goggles + clothing_flags = SCAN_REAGENTS //You can see reagents while wearing science goggles actions_types = list(/datum/action/item_action/toggle_research_scanner) glass_colour_type = /datum/client_colour/glass_colour/purple resistance_flags = ACID_PROOF @@ -202,7 +202,7 @@ /obj/item/clothing/glasses/sunglasses/reagent name = "beer goggles" desc = "A pair of sunglasses outfitted with apparatus to scan reagents." - scan_reagents = TRUE + clothing_flags = SCAN_REAGENTS /obj/item/clothing/glasses/sunglasses/garb name = "black gar glasses" @@ -388,7 +388,7 @@ item_state = "godeye" vision_flags = SEE_TURFS|SEE_MOBS|SEE_OBJS darkness_view = 8 - scan_reagents = TRUE + clothing_flags = SCAN_REAGENTS lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE resistance_flags = LAVA_PROOF | FIRE_PROOF diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index 31c441d1..cfca0db7 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -446,7 +446,7 @@ flash_protect = 0 armor = list("melee" = 30, "bullet" = 5, "laser" = 10, "energy" = 5, "bomb" = 10, "bio" = 100, "rad" = 60, "fire" = 60, "acid" = 75) flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR - scan_reagents = TRUE + clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | BLOCK_GAS_SMOKE_EFFECT | ALLOWINTERNALS | SCAN_REAGENTS /obj/item/clothing/suit/space/hardsuit/medical icon_state = "hardsuit-medical" @@ -468,7 +468,7 @@ max_heat_protection_temperature = FIRE_SUIT_MAX_TEMP_PROTECT armor = list("melee" = 30, "bullet" = 5, "laser" = 10, "energy" = 5, "bomb" = 100, "bio" = 100, "rad" = 60, "fire" = 60, "acid" = 80) var/obj/machinery/doppler_array/integrated/bomb_radar - scan_reagents = TRUE + clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | BLOCK_GAS_SMOKE_EFFECT | ALLOWINTERNALS | SCAN_REAGENTS actions_types = list(/datum/action/item_action/toggle_helmet_light, /datum/action/item_action/toggle_research_scanner) /obj/item/clothing/head/helmet/space/hardsuit/rd/Initialize() @@ -640,7 +640,7 @@ armor = list("melee" = 10, "bullet" = 5, "laser" = 5, "energy" = 500, "bomb" = 500, "bio" = 500, "rad" = 500, "fire" = 500, "acid" = 500) item_color = "ancient" brightness_on = 16 - scan_reagents = TRUE + clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | BLOCK_GAS_SMOKE_EFFECT | ALLOWINTERNALS | SCAN_REAGENTS flash_protect = 5 //We will not be flash by bombs tint = 1 var/obj/machinery/doppler_array/integrated/bomb_radar diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 715643a4..99176e7f 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -974,3 +974,14 @@ if(mood) if(mood.sanity < SANITY_UNSTABLE) return TRUE + +/mob/living/carbon/can_see_reagents() + . = ..() + if(.) //No need to run through all of this if it's already true. + return + if(isclothing(head)) + var/obj/item/clothing/H = head + if(H.clothing_flags & SCAN_REAGENTS) + return TRUE + if(isclothing(wear_mask) && (wear_mask.clothing_flags & SCAN_REAGENTS)) + return TRUE diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm index 6bb9dd6e..93c9ce32 100644 --- a/code/modules/mob/living/carbon/human/human_helpers.dm +++ b/code/modules/mob/living/carbon/human/human_helpers.dm @@ -118,7 +118,8 @@ /mob/living/carbon/human/can_use_guns(obj/item/G) . = ..() - + if(!.) + return if(G.trigger_guard == TRIGGER_GUARD_NORMAL) if(src.dna.check_mutation(HULK)) to_chat(src, "Your meaty finger is much too large for the trigger guard!") @@ -131,7 +132,12 @@ to_chat(src, "Use of ranged weaponry would bring dishonor to the clan.") return FALSE - return . +/mob/living/carbon/human/can_see_reagents() + . = ..() + if(.) //No need to run through all of this if it's already true. + return + if(isclothing(glasses) && (glasses.clothing_flags & SCAN_REAGENTS)) + return TRUE /* /mob/living/carbon/human/transfer_blood_dna(list/blood_dna) diff --git a/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm b/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm index f22e7b1d..61a11dfc 100644 --- a/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm +++ b/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm @@ -279,3 +279,12 @@ /mob/living/simple_animal/drone/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = 0, tesla_shock = 0, illusion = 0, stun = TRUE) return 0 //So they don't die trying to fix wiring + +/mob/living/simple_animal/drone/can_see_reagents() + . = ..() + if(.) + return + if(isclothing(head)) + var/obj/item/clothing/H = head + if(H.clothing_flags & SCAN_REAGENTS) + return TRUE diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index db37530f..3d60ea43 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -806,26 +806,6 @@ /mob/proc/can_interact_with(atom/A) return IsAdminGhost(src) || Adjacent(A) -//Can the mob see reagents inside of containers? -/mob/proc/can_see_reagents() - if(stat == DEAD) //Ghosts and such can always see reagents - return 1 - if(has_unlimited_silicon_privilege) //Silicons can automatically view reagents - return 1 - if(ishuman(src)) - var/mob/living/carbon/human/H = src - if(H.head && istype(H.head, /obj/item/clothing)) - var/obj/item/clothing/CL = H.head - if(CL.scan_reagents) - return 1 - if(H.wear_mask && H.wear_mask.scan_reagents) - return 1 - if(H.glasses && istype(H.glasses, /obj/item/clothing)) - var/obj/item/clothing/CL = H.glasses - if(CL.scan_reagents) - return 1 - return 0 - //Can the mob use Topic to interact with machines /mob/proc/canUseTopic(atom/movable/M, be_close=FALSE, no_dextery=FALSE, no_tk=FALSE) return diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 80f999f8..8a1fb90a 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -520,3 +520,7 @@ It's fairly easy to fix if dealing with single letters but not so much with comp if(!held_item) return return held_item.GetID() + +//Can the mob see reagents inside of containers? +/mob/proc/can_see_reagents() + return stat == DEAD || has_unlimited_silicon_privilege //Dead guys and silicons can always see reagents diff --git a/hyperstation/code/modules/clothing/spacesuits/hardsuit.dm b/hyperstation/code/modules/clothing/spacesuits/hardsuit.dm index 387842d1..e88793ce 100644 --- a/hyperstation/code/modules/clothing/spacesuits/hardsuit.dm +++ b/hyperstation/code/modules/clothing/spacesuits/hardsuit.dm @@ -7,7 +7,6 @@ resistance_flags = ACID_PROOF | FIRE_PROOF max_heat_protection_temperature = FIRE_SUIT_MAX_TEMP_PROTECT armor = list("melee" = 30, "bullet" = 10, "laser" = 10, "energy" = 5, "bomb" = 80, "bio" = 100, "rad" = 100, "fire" = 60, "acid" = 60) - scan_reagents = TRUE actions_types = list(/datum/action/item_action/toggle_research_scanner) /obj/item/clothing/suit/space/hardsuit/rd/hev