Skip to content

Commit

Permalink
Fix remove iv needing power to operate. (#4070)
Browse files Browse the repository at this point in the history
# About the pull request
fixes: #3848
and add a skill check like for the blood pack.
also turned four variable with a single letter into better ones.

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
add: Add a skill check to operate IV.
fix: Fix remove iv needing power to operate.
/:cl:

---------

Co-authored-by: Julien <[email protected]>
Co-authored-by: forest2001 <[email protected]>
Co-authored-by: Drathek <[email protected]>
  • Loading branch information
4 people authored Aug 9, 2023
1 parent 147ac8c commit d93e8da
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions code/game/machinery/iv_drip.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
var/mode = 1 // 1 is injecting, 0 is taking blood.
var/obj/item/reagent_container/beaker = null
var/datum/beam/current_beam
//make it so that IV doesn't require power to function.
use_power = USE_POWER_NONE

/obj/structure/machinery/iv_drip/update_icon()
if(attached)
Expand Down Expand Up @@ -44,33 +46,25 @@
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
if(H.stat || get_dist(H, src) > 1 || H.blinded || H.lying)
var/mob/living/carbon/human/user = usr
if(user.stat || get_dist(user, src) > 1 || user.blinded || user.lying)
return

if(!skillcheck(user, SKILL_SURGERY, SKILL_SURGERY_NOVICE))
to_chat(user, SPAN_WARNING("You don't know how to [attached ? "disconnect" : "connect"] this!"))
return

if(attached)
H.visible_message("[H] detaches \the [src] from \the [attached].", \
user.visible_message("[user] detaches \the [src] from \the [attached].", \
"You detach \the [src] from \the [attached].")
attached.active_transfusions -= src
attached = null
Expand All @@ -80,35 +74,35 @@
return

if(in_range(src, usr) && iscarbon(over_object) && get_dist(over_object, src) <= 1)
H.visible_message("[H] attaches \the [src] to \the [over_object].", \
user.visible_message("[user] attaches \the [src] to \the [over_object].", \
"You attach \the [src] to \the [over_object].")
attached = over_object
attached.active_transfusions += src
update_beam()
update_icon()
start_processing()


/obj/structure/machinery/iv_drip/attackby(obj/item/W, mob/living/user)
if (istype(W, /obj/item/reagent_container))
/obj/structure/machinery/iv_drip/attackby(obj/item/container, mob/living/user)
if (istype(container, /obj/item/reagent_container))
if(beaker)
to_chat(user, SPAN_WARNING("There is already a reagent container loaded!"))
return

if((!istype(W, /obj/item/reagent_container/blood) && !istype(W, /obj/item/reagent_container/glass)) || istype(W, /obj/item/reagent_container/glass/bucket))
if((!istype(container, /obj/item/reagent_container/blood) && !istype(container, /obj/item/reagent_container/glass)) || istype(container, /obj/item/reagent_container/glass/bucket))
to_chat(user, SPAN_WARNING("That won't fit!"))
return

if(user.drop_inv_item_to_loc(W, src))
beaker = W
if(user.drop_inv_item_to_loc(container, src))
beaker = container

var/reagentnames = ""
for(var/datum/reagent/R in beaker.reagents.reagent_list)
reagentnames += ";[R.name]"

for(var/datum/reagent/chem in beaker.reagents.reagent_list)
reagentnames += ";[chem.name]"

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].")
to_chat(user, "You attach \the [container] to \the [src].")
update_beam()
update_icon()
return
Expand Down Expand Up @@ -151,20 +145,20 @@
if(prob(5)) visible_message("\The [src] pings.")
return

var/mob/living/carbon/T = attached
var/mob/living/carbon/patient = attached

if(!istype(T))
if(!istype(patient))
return
if(ishuman(T))
var/mob/living/carbon/human/H = T
if(H.species && H.species.flags & NO_BLOOD)
if(ishuman(patient))
var/mob/living/carbon/human/human_patient = patient
if(human_patient.species && human_patient.species.flags & NO_BLOOD)
return

// If the human is losing too much blood, beep.
if(T.blood_volume < BLOOD_VOLUME_SAFE) if(prob(5))
if(patient.blood_volume < BLOOD_VOLUME_SAFE) if(prob(5))
visible_message("\The [src] beeps loudly.")

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

/obj/structure/machinery/iv_drip/attack_hand(mob/user as mob)
Expand Down

0 comments on commit d93e8da

Please sign in to comment.