diff --git a/baystation12.dme b/baystation12.dme index 31e245b184d..ade2cc5136c 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -851,6 +851,8 @@ #include "code\modules\maps\swapmaps.dm" #include "code\modules\maps\writer.dm" #include "code\modules\mining\abandonedcrates.dm" +#include "code\modules\mining\alloys.dm" +#include "code\modules\mining\coins.dm" #include "code\modules\mining\machine_input_output_plates.dm" #include "code\modules\mining\machine_processing.dm" #include "code\modules\mining\machine_stacking.dm" @@ -861,8 +863,11 @@ #include "code\modules\mining\minerals.dm" #include "code\modules\mining\mint.dm" #include "code\modules\mining\money_bag.dm" -#include "code\modules\mining\ores_coins.dm" +#include "code\modules\mining\ore.dm" +#include "code\modules\mining\ore_datum.dm" #include "code\modules\mining\satchel_ore_boxdm.dm" +#include "code\modules\mining\drilling\distribution.dm" +#include "code\modules\mining\drilling\drill.dm" #include "code\modules\mob\abilities.dm" #include "code\modules\mob\death.dm" #include "code\modules\mob\emote.dm" diff --git a/code/controllers/master_controller.dm b/code/controllers/master_controller.dm index eff3a8d62e2..99c63972853 100644 --- a/code/controllers/master_controller.dm +++ b/code/controllers/master_controller.dm @@ -78,6 +78,10 @@ datum/controller/game_controller/proc/setup() for(var/i=0, i(range*0.60)) + deep_count++ + else if(cell>(range*0.40)) + rare_count++ + else + surface_count++ + + if(surface_count < MIN_SURFACE_COUNT || surface_count > MAX_SURFACE_COUNT) return 0 + if(rare_count < MIN_RARE_COUNT || rare_count > MAX_RARE_COUNT) return 0 + if(deep_count < MIN_DEEP_COUNT || deep_count > MAX_DEEP_COUNT) return 0 + return 1 + +//Halfassed diamond-square algorithm with some fuckery since it's a single dimension array. +/datum/ore_distribution/proc/populate_distribution_map() + + //Seed beginning values. + + var/x = 1 + var/y = 1 + var/size = real_size-1 + + map[MAP_TOP_LEFT] = (range/3)+rand(range/5) + map[MAP_TOP_RIGHT] = (range/3)+rand(range/5) + map[MAP_BOTTOM_LEFT] = (range/3)+rand(range/5) + map[MAP_BOTTOM_RIGHT] = (range/3)+rand(range/5) + + //Fill in and smooth it out. + var/attempts = 0 + do + attempts++ + generate_distribution_map(1,1,size) + while(attempts < ITERATE_BEFORE_FAIL && !map_is_sane()) + + if(attempts >= ITERATE_BEFORE_FAIL) + world << "Could not generate a sane distribution map. Aborting." + map = null + return + else + apply_to_asteroid() + +/datum/ore_distribution/proc/clear_distribution_map() + for(var/x = 1, x <= real_size, x++) + for(var/y = 1, y <= real_size, y++) + map[MAP_CELL] = 0 + +/datum/ore_distribution/proc/generate_distribution_map(var/x,var/y,var/input_size) + + var/size = input_size + + map[MAP_MID_TOP] = (map[MAP_TOP_LEFT] + map[MAP_TOP_RIGHT])/2 + map[MAP_MID_RIGHT] = (map[MAP_BOTTOM_RIGHT] + map[MAP_TOP_RIGHT])/2 + map[MAP_MID_BOTTOM] = (map[MAP_BOTTOM_LEFT] + map[MAP_BOTTOM_RIGHT])/2 + map[MAP_MID_LEFT] = (map[MAP_TOP_LEFT] + map[MAP_BOTTOM_RIGHT])/2 + map[MAP_CENTRE] = (map[MAP_MID_LEFT]+map[MAP_MID_RIGHT]+map[MAP_MID_BOTTOM]+map[MAP_MID_TOP])/4 + + if(prob(random_variance_chance)) + map[MAP_CENTRE] *= (rand(1) ? (1.0-random_element) : (1.0+random_element)) + map[MAP_CENTRE] = max(0,min(range,map[MAP_CENTRE])) + + if(size>3) + generate_distribution_map(x,y,input_size/2) + generate_distribution_map(x+(input_size/2),y,input_size/2) + generate_distribution_map(x,y+(input_size/2),input_size/2) + generate_distribution_map(x+(input_size/2),y+(input_size/2),input_size/2) + +/datum/ore_distribution/proc/apply_to_asteroid() + + var/origin_x = 13 + var/origin_y = 32 + var/limit_x = 217 + var/limit_y = 223 + var/asteroid_z = 5 + + var/tx = origin_x + var/ty = origin_y + + for(var/y = 1, y <= real_size, y++) + + for(var/x = 1, x <= real_size, x++) + + var/turf/target_turf + + for(var/i=0,i limit_x || ty+i > limit_y) + continue + + target_turf = locate(tx+j, ty+i, asteroid_z) + + if(target_turf.has_resources) + + var/printcolor + if(map[MAP_CELL] > (range*0.60)) + printcolor = "#FF0000" + else if(map[MAP_CELL] > (range*0.40)) + printcolor = "#00FF00" + else + printcolor = "#0000FF" + target_turf.color = "#[printcolor]" + target_turf.resources = list() + + target_turf.resources["silicates"] = rand(RESOURCE_HIGH_MIN,RESOURCE_HIGH_MAX) + target_turf.resources["carbonaceous rock"] = rand(RESOURCE_HIGH_MIN,RESOURCE_HIGH_MAX) + + if(map[MAP_CELL] > (range*0.60)) + target_turf.resources["iron"] = 0 + target_turf.resources["gold"] = 0 + target_turf.resources["silver"] = 0 + target_turf.resources["uranium"] = rand(RESOURCE_HIGH_MIN,RESOURCE_HIGH_MAX) + target_turf.resources["diamond"] = rand(RESOURCE_HIGH_MIN,RESOURCE_HIGH_MAX) + target_turf.resources["phoron"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX) + target_turf.resources["osmium"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX) + target_turf.resources["hydrogen"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX) + else if(map[MAP_CELL] > (range*0.40)) + target_turf.resources["iron"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX) + target_turf.resources["gold"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX) + target_turf.resources["silver"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX) + target_turf.resources["uranium"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX) + target_turf.resources["diamond"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX) + target_turf.resources["phoron"] = rand(RESOURCE_LOW_MIN,RESOURCE_LOW_MAX) + target_turf.resources["osmium"] = rand(RESOURCE_LOW_MIN,RESOURCE_LOW_MAX) + target_turf.resources["hydrogen"] = rand(RESOURCE_LOW_MIN,RESOURCE_LOW_MAX) + else + target_turf.resources["iron"] = rand(RESOURCE_LOW_MIN,RESOURCE_LOW_MAX) + target_turf.resources["gold"] = rand(RESOURCE_LOW_MIN,RESOURCE_LOW_MAX) + target_turf.resources["silver"] = rand(RESOURCE_LOW_MIN,RESOURCE_LOW_MAX) + target_turf.resources["uranium"] = rand(RESOURCE_LOW_MIN,RESOURCE_LOW_MAX) + target_turf.resources["diamond"] = rand(RESOURCE_LOW_MIN,RESOURCE_LOW_MAX) + target_turf.resources["phoron"] = 0 + target_turf.resources["osmium"] = 0 + target_turf.resources["hydrogen"] = 0 + + tx += chunk_size + tx = origin_x + ty += chunk_size + +/datum/ore_distribution/proc/print_map() + world << "---" + var/string = "" + for(var/y = 1, y <= real_size, y++) + for(var/x = 1, x <= real_size, x++) + + var/printcolor + if(map[MAP_CELL] > (range*0.60)) + printcolor = "#FF0000" + else if(map[MAP_CELL] > (range*0.40)) + printcolor = "#00FF00" + else + printcolor = "#0000FF" + string += "#" + + world << string + string = "" + world << "---" + +#undef MAP_CELL +#undef MAP_CENTRE +#undef MAP_TOP_LEFT +#undef MAP_TOP_RIGHT +#undef MAP_BOTTOM_LEFT +#undef MAP_BOTTOM_RIGHT +#undef MAP_MID_TOP +#undef MAP_MID_BOTTOM +#undef MAP_MID_LEFT +#undef MAP_MID_RIGHT + +#undef MIN_SURFACE_COUNT +#undef MAX_SURFACE_COUNT +#undef MIN_RARE_COUNT +#undef MAX_RARE_COUNT +#undef MIN_DEEP_COUNT +#undef MAX_DEEP_COUNT +#undef ITERATE_BEFORE_FAIL + +#undef RESOURCE_HIGH_MAX +#undef RESOURCE_HIGH_MIN +#undef RESOURCE_MID_MAX +#undef RESOURCE_MID_MIN +#undef RESOURCE_LOW_MAX +#undef RESOURCE_LOW_MIN \ No newline at end of file diff --git a/code/modules/mining/drilling/drill.dm b/code/modules/mining/drilling/drill.dm new file mode 100644 index 00000000000..f19cc76d4b3 --- /dev/null +++ b/code/modules/mining/drilling/drill.dm @@ -0,0 +1,382 @@ +/obj/machinery/mining + icon = 'icons/obj/mining_drill.dmi' + anchored = 0 + use_power = 0 //The drill takes power directly from a cell. + density = 1 + layer = MOB_LAYER+0.1 //So it draws over mobs in the tile north of it. + +/obj/machinery/mining/drill + name = "mining drill head" + desc = "An enormous drill." + icon_state = "mining_drill" + var/braces_needed = 2 + var/list/supports = list() + var/supported = 0 + var/active = 0 + var/list/resource_field = list() + var/open = 0 + + var/ore_types = list( + "iron" = /obj/item/weapon/ore/iron, + "uranium" = /obj/item/weapon/ore/uranium, + "gold" = /obj/item/weapon/ore/gold, + "silver" = /obj/item/weapon/ore/silver, + "diamond" = /obj/item/weapon/ore/diamond, + "phoron" = /obj/item/weapon/ore/phoron, + "osmium" = /obj/item/weapon/ore/osmium, + "hydrogen" = /obj/item/weapon/ore/hydrogen, + "silicates" = /obj/item/weapon/ore/glass, + "carbonaceous rock" = /obj/item/weapon/ore/coal + ) + + //Upgrades + var/obj/item/weapon/stock_parts/matter_bin/storage + var/obj/item/weapon/stock_parts/micro_laser/cutter + var/obj/item/weapon/stock_parts/capacitor/cellmount + var/obj/item/weapon/cell/cell + + //Flags + var/need_update_field = 0 + var/need_player_check = 0 + +/obj/machinery/mining/drill/New() + + ..() + + storage = new(src) + cutter = new(src) + cellmount = new(src) + + cell = new(src) + cell.maxcharge = 10000 + cell.charge = cell.maxcharge + +/obj/machinery/mining/drill/process() + + if(need_player_check) + return + + check_supports() + + if(!active) return + + if(!anchored || !use_cell_power()) + system_error("system configuration or charge error") + return + + if(need_update_field) + get_resource_field() + + if(world.time % 10 == 0) + update_icon() + + if(!active) + return + + //Drill through the flooring, if any. + if(istype(get_turf(src),/turf/simulated/floor/plating/airless/asteroid)) + var/turf/simulated/floor/plating/airless/asteroid/T = get_turf(src) + if(!T.dug) + T.gets_dug() + else if(istype(get_turf(src),/turf/simulated/floor)) + var/turf/simulated/floor/T = get_turf(src) + T.ex_act(2.0) + + //Dig out the tasty ores. + if(resource_field.len) + var/turf/harvesting = pick(resource_field) + + while(resource_field.len && !harvesting.resources) + harvesting.has_resources = 0 + harvesting.resources = null + resource_field -= harvesting + harvesting = pick(resource_field) + + if(!harvesting) return + + var/total_harvest = get_harvest_capacity() //Ore harvest-per-tick. + var/found_resource = 0 //If this doesn't get set, the area is depleted and the drill errors out. + + for(var/metal in ore_types) + + if(contents.len >= get_storage_capacity()) + active = 0 + need_player_check = 1 + update_icon() + return + + if(contents.len + total_harvest >= get_storage_capacity()) + total_harvest = get_storage_capacity() - contents.len + + if(total_harvest <= 0) break + if(harvesting.resources[metal]) + + found_resource = 1 + + var/create_ore = 0 + if(harvesting.resources[metal] >= total_harvest) + harvesting.resources[metal] -= total_harvest + create_ore = total_harvest + total_harvest = 0 + else + total_harvest -= harvesting.resources[metal] + create_ore = harvesting.resources[metal] + harvesting.resources[metal] = 0 + + for(var/i=1,i<=create_ore,i++) + var/oretype = ore_types[metal] + new oretype(src) + + if(!found_resource) + harvesting.has_resources = 0 + harvesting.resources = null + resource_field -= harvesting + else + active = 0 + need_player_check = 1 + update_icon() + +/obj/machinery/mining/drill/attack_ai(var/mob/user as mob) + return src.attack_hand(user) + +/obj/machinery/mining/drill/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(istype(W,/obj/item/weapon/screwdriver)) + if(active) return + open = !open + user << "\blue You [open ? "open" : "close"] the maintenance panel." //TODO: Sprite. + return + else + if(!open || active) return ..() + if(istype(W,/obj/item/weapon/crowbar)) + if(storage) + user << "You slip the bolt and pry out \the [storage]." + storage.loc = get_turf(src) + storage = null + else if(cutter) + user << "You carefully detatch and pry out \the [cutter]." + cutter.loc = get_turf(src) + cutter = null + else if(cellmount) + user << "You yank out a few wires and pry out \the [cellmount]." + cellmount.loc = get_turf(src) + cellmount.loc = null + else if(cell) + user << "You pry out \the [cell]." + cell.loc = get_turf(src) + cell = null + else + user << "There's nothing inside the drilling rig to remove." + return + else if(istype(W,/obj/item/weapon/stock_parts/matter_bin)) + if(storage) + user << "The drill already has a matter bin installed." + else + W.loc = src + storage = W + user << "You install \the [W]." + return + else if(istype(W,/obj/item/weapon/stock_parts/micro_laser)) + if(cutter) + user << "The drill already has a cutting head installed." + else + W.loc = src + cutter = W + user << "You install \the [W]." + return + else if(istype(W,/obj/item/weapon/stock_parts/capacitor)) + if(cellmount) + user << "The drill already has a cell capacitor installed." + else + W.loc = src + cellmount = W + user << "You install \the [W]." + return + else if(istype(W,/obj/item/weapon/cell)) + if(cell) + user << "The drill already has a cell installed." + else + W.loc = src + cell = W + user << "You install \the [W]." + return + ..() +/obj/machinery/mining/drill/attack_hand(mob/user as mob) + check_supports() + + if(need_player_check) + user << "You hit the manual override and reset the drill's error checking." + need_player_check = 0 + if(anchored) get_resource_field() + update_icon() + return + + else if(supported) + if(use_cell_power()) + active = !active + if(active) + user << "\blue You engage \the [src] and it lurches downwards, grinding noisily." + need_update_field = 1 + else + user << "\blue You disengage \the [src] and it shudders to a grinding halt." + else + user << "\blue The drill is unpowered." + else + user << "\blue Turning on a piece of industrial machinery without sufficient bracing is a bad idea." + + update_icon() + +/obj/machinery/mining/drill/update_icon() + if(need_player_check) + icon_state = "mining_drill_error" + else if(active) + icon_state = "mining_drill_active" + else if(supported) + icon_state = "mining_drill_braced" + else + icon_state = "mining_drill" + return + +/obj/machinery/mining/drill/proc/check_supports() + + supported = 0 + + if((!supports || !supports.len) && initial(anchored) == 0) + icon_state = "mining_drill" + anchored = 0 + active = 0 + else + anchored = 1 + + if(supports && supports.len >= braces_needed) + supported = 1 + + update_icon() + +/obj/machinery/mining/drill/proc/system_error(var/error) + + if(error) src.visible_message("\red \The [src] flashes a '[error]' warning.") + need_player_check = 1 + active = 0 + update_icon() + +/obj/machinery/mining/drill/proc/get_harvest_capacity() + return 3 * (cutter ? cutter.rating : 0) + +/obj/machinery/mining/drill/proc/get_storage_capacity() + return 100 * (storage ? storage.rating : 0) + +/obj/machinery/mining/drill/proc/get_charge_use() + return 100 - (20 * (cellmount ? cellmount.rating : 0)) + +/obj/machinery/mining/drill/proc/get_resource_field() + + resource_field = list() + need_update_field = 0 + + var/turf/T = get_turf(src) + if(!istype(T)) return + + var/tx = T.x-2 + var/ty = T.y-2 + var/turf/mine_turf + for(var/iy=0,iy<5,iy++) + for(var/ix=0,ix<5,ix++) + mine_turf = locate(tx+ix,ty+iy,T.z) + if(mine_turf && istype(mine_turf) && mine_turf.has_resources) + resource_field += mine_turf + + if(!resource_field.len) + system_error("resources depleted") + +/obj/machinery/mining/drill/proc/use_cell_power() + if(!cell) return 0 + var/req = get_charge_use() + if(cell.charge >= req) + cell.use(req) + return 1 + return 0 + +/obj/machinery/mining/drill/verb/unload() + set name = "Unload Drill" + set category = "Object" + set src in oview(1) + + if(usr.stat) return + + var/obj/structure/ore_box/B = locate() in orange(1) + if(B) + for(var/obj/item/weapon/ore/O in contents) + O.loc = B + usr << "\red You unload the drill's storage cache into the ore box." + else + usr << "\red You must move an ore box up to the drill before you can unload it." + + +/obj/machinery/mining/brace + name = "mining drill brace" + desc = "A machinery brace for an industrial drill. It looks easily two feet thick." + icon_state = "mining_brace" + var/obj/machinery/mining/drill/connected + +/obj/machinery/mining/brace/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(istype(W,/obj/item/weapon/wrench)) + + if(istype(get_turf(src),/turf/space)) + user << "\blue You can't anchor something to empty space. Idiot." + return + + if(connected && connected.active) + user << "\blue You can't unanchor the brace of a running drill!" + return + + playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1) + user << "\blue You [anchored ? "un" : ""]anchor the brace." + + anchored = !anchored + if(anchored) + connect() + else + disconnect() + +/obj/machinery/mining/brace/proc/connect() + + var/turf/T = get_step(get_turf(src), src.dir) + for(var/thing in T.contents) + if(istype(thing,/obj/machinery/mining/drill)) + connected = thing + break + + if(!connected) return + + if(!connected.supports) connected.supports = list() + + icon_state = "mining_brace_active" + + connected.supports += src + connected.check_supports() + +/obj/machinery/mining/brace/proc/disconnect() + + if(!connected) return + + if(!connected.supports) connected.supports = list() + + icon_state = "mining_brace" + + connected.supports -= src + connected.check_supports() + connected = null + +/obj/machinery/mining/brace/verb/rotate() + set name = "Rotate" + set category = "Object" + set src in oview(1) + + if(usr.stat) return + + if (src.anchored) + usr << "It is anchored in place!" + return 0 + + src.dir = turn(src.dir, 90) + return 1 \ No newline at end of file diff --git a/code/modules/mining/machine_processing.dm b/code/modules/mining/machine_processing.dm index b41ff4ab163..dec66231b54 100644 --- a/code/modules/mining/machine_processing.dm +++ b/code/modules/mining/machine_processing.dm @@ -1,12 +1,3 @@ -#define ORE_PROC_GOLD 1 -#define ORE_PROC_SILVER 2 -#define ORE_PROC_DIAMOND 4 -#define ORE_PROC_GLASS 8 -#define ORE_PROC_PHORON 16 -#define ORE_PROC_URANIUM 32 -#define ORE_PROC_IRON 64 -#define ORE_PROC_CLOWN 128 - /**********************Mineral processing unit console**************************/ /obj/machinery/mineral/processing_unit_console @@ -15,175 +6,92 @@ icon_state = "console" density = 1 anchored = 1 + var/obj/machinery/mineral/processing_unit/machine = null var/machinedir = EAST + var/show_all_ores = 0 /obj/machinery/mineral/processing_unit_console/New() ..() spawn(7) src.machine = locate(/obj/machinery/mineral/processing_unit, get_step(src, machinedir)) if (machine) - machine.CONSOLE = src + machine.console = src else del(src) -/obj/machinery/mineral/processing_unit_console/process() - updateDialog() - /obj/machinery/mineral/processing_unit_console/attack_hand(mob/user) add_fingerprint(user) interact(user) /obj/machinery/mineral/processing_unit_console/interact(mob/user) + + if(..()) + return + + if(!allowed(user)) + user << "\red Access denied." + return + user.set_machine(src) - var/dat = "Smelter control console

