mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
First pass on ore distribution map and stationary drilling rig.
Added sprites for stationary drilling gear. Added skeleton ores for coal, adamantine, mythril. Updated some icons. Expanded mining rig functionality. Changed adamantine and mythril to osmium and metallic hydrogen. Added ore distribution map generation to master controller. Added upgrading to stationary drills, tweaked other stuff. Rewriting the ore processor and how ores handle information. Also rewrote the ore stacker.
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -78,6 +78,10 @@ datum/controller/game_controller/proc/setup()
|
||||
for(var/i=0, i<max_secret_rooms, i++)
|
||||
make_mining_asteroid_secret()
|
||||
|
||||
//Create the mining ore distribution map.
|
||||
var/datum/ore_distribution/O = new()
|
||||
O.populate_distribution_map()
|
||||
|
||||
spawn(0)
|
||||
if(ticker)
|
||||
ticker.pregame()
|
||||
|
||||
@@ -264,3 +264,31 @@ var/global/list/datum/stack_recipe/silver_recipes = list ( \
|
||||
throw_range = 3
|
||||
origin_tech = "materials=4"
|
||||
perunit = 2000
|
||||
|
||||
/*
|
||||
* TODO
|
||||
*/
|
||||
/obj/item/stack/sheet/mineral/platinum
|
||||
name = "platinum"
|
||||
icon_state = "sheet-diamond" //TODO
|
||||
sheettype = "platinum"
|
||||
|
||||
/obj/item/stack/sheet/mineral/mhydrogen
|
||||
name = "metallic hydrogen"
|
||||
icon_state = "sheet-diamond" //TODO
|
||||
sheettype = "mhydrogen"
|
||||
|
||||
/obj/item/stack/sheet/mineral/tritium
|
||||
name = "tritium"
|
||||
icon_state = "sheet-diamond" //TODO
|
||||
sheettype = "tritium"
|
||||
|
||||
/obj/item/stack/sheet/mineral/osmium
|
||||
name = "osmium"
|
||||
icon_state = "sheet-diamond" //TODO
|
||||
sheettype = "osmium"
|
||||
|
||||
obj/item/stack/sheet/mineral/iron
|
||||
name = "iron"
|
||||
icon_state = "sheet-gold"
|
||||
sheettype = "iron"
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
var/icon_old = null
|
||||
var/pathweight = 1
|
||||
|
||||
//Mining resource generation stuff.
|
||||
var/has_resources
|
||||
var/list/resources
|
||||
|
||||
/turf/New()
|
||||
..()
|
||||
for(var/atom/movable/AM as mob|obj in src)
|
||||
|
||||
@@ -1047,14 +1047,6 @@ I said no!
|
||||
items = list()
|
||||
result = /obj/item/weapon/reagent_containers/food/snacks/slimesoup
|
||||
|
||||
/datum/recipe/clownstears
|
||||
reagents = list("water" = 10)
|
||||
items = list(
|
||||
/obj/item/weapon/reagent_containers/food/snacks/grown/banana,
|
||||
/obj/item/weapon/ore/clown,
|
||||
)
|
||||
result = /obj/item/weapon/reagent_containers/food/snacks/clownstears
|
||||
|
||||
/datum/recipe/boiledslimeextract
|
||||
reagents = list("water" = 5)
|
||||
items = list(
|
||||
|
||||
27
code/modules/mining/alloys.dm
Normal file
27
code/modules/mining/alloys.dm
Normal file
@@ -0,0 +1,27 @@
|
||||
//Alloys that contain subsets of each other's ingredients must be ordered in the desired sequence
|
||||
//eg. steel comes after plasteel because plasteel's ingredients contain the ingredients for steel and
|
||||
//it would be impossible to produce.
|
||||
|
||||
/datum/alloy
|
||||
var/list/requires
|
||||
var/product_mod = 1
|
||||
var/product
|
||||
var/metaltag
|
||||
|
||||
/datum/alloy/plasteel
|
||||
metaltag = "plasteel"
|
||||
requires = list(
|
||||
"platinum" = 1,
|
||||
"coal" = 2,
|
||||
"hematite" = 2
|
||||
)
|
||||
product_mod = 0.3
|
||||
product = /obj/item/stack/sheet/plasteel
|
||||
|
||||
/datum/alloy/steel
|
||||
metaltag = "steel"
|
||||
requires = list(
|
||||
"coal" = 1,
|
||||
"hematite" = 1
|
||||
)
|
||||
product = /obj/item/stack/sheet/metal
|
||||
@@ -1,75 +1,3 @@
|
||||
/**********************Mineral ores**************************/
|
||||
|
||||
/obj/item/weapon/ore
|
||||
name = "Rock"
|
||||
icon = 'icons/obj/mining.dmi'
|
||||
icon_state = "ore2"
|
||||
var/datum/geosample/geologic_data
|
||||
|
||||
/obj/item/weapon/ore/uranium
|
||||
name = "Uranium ore"
|
||||
icon_state = "Uranium ore"
|
||||
origin_tech = "materials=5"
|
||||
|
||||
/obj/item/weapon/ore/iron
|
||||
name = "Iron ore"
|
||||
icon_state = "Iron ore"
|
||||
origin_tech = "materials=1"
|
||||
|
||||
/obj/item/weapon/ore/glass
|
||||
name = "Sand"
|
||||
icon_state = "Glass ore"
|
||||
origin_tech = "materials=1"
|
||||
|
||||
attack_self(mob/living/user as mob) //It's magic I ain't gonna explain how instant conversion with no tool works. -- Urist
|
||||
var/location = get_turf(user)
|
||||
for(var/obj/item/weapon/ore/glass/sandToConvert in location)
|
||||
new /obj/item/stack/sheet/mineral/sandstone(location)
|
||||
del(sandToConvert)
|
||||
new /obj/item/stack/sheet/mineral/sandstone(location)
|
||||
del(src)
|
||||
|
||||
/obj/item/weapon/ore/phoron
|
||||
name = "Phoron ore"
|
||||
icon_state = "Phoron ore"
|
||||
origin_tech = "materials=2"
|
||||
|
||||
/obj/item/weapon/ore/silver
|
||||
name = "Silver ore"
|
||||
icon_state = "Silver ore"
|
||||
origin_tech = "materials=3"
|
||||
|
||||
/obj/item/weapon/ore/gold
|
||||
name = "Gold ore"
|
||||
icon_state = "Gold ore"
|
||||
origin_tech = "materials=4"
|
||||
|
||||
/obj/item/weapon/ore/diamond
|
||||
name = "Diamond ore"
|
||||
icon_state = "Diamond ore"
|
||||
origin_tech = "materials=6"
|
||||
|
||||
/obj/item/weapon/ore/clown
|
||||
name = "Bananium ore"
|
||||
icon_state = "Clown ore"
|
||||
origin_tech = "materials=4"
|
||||
|
||||
/obj/item/weapon/ore/slag
|
||||
name = "Slag"
|
||||
desc = "Completely useless"
|
||||
icon_state = "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 ..()
|
||||
|
||||
/*****************************Coin********************************/
|
||||
|
||||
/obj/item/weapon/coin
|
||||
248
code/modules/mining/drilling/distribution.dm
Normal file
248
code/modules/mining/drilling/distribution.dm
Normal file
@@ -0,0 +1,248 @@
|
||||
//If anyone can think of a less shitty way to work out x,y points on a linear string of integers please tell me.
|
||||
#define MAP_CELL ((y-1)*real_size)+x
|
||||
#define MAP_CENTRE (((y-1)+size/2)*real_size)+(x+size/2)
|
||||
#define MAP_TOP_LEFT ((y-1)*real_size)+x
|
||||
#define MAP_TOP_RIGHT ((y-1)*real_size)+(x+size)
|
||||
#define MAP_BOTTOM_LEFT (((y+size)-1)*real_size)+x
|
||||
#define MAP_BOTTOM_RIGHT ((((y+size)-1)*real_size)+(x+size))
|
||||
#define MAP_MID_TOP MAP_TOP_LEFT + (size/2)
|
||||
#define MAP_MID_BOTTOM MAP_BOTTOM_LEFT + (size/2)
|
||||
#define MAP_MID_LEFT (((y-1)+size/2)*real_size)+x
|
||||
#define MAP_MID_RIGHT (((y-1)+size/2)*real_size)+(x+size)
|
||||
|
||||
#define MIN_SURFACE_COUNT 1000
|
||||
#define MAX_SURFACE_COUNT 5000
|
||||
#define MIN_RARE_COUNT 1000
|
||||
#define MAX_RARE_COUNT 5000
|
||||
#define MIN_DEEP_COUNT 100
|
||||
#define MAX_DEEP_COUNT 300
|
||||
#define ITERATE_BEFORE_FAIL 200
|
||||
|
||||
#define RESOURCE_HIGH_MAX 8
|
||||
#define RESOURCE_HIGH_MIN 5
|
||||
#define RESOURCE_MID_MAX 4
|
||||
#define RESOURCE_MID_MIN 2
|
||||
#define RESOURCE_LOW_MAX 1
|
||||
#define RESOURCE_LOW_MIN 0
|
||||
|
||||
/*
|
||||
Surface minerals:
|
||||
silicates
|
||||
iron
|
||||
gold
|
||||
silver
|
||||
|
||||
Rare minerals:
|
||||
uranium
|
||||
diamond
|
||||
|
||||
Deep minerals:
|
||||
phoron
|
||||
xerxium (adamantine)
|
||||
fulgurium (mythril)
|
||||
*/
|
||||
|
||||
/datum/ore_distribution
|
||||
|
||||
var/real_size = 65 //Overall map size ((must be power of 2)+1)
|
||||
var/chunk_size = 4 //Size each cell represents on map (like hell we're generating up to 100 256^2 grids at roundstart)
|
||||
var/list/map[4225] //The actual map. real_size squared.
|
||||
var/range = 255 //Max random range of cells in map.
|
||||
|
||||
var/random_variance_chance = 25
|
||||
var/random_element = 0.5
|
||||
|
||||
//Called by the drilling rigs each process().
|
||||
/datum/ore_distribution/proc/get_ore(var/x,var/y)
|
||||
return "Nope."
|
||||
|
||||
/datum/ore_distribution/proc/map_is_sane()
|
||||
if(!map) return 0
|
||||
|
||||
var/rare_count = 0
|
||||
var/surface_count = 0
|
||||
var/deep_count = 0
|
||||
|
||||
for(var/cell in map)
|
||||
if(cell>(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 << "<b><font color='red'>Could not generate a sane distribution map. Aborting.</font></b>"
|
||||
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<chunk_size,i++)
|
||||
|
||||
for(var/j=0,j<chunk_size,j++)
|
||||
|
||||
if(tx+j > 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 += "<font color='[printcolor]'>#</font>"
|
||||
|
||||
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
|
||||
382
code/modules/mining/drilling/drill.dm
Normal file
382
code/modules/mining/drilling/drill.dm
Normal file
@@ -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
|
||||
@@ -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 = "<b>Smelter control console</b><br><br>"
|
||||
//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("<A href='?src=\ref[src];sel_iron=no'><font color='green'>Smelting</font></A> ")
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];sel_iron=yes'><font color='red'>Not smelting</font></A> ")
|
||||
dat += text("Iron: [machine.ore_iron]<br>")
|
||||
else
|
||||
machine.selected &= ~ORE_PROC_IRON
|
||||
var/dat = "<h1>Ore processor console</h1>"
|
||||
|
||||
//sand - glass
|
||||
if(machine.ore_glass)
|
||||
if (machine.selected & ORE_PROC_GLASS)
|
||||
dat += text("<A href='?src=\ref[src];sel_glass=no'><font color='green'>Smelting</font></A> ")
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];sel_glass=yes'><font color='red'>Not smelting</font></A> ")
|
||||
dat += text("Sand: [machine.ore_glass]<br>")
|
||||
else
|
||||
machine.selected &= ~ORE_PROC_GLASS
|
||||
dat += "<hr><table>"
|
||||
|
||||
//phoron
|
||||
if(machine.ore_phoron)
|
||||
if (machine.selected & ORE_PROC_PHORON)
|
||||
dat += text("<A href='?src=\ref[src];sel_phoron=no'><font color='green'>Smelting</font></A> ")
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];sel_phoron=yes'><font color='red'>Not smelting</font></A> ")
|
||||
dat += text("Phoron: [machine.ore_phoron]<br>")
|
||||
else
|
||||
machine.selected &= ~ORE_PROC_PHORON
|
||||
for(var/ore in machine.ores_processing)
|
||||
|
||||
//uranium
|
||||
if(machine.ore_uranium)
|
||||
if (machine.selected & ORE_PROC_URANIUM)
|
||||
dat += text("<A href='?src=\ref[src];sel_uranium=no'><font color='green'>Smelting</font></A> ")
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];sel_uranium=yes'><font color='red'>Not smelting</font></A> ")
|
||||
dat += text("Uranium: [machine.ore_uranium]<br>")
|
||||
else
|
||||
machine.selected &= ~ORE_PROC_URANIUM
|
||||
if(!machine.ores_stored[ore] && !show_all_ores) continue
|
||||
|
||||
//gold
|
||||
if(machine.ore_gold)
|
||||
if (machine.selected & ORE_PROC_GOLD)
|
||||
dat += text("<A href='?src=\ref[src];sel_gold=no'><font color='green'>Smelting</font></A> ")
|
||||
dat += "<tr><td width = 40><b>[capitalize(ore)]</b></td><td width = 30>[machine.ores_stored[ore]]</td><td width = 100><font color='"
|
||||
if(machine.ores_processing[ore])
|
||||
switch(machine.ores_processing[ore])
|
||||
if(0)
|
||||
dat += "red'>not processing"
|
||||
if(1)
|
||||
dat += "orange'>smelting"
|
||||
if(2)
|
||||
dat += "blue'>compressing"
|
||||
if(3)
|
||||
dat += "gray'>alloying"
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];sel_gold=yes'><font color='red'>Not smelting</font></A> ")
|
||||
dat += text("Gold: [machine.ore_gold]<br>")
|
||||
else
|
||||
machine.selected &= ~ORE_PROC_GOLD
|
||||
|
||||
//silver
|
||||
if(machine.ore_silver)
|
||||
if (machine.selected & ORE_PROC_SILVER)
|
||||
dat += text("<A href='?src=\ref[src];sel_silver=no'><font color='green'>Smelting</font></A> ")
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];sel_silver=yes'><font color='red'>Not smelting</font></A> ")
|
||||
dat += text("Silver: [machine.ore_silver]<br>")
|
||||
else
|
||||
machine.selected &= ~ORE_PROC_SILVER
|
||||
|
||||
//diamond
|
||||
if(machine.ore_diamond)
|
||||
if (machine.selected & ORE_PROC_DIAMOND)
|
||||
dat += text("<A href='?src=\ref[src];sel_diamond=no'><font color='green'>Smelting</font></A> ")
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];sel_diamond=yes'><font color='red'>Not smelting</font></A> ")
|
||||
dat += text("Diamond: [machine.ore_diamond]<br>")
|
||||
else
|
||||
machine.selected &= ~ORE_PROC_DIAMOND
|
||||
|
||||
//bananium
|
||||
if(machine.ore_clown)
|
||||
if (machine.selected & ORE_PROC_CLOWN)
|
||||
dat += text("<A href='?src=\ref[src];sel_clown=no'><font color='green'>Smelting</font></A> ")
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];sel_clown=yes'><font color='red'>Not smelting</font></A> ")
|
||||
dat += text("Bananium: [machine.ore_clown]<br>")
|
||||
else
|
||||
machine.selected &= ~ORE_PROC_CLOWN
|
||||
|
||||
//On or off
|
||||
dat += text("Machine is currently ")
|
||||
if (machine.on==1)
|
||||
dat += text("<A href='?src=\ref[src];set_on=off'>On</A> ")
|
||||
else
|
||||
dat += text("<A href='?src=\ref[src];set_on=on'>Off</A> ")
|
||||
else
|
||||
dat+="---No Materials Loaded---"
|
||||
|
||||
|
||||
user << browse("[dat]", "window=console_processing_unit")
|
||||
onclose(user, "console_processing_unit")
|
||||
dat += "red'>not processing"
|
||||
dat += "</font>.</td><td width = 30><a href='?src=\ref[src];toggle_smelting=[ore]'>\[change\]</a></td></tr>"
|
||||
|
||||
dat += "</table><hr>"
|
||||
dat += "Currently displaying [show_all_ores ? "all ore types" : "only available ore types"]. <A href='?src=\ref[src];toggle_ores=1'>\[[show_all_ores ? "show less" : "show more"]\]</a></br>"
|
||||
dat += "The ore processor is currently <A href='?src=\ref[src];toggle_power=1'>[(machine.active ? "<font color='green'>processing</font>" : "<font color='red'>disabled</font>")]</a>."
|
||||
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)
|
||||
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
|
||||
continue
|
||||
if(ores_stored[metal] > 0 && ores_processing[metal] != 0)
|
||||
|
||||
var/datum/ore/O = ore_data[metal]
|
||||
|
||||
if(!O) continue
|
||||
|
||||
//if a non valid combination is selected
|
||||
if(ores_processing[metal] == 3 && O.alloy) //Alloying.
|
||||
var/can_make_alloy = 0
|
||||
var/datum/alloy/alloying
|
||||
|
||||
var/b = 1 //this part checks if all required ores are available
|
||||
for(var/datum/alloy/A in alloy_data)
|
||||
if(A.metaltag in tick_alloys) continue
|
||||
tick_alloys += A.metaltag
|
||||
|
||||
if (!selected)
|
||||
b = 0
|
||||
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
|
||||
|
||||
if (selected & ORE_PROC_GOLD)
|
||||
if (ore_gold <= 0)
|
||||
b = 0
|
||||
if (selected & ORE_PROC_SILVER)
|
||||
if (ore_silver <= 0)
|
||||
b = 0
|
||||
if (selected & ORE_PROC_DIAMOND)
|
||||
if (ore_diamond <= 0)
|
||||
b = 0
|
||||
if (selected & ORE_PROC_URANIUM)
|
||||
if (ore_uranium <= 0)
|
||||
b = 0
|
||||
if (selected & ORE_PROC_PHORON)
|
||||
if (ore_phoron <= 0)
|
||||
b = 0
|
||||
if (selected & ORE_PROC_IRON)
|
||||
if (ore_iron <= 0)
|
||||
b = 0
|
||||
if (selected & ORE_PROC_GLASS)
|
||||
if (ore_glass <= 0)
|
||||
b = 0
|
||||
if (selected & ORE_PROC_CLOWN)
|
||||
if (ore_clown <= 0)
|
||||
b = 0
|
||||
for(var/needs_metal in A.requires)
|
||||
|
||||
if (b) //if they are, deduct one from each, produce slag and shut the machine off
|
||||
if (selected & ORE_PROC_GOLD)
|
||||
ore_gold--
|
||||
if (selected & ORE_PROC_SILVER)
|
||||
ore_silver--
|
||||
if (selected & ORE_PROC_DIAMOND)
|
||||
ore_diamond--
|
||||
if (selected & ORE_PROC_URANIUM)
|
||||
ore_uranium--
|
||||
if (selected & ORE_PROC_PHORON)
|
||||
ore_phoron--
|
||||
if (selected & ORE_PROC_IRON)
|
||||
ore_iron--
|
||||
if (selected & ORE_PROC_CLOWN)
|
||||
ore_clown--
|
||||
new /obj/item/weapon/ore/slag(output.loc)
|
||||
on = 0
|
||||
else
|
||||
on = 0
|
||||
break
|
||||
//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
|
||||
for (i = 0; i < 10; i++)
|
||||
var/obj/item/O
|
||||
O = locate(/obj/item, input.loc)
|
||||
if (O)
|
||||
if (istype(O,/obj/item/weapon/ore/iron))
|
||||
ore_iron++;
|
||||
O.loc = null
|
||||
//del(O)
|
||||
continue
|
||||
if (istype(O,/obj/item/weapon/ore/glass))
|
||||
ore_glass++;
|
||||
O.loc = null
|
||||
//del(O)
|
||||
continue
|
||||
if (istype(O,/obj/item/weapon/ore/diamond))
|
||||
ore_diamond++;
|
||||
O.loc = null
|
||||
//del(O)
|
||||
continue
|
||||
if (istype(O,/obj/item/weapon/ore/phoron))
|
||||
ore_phoron++
|
||||
O.loc = null
|
||||
//del(O)
|
||||
continue
|
||||
if (istype(O,/obj/item/weapon/ore/gold))
|
||||
ore_gold++
|
||||
O.loc = null
|
||||
//del(O)
|
||||
continue
|
||||
if (istype(O,/obj/item/weapon/ore/silver))
|
||||
ore_silver++
|
||||
O.loc = null
|
||||
//del(O)
|
||||
continue
|
||||
if (istype(O,/obj/item/weapon/ore/uranium))
|
||||
ore_uranium++
|
||||
O.loc = null
|
||||
//del(O)
|
||||
continue
|
||||
if (istype(O,/obj/item/weapon/ore/clown))
|
||||
ore_clown++
|
||||
O.loc = null
|
||||
//del(O)
|
||||
continue
|
||||
O.loc = src.output.loc
|
||||
else
|
||||
break
|
||||
|
||||
if(!alloying)
|
||||
sheets++
|
||||
return
|
||||
|
||||
if(!can_make_alloy)
|
||||
continue
|
||||
else
|
||||
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,i<total,i++)
|
||||
new alloying.product(output.loc)
|
||||
|
||||
else if(ores_processing[metal] == 2 && O.compresses_to) //Compressing.
|
||||
|
||||
var/can_make = Clamp(ores_stored[metal],0,sheets_per_tick-sheets)
|
||||
if(can_make%2>0) can_make--
|
||||
|
||||
if(!can_make || ores_stored[metal] < 1)
|
||||
continue
|
||||
|
||||
for(var/i=0,i<can_make,i+=2)
|
||||
ores_stored[metal]-=2
|
||||
sheets+=2
|
||||
new O.compresses_to(output.loc)
|
||||
|
||||
else if(ores_processing[metal] == 1 && O.smelts_to) //Smelting.
|
||||
|
||||
var/can_make = Clamp(ores_stored[metal],0,sheets_per_tick-sheets)
|
||||
if(!can_make || ores_stored[metal] < 1)
|
||||
continue
|
||||
|
||||
for(var/i=0,i<can_make,i++)
|
||||
ores_stored[metal]--
|
||||
sheets++
|
||||
new O.smelts_to(output.loc)
|
||||
else
|
||||
ores_stored[metal]--
|
||||
sheets++
|
||||
new /obj/item/weapon/ore/slag(output.loc)
|
||||
else
|
||||
continue
|
||||
//Grab some more ore to process next tick.
|
||||
for(var/i = 0,i<sheets_per_tick,i++)
|
||||
var/obj/item/weapon/ore/O = locate() in input.loc
|
||||
if(!O) break
|
||||
if(!isnull(ores_stored[O.oretag])) ores_stored[O.oretag]++
|
||||
O.loc = null
|
||||
|
||||
console.updateUsrDialog()
|
||||
@@ -10,17 +10,16 @@
|
||||
var/machinedir = SOUTHEAST
|
||||
|
||||
/obj/machinery/mineral/stacking_unit_console/New()
|
||||
|
||||
..()
|
||||
|
||||
spawn(7)
|
||||
src.machine = locate(/obj/machinery/mineral/stacking_machine, get_step(src, machinedir))
|
||||
if (machine)
|
||||
machine.CONSOLE = src
|
||||
machine.console = src
|
||||
else
|
||||
del(src)
|
||||
|
||||
/obj/machinery/mineral/stacking_unit_console/process()
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/mineral/stacking_unit_console/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
interact(user)
|
||||
@@ -30,168 +29,38 @@
|
||||
|
||||
var/dat
|
||||
|
||||
dat += text("<b>Stacking unit console</b><br><br>")
|
||||
dat += text("<h1>Stacking unit console</h1><hr><table>")
|
||||
|
||||
if(machine.ore_iron)
|
||||
dat += text("Iron: [machine.ore_iron] <A href='?src=\ref[src];release=iron'>Release</A><br>")
|
||||
if(machine.ore_plasteel)
|
||||
dat += text("Plasteel: [machine.ore_plasteel] <A href='?src=\ref[src];release=plasteel'>Release</A><br>")
|
||||
if(machine.ore_glass)
|
||||
dat += text("Glass: [machine.ore_glass] <A href='?src=\ref[src];release=glass'>Release</A><br>")
|
||||
if(machine.ore_rglass)
|
||||
dat += text("Reinforced Glass: [machine.ore_rglass] <A href='?src=\ref[src];release=rglass'>Release</A><br>")
|
||||
if(machine.ore_phoron)
|
||||
dat += text("Phoron: [machine.ore_phoron] <A href='?src=\ref[src];release=phoron'>Release</A><br>")
|
||||
if(machine.ore_phoronglass)
|
||||
dat += text("Phoron Glass: [machine.ore_phoronglass] <A href='?src=\ref[src];release=phoronglass'>Release</A><br>")
|
||||
if(machine.ore_phoronrglass)
|
||||
dat += text("Reinforced Phoron Glass: [machine.ore_phoronrglass] <A href='?src=\ref[src];release=phoronrglass'>Release</A><br>")
|
||||
if(machine.ore_gold)
|
||||
dat += text("Gold: [machine.ore_gold] <A href='?src=\ref[src];release=gold'>Release</A><br>")
|
||||
if(machine.ore_silver)
|
||||
dat += text("Silver: [machine.ore_silver] <A href='?src=\ref[src];release=silver'>Release</A><br>")
|
||||
if(machine.ore_uranium)
|
||||
dat += text("Uranium: [machine.ore_uranium] <A href='?src=\ref[src];release=uranium'>Release</A><br>")
|
||||
if(machine.ore_diamond)
|
||||
dat += text("Diamond: [machine.ore_diamond] <A href='?src=\ref[src];release=diamond'>Release</A><br>")
|
||||
if(machine.ore_wood)
|
||||
dat += text("Wood: [machine.ore_wood] <A href='?src=\ref[src];release=wood'>Release</A><br>")
|
||||
if(machine.ore_cardboard)
|
||||
dat += text("Cardboard: [machine.ore_cardboard] <A href='?src=\ref[src];release=cardboard'>Release</A><br>")
|
||||
if(machine.ore_cloth)
|
||||
dat += text("Cloth: [machine.ore_cloth] <A href='?src=\ref[src];release=cloth'>Release</A><br>")
|
||||
if(machine.ore_leather)
|
||||
dat += text("Leather: [machine.ore_leather] <A href='?src=\ref[src];release=leather'>Release</A><br>")
|
||||
if(machine.ore_clown)
|
||||
dat += text("Bananium: [machine.ore_clown] <A href='?src=\ref[src];release=clown'>Release</A><br>")
|
||||
if(machine.ore_adamantine)
|
||||
dat += text ("Adamantine: [machine.ore_adamantine] <A href='?src=\ref[src];release=adamantine'>Release</A><br>")
|
||||
if(machine.ore_mythril)
|
||||
dat += text ("Mythril: [machine.ore_mythril] <A href='?src=\ref[src];release=adamantine'>Release</A><br>")
|
||||
|
||||
dat += text("<br>Stacking: [machine.stack_amt]<br><br>")
|
||||
for(var/stacktype in machine.stack_storage)
|
||||
if(machine.stack_storage[stacktype] > 0)
|
||||
dat += "<tr><td width = 150><b>[capitalize(stacktype)]:</b></td><td width = 30>[machine.stack_storage[stacktype]]</td><td width = 50><A href='?src=\ref[src];release_stack=[stacktype]'>\[release\]</a></td></tr>"
|
||||
dat += "</table><hr>"
|
||||
dat += text("<br>Stacking: [machine.stack_amt] <A href='?src=\ref[src];change_stack=1'>\[change\]</a><br><br>")
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -69,4 +69,4 @@ mineral/clown
|
||||
name = "Clown"
|
||||
result_amount = 3
|
||||
spread = 0
|
||||
ore = /obj/item/weapon/ore/clown
|
||||
ore = /obj/item/weapon/ore/slag
|
||||
81
code/modules/mining/ore.dm
Normal file
81
code/modules/mining/ore.dm
Normal file
@@ -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 ..()
|
||||
51
code/modules/mining/ore_datum.dm
Normal file
51
code/modules/mining/ore_datum.dm
Normal file
@@ -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"
|
||||
@@ -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
|
||||
BIN
icons/obj/mining_drill.dmi
Normal file
BIN
icons/obj/mining_drill.dmi
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Reference in New Issue
Block a user