From 82dca5a4a0f687ab1e3536a15858d62426ea3bc3 Mon Sep 17 00:00:00 2001 From: cib Date: Mon, 15 Oct 2012 17:19:43 +0200 Subject: [PATCH] Added an IV drip machinery. --- code/game/machinery/iv_drip.dm | 82 +++++++++++++++++++++++++++++++++ icons/obj/iv_drip.dmi | Bin 0 -> 881 bytes 2 files changed, 82 insertions(+) create mode 100644 code/game/machinery/iv_drip.dm create mode 100644 icons/obj/iv_drip.dmi diff --git a/code/game/machinery/iv_drip.dm b/code/game/machinery/iv_drip.dm new file mode 100644 index 00000000000..c9a62e0f86b --- /dev/null +++ b/code/game/machinery/iv_drip.dm @@ -0,0 +1,82 @@ +/obj/machinery/iv_drip + name = "\improper IV drip" + icon = 'icons/obj/iv_drip.dmi' + +/obj/machinery/iv_drip/var/mob/living/carbon/human/attached = null +/obj/machinery/iv_drip/var/obj/item/weapon/reagent_containers/beaker = null + +/obj/machinery/iv_drip/update_icon() + if(src.attached) + icon_state = "hooked" + else + icon_state = "" + + overlays = null + + if(beaker) + var/datum/reagents/reagents = beaker.reagents + if(reagents.total_volume) + var/image/filling = image('icons/obj/iv_drip.dmi', src, "reagent") + + var/percent = round((reagents.total_volume / beaker.volume) * 100) + switch(percent) + if(0 to 9) filling.icon_state = "reagent0" + if(10 to 24) filling.icon_state = "reagent10" + if(25 to 49) filling.icon_state = "reagent25" + if(50 to 74) filling.icon_state = "reagent50" + if(75 to 79) filling.icon_state = "reagent75" + if(80 to 90) filling.icon_state = "reagent80" + if(91 to INFINITY) filling.icon_state = "reagent100" + + filling.icon += mix_color_from_reagents(reagents.reagent_list) + overlays += filling + +/obj/machinery/iv_drip/MouseDrop(over_object, src_location, over_location) + ..() + + if(attached) + usr << "[attached] is already attached to the drip." + + if(in_range(src, usr) && ishuman(over_object) && get_dist(over_object, src) <= 1) + visible_message("[usr] attaches \the [src] to \the [over_object].") + src.attached = over_object + src.update_icon() + + +/obj/machinery/iv_drip/attackby(obj/item/weapon/W as obj, mob/user as mob) + if (istype(W, /obj/item/weapon/reagent_containers)) + if(!isnull(src.beaker)) + user << "There is already a reagent container loaded!" + return + + user.drop_item() + W.loc = src + src.beaker = W + user << "You attach \the [W] to \the [src]." + src.update_icon() + return + else + return ..() + + +/obj/machinery/iv_drip/process() + set background = 1 + + if(src.attached && src.beaker && src.beaker.volume > 0) + if(!(get_dist(src, src.attached) <= 1)) + visible_message("The needle is ripped out of [src.attached], doesn't that hurt?") + src.attached:apply_damage(3, BRUTE, pick("r_arm", "l_arm")) + src.attached = null + src.update_icon() + return + + src.beaker.reagents.trans_to(src.attached, REAGENTS_METABOLISM) + update_icon() + +/obj/machinery/iv_drip/attack_hand(mob/user as mob) + if(src.attached) + visible_message("[src.attached] is detached from \the [src]") + src.attached = null + src.update_icon() + else + return ..() diff --git a/icons/obj/iv_drip.dmi b/icons/obj/iv_drip.dmi new file mode 100644 index 0000000000000000000000000000000000000000..9adc8ec4cb5d82cef2b0c7645e0527c3dedb1084 GIT binary patch literal 881 zcmeAS@N?(olHy`uVBq!ia0vp^4M3d0!3HF+R#kZdsd-f)5hX6E#mPmP1tppJc?=8{ zb9&Eg5iG4 zUow7hYaZXy)O6Xg;9K81mVkmc7TglG8n;g#6=Pxb^~iL)UhqsQH9*0#dP41^ZS`;Z z%G{!KDyKNT`4sDrVY_bWvad_0XH~w-PL03&X4ULXyMBsqGw_iD8q5CYe2eO&oL%o2 z7?}DzT^vIy=DfYL(f6=}L|dZt#obBl{0%Ozzi7UQJY1WyG?mw^;5-x01kQ{VHjSDA zOE?5;p5OWTZvXpQtrn(l^Y>UL2`~RQ!(QvfF7Lg}9mY{lB=r;@2Jdd3itYiaoKa-~amg0i6!t406xAILB&KGFV>-EiMYuU-G`>G0dzuD&e!^}Q^A`S$jJ z+d8pd7`9#7misE!VC4*kX<@BvBP$gnd>Ga+ycQ95$kT2Rea5uoo5NU bx??`k`$uej9D^w^4>5SU`njxgN@xNAL