" - //iron - if(machine.ore_iron || machine.ore_glass || machine.ore_phoron || machine.ore_uranium || machine.ore_gold || machine.ore_silver || machine.ore_diamond || machine.ore_clown || machine.ore_adamantine) - if(machine.ore_iron) - if (machine.selected & ORE_PROC_IRON) - dat += text("Smelting ") - else - dat += text("Not smelting ") - dat += text("Iron: [machine.ore_iron]
") + var/dat = "

Ore processor console

" + + dat += "
" + + for(var/ore in machine.ores_processing) + + if(!machine.ores_stored[ore] && !show_all_ores) continue + + dat += "" + dat += "
[capitalize(ore)][machine.ores_stored[ore]]not processing" + if(1) + dat += "orange'>smelting" + if(2) + dat += "blue'>compressing" + if(3) + dat += "gray'>alloying" else - machine.selected &= ~ORE_PROC_IRON - - //sand - glass - if(machine.ore_glass) - if (machine.selected & ORE_PROC_GLASS) - dat += text("Smelting ") - else - dat += text("Not smelting ") - dat += text("Sand: [machine.ore_glass]
") - else - machine.selected &= ~ORE_PROC_GLASS - - //phoron - if(machine.ore_phoron) - if (machine.selected & ORE_PROC_PHORON) - dat += text("Smelting ") - else - dat += text("Not smelting ") - dat += text("Phoron: [machine.ore_phoron]
") - else - machine.selected &= ~ORE_PROC_PHORON - - //uranium - if(machine.ore_uranium) - if (machine.selected & ORE_PROC_URANIUM) - dat += text("Smelting ") - else - dat += text("Not smelting ") - dat += text("Uranium: [machine.ore_uranium]
") - else - machine.selected &= ~ORE_PROC_URANIUM - - //gold - if(machine.ore_gold) - if (machine.selected & ORE_PROC_GOLD) - dat += text("Smelting ") - else - dat += text("Not smelting ") - dat += text("Gold: [machine.ore_gold]
") - else - machine.selected &= ~ORE_PROC_GOLD - - //silver - if(machine.ore_silver) - if (machine.selected & ORE_PROC_SILVER) - dat += text("Smelting ") - else - dat += text("Not smelting ") - dat += text("Silver: [machine.ore_silver]
") - else - machine.selected &= ~ORE_PROC_SILVER - - //diamond - if(machine.ore_diamond) - if (machine.selected & ORE_PROC_DIAMOND) - dat += text("Smelting ") - else - dat += text("Not smelting ") - dat += text("Diamond: [machine.ore_diamond]
") - else - machine.selected &= ~ORE_PROC_DIAMOND - - //bananium - if(machine.ore_clown) - if (machine.selected & ORE_PROC_CLOWN) - dat += text("Smelting ") - else - dat += text("Not smelting ") - dat += text("Bananium: [machine.ore_clown]
") - else - machine.selected &= ~ORE_PROC_CLOWN - - //On or off - dat += text("Machine is currently ") - if (machine.on==1) - dat += text("On ") - else - dat += text("Off ") - else - dat+="---No Materials Loaded---" - - - user << browse("[dat]", "window=console_processing_unit") - onclose(user, "console_processing_unit") + dat += "red'>not processing" + dat += "
.
\[change\]

