Skip to content

Commit

Permalink
fix the issue seem ok to me after test
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien committed Aug 7, 2023
1 parent 8aebcba commit 56261a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 43 deletions.
3 changes: 2 additions & 1 deletion code/game/objects/items/storage/belt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,7 @@
name = "\improper M276 pattern M82F flare gun holster rig"
desc = "The M276 is the standard load-bearing equipment of the USCM. It consists of a modular belt with various clips. This version is for the M82F flare gun."
storage_slots = 17
storage_holster = TRUE
max_storage_space = 20
icon_state = "m82f_holster"
item_state = "s_marinebelt"
Expand All @@ -1476,7 +1477,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_ammo_into_belt_holster(M,user)
dump_into(M,user)
else
return ..()

Expand Down
49 changes: 7 additions & 42 deletions 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.
var/storage_holster = FALSE

/obj/item/storage/MouseDrop(obj/over_object as obj)
if(CAN_PICKUP(usr, src))
Expand Down Expand Up @@ -697,9 +697,7 @@ 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 @@ -723,46 +721,11 @@ W is always an item. stop_warning prevents messaging. user may be null.**/
to_chat(user, SPAN_WARNING("[ammo_dumping] is empty."))
return TRUE

/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(storage_holster == TRUE && contents.len >= (storage_slots-1))
to_chat(user, SPAN_WARNING("[src] is full."))
return FALSE

if(user.action_busy)
return

Expand All @@ -777,6 +740,8 @@ W is always an item. stop_warning prevents messaging. user may be null.**/
if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC))
return
for(var/obj/item/I in M)
if(storage_holster == TRUE && contents.len >= (storage_slots-1))
break
if(!has_room(I))
break
M.remove_from_storage(I)
Expand Down

0 comments on commit 56261a6

Please sign in to comment.