From d37c89bca9e8bb810569a0cf97522b1283ea8b8d Mon Sep 17 00:00:00 2001
From: Gristlebee <56049844+Gristlebee@users.noreply.github.com>
Date: Mon, 9 Sep 2024 13:37:08 -0700
Subject: [PATCH] Bandolier auto-loading (#3324)
## About The Pull Request
Bandoliers can now be loaded similarly to a magazine by using an ammo
box on it.
Adds an examine hint for this behavior.
## Why It's Good For The Game
QOL change, Streamlines loading the bandolier so you don't need to click
at minimum 80 times to manually hand load 40 rounds into your bandolier.
## Changelog
:cl:
add: Bandolier auto-loading and examine hint
/:cl:
---
code/game/objects/items/storage/belt.dm | 6 +++++-
.../boxes_magazines/_box_magazine.dm | 20 +++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm
index 0455a9366557..22f64d0a1a6c 100644
--- a/code/game/objects/items/storage/belt.dm
+++ b/code/game/objects/items/storage/belt.dm
@@ -681,7 +681,7 @@
/obj/item/storage/belt/bandolier
name = "bandolier"
- desc = "A bandolier for holding ammunition. Does not hold magazines"
+ desc = "A bandolier for holding ammunition. Does not hold magazines."
icon_state = "bandolier"
item_state = "bandolier"
@@ -695,6 +695,10 @@
/obj/item/ammo_casing
))
+/obj/item/storage/belt/bandolier/examine(mob/user)
+ . = ..()
+ . += span_notice("The bandolier can be directly loaded by clicking on it with an ammo box.")
+
/obj/item/storage/belt/fannypack
name = "fannypack"
desc = "A dorky fannypack for keeping small items in."
diff --git a/code/modules/projectiles/boxes_magazines/_box_magazine.dm b/code/modules/projectiles/boxes_magazines/_box_magazine.dm
index 3b1bdbc6eb1c..7f92dfad16a6 100644
--- a/code/modules/projectiles/boxes_magazines/_box_magazine.dm
+++ b/code/modules/projectiles/boxes_magazines/_box_magazine.dm
@@ -125,6 +125,26 @@
to_chat(user, "You load [num_loaded] cartridge\s into \the [src]!")
return num_loaded
+/obj/item/ammo_box/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
+ . = ..()
+ var/num_loaded = 0
+ var/obj/item/storage/belt/bandolier/to_load
+ if(istype(target,/obj/item/storage/belt/bandolier))
+ to_load = target
+ var/datum/component/storage/storage_to_load = to_load.GetComponent(/datum/component/storage)
+ for(var/obj/item/ammo_casing/casing_to_insert in stored_ammo)
+ if(!((to_load.contents.len >= storage_to_load.get_max_volume()) || do_after(user, 0.5 SECONDS, src)))
+ break
+ if(!storage_to_load.can_be_inserted(casing_to_insert,TRUE,user))
+ break
+ storage_to_load.handle_item_insertion(casing_to_insert,TRUE,user)
+ stored_ammo -= casing_to_insert
+ playsound(get_turf(src), 'sound/weapons/gun/general/mag_bullet_insert.ogg', 60, TRUE)
+ num_loaded++
+ update_ammo_count()
+ if(num_loaded)
+ to_chat(user, "You load [num_loaded] cartridge\s into \the [to_load]!")
+ return
/obj/item/ammo_box/attack_self(mob/user)
var/obj/item/ammo_casing/A = get_round()
if(!A)