Gun update; new icons, more guns and better code organization (#3434)

-ports some gun and gun mechanics from polaris and bay such as the Lemant revolver, capguns sprites
-collapses svd.dm and scout_sniper.dm into sniper.dm
-renames boltaction.dm to rifle.dm
This commit is contained in:
Alberyk
2017-09-18 22:22:09 +03:00
committed by Erki
parent a9bbe58b92
commit 62f142e215
14 changed files with 383 additions and 212 deletions
@@ -79,7 +79,7 @@
projectile_type = /obj/item/projectile/beam/xray
origin_tech = list(TECH_COMBAT = 5, TECH_MATERIAL = 3, TECH_MAGNET = 2, TECH_ILLEGAL = 2)
max_shots = 40
/obj/item/weapon/gun/energy/rifle/pulse
name = "pulse rifle"
desc = "A weapon that uses advanced pulse-based beam generation technology to emit powerful laser blasts. Because of its complexity and cost, it is rarely seen in use except by specialists."
@@ -89,7 +89,7 @@
projectile_type = /obj/item/projectile/beam
sel_mode = 2
origin_tech = list(TECH_COMBAT = 7, TECH_MATERIAL = 6, TECH_MAGNET = 4)
modifystate = null
firemodes = list(
@@ -132,13 +132,20 @@
name = ".50 magnum pistol"
desc = "A robust handgun that uses .50 AE ammo."
icon_state = "deagle"
item_state = "deagle"
force = 14.0
caliber = ".50"
load_method = MAGAZINE
magazine_type = /obj/item/ammo_magazine/a50
allowed_magazines = list(/obj/item/ammo_magazine/a50)
auto_eject = 1
auto_eject_sound = 'sound/weapons/smg_empty_alarm.ogg'
/obj/item/weapon/gun/projectile/deagle/update_icon()
..()
if(ammo_magazine)
icon_state = "[initial(icon_state)]"
else
icon_state = "[initial(icon_state)]-e"
/obj/item/weapon/gun/projectile/deagle/gold
desc = "A gold plated gun folded over a million times by superior martian gunsmiths. Uses .50 AE ammo."
@@ -148,8 +155,6 @@
/obj/item/weapon/gun/projectile/deagle/camo
desc = "A Deagle brand Deagle for operators operating operationally. Uses .50 AE ammo."
icon_state = "deaglecamo"
item_state = "deagleg"
auto_eject_sound = 'sound/weapons/smg_empty_alarm.ogg'
/obj/item/weapon/gun/projectile/gyropistol
name = "gyrojet pistol"
@@ -106,10 +106,111 @@
/obj/item/weapon/gun/projectile/revolver/capgun
name = "cap gun"
desc = "Looks almost like the real thing! Ages 8 and up."
icon_state = "revolver"
icon_state = "capgun"
item_state = "revolver"
caliber = "caps"
origin_tech = list(TECH_COMBAT = 1, TECH_MATERIAL = 1)
handle_casings = CYCLE_CASINGS
max_shells = 7
ammo_type = /obj/item/ammo_casing/cap
/obj/item/weapon/gun/projectile/revolver/capgun/attackby(obj/item/W, mob/user)
if(!iswirecutter(W) || icon_state == "revolver")
return ..()
to_chat(user, "<span class='notice'>You snip off the toy markings off the [src].</span>")
name = "revolver"
icon_state = "revolver"
desc += " Someone snipped off the barrel's toy mark. How dastardly."
return 1
/obj/item/weapon/gun/projectile/revolver/lemat
name = "grapeshot revolver"
desc = "The LeMat revolver is a 6 shot revolver with a secondary firing barrel loading shotgun shells. Uses .38-Special and 12g rounds depending on the barrel."
icon_state = "lemat"
item_state = "revolver"
origin_tech = list(TECH_COMBAT = 2, TECH_MATERIAL = 2)
handle_casings = CYCLE_CASINGS
max_shells = 6
caliber = "38"
fire_sound = 'sound/weapons/Gunshot_light.ogg'
ammo_type = /obj/item/ammo_casing/c38
var/secondary_max_shells = 1
var/secondary_caliber = "shotgun"
var/secondary_ammo_type = /obj/item/ammo_casing/shotgun/pellet
var/flipped_firing = 0
var/list/secondary_loaded = list()
var/list/tertiary_loaded = list()
/obj/item/weapon/gun/projectile/revolver/lemat/Initialize()
. = ..()
for(var/i in 1 to secondary_max_shells)
secondary_loaded += new secondary_ammo_type(src)
/obj/item/weapon/gun/projectile/revolver/lemat/verb/swap_firingmode()
set name = "Swap Firing Mode"
set category = "Object"
set desc = "Click to swap from one method of firing to another."
var/mob/living/carbon/human/M = usr
if(!M.mind)
return 0
to_chat(M, "<span class='notice'>You change the firing mode on \the [src].</span>")
if(!flipped_firing)
if(max_shells && secondary_max_shells)
max_shells = secondary_max_shells
if(caliber && secondary_caliber)
caliber = secondary_caliber
fire_sound = 'sound/weapons/shotgun.ogg'
if(ammo_type && secondary_ammo_type)
ammo_type = secondary_ammo_type
if(secondary_loaded)
tertiary_loaded = loaded.Copy()
loaded = secondary_loaded
flipped_firing = 1
else
if(max_shells)
max_shells = initial(max_shells)
if(caliber && secondary_caliber)
caliber = initial(caliber)
fire_sound = initial(fire_sound)
if(ammo_type && secondary_ammo_type)
ammo_type = initial(ammo_type)
if(tertiary_loaded)
secondary_loaded = loaded.Copy()
loaded = tertiary_loaded
flipped_firing = 0
/obj/item/weapon/gun/projectile/revolver/lemat/spin_cylinder()
set name = "Spin cylinder"
set desc = "Fun when you're bored out of your skull."
set category = "Object"
chamber_offset = 0
visible_message("<span class='warning'>\The [usr] spins the cylinder of \the [src]!</span>", \
"<span class='notice'>You hear something metallic spin and click.</span>")
playsound(src.loc, 'sound/weapons/revolver_spin.ogg', 100, 1)
if(!flipped_firing)
loaded = shuffle(loaded)
if(rand(1,max_shells) > loaded.len)
chamber_offset = rand(0,max_shells - loaded.len)
/obj/item/weapon/gun/projectile/revolver/lemat/examine(mob/user)
..()
if(secondary_loaded)
var/to_print
for(var/round in secondary_loaded)
to_print += round
to_chat(user, "\The [src] has a secondary barrel loaded with \a [to_print]")
else
to_chat(user, "\The [src] has a secondary barrel that is empty.")
@@ -1,93 +1,143 @@
/obj/item/weapon/gun/projectile/boltaction
name = "\improper 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
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/boltaction/can_wield()
return 1
/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
name = "obrez"
desc = "A shortened bolt action rifle, not really accurate. Uses 7.62mm rounds."
icon_state = "obrez"
item_state = "obrez"
w_class = 3
recoil = 2
accuracy = -2
slot_flags = SLOT_BELT|SLOT_HOLSTER
/obj/item/weapon/gun/projectile/boltaction
name = "\improper 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
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/boltaction/can_wield()
return 1
/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
name = "obrez"
desc = "A shortened bolt action rifle, not really accurate. Uses 7.62mm rounds."
icon_state = "obrez"
item_state = "obrez"
w_class = 3
recoil = 2
accuracy = -2
slot_flags = SLOT_BELT|SLOT_HOLSTER
/obj/item/weapon/gun/projectile/contender
name = "pocket rifle"
desc = "A perfect, pristine replica of an ancient one-shot hand-cannon. This one has been modified to work almost like a bolt-action. Uses 5.56mm rounds."
icon_state = "pockrifle"
item_state = "obrez"
caliber = "a556"
handle_casings = HOLD_CASINGS
max_shells = 1
ammo_type = /obj/item/ammo_casing/a556
slot_flags = SLOT_BELT|SLOT_HOLSTER
load_method = SINGLE_CASING
fire_sound = 'sound/weapons/rifleshot.ogg'
var/retracted_bolt = 0
var/icon_retracted = "pockrifle-empty"
/obj/item/weapon/gun/projectile/contender/special_check(mob/user)
if(retracted_bolt)
user << "<span class='warning'>You can't fire \the [src] while the bolt is open!</span>"
return 0
return ..()
/obj/item/weapon/gun/projectile/contender/attack_self(mob/user as mob)
if(chambered)
chambered.loc = get_turf(src)
chambered = null
var/obj/item/ammo_casing/C = loaded[1]
loaded -= C
if(!retracted_bolt)
to_chat(user, "<span class='notice'>You cycle back the bolt on \the [src], ejecting the casing and allowing you to reload.</span>")
playsound(user, 'sound/weapons/riflebolt.ogg', 60, 1)
icon_state = icon_retracted
retracted_bolt = 1
return 1
else if(retracted_bolt && loaded.len)
to_chat(user, "<span class='notice'>You cycle the loaded round into the chamber, allowing you to fire.</span>")
else
to_chat(user, "<span class='notice'>You cycle the bolt back into position, leaving the gun empty.</span>")
icon_state = initial(icon_state)
retracted_bolt = 0
/obj/item/weapon/gun/projectile/contender/load_ammo(var/obj/item/A, mob/user)
if(!retracted_bolt)
to_chat(user, "<span class='notice'>You can't load \the [src] without cycling the bolt.</span>")
return
..()
@@ -1,44 +0,0 @@
/obj/item/weapon/gun/projectile/automatic/rifle/w556
name = "scout rifle"
desc = "A lightweight Neyland 556mi 'Ranger' used within the Sol Navy and Nanotrasen Emergency Response Teams. Equipped with a scope and designed for medium to long range combat, with moderate stopping power. Chambered in 5.56 rounds."
icon_state = "w556rifle"
item_state = "heavysniper"
w_class = 4
force = 10
slot_flags = SLOT_BACK
origin_tech = list(TECH_COMBAT = 5, TECH_MATERIAL = 3)
caliber = "a556"
recoil = 4
load_method = MAGAZINE
fire_sound = 'sound/weapons/Gunshot_DMR.ogg'
max_shells = 10
ammo_type = /obj/item/ammo_casing/a556/ap
magazine_type = /obj/item/ammo_magazine/a556/ap
allowed_magazines = list(/obj/item/ammo_magazine/a556, /obj/item/ammo_magazine/a556/ap)
accuracy = -4
scoped_accuracy = 3
recoil_wielded = 2
accuracy_wielded = 0
multi_aim = 0 //Definitely a fuck no. Being able to target one person at this range is plenty.
firemodes = list(
list(mode_name="semiauto", burst=1, fire_delay=0, move_delay=null, burst_accuracy=null, dispersion=null),
list(mode_name="2-round bursts", burst=2, fire_delay=null, move_delay=4, burst_accuracy=list(0,-1,-1), dispersion=list(0.0, 0.6, 1.0))
)
/obj/item/weapon/gun/projectile/automatic/rifle/w556/verb/scope()
set category = "Object"
set name = "Use Scope"
set popup_menu = 1
if(wielded)
toggle_scope(2.0, usr)
else
usr << "<span class='warning'>You can't look through the scope without stabilizing the rifle!</span>"
/obj/item/weapon/gun/projectile/automatic/rifle/w556/update_icon()
if(wielded)
item_state = "heavysniper-wielded"
else
item_state = "heavysniper"
update_held_icon()
@@ -130,6 +130,115 @@
icon_state = "tranqsniper-open"
else
icon_state = "tranqsniper"
if(wielded)
item_state = "heavysniper-wielded"
else
item_state = "heavysniper"
update_held_icon()
/obj/item/weapon/gun/projectile/dragunov
name = "antique sniper rifle"
desc = "An old Dragunov semi-automatic marksman rifle. Smells of vodka and Communism. Uses 7.62mm rounds."
icon = 'icons/obj/dragunov.dmi'
icon_state = "dragunov"
item_state = "dragunov"
contained_sprite = 1
w_class = 4
force = 10
slot_flags = SLOT_BACK
origin_tech = list(TECH_COMBAT = 8, TECH_MATERIAL = 3, TECH_MAGNET = 2, TECH_ILLEGAL = 5)
caliber = "a762"
recoil = 2
fire_sound = 'sound/weapons/svd_shot.ogg'
load_method = MAGAZINE
max_shells = 10
magazine_type = /obj/item/ammo_magazine/d762
allowed_magazines = list(/obj/item/ammo_magazine/d762)
accuracy = -4
scoped_accuracy = 2
recoil_wielded = 1
accuracy_wielded = 0
//action button for wielding
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/dragunov/update_icon()
if(ammo_magazine)
icon_state = "dragunov"
else
icon_state = "dragunov-empty"
/obj/item/weapon/gun/projectile/dragunov/can_wield()
return 1
/obj/item/weapon/gun/projectile/dragunov/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/projectile/dragunov/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/projectile/dragunov/special_check(mob/user)
if(!wielded)
user << "<span class='warning'>You can't fire without stabilizing the rifle!</span>"
return 0
return ..()
/obj/item/weapon/gun/projectile/dragunov/verb/scope()
set category = "Object"
set name = "Use Scope"
set popup_menu = 1
if(wielded)
toggle_scope(2.0, usr)
else
usr << "<span class='warning'>You can't look through the scope without stabilizing the rifle!</span>"
/obj/item/weapon/gun/projectile/automatic/rifle/w556
name = "scout rifle"
desc = "A lightweight Neyland 556mi 'Ranger' used within the Sol Navy and Nanotrasen Emergency Response Teams. Equipped with a scope and designed for medium to long range combat, with moderate stopping power. Chambered in 5.56 rounds."
icon_state = "w556rifle"
item_state = "heavysniper"
w_class = 4
force = 10
slot_flags = SLOT_BACK
origin_tech = list(TECH_COMBAT = 5, TECH_MATERIAL = 3)
caliber = "a556"
recoil = 4
load_method = MAGAZINE
fire_sound = 'sound/weapons/Gunshot_DMR.ogg'
max_shells = 10
ammo_type = /obj/item/ammo_casing/a556/ap
magazine_type = /obj/item/ammo_magazine/a556/ap
allowed_magazines = list(/obj/item/ammo_magazine/a556, /obj/item/ammo_magazine/a556/ap)
accuracy = -4
scoped_accuracy = 3
recoil_wielded = 2
accuracy_wielded = 0
multi_aim = 0 //Definitely a fuck no. Being able to target one person at this range is plenty.
firemodes = list(
list(mode_name="semiauto", burst=1, fire_delay=0, move_delay=null, burst_accuracy=null, dispersion=null),
list(mode_name="2-round bursts", burst=2, fire_delay=null, move_delay=4, burst_accuracy=list(0,-1,-1), dispersion=list(0.0, 0.6, 1.0))
)
/obj/item/weapon/gun/projectile/automatic/rifle/w556/verb/scope()
set category = "Object"
set name = "Use Scope"
set popup_menu = 1
if(wielded)
toggle_scope(2.0, usr)
else
usr << "<span class='warning'>You can't look through the scope without stabilizing the rifle!</span>"
/obj/item/weapon/gun/projectile/automatic/rifle/w556/update_icon()
if(wielded)
item_state = "heavysniper-wielded"
else
@@ -1,63 +0,0 @@
/obj/item/weapon/gun/projectile/dragunov
name = "antique sniper rifle"
desc = "An old Dragunov semi-automatic marksman rifle. Smells of vodka and Communism. Uses 7.62mm rounds."
icon = 'icons/obj/dragunov.dmi'
icon_state = "dragunov"
item_state = "dragunov"
contained_sprite = 1
w_class = 4
force = 10
slot_flags = SLOT_BACK
origin_tech = list(TECH_COMBAT = 8, TECH_MATERIAL = 3, TECH_MAGNET = 2, TECH_ILLEGAL = 5)
caliber = "a762"
recoil = 2
fire_sound = 'sound/weapons/svd_shot.ogg'
load_method = MAGAZINE
max_shells = 10
magazine_type = /obj/item/ammo_magazine/d762
allowed_magazines = list(/obj/item/ammo_magazine/d762)
accuracy = -4
scoped_accuracy = 2
recoil_wielded = 1
accuracy_wielded = 0
//action button for wielding
action_button_name = "Wield rifle"
/obj/item/weapon/gun/projectile/dragunov/update_icon()
if(ammo_magazine)
icon_state = "dragunov"
else
icon_state = "dragunov-empty"
/obj/item/weapon/gun/projectile/dragunov/can_wield()
return 1
/obj/item/weapon/gun/projectile/dragunov/ui_action_click()
if(src in usr)
toggle_wield(usr)
/obj/item/weapon/gun/projectile/dragunov/verb/wield_rifle()
set name = "Wield rifle"
set category = "Object"
set src in usr
toggle_wield(usr)
/obj/item/weapon/gun/projectile/dragunov/special_check(mob/user)
if(!wielded)
user << "<span class='warning'>You can't fire without stabilizing the rifle!</span>"
return 0
return ..()
/obj/item/weapon/gun/projectile/dragunov/verb/scope()
set category = "Object"
set name = "Use Scope"
set popup_menu = 1
if(wielded)
toggle_scope(2.0, usr)
else
usr << "<span class='warning'>You can't look through the scope without stabilizing the rifle!</span>"