From 391ddd970e68dc0ba06dafd5fd8303052e8ea066 Mon Sep 17 00:00:00 2001 From: Zuhayr Date: Tue, 24 Feb 2015 17:55:39 +1030 Subject: [PATCH] Resolves remaining issues with xenohydro PR. --- .../hydroponics/spreading/spreading.dm | 6 ++-- code/modules/hydroponics/trays/tray.dm | 2 +- .../hydroponics/trays/tray_update_icons.dm | 3 +- code/modules/reagents/Chemistry-Machinery.dm | 33 ++++++++++++++++--- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/code/modules/hydroponics/spreading/spreading.dm b/code/modules/hydroponics/spreading/spreading.dm index 22dbabe2757..4f52b82ceea 100644 --- a/code/modules/hydroponics/spreading/spreading.dm +++ b/code/modules/hydroponics/spreading/spreading.dm @@ -114,11 +114,11 @@ spread_chance = seed.get_trait(TRAIT_POTENCY) spread_distance = ((growth_type>0) ? round(spread_chance*0.6) : round(spread_chance*0.3)) - - set_dir(calc_dir()) update_icon() - spawn(1) + spawn(1) // Plants will sometimes be spawned in the turf adjacent to the one they need to end up in, for the sake of correct dir/etc being set. + set_dir(calc_dir()) + update_icon() plant_controller.add_plant(src) // Some plants eat through plating. if(!isnull(seed.chems["pacid"])) diff --git a/code/modules/hydroponics/trays/tray.dm b/code/modules/hydroponics/trays/tray.dm index 968d707472e..d915a116c58 100644 --- a/code/modules/hydroponics/trays/tray.dm +++ b/code/modules/hydroponics/trays/tray.dm @@ -530,7 +530,7 @@ A.hydrotray_type = src.type del(src) else if(O.force && seed) - user.visible_message("\The [user] attacks the [seed.display_name] with \the [O]!") + user.visible_message("\The [seed.display_name] has been attacked by [user] with \the [O]!") if(!dead) health -= O.force check_health() diff --git a/code/modules/hydroponics/trays/tray_update_icons.dm b/code/modules/hydroponics/trays/tray_update_icons.dm index e13bf644f0d..ea8fb669cde 100644 --- a/code/modules/hydroponics/trays/tray_update_icons.dm +++ b/code/modules/hydroponics/trays/tray_update_icons.dm @@ -36,8 +36,7 @@ if(age >= seed.get_trait(TRAIT_MATURATION)) overlay_stage = seed.growth_stages else - overlay_stage = max(1,round(seed.get_trait(TRAIT_MATURATION) / seed.growth_stages)) - + overlay_stage = max(1,round(age/round(seed.get_trait(TRAIT_MATURATION)/seed.growth_stages))) var/ikey = "[seed.get_trait(TRAIT_PLANT_ICON)]-[overlay_stage]" var/image/plant_overlay = plant_controller.plant_icon_cache["[ikey]-[seed.get_trait(TRAIT_PLANT_COLOUR)]"] if(!plant_overlay) diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index dbe37780be9..8d3f0016cf7 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -3,8 +3,8 @@ #define GAS 3 #define CHEM_DISPENSER_ENERGY_COST 0.1 //How many energy points do we use per unit of chemical? - #define BOTTLE_SPRITES list("bottle-1", "bottle-2", "bottle-3", "bottle-4") //list of available bottle sprites +#define REAGENTS_PER_SHEET 20 /obj/machinery/chem_dispenser name = "chem dispenser" @@ -827,6 +827,14 @@ var/obj/item/weapon/reagent_containers/beaker = null var/limit = 10 var/list/holdingitems = list() + var/list/sheet_reagents = list( + /obj/item/stack/sheet/mineral/iron = "iron", + /obj/item/stack/sheet/mineral/uranium = "uranium", + /obj/item/stack/sheet/mineral/phoron = "phoron", + /obj/item/stack/sheet/mineral/gold = "gold", + /obj/item/stack/sheet/mineral/silver = "silver", + /obj/item/stack/sheet/mineral/mhydrogen = "hydrogen" + ) /obj/machinery/reagentgrinder/New() ..() @@ -857,12 +865,10 @@ usr << "The machine cannot hold anymore items." return 1 - //Fill machine with the plantbag! if(!istype(O)) return if(istype(O,/obj/item/weapon/storage/bag/plants)) - var/failed = 1 for (var/obj/item/G in O.contents) if(!O.reagents || !O.reagents.total_volume) @@ -886,7 +892,7 @@ src.updateUsrDialog() return 0 - if(!O.reagents || !O.reagents.total_volume) + if(!sheet_reagents[O.type] && (!O.reagents || !O.reagents.total_volume)) user << "\The [O] is not suitable for blending." return 1 @@ -1008,8 +1014,25 @@ // Process. for (var/obj/item/O in holdingitems) - O.reagents.trans_to(beaker, min(O.reagents.total_volume, (beaker.reagents.maximum_volume - beaker.reagents.total_volume))) + + if(!O || !istype(O)) + holdingitems -= null + continue + + var/remaining_volume = beaker.reagents.maximum_volume - beaker.reagents.total_volume + if(sheet_reagents[O.type]) + var/obj/item/stack/stack = O + if(istype(stack)) + var/amount_to_take = max(0,min(stack.amount,round(remaining_volume/REAGENTS_PER_SHEET))) + if(amount_to_take) + stack.use(amount_to_take) + beaker.reagents.add_reagent(sheet_reagents[stack.type], (amount_to_take*REAGENTS_PER_SHEET)) + continue + + O.reagents.trans_to(beaker, min(O.reagents.total_volume, remaining_volume)) if(O.reagents.total_volume == 0) remove_object(O) if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume) break + +#undef REAGENTS_PER_SHEET \ No newline at end of file