From 5ff72c530284c6e8bb714d0de90b5f724ef099a6 Mon Sep 17 00:00:00 2001 From: Sonoida Date: Sun, 11 Dec 2022 17:32:55 +0100 Subject: [PATCH] initializing feeding tube just a quick save so it doesn't get lost, this commit initializes the feeding tube item (massively WIP, basically renamed IV drip) --- code/game/machinery/feeding_tube.dm | 227 ++++++++++++++++++++ code/modules/cargo/exports/large_objects.dm | 5 + icons/obj/feeding_tube.dmi | Bin 0 -> 1524 bytes 3 files changed, 232 insertions(+) create mode 100644 code/game/machinery/feeding_tube.dm create mode 100644 icons/obj/feeding_tube.dmi diff --git a/code/game/machinery/feeding_tube.dm b/code/game/machinery/feeding_tube.dm new file mode 100644 index 00000000..3cf9b8a7 --- /dev/null +++ b/code/game/machinery/feeding_tube.dm @@ -0,0 +1,227 @@ +//GS13! + +#define FEEDTUBE_TAKING 0 +#define FEEDTUBE_INJECTING 1 + +/obj/machinery/feeding_tube + name = "\improper Feeding Tube" + desc = "something something test." + icon = 'icons/obj/feeding_tube.dmi' + icon_state = "feeding_tube" + anchored = FALSE + mouse_drag_pointer = MOUSE_ACTIVE_POINTER + var/mob/living/carbon/attached + var/mode = FEEDTUBE_INJECTING + var/obj/item/reagent_containers/beaker + var/static/list/drip_containers = typecacheof(list(/obj/item/reagent_containers/food, + /obj/item/reagent_containers/glass, + /obj/item/reagent_containers/chem_pack)) +/obj/machinery/feeding_tube/Initialize(mapload) + . = ..() + update_icon() + +/obj/machinery/feeding_tube/Destroy() + attached = null + QDEL_NULL(beaker) + return ..() + +/obj/machinery/feeding_tube/update_icon() + if(attached) + if(mode) + icon_state = "injecting" + else + icon_state = "donating" + else + if(mode) + icon_state = "injectidle" + else + icon_state = "donateidle" + + cut_overlays() + + if(beaker) + if(attached) + add_overlay("beakeractive") + else + add_overlay("beakeridle") + if(beaker.reagents.total_volume) + var/mutable_appearance/filling_overlay = mutable_appearance('icons/obj/feeding_tube.dmi', "reagent") + + var/percent = round((beaker.reagents.total_volume / beaker.volume) * 100) + switch(percent) + if(0 to 9) + filling_overlay.icon_state = "reagent0" + if(10 to 24) + filling_overlay.icon_state = "reagent10" + if(25 to 49) + filling_overlay.icon_state = "reagent25" + if(50 to 74) + filling_overlay.icon_state = "reagent50" + if(75 to 79) + filling_overlay.icon_state = "reagent75" + if(80 to 90) + filling_overlay.icon_state = "reagent80" + if(91 to INFINITY) + filling_overlay.icon_state = "reagent100" + + filling_overlay.color = mix_color_from_reagents(beaker.reagents.reagent_list) + add_overlay(filling_overlay) + +/obj/machinery/feeding_tube/MouseDrop(mob/living/target) + . = ..() + if(!ishuman(usr) || !usr.canUseTopic(src, BE_CLOSE) || !isliving(target)) + return + + if(attached) + visible_message("[attached] is detached from [src].") + attached = null + update_icon() + return + + if(!target.has_dna()) + to_chat(usr, "The drip beeps: Warning, incompatible creature!") + return + + if(Adjacent(target) && usr.Adjacent(target)) + if(beaker) + usr.visible_message("[usr] attaches [src] to [target].", "You attach [src] to [target].") + log_combat(usr, target, "attached", src, "containing: [beaker.name] - ([beaker.reagents.log_list()])") + add_fingerprint(usr) + attached = target + START_PROCESSING(SSmachines, src) + update_icon() + else + to_chat(usr, "There's nothing attached to the IV drip!") + + +/obj/machinery/feeding_tube/attackby(obj/item/W, mob/user, params) + if(is_type_in_typecache(W, drip_containers)) + if(beaker) + to_chat(user, "There is already a reagent container loaded!") + return + if(!user.transferItemToLoc(W, src)) + return + beaker = W + to_chat(user, "You attach [W] to [src].") + user.log_message("attached a [W] to [src] at [AREACOORD(src)] containing ([beaker.reagents.log_list()])", LOG_ATTACK) + add_fingerprint(user) + update_icon() + return + else + return ..() + +/obj/machinery/feeding_tube/deconstruct(disassembled = TRUE) + if(!(flags_1 & NODECONSTRUCT_1)) + new /obj/item/stack/sheet/metal(loc) + qdel(src) + +/obj/machinery/feeding_tube/process() + if(!attached) + return PROCESS_KILL + + if(!(get_dist(src, attached) <= 1 && isturf(attached.loc))) + to_chat(attached, "The IV drip needle is ripped out of you!") + attached.apply_damage(3, BRUTE, pick(BODY_ZONE_R_ARM, BODY_ZONE_L_ARM)) + attached = null + update_icon() + return PROCESS_KILL + + if(beaker) + // Give blood + if(mode) + if(beaker.reagents.total_volume) + var/transfer_amount = 5 + if(istype(beaker, /obj/item/reagent_containers/blood)) + // speed up transfer on blood packs + transfer_amount = 10 + var/fraction = min(transfer_amount/beaker.reagents.total_volume, 1) //the fraction that is transfered of the total volume + beaker.reagents.reaction(attached, INJECT, fraction, FALSE) //make reagents reacts, but don't spam messages + beaker.reagents.trans_to(attached, transfer_amount) + update_icon() + + // Take blood + else + var/amount = beaker.reagents.maximum_volume - beaker.reagents.total_volume + amount = min(amount, 4) + // If the beaker is full, ping + if(!amount) + if(prob(5)) + visible_message("[src] pings.") + playsound(loc, 'sound/machines/beep.ogg', 50, 1) + return + + // If the human is losing too much blood, beep. + if(attached.blood_volume < ((BLOOD_VOLUME_SAFE*attached.blood_ratio) && prob(5) && ishuman(attached))) //really couldn't care less about monkeys + visible_message("[src] beeps loudly.") + playsound(loc, 'sound/machines/twobeep.ogg', 50, 1) + attached.transfer_blood_to(beaker, amount) + update_icon() + +/obj/machinery/feeding_tube/attack_hand(mob/user) + . = ..() + if(.) + return + if(!ishuman(user)) + return + if(attached) + visible_message("[attached] is detached from [src]") + attached = null + update_icon() + return + else if(beaker) + eject_beaker(user) + else + toggle_mode() + +/obj/machinery/feeding_tube/verb/eject_beaker() + set category = "Object" + set name = "Remove IV Container" + set src in view(1) + + if(!isliving(usr)) + to_chat(usr, "You can't do that!") + return + + if(usr.incapacitated()) + return + if(beaker) + if(usr && Adjacent(usr) && !issiliconoradminghost(usr)) + if(!usr.put_in_hands(beaker)) + beaker.forceMove(drop_location()) + beaker = null + update_icon() + +/obj/machinery/feeding_tube/verb/toggle_mode() + set category = "Object" + set name = "Toggle Mode" + set src in view(1) + + if(!isliving(usr)) + to_chat(usr, "You can't do that!") + return + + if(usr.incapacitated()) + return + mode = !mode + to_chat(usr, "The IV drip is now [mode ? "injecting" : "taking blood"].") + update_icon() + +/obj/machinery/feeding_tube/examine(mob/user) + . = ..() + if(get_dist(user, src) > 2) + return + + . += "[src] is [mode ? "injecting" : "taking blood"].\n" + + if(beaker) + if(beaker.reagents && beaker.reagents.reagent_list.len) + . += "\tAttached is \a [beaker] with [beaker.reagents.total_volume] units of liquid.\n" + else + . += "\tAttached is an empty [beaker.name].\n" + else + . += "\tNo chemicals are attached.\n" + + . += "\t[attached ? attached : "No one"] is attached." + +#undef FEEDTUBE_TAKING +#undef FEEDTUBE_INJECTING diff --git a/code/modules/cargo/exports/large_objects.dm b/code/modules/cargo/exports/large_objects.dm index fcee41b5..a7469dc6 100644 --- a/code/modules/cargo/exports/large_objects.dm +++ b/code/modules/cargo/exports/large_objects.dm @@ -134,6 +134,11 @@ unit_name = "iv drip" export_types = list(/obj/machinery/iv_drip) +/datum/export/large/iv //GS13 + cost = 50 + unit_name = "feeding tube" + export_types = list(/obj/machinery/feeding_tube) + /datum/export/large/barrier cost = 25 unit_name = "security barrier" diff --git a/icons/obj/feeding_tube.dmi b/icons/obj/feeding_tube.dmi new file mode 100644 index 0000000000000000000000000000000000000000..dc1af013315989c9cf88a87d53d0b0ad0324c421 GIT binary patch literal 1524 zcmbW1X)qfI6vrbXh@)w-&K6CJq8oa!MH@#{qXaFL6&h3zY#R+}vXUmQ)i!Eeb*x+K zXkAt6*czg=jv_QmbVd=k1nCMz5H_9tu=`;@b>{c}|1WRmy?Otc_sAXXqy*7|0000b z)CJ@vi5E&LN)9a1$JYY2CDtG5iHSg755GnT4vPrJ-vI!~x#_I8$}wh&VD9R=s*-P_ z)X>6pb!l@Qu9^#x=yLbSvp_0kpT@M^bW?rL#@=nk(LirbvUiD2_eMi_q5m1T;wEgr zk`X58(y1WVj%oJE6VWjX$l|J#l-7ersrJ~3*ceYnT9--Usy3EX3d7!P?R9~;9zSPm zXSMy1$C_LlTFkn$w^w5Qz{PIOmaLD6o=RDUGO%m$>?5Myvqkz{DhmdfYVRU~+UMV8 zNTqM{5CMvgc@9_8h4O)y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