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
32 changes: 31 additions & 1 deletion code/game/machinery/iv_drip.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
anchored = FALSE
density = FALSE
drag_delay = 1
base_pixel_x = 15
base_pixel_y = -2

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

/obj/structure/machinery/iv_drip/update_icon()
if(src.attached)
if(attached)
icon_state = "hooked"
else
icon_state = ""
Expand All @@ -35,8 +38,31 @@
filling.color = mix_color_from_reagents(reagents.reagent_list)
overlays += filling

/obj/structure/machinery/iv_drip/proc/update_beam()
if(current_beam)
QDEL_NULL(current_beam)
else if(!QDELETED(src) && attached)
current_beam = beam(attached, "iv_tube")

/obj/structure/machinery/iv_drip/power_change()
. = ..()
if(stat & NOPOWER && attached)
visible_message("\The [src] retracts its IV tube and shuts down.")
attached.active_transfusions -= src
attached = null
update_beam()
update_icon()

/obj/structure/machinery/iv_drip/Destroy()
attached?.active_transfusions -= src
update_beam()
. = ..()

/obj/structure/machinery/iv_drip/MouseDrop(over_object, src_location, over_location)
..()
if(inoperable())
visible_message("\The [src] is not powered.")
return

if(ishuman(usr))
var/mob/living/carbon/human/H = usr
Expand All @@ -48,6 +74,7 @@
"You detach \the [src] from \the [attached].")
attached.active_transfusions -= src
attached = null
update_beam()
update_icon()
stop_processing()
return
Expand All @@ -57,6 +84,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()
update_icon()
start_processing()

Expand All @@ -81,6 +109,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 +126,7 @@
attached.emote("scream")
attached.active_transfusions -= src
attached = null
update_beam()
update_icon()
stop_processing()
return
Expand Down
21 changes: 21 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

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

/obj/item/reagent_container/blood/proc/update_beam()
if(current_beam)
QDEL_NULL(current_beam)
else if(connected_from && connected_to)
current_beam = connected_from.beam(connected_to, "iv_tube")

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

Expand All @@ -44,7 +52,10 @@
user.visible_message("[user] detaches [src] from [connected_to].", \
"You detach [src] from [connected_to].")
connected_to.active_transfusions -= src
connected_to.base_pixel_x = 0
connected_to = null
connected_from = null
update_beam()
return

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

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

/obj/item/reagent_container/blood/process()
//if we're not connected to anything stop doing stuff
Expand Down Expand Up @@ -106,6 +120,10 @@

connected_to.take_blood(src, amount)

/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()
if(!connected_to)
Expand All @@ -116,7 +134,10 @@
if(connected_to.pain.feels_pain)
connected_to.emote("scream")
connected_to.active_transfusions -= src
connected_to.base_pixel_x = 0
connected_to = null
connected_from = null
update_beam()

/obj/item/reagent_container/blood/verb/toggle_mode()
set category = "Object"
Expand Down
Binary file modified icons/effects/beam.dmi
Binary file not shown.
Loading