Turf cleanup, Shoe unsnowflaking

This commit does the following:
 - Removes unused variables from turfs
 - Removes the mining/drilling folder following the removal of it's turf
   variables
 - All mobs now generate dirt on simulated turfs, not just humans.
 - Shoe sounds are now handled by a proc on shoes, step_action()
  - This is called by human/Move().
This commit is contained in:
Tigercat2000
2015-10-10 10:00:51 -07:00
parent 07770fdda7
commit 4bc8c737b1
7 changed files with 49 additions and 718 deletions
+28 -3
View File
@@ -1,3 +1,5 @@
/obj/item/clothing/shoes/proc/step_action(var/mob/living/carbon/human/H) //squeek squeek
/obj/item/clothing/shoes/syndigaloshes
desc = "A pair of brown shoes. They seem to have extra grip."
name = "brown shoes"
@@ -61,6 +63,18 @@
var/footstep = 1 //used for squeeks whilst walking
species_restricted = null
/obj/item/clothing/shoes/clown_shoes/step_action(var/mob/living/carbon/human/H)
if(!istype(H)) return 0
if(H.m_intent == "run")
if(footstep >= 2)
playsound(src, "clownstep", 50, 1)
footstep = 0
else
footstep++
else
playsound(src, "clownstep", 20, 1)
/obj/item/clothing/shoes/jackboots
name = "jackboots"
desc = "Nanotrasen-issue Security combat boots for combat scenarios or combat situations. All combat, all the time."
@@ -68,7 +82,19 @@
item_state = "jackboots"
item_color = "hosred"
siemens_coefficient = 0.7
var/footstep=1
var/footstep = 1
/obj/item/clothing/shoes/jackboots/step_action(var/mob/living/carbon/human/H)
if(!istype(H)) return 0
if(H.m_intent == "run")
if(footstep >= 2)
playsound(src, "jackboot", 50, 1)
footstep = 0
else
footstep++
else
playsound(src, "jackboot", 20, 1)
/obj/item/clothing/shoes/jackboots/jacksandals
name = "jacksandals"
@@ -132,11 +158,10 @@
icon_state = "griffinboots"
item_state = "griffinboots"
flags = NODROP
/obj/item/clothing/shoes/fluff/noble_boot
name = "noble boots"
desc = "The boots are economically designed to balance function and comfort, so that you can step on peasants without having to worry about blisters. The leather also resists unwanted blood stains."
icon_state = "noble_boot"
item_color = "noble_boot"
item_state = "noble_boot"
@@ -1,234 +0,0 @@
//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 4
#define RESOURCE_HIGH_MIN 2
#define RESOURCE_MID_MAX 3
#define RESOURCE_MID_MIN 1
#define RESOURCE_LOW_MAX 1
#define RESOURCE_LOW_MIN 0
/*
Surface minerals:
silicates
iron
gold
silver
Rare minerals:
uranium
diamond
Deep minerals:
plasma
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
/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()
//Announce it!
world << "<b><font color='red'>Generating resource distribution map.</b></font>"
//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/print_distribution_map()
var/line = ""
for(var/x = 1, x <= real_size, x++)
for(var/y = 1, y <= real_size, y++)
line += num2text(round(map[MAP_CELL]/25.5))
world << line
line = ""
/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()
// THESE VALUES DETERMINE THE AREA THAT THE DISTRIBUTION MAP IS APPLIED TO.
// IF YOU DO NOT RUN OFFICIAL BAYCODE ASTEROID MAP YOU NEED TO CHANGE THEM.
// ORIGIN IS THE BOTTOM LEFT CORNER OF THE SQUARE CONTAINING ALL ASTEROID
// TILES YOU WISH TO APPLY THE DISTRIBUTION MAP TO.
var/origin_x = 13 //We start here...
var/origin_y = 32 //...and here...
var/limit_x = 217 //...and iterate until here...
var/limit_y = 223 //...and here...
var/asteroid_z = 5 //...on this Z-level.
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 && target_turf.has_resources)
target_turf.resources = list()
target_turf.resources["silicates"] = rand(3,5)
target_turf.resources["carbonaceous rock"] = rand(3,5)
switch(map[MAP_CELL])
if(0 to 100)
target_turf.resources["iron"] = rand(RESOURCE_HIGH_MIN,RESOURCE_HIGH_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"] = 0
target_turf.resources["plasma"] = 0
target_turf.resources["osmium"] = 0
target_turf.resources["hydrogen"] = 0
if(100 to 124)
target_turf.resources["iron"] = 0
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"] = 0
target_turf.resources["plasma"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX)
target_turf.resources["osmium"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX)
target_turf.resources["hydrogen"] = 0
if(125 to 255)
target_turf.resources["iron"] = 0
target_turf.resources["gold"] = 0
target_turf.resources["silver"] = 0
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["plasma"] = rand(RESOURCE_HIGH_MIN,RESOURCE_HIGH_MAX)
target_turf.resources["osmium"] = rand(RESOURCE_HIGH_MIN,RESOURCE_HIGH_MAX)
target_turf.resources["hydrogen"] = rand(RESOURCE_MID_MIN,RESOURCE_MID_MAX)
tx += chunk_size
tx = origin_x
ty += chunk_size
world << "<b><font color='red'>Resource map generation complete.</font></b>"
return
#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
-392
View File
@@ -1,392 +0,0 @@
/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,
"plasma" = /obj/item/weapon/ore/plasma,
"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/stock_parts/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())
system_error("insufficient storage space")
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, params)
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(cell)
user << "You pry out \the [cell]."
cell.loc = get_turf(src)
cell = null
else 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 = 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
user.drop_item()
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
user.drop_item()
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
user.drop_item()
W.loc = src
cellmount = W
user << "You install \the [W]."
return
else if(istype(W,/obj/item/weapon/stock_parts/cell))
if(cell)
user << "The drill already has a cell installed."
else
user.drop_item()
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 (cutter ? cutter.rating : 0)
/obj/machinery/mining/drill/proc/get_storage_capacity()
return 200 * (storage ? storage.rating : 0)
/obj/machinery/mining/drill/proc/get_charge_use()
return 50 - (10 * (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, params)
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)
if(!T.has_resources)
src.visible_message("\red The terrain near the brace is unsuitable!")
return
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
-54
View File
@@ -1,54 +0,0 @@
/obj/item/weapon/mining_scanner
name = "ore detector"
desc = "A complex device used to locate ore deep underground."
icon = 'icons/obj/device.dmi'
icon_state = "forensic0-old" //GET A BETTER SPRITE.
item_state = "electronic"
// matter = list("metal" = 150)
origin_tech = "magnets=1;engineering=1"
/obj/item/weapon/mining_scanner/attack_self(mob/user as mob)
user << "You begin sweeping \the [src] about, scanning for metal deposits."
if(!do_after(user,50, target = src)) return
if(!user || !src) return
var/list/metals = list(
"surface minerals" = 0,
"precious metals" = 0,
"nuclear fuel" = 0,
"exotic matter" = 0
)
for(var/turf/T in oview(3,get_turf(user)))
if(!T.has_resources)
continue
for(var/metal in T.resources)
var/ore_type
switch(metal)
if("silicates" || "carbonaceous rock" || "iron") ore_type = "surface minerals"
if("gold" || "silver" || "diamond") ore_type = "precious metals"
if("uranium") ore_type = "nuclear fuel"
if("plasma" || "osmium" || "hydrogen") ore_type = "exotic matter"
if(ore_type) metals[ore_type] += T.resources[metal]
user << "\icon[src] \blue The scanner beeps and displays a readout."
for(var/ore_type in metals)
var/result = "no sign"
switch(metals[ore_type])
if(1 to 50) result = "trace amounts"
if(51 to 150) result = "significant amounts"
if(151 to INFINITY) result = "huge quantities"
user << "- [result] of [ore_type]."
@@ -73,3 +73,12 @@
/mob/living/carbon/human/mob_negates_gravity()
return shoes && shoes.negates_gravity()
/mob/living/carbon/human/Move(NewLoc, direct)
. = ..()
if(shoes)
if(!lying && !buckled)
if(!has_gravity(loc))
return
var/obj/item/clothing/shoes/S = shoes
S.step_action(src)