Syringe Refactor. Overhauls Lethal Injection Syringe

This commit is contained in:
Fox McCloud
2019-09-30 18:25:36 -04:00
parent 7766b47093
commit a97d050f4b
25 changed files with 89 additions and 203 deletions
@@ -76,7 +76,7 @@
return
if(!istype(M))
return
if(R.total_volume && M.can_inject(user, 1, penetrate_thick = bypass_protection))
if(R.total_volume && M.can_inject(user, TRUE, user.zone_sel.selecting, penetrate_thick = bypass_protection))
to_chat(user, "<span class='notice'>You inject [M] with the injector.</span>")
to_chat(M, "<span class='notice'>You feel a tiny prick!</span>")
@@ -114,7 +114,7 @@
/obj/item/reagent_containers/dropper/precision/viral_injector
/obj/item/reagent_containers/dropper/precision/viral_injector/attack(mob/living/M, mob/living/user, def_zone)
if(M.can_inject(user, 1))
if(M.can_inject(user, TRUE))
to_chat(user, "<span class='warning'>You stab [M] with the [src].</span>")
if(reagents.total_volume && M.reagents)
var/list/injected = list()
@@ -135,8 +135,8 @@
virusData += " ([english_list(english_symptoms)])"
virList += virusData
var/str = english_list(virList)
add_attack_logs(user, M, "Infected with [str].")
add_attack_logs(user, M, "Infected with [str].")
reagents.reaction(M, INGEST, reagents.total_volume)
reagents.trans_to(M, 1)
@@ -24,7 +24,7 @@
if(!iscarbon(M))
return
if(reagents.total_volume && (ignore_flags || M.can_inject(user, 1))) // Ignore flag should be checked first or there will be an error message.
if(reagents.total_volume && (ignore_flags || M.can_inject(user, TRUE))) // Ignore flag should be checked first or there will be an error message.
to_chat(M, "<span class='warning'>You feel a tiny prick!</span>")
to_chat(user, "<span class='notice'>You inject [M] with [src].</span>")
@@ -101,7 +101,7 @@
"<span class='userdanger'>[user] removes [src]'s needle from [L]'s arm!</span>")
end_processing()
else // Inserting the needle
if(!L.can_inject(user, 1))
if(!L.can_inject(user, TRUE))
return
if(amount_per_transfer_from_this > 10) // We only want to be able to transfer 1, 5, or 10 units to people. Higher numbers are for transfering to other containers
to_chat(user, "<span class='warning'>The IV bag can only be used on someone with a transfer amount of 1, 5 or 10.</span>")
@@ -126,7 +126,7 @@
var/trans = reagents.trans_to(target, amount_per_transfer_from_this)
to_chat(user, "<span class='notice'>You transfer [trans] units of the solution to [target].</span>")
else if(istype(target, /obj/item/reagent_containers/glass) && !target.is_open_container())
to_chat(user, "<span class='warning'>You cannot fill [target] while it is sealed.</span>")
return
@@ -1,6 +1,3 @@
////////////////////////////////////////////////////////////////////////////////
/// Syringes.
////////////////////////////////////////////////////////////////////////////////
#define SYRINGE_DRAW 0
#define SYRINGE_INJECT 1
#define SYRINGE_BROKEN 2
@@ -12,14 +9,14 @@
item_state = "syringe_0"
icon_state = "0"
amount_per_transfer_from_this = 5
possible_transfer_amounts = null //list(5,10,15)
possible_transfer_amounts = list()
volume = 15
w_class = WEIGHT_CLASS_TINY
sharp = 1
container_type = TRANSPARENT
var/busy = 0
sharp = TRUE
var/busy = FALSE
var/mode = SYRINGE_DRAW
var/projectile_type = /obj/item/projectile/bullet/dart/syringe
materials = list(MAT_METAL=10, MAT_GLASS=20)
container_type = TRANSPARENT
/obj/item/reagent_containers/syringe/New()
..()
@@ -39,25 +36,14 @@
update_icon()
/obj/item/reagent_containers/syringe/attack_self(mob/user)
switch(mode)
if(SYRINGE_DRAW)
mode = SYRINGE_INJECT
if(SYRINGE_INJECT)
mode = SYRINGE_DRAW
if(SYRINGE_BROKEN)
return
mode = !mode
update_icon()
/obj/item/reagent_containers/syringe/attack_hand()
..()
update_icon()
/obj/item/reagent_containers/syringe/attack(mob/living/M, mob/living/user, def_zone)
return
/obj/item/reagent_containers/syringe/attackby(obj/item/I, mob/user, params)
if(istype(I,/obj/item/storage/bag))
..()
return
/obj/item/reagent_containers/syringe/afterattack(atom/target, mob/user , proximity)
@@ -69,13 +55,9 @@
var/mob/living/L
if(isliving(target))
L = target
if(!L.can_inject(user, 1))
if(!L.can_inject(user, TRUE))
return
if(mode == SYRINGE_BROKEN)
to_chat(user, "<span class='warning'>This syringe is broken!</span>")
return
switch(mode)
if(SYRINGE_DRAW)
@@ -88,15 +70,15 @@
if(target != user)
target.visible_message("<span class='danger'>[user] is trying to take a blood sample from [target]!</span>", \
"<span class='userdanger'>[user] is trying to take a blood sample from [target]!</span>")
busy = 1
busy = TRUE
if(!do_mob(user, target))
busy = 0
busy = FALSE
return
if(reagents.holder_full())
return
busy = 0
busy = FALSE
if(L.transfer_blood_to(src, drawn_amount))
user.visible_message("[user] takes a blood sample from [L].")
user.visible_message("<span class='notice'>[user] takes a blood sample from [L].</span>")
else
to_chat(user, "<span class='warning'>You are unable to draw any blood from [L]!</span>")
@@ -105,15 +87,15 @@
to_chat(user, "<span class='warning'>[target] is empty!</span>")
return
if(!target.is_drawable())
if(!target.is_drawable(user))
to_chat(user, "<span class='warning'>You cannot directly remove reagents from [target]!</span>")
return
var/trans = target.reagents.trans_to(src, amount_per_transfer_from_this) // transfer from, transfer to - who cares?
to_chat(user, "<span class='notice'>You fill [src] with [trans] units of the solution.</span>")
to_chat(user, "<span class='notice'>You fill [src] with [trans] units of the solution. It now contains [reagents.total_volume] units.</span>")
if(reagents.holder_full())
mode=!mode
mode = !mode
update_icon()
if(SYRINGE_INJECT)
@@ -121,17 +103,20 @@
to_chat(user, "<span class='notice'>[src] is empty.</span>")
return
if(!L && !target.is_injectable())
if(!L && !target.is_injectable(user)) //only checks on non-living mobs, due to how can_inject() handles
to_chat(user, "<span class='warning'>You cannot directly fill [target]!</span>")
return
if(target.reagents.total_volume >= target.reagents.maximum_volume)
to_chat(user, "<span class='notice'>[target] is full.</span>")
return
if(L) //living mob
if(!L.can_inject(user, TRUE))
return
if(L != user)
L.visible_message("<span class='danger'>[user] is trying to inject [L]!</span>", \
"<span class='userdanger'>[user] is trying to inject [L]!</span>")
"<span class='userdanger'>[user] is trying to inject you!</span>")
if(!do_mob(user, L))
return
if(!reagents.total_volume)
@@ -148,155 +133,43 @@
add_attack_logs(user, L, "Injected with [name] containing [contained], transfered [amount_per_transfer_from_this] units", reagents.harmless_helper() ? ATKLOG_ALMOSTALL : null)
var/fraction = min(amount_per_transfer_from_this/reagents.total_volume, 1)
var/fraction = min(amount_per_transfer_from_this / reagents.total_volume, 1)
reagents.reaction(L, INGEST, fraction)
reagents.trans_to(target, amount_per_transfer_from_this)
to_chat(user, "<span class='notice'>You inject [amount_per_transfer_from_this] units of the solution. The syringe now contains [reagents.total_volume] units.</span>")
if (reagents.total_volume <= 0 && mode==SYRINGE_INJECT)
if(reagents.total_volume <= 0 && mode == SYRINGE_INJECT)
mode = SYRINGE_DRAW
update_icon()
/obj/item/reagent_containers/syringe/update_icon()
if(mode == SYRINGE_BROKEN)
icon_state = "broken"
overlays.Cut()
return
var/rounded_vol = round(reagents.total_volume,5)
overlays.Cut()
cut_overlays()
var/rounded_vol
if(reagents && reagents.total_volume)
rounded_vol = Clamp(round((reagents.total_volume / volume * 15), 5), 1, 15)
var/image/filling_overlay = mutable_appearance('icons/obj/reagentfillings.dmi', "syringe[rounded_vol]")
filling_overlay.color = mix_color_from_reagents(reagents.reagent_list)
add_overlay(filling_overlay)
else
rounded_vol = 0
icon_state = "[rounded_vol]"
item_state = "syringe_[rounded_vol]"
if(ismob(loc))
var/mob/M = loc
var/injoverlay
switch(mode)
if(SYRINGE_DRAW)
injoverlay = "draw"
if(SYRINGE_INJECT)
injoverlay = "inject"
overlays += injoverlay
icon_state = "[rounded_vol]"
item_state = "syringe_[rounded_vol]"
if(reagents.total_volume)
var/image/filling = image('icons/obj/reagentfillings.dmi', src, "syringe10")
filling.icon_state = "syringe[rounded_vol]"
filling.icon += mix_color_from_reagents(reagents.reagent_list)
overlays += filling
/obj/item/reagent_containers/ld50_syringe
name = "Lethal Injection Syringe"
desc = "A syringe used for lethal injections."
icon = 'icons/goonstation/objects/syringe.dmi'
item_state = "syringe_0"
icon_state = "0"
amount_per_transfer_from_this = 50
possible_transfer_amounts = null //list(5,10,15)
volume = 50
var/mode = SYRINGE_DRAW
/obj/item/reagent_containers/ld50_syringe/on_reagent_change()
update_icon()
/obj/item/reagent_containers/ld50_syringe/pickup(mob/user)
. = ..()
update_icon()
/obj/item/reagent_containers/ld50_syringe/dropped(mob/user)
..()
update_icon()
/obj/item/reagent_containers/ld50_syringe/attack_self(mob/user)
mode = !mode
update_icon()
/obj/item/reagent_containers/ld50_syringe/attack_hand()
..()
update_icon()
/obj/item/reagent_containers/ld50_syringe/attackby(obj/item/I, mob/user)
return
/obj/item/reagent_containers/ld50_syringe/afterattack(obj/target, mob/user , flag)
if(!target.reagents)
return
switch(mode)
if(SYRINGE_DRAW)
if(reagents.total_volume >= reagents.maximum_volume)
to_chat(user, "<span class='warning'>The syringe is full.</span>")
return
if(ismob(target))
if(istype(target, /mob/living/carbon))//I Do not want it to suck 50 units out of people
to_chat(usr, "This needle isn't designed for drawing blood.")
return
else //if not mob
if(!target.reagents.total_volume)
to_chat(user, "<span class='warning'>[target] is empty.</span>")
return
if(!target.is_open_container() && !istype(target,/obj/structure/reagent_dispensers))
to_chat(user, "<span class='warning'>You cannot directly remove reagents from this object.</span>")
return
var/trans = target.reagents.trans_to(src, amount_per_transfer_from_this) // transfer from, transfer to - who cares?
to_chat(user, "<span class='notice'>You fill the syringe with [trans] units of the solution.</span>")
if(reagents.total_volume >= reagents.maximum_volume)
mode=!mode
update_icon()
if(SYRINGE_INJECT)
if(!reagents.total_volume)
to_chat(user, "<span class='warning'>The Syringe is empty.</span>")
return
if(istype(target, /obj/item/implantcase/chem))
return
if(!target.is_open_container() && !ismob(target) && !istype(target, /obj/item/reagent_containers/food))
to_chat(user, "<span class='warning'>You cannot directly fill this object.</span>")
return
if(target.reagents.total_volume >= target.reagents.maximum_volume)
to_chat(user, "<span class='warning'>[target] is full.</span>")
return
if(ismob(target) && target != user)
for(var/mob/O in viewers(world.view, user))
O.show_message(text("<span class='danger'>[] is trying to inject [] with a giant syringe!</span>", user, target), 1)
if(!do_mob(user, target, 300)) return
for(var/mob/O in viewers(world.view, user))
O.show_message(text("<span class='warning'>[] injects [] with a giant syringe!</span>", user, target), 1)
reagents.reaction(target, INGEST)
if(ismob(target) && target == user)
reagents.reaction(target, INGEST)
spawn(5)
var/trans = reagents.trans_to(target, amount_per_transfer_from_this)
to_chat(user, "<span class='notice'>You inject [trans] units of the solution. The syringe now contains [reagents.total_volume] units.</span>")
if(reagents.total_volume >= reagents.maximum_volume && mode==SYRINGE_INJECT)
mode = SYRINGE_DRAW
update_icon()
/obj/item/reagent_containers/ld50_syringe/update_icon()
var/rounded_vol = round(reagents.total_volume,50)
if(ismob(loc))
var/mode_t
switch(mode)
if(SYRINGE_DRAW)
mode_t = "d"
if(SYRINGE_INJECT)
mode_t = "i"
icon_state = "[mode_t][rounded_vol]"
else
icon_state = "[rounded_vol]"
item_state = "syringe_[rounded_vol]"
add_overlay(injoverlay)
M.update_inv_l_hand()
M.update_inv_r_hand()
/obj/item/reagent_containers/syringe/antiviral
name = "Syringe (spaceacillin)"
desc = "Contains antiviral agents."
list_reagents = list("spaceacillin" = 15)
/obj/item/reagent_containers/ld50_syringe/lethal
list_reagents = list("cyanide" = 10, "neurotoxin2" = 40)
/obj/item/reagent_containers/syringe/charcoal
name = "Syringe (charcoal)"
desc = "Contains charcoal - used to treat toxins and damage from toxins."
@@ -342,4 +215,11 @@
/obj/item/reagent_containers/syringe/pancuronium
name = "pancuronium syringe"
desc = "A powerful paralyzing poison."
list_reagents = list("pancuronium" = 15)
list_reagents = list("pancuronium" = 15)
/obj/item/reagent_containers/syringe/lethal
name = "lethal injection syringe"
desc = "A syringe used for lethal injections. It can hold up to 50 units."
amount_per_transfer_from_this = 50
volume = 50
list_reagents = list("toxin" = 15, "pancuronium" = 10, "cyanide" = 5, "facid" = 10, "fluorine" = 10)