mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-21 15:42:35 +00:00
Adding more features to guns (#768)
In this new gun patch: -rewritting bolt action rifles, so they are less shotgun like, also new sounds for them! -adding a spin cylinder verb for the revolver -jamming mechanics for guns, only the ghetto .45 pistol will use them atm -minor changes to renegades, removing big shotgun that won't make it really stealthy, and heisters, by adding more guns.
This commit is contained in:
@@ -27,6 +27,10 @@
|
||||
var/list/allowed_magazines //determines list of which magazines will fit in the gun
|
||||
var/auto_eject = 0 //if the magazine should automatically eject itself when empty.
|
||||
var/auto_eject_sound = null
|
||||
|
||||
var/is_jammed = 0 //Whether this gun is jammed
|
||||
var/jam_chance = 0 //Chance it jams on fire
|
||||
|
||||
//TODO generalize ammo icon states for guns
|
||||
//var/magazine_states = 0
|
||||
//var/list/icon_keys = list() //keys
|
||||
@@ -42,6 +46,8 @@
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/gun/projectile/consume_next_projectile()
|
||||
if(is_jammed)
|
||||
return 0
|
||||
//get the next casing
|
||||
if(loaded.len)
|
||||
chambered = loaded[1] //load next casing.
|
||||
@@ -66,6 +72,15 @@
|
||||
..()
|
||||
process_chambered()
|
||||
|
||||
/obj/item/weapon/gun/projectile/special_check(var/mob/user)
|
||||
if(!..())
|
||||
return 0
|
||||
if(!is_jammed && jam_chance)
|
||||
if(prob(jam_chance))
|
||||
user << "<span class='danger'>\The [src] jams!</span>"
|
||||
is_jammed = 1
|
||||
return 1
|
||||
|
||||
/obj/item/weapon/gun/projectile/proc/process_chambered()
|
||||
if (!chambered) return
|
||||
|
||||
@@ -176,8 +191,13 @@
|
||||
load_ammo(A, user)
|
||||
|
||||
/obj/item/weapon/gun/projectile/attack_self(mob/user as mob)
|
||||
if(firemodes.len > 1)
|
||||
switch_firemodes(user)
|
||||
if(is_jammed)
|
||||
user << "<span class='notice'>\The [user] unjams \the [src]!</span>"
|
||||
if(do_after(user, 5))
|
||||
playsound(src.loc, 'sound/weapons/empty.ogg', 100, 1)
|
||||
is_jammed = 0
|
||||
else if(firemodes.len > 1)
|
||||
..()
|
||||
else
|
||||
unload_ammo(user)
|
||||
|
||||
@@ -187,6 +207,7 @@
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/item/weapon/gun/projectile/afterattack(atom/A, mob/living/user)
|
||||
..()
|
||||
if(auto_eject && ammo_magazine && ammo_magazine.stored_ammo && !ammo_magazine.stored_ammo.len)
|
||||
@@ -203,6 +224,8 @@
|
||||
|
||||
/obj/item/weapon/gun/projectile/examine(mob/user)
|
||||
..(user)
|
||||
if(is_jammed)
|
||||
user << "<span class='warning'>It looks jammed.</span>"
|
||||
if(ammo_magazine)
|
||||
user << "It has \a [ammo_magazine] loaded."
|
||||
user << "Has [getAmmo()] round\s remaining."
|
||||
|
||||
93
code/modules/projectiles/guns/projectile/boltaction.dm
Normal file
93
code/modules/projectiles/guns/projectile/boltaction.dm
Normal file
@@ -0,0 +1,93 @@
|
||||
/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 = "combat=2;materials=2"
|
||||
fire_sound = 'sound/weapons/rifleshot.ogg'
|
||||
slot_flags = SLOT_BACK
|
||||
load_method = SINGLE_CASING|SPEEDLOADER
|
||||
caliber = "a762"
|
||||
ammo_type = /obj/item/ammo_casing/a762
|
||||
max_shells = 5
|
||||
w_class = 4.0
|
||||
force = 10
|
||||
var/recentpump = 0
|
||||
|
||||
icon_action_button = "action_blank"
|
||||
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/pickaxe/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 = "gun"
|
||||
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 = "gun"
|
||||
w_class = 3
|
||||
recoil = 2
|
||||
accuracy = -2
|
||||
slot_flags = SLOT_BELT|SLOT_HOLSTER
|
||||
@@ -140,6 +140,7 @@
|
||||
origin_tech = "combat=2;materials=2"
|
||||
fire_sound = 'sound/weapons/Gunshot_light.ogg'
|
||||
load_method = MAGAZINE
|
||||
jam_chance = 55
|
||||
|
||||
/obj/item/weapon/stock/update_icon()
|
||||
icon_state = "ipistol[buildstate]"
|
||||
|
||||
@@ -8,6 +8,30 @@
|
||||
handle_casings = CYCLE_CASINGS
|
||||
max_shells = 7
|
||||
ammo_type = /obj/item/ammo_casing/a357
|
||||
var/chamber_offset = 0 //how many empty chambers in the cylinder until you hit a round
|
||||
|
||||
/obj/item/weapon/gun/projectile/revolver/verb/spin_cylinder()
|
||||
set name = "Spin cylinder"
|
||||
set desc = "Fun when you're bored out of your skull."
|
||||
set category = "Object"
|
||||
|
||||
chamber_offset = 0
|
||||
usr.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)
|
||||
loaded = shuffle(loaded)
|
||||
if(rand(1,max_shells) > loaded.len)
|
||||
chamber_offset = rand(0,max_shells - loaded.len)
|
||||
|
||||
/obj/item/weapon/gun/projectile/revolver/consume_next_projectile()
|
||||
if(chamber_offset)
|
||||
chamber_offset--
|
||||
return
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/gun/projectile/revolver/load_ammo(var/obj/item/A, mob/user)
|
||||
chamber_offset = 0
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/gun/projectile/revolver/mateba
|
||||
name = "mateba"
|
||||
|
||||
@@ -136,46 +136,3 @@
|
||||
w_class = 3
|
||||
force = 5
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/boltaction
|
||||
name = "\improper bolt action rifle"
|
||||
desc = "A cheap ballistic rifle often found in the hands of crooks and frontiersmen."
|
||||
icon_state = "moistnugget"
|
||||
item_state = "moistnugget"
|
||||
origin_tech = "combat=4;materials=2"
|
||||
slot_flags = SLOT_BACK
|
||||
load_method = SINGLE_CASING|SPEEDLOADER
|
||||
caliber = "a762"
|
||||
ammo_type = /obj/item/ammo_casing/a762
|
||||
max_shells = 5
|
||||
|
||||
/obj/item/weapon/gun/projectile/shotgun/pump/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/pickaxe/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 = "gun"
|
||||
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/shotgun/pump/boltaction/obrez
|
||||
name = "obrez"
|
||||
desc = "A shortened bolt action rifle, not really accurate. Uses 7.62mm rounds."
|
||||
icon_state = "obrez"
|
||||
item_state = "gun"
|
||||
w_class = 3
|
||||
recoil = 2
|
||||
accuracy = -2
|
||||
slot_flags = SLOT_BELT|SLOT_HOLSTER
|
||||
|
||||
Reference in New Issue
Block a user