Skip to content

Commit

Permalink
Generic ammo boxes and printable ammo cans (#2940)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

Adds generic ammo boxes, printable in the autolathe. They can be set to
hold any ammo type by using a bullet on it, and the capacity changes
depending on the bullet type.

Also makes ammo cans autolathe printable.

Replaces a few instances of update_appearence with update_ammo_count in
ammo box code so the materials properly update.

Thanks to FalloutFalcon for the idea

## Why It's Good For The Game

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

Basically a redo of my other PR, #2868 intentwise. This PR aims to make
ammo storage more practical by adding these generic ammo boxes to
prevent having loose rounds everywhere if you don't have a compatible
ammo box with space. Ammo cans are basically just themed toolboxes, so
they're just nice to have thematically as well.

Also some bug fixes I guess, that's good.

## Changelog

:cl:
add: Generic Ammo Boxes, printable in the autolathe
add: Ammo cans are printable in the autolathe
fix: Ammo boxes sometimes not properly updating their materials
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Gristlebee authored May 27, 2024
1 parent 2e3d566 commit 01cb1c1
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 4 deletions.
2 changes: 2 additions & 0 deletions code/modules/projectiles/ammunition/_ammunition.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

var/list/bounce_sfx_override // if true, overrides the bouncing sfx from the turf to this one

var/bullet_per_box


/obj/item/ammo_casing/spent
name = "spent bullet casing"
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/ammunition/ballistic/lmg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
icon_state = "rifle-steel"
caliber = "7.12x82mm"
projectile_type = /obj/projectile/bullet/mm712x82
bullet_per_box = 100

/obj/item/ammo_casing/mm712x82/ap
name = "7.12x82mm armor-piercing bullet casing"
Expand Down
5 changes: 5 additions & 0 deletions code/modules/projectiles/ammunition/ballistic/pistol.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
icon_state = "pistol-steel"
caliber = "10mm"
projectile_type = /obj/projectile/bullet/c10mm
bullet_per_box = 50

/obj/item/ammo_casing/c10mm/surplus
name = "10mm surplus bullet casing"
Expand Down Expand Up @@ -45,6 +46,7 @@
icon_state = "pistol-brass"
caliber = "9mm"
projectile_type = /obj/projectile/bullet/c9mm
bullet_per_box = 50

/obj/item/ammo_casing/c9mm/surplus
name = "9mm surplus bullet casing"
Expand Down Expand Up @@ -84,6 +86,7 @@
icon_state = "pistol-steel"
caliber = ".45"
projectile_type = /obj/projectile/bullet/c45
bullet_per_box = 50

/obj/item/ammo_casing/c45/surplus
name = ".45 surplus bullet casing"
Expand Down Expand Up @@ -122,6 +125,7 @@
desc = "A .50 AE bullet casing."
caliber = ".50 AE"
projectile_type = /obj/projectile/bullet/a50AE
bullet_per_box = 20

/obj/item/ammo_casing/a50AE/hp
name = ".50 AE hollow point bullet casing"
Expand All @@ -134,4 +138,5 @@
desc = "A .22 LR bullet casing."
projectile_type = /obj/projectile/bullet/c22lr
caliber = "22lr"
bullet_per_box = 75

3 changes: 3 additions & 0 deletions code/modules/projectiles/ammunition/ballistic/revolver.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
caliber = ".357"
icon_state = "magnum-brass"
projectile_type = /obj/projectile/bullet/a357
bullet_per_box = 50

/obj/item/ammo_casing/a357/match
name = ".357 match bullet casing"
Expand All @@ -28,6 +29,7 @@
caliber = ".45-70"
icon_state = "magnum-brass"
projectile_type = /obj/projectile/bullet/a4570
bullet_per_box = 12

/obj/item/ammo_casing/a4570/match
name = ".45-70 match bullet casing"
Expand All @@ -53,6 +55,7 @@
desc = "A .38 Special bullet casing."
caliber = ".38"
projectile_type = /obj/projectile/bullet/c38
bullet_per_box = 50

/obj/item/ammo_casing/c38/surplus
name = ".38 surplus bullet casing"
Expand Down
9 changes: 9 additions & 0 deletions code/modules/projectiles/ammunition/ballistic/rifle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
icon_state = "rifle-brass"
caliber = "8x50mmR"
projectile_type = /obj/projectile/bullet/a8_50r
bullet_per_box = 20

/obj/item/ammo_casing/a8_50rhp
name = "8x50mmR hollow point bullet casing"
Expand All @@ -23,6 +24,7 @@
icon_state = "caseless"
caliber = "a858"
projectile_type = /obj/projectile/bullet/a858
bullet_per_box = 20

// .300 Magnum (Smile Rifle)

Expand All @@ -32,6 +34,7 @@
icon_state = "rifle-steel"
caliber = "a300"
projectile_type = /obj/projectile/bullet/a300
bullet_per_box = 20

// 5.56x39mm (M-90gl Carbine & P-16)

Expand All @@ -41,6 +44,7 @@
icon_state = "rifle-brass"
caliber = "5.56x45mm"
projectile_type = /obj/projectile/bullet/a556_45
bullet_per_box = 80

// 5.45x39mm (SKM-24v)

Expand All @@ -51,6 +55,7 @@
caliber = "5.45x39mm"
randomspread = TRUE
projectile_type = /obj/projectile/bullet/a545_39
bullet_per_box = 80

/obj/item/ammo_casing/a545_39/recycled
name = "recycled 5.45x39mm bullet casing"
Expand All @@ -67,6 +72,7 @@
icon_state = "rifle-brass"
caliber = "7.62x40mm"
projectile_type = /obj/projectile/bullet/a762_40
bullet_per_box = 80

// .300 Blackout (Polymer Survivor Rifle)

Expand All @@ -76,6 +82,7 @@
icon_state = "rifle-steel"
caliber = ".300 BLK"
projectile_type = /obj/projectile/bullet/aac_300blk
bullet_per_box = 20

/obj/item/ammo_casing/aac_300blk/recycled
name = "recycled .300 BLK bullet casing"
Expand All @@ -91,10 +98,12 @@
icon_state = "rifle-brass"
caliber = ".308"
projectile_type = /obj/projectile/bullet/a308
bullet_per_box = 20

/obj/item/ammo_casing/caseless/c299
name = ".229 Eoehoma caseless bullet casing"
desc = "A .229 Eoehoma caseless bullet casing."
icon_state = "caseless"
caliber = ".299 caseless"
projectile_type = /obj/projectile/bullet/c299
bullet_per_box = 80
1 change: 1 addition & 0 deletions code/modules/projectiles/ammunition/ballistic/shotgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
caliber = "12ga"
custom_materials = list(/datum/material/iron=4000)
projectile_type = /obj/projectile/bullet/slug
bullet_per_box = 25

bounce_sfx_override = 'sound/weapons/gun/general/bulletcasing_shotgun_bounce.ogg'

Expand Down
3 changes: 3 additions & 0 deletions code/modules/projectiles/ammunition/ballistic/smg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
icon_state = "rifle-brass"
caliber = "4.6x30mm"
projectile_type = /obj/projectile/bullet/c46x30mm
bullet_per_box = 50

/obj/item/ammo_casing/c46x30mm/ap
name = "4.6x30mm armor-piercing bullet casing"
Expand All @@ -18,6 +19,7 @@
desc = "A 4.6x30mm incendiary bullet casing."
bullet_skin = "incen"
projectile_type = /obj/projectile/bullet/incendiary/c46x30mm
bullet_per_box = 50

// 4.73x33mm caseless (Solar)

Expand All @@ -27,6 +29,7 @@
icon_state = "caseless"
caliber = "4.73x33mm caseless"
projectile_type = /obj/projectile/bullet/c47x33mm
bullet_per_box = 50

// 5.56mm HITP caseless (Pistole C)

Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/ammunition/ballistic/sniper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
icon_state = "big-steel"
caliber = ".50 BMG"
projectile_type = /obj/projectile/bullet/p50
bullet_per_box = 20

/obj/item/ammo_casing/p50/soporific
name = ".50 BMG soporific bullet casing"
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/ammunition/caseless/foam.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
custom_materials = list(/datum/material/iron = 11.25)
harmful = FALSE
var/modified = FALSE
bullet_per_box = 40

/obj/item/ammo_casing/caseless/foam_dart/update_icon_state()
. = ..()
Expand Down
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
53 changes: 53 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,53 @@
/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)
if(ammo.bullet_per_box)
max_ammo = round(ammo.bullet_per_box)
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 @@ -3006,6 +3006,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

0 comments on commit 01cb1c1

Please sign in to comment.