" + dat += "Currently displaying [show_all_ores ? "all ore types" : "only available ore types"]. \[[show_all_ores ? "show less" : "show more"]\]
" + dat += "The ore processor is currently [(machine.active ? "processing" : "disabled")]." + user << browse(dat, "window=processor_console;size=400x500") + onclose(user, "computer") + return /obj/machinery/mineral/processing_unit_console/Topic(href, href_list) if(..()) return usr.set_machine(src) src.add_fingerprint(usr) - if(href_list["sel_iron"]) - if (href_list["sel_iron"] == "yes") - machine.selected |= ORE_PROC_IRON - else - machine.selected &= ~ORE_PROC_IRON - if(href_list["sel_glass"]) - if (href_list["sel_glass"] == "yes") - machine.selected |= ORE_PROC_GLASS - else - machine.selected &= ~ORE_PROC_GLASS - if(href_list["sel_phoron"]) - if (href_list["sel_phoron"] == "yes") - machine.selected |= ORE_PROC_PHORON - else - machine.selected &= ~ORE_PROC_PHORON - if(href_list["sel_uranium"]) - if (href_list["sel_uranium"] == "yes") - machine.selected |= ORE_PROC_URANIUM - else - machine.selected &= ~ORE_PROC_URANIUM - if(href_list["sel_gold"]) - if (href_list["sel_gold"] == "yes") - machine.selected |= ORE_PROC_GOLD - else - machine.selected &= ~ORE_PROC_GOLD - if(href_list["sel_silver"]) - if (href_list["sel_silver"] == "yes") - machine.selected |= ORE_PROC_SILVER - else - machine.selected &= ~ORE_PROC_SILVER - if(href_list["sel_diamond"]) - if (href_list["sel_diamond"] == "yes") - machine.selected |= ORE_PROC_DIAMOND - else - machine.selected &= ~ORE_PROC_DIAMOND - if(href_list["sel_clown"]) - if (href_list["sel_clown"] == "yes") - machine.selected |= ORE_PROC_CLOWN - else - machine.selected &= ~ORE_PROC_CLOWN - if(href_list["set_on"]) - if (href_list["set_on"] == "on") - machine.on = 1 - else - machine.on = 0 + if(href_list["toggle_smelting"]) + + var/choice = input("What setting do you wish to use for processing [href_list["toggle_smelting"]]?") as null|anything in list("Smelting","Compressing","Alloying","Nothing") + if(!choice) return + + switch(choice) + if("Nothing") choice = 0 + if("Smelting") choice = 1 + if("Compressing") choice = 2 + if("Alloying") choice = 3 + + machine.ores_processing[href_list["toggle_smelting"]] = choice + + if(href_list["toggle_power"]) + + machine.active = !machine.active + + if(href_list["toggle_ores"]) + + show_all_ores = !show_all_ores + src.updateUsrDialog() return @@ -191,271 +99,142 @@ /obj/machinery/mineral/processing_unit - name = "furnace" + name = "material processor" //This isn't actually a goddamn furnace, we're in space and it's processing platinum and flammable phoron... icon = 'icons/obj/machines/mining_machines.dmi' icon_state = "furnace" density = 1 - anchored = 1.0 - luminosity = 3 //Big fire with window, yeah it puts out a little light. + anchored = 1 + luminosity = 3 var/obj/machinery/mineral/input = null var/obj/machinery/mineral/output = null - var/obj/machinery/mineral/CONSOLE = null - var/ore_gold = 0; - var/ore_silver = 0; - var/ore_diamond = 0; - var/ore_glass = 0; - var/ore_phoron = 0; - var/ore_uranium = 0; - var/ore_iron = 0; - var/ore_clown = 0; - var/ore_adamantine = 0; - var/selected = 0 -/* - var/selected_gold = 0 - var/selected_silver = 0 - var/selected_diamond = 0 - var/selected_glass = 0 - var/selected_plasma = 0 - var/selected_uranium = 0 - var/selected_iron = 0 - var/selected_clown = 0 -*/ - var/on = 0 //0 = off, 1 =... oh you know! - + var/obj/machinery/mineral/console = null + var/sheets_per_tick = 10 + var/list/ores_processing[0] + var/list/ores_stored[0] + var/list/ore_data[0] + var/list/alloy_data[0] + var/active = 0 /obj/machinery/mineral/processing_unit/New() + ..() - spawn( 5 ) + + //TODO: Ore and alloy global storage datum. + for(var/alloytype in typesof(/datum/alloy)-/datum/alloy) + alloy_data += new alloytype() + + for(var/oretype in typesof(/datum/ore)-/datum/ore) + var/datum/ore/OD = new oretype() + ore_data[OD.oretag] = OD + ores_processing[OD.oretag] = 0 + ores_stored[OD.oretag] = 0 + + //Locate our output and input machinery. + spawn(5) for (var/dir in cardinal) src.input = locate(/obj/machinery/mineral/input, get_step(src, dir)) if(src.input) break for (var/dir in cardinal) src.output = locate(/obj/machinery/mineral/output, get_step(src, dir)) if(src.output) break - processing_objects.Add(src) return return /obj/machinery/mineral/processing_unit/process() - if (src.output && src.input) - var/i - for (i = 0; i < 10; i++) - if (on) + if (!active || !src.output || !src.input) return + var/list/tick_alloys = list() - if (selected == ORE_PROC_GLASS) - if (ore_glass > 0) - ore_glass--; - new /obj/item/stack/sheet/glass(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_GLASS + ORE_PROC_IRON) - if (ore_glass > 0 && ore_iron > 0) - ore_glass--; - ore_iron--; - new /obj/item/stack/sheet/rglass(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_GOLD) - if (ore_gold > 0) - ore_gold--; - new /obj/item/stack/sheet/mineral/gold(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_SILVER) - if (ore_silver > 0) - ore_silver--; - new /obj/item/stack/sheet/mineral/silver(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_DIAMOND) - if (ore_diamond > 0) - ore_diamond--; - new /obj/item/stack/sheet/mineral/diamond(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_PHORON) - if (ore_phoron > 0) - ore_phoron--; - new /obj/item/stack/sheet/mineral/phoron(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_URANIUM) - if (ore_uranium > 0) - ore_uranium--; - new /obj/item/stack/sheet/mineral/uranium(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_IRON) - if (ore_iron > 0) - ore_iron--; - new /obj/item/stack/sheet/metal(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_IRON + ORE_PROC_PHORON) - if (ore_iron > 0 && ore_phoron > 0) - ore_iron--; - ore_phoron--; - new /obj/item/stack/sheet/plasteel(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_CLOWN) - if (ore_clown > 0) - ore_clown--; - new /obj/item/stack/sheet/mineral/clown(output.loc) - else - on = 0 - continue - /* - if (selected == ORE_PROC_GLASS + ORE_PROC_PHORON) - if (ore_glass > 0 && ore_plasma > 0) - ore_glass--; - ore_plasma--; - new /obj/item/stack/sheet/glass/plasmaglass(output.loc) - else - on = 0 - continue - if (selected == ORE_PROC_GLASS + ORE_PROC_IRON + ORE_PROC_PHORON) - if (ore_glass > 0 && ore_plasma > 0 && ore_iron > 0) - ore_glass--; - ore_iron--; - ore_plasma--; - new /obj/item/stack/sheet/glass/plasmarglass(output.loc) - else - on = 0 - continue - */ + //Process our stored ores and spit out sheets. + var/sheets = 0 + for(var/metal in ores_stored) + if(sheets >= sheets_per_tick) break - if (selected == ORE_PROC_URANIUM + ORE_PROC_DIAMOND) - if (ore_uranium >= 2 && ore_diamond >= 1) - ore_uranium -= 2 - ore_diamond -= 1 - new /obj/item/stack/sheet/mineral/adamantine(output.loc) + if(ores_stored[metal] > 0 && ores_processing[metal] != 0) + + var/datum/ore/O = ore_data[metal] + + if(!O) continue + + if(ores_processing[metal] == 3 && O.alloy) //Alloying. + var/can_make_alloy = 0 + var/datum/alloy/alloying + + for(var/datum/alloy/A in alloy_data) + if(A.metaltag in tick_alloys) continue + tick_alloys += A.metaltag + + if(!isnull(A.requires[metal]) && ores_stored[metal] >= A.requires[metal]) //We have enough of our first metal, we're off to a good start. + alloying = A + can_make_alloy = 0 + var/enough_metal = 1 + + for(var/needs_metal in A.requires) + + //Check if we're alloying the needed metal and have it stored. + if(ores_processing[needs_metal] != 3 || ores_stored[needs_metal] < A.requires[needs_metal]) + enough_metal = 0 + break + + if(!enough_metal) + can_make_alloy = 0 + else + can_make_alloy = 1 + break + + if(!alloying) + sheets++ + return + + if(!can_make_alloy) + continue else - on = 0 - continue - if (selected == ORE_PROC_SILVER + ORE_PROC_PHORON) - if (ore_silver >= 1 && ore_phoron >= 3) - ore_silver -= 1 - ore_phoron -= 3 - new /obj/item/stack/sheet/mineral/mythril(output.loc) - else - on = 0 + var/total + for(var/needs_metal in alloying.requires) + ores_stored[needs_metal] -= alloying.requires[needs_metal] + total += alloying.requires[needs_metal] + total = round(total*alloying.product_mod) + sheets += total-1 + + for(var/i=0,i0) can_make-- + + if(!can_make || ores_stored[metal] < 1) continue + for(var/i=0,iStacking unit console

