From 76b0b45a0b2b95ae7eae11494d67956fa0ff3e39 Mon Sep 17 00:00:00 2001 From: DragonTrance Date: Sun, 27 Dec 2020 12:12:41 -0700 Subject: [PATCH 1/2] drink flinging fix finally --- code/modules/food_and_drinks/drinks/drinks.dm | 53 +++++++------------ .../food_and_drinks/drinks/drinks/bottle.dm | 34 ------------ code/modules/reagents/reagent_containers.dm | 15 +++--- .../reagents/reagent_containers/spray.dm | 1 - 4 files changed, 27 insertions(+), 76 deletions(-) diff --git a/code/modules/food_and_drinks/drinks/drinks.dm b/code/modules/food_and_drinks/drinks/drinks.dm index ad99e583..4a1000ef 100644 --- a/code/modules/food_and_drinks/drinks/drinks.dm +++ b/code/modules/food_and_drinks/drinks/drinks.dm @@ -13,7 +13,7 @@ possible_transfer_amounts = list(5,10,15,20,25,30,50) volume = 50 resistance_flags = NONE - var/isGlass = TRUE //Whether the 'bottle' is made of glass or not so that milk cartons dont shatter when someone gets hit by it + var/isGlass = TRUE //Whether the container is made of glass or not so that milk cartons dont shatter when someone gets hit by it splashable = TRUE /obj/item/reagent_containers/food/drinks/on_reagent_change(changetype) @@ -105,34 +105,43 @@ /obj/item/reagent_containers/food/drinks/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) . = ..() if(!.) //if the bottle wasn't caught - smash(hit_atom, throwingdatum?.thrower, TRUE) + smash(hit_atom, throwingdatum.thrower, TRUE) + +/obj/item/reagent_containers/food/drinks/after_throw(datum/callback/callback) + . = ..() + if (!QDELETED(src) || !QDELING(src)) //If we didn't get qdeleted by smash(), assume we got flung by a bartender + transform = initial(transform) + to_chat(viewers(8, get_turf(src)), "\The [src] lands upright without spilling a drop!") /obj/item/reagent_containers/food/drinks/proc/smash(atom/target, mob/thrower, ranged = FALSE) - if(!isGlass) + if (!isGlass) return - if(QDELING(src) || !target) //Invalid loc + if (QDELING(src) || !target) //Invalid loc return - if(bartender_check(target) && ranged) + if (bartender_check(thrower) && istype(target, /turf/open) && ranged) //Smash against windows and players, but not on floors or tables. The target is always an open turf if there is no density return + SplashReagents(target) var/obj/item/broken_bottle/B = new (loc) B.icon_state = icon_state - var/icon/I = new('icons/obj/drinks.dmi', src.icon_state) + var/icon/I = new(icon, icon_state) I.Blend(B.broken_outline, ICON_OVERLAY, rand(5), 1) I.SwapColor(rgb(255, 0, 220, 255), rgb(0, 0, 0, 0)) B.icon = I B.name = "broken [name]" - if(ranged) + transfer_fingerprints_to(B) + qdel(src) + if (ranged) var/matrix/M = matrix(B.transform) M.Turn(rand(-170, 170)) B.transform = M B.pixel_x = rand(-12, 12) B.pixel_y = rand(-12, 12) - if(prob(33)) - new/obj/item/shard(drop_location()) + else + thrower.put_in_hands(B) + if (prob(33)) + new/obj/item/shard(get_turf(target)) playsound(src, "shatter", 70, 1) - transfer_fingerprints_to(B) - qdel(src) @@ -305,28 +314,6 @@ icon_state = "juicebox" volume = 15 //I figure if you have to craft these it should at least be slightly better than something you can get for free from a watercooler -/obj/item/reagent_containers/food/drinks/sillycup/smallcarton/smash(atom/target, mob/thrower, ranged = FALSE) - if(bartender_check(target) && ranged) - return - var/obj/item/broken_bottle/B = new (loc) - B.icon_state = icon_state - var/icon/I = new('icons/obj/drinks.dmi', src.icon_state) - I.Blend(B.broken_outline, ICON_OVERLAY, rand(5), 1) - I.SwapColor(rgb(255, 0, 220, 255), rgb(0, 0, 0, 0)) - B.icon = I - B.name = "broken [name]" - B.force = 0 - B.throwforce = 0 - B.desc = "A carton with the bottom half burst open. Might give you a papercut." - if(ranged) - var/matrix/M = matrix(B.transform) - M.Turn(rand(-170, 170)) - B.transform = M - B.pixel_x = rand(-12, 12) - B.pixel_y = rand(-12, 12) - transfer_fingerprints_to(B) - qdel(src) - /obj/item/reagent_containers/food/drinks/sillycup/smallcarton/on_reagent_change(changetype) if (reagents.reagent_list.len) switch(reagents.get_master_reagent_id()) diff --git a/code/modules/food_and_drinks/drinks/drinks/bottle.dm b/code/modules/food_and_drinks/drinks/drinks/bottle.dm index e269612b..2787db0b 100644 --- a/code/modules/food_and_drinks/drinks/drinks/bottle.dm +++ b/code/modules/food_and_drinks/drinks/drinks/bottle.dm @@ -16,40 +16,6 @@ isGlass = TRUE foodtype = ALCOHOL - -/obj/item/reagent_containers/food/drinks/bottle/smash(mob/living/target, mob/thrower, ranged = FALSE) - //Creates a shattering noise and replaces the bottle with a broken_bottle - if(bartender_check(target) && ranged) - return - var/obj/item/broken_bottle/B = new (loc) - if(!ranged) - thrower.put_in_hands(B) - else - var/matrix/M = matrix(B.transform) - M.Turn(rand(-170, 170)) - B.transform = M - B.pixel_x = rand(-12, 12) - B.pixel_y = rand(-12, 12) - B.icon_state = icon_state - - var/icon/I = new('icons/obj/drinks.dmi', src.icon_state) - I.Blend(B.broken_outline, ICON_OVERLAY, rand(5), 1) - I.SwapColor(rgb(255, 0, 220, 255), rgb(0, 0, 0, 0)) - B.icon = I - - if(isGlass) - if(prob(33)) - new/obj/item/shard(drop_location()) - playsound(src, "shatter", 70, 1) - else - B.force = 0 - B.throwforce = 0 - B.desc = "A carton with the bottom half burst open. Might give you a papercut." - B.name = "broken [name]" - transfer_fingerprints_to(B) - - qdel(src) - /obj/item/reagent_containers/food/drinks/bottle/attack(mob/living/target, mob/living/user) if(!target) diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index 9cf908a1..727a336c 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -85,10 +85,10 @@ /obj/item/reagent_containers/proc/bartender_check(atom/target) . = FALSE var/turf/T = get_turf(src) - if(!T || target.CanPass(src, T) || !thrownby || !thrownby.actions) + if(!T || !thrownby || !thrownby.actions) //|| target.CanPass(src, T) || !thrownby || !thrownby.actions) return - for(var/datum/action/innate/drink_fling/D in thrownby.actions) - if(D.active) + for(var/datum/action/innate/D in thrownby.actions) + if(D.active && istype(D, /datum/action/innate/drink_fling)) return TRUE @@ -107,17 +107,16 @@ target.visible_message("[M] has been splashed with something!", \ "[M] has been splashed with something!") for(var/datum/reagent/A in reagents.reagent_list) - R += A.type + " (" - R += num2text(A.volume) + ")," + R += "[A.type] ([num2text(A.volume)]), " if(thrownby) log_combat(thrownby, M, "splashed", R) reagents.reaction(target, TOUCH) else if(bartender_check(target) && thrown) - visible_message("[src] lands onto the [target.name] without spilling a single drop.") - transform = initial(transform) - addtimer(CALLBACK(src, .proc/ForceResetRotation), 1) + if(!istype(src, /obj/item/reagent_containers/food/drinks)) //drinks smash against solid objects + visible_message("[src] lands upright without spilling a single drop!") + transform = initial(transform) return else diff --git a/code/modules/reagents/reagent_containers/spray.dm b/code/modules/reagents/reagent_containers/spray.dm index 1b2e6248..a0070273 100644 --- a/code/modules/reagents/reagent_containers/spray.dm +++ b/code/modules/reagents/reagent_containers/spray.dm @@ -63,7 +63,6 @@ log_game("[key_name(user)] fired Space lube from \a [src] at [AREACOORD(T)].") return - /obj/item/reagent_containers/spray/proc/spray(atom/A) var/range = CLAMP(get_dist(src, A), 1, current_range) var/obj/effect/decal/chempuff/D = new /obj/effect/decal/chempuff(get_turf(src)) From e57ba1502e516fa822cb3e94067be2e029f67993 Mon Sep 17 00:00:00 2001 From: DragonTrance Date: Sun, 27 Dec 2020 12:19:54 -0700 Subject: [PATCH 2/2] tiny bit of cleanup --- code/modules/food_and_drinks/drinks/drinks.dm | 2 ++ code/modules/reagents/reagent_containers.dm | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/code/modules/food_and_drinks/drinks/drinks.dm b/code/modules/food_and_drinks/drinks/drinks.dm index 4a1000ef..f3f4a118 100644 --- a/code/modules/food_and_drinks/drinks/drinks.dm +++ b/code/modules/food_and_drinks/drinks/drinks.dm @@ -109,6 +109,8 @@ /obj/item/reagent_containers/food/drinks/after_throw(datum/callback/callback) . = ..() + if (!isGlass) + return if (!QDELETED(src) || !QDELING(src)) //If we didn't get qdeleted by smash(), assume we got flung by a bartender transform = initial(transform) to_chat(viewers(8, get_turf(src)), "\The [src] lands upright without spilling a drop!") diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index 727a336c..31c80248 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -85,7 +85,7 @@ /obj/item/reagent_containers/proc/bartender_check(atom/target) . = FALSE var/turf/T = get_turf(src) - if(!T || !thrownby || !thrownby.actions) //|| target.CanPass(src, T) || !thrownby || !thrownby.actions) + if(!T || !thrownby || !thrownby.actions) return for(var/datum/action/innate/D in thrownby.actions) if(D.active && istype(D, /datum/action/innate/drink_fling))