diff --git a/code/game/machinery/crafting_station.dm b/code/game/machinery/crafting_station.dm index 133182c523f..06aa50b9401 100644 --- a/code/game/machinery/crafting_station.dm +++ b/code/game/machinery/crafting_station.dm @@ -1,3 +1,6 @@ +#define WORK "work" +#define DONE "done" + /obj/machinery/craftingstation name = "crafting station" desc = "Makeshift fabrication station for home-made munitions and components of firearms and armor." @@ -6,27 +9,21 @@ circuit = /obj/item/electronics/circuitboard/crafting_station density = TRUE anchored = TRUE - layer = BELOW_OBJ_LAYER - - var/is_working = FALSE - var/storage_capacity = 20 // How many of each resource could be stored. Multiplied by matter bin rating - var/productivity_bonus = 2 // Sum of micro-laser and manipulator ratings, increases effectiveness of ammo crafting - var/list/materials_stored = list() - var/list/materials_compatible = list (MATERIAL_PLASTEEL, MATERIAL_STEEL, MATERIAL_PLASTIC, MATERIAL_WOOD, MATERIAL_CARDBOARD, MATERIAL_PLASMA) - var/list/materials_armorpart = list(MATERIAL_STEEL = 10, MATERIAL_PLASTIC = 10) - var/list/materials_ammo = list(MATERIAL_STEEL = 10, MATERIAL_CARDBOARD = 1) - var/list/materials_rocket = list(MATERIAL_PLASMA = 5, MATERIAL_PLASTIC = 5, MATERIAL_PLASTEEL = 5, MATERIAL_STEEL = 10) - var/list/materials_lbarrel = list(MATERIAL_PLASTEEL = 8) - var/list/materials_sbarrel = list(MATERIAL_PLASTEEL = 4) - var/list/materials_lmechanism = list(MATERIAL_PLASTEEL = 10) - var/list/materials_smechanism = list(MATERIAL_PLASTEEL = 5) - var/list/materials_lbarrel_steel = list(MATERIAL_STEEL = 8) - var/list/materials_sbarrel_steel = list(MATERIAL_STEEL = 4) - var/list/materials_lmechanism_steel = list(MATERIAL_STEEL = 10) - var/list/materials_smechanism_steel = list(MATERIAL_STEEL = 5) - var/list/materials_hpart = list(MATERIAL_PLASTEEL = 16) - var/list/materials_pgrip = list(MATERIAL_PLASTIC = 6) - var/list/materials_wgrip = list(MATERIAL_WOOD = 6) + layer = 2.8 + + var/power_cost = 250 + + var/working = FALSE + var/start_working + var/work_time = 20 SECONDS + var/mat_efficiency = 15 + var/storage_capacity = 40 + var/list/stored_material = list() + var/list/accepted_material = list (MATERIAL_PLASTEEL, MATERIAL_STEEL, MATERIAL_PLASTIC, MATERIAL_WOOD, MATERIAL_CARDBOARD, MATERIAL_PLASMA) + var/list/needed_material_gunpart = list(MATERIAL_PLASTEEL = 5) + var/list/needed_material_armorpart = list(MATERIAL_STEEL = 20, MATERIAL_PLASTIC = 20, MATERIAL_WOOD = 20,MATERIAL_CARDBOARD = 20) + var/list/needed_material_ammo = list(MATERIAL_STEEL = 10, MATERIAL_CARDBOARD = 5) + var/list/needed_material_rocket = list(MATERIAL_PLASMA = 5, MATERIAL_PLASTIC = 5, MATERIAL_PLASTEEL = 5, MATERIAL_STEEL = 10) // A vis_contents hack for materials loading animation. var/tmp/obj/effect/flick_light_overlay/image_load @@ -38,27 +35,28 @@ /obj/machinery/craftingstation/examine(user) . = ..() - var/list/craft_options = list( - "ammunition" = materials_ammo, - "RPG shell" = materials_rocket, - "armor parts" = materials_armorpart, - "barrels" = "4 plasteel for small; 8 plasteel for large; 16 plasteel for heavy", - "mechanisms" ="5 plasteel for small; 10 plasteel for large; 16 plasteel for heavy", - "cheap barrels" = "4 steel for small; 8 steel for large", - "cheap mechanisms" = "5 steel for small; 10 steel for large", - "grips" = "6 plastic or 6 wood") - - for(var/i in craft_options) - var/list/required_materials = craft_options[i] - var/list/requirements = list() - for(var/material in required_materials) - requirements += "[required_materials[material]] [material]" - to_chat(user, SPAN_NOTICE("Materials required to craft [i]: [english_list(requirements)].")) + var/list/matter_count_need_ammo = list() + var/list/matter_count_need_gunpart = list() + var/list/matter_count_need_armorpart = list() + var/list/matter_count_need_rocket = list() + + for(var/_material in needed_material_ammo) + matter_count_need_ammo += "[needed_material_ammo[_material]] [_material]" + + for(var/_material in needed_material_gunpart) + matter_count_need_gunpart += "[needed_material_ammo[_material]] [_material]" + + for(var/_material in needed_material_armorpart) + matter_count_need_armorpart += "[needed_material_ammo[_material]] [_material]" + + for(var/_material in needed_material_rocket) + matter_count_need_rocket += "[needed_material_rocket[_material]] [_material]" var/list/matter_count = list() - for(var/material in materials_stored) - matter_count += " [materials_stored[material]] [material]" - to_chat(user, SPAN_NOTICE("It contains: [english_list(matter_count)].")) + for(var/_material in stored_material) + matter_count += " [stored_material[_material]] [_material]" + + to_chat(user, SPAN_NOTICE("Materials required to craft ammunition: [english_list(matter_count_need_ammo)].\nMaterials required to craft gun parts: 5 [english_list(matter_count_need_gunpart)] \nMaterials required to craft armor parts: [english_list(matter_count_need_armorpart)] \n Materials required to craft RPG shell: [english_list(matter_count_need_rocket)].\nIt contains: [english_list(matter_count)].")) /obj/machinery/craftingstation/attackby(obj/item/I, mob/user) @@ -68,259 +66,559 @@ if(default_deconstruction(I, user)) return - if(istype(I, /obj/item/stack/material)) + if(istype(I, /obj/item/stack)) eat(user, I) return . = ..() -/obj/machinery/craftingstation/attack_hand(mob/living/user) - if(!istype(user) || is_working || stat & NOPOWER || !in_range(src, user)) +/obj/machinery/craftingstation/attack_hand(mob/user as mob) + if(working) + to_chat(user, SPAN_NOTICE("You are already crafting something.")) return - // Only one user can interact with the machine at the same time - // This is always true, but we need to wait for that proc's return - if(!interface(user)) - is_working = FALSE - icon_state = "craft" - flick("craft_done", src) - - -/obj/machinery/craftingstation/proc/interface(mob/living/user) - is_working = TRUE - icon_state = "craft_ready" - flick("craft_warmup", src) - - var/list/required_resources = list() - var/list/items_to_spawn = list() - - var/choice = input(user, "What do you want to craft?") as null|anything in list("Ammunition","RPG shell","Gun parts","Armor parts") - switch(choice) - if("Ammunition") - required_resources = materials_ammo - - if("RPG shell") - required_resources = materials_rocket - items_to_spawn = list("" = /obj/item/ammo_casing/rocket/scrap/prespawned) - - if("Gun parts") - choice = input(user, "Which type of part do you want to craft?") as null|anything in list("Small parts", "Large parts", "Heavy parts", "Cheap parts", "Grips") - switch(choice) - if("Small parts") - choice = input(user, "Which type of part do you want to craft?") as null|anything in list("Barrels", "Mechanisms") - switch(choice) - if("Barrels") - required_resources = materials_sbarrel - choice = input(user) as null|anything in list(".35 barrel", ".40 barrel") - switch(choice) - if(".35 barrel") - items_to_spawn = list("" = /obj/item/part/gun/barrel/pistol) - if(".40 barrel") - items_to_spawn = list("" = /obj/item/part/gun/barrel/magnum) - if("Mechanisms") - required_resources = materials_smechanism - choice = input(user) as null|anything in list("Pistol mechanism", "Revolver mechanism", "SMG mechanism") - switch(choice) - if("Pistol mechanism") - items_to_spawn = list("" = /obj/item/part/gun/mechanism/pistol) - if("Revolver mechanism") - items_to_spawn = list("" = /obj/item/part/gun/mechanism/revolver) - if("SMG mechanism") - items_to_spawn = list("" = /obj/item/part/gun/mechanism/smg) - - if("Large parts") - choice = input(user, "Which type of part do you want to craft?") as null|anything in list("Barrels", "Mechanisms") - switch(choice) - if("Barrels") - required_resources = materials_lbarrel - choice = input(user) as null|anything in list(".20 barrel", ".25 barrel", ".30 barrel", "Shotgun barrel") - switch(choice) - if(".20 barrel") - items_to_spawn = list("" = /obj/item/part/gun/barrel/srifle) - if(".25 barrel") - items_to_spawn = list("" = /obj/item/part/gun/barrel/clrifle) - if(".30 barrel") - items_to_spawn = list("" = /obj/item/part/gun/barrel/lrifle) - if("Shotgun barrel") - items_to_spawn = list("" = /obj/item/part/gun/barrel/shotgun) - if("Mechanisms") - required_resources = materials_lmechanism - choice = input(user) as null|anything in list("Self-loading mechanism", "Shotgun mechanism") - switch(choice) - if("Self-loading mechanism") - items_to_spawn = list("" = /obj/item/part/gun/mechanism/autorifle) - if("Shotgun mechanism") - items_to_spawn = list("" = /obj/item/part/gun/mechanism/shotgun) - - if("Heavy parts") - required_resources = materials_hpart - choice = input(user, "Which type of part do you want to craft?") as null|anything in list("Anti-materiel barrel", "Machinegun mechanism") - switch(choice) - if("Anti-materiel barrel") - items_to_spawn = list("" = /obj/item/part/gun/barrel/antim) - if("Machinegun mechanism") - items_to_spawn = list("" = /obj/item/part/gun/mechanism/machinegun) - - if("Cheap parts") - choice = input(user, "Which type of part do you want to craft?") as null|anything in list("Barrels", "Mechanisms") - switch(choice) - if("Barrels") - choice = input(user) as null|anything in list(".35 barrel", ".40 barrel", ".20 barrel", ".25 barrel", ".30 barrel", "Shotgun barrel") - switch(choice) - if(".35 barrel") - required_resources = materials_sbarrel_steel - items_to_spawn = list("" = /obj/item/part/gun/barrel/pistol/steel) - if(".40 barrel") - required_resources = materials_sbarrel_steel - items_to_spawn = list("" = /obj/item/part/gun/barrel/magnum/steel) - if(".20 barrel") - required_resources = materials_lbarrel_steel - items_to_spawn = list("" = /obj/item/part/gun/barrel/srifle/steel) - if(".25 barrel") - required_resources = materials_lbarrel_steel - items_to_spawn = list("" = /obj/item/part/gun/barrel/clrifle/steel) - if(".30 barrel") - required_resources = materials_lbarrel_steel - items_to_spawn = list("" = /obj/item/part/gun/barrel/lrifle/steel) - if("Shotgun barrel") - required_resources = materials_lbarrel_steel - items_to_spawn = list("" = /obj/item/part/gun/barrel/shotgun/steel) - if("Mechanisms") - choice = input(user) as null|anything in list("Pistol mechanism", "Revolver mechanism", "SMG mechanism", "Manual-action mechanism", "Self-loading mechanism", "Shotgun mechanism") - switch(choice) - if("Pistol mechanism") - required_resources = materials_smechanism_steel - items_to_spawn = list("" = /obj/item/part/gun/mechanism/pistol/steel) - if("Revolver mechanism") - required_resources = materials_smechanism_steel - items_to_spawn = list("" = /obj/item/part/gun/mechanism/revolver/steel) - if("SMG mechanism") - required_resources = materials_smechanism_steel - items_to_spawn = list("" = /obj/item/part/gun/mechanism/smg/steel) - if("Manual-action mechanism") - required_resources = materials_lmechanism_steel - items_to_spawn = list("" = /obj/item/part/gun/mechanism/boltgun) - if("Self-loading mechanism") - required_resources = materials_lmechanism_steel - items_to_spawn = list("" = /obj/item/part/gun/mechanism/autorifle/steel) - if("Shotgun mechanism") - required_resources = materials_lmechanism_steel - items_to_spawn = list("" = /obj/item/part/gun/mechanism/shotgun/steel) - - if("Grips") - choice = input(user) as null|anything in list("Plastic grip", "Rubber grip", "Excelsior grip", "Bakelite grip", "Wooden grip") - switch(choice) - if("Plastic grip") - required_resources = materials_pgrip - items_to_spawn = list("" = /obj/item/part/gun/grip/black) - if("Rubber grip") - required_resources = materials_pgrip - items_to_spawn = list("" = /obj/item/part/gun/grip/rubber) - if("Excelsior grip") - required_resources = materials_pgrip - items_to_spawn = list("" = /obj/item/part/gun/grip/excel) - if("Bakelite grip") - required_resources = materials_pgrip - items_to_spawn = list("" = /obj/item/part/gun/grip/serb) - if("Wooden grip") - required_resources = materials_wgrip - items_to_spawn = list("" = /obj/item/part/gun/grip/wood) - - if("Armor parts") - required_resources = materials_armorpart - items_to_spawn = list("" = /obj/item/part/armor) + var/cog_stat = user.stats.getStat(STAT_COG) + + var/list/options = list( + ".20 Rifle ammunition" = "srifle", + ".25 Caseless Rifle ammunition" = "clrifle", + ".30 Rifle ammunition" = "lrifle", + ".35 Auto ammunition" = "pistol", + ".40 Magnum ammunition" = "magnum", + ".50 Shotgun Buckshot ammunition" = "shot", + ".50 Shotgun Beanbag ammunition" = "bean", + ".50 Shotgun Slug ammunition" = "slug", + ".60 Anti-Material ammunition" = "antim", + "RPG shell" = "rocket", + "Gun parts" = "gunpart", + "Armor parts"= "armorpart", + ) + + var/choice = input(user,"What do you want to craft?") as null|anything in options + if(choice == null) + return + var/produce_type = options[choice] + + switch(produce_type) + if("pistol") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("magnum") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("srifle") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("clrifle") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("lrifle") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("shot") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("bean") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("slug") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with")) + return + if("antim") + for(var/material in needed_material_ammo) + var/amount = needed_material_ammo[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("rocket") + for(var/material in needed_material_rocket) + var/amount = needed_material_rocket[material] + if(amount > stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + if("gunpart") + if(stored_material[MATERIAL_PLASTEEL] < needed_material_gunpart[MATERIAL_PLASTEEL]) + to_chat(user, SPAN_NOTICE("You do not have enough plasteel to craft gun part.")) + return + if("armorpart") + for(var/material in needed_material_armorpart) + var/amount = needed_material_armorpart[material] + if(amount>stored_material[material]) + to_chat(user, SPAN_NOTICE("You don't have enough [material] to work with.")) + return + + flick("[initial(icon_state)]_warmup", src) + working = TRUE + START_PROCESSING(SSmachines, src) + if(do_after(user, work_time, src)) + STOP_PROCESSING(SSmachines, src) + working = FALSE + flick("[initial(icon_state)]_done", src) + icon_state = "[initial(icon_state)]" + update_icon() + else + STOP_PROCESSING(SSmachines, src) + working = FALSE + flick("[initial(icon_state)]_done", src) + icon_state = "[initial(icon_state)]" + update_icon() + return + + + var/dice_roll = (rand(0,20) * (1 + cog_stat / mat_efficiency)) + + if(user.stats.getPerk(/datum/perk/oddity/gunsmith)) + dice_roll = dice_roll * 2 + switch(produce_type)//God forgive me + if("pistol") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + spawn_pistol(dice_roll,user) + if("magnum") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + + spawn_magnum(dice_roll,user) + if("srifle") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + + spawn_rifle(dice_roll,user,1) + if("clrifle") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + + spawn_rifle(dice_roll,user,2) + if("lrifle") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + + spawn_rifle(dice_roll,user,3) + if("antim") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + + spawn_antim(dice_roll,user) + if("rocket") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + spawn_rocket(dice_roll,user) + if("shot") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + + spawn_shotgun(dice_roll,user,1) + if("bean") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + + spawn_shotgun(dice_roll,user,2) + if("slug") + for(var/_material in needed_material_ammo) + stored_material[_material] -= needed_material_ammo[_material] + + spawn_shotgun(dice_roll,user,3) + if("gunpart") + for(var/_material in needed_material_gunpart) + stored_material[_material] -= needed_material_gunpart[_material] + + spawn_gunpart(dice_roll,user) + if("armorpart") + for(var/_material in needed_material_armorpart) + stored_material[_material] -= needed_material_armorpart[_material] + + spawn_armorpart(dice_roll,user) + + if(choice) + user.visible_message("[user] finishes trying to craft some [choice] using [src]") + else + to_chat(user, "You reconsider the path of craftsmanship.") + +//////////////////////////////////////////////////////////////////////////// + +/obj/machinery/craftingstation/proc/spawn_pistol(dice = 0, mob/user) //Shazbot- I know there is probably a better way to do this, but this is easier to code + + var/boxxes = 0 + var/piles = 0 + var/mags = 0 + + switch(dice) + if(-99 to 10) //if someone gets less than -99, they deserve the ammo + piles = 1 + if(10 to 20) + mags = 1 + if(20 to 30) + boxxes = 1 + mags = 1 + if(30 to 40) + boxxes = 1 + mags = 2 + if(40 to 50) + piles = 1 + boxxes = 2 + mags = 1 else - return + boxxes = 3+ round(dice/10-5,1) //rich get richer + + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/pistol/scrap/prespawned(get_turf(src)) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/pistol/scrap(get_turf(src)) + if(mags) + for(var/j = 1 to mags) + if(prob(50)) + new /obj/item/ammo_magazine/pistol/scrap(get_turf(src)) + else + new /obj/item/ammo_magazine/smg/scrap(get_turf(src)) + +////////////////////////////////////////////////////////////////////////////////////// + +/obj/machinery/craftingstation/proc/spawn_magnum(dice = 0, mob/user) + + var/boxxes = 0 + var/piles = 0 + var/mags = 0 + + switch(dice) + if(-99 to 8) + piles = 2 + if(8 to 16) + piles = 2 + mags = 1 + if(16 to 24) + boxxes = 1 + if(24 to 32) + boxxes = 1 + mags = 1 + if(32 to 40) + piles = 2 + boxxes = 1 + mags = 1 + if(40 to 48) + boxxes = 1 + mags = 3 + else + boxxes = 3 + round(dice/10-5,1) + + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/magnum/scrap/prespawned(get_turf(src)) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/magnum/scrap(get_turf(src)) + if(mags) + for(var/j = 1 to mags) + if(prob(50)) + new /obj/item/ammo_magazine/magnum/scrap(get_turf(src)) + else + new /obj/item/ammo_magazine/msmg/scrap(get_turf(src)) + +////////////////////////////////////////////////////////////////////////////////////// + +/obj/machinery/craftingstation/proc/spawn_rifle(dice = 0, mob/user,rifle=1) //All rifles use same spawning stats + + var/boxxes = 0 + var/piles = 0 + var/mags = 0 + + switch(dice) + if(-99 to 6) //if someone gets less than -99, they deserve the ammo + piles = 1 + if(6 to 12) + piles = 2 + if(12 to 18) + piles = 1 + mags = 1 + if(18 to 24) + piles = 2 + mags = 1 + if(24 to 30) + boxxes = 1 + if(30 to 42) + boxxes = 1 + mags = 1 + if(42 to 48) + boxxes = 1 + piles = 2 + mags = 1 + else + boxxes = 2 + round(dice/10-5,1) + + if(rifle == 1) //srifle + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/srifle/scrap/prespawned(get_turf(src)) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/srifle_small/scrap(get_turf(src)) + if(mags) + for(var/j = 1 to mags) + new /obj/item/ammo_magazine/srifle/scrap(get_turf(src)) + + if(rifle == 2) //clrifle + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/clrifle/scrap/prespawned(get_turf(src)) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/clrifle_small/scrap(get_turf(src)) + if(mags) + for(var/j = 1 to mags) + new /obj/item/ammo_magazine/ihclrifle/scrap(get_turf(src)) + + if(rifle == 3) //lrifle + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/lrifle/scrap/prespawned(get_turf(src)) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/lrifle_small/scrap(get_turf(src)) + if(mags) + for(var/j = 1 to mags) + new /obj/item/ammo_magazine/lrifle/scrap(get_turf(src)) +////////////////////////////////////////////////////////////////////////////////////// + +/obj/machinery/craftingstation/proc/spawn_antim(dice = 0, mob/user) //Shazbot- I know there is probably a better way to do this, but this is easier to code + + var/boxxes = 0 + var/piles = 0 + + switch(dice) + if(-99 to 10) //if someone gets less than -99, they deserve the ammo + piles = 1 + if(10 to 20) + piles = 2 + if(20 to 30) + piles = 3 + if(30 to 40) + piles = 4 + if(40 to 50) + piles = 5 + else + boxxes = 1 + piles = round(dice/10-6,1) - for(var/i in required_resources) - if(required_resources[i] > materials_stored[i]) - to_chat(user, SPAN_NOTICE("Not enough materials.")) - return + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/antim/scrap/prespawned(get_turf(src)) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/antim/scrap(get_turf(src)) - if(!items_to_spawn.len) - items_to_spawn = make_scrap_ammo(user, src, productivity_bonus) +////////////////////////////////////////////////////////////////////////////////////// - if(!items_to_spawn || !items_to_spawn.len) - return +/obj/machinery/craftingstation/proc/spawn_shotgun(dice = 0, mob/user,shotgun=1) //All rifles use same spawning stats - update_use_power(ACTIVE_POWER_USE) - icon_state = "craft_[pick("cut", "points", "square")]" + var/piles = 0 - if(do_mob(user, src, 5 SECONDS)) - var/tampering_detected - for(var/i in required_resources) - if(required_resources[i] == materials_stored[i]) - materials_stored.Remove(i) - else if(required_resources[i] < materials_stored[i]) - materials_stored[i] -= required_resources[i] - else // Materials pulled out during make_scrap_ammo() - to_chat(user, SPAN_WARNING("Nice try, but you only wasted some materials.")) - tampering_detected = TRUE - break + switch(dice) + if(-99 to 0) //if someone gets less than -99, they deserve the ammo + piles = 1 + else + piles = 1 + round(dice/7-1,1) //We can use math here because it's just piles + + if(shotgun==1) //shot + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/shotgun/pellet/scrap/prespawned(get_turf(src)) + + if(shotgun==2) //bean + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/shotgun/beanbag/scrap/prespawned(get_turf(src)) + + if(shotgun==3) //slug + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/shotgun/scrap/prespawned(get_turf(src)) + +////////////////////////////////////////////////////////////////////////////////////////////// + +/obj/machinery/craftingstation/proc/spawn_rocket(dice = 0, mob/user) //All rifles use same spawning stats + + var/piles + + switch(dice) + if(-99 to 20) + piles = 1 + if(20 to 50) + piles = 2 + + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/rocket/scrap/prespawned(user.loc) + +////////////////////////////////////////////////////////////////////////////////////////////// +/obj/machinery/craftingstation/proc/spawn_gunpart(dice = 0, mob/user) + + var/parts = 0 + + switch(dice) + if(-99 to 5) //crafting gunparts is difficult task, unlike with ammo, player can fail it completely + parts = 0 + to_chat(user, SPAN_WARNING("Every step of the way you just made things worse and worse. You wasted all the materials.")) + if(5 to 20) + parts = 1 + if(20 to 35) + parts = 2 + if(35 to 50) + parts = 3 + else + parts = 4 - if(!tampering_detected) - for(var/i in items_to_spawn) - var/item_type = items_to_spawn[i] - new item_type(loc) + for(var/j = 1 to parts) + new /obj/item/part/gun(get_turf(src)) - update_use_power(IDLE_POWER_USE) +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/obj/machinery/craftingstation/proc/eat(mob/living/carbon/user, obj/item/stack/material/M) - if(stat || user.stat || !Adjacent(user) || !M.matter) - return +/obj/machinery/craftingstation/proc/spawn_armorpart(dice = 0, mob/user) + var/parts = 0 - var/materials_used = 0 - var/material_type = M.default_type + switch(dice) + if(-99 to 10) //crafting armorparts is easier + parts = 1 + if(10 to 25) + parts = 2 + if(25 to 40) + parts = 3 + else + parts = 4 - if(!(material_type in materials_compatible)) - to_chat(user, SPAN_WARNING("[src] can not hold [material_type].")) - return + for(var/j = 1 to parts) + new /obj/item/part/armor(get_turf(src)) - if(materials_stored[material_type] >= storage_capacity) - to_chat(user, SPAN_WARNING("The [src] is full of [material_type].")) - return +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/obj/machinery/craftingstation/proc/eat(mob/living/user, obj/item/eating) - if(materials_stored[material_type] + M.amount > storage_capacity) - materials_used = storage_capacity - materials_stored[material_type] + if(!eating && istype(user)) + eating = user.get_active_hand() + + if(!istype(eating)) + return FALSE + + if(stat) + return FALSE + + if(!Adjacent(user) && !Adjacent(eating)) + return FALSE + + if(is_robot_module(eating)) + return FALSE + + if(!istype(eating, /obj/item/stack/material)) + to_chat(user, SPAN_WARNING("[src] does not support this type of recycling.")) + return FALSE + + if(!length(eating.get_matter())) + to_chat(user, SPAN_WARNING("\The [eating] does not contain significant amounts of useful materials and cannot be accepted.")) + return FALSE + + var/total_used = 0 // Amount of material used. + var/obj/item/stack/material/stack = eating + var/material = stack.default_type + + if(!(material in accepted_material)) + to_chat(user, SPAN_WARNING("[src] does not support [material] recycle.")) + return FALSE + + if(stored_material[material] >= storage_capacity) + to_chat(user, SPAN_WARNING("The [src] is full of [material].")) + return FALSE + + if(stored_material[material] + stack.amount > storage_capacity) + total_used = storage_capacity - stored_material[material] else - materials_used = M.amount + total_used = stack.amount - materials_stored[material_type] += materials_used + stored_material[material] += total_used - if(!M.use(materials_used)) - qdel(M) + if(!stack.use(total_used)) + qdel(stack) - to_chat(user, SPAN_NOTICE("You add [materials_used] of [M]\s to \the [src].")) + to_chat(user, SPAN_NOTICE("You add [total_used] of [stack]\s to \the [src].")) /obj/machinery/craftingstation/power_change() ..() if(stat & NOPOWER) - icon_state = "craft_off" - else - icon_state = "craft" - + working = FALSE + icon_state = "[initial(icon_state)]_off" + update_icon() + +/obj/machinery/craftingstation/Process() + if(working) + use_power(power_cost) + var/pick_string = list( "_cut" , "_points", "_square") + pick_string = pick(pick_string) + flick("[initial(icon_state)][pick_string]", src) + icon_state = "[initial(icon_state)][pick_string]" + update_icon() /obj/machinery/craftingstation/RefreshParts() - productivity_bonus = 0 - for(var/obj/item/stock_parts/i in component_parts) - if(istype(i, /obj/item/stock_parts/matter_bin)) - storage_capacity = 20 * i.rating - else - productivity_bonus += i.rating + ..() + var/mb_rating = 0 + for(var/obj/item/stock_parts/matter_bin/MB in component_parts) + mb_rating += MB.rating + + storage_capacity = round(initial(storage_capacity) + 10*(mb_rating - 1)) + var/man_rating = 0 + for(var/obj/item/stock_parts/manipulator/M in component_parts) + man_rating += M.rating + + var/las_rating = 0 + for(var/obj/item/stock_parts/micro_laser/M in component_parts) + las_rating += M.rating + + work_time = initial(work_time) - 2 * (man_rating - 1) SECONDS + mat_efficiency = initial(mat_efficiency) - (1.5 ^ las_rating) /obj/machinery/craftingstation/on_deconstruction() - for(var/i in materials_stored) - eject(i, materials_stored[i]) + for(var/mat in stored_material) + eject(mat, stored_material[mat]) + ..() //Autolathes can eject decimal quantities of material as a shard -/obj/machinery/craftingstation/proc/eject(material/M, amount) - if(!amount || !M.stack_type) +/obj/machinery/craftingstation/proc/eject(material, amount) + if(!(material in stored_material)) return - amount = min(amount, materials_stored[M]) + if(!amount) + return + + var/material/M = get_material_by_name(material) + + if(!M.stack_type) + return + amount = min(amount, stored_material[material]) var/whole_amount = round(amount) var/remainder = amount - whole_amount @@ -350,7 +648,10 @@ //And if there's any remainder, we eject that as a shard if(remainder) - new /obj/item/material/shard(drop_location(), M, _amount = remainder) + new /obj/item/material/shard(drop_location(), material, _amount = remainder) //The stored material gets the amount (whole+remainder) subtracted - materials_stored[M] -= amount + stored_material[material] -= amount + +#undef WORK +#undef DONE diff --git a/code/modules/projectiles/ammunition/ammo_kits.dm b/code/modules/projectiles/ammunition/ammo_kits.dm index 165f751f7b3..266f240c0d4 100644 --- a/code/modules/projectiles/ammunition/ammo_kits.dm +++ b/code/modules/projectiles/ammunition/ammo_kits.dm @@ -1,4 +1,5 @@ +//// .35 //// /obj/item/ammo_kit name = "scrap ammo kit" desc = "A somewhat jank looking crafting kit. It has a can of single-use tools, cheap pliers and a box of bullet making materials." @@ -7,123 +8,261 @@ flags = CONDUCT throwforce = 1 w_class = ITEM_SIZE_SMALL + rarity_value = 10 spawn_tags = SPAWN_TAG_AMMO_COMMON - /obj/item/ammo_kit/Initialize() . = ..() icon_state = "ammo_kit-[rand(1,5)]" +////////////////////////////////////////////////////////////////////////////////////// -/obj/item/ammo_kit/attack_self(mob/user) - var/list/items_to_spawn = make_scrap_ammo(user, src) - if(items_to_spawn && items_to_spawn.len) - if(do_mob(user, src, 10 SECONDS)) - var/location = get_turf(src) - for(var/i in items_to_spawn) - var/item_type = items_to_spawn[i] - new item_type(location) - qdel(src) - +/obj/item/ammo_kit/attack_self(mob/living/user as mob) + var/cog_stat = user.stats.getStat(STAT_COG) -// Typeless so it could be reused in crafting_station.dm -/proc/make_scrap_ammo(mob/living/user, obj/source, extra_material_points = 0) - if(!istype(user)) + if(!isliving(loc)) return - var/material_points = 15 + extra_material_points // 10 steel and 5 cardboard - - if(user.stats) - switch(user.stats.getStat(STAT_MEC)) - if(STAT_LEVEL_BASIC to STAT_LEVEL_ADEPT) - material_points += 3 - if(STAT_LEVEL_ADEPT to STAT_LEVEL_EXPERT) - material_points += 6 - if(STAT_LEVEL_EXPERT to STAT_LEVEL_PROF) - material_points += 9 - if(STAT_LEVEL_PROF to STAT_LEVEL_GODLIKE) - material_points += 12 - if(STAT_LEVEL_GODLIKE to INFINITY) - material_points += 15 - if(user.stats.getPerk(/datum/perk/oddity/gunsmith)) - material_points += 15 - - var/list/array = list( - CAL_SRIFLE = list( - ".20 ammo pile (10 ammo, 3 points)" = list(3, /obj/item/ammo_casing/srifle/scrap/prespawned), - ".20 ammo strip (5 ammo, 1 point)" = list(1, /obj/item/ammo_magazine/slsrifle/scrap), - ".20 ammo speedloader (8 ammo, 3 points)" = list(3, /obj/item/ammo_magazine/slsrifle_rev/scrap), - ".20 standard magazine (empty, 25 ammo, 5 points)" = list(5, /obj/item/ammo_magazine/srifle/empty), - ".20 extended magazine (empty, 35 ammo, 7 points)" = list(7, /obj/item/ammo_magazine/srifle/long/empty), - ".20 drum magazine (empty, 60 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/srifle/drum/empty), - ".20 ammo box (50 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/ammobox/srifle_small/scrap)), - CAL_CLRIFLE = list( - ".25 ammo pile (10 ammo, 3 points)" = list(3, /obj/item/ammo_casing/clrifle/scrap/prespawned), - ".25 ammo strip (5 ammo, 1 point)" = list(1, /obj/item/ammo_magazine/slclrifle/scrap), - ".25 pistol magazine (empty, 10 ammo, 5 points)" = list(5, /obj/item/ammo_magazine/cspistol/empty), - ".25 standard magazine (empty, 30 ammo, 5 points)" = list(5, /obj/item/ammo_magazine/ihclrifle/empty), - ".25 ammo box (60 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/ammobox/clrifle_small/scrap)), - CAL_LRIFLE = list( - ".30 ammo pile (10 ammo, 3 points)" = list(3, /obj/item/ammo_casing/lrifle/scrap/prespawned), - ".30 ammo strip (5 ammo, 1 point)" = list(1, /obj/item/ammo_magazine/sllrifle/scrap), - ".30 standard magazine (empty, 30 ammo, 5 points)" = list(5, /obj/item/ammo_magazine/lrifle/empty), - ".30 drum magazine (empty, 45 ammo, 10 points)" = list(10, /obj/item/ammo_magazine/lrifle/drum/empty), - ".30 ammo box (60 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/ammobox/lrifle_small/scrap)), - CAL_PISTOL = list( - ".35 ammo pile (15 ammo, 5 points)" = list(5, /obj/item/ammo_casing/pistol/scrap/prespawned), - ".35 speedloader (6 ammo, 1 point)" = list(1, /obj/item/ammo_magazine/slpistol/scrap), - ".35 standard magazine (empty, 10 ammo, 3 points)" = list(3, /obj/item/ammo_magazine/pistol/empty), - ".35 extended magazine (empty, 16 ammo, 10 points)" = list(10, /obj/item/ammo_magazine/hpistol/empty), - ".35 SMG magazine (empty, 35 ammo, 5 points)" = list(5, /obj/item/ammo_magazine/smg/empty), - ".35 ammo box (70 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/ammobox/pistol/scrap)), - CAL_MAGNUM = list( - ".40 ammo pile (10 ammo, 3 points)" = list(3, /obj/item/ammo_casing/magnum/scrap/prespawned), - ".40 speedloader (6 ammo, 3 points)" = list(3, /obj/item/ammo_magazine/slmagnum/scrap), - ".40 standard magazine (empty, 10 ammo, 5 points)" = list(5, /obj/item/ammo_magazine/magnum/empty), - ".40 SMG magazine (empty, 25 ammo, 7 points)" = list(7, /obj/item/ammo_magazine/msmg/empty), - ".40 ammo box (50 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/ammobox/magnum/scrap)), - CAL_SHOTGUN = list( - ".50 slug pile (5 ammo, 3 points)" = list(3, /obj/item/ammo_casing/shotgun/scrap/prespawned), - ".50 pellet pile (5 ammo, 3 points)" = list(3, /obj/item/ammo_casing/shotgun/pellet/scrap/prespawned), - ".50 beanbag pile (5 ammo, 3 points)" = list(3, /obj/item/ammo_casing/shotgun/beanbag/scrap/prespawned), - ".50 drum (empty, 8 ammo, 10 points)" = list(10, /obj/item/ammo_magazine/m12/empty), - ".50 slug box (30 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/ammobox/shotgun/scrap), - ".50 pellet box (30 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/ammobox/shotgun/pellet/scrap), - ".50 beanbag box (30 ammo, 15 points)" = list(15, /obj/item/ammo_magazine/ammobox/shotgun/beanbag/scrap)), - CAL_ANTIM = list( - ".60 ammo pile (5 ammo, 5 points)" = list(5, /obj/item/ammo_casing/antim/scrap/prespawned), - ".60 ammo box (30 ammo, 20 points)" = list(20, /obj/item/ammo_magazine/ammobox/antim/scrap))) - - var/list/items_to_spawn = list() - var/user_is_choosing = TRUE - - while(user_is_choosing) - var/items_to_spawn_string = items_to_spawn.len ? "\n" + jointext(items_to_spawn, "\n") : "None" - var/action = alert(user, "Picked items: [items_to_spawn_string]", "Material points: [material_points]", "Pick an item", "Craft picked", "Cancel") - switch(action) - if("Pick an item") - var/caliber_of_choice = input(user, "Choose a caliber", "Material points: [material_points]") as null|anything in array - if(caliber_of_choice) - var/craft = input(user, "Choose a craft", "Material points: [material_points]") as null|anything in array[caliber_of_choice] - if(craft) - if(material_points >= array[caliber_of_choice][craft][1]) - material_points -= array[caliber_of_choice][craft][1] - items_to_spawn.Add(craft) - items_to_spawn[craft] = array[caliber_of_choice][craft][2] - else - to_chat(user, SPAN_NOTICE("Not enough materials.")) - continue - - if("Craft picked") - if(!items_to_spawn.len) - if(alert(user, "No items picked. Abort crafting?", "Material points: [material_points]", "Yes", "No, turn back") != "No, turn back") - user_is_choosing = FALSE - else - if(material_points) - if(alert(user, "Remaining material points would be wasted. Craft anyway?", "Material points: [material_points]", "Yes", "No, turn back") == "No, turn back") - continue - - if(!QDELETED(source) && in_range(source, user)) - return items_to_spawn + var/list/options = list() + options[".20 Rifle"] = "srifle" + options[".25 Caseless Rifle"] = "clrifle" + options[".30 Rifle"] = "lrifle" + options[".35 Auto"] = "pistol" + options[".40 Magnum"] = "magnum" + options[".50 Shotgun Buckshot"] = "shot" + options[".50 Shotgun Beanbag"] = "bean" + options[".50 Shotgun Slug"] = "slug" + options[".60 Anti-Material"] = "antim" + + var/choice = input(user,"What ammo do you want to make?") as null|anything in options + + var/ammo_type = options[choice] + + var/dice_roll = (rand(0,20)*(1+cog_stat/20)) //0 cog means you get between 0 and 20, negative means you only over get minimum + if(user.stats.getPerk(/datum/perk/oddity/gunsmith)) + dice_roll = dice_roll * 2 + switch(ammo_type) + if("pistol") + spawn_pistol(dice_roll,user) + if("magnum") + spawn_magnum(dice_roll,user) + if("srifle") + spawn_rifle(dice_roll,user,1) //same table, different spawns for all normal rifles + if("clrifle") + spawn_rifle(dice_roll,user,2) + if("lrifle") + spawn_rifle(dice_roll,user,3) + if("antim") + spawn_antim(dice_roll,user) + if("shot") + spawn_shotgun(dice_roll,user,1) + if("bean") + spawn_shotgun(dice_roll,user,2) + if("slug") + spawn_shotgun(dice_roll,user,3) + if(choice) + user.visible_message("[user] makes some [choice] rounds out of [src], using up all the materials in it.") + qdel(src) //All used up + else + to_chat(user, "You reconsider the path of gunsmith.") + +////////////////////////////////////////////////////////////////////////////////////// + +/obj/item/ammo_kit/proc/spawn_pistol(dice = 0, mob/user) //Shazbot- I know there is probably a better way to do this, but this is easier to code + + var/boxxes = 0 + var/piles = 0 + var/mags = 0 + + switch(dice) + if(-99 to 10) //if someone gets less than -99, they deserve the ammo + piles = 1 + if(10 to 20) + mags = 1 + if(20 to 30) + boxxes = 1 + mags = 1 + if(30 to 40) + boxxes = 1 + mags = 2 + if(40 to 50) + piles = 1 + boxxes = 2 + mags = 1 + else + boxxes = 3+ round(dice/10-5,1) //rich get richer + + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/pistol/scrap/prespawned(user.loc) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/pistol/scrap(user.loc) + if(mags) + for(var/j = 1 to mags) + if(prob(50)) + new /obj/item/ammo_magazine/pistol/scrap(user.loc) else - user_is_choosing = FALSE + new /obj/item/ammo_magazine/smg/scrap(user.loc) + +////////////////////////////////////////////////////////////////////////////////////// + +/obj/item/ammo_kit/proc/spawn_magnum(dice = 0, mob/user) + + var/boxxes = 0 + var/piles = 0 + var/mags = 0 + + switch(dice) + if(-99 to 8) + piles = 2 + if(8 to 16) + piles = 2 + mags = 1 + if(16 to 24) + boxxes = 1 + if(24 to 32) + boxxes = 1 + mags = 1 + if(32 to 40) + piles = 2 + boxxes = 1 + mags = 1 + if(40 to 48) + boxxes = 1 + mags = 3 + else + boxxes = 3 + round(dice/10-5,1) + + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/magnum/scrap/prespawned(user.loc) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/magnum/scrap(user.loc) + if(mags) + for(var/j = 1 to mags) + if(prob(50)) + new /obj/item/ammo_magazine/magnum/scrap(user.loc) + + else + new /obj/item/ammo_magazine/msmg/scrap(user.loc) + +////////////////////////////////////////////////////////////////////////////////////// + +/obj/item/ammo_kit/proc/spawn_rifle(dice = 0, mob/user,rifle=1) //All rifles use same spawning stats + + var/boxxes = 0 + var/piles = 0 + var/mags = 0 + + switch(dice) + if(-99 to 6) //if someone gets less than -99, they deserve the ammo + piles = 1 + if(6 to 12) + piles = 2 + if(12 to 18) + piles = 1 + mags = 1 + if(18 to 24) + piles = 2 + mags = 1 + if(24 to 30) + boxxes = 1 + if(30 to 42) + boxxes = 1 + mags = 1 + if(42 to 48) + boxxes = 1 + piles = 2 + mags = 1 + else + boxxes = 2 + round(dice/10-5,1) + + if(rifle==1) //srifle + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/srifle/scrap/prespawned(user.loc) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/srifle_small/scrap(user.loc) + if(mags) + for(var/j = 1 to mags) + new /obj/item/ammo_magazine/srifle/scrap(user.loc) + + if(rifle==2) //clrifle + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/clrifle/scrap/prespawned(user.loc) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/clrifle_small/scrap(user.loc) + if(mags) + for(var/j = 1 to mags) + new /obj/item/ammo_magazine/ihclrifle/scrap(user.loc) + + if(rifle==3) //lrifle + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/lrifle/scrap/prespawned(user.loc) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/lrifle_small/scrap(user.loc) + if(mags) + for(var/j = 1 to mags) + new /obj/item/ammo_magazine/lrifle/scrap(user.loc) +////////////////////////////////////////////////////////////////////////////////////// + +/obj/item/ammo_kit/proc/spawn_antim(dice = 0, mob/user) //Shazbot- I know there is probably a better way to do this, but this is easier to code + + var/boxxes = 0 + var/piles = 0 + + switch(dice) + if(-99 to 10) //if someone gets less than -99, they deserve the ammo + piles = 1 + if(10 to 20) + piles = 2 + if(20 to 30) + piles = 3 + if(30 to 40) + piles = 4 + if(40 to 50) + piles = 5 + else + boxxes = 1 + piles = round(dice/10-6,1) + + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/antim/scrap/prespawned(user.loc) + if(boxxes) + for(var/j = 1 to boxxes) + new /obj/item/ammo_magazine/ammobox/antim/scrap(user.loc) + +////////////////////////////////////////////////////////////////////////////////////// + +/obj/item/ammo_kit/proc/spawn_shotgun(dice = 0, mob/user,shotgun=1) //All rifles use same spawning stats + + var/piles = 0 + + switch(dice) + if(-99 to 0) //if someone gets less than -99, they deserve the ammo + piles = 1 + else + piles = 1 + round(dice/7-1,1) //We can use math here because it's just piles + + if(shotgun==1) //shot + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/shotgun/pellet/scrap/prespawned(user.loc) + + if(shotgun==2) //bean + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/shotgun/beanbag/scrap/prespawned(user.loc) + + if(shotgun==3) //slug + if(piles) + for(var/j = 1 to piles) + new /obj/item/ammo_casing/shotgun/scrap/prespawned(user.loc)