") + dat += text("

Stacking unit console


") - if(machine.ore_iron) - dat += text("Iron: [machine.ore_iron] Release
") - if(machine.ore_plasteel) - dat += text("Plasteel: [machine.ore_plasteel] Release
") - if(machine.ore_glass) - dat += text("Glass: [machine.ore_glass] Release
") - if(machine.ore_rglass) - dat += text("Reinforced Glass: [machine.ore_rglass] Release
") - if(machine.ore_phoron) - dat += text("Phoron: [machine.ore_phoron] Release
") - if(machine.ore_phoronglass) - dat += text("Phoron Glass: [machine.ore_phoronglass] Release
") - if(machine.ore_phoronrglass) - dat += text("Reinforced Phoron Glass: [machine.ore_phoronrglass] Release
") - if(machine.ore_gold) - dat += text("Gold: [machine.ore_gold] Release
") - if(machine.ore_silver) - dat += text("Silver: [machine.ore_silver] Release
") - if(machine.ore_uranium) - dat += text("Uranium: [machine.ore_uranium] Release
") - if(machine.ore_diamond) - dat += text("Diamond: [machine.ore_diamond] Release
") - if(machine.ore_wood) - dat += text("Wood: [machine.ore_wood] Release
") - if(machine.ore_cardboard) - dat += text("Cardboard: [machine.ore_cardboard] Release
") - if(machine.ore_cloth) - dat += text("Cloth: [machine.ore_cloth] Release
") - if(machine.ore_leather) - dat += text("Leather: [machine.ore_leather] Release
") - if(machine.ore_clown) - dat += text("Bananium: [machine.ore_clown] Release
") - if(machine.ore_adamantine) - dat += text ("Adamantine: [machine.ore_adamantine] Release
") - if(machine.ore_mythril) - dat += text ("Mythril: [machine.ore_mythril] Release
") - - dat += text("
Stacking: [machine.stack_amt]

