Skip to content

Commit

Permalink
Bandolier auto-loading (#3324)
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! -->

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

<!-- 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. -->

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:

<!-- 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 Sep 9, 2024
1 parent eacad4f commit d37c89b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion code/game/objects/items/storage/belt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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."
Expand Down
20 changes: 20 additions & 0 deletions code/modules/projectiles/boxes_magazines/_box_magazine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@
to_chat(user, "<span class='notice'>You load [num_loaded] cartridge\s into \the [src]!</span>")
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, "<span class='notice'>You load [num_loaded] cartridge\s into \the [to_load]!</span>")
return
/obj/item/ammo_box/attack_self(mob/user)
var/obj/item/ammo_casing/A = get_round()
if(!A)
Expand Down

0 comments on commit d37c89b

Please sign in to comment.