diff --git a/code/game/machinery/reagents/pump.dm b/code/game/machinery/reagents/pump.dm deleted file mode 100644 index c48e8d9834..0000000000 --- a/code/game/machinery/reagents/pump.dm +++ /dev/null @@ -1,270 +0,0 @@ - -/obj/machinery/pump - name = "fluid pump" - desc = "A fluid pumping machine." - - description_info = "A machine that can pump fluid from certain turfs.
\ - Water can be pumped from any body of water. Certain locations or environmental\ - conditions can cause different byproducts to be produced.
\ - Magma or Lava can be pumped to produce mineralized fluid." - - anchored = FALSE - density = TRUE - - icon = 'icons/obj/machines/reagent.dmi' - icon_state = "pump" - - circuit = /obj/item/weapon/circuitboard/fluidpump - - var/on = 0 - var/obj/item/weapon/cell/cell = null - var/use = 200 - var/efficiency = 1 - var/reagents_per_cycle = 40 - var/unlocked = 0 - var/open = 0 - - var/obj/item/hose_connector/output/Output - -// Overlay cache vars. - var/icon/liquid - var/icon/tank - var/icon/powerlow - var/icon/glass - var/icon/open_overlay - var/icon/cell_overlay - -/obj/machinery/pump/Initialize() - create_reagents(200) - . = ..() - default_apply_parts() - - if(ispath(cell)) - cell = new cell(src) - - Output = new(src) - - RefreshParts() - update_icon() - -/obj/machinery/pump/update_icon() - ..() - if(!tank) - tank = new/icon(icon, "[icon_state]-volume") - - if(!powerlow) - powerlow = new/icon(icon, "[icon_state]-lowpower") - - if(!liquid) - var/icon/cutter = new/icon(icon, "[icon_state]-volume") - - cutter.Blend(rgb(0, 0, 0,), ICON_MULTIPLY) - - liquid = new/icon(icon, "[icon_state]-cutting") - - liquid.Blend(cutter,ICON_AND) - - if(!glass) - glass = new/icon(icon, "[icon_state]-glass") - - glass.Blend(rgb(1,1,1,0.5), ICON_MULTIPLY) - - if(!open_overlay) - open_overlay = new/icon(icon, "[icon_state]-open") - - if(!cell_overlay) - cell_overlay = new/icon(icon, "[icon_state]-cell") - - cut_overlays() - add_overlay(tank) - - if(cell && cell.charge < (use * CELLRATE / efficiency)) - add_overlay(powerlow) - - if(reagents.total_volume >= 1) - var/list/hextorgb = hex2rgb(reagents.get_color()) - liquid.GrayScale() - - liquid.Blend(rgb(hextorgb[1],hextorgb[2],hextorgb[3]),ICON_MULTIPLY) - - add_overlay(liquid) - - add_overlay(glass) - - if(open) - add_overlay(open_overlay) - - if(cell) - add_overlay(cell_overlay) - - if(on) - icon_state = "[initial(icon_state)]-running" - - else - icon_state = "[initial(icon_state)]" - -/obj/machinery/pump/process() - if(Output.get_pairing()) - reagents.trans_to_holder(Output.reagents, Output.reagents.maximum_volume) - if(prob(5)) - visible_message("\The [src] gurgles as it exports fluid.") - - if(!on) - return - - if(!cell || (cell.charge < (use * CELLRATE / efficiency))) - turn_off(TRUE) - return - - handle_pumping() - update_icon() - -/obj/machinery/pump/RefreshParts() - for(var/obj/item/weapon/stock_parts/manipulator/SM in component_parts) - efficiency = SM.rating - - var/total_bin_rating = 0 - for(var/obj/item/weapon/stock_parts/matter_bin/SB in component_parts) - total_bin_rating += SB.rating - - reagents.maximum_volume = round(initial(reagents.maximum_volume) + 100 * total_bin_rating) - - return - -/obj/machinery/pump/power_change() - if(!cell || cell.charge < (use * CELLRATE) || !anchored) - return turn_off(TRUE) - - return FALSE - - -// Returns 0 on failure and 1 on success -/obj/machinery/pump/proc/turn_on(var/loud = 0) - if(!cell) - return 0 - if(cell.charge < (use * CELLRATE)) - return 0 - - on = 1 - update_icon() - if(loud) - visible_message("\The [src] turns on.") - return 1 - -/obj/machinery/pump/proc/turn_off(var/loud = 0) - on = 0 - set_light(0, 0) - update_icon() - if(loud) - visible_message("\The [src] shuts down.") - - if(!on) - return TRUE - - return FALSE - -/obj/machinery/pump/attack_ai(mob/user as mob) - if(istype(user, /mob/living/silicon/robot) && Adjacent(user)) - return attack_hand(user) - - if(on) - turn_off(TRUE) - else - if(!turn_on(1)) - to_chat(user, "You try to turn on \the [src] but it does not work.") - -/obj/machinery/pump/attack_hand(mob/user as mob) - if(open && cell) - if(ishuman(user)) - if(!user.get_active_hand()) - user.put_in_hands(cell) - cell.loc = user.loc - else - cell.loc = src.loc - - cell.add_fingerprint(user) - cell.update_icon() - - cell = null - on = 0 - set_light(0) - to_chat(user, "You remove the power cell.") - update_icon() - return - - if(on) - turn_off(TRUE) - else if(anchored) - if(!turn_on(1)) - to_chat(user, "You try to turn on \the [src] but it does not work.") - - update_icon() - -/obj/machinery/pump/attackby(obj/item/weapon/W as obj, mob/user as mob) - if(W.is_screwdriver()) - if(!open) - if(unlocked) - unlocked = 0 - to_chat(user, "You screw the battery panel in place.") - else - unlocked = 1 - to_chat(user, "You unscrew the battery panel.") - - else if(W.is_crowbar()) - if(unlocked) - if(open) - open = 0 - overlays = null - to_chat(user, "You crowbar the battery panel in place.") - else - if(unlocked) - open = 1 - to_chat(user, "You remove the battery panel.") - - else if(W.is_wrench()) - if(on) - to_chat(user, "\The [src] is active. Turn it off before trying to move it!") - return - default_unfasten_wrench(user, W, 2 SECONDS) - - else if(istype(W, /obj/item/weapon/cell)) - if(open) - if(cell) - to_chat(user, "There is a power cell already installed.") - else - user.drop_item() - W.loc = src - cell = W - to_chat(user, "You insert the power cell.") - else - ..() - RefreshParts() - update_icon() - -/obj/machinery/pump/proc/handle_pumping() - var/turf/T = get_turf(src) - - if(istype(T, /turf/simulated/floor/water)) - cell.use(use * CELLRATE / efficiency) - reagents.add_reagent("water", reagents_per_cycle) - - if(T.temperature <= T0C) - reagents.add_reagent("ice", round(reagents_per_cycle / 2, 0.1)) - - if((istype(T,/turf/simulated/floor/water/pool) || istype(T,/turf/simulated/floor/water/deep/pool))) - reagents.add_reagent("chlorine", round(reagents_per_cycle / 10 * efficiency, 0.1)) - - else if(istype(T,/turf/simulated/floor/water/contaminated)) - reagents.add_reagent("vatstabilizer", round(reagents_per_cycle / 2)) - - if(T.loc.name == "Sea") // Saltwater. - reagents.add_reagent("sodiumchloride", round(reagents_per_cycle / 10 * efficiency, 0.1)) - - for(var/turf/simulated/mineral/MT in range(5)) - if(MT.mineral) - var/obj/effect/mineral/OR = MT.mineral - reagents.add_reagent(OR.ore_reagent, round(reagents_per_cycle / 20 * efficiency, 0.1)) - - else if(istype(T, /turf/simulated/floor/lava)) - cell.use(use * CELLRATE / efficiency * 4) - reagents.add_reagent("mineralizedfluid", round(reagents_per_cycle * efficiency / 2, 0.1)) diff --git a/code/modules/reagents/machinery/pump.dm b/code/modules/reagents/machinery/pump.dm new file mode 100644 index 0000000000..6c9302d61e --- /dev/null +++ b/code/modules/reagents/machinery/pump.dm @@ -0,0 +1,205 @@ +/obj/machinery/pump + name = "fluid pump" + desc = "A fluid pumping machine." + + description_info = "A machine that can pump fluid from certain turfs.
\ + Water can be pumped from any body of water. Certain locations or environmental\ + conditions can cause different byproducts to be produced.
\ + Magma or Lava can be pumped to produce mineralized fluid." + + anchored = 0 + density = 1 + + icon = 'icons/obj/machines/reagent.dmi' + icon_state = "pump" + + circuit = /obj/item/weapon/circuitboard/fluidpump + active_power_usage = 200 * CELLRATE + + var/obj/item/weapon/cell/cell = null + var/obj/item/hose_connector/output/Output = null + var/reagents_per_cycle = 40 + var/on = 0 + var/unlocked = 0 + var/open = 0 + +/obj/machinery/pump/Initialize() + create_reagents(200) + . = ..() + default_apply_parts() + cell = default_use_hicell() + + Output = new(src) + + RefreshParts() + update_icon() + +/obj/machinery/pump/Destroy() + QDEL_NULL(cell) + QDEL_NULL(Output) + . = ..() + +/obj/machinery/pump/RefreshParts() + var/obj/item/weapon/stock_parts/manipulator/SM = locate() in component_parts + active_power_usage = initial(active_power_usage) / SM.rating + + var/motor_power = 0 + for(var/obj/item/weapon/stock_parts/motor/M in component_parts) + motor_power += M.rating + reagents_per_cycle = initial(reagents_per_cycle) * motor_power / 2 + + var/bin_size = 0 + for(var/obj/item/weapon/stock_parts/matter_bin/SB in component_parts) + bin_size += SB.rating + + // New holder might have different volume. Transfer everything to a new holder to account for this. + var/datum/reagents/R = new(round(initial(reagents.maximum_volume) + 100 * bin_size), src) + src.reagents.trans_to_holder(R, src.reagents.total_volume) + qdel(src.reagents) + src.reagents = R + +/obj/machinery/pump/update_icon() + ..() + cut_overlays() + add_overlay("[icon_state]-tank") + if(!(cell?.check_charge(active_power_usage))) + add_overlay("[icon_state]-lowpower") + + if(reagents.total_volume >= 1) + var/image/I = image(icon, "[icon_state]-volume") + I.color = reagents.get_color() + add_overlay(I) + add_overlay("[icon_state]-glass") + + if(open) + add_overlay("[icon_state]-open") + if(istype(cell)) + add_overlay("[icon_state]-cell") + + icon_state = "[initial(icon_state)][on ? "-running" : ""]" + +/obj/machinery/pump/process() + if(!on) + return + + if(!anchored || !(cell?.use(active_power_usage))) + set_state(FALSE) + return + + var/turf/T = get_turf(src) + if(!istype(T)) + return + T.pump_reagents(reagents, reagents_per_cycle) + update_icon() + + if(Output.get_pairing()) + reagents.trans_to_holder(Output.reagents, Output.reagents.maximum_volume) + if(prob(5)) + visible_message("\The [src] gurgles as it pumps fluid.") + + +// Sets the power state, if possible. +// Returns TRUE/FALSE on power state changing +// var/target = target power state +// var/message = TRUE/FALSE whether to make a message about state change +/obj/machinery/pump/proc/set_state(var/target, var/message = TRUE) + if(target == on) + return FALSE + + if(!on && (!(cell?.check_charge(active_power_usage)) || !anchored)) + return FALSE + + on = !on + update_icon() + if(message) + if(on) + message = SPAN_NOTICE("\The [src] turns on.") + else + message = SPAN_NOTICE("\The [src] shuts down.") + visible_message(message) + return TRUE + +/obj/machinery/pump/attack_robot(mob/user) + return attack_hand(user) + +/obj/machinery/pump/attack_ai(mob/user) + if(!set_state(!on)) + to_chat(user, "You try to toggle \the [src] but it does not respond.") + +/obj/machinery/pump/attack_hand(mob/user) + if(open && istype(cell)) + user.put_in_hands(cell) + cell.add_fingerprint(user) + cell.update_icon() + cell = null + set_state(FALSE) + to_chat(user, "You remove the power cell.") + return + + if(!set_state(!on)) + to_chat(user, "You try to toggle \the [src] but it does not respond.") + +/obj/machinery/pump/attackby(obj/item/weapon/W, mob/user) + . = TRUE + if(W.is_screwdriver() && !open) + to_chat(user, SPAN_NOTICE("You [unlocked ? "screw" : "unscrew"] the battery panel.")) + unlocked = !unlocked + + else if(W.is_crowbar() && unlocked) + to_chat(user, open ? \ + "You crowbar the battery panel in place." : \ + "You remove the battery panel." \ + ) + open = !open + + else if(W.is_wrench()) + if(on) + to_chat(user, "\The [src] is active. Turn it off before trying to move it!") + return FALSE + default_unfasten_wrench(user, W, 2 SECONDS) + + else if(istype(W, /obj/item/weapon/cell) && open) + if(istype(cell)) + to_chat(user, "There is a power cell already installed.") + return FALSE + user.drop_from_inventory(W, src) + to_chat(user, "You insert the power cell.") + + else + . = ..() + + RefreshParts() + update_icon() + + +/turf/proc/pump_reagents() + return + +/turf/simulated/floor/lava/pump_reagents(var/datum/reagents/R, var/volume) + . = ..() + R.add_reagent("mineralizedfluid", round(volume / 2, 0.1)) + + +/turf/simulated/floor/water/pump_reagents(var/datum/reagents/R, var/volume) + . = ..() + R.add_reagent("water", round(volume, 0.1)) + + if(temperature <= T0C) + R.add_reagent("ice", round(volume / 2, 0.1)) + + for(var/turf/simulated/mineral/M in orange(5)) + if(istype(M.mineral, /obj/effect/mineral)) + var/obj/effect/mineral/ore = M.mineral + reagents.add_reagent(ore.ore_reagent, round(volume / 2, 0.1)) + +/turf/simulated/floor/water/pool/pump_reagents(var/datum/reagents/R, var/volume) + . = ..() + R.add_reagent("chlorine", round(volume / 10, 0.1)) + +/turf/simulated/floor/water/deep/pool/pump_reagents(var/datum/reagents/R, var/volume) + . = ..() + R.add_reagent("chlorine", round(volume / 10, 0.1)) + +/turf/simulated/floor/water/contaminated/pump_reagents(var/datum/reagents/R, var/volume) + . = ..() + R.add_reagent("vatstabilizer", round(volume / 2, 0.1)) \ No newline at end of file diff --git a/icons/obj/machines/reagent.dmi b/icons/obj/machines/reagent.dmi index 7495451380..7a284942bc 100644 Binary files a/icons/obj/machines/reagent.dmi and b/icons/obj/machines/reagent.dmi differ diff --git a/vorestation.dme b/vorestation.dme index 7a13ad97f6..7ae79d8606 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -1005,7 +1005,6 @@ #include "code\game\machinery\pipe\pipe_dispenser.dm" #include "code\game\machinery\pipe\pipe_recipes.dm" #include "code\game\machinery\pipe\pipelayer.dm" -#include "code\game\machinery\reagents\pump.dm" #include "code\game\machinery\telecomms\broadcaster.dm" #include "code\game\machinery\telecomms\broadcaster_ch.dm" #include "code\game\machinery\telecomms\logbrowser.dm" @@ -3907,6 +3906,7 @@ #include "code\modules\reagents\machinery\chemalyzer.dm" #include "code\modules\reagents\machinery\distillery.dm" #include "code\modules\reagents\machinery\grinder.dm" +#include "code\modules\reagents\machinery\pump.dm" #include "code\modules\reagents\machinery\dispenser\_defines.dm" #include "code\modules\reagents\machinery\dispenser\cartridge.dm" #include "code\modules\reagents\machinery\dispenser\cartridge_presets.dm"