") + for(var/stacktype in machine.stack_storage) + if(machine.stack_storage[stacktype] > 0) + dat += "" + dat += "
[capitalize(stacktype)]:[machine.stack_storage[stacktype]]\[release\]

" + dat += text("
Stacking: [machine.stack_amt] \[change\]

") user << browse("[dat]", "window=console_stacking_machine") onclose(user, "console_stacking_machine") + /obj/machinery/mineral/stacking_unit_console/Topic(href, href_list) if(..()) return - usr.set_machine(src) - src.add_fingerprint(usr) - if(href_list["release"]) - switch(href_list["release"]) - if ("phoron") - if (machine.ore_phoron > 0) - var/obj/item/stack/sheet/mineral/phoron/G = new /obj/item/stack/sheet/mineral/phoron - G.amount = machine.ore_phoron - G.loc = machine.output.loc - machine.ore_phoron = 0 - if ("phoronglass") - if (machine.ore_phoronglass > 0) - var/obj/item/stack/sheet/glass/phoronglass/G = new /obj/item/stack/sheet/glass/phoronglass - G.amount = machine.ore_phoronglass - G.loc = machine.output.loc - machine.ore_phoronglass = 0 - if ("phoronrglass") - if (machine.ore_phoronrglass > 0) - var/obj/item/stack/sheet/glass/phoronrglass/G = new /obj/item/stack/sheet/glass/phoronrglass - G.amount = machine.ore_phoronrglass - G.loc = machine.output.loc - machine.ore_phoronrglass = 0 - if ("uranium") - if (machine.ore_uranium > 0) - var/obj/item/stack/sheet/mineral/uranium/G = new /obj/item/stack/sheet/mineral/uranium - G.amount = machine.ore_uranium - G.loc = machine.output.loc - machine.ore_uranium = 0 - if ("glass") - if (machine.ore_glass > 0) - var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass - G.amount = machine.ore_glass - G.loc = machine.output.loc - machine.ore_glass = 0 - if ("rglass") - if (machine.ore_rglass > 0) - var/obj/item/stack/sheet/rglass/G = new /obj/item/stack/sheet/rglass - G.amount = machine.ore_rglass - G.loc = machine.output.loc - machine.ore_rglass = 0 - if ("gold") - if (machine.ore_gold > 0) - var/obj/item/stack/sheet/mineral/gold/G = new /obj/item/stack/sheet/mineral/gold - G.amount = machine.ore_gold - G.loc = machine.output.loc - machine.ore_gold = 0 - if ("silver") - if (machine.ore_silver > 0) - var/obj/item/stack/sheet/mineral/silver/G = new /obj/item/stack/sheet/mineral/silver - G.amount = machine.ore_silver - G.loc = machine.output.loc - machine.ore_silver = 0 - if ("diamond") - if (machine.ore_diamond > 0) - var/obj/item/stack/sheet/mineral/diamond/G = new /obj/item/stack/sheet/mineral/diamond - G.amount = machine.ore_diamond - G.loc = machine.output.loc - machine.ore_diamond = 0 - if ("iron") - if (machine.ore_iron > 0) - var/obj/item/stack/sheet/metal/G = new /obj/item/stack/sheet/metal - G.amount = machine.ore_iron - G.loc = machine.output.loc - machine.ore_iron = 0 - if ("plasteel") - if (machine.ore_plasteel > 0) - var/obj/item/stack/sheet/plasteel/G = new /obj/item/stack/sheet/plasteel - G.amount = machine.ore_plasteel - G.loc = machine.output.loc - machine.ore_plasteel = 0 - if ("wood") - if (machine.ore_wood > 0) - var/obj/item/stack/sheet/wood/G = new /obj/item/stack/sheet/wood - G.amount = machine.ore_wood - G.loc = machine.output.loc - machine.ore_wood = 0 - if ("cardboard") - if (machine.ore_cardboard > 0) - var/obj/item/stack/sheet/cardboard/G = new /obj/item/stack/sheet/cardboard - G.amount = machine.ore_cardboard - G.loc = machine.output.loc - machine.ore_cardboard = 0 - if ("cloth") - if (machine.ore_cloth > 0) - var/obj/item/stack/sheet/cloth/G = new /obj/item/stack/sheet/cloth - G.amount = machine.ore_cloth - G.loc = machine.output.loc - machine.ore_cloth = 0 - if ("leather") - if (machine.ore_leather > 0) - var/obj/item/stack/sheet/leather/G = new /obj/item/stack/sheet/leather - G.amount = machine.ore_diamond - G.loc = machine.output.loc - machine.ore_leather = 0 - if ("clown") - if (machine.ore_clown > 0) - var/obj/item/stack/sheet/mineral/clown/G = new /obj/item/stack/sheet/mineral/clown - G.amount = machine.ore_clown - G.loc = machine.output.loc - machine.ore_clown = 0 - if ("adamantine") - if (machine.ore_adamantine > 0) - var/obj/item/stack/sheet/mineral/adamantine/G = new /obj/item/stack/sheet/mineral/adamantine - G.amount = machine.ore_adamantine - G.loc = machine.output.loc - machine.ore_adamantine = 0 - if ("mythril") - if (machine.ore_mythril > 0) - var/obj/item/stack/sheet/mineral/mythril/G = new /obj/item/stack/sheet/mineral/mythril - G.amount = machine.ore_mythril - G.loc = machine.output.loc - machine.ore_mythril = 0 - src.updateUsrDialog() - return + if(href_list["change_stack"]) + var/choice = input("What would you like to set the stack amount to?") as null|anything in list(1,5,10,20,50) + if(!choice) return + machine.stack_amt = choice + + if(href_list["release_stack"]) + if(machine.stack_storage[href_list["release_stack"]] > 0) + var/stacktype = machine.stack_paths[href_list["release_stack"]] + var/obj/item/stack/sheet/S = new stacktype (get_turf(machine.output)) + S.amount = machine.stack_storage[href_list["release_stack"]] + machine.stack_storage[href_list["release_stack"]] = 0 + + src.add_fingerprint(usr) + src.updateUsrDialog() + + return /**********************Mineral stacking unit**************************/ @@ -202,33 +71,29 @@ icon_state = "stacker" density = 1 anchored = 1.0 - var/obj/machinery/mineral/stacking_unit_console/CONSOLE - var/stk_types = list() - var/stk_amt = list() + var/obj/machinery/mineral/stacking_unit_console/console var/obj/machinery/mineral/input = null var/obj/machinery/mineral/output = null - var/ore_gold = 0; - var/ore_silver = 0; - var/ore_diamond = 0; - var/ore_phoron = 0; - var/ore_phoronglass = 0; - var/ore_phoronrglass = 0; - var/ore_iron = 0; - var/ore_uranium = 0; - var/ore_clown = 0; - var/ore_glass = 0; - var/ore_rglass = 0; - var/ore_plasteel = 0; - var/ore_wood = 0 - var/ore_cardboard = 0 - var/ore_cloth = 0; - var/ore_leather = 0; - var/ore_adamantine = 0; - var/ore_mythril = 0; - var/stack_amt = 50; //ammount to stack before releassing + var/list/stack_storage[0] + var/list/stack_paths[0] + var/stack_amt = 50; // Amount to stack before releassing /obj/machinery/mineral/stacking_machine/New() ..() + + for(var/stacktype in typesof(/obj/item/stack/sheet/mineral)-/obj/item/stack/sheet/mineral) + var/obj/item/stack/S = new stacktype(src) + stack_storage[S.name] = 0 + stack_paths[S.name] = stacktype + del(S) + + stack_storage["glass"] = 0 + stack_paths["glass"] = /obj/item/stack/sheet/glass + stack_storage["metal"] = 0 + stack_paths["metal"] = /obj/item/stack/sheet/metal + stack_storage["plasteel"] = 0 + stack_paths["plasteel"] = /obj/item/stack/sheet/plasteel + spawn( 5 ) for (var/dir in cardinal) src.input = locate(/obj/machinery/mineral/input, get_step(src, dir)) @@ -236,220 +101,31 @@ for (var/dir in cardinal) src.output = locate(/obj/machinery/mineral/output, get_step(src, dir)) if(src.output) break - processing_objects.Add(src) return return /obj/machinery/mineral/stacking_machine/process() if (src.output && src.input) - var/obj/item/stack/O - while (locate(/obj/item, input.loc)) - O = locate(/obj/item/stack, input.loc) - if(isnull(O)) - var/obj/item/I = locate(/obj/item, input.loc) - if (istype(I,/obj/item/weapon/ore/slag)) - I.loc = null + var/turf/T = get_turf(input) + for(var/obj/item/O in T.contents) + if(!O) return + if(istype(O,/obj/item/stack)) + if(!isnull(stack_storage[O.name])) + stack_storage[O.name]++ + O.loc = null else - I.loc = output.loc - continue - if (istype(O,/obj/item/stack/sheet/metal)) - ore_iron+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/mineral/diamond)) - ore_diamond+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/mineral/phoron)) - ore_phoron+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/mineral/gold)) - ore_gold+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/mineral/silver)) - ore_silver+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/mineral/clown)) - ore_clown+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/mineral/uranium)) - ore_uranium+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/glass/phoronglass)) - ore_phoronglass+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/glass/phoronrglass)) - ore_phoronrglass+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/glass)) - ore_glass+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/rglass)) - ore_rglass+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/plasteel)) - ore_plasteel+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/mineral/adamantine)) - ore_adamantine+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/mineral/mythril)) - ore_mythril+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/cardboard)) - ore_cardboard+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/wood)) - ore_wood+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/cloth)) - ore_cloth+= O.amount - O.loc = null - //del(O) - continue - if (istype(O,/obj/item/stack/sheet/leather)) - ore_leather+= O.amount - O.loc = null - //del(O) - continue - O.loc = src.output.loc + O.loc = output.loc + else + O.loc = output.loc - if (ore_gold >= stack_amt) - var/obj/item/stack/sheet/mineral/gold/G = new /obj/item/stack/sheet/mineral/gold - G.amount = stack_amt - G.loc = output.loc - ore_gold -= stack_amt - return - if (ore_silver >= stack_amt) - var/obj/item/stack/sheet/mineral/silver/G = new /obj/item/stack/sheet/mineral/silver - G.amount = stack_amt - G.loc = output.loc - ore_silver -= stack_amt - return - if (ore_diamond >= stack_amt) - var/obj/item/stack/sheet/mineral/diamond/G = new /obj/item/stack/sheet/mineral/diamond - G.amount = stack_amt - G.loc = output.loc - ore_diamond -= stack_amt - return - if (ore_phoron >= stack_amt) - var/obj/item/stack/sheet/mineral/phoron/G = new /obj/item/stack/sheet/mineral/phoron - G.amount = stack_amt - G.loc = output.loc - ore_phoron -= stack_amt - return - if (ore_iron >= stack_amt) - var/obj/item/stack/sheet/metal/G = new /obj/item/stack/sheet/metal - G.amount = stack_amt - G.loc = output.loc - ore_iron -= stack_amt - return - if (ore_clown >= stack_amt) - var/obj/item/stack/sheet/mineral/clown/G = new /obj/item/stack/sheet/mineral/clown - G.amount = stack_amt - G.loc = output.loc - ore_clown -= stack_amt - return - if (ore_uranium >= stack_amt) - var/obj/item/stack/sheet/mineral/uranium/G = new /obj/item/stack/sheet/mineral/uranium - G.amount = stack_amt - G.loc = output.loc - ore_uranium -= stack_amt - return - if (ore_glass >= stack_amt) - var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass - G.amount = stack_amt - G.loc = output.loc - ore_glass -= stack_amt - return - if (ore_rglass >= stack_amt) - var/obj/item/stack/sheet/rglass/G = new /obj/item/stack/sheet/rglass - G.amount = stack_amt - G.loc = output.loc - ore_rglass -= stack_amt - return - if (ore_phoronglass >= stack_amt) - var/obj/item/stack/sheet/glass/phoronglass/G = new /obj/item/stack/sheet/glass/phoronglass - G.amount = stack_amt - G.loc = output.loc - ore_phoronglass -= stack_amt - return - if (ore_phoronrglass >= stack_amt) - var/obj/item/stack/sheet/glass/phoronrglass/G = new /obj/item/stack/sheet/glass/phoronrglass - G.amount = stack_amt - G.loc = output.loc - ore_phoronrglass -= stack_amt - return - if (ore_plasteel >= stack_amt) - var/obj/item/stack/sheet/plasteel/G = new /obj/item/stack/sheet/plasteel - G.amount = stack_amt - G.loc = output.loc - ore_plasteel -= stack_amt - return - if (ore_wood >= stack_amt) - var/obj/item/stack/sheet/wood/G = new /obj/item/stack/sheet/wood - G.amount = stack_amt - G.loc = output.loc - ore_wood -= stack_amt - return - if (ore_cardboard >= stack_amt) - var/obj/item/stack/sheet/cardboard/G = new /obj/item/stack/sheet/cardboard - G.amount = stack_amt - G.loc = output.loc - ore_cardboard -= stack_amt - return - if (ore_cloth >= stack_amt) - var/obj/item/stack/sheet/cloth/G = new /obj/item/stack/sheet/cloth - G.amount = stack_amt - G.loc = output.loc - ore_cloth -= stack_amt - return - if (ore_leather >= stack_amt) - var/obj/item/stack/sheet/leather/G = new /obj/item/stack/sheet/leather - G.amount = stack_amt - G.loc = output.loc - ore_leather -= stack_amt - return - if (ore_adamantine >= stack_amt) - var/obj/item/stack/sheet/mineral/adamantine/G = new /obj/item/stack/sheet/mineral/adamantine - G.amount = stack_amt - G.loc = output.loc - ore_adamantine -= stack_amt - return - if (ore_mythril >= stack_amt) - var/obj/item/stack/sheet/mineral/mythril/G = new /obj/item/stack/sheet/mineral/mythril - G.amount = stack_amt - G.loc = output.loc - ore_mythril -= stack_amt - return + //Output amounts that are past stack_amt. + for(var/sheet in stack_storage) + if(stack_storage[sheet] >= stack_amt) + var/stacktype = stack_paths[sheet] + var/obj/item/stack/sheet/S = new stacktype (get_turf(output)) + S.amount = stack_amt + stack_storage[sheet] -= stack_amt + + console.updateUsrDialog() return + diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm index 88363da800a..4c1d4150a04 100644 --- a/code/modules/mining/mine_turfs.dm +++ b/code/modules/mining/mine_turfs.dm @@ -27,6 +27,7 @@ var/list/artifact_spawn = list() // Runtime fix for geometry loading before cont var/obj/item/weapon/last_find var/datum/artifact_find/artifact_find + has_resources = 1 New() . = ..() @@ -392,6 +393,7 @@ var/list/artifact_spawn = list() // Runtime fix for geometry loading before cont temperature = T0C icon_plating = "asteroid" var/dug = 0 //0 = has not yet been dug, 1 = has already been dug + has_resources = 1 /turf/simulated/floor/plating/airless/asteroid/New() var/proper_name = name diff --git a/code/modules/mining/minerals.dm b/code/modules/mining/minerals.dm index fb7378ae848..30db2262075 100644 --- a/code/modules/mining/minerals.dm +++ b/code/modules/mining/minerals.dm @@ -69,4 +69,4 @@ mineral/clown name = "Clown" result_amount = 3 spread = 0 - ore = /obj/item/weapon/ore/clown \ No newline at end of file + ore = /obj/item/weapon/ore/slag \ No newline at end of file diff --git a/code/modules/mining/ore.dm b/code/modules/mining/ore.dm new file mode 100644 index 00000000000..8c537252d5f --- /dev/null +++ b/code/modules/mining/ore.dm @@ -0,0 +1,81 @@ +/obj/item/weapon/ore + name = "rock" + icon = 'icons/obj/mining.dmi' + icon_state = "ore2" + var/datum/geosample/geologic_data + var/oretag + +/obj/item/weapon/ore/uranium + name = "pitchblende" + icon_state = "Uranium ore" + origin_tech = "materials=5" + oretag = "uranium" + +/obj/item/weapon/ore/iron + name = "hematite" + icon_state = "Iron ore" + origin_tech = "materials=1" + oretag = "hematite" + +/obj/item/weapon/ore/coal + name = "carbonaceous rock" + icon_state = "Iron ore" //TODO + origin_tech = "materials=1" + oretag = "coal" + +/obj/item/weapon/ore/glass + name = "impure silicates" + icon_state = "Glass ore" + origin_tech = "materials=1" + oretag = "sand" + +/obj/item/weapon/ore/phoron + name = "phoron crystals" + icon_state = "Phoron ore" + origin_tech = "materials=2" + oretag = "phoron" + +/obj/item/weapon/ore/silver + name = "native silver ore" + icon_state = "Silver ore" + origin_tech = "materials=3" + oretag = "silver" + +/obj/item/weapon/ore/gold + name = "native gold ore" + icon_state = "Gold ore" + origin_tech = "materials=4" + oretag = "gold" + +/obj/item/weapon/ore/diamond + name = "diamonds" + icon_state = "Diamond ore" + origin_tech = "materials=6" + oretag = "diamond" + +/obj/item/weapon/ore/osmium + name = "raw platinum" + icon_state = "slag" //TODO + oretag = "platinum" + +/obj/item/weapon/ore/hydrogen + name = "raw hydrogen" + icon_state = "slag" //TODO + oretag = "hydrogen" + +/obj/item/weapon/ore/slag + name = "Slag" + desc = "Completely useless" + icon_state = "slag" + oretag = "slag" + +/obj/item/weapon/ore/New() + pixel_x = rand(0,16)-8 + pixel_y = rand(0,8)-8 + +/obj/item/weapon/ore/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(istype(W,/obj/item/device/core_sampler)) + var/obj/item/device/core_sampler/C = W + C.sample_item(src, user) + else + return ..() \ No newline at end of file diff --git a/code/modules/mining/ore_datum.dm b/code/modules/mining/ore_datum.dm new file mode 100644 index 00000000000..d05b5fcb16a --- /dev/null +++ b/code/modules/mining/ore_datum.dm @@ -0,0 +1,51 @@ +/datum/ore + var/oretag + var/alloy + var/smelts_to + var/compresses_to + +/datum/ore/uranium + smelts_to = /obj/item/stack/sheet/mineral/uranium + oretag = "uranium" + +/datum/ore/iron + smelts_to = /obj/item/stack/sheet/mineral/iron + alloy = 1 + oretag = "hematite" + +/datum/ore/coal + smelts_to = /obj/item/stack/sheet/mineral/plastic + alloy = 1 + oretag = "coal" + +/datum/ore/glass + smelts_to = /obj/item/stack/sheet/glass + compresses_to = /obj/item/stack/sheet/mineral/sandstone + oretag = "sand" + +/datum/ore/phoron + smelts_to = /obj/item/stack/sheet/mineral/phoron + oretag = "phoron" + +/datum/ore/silver + smelts_to = /obj/item/stack/sheet/mineral/silver + oretag = "silver" + +/datum/ore/gold + smelts_to = /obj/item/stack/sheet/mineral/gold + oretag = "gold" + +/datum/ore/diamond + smelts_to = /obj/item/stack/sheet/mineral/diamond + oretag = "diamond" + +/datum/ore/osmium + smelts_to = /obj/item/stack/sheet/mineral/platinum + compresses_to = /obj/item/stack/sheet/mineral/osmium + alloy = 1 + oretag = "platinum" + +/datum/ore/hydrogen + smelts_to = /obj/item/stack/sheet/mineral/tritium + compresses_to = /obj/item/stack/sheet/mineral/mhydrogen + oretag = "hydrogen" diff --git a/code/modules/mining/satchel_ore_boxdm.dm b/code/modules/mining/satchel_ore_boxdm.dm index a4b6378d4c4..f02b1797183 100644 --- a/code/modules/mining/satchel_ore_boxdm.dm +++ b/code/modules/mining/satchel_ore_boxdm.dm @@ -151,8 +151,4 @@ if (istype(O, /obj/item/weapon/ore/strangerock)) amt_strange++ continue - if (istype(O, /obj/item/weapon/ore/clown)) - amt_clown++ - continue - return \ No newline at end of file diff --git a/icons/obj/mining_drill.dmi b/icons/obj/mining_drill.dmi new file mode 100644 index 00000000000..7a9ad6b057f Binary files /dev/null and b/icons/obj/mining_drill.dmi differ