From fabc9d08a39295ebee444b3b2ba4bc845a5daf2c Mon Sep 17 00:00:00 2001 From: larentoun Date: Tue, 11 Apr 2023 16:06:54 +0300 Subject: [PATCH] feat: Mouth obscuration is now config dependant --- code/controllers/configuration.dm | 4 ++++ code/game/objects/items/weapons/kitchen.dm | 6 +----- code/modules/food_and_drinks/drinks/drinks.dm | 10 ++++------ code/modules/food_and_drinks/food/condiment.dm | 6 +----- code/modules/food_and_drinks/food/snacks.dm | 6 +----- code/modules/mob/mob.dm | 12 ++++++++++++ code/modules/reagents/reagent_containers/pill.dm | 6 +----- config/example/config.txt | 2 ++ 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index bb43807c195..fe1f4bd089b 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -313,6 +313,8 @@ var/default_map = null var/override_map = null + var/ignore_obscured_mouth = FALSE + /datum/configuration/New() for(var/T in subtypesof(/datum/game_mode)) var/datum/game_mode/M = T @@ -897,6 +899,8 @@ if("override_map") config.override_map = value + if("ignore_obscured_mouth") + config.ignore_obscured_mouth = TRUE else log_config("Unknown setting in configuration: '[name]'") diff --git a/code/game/objects/items/weapons/kitchen.dm b/code/game/objects/items/weapons/kitchen.dm index 0cf882f375c..f14945fac3a 100644 --- a/code/game/objects/items/weapons/kitchen.dm +++ b/code/game/objects/items/weapons/kitchen.dm @@ -57,11 +57,7 @@ if(length(contents)) var/obj/item/reagent_containers/food/snacks/toEat = contents[1] if(istype(toEat)) - if(!get_location_accessible(C, "mouth")) - if(C == user) - to_chat(user, "Your face is obscured, so you cant eat.") - else - to_chat(user, "[C]'s face is obscured, so[C.p_they()] cant eat.") + if(C.is_mouth_obscured(user)) return if(C.eat(toEat, user)) toEat.On_Consume(C, user) diff --git a/code/modules/food_and_drinks/drinks/drinks.dm b/code/modules/food_and_drinks/drinks/drinks.dm index 4ba9652afeb..9b09600bb6e 100644 --- a/code/modules/food_and_drinks/drinks/drinks.dm +++ b/code/modules/food_and_drinks/drinks/drinks.dm @@ -36,14 +36,12 @@ to_chat(user, " You need to open [src] first!") return FALSE + if(M.is_mouth_obscured(user)) + return FALSE + if(istype(M, /mob/living/carbon)) var/mob/living/carbon/C = M - if(!get_location_accessible(C, "mouth")) - if(C == user) - to_chat(user, "Your face is obscured, so you cant eat.") - else - to_chat(user, "[C]'s face is obscured, so[C.p_they()] cant eat.") - return FALSE + var/list/transfer_data = reagents.get_transferred_reagents(C, amount_per_transfer_from_this) if(C.eat(src, user)) diff --git a/code/modules/food_and_drinks/food/condiment.dm b/code/modules/food_and_drinks/food/condiment.dm index b80d92a03eb..3b8e6a798b1 100644 --- a/code/modules/food_and_drinks/food/condiment.dm +++ b/code/modules/food_and_drinks/food/condiment.dm @@ -44,11 +44,7 @@ to_chat(user, "None of [src] left, oh no!") return 0 - if(!get_location_accessible(M, "mouth")) - if(M == user) - to_chat(user, "Your face is obscured, so you cant eat.") - else - to_chat(user, "[M]'s face is obscured, so[M.p_they()] cant eat.") + if(M.is_mouth_obscured(user)) return FALSE if(M == user) diff --git a/code/modules/food_and_drinks/food/snacks.dm b/code/modules/food_and_drinks/food/snacks.dm index bc8fb0c6678..3ff33e3dd91 100644 --- a/code/modules/food_and_drinks/food/snacks.dm +++ b/code/modules/food_and_drinks/food/snacks.dm @@ -79,11 +79,7 @@ qdel(src) return FALSE - if(!get_location_accessible(M, "mouth")) - if(M == user) - to_chat(user, "Your face is obscured, so you cant eat.") - else - to_chat(user, "[M]'s face is obscured, so[M.p_they()] cant eat.") + if(M.is_mouth_obscured(user)) return FALSE if(iscarbon(M)) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 00681b9b472..c74e1d51d62 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1510,3 +1510,15 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( \ else . = invoked_callback.Invoke() usr = temp + +/// Check if +/mob/proc/is_mouth_obscured(mob/attacker) + . = FALSE + if(config.ignore_obscured_mouth) + return + if(!get_location_accessible(src, "mouth")) + if(src == attacker) + to_chat(attacker, span_warning("Your face is obscured, so you can't eat")) + else + to_chat(attacker, span_warning("[src]'s face is obscured, so [src.p_they()] can't eat.")) + return TRUE diff --git a/code/modules/reagents/reagent_containers/pill.dm b/code/modules/reagents/reagent_containers/pill.dm index 35682aeb25b..21117efcd88 100644 --- a/code/modules/reagents/reagent_containers/pill.dm +++ b/code/modules/reagents/reagent_containers/pill.dm @@ -24,11 +24,7 @@ /obj/item/reagent_containers/food/pill/attack(mob/living/carbon/M, mob/user, def_zone) if(!istype(M)) return FALSE - if(!get_location_accessible(M, "mouth")) - if(M == user) - to_chat(user, "Your face is obscured, so you cant eat.") - else - to_chat(user, "[M]'s face is obscured, so[M.p_they()] cant eat.") + if(M.is_mouth_obscured(user)) return FALSE bitesize = reagents.total_volume if(M.eat(src, user)) diff --git a/config/example/config.txt b/config/example/config.txt index 747908ffc4e..f64373b8e75 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -586,3 +586,5 @@ DEFAULT_MAP /datum/map/cyberiad ## Override server map by specified, uncomment to apply # OVERRIDE_MAP /datum/map/delta +## Can eat through blocked mouth? +#IGNORE_OBSCURED_MOUTH