Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds a visible line when using iv drips / bloodpacks #3645

Merged
merged 16 commits into from
Jul 8, 2023
Merged
29 changes: 29 additions & 0 deletions code/game/machinery/iv_drip.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
var/mob/living/carbon/attached = null
var/mode = 1 // 1 is injecting, 0 is taking blood.
var/obj/item/reagent_container/beaker = null
var/datum/beam/current_beam = null
realkhad marked this conversation as resolved.
Show resolved Hide resolved

/obj/structure/machinery/iv_drip/update_icon()
if(src.attached)
realkhad marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -35,6 +36,26 @@
filling.color = mix_color_from_reagents(reagents.reagent_list)
overlays += filling

/obj/structure/machinery/iv_drip/proc/update_beam(ignore = FALSE)
var/beam_icon = "iv_tube"
if(mode)
if(beaker)
beam_icon = (beaker.reagents.total_volume == 0) ? "iv_tube" : "iv_tube_blood"
if(current_beam && current_beam.icon_state != beam_icon || ignore)
delete_beam()
current_beam = attached.beam(src, beam_icon)
else
if(beaker)
beam_icon = (attached.blood_volume == 0) ? "iv_tube" : "iv_tube_blood"
if(current_beam && current_beam.icon_state != beam_icon || ignore)
delete_beam()
current_beam = src.beam(attached, beam_icon)
realkhad marked this conversation as resolved.
Show resolved Hide resolved

/obj/structure/machinery/iv_drip/proc/delete_beam()
if(current_beam)
qdel(current_beam)
current_beam = null
realkhad marked this conversation as resolved.
Show resolved Hide resolved

/obj/structure/machinery/iv_drip/MouseDrop(over_object, src_location, over_location)
..()

Expand All @@ -48,6 +69,7 @@
"You detach \the [src] from \the [attached].")
attached.active_transfusions -= src
attached = null
delete_beam()
update_icon()
stop_processing()
return
Expand All @@ -57,6 +79,7 @@
"You attach \the [src] to \the [over_object].")
realkhad marked this conversation as resolved.
Show resolved Hide resolved
attached = over_object
attached.active_transfusions += src
update_beam(ignore = TRUE)
update_icon()
start_processing()

Expand All @@ -81,6 +104,7 @@
log_admin("[key_name(user)] put a [beaker] into [src], containing [reagentnames] at ([src.loc.x],[src.loc.y],[src.loc.z]).")

to_chat(user, "You attach \the [W] to \the [src].")
update_beam()
update_icon()
return
else
Expand All @@ -97,6 +121,7 @@
attached.emote("scream")
attached.active_transfusions -= src
attached = null
delete_beam()
update_icon()
stop_processing()
return
Expand All @@ -110,6 +135,7 @@
// speed up transfer on blood packs
transfer_amount = 4
attached.inject_blood(beaker, transfer_amount)
update_beam()
update_icon()

// Take blood
Expand All @@ -135,12 +161,14 @@
visible_message("\The [src] beeps loudly.")

T.take_blood(beaker,amount)
update_beam()
update_icon()

/obj/structure/machinery/iv_drip/attack_hand(mob/user as mob)
if(src.beaker)
src.beaker.forceMove(get_turf(src))
src.beaker = null
update_beam()
update_icon()
else
return ..()
Expand All @@ -159,6 +187,7 @@

mode = !mode
to_chat(usr, "The IV drip is now [mode ? "injecting" : "taking blood"].")
update_beam(ignore = TRUE)

/obj/structure/machinery/iv_drip/get_examine_text(mob/user)
. = ..()
Expand Down
33 changes: 33 additions & 0 deletions code/game/objects/items/reagent_containers/blood_pack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

var/mode = BLOOD_BAG_INJECTING
var/mob/living/carbon/human/connected_to
var/mob/living/carbon/human/connected_from
var/blood_type = null
var/datum/beam/current_beam = null

/obj/item/reagent_container/blood/Initialize()
. = ..()
Expand All @@ -32,6 +34,24 @@
if(10 to 50) icon_state = "half"
if(51 to INFINITY) icon_state = "full"

/obj/item/reagent_container/blood/proc/update_beam(ignore = FALSE)
var/beam_icon = "iv_tube"
if(mode)
beam_icon = (reagents.total_volume == 0) ? "iv_tube" : "iv_tube_blood"
if(current_beam && current_beam.icon_state != beam_icon || ignore)
delete_beam()
current_beam = connected_to.beam(connected_from, beam_icon)
else
beam_icon = (connected_to.blood_volume == 0) ? "iv_tube" : "iv_tube_blood"
if(current_beam && current_beam.icon_state != beam_icon || ignore)
delete_beam()
current_beam = connected_from.beam(connected_to, beam_icon)

/obj/item/reagent_container/blood/proc/delete_beam()
if(current_beam)
qdel(current_beam)
current_beam = null
realkhad marked this conversation as resolved.
Show resolved Hide resolved

/obj/item/reagent_container/blood/attack(mob/attacked_mob, mob/user)
. = ..()

Expand All @@ -45,6 +65,8 @@
"You detach [src] from [connected_to].")
connected_to.active_transfusions -= src
connected_to = null
connected_from = null
delete_beam()
return

if(!skillcheck(user, SKILL_SURGERY, SKILL_SURGERY_NOVICE))
Expand All @@ -60,10 +82,12 @@

if(istype(attacked_mob, /mob/living/carbon/human))
connected_to = attacked_mob
connected_from = user
connected_to.active_transfusions += src
START_PROCESSING(SSobj, src)
user.visible_message("[user] attaches \the [src] to [connected_to].", \
"You attach \the [src] to [connected_to].")
update_beam(ignore = TRUE)

/obj/item/reagent_container/blood/process()
//if we're not connected to anything stop doing stuff
Expand Down Expand Up @@ -91,6 +115,7 @@
if(volume > 0)
var/transfer_amount = REAGENTS_METABOLISM * 30
connected_to.inject_blood(src, transfer_amount)
update_beam()
return

// Take blood
Expand All @@ -105,6 +130,11 @@
return

connected_to.take_blood(src, amount)
update_beam()

/obj/item/reagent_container/blood/dropped()
..()
bad_disconnect()

///Used to standardize effects of a blood bag disconnecting improperly
/obj/item/reagent_container/blood/proc/bad_disconnect()
Expand All @@ -117,6 +147,8 @@
connected_to.emote("scream")
connected_to.active_transfusions -= src
connected_to = null
connected_from = null
delete_beam()

/obj/item/reagent_container/blood/verb/toggle_mode()
set category = "Object"
Expand All @@ -131,6 +163,7 @@

mode = !mode
to_chat(usr, "The blood bag is now [mode ? "giving blood" : "taking blood"].")
update_beam(ignore = TRUE)


/obj/item/reagent_container/blood/APlus
Expand Down
Binary file modified icons/effects/beam.dmi
Binary file not shown.