mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-30 12:02:24 +00:00
Rewrites gun.dm. Reorganizes the firing procedure into logical procs and cleans up some unnecessary variables or demotes them to the subtypes that actually care. Energy weapons that create their own projectiles no longer care about in_chamber. Launcher support is much more natural now. Cleans up duplicated cyborg energy weapon power supply code. Adds support for energy weapons to recharge from external power sources, unifying cyborg and hardsuit mounted weapons. Incorporates the cyborg taser recharging mechanism. Cleans up laser tag gun duplication Changes path strings to actual paths. Changes relative paths to absolute paths. Renamed several targeting vars to make their purposes more clear. Fixed targeting not handling firing correctly for certain subtypes.
126 lines
3.5 KiB
Plaintext
126 lines
3.5 KiB
Plaintext
#define SPEEDLOADER 0
|
|
#define FROM_BOX 1
|
|
#define MAGAZINE 2
|
|
|
|
/obj/item/weapon/gun/projectile
|
|
name = "revolver"
|
|
desc = "A classic revolver. Uses .357 ammo"
|
|
icon_state = "revolver"
|
|
origin_tech = "combat=2;materials=2"
|
|
w_class = 3.0
|
|
matter = list("metal" = 1000)
|
|
recoil = 1
|
|
var/caliber = "357"
|
|
var/ammo_type = "/obj/item/ammo_casing/a357"
|
|
var/list/loaded = list()
|
|
var/max_shells = 7
|
|
var/load_method = SPEEDLOADER //0 = Single shells or quick loader, 1 = box, 2 = magazine
|
|
var/obj/item/ammo_magazine/empty_mag = null
|
|
var/mag_type = null
|
|
|
|
/obj/item/weapon/gun/projectile/New()
|
|
..()
|
|
for(var/i = 1, i <= max_shells, i++)
|
|
loaded += new ammo_type(src)
|
|
if(load_method == MAGAZINE)
|
|
empty_mag = new mag_type(src)
|
|
update_icon()
|
|
return
|
|
|
|
/obj/item/weapon/gun/projectile/can_fire()
|
|
if(!loaded.len)
|
|
return 0
|
|
return 1
|
|
|
|
/obj/item/weapon/gun/projectile/get_next_projectile()
|
|
if(!loaded.len)
|
|
return null
|
|
var/obj/item/ammo_casing/AC = loaded[1] //load next casing.
|
|
if(isnull(AC) || !istype(AC))
|
|
return null
|
|
if(AC.BB)
|
|
AC.BB.loc = src //Set projectile loc to gun.
|
|
return AC.BB //Load projectile into chamber.
|
|
return null
|
|
|
|
/obj/item/weapon/gun/projectile/handle_post_fire()
|
|
..()
|
|
if(loaded.len)
|
|
var/obj/item/ammo_casing/AC = loaded[1]
|
|
loaded -= AC
|
|
AC.loc = get_turf(src) //Eject casing onto ground.
|
|
|
|
/obj/item/weapon/gun/projectile/attackby(var/obj/item/A as obj, mob/user as mob)
|
|
|
|
var/num_loaded = 0
|
|
if(istype(A, /obj/item/ammo_magazine))
|
|
if((load_method == MAGAZINE) && loaded.len) return
|
|
var/obj/item/ammo_magazine/AM = A
|
|
if(AM.stored_ammo.len <= 0)
|
|
user << "<span class='warning'>The magazine is empty!</span>"
|
|
return
|
|
for(var/obj/item/ammo_casing/AC in AM.stored_ammo)
|
|
if(loaded.len >= max_shells)
|
|
break
|
|
if(AC.caliber == caliber && loaded.len < max_shells)
|
|
AC.loc = src
|
|
AM.stored_ammo -= AC
|
|
loaded += AC
|
|
num_loaded++
|
|
if(load_method == MAGAZINE)
|
|
user.remove_from_mob(AM)
|
|
empty_mag = AM
|
|
empty_mag.loc = src
|
|
if(istype(A, /obj/item/ammo_casing) && load_method == SPEEDLOADER)
|
|
var/obj/item/ammo_casing/AC = A
|
|
if(AC.caliber == caliber && loaded.len < max_shells)
|
|
user.drop_item()
|
|
AC.loc = src
|
|
loaded += AC
|
|
num_loaded++
|
|
if(num_loaded)
|
|
user << "\blue You load [num_loaded] shell\s into the gun!"
|
|
A.update_icon()
|
|
update_icon()
|
|
return
|
|
|
|
/obj/item/weapon/gun/projectile/attack_self(mob/user as mob)
|
|
if (aim_targets)
|
|
return ..()
|
|
if (loaded.len)
|
|
if (load_method == SPEEDLOADER)
|
|
var/obj/item/ammo_casing/AC = loaded[1]
|
|
loaded -= AC
|
|
AC.loc = get_turf(src) //Eject casing onto ground.
|
|
user << "\blue You unload shell from \the [src]!"
|
|
if (load_method == MAGAZINE)
|
|
var/obj/item/ammo_magazine/AM = empty_mag
|
|
for (var/obj/item/ammo_casing/AC in loaded)
|
|
AM.stored_ammo += AC
|
|
loaded -= AC
|
|
AM.loc = get_turf(src)
|
|
empty_mag = null
|
|
update_icon()
|
|
AM.update_icon()
|
|
user << "\blue You unload magazine from \the [src]!"
|
|
else
|
|
user << "\red Nothing loaded in \the [src]!"
|
|
|
|
|
|
|
|
/obj/item/weapon/gun/projectile/examine(mob/user)
|
|
..(user)
|
|
user << "Has [getAmmo()] round\s remaining."
|
|
// if(in_chamber && !loaded.len)
|
|
// user << "However, it has a chambered round."
|
|
// if(in_chamber && loaded.len)
|
|
// user << "It also has a chambered round." {R}
|
|
return
|
|
|
|
/obj/item/weapon/gun/projectile/proc/getAmmo()
|
|
var/bullets = 0
|
|
for(var/obj/item/ammo_casing/AC in loaded)
|
|
if(istype(AC))
|
|
bullets += 1
|
|
return bullets
|