Skip to content

Commit

Permalink
Merge pull request #1088 from ariaworld/chug-yes
Browse files Browse the repository at this point in the history
[NON-MODULAR + CLEANUP] Adds chugging to any type of liquid container + optimizes and fixes some drinking code
  • Loading branch information
MosleyTheMalO authored Mar 3, 2024
2 parents 856621f + 1fc8b9d commit 4c01698
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
15 changes: 8 additions & 7 deletions code/modules/food_and_drinks/drinks/drinks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
righthand_file = 'icons/mob/inhands/misc/food_righthand.dmi'
reagent_flags = OPENCONTAINER
reagent_value = DEFAULT_REAGENTS_VALUE
var/gulp_size = 5 //This is now officially broken ... need to think of a nice way to fix it.
var/gulp_size = 5
possible_transfer_amounts = list(5,10,15,20,25,30,50)
volume = 50
resistance_flags = NONE
Expand All @@ -23,14 +23,14 @@
/obj/item/reagent_containers/food/drinks/attack(mob/living/M, mob/user, def_zone)
if(!reagents || !reagents.total_volume)
to_chat(user, "<span class='warning'>[src] is empty!</span>")
return 0
return

if(!canconsume(M, user))
return 0
return

if (!is_drainable())
to_chat(user, "<span class='warning'>[src]'s lid hasn't been opened!</span>")
return 0
return

var/gulp_amount = gulp_size
if(M == user)
Expand All @@ -39,16 +39,17 @@
user.visible_message("<span class='notice'>[user] starts chugging [src].</span>", \
"<span class='notice'>You start chugging [src].</span>")
if(!do_mob(user, M))
beingChugged = FALSE
return
if(!reagents || !reagents.total_volume)
beingChugged = FALSE
return
gulp_amount = 50
user.visible_message("<span class='notice'>[user] chugs [src].</span>", \
"<span class='notice'>You chug [src].</span>")
beingChugged = FALSE
else
user.visible_message("<span class='notice'>[user] swallows a gulp of [src].</span>", \
"<span class='notice'>You swallow a gulp of [src].</span>")
to_chat(user, "<span class='notice'>You swallow a gulp of [src].</span>")
else
M.visible_message("<span class='danger'>[user] attempts to feed the contents of [src] to [M].</span>", "<span class='userdanger'>[user] attempts to feed the contents of [src] to [M].</span>")
if(!do_mob(user, M))
Expand All @@ -63,7 +64,7 @@
reagents.reaction(M, INGEST, fraction)
reagents.trans_to(M, gulp_amount, log = TRUE)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
return 1
return TRUE

/obj/item/reagent_containers/food/drinks/CheckAttackCooldown(mob/user, atom/target)
var/fast = HAS_TRAIT(user, TRAIT_VORACIOUS) && (user == target)
Expand Down
40 changes: 27 additions & 13 deletions code/modules/reagents/reagent_containers/glass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
spillable = TRUE
resistance_flags = ACID_PROOF
container_HP = 2
var/gulp_size = 5
var/beingChugged = FALSE

/obj/item/reagent_containers/glass/attack(mob/M, mob/user, obj/target)
// WARNING: This entire section is shitcode and prone to breaking at any time.
INVOKE_ASYNC(src, .proc/attempt_feed, M, user, target) // for example, the arguments in this proc are wrong
// but i don't have time to properly fix it right now.

/obj/item/reagent_containers/glass/proc/attempt_feed(mob/M, mob/user, obj/target)
if(!canconsume(M, user))
return

Expand All @@ -24,6 +21,8 @@
to_chat(user, "<span class='warning'>[src] is empty!</span>")
return

var/gulp_amount = gulp_size
var/self_fed = M == user
if(istype(M))
if(user.a_intent == INTENT_HARM)
M.visible_message("<span class='danger'>[user] splashes the contents of [src] onto [M]!</span>", \
Expand All @@ -41,8 +40,26 @@
log_reagent("SPLASH: attack(target mob [key_name(M)] at [AREACOORD(MT)], from user [key_name(user)] at [AREACOORD(UT)], target object [target] at [AREACOORD(OT)]) - [R]")
reagents.clear_reagents()
else
var/self_fed = M == user
if(!self_fed)
if(self_fed)
if(user.zone_selected == BODY_ZONE_PRECISE_MOUTH && !beingChugged)
beingChugged = TRUE
user.visible_message("<span class='notice'>[user] starts chugging [src].</span>", \
"<span class='notice'>You start chugging [src].</span>")
if(!do_mob(user, M))
beingChugged = FALSE
return
if(!reagents || !reagents.total_volume)
beingChugged = FALSE
return
gulp_amount = 50
user.visible_message(span_notice("[user] chugs [src]."), \
span_notice("You chug [src]."))
beingChugged = FALSE
else
var/turf/T = get_turf(user)
to_chat(user, "<span class='notice'>You swallow a gulp of [src].</span>")
log_reagent("INGESTION: SELF: [key_name(user)] (loc [user.loc] at [AREACOORD(T)]) - [reagents.log_list()]")
else
M.visible_message("<span class='danger'>[user] attempts to feed something to [M].</span>", \
"<span class='userdanger'>[user] attempts to feed something to you.</span>")
log_combat(user, M, "is attempting to feed", reagents.log_list())
Expand All @@ -55,14 +72,11 @@
M.visible_message("<span class='danger'>[user] feeds something to [M].</span>", "<span class='userdanger'>[user] feeds something to you.</span>")
log_combat(user, M, "fed", reagents.log_list())
log_reagent("INGESTION: FED BY: [key_name(user)] (loc [user.loc] at [AREACOORD(UT)]) -> [key_name(M)] (loc [M.loc] at [AREACOORD(MT)]) - [reagents.log_list()]")
else
var/turf/T = get_turf(user)
to_chat(user, "<span class='notice'>You swallow a gulp of [src].</span>")
log_reagent("INGESTION: SELF: [key_name(user)] (loc [user.loc] at [AREACOORD(T)]) - [reagents.log_list()]")
var/fraction = min(5/reagents.total_volume, 1)
var/fraction = min(gulp_amount/reagents.total_volume, 1)
reagents.reaction(M, INGEST, fraction)
addtimer(CALLBACK(reagents, /datum/reagents.proc/trans_to, M, 5, null, null, null, self_fed? "self swallowed" : "fed by [user]"), 5)
reagents.trans_to(M, gulp_amount, log = TRUE)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
return TRUE

/obj/item/reagent_containers/glass/afterattack(obj/target, mob/user, proximity)
. = ..()
Expand Down

0 comments on commit 4c01698

Please sign in to comment.