Files
Bubberstation/code/modules/projectiles/boxes_magazines/internal/_cylinder.dm
Ghom 1be27a4ffe Dunking handle_atom_del() in the trash bin. (#77339)
Whatever you do, if it warrants the use of something like
`handle_atom_del`, chances are `Exited` can do it better, as most of
these cases involve movables that shouldn't be moved out of their loc
(`Destroy` forcefully moves movables to nullspace) without calling
specific procs, and for the remaining few, `handle_atom_del` doesn't
even cover the eventuality of a movable being deleted outside the source
atom, so it's quite garbage.

Beside, I feel confident in saying `handle_atom_del()` is older than the
DCS, an echo on the workarounds done at the time.
2023-08-18 11:02:22 +00:00

61 lines
1.7 KiB
Plaintext

/obj/item/ammo_box/magazine/internal/cylinder
name = "revolver cylinder"
ammo_type = /obj/item/ammo_casing/a357
caliber = CALIBER_357
max_ammo = 7
///Here, we have to maintain the list size, to emulate a cylinder with several chambers, empty or otherwise.
/obj/item/ammo_box/magazine/internal/cylinder/remove_from_stored_ammo(atom/movable/gone)
for(var/index in 1 to length(stored_ammo))
var/obj/item/ammo_casing/bullet = stored_ammo[index]
if(gone == bullet)
stored_ammo[index] = null
update_appearance()
return
/obj/item/ammo_box/magazine/internal/cylinder/get_round()
rotate()
return stored_ammo[1]
/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/ammo_list()
var/list/no_nulls_ammo = stored_ammo.Copy()
list_clear_nulls(no_nulls_ammo)
return no_nulls_ammo
/obj/item/ammo_box/magazine/internal/cylinder/give_round(obj/item/ammo_casing/R, replace_spent = 0)
if(!R || !(caliber ? (caliber == R.caliber) : (ammo_type == R.type)))
return FALSE
for(var/i in 1 to stored_ammo.len)
var/obj/item/ammo_casing/bullet = stored_ammo[i]
if(!bullet || !bullet.loaded_projectile) // found a spent ammo
stored_ammo[i] = R
R.forceMove(src)
if(bullet)
bullet.forceMove(drop_location())
return TRUE
return FALSE
/obj/item/ammo_box/magazine/internal/cylinder/top_off(load_type, starting=FALSE)
if(starting) // nulls don't exist when we're starting off
return ..()
if(!load_type)
load_type = ammo_type
for(var/i in 1 to max_ammo)
if(!give_round(new load_type(src)))
break
update_appearance()