Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic ammo boxes and printable ammo cans #2940

Merged
merged 17 commits into from
May 27, 2024
Merged
8 changes: 4 additions & 4 deletions code/modules/projectiles/boxes_magazines/_box_magazine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
if(!start_empty)
for(var/i = 1, i <= max_ammo, i++)
stored_ammo += new ammo_type(src)
update_appearance()
update_ammo_count()

///gets a round from the magazine, if keep is TRUE the round will stay in the gun
/obj/item/ammo_box/proc/get_round(keep = FALSE)
Expand Down Expand Up @@ -107,8 +107,8 @@
if(!silent)
playsound(get_turf(attacking_box), 'sound/weapons/gun/general/mag_bullet_insert.ogg', 60, TRUE) //src is nullspaced, which means internal magazines won't properly play sound, thus we use attacking_box
num_loaded++
attacking_obj.update_appearance()
update_appearance()
attacking_box.update_ammo_count()
update_ammo_count()

if(istype(attacking_obj, /obj/item/ammo_casing))
var/obj/item/ammo_casing/casing_to_insert = attacking_obj
Expand All @@ -117,7 +117,7 @@
if(!silent)
playsound(casing_to_insert, 'sound/weapons/gun/general/mag_bullet_insert.ogg', 60, TRUE)
num_loaded++
update_appearance()
update_ammo_count()


if(num_loaded)
Expand Down
63 changes: 63 additions & 0 deletions code/modules/projectiles/boxes_magazines/generic_ammo_box.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/obj/item/ammo_box/generic
name = "generic ammo box"
desc = "A generic, unbranded box of ammo. It doesn't have great capacity, but it can hold a variety of different calibers."
max_ammo = 20
start_empty = TRUE
icon_state = "generic-ammo"
/// Does the box currently have an ammo type set?
var/ammo_set = FALSE
/// Name of the currently set ammo type
var/ammo_name

/obj/item/ammo_box/generic/update_ammo_count()
. = ..()
if(LAZYLEN(stored_ammo) == 0)
ammo_set = FALSE
ammo_type = /obj/item/ammo_casing

/obj/item/ammo_box/generic/proc/update_max_ammo(obj/item/ammo_casing/ammo)
FalloutFalcon marked this conversation as resolved.
Show resolved Hide resolved
var/caliber = ammo.caliber
if(caliber in list("9mm","10mm",".45","22lr",".357",".38","5.56mm caseless","slug"))
// handgun calibers
max_ammo = 25
else if(caliber in list("4.6x30mm","5.56x45mm","5.45x39mm","7.62x40mm",".299 caseless","7.12x82mm","pellet","lance"))
// automatic rifle calibers
max_ammo = 30
else if (caliber in list("12ga"))
// shotgun ammo
max_ammo = 20
else if (caliber in list("8x50mmR","a858","a300",".300 BLK",".308",".50 BMG"))
// bolt actions, semi-auto rifles, snipers
max_ammo = 10
else
max_ammo = 10

return

/obj/item/ammo_box/generic/attackby(obj/item/attacking_obj, mob/user, params, silent, replace_spent)
. = ..()

if(!ammo_set && istype(attacking_obj, /obj/item/ammo_casing))
var/obj/item/ammo_casing/ammo_load = attacking_obj.type
ammo_type = ammo_load
ammo_set = TRUE
ammo_name = attacking_obj.name
update_max_ammo(attacking_obj)
to_chat(user, span_notice("You set the box to hold [attacking_obj]!"))

if(istype(attacking_obj, /obj/item/pen))
if(!user.is_literate())
to_chat(user, span_notice("You scribble illegibly on the cover of [src]!"))
return
var/inputvalue = stripped_input(user, "What would you like to label the box?", "Box Labelling", "", MAX_NAME_LEN)

if(!inputvalue)
return

if(user.canUseTopic(src, BE_CLOSE))
name = "[initial(src.name)][(inputvalue ? " - '[inputvalue]'" : null)]"

/obj/item/ammo_box/generic/examine(mob/user)
. = ..()
. += span_notice("[ammo_set ? "It's set to hold [ammo_name]\s. The box can hold up to [max_ammo] rounds." : "It doesn't have an ammo type set. Use a bullet on the box to set it."]")
. += span_notice("You can use a pen on it to rename the box.")
16 changes: 16 additions & 0 deletions code/modules/research/designs/autolathe_designs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,22 @@
build_path = /obj/item/ammo_box/c556mmHITP/surplus
category = list("initial", "Security", "Ammo")

/datum/design/generic_ammo_box
name = "Generic Ammo Box"
id = "ammo-generic"
build_type = AUTOLATHE | PROTOLATHE
materials = list(/datum/material/iron = 1500)
build_path = /obj/item/ammo_box/generic
category = list("initial", "Security", "Ammo")

/datum/design/ammo_can
name = "Ammo Can"
id = "ammo-can"
build_type = AUTOLATHE | PROTOLATHE
materials = list(/datum/material/iron = 500)
build_path = /obj/item/storage/toolbox/ammo
category = list("initial", "Security", "Ammo")

/datum/design/cleaver
name = "Butcher's Cleaver"
id = "cleaver"
Expand Down
Binary file modified icons/obj/ammo.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2993,6 +2993,7 @@
#include "code\modules\projectiles\ammunition\special\syringe.dm"
#include "code\modules\projectiles\boxes_magazines\_box_magazine.dm"
#include "code\modules\projectiles\boxes_magazines\ammo_boxes.dm"
#include "code\modules\projectiles\boxes_magazines\generic_ammo_box.dm"
#include "code\modules\projectiles\boxes_magazines\external\gauss.dm"
#include "code\modules\projectiles\boxes_magazines\external\grenade.dm"
#include "code\modules\projectiles\boxes_magazines\external\lmg.dm"
Expand Down
Loading