From 57cd724dadaf93c1503a62e2452f7a4d624be521 Mon Sep 17 00:00:00 2001 From: IndusRobot Date: Fri, 14 Jun 2024 14:19:21 -0600 Subject: [PATCH] Fixes borgs duplicating ammunition with the munition clamp upgrade (#2657) --- .../munitions/ship_weapons/_ship_weapon.dm | 16 ++++++++++++++++ .../ship_weapons/ballistic_weapons/deck_guns.dm | 15 ++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm b/nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm index 314d22500b7..dabaa7495f4 100644 --- a/nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm +++ b/nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm @@ -267,6 +267,9 @@ to_chat(user, "You start to load [A] into [src].") loading = TRUE if(do_after(user, load_delay, target = src)) + if ( !user_has_payload( A, user ) ) + loading = FALSE + return FALSE if(mag_load_sound) playsound(src, mag_load_sound, 100, 1) @@ -291,6 +294,19 @@ return FALSE +/obj/machinery/ship_weapon/proc/user_has_payload(obj/item/A, mob/user) // Searches humans and borgs for gunpowder before depositing + if ( !user ) + return FALSE + + // Prove you're not human + if ( istype( user, /mob/living/silicon/robot ) ) + // Give me your hands + var/obj/item/borg/apparatus/munitions/hands = locate( /obj/item/borg/apparatus/munitions ) in user.contents + if ( !hands?.stored ) + return FALSE + + return TRUE + /** * If we're not magazine-fed, eject round(s) from the weapon. * Transitions to STATE_NOTLOADED from higher states. diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/deck_guns.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/deck_guns.dm index e21a649bc86..9be91001f7e 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/deck_guns.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/deck_guns.dm @@ -328,7 +328,7 @@ if(locate(/obj/machinery/deck_turret/autoelevator) in orange(2, src)) temp /= 2 if(do_after(user, temp, target = src)) - if(user) + if(user_has_payload(A, user)) to_chat(user, "You load [A] into [src].") bag = A bag.forceMove(src) @@ -336,6 +336,19 @@ playsound(src.loc, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) loading = FALSE +/obj/machinery/deck_turret/powder_gate/proc/user_has_payload(obj/item/A, mob/user) // Searches humans and borgs for gunpowder before depositing + if ( !user ) + return FALSE + + // Prove you're not human + if ( istype( user, /mob/living/silicon/robot ) ) + // Give me your hands + var/obj/item/borg/apparatus/munitions/hands = locate( /obj/item/borg/apparatus/munitions ) in user.contents + if ( !hands?.stored ) + return FALSE + + return TRUE + /obj/item/powder_bag name = "gunpowder bag" desc = "A highly flammable bag of gunpowder which is used in naval artillery systems."