From e602b3db8b9892bec200ffa773997a3ad2c0ff28 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 10 Feb 2024 05:05:05 +0100 Subject: [PATCH] [MIRROR] Fixes screwdriver cocktail not being a screwdriver. (#26439) * Fixes screwdriver cocktail not being a screwdriver. (#81030) ## About The Pull Request Alternative title: The screwdriver cocktail is now the world's worst screwdriver (for real this time). As mentioned in my writeup in the related issue (#81017), as far as I know, it has never actually worked. Tl;dr: It requires `on_transfer` to be called with the method as ingestion, but in no way does transferring into a drinking glass ever use that method, and most ways don't even specify a method and thus `on_transfer` doesn't even get called in the first place. Then I went back to the original pr and tried it, and it didn't work. Then for resolving it, it feels unwieldy to do all this trickery on the reagent to change a value on the drinking glass when the drinking glass already has the perfect procs for this: the `on_cup_change` and `on_cup_reset` callbacks. Instead of using `on_transfer` and registering a hell of a lot of signals to re-check the master reagent every time the contents get changed, we just check whether the style we changed into is that of a screwdriver cocktail. This actually works. Oh, and I also added use sounds because it didn't have them, which I believe only actually get used when using it as a tool and thus only when it's a screwdriver. ## Why It's Good For The Game Fixes #81017. ## Changelog :cl: fix: As they should've for a while, screwdrivers (cocktail) actually work as screwdrivers (tool). sound: The screwdriver cocktail also actually plays the screwdriver sound when used. /:cl: --------- Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com> * Fixes screwdriver cocktail not being a screwdriver. --------- Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com> --- .../reagents/drinks/alcohol_reagents.dm | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm b/code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm index 9439176fd09..8963e21c911 100644 --- a/code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm @@ -589,37 +589,55 @@ taste_description = "oranges" chemical_flags = REAGENT_CAN_BE_SYNTHESIZED -/datum/reagent/consumable/ethanol/screwdrivercocktail/on_transfer(atom/atom, methods = TOUCH, trans_volume) - if(!(methods & INGEST)) - return ..() - - if(src == atom.reagents.get_master_reagent() && istype(atom, /obj/item/reagent_containers/cup/glass/drinkingglass)) - var/obj/item/reagent_containers/cup/glass/drinkingglass/drink = atom - drink.tool_behaviour = TOOL_SCREWDRIVER +/datum/reagent/consumable/ethanol/screwdrivercocktail/on_new(data) + . = ..() + // We want to turn only base drinking glasses with screwdriver(cocktail) into screwdrivers(tool), + // but we can't check style so we have to check type, and we don't want it match subtypes like istype does + if(holder?.my_atom && holder.my_atom.type == /obj/item/reagent_containers/cup/glass/drinkingglass/) var/list/reagent_change_signals = list( COMSIG_REAGENTS_ADD_REAGENT, COMSIG_REAGENTS_NEW_REAGENT, COMSIG_REAGENTS_REM_REAGENT, - COMSIG_REAGENTS_DEL_REAGENT, - COMSIG_REAGENTS_CLEAR_REAGENTS, - COMSIG_REAGENTS_REACTED, ) - RegisterSignals(drink.reagents, reagent_change_signals, PROC_REF(on_reagent_change)) - - return ..() + RegisterSignals(holder, reagent_change_signals, PROC_REF(on_reagent_change)) + RegisterSignal(holder, COMSIG_REAGENTS_CLEAR_REAGENTS, PROC_REF(on_reagents_clear)) + RegisterSignal(holder, COMSIG_REAGENTS_DEL_REAGENT, PROC_REF(on_reagent_delete)) + if(src == holder.get_master_reagent()) + var/obj/item/reagent_containers/cup/glass/drinkingglass/drink = holder.my_atom + drink.tool_behaviour = TOOL_SCREWDRIVER + drink.usesound = list('sound/items/screwdriver.ogg', 'sound/items/screwdriver2.ogg') /datum/reagent/consumable/ethanol/screwdrivercocktail/proc/on_reagent_change(datum/reagents/reagents) SIGNAL_HANDLER - if(src != reagents.get_master_reagent()) - var/obj/item/reagent_containers/cup/glass/drinkingglass/drink = reagents.my_atom + var/obj/item/reagent_containers/cup/glass/drinkingglass/drink = reagents.my_atom + if(reagents.get_master_reagent() == src) + drink.tool_behaviour = TOOL_SCREWDRIVER + drink.usesound = list('sound/items/screwdriver.ogg', 'sound/items/screwdriver2.ogg') + else drink.tool_behaviour = initial(drink.tool_behaviour) - UnregisterSignal(reagents, list( + drink.usesound = initial(drink.usesound) + +/datum/reagent/consumable/ethanol/screwdrivercocktail/proc/on_reagents_clear(datum/reagents/reagents) + SIGNAL_HANDLER + unregister_screwdriver(reagents) + +/datum/reagent/consumable/ethanol/screwdrivercocktail/proc/on_reagent_delete(datum/reagents/reagents, datum/reagent/deleted_reagent) + SIGNAL_HANDLER + if(deleted_reagent != src) + return + unregister_screwdriver(reagents) + +/datum/reagent/consumable/ethanol/screwdrivercocktail/proc/unregister_screwdriver(datum/reagents/reagents) + var/obj/item/reagent_containers/cup/glass/drinkingglass/drink = reagents.my_atom + if(drink.tool_behaviour == TOOL_SCREWDRIVER) + drink.tool_behaviour = initial(drink.tool_behaviour) + drink.usesound = initial(drink.usesound) + UnregisterSignal(reagents, list( COMSIG_REAGENTS_ADD_REAGENT, COMSIG_REAGENTS_NEW_REAGENT, COMSIG_REAGENTS_REM_REAGENT, COMSIG_REAGENTS_DEL_REAGENT, COMSIG_REAGENTS_CLEAR_REAGENTS, - COMSIG_REAGENTS_REACTED, )) /datum/reagent/consumable/ethanol/screwdrivercocktail/on_mob_life(mob/living/carbon/drinker, seconds_per_tick, times_fired)