Code Improvements

This commit is contained in:
shazbot194
2018-07-12 16:40:21 -08:00
parent 6b8da9ca13
commit b82393790e
@@ -80,38 +80,79 @@
desc = "A sturdy shotgun with a longer magazine and a fixed tactical stock designed for non-lethal riot control."
icon_state = "riotshotgun"
mag_type = /obj/item/ammo_box/magazine/internal/shot/riot
var/style = 1
sawn_desc = "Come with me if you want to live."
sawn_state = SAWN_INTACT
/obj/item/gun/projectile/shotgun/riot/attackby(obj/item/A, mob/user, params)
..()
if(istype(A, /obj/item/circular_saw) || istype(A, /obj/item/gun/energy/plasmacutter))
sawoff(A, user, 0)
sawoff(user)
if(istype(A, /obj/item/melee/energy))
var/obj/item/melee/energy/W = A
if(W.active)
sawoff(A, user, 0)
sawoff(user)
if(istype(A, /obj/item/pipe))
sawoff(A, user, 1)
unsaw(A, user)
/obj/item/gun/projectile/shotgun/riot/sawoff(obj/item/A, mob/user, style = 0)
//Check to see if they match
if(sawn_state == SAWN_OFF & style == 0)
to_chat(user, "<span class='warning'>\The [src] is already shortened!</span>")
/obj/item/gun/projectile/sawoff(mob/user)
if(sawn_state == SAWN_OFF)
to_chat(user, "<span class='warning'>[src] has already been shortened!</span>")
return
if(sawn_state != SAWN_OFF & style == 1)
to_chat(user, "<span class='notice'>[src] already has a full barrel and magazine!</span>")
return
//Make sure it isn't in a bag
if(istype(loc, /obj/item/storage))
if(istype(loc, /obj/item/storage)) //To prevent inventory exploits
to_chat(user, "<span class='info'>How do you plan to modify [src] while it's in a bag.</span>")
return
//if there's any live ammo inside the gun, makes it go off
if(chambered)
afterattack(user, user)
user.visible_message("<span class='danger'>\The [src] goes off!</span>", "<span class='danger'>\The [src] goes off in your face!</span>")
if(chambered) //if the gun is chambering live ammo, shoot self, if chambering empty ammo, 'click'
if(chambered.BB)
afterattack(user, user)
user.visible_message("<span class='danger'>\The [src] goes off!</span>", "<span class='danger'>\The [src] goes off in your face!</span>")
return
else
afterattack(user, user)
user.visible_message("The [src] goes click!", "<span class='notice'>The [src] you are holding goes click.</span>")
if(magazine.ammo_count()) //Spill the mag onto the floor
user.visible_message("<span class='danger'>[user.name] opens [src] up and the shells go goes flying around!</span>", "<span class='userdanger'>You open [src] up and the shells go goes flying everywhere!!</span>")
while(get_ammo(0) > 0)
var/obj/item/ammo_casing/CB
CB = magazine.get_round(0)
if(CB)
CB.loc = get_turf(loc)
CB.update_icon()
if(do_after(user, 30, target = src))
user.visible_message("[user] shortens \the [src]!", "<span class='notice'>You shorten \the [src].</span>")
post_sawoff()
return 1
/obj/item/gun/projectile/proc/post_sawoff()
name = "assault shotgun"
desc = sawn_desc
w_class = WEIGHT_CLASS_NORMAL
current_skin = "riotshotgun-short"
item_state = "gun" //phil235 is it different with different skin?
slot_flags &= ~SLOT_BACK //you can't sling it on your back
slot_flags |= SLOT_BELT //but you can wear it on your belt (poorly concealed under a trenchcoat, ideally)
sawn_state = SAWN_OFF
magazine.max_ammo = 3
update_icon()
/obj/item/gun/projectile/proc/unsaw(obj/item/A, mob/user)
if(sawn_state == SAWN_INTACT)
to_chat(user, "<span class='warning'>[src] has not been shortened!</span>")
return
//Spill the mag onto the floor
if(magazine.ammo_count())
if(istype(loc, /obj/item/storage)) //To prevent inventory exploits
to_chat(user, "<span class='info'>How do you plan to modify [src] while it's in a bag.</span>")
return
if(chambered) //if the gun is chambering live ammo, shoot self, if chambering empty ammo, 'click'
if(chambered.BB)
afterattack(user, user)
user.visible_message("<span class='danger'>\The [src] goes off!</span>", "<span class='danger'>\The [src] goes off in your face!</span>")
return
else
afterattack(user, user)
user.visible_message("The [src] goes click!", "<span class='notice'>The [src] you are holding goes click.</span>")
if(magazine.ammo_count()) //Spill the mag onto the floor
user.visible_message("<span class='danger'>[user.name] opens [src] up and the shells go goes flying around!</span>", "<span class='userdanger'>You open [src] up and the shells go goes flying everywhere!!</span>")
while(get_ammo() > 0)
var/obj/item/ammo_casing/CB
@@ -119,30 +160,24 @@
if(CB)
CB.loc = get_turf(loc)
CB.update_icon()
if(style == 0)
if(do_after(user, 10, target = src))
to_chat(user, "<span class='notice'>You saw the barrel and magazine of the [src].</span>")
w_class = WEIGHT_CLASS_NORMAL
slot_flags = null
magazine.max_ammo = 3
name = "assault shotgun"
current_skin = "riotshotgun-short"
desc = "A shortened riot shotgun that has been shortened enough to fit inside a bag."
sawn_state = SAWN_OFF
update_icon()
else
if(do_after(user, 10, target = src))
to_chat(user, "<span class='notice'>You install the longer barrel and magazine onto [src].</span>")
w_class = WEIGHT_CLASS_BULKY
slot_flags = SLOT_BACK
magazine.max_ammo = 6
name = "riot shotgun"
current_skin = "riotshotgun"
desc = "A sturdy shotgun with a longer magazine and a fixed tactical stock designed for non-lethal riot control."
sawn_state = null
update_icon()
qdel(A)
return
if(do_after(user, 30, target = src))
qdel(A)
user.visible_message("<span class='notice'>[user] lengthens [src]!</span>", "<span class='notice'>You lengthen [src].</span>")
post_unsaw(user)
return 1
/obj/item/gun/projectile/proc/post_unsaw()
name = initial(name)
desc = initial(desc)
w_class = initial(w_class)
current_skin = "riotshotgun"
item_state = initial(item_state)
slot_flags &= ~SLOT_BELT
slot_flags |= SLOT_BACK
sawn_state = SAWN_INTACT
magazine.max_ammo = 6
update_icon()
/obj/item/gun/projectile/shotgun/riot/update_icon() //Can't use the old proc as it makes it go to riotshotgun-short_sawn
..()
@@ -152,13 +187,13 @@
icon_state = "[initial(icon_state)]"
/obj/item/gun/projectile/shotgun/riot/short
name = "assault shotgun"
desc = "A shortened riot shotgun that has been shortened enough to fit inside a bag."
icon_state = "riotshotgun-short"
mag_type = /obj/item/ammo_box/magazine/internal/shot/riot/short
w_class = WEIGHT_CLASS_NORMAL
slot_flags = null
sawn_state = SAWN_OFF
/obj/item/gun/projectile/shotgun/riot/short/New()
..()
post_sawoff()
///////////////////////
// BOLT ACTION RIFLE //