mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-01-06 07:22:15 +00:00
Bolt-action refactor (#4667)
Makes bolt-action rifles a child of pump-action shotguns again to remove some shared code.
This commit is contained in:
@@ -1,88 +1,36 @@
|
||||
/obj/item/weapon/gun/projectile/boltaction
|
||||
name = "\improper bolt action rifle"
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle
|
||||
name = "bolt action rifle"
|
||||
desc = "A cheap ballistic rifle often found in the hands of crooks and frontiersmen. Uses 7.62mm rounds."
|
||||
icon_state = "moistnugget"
|
||||
item_state = "moistnugget"
|
||||
origin_tech = list(TECH_COMBAT = 2, TECH_MATERIAL = 2)
|
||||
fire_sound = 'sound/weapons/rifleshot.ogg'
|
||||
slot_flags = SLOT_BACK
|
||||
load_method = SINGLE_CASING|SPEEDLOADER
|
||||
handle_casings = HOLD_CASINGS
|
||||
caliber = "a762"
|
||||
ammo_type = /obj/item/ammo_casing/a762
|
||||
max_shells = 5
|
||||
w_class = 4.0
|
||||
force = 10
|
||||
var/recentpump = 0
|
||||
|
||||
pump_fail_msg = "<span class='warning'>You cannot work the rifle's bolt without gripping it with both hands!</span>"
|
||||
pump_snd = 'sound/weapons/riflebolt.ogg'
|
||||
has_wield_state = FALSE
|
||||
|
||||
can_sawoff = TRUE
|
||||
sawnoff_workmsg = "shorten the barrel and stock"
|
||||
|
||||
action_button_name = "Wield rifle"
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/can_wield()
|
||||
return 1
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/saw_off(mob/user, obj/item/tool)
|
||||
icon_state = "obrez"
|
||||
w_class = 3
|
||||
recoil = 2
|
||||
accuracy = -2
|
||||
item_state = "obrez"
|
||||
slot_flags &= ~SLOT_BACK
|
||||
slot_flags |= (SLOT_BELT|SLOT_HOLSTER)
|
||||
name = "obrez"
|
||||
desc = "A shortened bolt action rifle, not really acurate. Uses 7.62mm rounds."
|
||||
to_chat(user, "<span class='warning'>You shorten the barrel and stock of the rifle!</span>")
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/ui_action_click()
|
||||
if(src in usr)
|
||||
toggle_wield(usr)
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/verb/wield_shotgun()
|
||||
set name = "Wield rifle"
|
||||
set category = "Object"
|
||||
set src in usr
|
||||
|
||||
toggle_wield(usr)
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/consume_next_projectile()
|
||||
if(chambered)
|
||||
return chambered.BB
|
||||
return null
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/attack_self(mob/living/user as mob)
|
||||
if(world.time >= recentpump + 10)
|
||||
pump(user)
|
||||
recentpump = world.time
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/proc/pump(mob/M as mob)
|
||||
if(!wielded)
|
||||
M << "<span class='warning'>You cannot work the rifle's bolt without gripping it with both hands!</span>"
|
||||
return
|
||||
|
||||
playsound(M, 'sound/weapons/riflebolt.ogg', 60, 1)
|
||||
|
||||
if(chambered)//We have a shell in the chamber
|
||||
chambered.loc = get_turf(src)//Eject casing
|
||||
chambered = null
|
||||
|
||||
if(loaded.len)
|
||||
var/obj/item/ammo_casing/AC = loaded[1] //load next casing.
|
||||
loaded -= AC //Remove casing from loaded list.
|
||||
chambered = AC
|
||||
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/attackby(var/obj/item/A as obj, mob/user as mob)
|
||||
if(istype(A, /obj/item/weapon/circular_saw) || istype(A, /obj/item/weapon/melee/energy) || istype(A, /obj/item/weapon/gun/energy/plasmacutter) && w_class != 3)
|
||||
user << "<span class='notice'>You begin to shorten the barrel and stock of \the [src].</span>"
|
||||
if(loaded.len)
|
||||
afterattack(user, user)
|
||||
playsound(user, fire_sound, 50, 1)
|
||||
user.visible_message("<span class='danger'>[src] goes off!</span>", "<span class='danger'>The rifle goes off in your face!</span>")
|
||||
return
|
||||
if(do_after(user, 30))
|
||||
icon_state = "obrez"
|
||||
w_class = 3
|
||||
recoil = 2
|
||||
accuracy = -2
|
||||
item_state = "obrez"
|
||||
slot_flags &= ~SLOT_BACK
|
||||
slot_flags |= (SLOT_BELT|SLOT_HOLSTER)
|
||||
name = "\improper obrez"
|
||||
desc = "A shortened bolt action rifle, not really acurate. Uses 7.62mm rounds."
|
||||
user << "<span class='warning'>You shorten the barrel and stock of the rifle!</span>"
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/obrez
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/obrez
|
||||
name = "obrez"
|
||||
desc = "A shortened bolt action rifle, not really accurate. Uses 7.62mm rounds."
|
||||
icon_state = "obrez"
|
||||
@@ -142,7 +90,7 @@
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/vintage
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/vintage
|
||||
name = "\improper vintage bolt action rifle"
|
||||
desc = "An extremely old-looking rifle. Words you can't read are stamped on the gun. Doesn't look like it'll take any modern rounds."
|
||||
icon_state = "springfield"
|
||||
@@ -156,10 +104,7 @@
|
||||
var/open_bolt = 0
|
||||
var/obj/item/ammo_magazine/boltaction/vintage/has_clip
|
||||
|
||||
action_button_name = "Wield rifle"
|
||||
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/vintage/attack_self(mob/living/user as mob)
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/vintage/attack_self(mob/living/user as mob)
|
||||
if(wielded)
|
||||
if(world.time >= recentpump + 10)
|
||||
pump(user)
|
||||
@@ -171,11 +116,11 @@
|
||||
load_ammo(has_clip, user)
|
||||
src.cut_overlays()
|
||||
if(!has_clip.stored_ammo.len)
|
||||
src.add_overlay(image('icons/obj/gun.dmi', "springfield-clip-empty"))
|
||||
add_overlay("springfield-clip-empty")
|
||||
else if(has_clip.stored_ammo.len <= 3)
|
||||
src.add_overlay(image('icons/obj/gun.dmi', "springfield-clip-half"))
|
||||
add_overlay("springfield-clip-half")
|
||||
else
|
||||
src.add_overlay(image('icons/obj/gun.dmi', "springfield-clip-full"))
|
||||
add_overlay("springfield-clip-full")
|
||||
else
|
||||
user << "<span class='warning'>There is no ammo in \the [has_clip.name]!</span>"
|
||||
else if(!open_bolt)
|
||||
@@ -183,9 +128,9 @@
|
||||
else
|
||||
user << "<span class='warning'>There is no clip in \the [src.name]!</span>"
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/vintage/pump(mob/M as mob)
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/vintage/pump(mob/M as mob)
|
||||
if(!wielded)
|
||||
M << "<span class='warning'>You cannot work \the [src.name]'s bolt without gripping it with both hands!</span>"
|
||||
M << "<span class='warning'>You cannot work \the [src]'s bolt without gripping it with both hands!</span>"
|
||||
return
|
||||
if(!open_bolt)
|
||||
open_bolt = 1
|
||||
@@ -199,7 +144,7 @@
|
||||
if(has_clip)
|
||||
has_clip.forceMove(get_turf(src))
|
||||
has_clip = null
|
||||
src.cut_overlays()
|
||||
cut_overlays()
|
||||
|
||||
|
||||
if(chambered)//We have a shell in the chamber
|
||||
@@ -213,7 +158,7 @@
|
||||
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/vintage/attackby(var/obj/item/A as obj, mob/user as mob)
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/vintage/attackby(var/obj/item/A as obj, mob/user as mob)
|
||||
if(istype(A, /obj/item/ammo_magazine/boltaction/vintage))
|
||||
if(!open_bolt)
|
||||
user << "<span class='notice'>You need to open the bolt of \the [src] first.</span>"
|
||||
@@ -224,25 +169,25 @@
|
||||
has_clip = A
|
||||
user << "<span class='notice'>You load the clip into \the [src].</span>"
|
||||
if(!has_clip.stored_ammo.len)
|
||||
src.add_overlay(image('icons/obj/gun.dmi', "springfield-clip-empty"))
|
||||
add_overlay("springfield-clip-empty")
|
||||
else if(has_clip.stored_ammo.len <= 3)
|
||||
src.add_overlay(image('icons/obj/gun.dmi', "springfield-clip-half"))
|
||||
add_overlay("springfield-clip-half")
|
||||
else
|
||||
src.add_overlay(image('icons/obj/gun.dmi', "springfield-clip-full"))
|
||||
add_overlay("springfield-clip-full")
|
||||
else
|
||||
user << "<span class='notice'>There's already a clip in \the [src].</span>"
|
||||
to_chat(user, "<span class='notice'>There's already a clip in \the [src].</span>")
|
||||
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/vintage/load_ammo(var/obj/item/A, mob/user)
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/vintage/load_ammo(var/obj/item/A, mob/user)
|
||||
if(!open_bolt)
|
||||
user << "<span class='warning'>The bolt is closed on \the [src.name]!</span>"
|
||||
user << "<span class='warning'>The bolt is closed on \the [src]!</span>"
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/projectile/boltaction/vintage/Fire(atom/target, mob/living/user, clickparams, pointblank=0, reflex=0)
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/rifle/vintage/Fire(atom/target, mob/living/user, clickparams, pointblank=0, reflex=0)
|
||||
if(open_bolt)
|
||||
user << "<span class='warning'>The bolt is open on \the [src.name]!</span>"
|
||||
user << "<span class='warning'>The bolt is open on \the [src]!</span>"
|
||||
return
|
||||
..()
|
||||
..()
|
||||
|
||||
@@ -1,12 +1,51 @@
|
||||
/obj/item/weapon/gun/projectile/shotgun
|
||||
name = "strange shotgun"
|
||||
desc = "A strange shotgun that doesn't seem to belong anywhere. You feel like you shouldn't be able to see this and should... submit an issue?"
|
||||
|
||||
var/can_sawoff = FALSE
|
||||
var/sawnoff_workmsg
|
||||
var/sawing_in_progress = FALSE
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/attackby(obj/item/A, mob/user)
|
||||
if (!can_sawoff || sawing_in_progress)
|
||||
return ..()
|
||||
|
||||
var/static/list/barrel_cutting_tools = typecacheof(list(
|
||||
/obj/item/weapon/circular_saw,
|
||||
/obj/item/weapon/melee/energy,
|
||||
/obj/item/weapon/gun/energy/plasmacutter // does this even work?
|
||||
))
|
||||
if(is_type_in_typecache(A, barrel_cutting_tools) && w_class != 3)
|
||||
to_chat(user, "<span class='notice'>You begin to [sawnoff_workmsg] of \the [src].</span>")
|
||||
if(loaded.len)
|
||||
for(var/i in 1 to max_shells)
|
||||
Fire(user, user) //will this work? //it will. we call it twice, for twice the FUN
|
||||
user.visible_message("<span class='danger'>\The [src] goes off!</span>", "<span class='danger'>\The [src] goes off in your face!</span>")
|
||||
return
|
||||
|
||||
sawing_in_progress = TRUE
|
||||
if(do_after(user, 30, act_target = src)) //SHIT IS STEALTHY EYYYYY
|
||||
sawing_in_progress = FALSE
|
||||
saw_off(user, A)
|
||||
else
|
||||
..()
|
||||
|
||||
// called on a SUCCESSFUL saw-off.
|
||||
/obj/item/weapon/gun/projectile/shotgun/proc/saw_off(mob/user, obj/item/tool)
|
||||
to_chat(user, "<span class='notice'>You attempt to cut [src]'s barrel with [tool], but nothing happens.</span>")
|
||||
log_debug("shotgun: attempt to saw-off shotgun with no saw-off behavior.")
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump
|
||||
name = "pump shotgun"
|
||||
desc = "An ubiquitous unbranded shotgun. Useful for sweeping alleys."
|
||||
icon_state = "shotgun"
|
||||
item_state = "shotgun"
|
||||
max_shells = 4
|
||||
w_class = 4.0
|
||||
w_class = ITEMSIZE_LARGE
|
||||
force = 10
|
||||
flags = CONDUCT
|
||||
flags = CONDUCT
|
||||
slot_flags = SLOT_BACK
|
||||
caliber = "shotgun"
|
||||
origin_tech = list(TECH_COMBAT = 4, TECH_MATERIAL = 2)
|
||||
@@ -15,8 +54,11 @@
|
||||
handle_casings = HOLD_CASINGS
|
||||
fire_sound = 'sound/weapons/shotgun.ogg'
|
||||
var/recentpump = 0 // to prevent spammage
|
||||
var/pump_fail_msg = "<span class='warning'>You cannot rack the shotgun without gripping it with both hands!</span>"
|
||||
var/pump_snd = 'sound/weapons/shotgunpump.ogg'
|
||||
var/has_wield_state = TRUE
|
||||
|
||||
action_button_name = "Wield rifle"
|
||||
action_button_name = "Wield shotgun"
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/can_wield()
|
||||
return 1
|
||||
@@ -26,7 +68,7 @@
|
||||
toggle_wield(usr)
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/verb/wield_shotgun()
|
||||
set name = "Wield shotgun"
|
||||
set name = "Wield"
|
||||
set category = "Object"
|
||||
set src in usr
|
||||
|
||||
@@ -37,20 +79,20 @@
|
||||
return chambered.BB
|
||||
return null
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/attack_self(mob/living/user as mob)
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/attack_self(mob/living/user)
|
||||
if(world.time >= recentpump + 10)
|
||||
pump(user)
|
||||
recentpump = world.time
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/proc/pump(mob/M as mob)
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/proc/pump(mob/M)
|
||||
if(!wielded)
|
||||
M << "<span class='warning'>You cannot rack the shotgun without gripping it with both hands!</span>"
|
||||
to_chat(M, pump_fail_msg)
|
||||
return
|
||||
|
||||
playsound(M, 'sound/weapons/shotgunpump.ogg', 60, 1)
|
||||
playsound(M, pump_snd, 60, 1)
|
||||
|
||||
if(chambered)//We have a shell in the chamber
|
||||
chambered.loc = get_turf(src)//Eject casing
|
||||
chambered.forceMove(get_turf(src)) //Eject casing
|
||||
chambered = null
|
||||
|
||||
if(loaded.len)
|
||||
@@ -62,7 +104,7 @@
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/update_icon()
|
||||
..()
|
||||
if(wielded)
|
||||
if(wielded && has_wield_state)
|
||||
item_state = "[icon_state]-wielded"
|
||||
else
|
||||
item_state = "[icon_state]"
|
||||
@@ -103,6 +145,9 @@
|
||||
list(mode_name="fire both barrels at once", burst=2)
|
||||
)
|
||||
|
||||
can_sawoff = TRUE
|
||||
sawnoff_workmsg = "shorten the barrel"
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/doublebarrel/pellet
|
||||
ammo_type = /obj/item/ammo_casing/shotgun/pellet
|
||||
|
||||
@@ -114,28 +159,16 @@
|
||||
/obj/item/weapon/gun/projectile/shotgun/doublebarrel/unload_ammo(user, allow_dump)
|
||||
..(user, allow_dump=1)
|
||||
|
||||
//this is largely hacky and bad :( -Pete
|
||||
/obj/item/weapon/gun/projectile/shotgun/doublebarrel/attackby(var/obj/item/A as obj, mob/user as mob)
|
||||
if(istype(A, /obj/item/weapon/circular_saw) || istype(A, /obj/item/weapon/melee/energy) || istype(A, /obj/item/weapon/gun/energy/plasmacutter) && w_class != 3)
|
||||
user << "<span class='notice'>You begin to shorten the barrel of \the [src].</span>"
|
||||
if(loaded.len)
|
||||
for(var/i in 1 to max_shells)
|
||||
Fire(user, user) //will this work? //it will. we call it twice, for twice the FUN
|
||||
user.visible_message("<span class='danger'>The shotgun goes off!</span>", "<span class='danger'>The shotgun goes off in your face!</span>")
|
||||
return
|
||||
if(do_after(user, 30)) //SHIT IS STEALTHY EYYYYY
|
||||
icon_state = "sawnshotgun"
|
||||
item_state = "sawnshotgun"
|
||||
w_class = 3
|
||||
force = 5
|
||||
slot_flags &= ~SLOT_BACK //you can't sling it on your back
|
||||
slot_flags |= (SLOT_BELT|SLOT_HOLSTER) //but you can wear it on your belt (poorly concealed under a trenchcoat, ideally) - or in a holster, why not.
|
||||
name = "sawn-off shotgun"
|
||||
desc = "Omar's coming!"
|
||||
user << "<span class='warning'>You shorten the barrel of \the [src]!</span>"
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/doublebarrel/saw_off(mob/user, obj/item/tool)
|
||||
icon_state = "sawnshotgun"
|
||||
item_state = "sawnshotgun"
|
||||
w_class = 3
|
||||
force = 5
|
||||
slot_flags &= ~SLOT_BACK //you can't sling it on your back
|
||||
slot_flags |= (SLOT_BELT|SLOT_HOLSTER) //but you can wear it on your belt (poorly concealed under a trenchcoat, ideally) - or in a holster, why not.
|
||||
name = "sawn-off shotgun"
|
||||
desc = "Omar's coming!"
|
||||
to_chat(user, "<span class='warning'>You shorten the barrel of \the [src]!</span>")
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/doublebarrel/sawn
|
||||
name = "sawn-off shotgun"
|
||||
|
||||
Reference in New Issue
Block a user