Files
CHOMPStation2/code/modules/projectiles/guns/launcher/syringe_gun.dm
mwerezak f8977c65af Much nicer syringe gun implementation
Makes syringe guns a type of launcher gun, and removes the hack
projectile.
Also moves syringe and dart gun source files into the modules/projectile
folder.
2015-02-13 23:48:35 -05:00

136 lines
4.6 KiB
Plaintext

/obj/item/weapon/syringe_cartridge
name = "compressed gas cartridge"
desc = "An impact-triggered compressed gas cartridge that can fitted to a syringe for rapid injection."
icon = 'icons/obj/ammo.dmi'
icon_state = "syringe-cartridge"
var/icon_flight = "syringe-cartridge-flight" //so it doesn't look so weird when shot
flags = CONDUCT
slot_flags = SLOT_BELT
throwforce = 3
force = 3
w_class = 1
var/obj/item/weapon/reagent_containers/syringe/syringe
var/primed = 0
/obj/item/weapon/syringe_cartridge/update_icon()
underlays.Cut()
if(syringe)
underlays += image(syringe.icon, src, syringe.icon_state)
underlays += syringe.filling
/obj/item/weapon/syringe_cartridge/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/weapon/reagent_containers/syringe))
syringe = I
user << "<span class='notice'>You carefully insert [syringe] into [src].</span>"
user.remove_from_mob(syringe)
syringe.loc = src
sharp = 1
update_icon()
/obj/item/weapon/syringe_cartridge/attack_self(mob/user)
if(syringe)
user << "<span class='notice'>You remove [syringe] from [src].</span>"
user.put_in_hands(syringe)
syringe = null
sharp = initial(sharp)
update_icon()
/obj/item/weapon/syringe_cartridge/proc/prime()
//the icon state will revert back when update_icon() is called from throw_impact()
icon_state = icon_flight
underlays.Cut()
primed = 1
/obj/item/weapon/syringe_cartridge/throw_impact(atom/hit_atom, var/speed)
..() //handles embedding for us. Should have a decent chance if thrown fast enough
if(syringe)
//check speed to see if we hit hard enough to trigger the rapid injection
//incidentally, this means syringe_cartridges can be used with the pneumatic launcher
if(speed >= 10 && primed && isliving(hit_atom))
var/mob/living/L = hit_atom
//unfortuately we don't know where the dart will actually hit, since that's done by the parent.
if(L.can_inject())
if(syringe.reagents)
syringe.reagents.trans_to(L, 15)
syringe.break_syringe(iscarbon(hit_atom)? hit_atom : null)
syringe.update_icon()
icon_state = initial(icon_state) //reset icon state
update_icon()
/obj/item/weapon/gun/launcher/syringe
name = "syringe gun"
desc = "A spring loaded rifle designed to fit syringes, designed to incapacitate unruly patients from a distance."
icon = 'icons/obj/gun.dmi'
icon_state = "syringegun"
item_state = "syringegun"
w_class = 3
force = 7
matter = list("metal" = 2000)
slot_flags = SLOT_BELT
fire_sound = 'sound/weapons/empty.ogg'
fire_sound_text = "a metallic thunk"
recoil = 0
release_force = 10
throw_distance = 10
var/list/darts = list()
var/max_darts = 1
var/obj/item/weapon/syringe_cartridge/next
/obj/item/weapon/gun/launcher/syringe/consume_next_projectile()
if(next)
next.prime()
return next
return null
/obj/item/weapon/gun/launcher/syringe/handle_post_fire()
..()
darts -= next
next = null
/obj/item/weapon/gun/launcher/syringe/attack_self(mob/living/user as mob)
if(next)
user.visible_message("[user] unlatches and carefully relax the bolt on [src].", "<span class='notice'>You unlatch and carefully relax the bolt on [src], unloading the spring.</span>")
next = null
else if(darts.len)
playsound(src.loc, 'sound/weapons/flipblade.ogg', 50, 1)
user.visible_message("[user] draws back the bolt on [src], clicking it into place.", "<span class='warning'>You draw back the bolt on the [src], loading the spring!</span>")
next = darts[1]
/obj/item/weapon/gun/launcher/syringe/attack_hand(mob/living/user as mob)
if(src in user)
if(!darts.len)
user << "<span class='warning'>[src] is empty.</span>"
return
if(next)
user << "<span class='warning'>The cover on [src] is locked shut.</span>"
return
var/obj/item/weapon/syringe_cartridge/C = darts[1]
darts -= C
user.put_in_hands(C)
user.visible_message("[user] removes \a [C] from [src].", "<span class='notice'>You remove \a [C] from [src].</span>")
else
..()
/obj/item/weapon/gun/launcher/syringe/attackby(var/obj/item/A as obj, mob/user as mob)
if(istype(A, /obj/item/weapon/syringe_cartridge))
var/obj/item/weapon/syringe_cartridge/C = A
if(darts.len >= max_darts)
user << "<span class='warning'>[src] is full!</span>"
return
user.remove_from_mob(C)
C.loc = src
darts += C //add to the end
user.visible_message("[user] inserts \a [C] into [src].", "<span class='notice'>You insert \a [C] into [src].</span>")
else
..()
/obj/item/weapon/gun/launcher/syringe/rapid
name = "rapid syringe gun"
desc = "A modification of the syringe gun design, using a rotating cylinder to store up to four syringes. The spring still needs to be drawn between shots."
icon_state = "rapidsyringegun"
max_darts = 4