From 70252d291464443d001981b94ea3093d2d44b85e Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Sat, 14 Dec 2019 19:20:02 +0100 Subject: [PATCH 1/6] Fixing a few pill bottle issues with the ChemMaster. --- .../chemistry/machinery/chem_dispenser.dm | 2 +- .../chemistry/machinery/chem_master.dm | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm index a3dd3c8049..c6aa51deda 100644 --- a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm +++ b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm @@ -161,7 +161,7 @@ . = ..() if(A == beaker) beaker = null - cut_overlays() + update_icon() /obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index 06e33ddf9f..6cd8ee8e8c 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -58,14 +58,14 @@ if(bottle) bottle.ex_act(severity, target) -/obj/machinery/chem_master/handle_atom_del(atom/A) - ..() +/obj/machinery/chem_master/Exited(atom/movable/A, atom/newloc) + . = ..() if(A == beaker) beaker = null - reagents.clear_reagents() update_icon() - else if(A == bottle) + if(A == bottle) bottle = null + update_icon() /obj/machinery/chem_master/update_icon() cut_overlays() @@ -115,32 +115,33 @@ . = ..() if(!istype(user) || !user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK)) return - replace_beaker(user) + if(beaker) + replace_beaker(user) + else + replace_pillbottle(user) return TRUE /obj/machinery/chem_master/proc/replace_beaker(mob/living/user, obj/item/reagent_containers/new_beaker) if(beaker) - beaker.forceMove(drop_location()) + var/obj/item/reagent_containers/beaker/B = beaker + B.forceMove(drop_location()) if(user && Adjacent(user) && !issiliconoradminghost(user)) - user.put_in_hands(beaker) + B.put_in_hands(beaker) if(new_beaker) beaker = new_beaker - else - beaker = null update_icon() return TRUE /obj/machinery/chem_master/proc/replace_pillbottle(mob/living/user, obj/item/storage/pill_bottle/new_bottle) if(bottle) - bottle.forceMove(drop_location()) + var/obj/item/storage/pill_bottle/B = bottle + B.forceMove(drop_location()) if(user && Adjacent(user) && !issiliconoradminghost(user)) - user.put_in_hands(beaker) + B.put_in_hands(bottle) else - adjust_item_drop_location(bottle) + adjust_item_drop_location(B) if(new_bottle) bottle = new_bottle - else - bottle = null update_icon() return TRUE @@ -261,15 +262,16 @@ if(!name || !reagents.total_volume || !src || QDELETED(src) || !usr.canUseTopic(src, !issilicon(usr))) return var/obj/item/reagent_containers/pill/P - var/target_loc = bottle ? bottle : drop_location() + var/target_loc = drop_location() var/drop_threshold = INFINITY if(bottle) var/datum/component/storage/STRB = bottle.GetComponent(/datum/component/storage) if(STRB) drop_threshold = STRB.max_items - bottle.contents.len + target_loc = bottle for(var/i in 1 to amount) - if(i < drop_threshold) + if(i <= drop_threshold) P = new(target_loc) else P = new(drop_location()) From 6117434c7f04ddb3b3a08de26a322ccbe8305386 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Sat, 14 Dec 2019 19:24:43 +0100 Subject: [PATCH 2/6] Ok --- code/modules/reagents/chemistry/machinery/chem_master.dm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index 6cd8ee8e8c..fec0734092 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -117,7 +117,7 @@ return if(beaker) replace_beaker(user) - else + else if(bottle) replace_pillbottle(user) return TRUE @@ -130,7 +130,6 @@ if(new_beaker) beaker = new_beaker update_icon() - return TRUE /obj/machinery/chem_master/proc/replace_pillbottle(mob/living/user, obj/item/storage/pill_bottle/new_bottle) if(bottle) @@ -142,8 +141,6 @@ adjust_item_drop_location(B) if(new_bottle) bottle = new_bottle - update_icon() - return TRUE /obj/machinery/chem_master/on_deconstruction() replace_beaker(usr) From 2ccfaf38fbb16d79c4b3d721e4fd9f593e27f0f4 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Sat, 14 Dec 2019 19:27:39 +0100 Subject: [PATCH 3/6] consistency. --- code/modules/reagents/chemistry/machinery/chem_master.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index fec0734092..a3cc357307 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -103,6 +103,10 @@ updateUsrDialog() update_icon() else if(!condi && istype(I, /obj/item/storage/pill_bottle)) + . = TRUE // no afterattack + if(panel_open) + to_chat(user, "You can't use the [src.name] while its panel is opened!") + return if(!user.transferItemToLoc(I, src)) return replace_pillbottle(user, I) From 12b87b4f3d53416808ec4e9707d5a07cf345de41 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Sat, 14 Dec 2019 19:29:51 +0100 Subject: [PATCH 4/6] Better. --- code/modules/reagents/chemistry/machinery/chem_master.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index a3cc357307..88d67d2514 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -147,8 +147,9 @@ bottle = new_bottle /obj/machinery/chem_master/on_deconstruction() - replace_beaker(usr) - replace_pillbottle(usr) + var/atom/A = drop_location() + beaker.forceMove(A) + bottle.forceMove(A) return ..() /obj/machinery/chem_master/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ From d3d1f8328f47b9eef95d0a7e926e7e86cd3656f0 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Sun, 15 Dec 2019 22:16:02 +0100 Subject: [PATCH 5/6] compiles now. --- code/modules/reagents/chemistry/machinery/chem_master.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index 88d67d2514..bab986c6be 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -127,7 +127,7 @@ /obj/machinery/chem_master/proc/replace_beaker(mob/living/user, obj/item/reagent_containers/new_beaker) if(beaker) - var/obj/item/reagent_containers/beaker/B = beaker + var/obj/item/reagent_containers/B = beaker B.forceMove(drop_location()) if(user && Adjacent(user) && !issiliconoradminghost(user)) B.put_in_hands(beaker) From 843f4ed0da0426ab38c5484011a5ece317d3d3bb Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Mon, 16 Dec 2019 02:44:58 +0100 Subject: [PATCH 6/6] FLAK --- code/modules/reagents/chemistry/machinery/chem_master.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index bab986c6be..1ac62ba651 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -130,7 +130,7 @@ var/obj/item/reagent_containers/B = beaker B.forceMove(drop_location()) if(user && Adjacent(user) && !issiliconoradminghost(user)) - B.put_in_hands(beaker) + user.put_in_hands(B) if(new_beaker) beaker = new_beaker update_icon() @@ -140,7 +140,7 @@ var/obj/item/storage/pill_bottle/B = bottle B.forceMove(drop_location()) if(user && Adjacent(user) && !issiliconoradminghost(user)) - B.put_in_hands(bottle) + user.put_in_hands(B) else adjust_item_drop_location(B) if(new_bottle)