Files
GS13NG/code/modules/projectiles/boxes_magazines/internal/_cylinder.dm
CitadelStationBot c72201e605 [MIRROR] Splits projectiles into different files for readability (#5800)
* Splits projectiles into different files for readability

* Update tgstation.dme

* I love how the dme cleans itself up
2018-03-05 14:13:08 -06:00

48 lines
1.2 KiB
Plaintext

/obj/item/ammo_box/magazine/internal/cylinder
name = "revolver cylinder"
ammo_type = /obj/item/ammo_casing/a357
caliber = "357"
max_ammo = 7
/obj/item/ammo_box/magazine/internal/cylinder/ammo_count(countempties = 1)
var/boolets = 0
for(var/obj/item/ammo_casing/bullet in stored_ammo)
if(bullet && (bullet.BB || countempties))
boolets++
return boolets
/obj/item/ammo_box/magazine/internal/cylinder/get_round(keep = 0)
rotate()
var/b = stored_ammo[1]
if(!keep)
stored_ammo[1] = null
return b
/obj/item/ammo_box/magazine/internal/cylinder/proc/rotate()
var/b = stored_ammo[1]
stored_ammo.Cut(1,2)
stored_ammo.Insert(0, b)
/obj/item/ammo_box/magazine/internal/cylinder/proc/spin()
for(var/i in 1 to rand(0, max_ammo*2))
rotate()
/obj/item/ammo_box/magazine/internal/cylinder/give_round(obj/item/ammo_casing/R, replace_spent = 0)
if(!R || (caliber && R.caliber != caliber) || (!caliber && R.type != ammo_type))
return FALSE
for(var/i in 1 to stored_ammo.len)
var/obj/item/ammo_casing/bullet = stored_ammo[i]
if(!bullet || !bullet.BB) // found a spent ammo
stored_ammo[i] = R
R.forceMove(src)
if(bullet)
bullet.forceMove(drop_location())
return TRUE
return FALSE