From 597d667dfa73ec09a9d8edfda52d40aac87d5dd4 Mon Sep 17 00:00:00 2001
From: SabreML <57483089+SabreML@users.noreply.github.com>
Date: Sat, 18 Sep 2021 03:03:08 +0100
Subject: [PATCH] Fixes some chugging-related bugs (#16475)
* Chugging-related fixes
The word "chug" doesn't sound real anymore
* Drinks can fix
#16500
---
code/modules/food_and_drinks/drinks/drinks.dm | 21 ++++++++++++++-----
.../food_and_drinks/drinks/drinks/cans.dm | 9 +++-----
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/code/modules/food_and_drinks/drinks/drinks.dm b/code/modules/food_and_drinks/drinks/drinks.dm
index b3b03b5777b..209f9526b76 100644
--- a/code/modules/food_and_drinks/drinks/drinks.dm
+++ b/code/modules/food_and_drinks/drinks/drinks.dm
@@ -12,6 +12,7 @@
volume = 50
resistance_flags = NONE
antable = FALSE
+ var/chugging = FALSE
/obj/item/reagent_containers/food/drinks/New()
..()
@@ -40,22 +41,32 @@
return FALSE
/obj/item/reagent_containers/food/drinks/MouseDrop(atom/over_object) //CHUG! CHUG! CHUG!
+ if(!iscarbon(over_object))
+ return
var/mob/living/carbon/chugger = over_object
- if (!(container_type & DRAINABLE))
+ if(!(container_type & DRAINABLE))
to_chat(chugger, "You need to open [src] first!")
return
- if(istype(chugger) && loc == chugger && src == chugger.get_active_hand() && reagents.total_volume)
- chugger.visible_message("[chugger] raises [src] to [chugger.p_their()] mouth and starts [pick("chugging","gulping")] it down like [pick("a savage","a mad beast","it's going out of style","there's no tomorrow")]!", "You start chugging [src].", "You hear what sounds like gulping.")
- while(do_mob(chugger, chugger, 40)) //Between the default time for do_mob and the time it takes for a vampire to suck blood.
+ if(reagents.total_volume && loc == chugger && src == chugger.get_active_hand())
+ chugger.visible_message("[chugger] raises [src] to [chugger.p_their()] mouth and starts [pick("chugging","gulping")] it down like [pick("a savage","a mad beast","it's going out of style","there's no tomorrow")]!",
+ "You start chugging [src].",
+ "You hear what sounds like gulping.")
+ chugging = TRUE
+ while(do_after_once(chugger, 4 SECONDS, TRUE, chugger, null, "You stop chugging [src]."))
chugger.eat(src, chugger, 25) //Half of a glass, quarter of a bottle.
if(!reagents.total_volume) //Finish in style.
chugger.emote("gasp")
- chugger.visible_message("[chugger] [pick("finishes","downs","polishes off","slams")] the entire [src], what a [pick("savage","monster","champ","beast")]!", "You finish off [src]![prob(50) ? " Maybe that wasn't such a good idea..." : ""]", "You hear a gasp and a clink.")
+ chugger.visible_message("[chugger] [pick("finishes","downs","polishes off","slams")] the entire [src], what a [pick("savage","monster","champ","beast")]!",
+ "You finish off [src]![prob(50) ? " Maybe that wasn't such a good idea..." : ""]",
+ "You hear a gasp and a clink.")
break
+ chugging = FALSE
/obj/item/reagent_containers/food/drinks/afterattack(obj/target, mob/user, proximity)
if(!proximity)
return
+ if(chugging)
+ return
if(target.is_refillable() && is_drainable()) //Something like a glass. Player probably wants to transfer TO it.
if(!reagents.total_volume)
diff --git a/code/modules/food_and_drinks/drinks/drinks/cans.dm b/code/modules/food_and_drinks/drinks/drinks/cans.dm
index 4759f76eb2b..e373fa7f78e 100644
--- a/code/modules/food_and_drinks/drinks/drinks/cans.dm
+++ b/code/modules/food_and_drinks/drinks/drinks/cans.dm
@@ -1,4 +1,5 @@
/obj/item/reagent_containers/food/drinks/cans
+ container_type = NONE
var/canopened = FALSE
var/is_glass = 0
var/is_plastic = 0
@@ -7,10 +8,6 @@
var/can_burst = FALSE
var/burst_chance = 0
-/obj/item/reagent_containers/food/drinks/cans/New()
- ..()
- flags &= ~OPENCONTAINER
-
/obj/item/reagent_containers/food/drinks/cans/examine(mob/user)
. = ..()
if(canopened)
@@ -26,7 +23,7 @@
return ..()
playsound(loc, 'sound/effects/canopen.ogg', rand(10, 50), 1)
canopened = TRUE
- flags |= OPENCONTAINER
+ container_type |= OPENCONTAINER
to_chat(user, "You open the drink with an audible pop!")
return ..()
@@ -111,7 +108,7 @@
/obj/item/reagent_containers/food/drinks/cans/proc/fizzy_open(mob/user, burstopen = FALSE)
playsound(loc, 'sound/effects/canopenfizz.ogg', rand(10, 50), 1)
canopened = TRUE
- flags |= OPENCONTAINER
+ container_type |= OPENCONTAINER
if(!burstopen && user)
to_chat(user, "You open the drink with an audible pop!")