mirror of
https://github.com/cybergirlvannie/OpenSS13.git
synced 2026-07-16 18:22:23 +01:00
Committed atmospheric pipe tests
This commit is contained in:
@@ -164,7 +164,4 @@
|
||||
|
||||
sngas.turf_take(T, delta_gt) // grab gas from turf and direcly add it to the new gas
|
||||
|
||||
T.res_vars() // update turf gas vars for both cases
|
||||
|
||||
|
||||
|
||||
T.res_vars() // update turf gas vars for both cases
|
||||
@@ -156,6 +156,7 @@ obj/machinery/circulator
|
||||
ngas2.replace_by(gas2)
|
||||
|
||||
|
||||
|
||||
// now do standard gas flow process
|
||||
|
||||
var/delta_gt
|
||||
@@ -214,4 +215,4 @@ obj/machinery/circulator
|
||||
if(from == vnode1)
|
||||
return gas1
|
||||
else
|
||||
return gas2
|
||||
return gas2
|
||||
@@ -101,3 +101,365 @@ obj/machinery/inlet
|
||||
flow_to_turf(gas, ngas, T)
|
||||
|
||||
|
||||
//Filtration Procs for Filtered Inlet
|
||||
|
||||
/obj/machinery/proc
|
||||
flow_filter1(var/obj/substance/gas/sgas, var/obj/substance/gas/sngas, var/turf/T)
|
||||
var/t_tot = T.tot_gas() * 0.2
|
||||
var/delta_gt = FLOWFRAC * ( t_tot - sgas.tot_gas() / capmult )
|
||||
sngas.turf_take_filter1(T, delta_gt)
|
||||
T.res_vars()
|
||||
flow_filter2(var/obj/substance/gas/sgas, var/obj/substance/gas/sngas, var/turf/T)
|
||||
var/t_tot = T.tot_gas() * 0.2
|
||||
var/delta_gt = FLOWFRAC * ( t_tot - sgas.tot_gas() / capmult )
|
||||
sngas.turf_take_filter2(T, delta_gt)
|
||||
T.res_vars()
|
||||
flow_filter3(var/obj/substance/gas/sgas, var/obj/substance/gas/sngas, var/turf/T)
|
||||
var/t_tot = T.tot_gas() * 0.2
|
||||
var/delta_gt = FLOWFRAC * ( t_tot - sgas.tot_gas() / capmult )
|
||||
sngas.turf_take_filter3(T, delta_gt)
|
||||
T.res_vars()
|
||||
flow_filter4(var/obj/substance/gas/sgas, var/obj/substance/gas/sngas, var/turf/T)
|
||||
var/t_tot = T.tot_gas() * 0.2
|
||||
var/delta_gt = FLOWFRAC * ( t_tot - sgas.tot_gas() / capmult )
|
||||
sngas.turf_take_filter4(T, delta_gt)
|
||||
T.res_vars()
|
||||
flow_filter5(var/obj/substance/gas/sgas, var/obj/substance/gas/sngas, var/turf/T)
|
||||
var/t_tot = T.tot_gas() * 0.2
|
||||
var/delta_gt = FLOWFRAC * ( t_tot - sgas.tot_gas() / capmult )
|
||||
sngas.turf_take_filter5(T, delta_gt)
|
||||
T.res_vars()
|
||||
|
||||
/obj/substance/gas/proc
|
||||
turf_take_filter1(var/turf/target as turf, amount)
|
||||
if (((!( istype(target, /turf) ) && !( istype(target, /obj/move) )) || !( amount )))
|
||||
return
|
||||
if (locate(/obj/move, target))
|
||||
target = locate(/obj/move, target)
|
||||
var/t1 = target.oxygen + target.n2
|
||||
if (!( t1 ))
|
||||
return
|
||||
var/t2 = src.oxygen + src.n2
|
||||
if (amount > 0)
|
||||
if ((src.maximum > 0 && (src.maximum - t2) < amount))
|
||||
amount = src.maximum - t2
|
||||
else
|
||||
amount = src.oxygen + src.n2
|
||||
if (amount > t1)
|
||||
amount = t1
|
||||
var/turf_total = target.oxygen + target.n2
|
||||
var/heat_gain = (turf_total ? amount * target.temp : 0)
|
||||
var/t_oxygen = amount * target.co2 / t1
|
||||
var/t_n2 = amount * target.n2 / t1
|
||||
if(t2+amount>0)
|
||||
temperature = (temperature*t2 + heat_gain * TURF_TAKE_FRAC)/(t2+amount)
|
||||
src.oxygen += t_oxygen
|
||||
src.n2 += t_n2
|
||||
target.oxygen -= t_oxygen
|
||||
target.n2 -= t_n2
|
||||
target.res_vars()
|
||||
return
|
||||
turf_take_filter2(var/turf/target as turf, amount)
|
||||
if (((!( istype(target, /turf) ) && !( istype(target, /obj/move) )) || !( amount )))
|
||||
return
|
||||
if (locate(/obj/move, target))
|
||||
target = locate(/obj/move, target)
|
||||
var/t1 = target.co2
|
||||
if (!( t1 ))
|
||||
return
|
||||
var/t2 = src.co2
|
||||
if (amount > 0)
|
||||
if ((src.maximum > 0 && (src.maximum - t2) < amount))
|
||||
amount = src.maximum - t2
|
||||
else
|
||||
amount = src.co2
|
||||
if (amount > t1)
|
||||
amount = t1
|
||||
var/turf_total = target.co2
|
||||
var/heat_gain = (turf_total ? amount * target.temp : 0)
|
||||
var/t_co2 = amount * target.co2 / t1
|
||||
if(t2+amount>0)
|
||||
temperature = (temperature*t2 + heat_gain * TURF_TAKE_FRAC)/(t2+amount)
|
||||
src.co2 += t_co2
|
||||
target.co2 -= t_co2
|
||||
target.res_vars()
|
||||
return
|
||||
turf_take_filter3(var/turf/target as turf, amount)
|
||||
if (((!( istype(target, /turf) ) && !( istype(target, /obj/move) )) || !( amount )))
|
||||
return
|
||||
if (locate(/obj/move, target))
|
||||
target = locate(/obj/move, target)
|
||||
var/t1 = target.oxygen + target.n2 + target.poison + target.sl_gas
|
||||
if (!( t1 ))
|
||||
return
|
||||
var/t2 = src.oxygen + src.n2 + src.plasma + src.sl_gas
|
||||
if (amount > 0)
|
||||
if ((src.maximum > 0 && (src.maximum - t2) < amount))
|
||||
amount = src.maximum - t2
|
||||
else
|
||||
amount = src.oxygen + src.n2 + src.plasma + src.sl_gas
|
||||
if (amount > t1)
|
||||
amount = t1
|
||||
var/turf_total = target.oxygen + target.n2 + target.poison + target.sl_gas
|
||||
var/heat_gain = (turf_total ? amount * target.temp : 0)
|
||||
var/t_oxygen = amount * target.co2 / t1
|
||||
var/t_n2 = amount * target.n2 / t1
|
||||
var/t_poison = amount * target.poison / t1
|
||||
var/t_sl_gas = amount * target.sl_gas / t1
|
||||
if(t2+amount>0)
|
||||
temperature = (temperature*t2 + heat_gain * TURF_TAKE_FRAC)/(t2+amount)
|
||||
src.oxygen += t_oxygen
|
||||
src.n2 += t_n2
|
||||
src.plasma += t_poison
|
||||
src.sl_gas += t_sl_gas
|
||||
target.oxygen -= t_oxygen
|
||||
target.n2 -= t_n2
|
||||
target.poison -= t_poison
|
||||
target.sl_gas -= t_sl_gas
|
||||
target.res_vars()
|
||||
return
|
||||
turf_take_filter4(var/turf/target as turf, amount)
|
||||
if (((!( istype(target, /turf) ) && !( istype(target, /obj/move) )) || !( amount )))
|
||||
return
|
||||
if (locate(/obj/move, target))
|
||||
target = locate(/obj/move, target)
|
||||
var/t1 = target.co2 + target.poison + target.sl_gas
|
||||
if (!( t1 ))
|
||||
return
|
||||
var/t2 = src.co2 + src.plasma + src.sl_gas
|
||||
if (amount > 0)
|
||||
if ((src.maximum > 0 && (src.maximum - t2) < amount))
|
||||
amount = src.maximum - t2
|
||||
else
|
||||
amount = src.co2 + src.plasma + src.sl_gas
|
||||
if (amount > t1)
|
||||
amount = t1
|
||||
var/turf_total = target.co2 + src.plasma + src.sl_gas
|
||||
var/heat_gain = (turf_total ? amount * target.temp : 0)
|
||||
var/t_co2 = amount * target.co2 / t1
|
||||
var/t_poison = amount * target.poison / t1
|
||||
var/t_sl_gas = amount * target.sl_gas / t1
|
||||
if(t2+amount>0)
|
||||
temperature = (temperature*t2 + heat_gain * TURF_TAKE_FRAC)/(t2+amount)
|
||||
src.co2 += t_co2
|
||||
src.plasma += t_poison
|
||||
src.sl_gas += t_sl_gas
|
||||
target.co2 -= t_co2
|
||||
target.poison -= t_poison
|
||||
target.sl_gas -= t_sl_gas
|
||||
target.res_vars()
|
||||
return
|
||||
turf_take_filter5(var/turf/target as turf, amount)
|
||||
if (((!( istype(target, /turf) ) && !( istype(target, /obj/move) )) || !( amount )))
|
||||
return
|
||||
if (locate(/obj/move, target))
|
||||
target = locate(/obj/move, target)
|
||||
var/t1 = target.co2 + target.poison + target.sl_gas + target.oxygen + target.n2
|
||||
if (!( t1 ))
|
||||
return
|
||||
var/t2 = src.co2 + src.plasma + src.sl_gas + src.oxygen + src.n2
|
||||
if (amount > 0)
|
||||
if ((src.maximum > 0 && (src.maximum - t2) < amount))
|
||||
amount = src.maximum - t2
|
||||
else
|
||||
amount = src.co2 + src.plasma + src.sl_gas + src.oxygen + src.n2
|
||||
if (amount > t1)
|
||||
amount = t1
|
||||
var/turf_total = target.co2 + src.plasma + src.sl_gas + target.oxygen + target.n2
|
||||
var/heat_gain = (turf_total ? amount * target.temp : 0)
|
||||
var/t_co2 = amount * target.co2 / t1
|
||||
var/t_poison = amount * target.poison / t1
|
||||
var/t_sl_gas = amount * target.sl_gas / t1
|
||||
var/t_oxygen = amount * target.co2 / t1
|
||||
var/t_n2 = amount * target.n2 / t1
|
||||
if(t2+amount>0)
|
||||
temperature = (temperature*t2 + heat_gain * TURF_TAKE_FRAC)/(t2+amount)
|
||||
src.oxygen += t_oxygen
|
||||
src.n2 += t_n2
|
||||
src.co2 += t_co2
|
||||
src.plasma += t_poison
|
||||
src.sl_gas += t_sl_gas
|
||||
target.oxygen -= t_oxygen
|
||||
target.n2 -= t_n2
|
||||
target.co2 -= t_co2
|
||||
target.poison -= t_poison
|
||||
target.sl_gas -= t_sl_gas
|
||||
target.res_vars()
|
||||
return
|
||||
|
||||
|
||||
|
||||
obj/machinery/inletfiltered
|
||||
name = "Atmospheric Preservation Inlet"
|
||||
icon = 'pipes.dmi'
|
||||
icon_state = "inlet"
|
||||
desc = "A gas pipe inlet, fitted with a filter."
|
||||
anchored = 1
|
||||
p_dir = 2
|
||||
capmult = 2
|
||||
|
||||
var
|
||||
obj/machinery/node // the connected object
|
||||
obj/machinery/vnode // the connected pipeline (if node is a pipe)
|
||||
obj/substance/gas/gas // the gas reservoir
|
||||
obj/substance/gas/ngas // the new gas reservoir after calculating flow
|
||||
capacity = 6000000 // nominal gas capacity
|
||||
|
||||
cover = 1 //positive if cover is screwed on
|
||||
filtertype = 2 //0- No Filter, vent will not operate, 1- Nitrogen & Oxygen, 2 - co2, 3- Nitrogen, Oxygen, Plasma, n2o 4- co2, Plasma, n2o, 5- Hacked filter, allow all
|
||||
ofiltertype = 2 //Orig. filter type before tampering. Used so removed type 5 filters are repairable.
|
||||
orname //Orig. filter name before tampering.
|
||||
ordescription //Orig. description before tampering.
|
||||
|
||||
// Create a new inlet. Pipe connection direction is set same as icon direction, thus p_dir does not need to be set
|
||||
// when placing inlet on map. Create gas reservoir and register self with the gasflowlist
|
||||
|
||||
New()
|
||||
|
||||
..()
|
||||
p_dir = dir
|
||||
gas = new/obj/substance/gas(src)
|
||||
gas.maximum = capacity
|
||||
ngas = new/obj/substance/gas()
|
||||
gasflowlist += src
|
||||
|
||||
|
||||
// Find the connected pipe or machine
|
||||
|
||||
buildnodes()
|
||||
|
||||
var/turf/T = get_step(src.loc, src.dir)
|
||||
var/fdir = turn(src.p_dir, 180)
|
||||
|
||||
for(var/obj/machinery/M in T)
|
||||
if(M.p_dir & fdir)
|
||||
src.node = M
|
||||
break
|
||||
|
||||
if(node) vnode = node.getline()
|
||||
|
||||
return
|
||||
|
||||
|
||||
// Returns the gas fullness value. Capmult is 2 for inlets because they in effect have two connections: the pipe, and the turf
|
||||
|
||||
get_gas_val(from)
|
||||
return gas.tot_gas()/capmult
|
||||
|
||||
|
||||
// Return the internal gas reservoir
|
||||
|
||||
get_gas(from)
|
||||
return gas
|
||||
|
||||
|
||||
// After all machine process()es in world are complete, update the current gas levels with the new calculated levels
|
||||
|
||||
gas_flow()
|
||||
gas.replace_by(ngas)
|
||||
|
||||
|
||||
// Timed process. Calculate gas flow to and from the turf, and to and from the connected pipe
|
||||
|
||||
process()
|
||||
var/delta_gt
|
||||
|
||||
var/turf/T = src.loc
|
||||
|
||||
if(T && !T.density)
|
||||
if (src.filtertype == 0) //NO Filter. Will not run without filters.
|
||||
if (src.cover == 1) //Check if the filter has it's cover on.
|
||||
flick("inletnofilter",src) //Of so flick the warning button icon_state
|
||||
return
|
||||
else //If the cover is up
|
||||
return //Just return, don't flick the warning
|
||||
|
||||
|
||||
if (src.filtertype == 1) //Filter Type 1, Allow: Oxygen & Nitrogen
|
||||
flow_filter1(gas, ngas, T)
|
||||
if (src.filtertype == 2) //Filter Type 2, Allow: co2
|
||||
flow_filter2(gas, ngas, T)
|
||||
if (src.filtertype == 3) //Filter Type 3, Allow: Oxygen, Nitrogen, Plasma, n2o
|
||||
flow_filter3(gas, ngas, T)
|
||||
if (src.filtertype == 4) //Filter Type 4, Allow: co2, Plasma, n2o
|
||||
flow_filter4(gas, ngas, T)
|
||||
if (src.filtertype == 5) //Filter Type 5, Allow: All
|
||||
flow_filter5(gas, ngas, T)
|
||||
|
||||
if(vnode)
|
||||
delta_gt = FLOWFRAC * ( vnode.get_gas_val(src) - gas.tot_gas() / capmult)
|
||||
calc_delta( src, gas, ngas, vnode, delta_gt)
|
||||
else
|
||||
leak_to_turf()
|
||||
|
||||
|
||||
// If no node is present, leak the contents to the turf position the node would be.
|
||||
// note this is a leak from the node, not the inlet itself
|
||||
// thus acts as a link between the inlet turf and the turf in step(dir)
|
||||
|
||||
proc/leak_to_turf()
|
||||
|
||||
var/turf/T = get_step(src, dir)
|
||||
if(T && !T.density)
|
||||
flow_to_turf(gas, ngas, T)
|
||||
|
||||
//Remove Cover
|
||||
|
||||
attackby(obj/item/weapon/W, mob/user)
|
||||
if ( istype(W, /obj/item/weapon/screwdriver))
|
||||
if (src.cover == 1)
|
||||
user.show_message("\blue You carefully unscrew the cover to the inlet")
|
||||
src.cover = 0
|
||||
src.icon_state="inletopen"
|
||||
src.add_fingerprint(user)
|
||||
else
|
||||
user.show_message("\blue You carefully screw the cover back on the inlet")
|
||||
src.cover = 1
|
||||
src.icon_state="inlet"
|
||||
src.add_fingerprint(user)
|
||||
|
||||
|
||||
//Remove Filter
|
||||
|
||||
else
|
||||
if ( istype(W, /obj/item/weapon/wrench))
|
||||
if (src.cover == 1) //If it's covered, this won't happen.
|
||||
return
|
||||
else
|
||||
if (src.filtertype > 0)
|
||||
user.show_message("\blue You remove the bolts holding the filter and slide it out of place. The inlet shuts down.")
|
||||
if (src.filtertype == 1)
|
||||
new /obj/item/weapon/filter/filtertype1 (src.loc)
|
||||
if (src.filtertype == 2)
|
||||
new /obj/item/weapon/filter/filtertype2 (src.loc)
|
||||
if (src.filtertype == 3)
|
||||
new /obj/item/weapon/filter/filtertype3 (src.loc)
|
||||
if (src.filtertype == 4)
|
||||
new /obj/item/weapon/filter/filtertype4 (src.loc)
|
||||
if (src.filtertype == 5)
|
||||
var/obj/item/weapon/filter/filtertype5/I = new(src.loc) //Spawn Malf. Filter
|
||||
I.oftype = src.ofiltertype //Set filters original filter type, so it can be repaired.
|
||||
I.oname = src.orname //Set filters original name
|
||||
I.odesc = src.ordescription //Set filters original desc
|
||||
src.filtertype = 0
|
||||
src.add_fingerprint(user)
|
||||
else
|
||||
user.show_message("\blue There is no filter installed!")
|
||||
|
||||
//Apply filter
|
||||
//TODO: Maybe just store the physical filter instead of using variables. Maybe not :p I sort of like variables...
|
||||
else
|
||||
if ( istype(W, /obj/item/weapon/filter))
|
||||
if (src.cover == 1) //If it's covered this won't happen.
|
||||
return
|
||||
else
|
||||
if (src.filtertype == 0)
|
||||
user.show_message("\blue You slide the filter into position and tighten the bolts. The inlet starts up.")
|
||||
src.filtertype = W:ftype //Set the vent to the correct filter status
|
||||
src.ofiltertype = W:oftype //Store filter's original filter type.
|
||||
src.orname = W:oname //Store filter's original name.
|
||||
src.ordescription = W:odesc //Store filter's original description.
|
||||
src.add_fingerprint(user)
|
||||
del (W)
|
||||
else
|
||||
user.show_message("\blue There is already a filter installed!")
|
||||
@@ -389,3 +389,191 @@ obj/machinery/pipes
|
||||
icon = 'hi_pipe.dmi'
|
||||
density = 1
|
||||
capacity = 1.8E7
|
||||
|
||||
|
||||
obj/machinery/pump
|
||||
name = "Gas Pump"
|
||||
desc = "A gas pump"
|
||||
icon = 'pipes.dmi'
|
||||
icon_state = "one-way"
|
||||
anchored = 1
|
||||
density = 0
|
||||
capmult = 1
|
||||
|
||||
var
|
||||
status = 0 // 0 = off, 1 = on
|
||||
rate = 400000
|
||||
maxrate = 1e22
|
||||
|
||||
obj/substance/gas/gas1 = null
|
||||
obj/substance/gas/ngas1 = null
|
||||
|
||||
obj/substance/gas/gas2 = null
|
||||
obj/substance/gas/ngas2 = null
|
||||
|
||||
capacity = 1e22
|
||||
|
||||
obj/machinery/node1 = null // the physical pipe object to the south
|
||||
obj/machinery/node2 = null // the physical pipe object to the north
|
||||
|
||||
obj/machinery/vnode1 // the pipeline object
|
||||
obj/machinery/vnode2 // the pipeline object
|
||||
|
||||
|
||||
New()
|
||||
..()
|
||||
gas1 = new/obj/substance/gas(src)
|
||||
gas1.maximum = capacity
|
||||
gas2 = new/obj/substance/gas(src)
|
||||
gas2.maximum = capacity
|
||||
|
||||
ngas1 = new/obj/substance/gas()
|
||||
ngas2 = new/obj/substance/gas()
|
||||
|
||||
gasflowlist += src
|
||||
|
||||
proc/update()
|
||||
p_dir = text2num(icon_state)
|
||||
|
||||
buildnodes()
|
||||
var/turf/n1
|
||||
var/turf/n2
|
||||
if (src.dir == 1)
|
||||
n1 = get_step(src, SOUTH)
|
||||
n2 = get_step(src, NORTH)
|
||||
if (src.dir == 8)
|
||||
n1 = get_step(src, EAST)
|
||||
n2 = get_step(src, WEST)
|
||||
if (src.dir == 2)
|
||||
n1 = get_step(src, NORTH)
|
||||
n2 = get_step(src, SOUTH)
|
||||
if (src.dir == 4)
|
||||
n1 = get_step(src, WEST)
|
||||
n2 = get_step(src, EAST)
|
||||
for(var/obj/machinery/M in n1)
|
||||
|
||||
// if(M && (M.p_dir & 1))
|
||||
node1 = M
|
||||
break
|
||||
|
||||
for(var/obj/machinery/M in n2)
|
||||
|
||||
// if(M && (M.p_dir & 2))
|
||||
node2 = M
|
||||
break
|
||||
|
||||
|
||||
if(node1) vnode1 = node1.getline()
|
||||
|
||||
if(node2) vnode2 = node2.getline()
|
||||
|
||||
|
||||
|
||||
/* proc/control(var/on, var/prate)
|
||||
|
||||
rate = prate/100*maxrate
|
||||
|
||||
if(status == 1)
|
||||
if(!on)
|
||||
status = 2
|
||||
spawn(30)
|
||||
if(status == 2) //Most of the pump code is shamefully swiped and hacked from circulators :p
|
||||
status = 0
|
||||
// updateicon()
|
||||
else if(status == 0)
|
||||
if(on)
|
||||
status = 1
|
||||
else // status ==2
|
||||
if(on)
|
||||
status = 1*/
|
||||
|
||||
|
||||
|
||||
|
||||
gas_flow()
|
||||
|
||||
gas1.replace_by(ngas1)
|
||||
gas2.replace_by(ngas2)
|
||||
|
||||
|
||||
|
||||
process()
|
||||
|
||||
if(! (stat & NOPOWER) )
|
||||
if(status==1 || status==2)
|
||||
gas2.transfer_from(gas1, 1e22)
|
||||
use_power(rate/capacity * 100)
|
||||
ngas1.replace_by(gas1)
|
||||
ngas2.replace_by(gas2)
|
||||
|
||||
|
||||
// now do standard gas flow process
|
||||
|
||||
var/delta_gt
|
||||
|
||||
if(vnode1)
|
||||
delta_gt = FLOWFRAC * ( vnode1.get_gas_val(src) - gas1.tot_gas() / capmult)
|
||||
calc_delta( src, gas1, ngas1, vnode1, delta_gt)
|
||||
else
|
||||
leak_to_turf(1)
|
||||
|
||||
if(vnode2)
|
||||
delta_gt = FLOWFRAC * ( vnode2.get_gas_val(src) - gas2.tot_gas() / capmult)
|
||||
calc_delta( src, gas2, ngas2, vnode2, delta_gt)
|
||||
else
|
||||
leak_to_turf(2)
|
||||
|
||||
|
||||
// If nothing connected to either pipe node, leak the gas to the turf instead
|
||||
|
||||
proc/leak_to_turf(var/port)
|
||||
|
||||
var/turf/T
|
||||
|
||||
switch(port)
|
||||
if(1)
|
||||
T = get_step(src, SOUTH)
|
||||
if(2)
|
||||
T = get_step(src, NORTH)
|
||||
|
||||
if(T.density)
|
||||
T = src.loc
|
||||
if(T.density)
|
||||
return
|
||||
|
||||
switch(port)
|
||||
if(1)
|
||||
flow_to_turf(gas1, ngas1, T)
|
||||
if(2)
|
||||
flow_to_turf(gas2, ngas2, T)
|
||||
|
||||
|
||||
// Get the current gas fill level. Note since we have two reservoirs, value depends on which node is enquiring
|
||||
|
||||
get_gas_val(from)
|
||||
|
||||
if(from == vnode1)
|
||||
return gas1.tot_gas()/capmult
|
||||
else
|
||||
return gas2.tot_gas()/capmult
|
||||
|
||||
|
||||
// Get the gas reservoir object connected to node "from"
|
||||
|
||||
get_gas(from)
|
||||
|
||||
if(from == vnode1)
|
||||
return gas1
|
||||
else
|
||||
return gas2
|
||||
|
||||
attack_hand(var/mob/user)
|
||||
|
||||
if (src.status == 0)
|
||||
user.show_message("\blue You activate the pump")
|
||||
src.status = 1
|
||||
src.rate = 1e22
|
||||
else
|
||||
user.show_message("\blue You deactivate the pump")
|
||||
src.status = 0
|
||||
src.rate = 400000
|
||||
|
||||
@@ -181,5 +181,4 @@ obj/machinery/valve
|
||||
flick("valve10", src)
|
||||
icon_state = "valve0"
|
||||
sleep(10)
|
||||
open = !open
|
||||
|
||||
open = !open
|
||||
@@ -93,8 +93,96 @@ obj/machinery/vent
|
||||
|
||||
|
||||
|
||||
obj/machinery/emergencyrelease
|
||||
|
||||
|
||||
name = "vent"
|
||||
icon = 'pipes.dmi'
|
||||
icon_state = "vent"
|
||||
desc = "An emergency release vent. Releases at 133% suggested mass content."
|
||||
anchored = 1
|
||||
p_dir = 2
|
||||
capmult = 2
|
||||
|
||||
var
|
||||
obj/machinery/node // the connected object
|
||||
obj/machinery/vnode // the connected pipeline (if node is a pipe)
|
||||
obj/substance/gas/gas // the gas reservoir
|
||||
obj/substance/gas/ngas // the new gas reservoir after calculating flow
|
||||
capacity = 6000000 // nominal gas capacity
|
||||
|
||||
|
||||
// Create a new vent. Pipe connection p_dir is calculated from icon dir, so p_dir does not need to be set on map.
|
||||
// Create the gas reservoir and register with the gasflowlist.
|
||||
|
||||
New()
|
||||
..()
|
||||
p_dir = dir
|
||||
gas = new/obj/substance/gas(src)
|
||||
gas.maximum = capacity
|
||||
ngas = new/obj/substance/gas()
|
||||
gasflowlist += src
|
||||
|
||||
|
||||
// Find the connected machine or pipe to the vent pipe.
|
||||
|
||||
buildnodes()
|
||||
var/turf/T = get_step(src.loc, src.dir)
|
||||
var/fdir = turn(src.p_dir, 180)
|
||||
|
||||
for(var/obj/machinery/M in T)
|
||||
if(M.p_dir & fdir)
|
||||
src.node = M
|
||||
break
|
||||
|
||||
if(node) vnode = node.getline()
|
||||
|
||||
return
|
||||
|
||||
|
||||
// Get the gas fullness value.
|
||||
|
||||
get_gas_val(from)
|
||||
return gas.tot_gas()/2
|
||||
|
||||
// Get the gas reservoir object
|
||||
|
||||
get_gas(from)
|
||||
return gas
|
||||
|
||||
|
||||
// Replace the gas level by the new level calculated in process()
|
||||
|
||||
gas_flow()
|
||||
gas.replace_by(ngas)
|
||||
|
||||
|
||||
// Timed process. Dump gas into turf, then do standard flow calc for connected pipe.
|
||||
|
||||
process()
|
||||
|
||||
var/delta_gt
|
||||
|
||||
var/turf/T = src.loc
|
||||
|
||||
if(gas.tot_gas() >= gas.maximum * 1.3)
|
||||
|
||||
delta_gt = FLOWFRAC * (gas.tot_gas() / capmult)
|
||||
ngas.turf_add(T, delta_gt)
|
||||
if(vnode)
|
||||
delta_gt = FLOWFRAC * ( vnode.get_gas_val(src) - gas.tot_gas() / capmult)
|
||||
calc_delta( src, gas, ngas, vnode, delta_gt)//, dbg)
|
||||
else
|
||||
leak_to_turf()
|
||||
|
||||
|
||||
// Leak from pipe to turf if no node connected
|
||||
|
||||
proc/leak_to_turf()
|
||||
|
||||
var/turf/T = get_step(src, dir)
|
||||
if(T && !T.density)
|
||||
flow_to_turf(gas, ngas, T)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user