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

fix prevent belt flare being filled by dump in action leaving no space for flare gun. #4110

Merged
merged 16 commits into from
Aug 20, 2023
2 changes: 1 addition & 1 deletion code/game/objects/items/storage/belt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@
/obj/item/storage/belt/gun/flaregun/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/storage/box/m94))
var/obj/item/storage/box/m94/M = W
dump_into(M,user)
dump_ammo_into_belt_holster(M,user)
else
return ..()

Expand Down
43 changes: 42 additions & 1 deletion code/game/objects/items/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
var/list/content_watchers //list of mobs currently seeing the storage's contents
var/storage_flags = STORAGE_FLAGS_DEFAULT
var/has_gamemode_skin = FALSE ///Whether to use map-variant skins.

/// TRUE mean this belt as an holster for a gun. this variable is used for the dump into action.

/obj/item/storage/MouseDrop(obj/over_object as obj)
if(CAN_PICKUP(usr, src))
Expand Down Expand Up @@ -697,7 +697,9 @@ W is always an item. stop_warning prevents messaging. user may be null.**/
if(ammo_dumping.flags_magazine & AMMUNITION_HANDFUL_BOX)
var/handfuls = round(ammo_dumping.current_rounds / amount_to_dump, 1) //The number of handfuls, we round up because we still want the last one that isn't full
if(ammo_dumping.current_rounds != 0)

if(contents.len < storage_slots)

to_chat(user, SPAN_NOTICE("You start refilling [src] with [ammo_dumping]."))
if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return
for(var/i = 1 to handfuls)
Expand All @@ -721,6 +723,45 @@ W is always an item. stop_warning prevents messaging. user may be null.**/
to_chat(user, SPAN_WARNING("[ammo_dumping] is empty."))
return TRUE

Huffie56 marked this conversation as resolved.
Show resolved Hide resolved
/obj/item/storage/proc/dump_ammo_into_belt_holster(obj/item/ammo_magazine/ammo_dumping, mob/user, amount_to_dump = 5) //amount_to_dump should never actually need to be used as default value
if(user.action_busy)
return

if(ammo_dumping.flags_magazine & AMMUNITION_CANNOT_REMOVE_BULLETS)
to_chat(user, SPAN_WARNING("You can't remove ammo from \the [ammo_dumping]!"))
return

if(ammo_dumping.flags_magazine & AMMUNITION_HANDFUL_BOX)
var/handfuls = round(ammo_dumping.current_rounds / amount_to_dump, 1) //The number of handfuls, we round up because we still want the last one that isn't full
if(ammo_dumping.current_rounds != 0)

if(contents.len < (storage_slots - 1))

to_chat(user, SPAN_NOTICE("You start refilling [src] with [ammo_dumping]."))
if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC)) return
for(var/i = 1 to handfuls)
if(contents.len < (storage_slots - 1))
//Hijacked from /obj/item/ammo_magazine/proc/create_handful because it had to be handled differently
//All this because shell types are instances and not their own objects :)

var/obj/item/ammo_magazine/handful/new_handful = new /obj/item/ammo_magazine/handful
var/transferred_handfuls = min(ammo_dumping.current_rounds, amount_to_dump)
new_handful.generate_handful(ammo_dumping.default_ammo, ammo_dumping.caliber, amount_to_dump, transferred_handfuls, ammo_dumping.gun_type)
ammo_dumping.current_rounds -= transferred_handfuls
handle_item_insertion(new_handful, TRUE,user)
update_icon(-transferred_handfuls)
else
break
playsound(user.loc, "rustle", 15, TRUE, 6)
ammo_dumping.update_icon()
else
to_chat(user, SPAN_WARNING("[src] is full."))
else
to_chat(user, SPAN_WARNING("[ammo_dumping] is empty."))
return TRUE



/obj/item/storage/proc/dump_into(obj/item/storage/M, mob/user)
if(user.action_busy)
return
Expand Down