Added Willox’s explosion code. It should make explosions faster than they have been lately.

Moved an unchecked file into unused, please put any unchecked files out of WIP or FEA into unused that way if you see an unchecked file you know it should be checked.  DM loves to uncheck files when you are messing around with folders in the editor.
Moved the old TEG defines into the proper files.
Commented out some old nonfunctioning FEA debug code.
Removed some commented out codechunks from FEA and attempted to clean up a few of the files a bit. 


git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3852 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
mport2004@gmail.com
2012-06-18 01:56:24 +00:00
parent b1394e315f
commit b6f8b3fb77
11 changed files with 1632 additions and 1498 deletions
+122 -111
View File
@@ -6,148 +6,159 @@
gen_amount = g
*/
/obj/machinery/power/generator
name = "thermoelectric generator"
desc = "It's a high efficiency thermoelectric generator."
icon_state = "teg"
anchored = 1
density = 1
/obj/machinery/power/generator/New()
..()
var/obj/machinery/atmospherics/binary/circulator/circ1
var/obj/machinery/atmospherics/binary/circulator/circ2
spawn(5)
circ1 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,WEST)
circ2 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,EAST)
var/lastgen = 0
var/lastgenlev = -1
if(circ1)
circ1.side = 1
circ1.update_icon()
if(circ2)
circ2.side = 2
circ2.update_icon()
if(!circ1 || !circ2)
stat |= BROKEN
New()
..()
updateicon()
spawn(5)
circ1 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,WEST)
circ2 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,EAST)
/obj/machinery/power/generator/proc/updateicon()
if(circ1)
circ1.side = 1
circ1.update_icon()
if(circ2)
circ2.side = 2
circ2.update_icon()
if(stat & (NOPOWER|BROKEN))
overlays = null
else
overlays = null
if(!circ1 || !circ2)
stat |= BROKEN
if(lastgenlev != 0)
overlays += image('power.dmi', "teg-op[lastgenlev]")
updateicon()
proc/updateicon()
if(stat & (NOPOWER|BROKEN))
overlays = null
else
overlays = null
if(lastgenlev != 0)
overlays += image('power.dmi', "teg-op[lastgenlev]")
#define GENRATE 800 // generator output coefficient from Q
/obj/machinery/power/generator/process()
process()
//world << "Generator process ran"
//world << "Generator process ran"
if(!circ1 || !circ2)
return
if(!circ1 || !circ2)
return
//world << "circ1 and circ2 pass"
//world << "circ1 and circ2 pass"
var/datum/gas_mixture/cold_air = circ1.return_transfer_air()
var/datum/gas_mixture/hot_air = circ2.return_transfer_air()
var/datum/gas_mixture/cold_air = circ1.return_transfer_air()
var/datum/gas_mixture/hot_air = circ2.return_transfer_air()
lastgen = 0
lastgen = 0
//world << "hot_air = [hot_air]; cold_air = [cold_air];"
//world << "hot_air = [hot_air]; cold_air = [cold_air];"
if(cold_air && hot_air)
if(cold_air && hot_air)
//world << "hot_air = [hot_air] temperature = [hot_air.temperature]; cold_air = [cold_air] temperature = [hot_air.temperature];"
//world << "hot_air = [hot_air] temperature = [hot_air.temperature]; cold_air = [cold_air] temperature = [hot_air.temperature];"
//world << "coldair and hotair pass"
var/cold_air_heat_capacity = cold_air.heat_capacity()
var/hot_air_heat_capacity = hot_air.heat_capacity()
//world << "coldair and hotair pass"
var/cold_air_heat_capacity = cold_air.heat_capacity()
var/hot_air_heat_capacity = hot_air.heat_capacity()
var/delta_temperature = hot_air.temperature - cold_air.temperature
var/delta_temperature = hot_air.temperature - cold_air.temperature
//world << "delta_temperature = [delta_temperature]; cold_air_heat_capacity = [cold_air_heat_capacity]; hot_air_heat_capacity = [hot_air_heat_capacity]"
//world << "delta_temperature = [delta_temperature]; cold_air_heat_capacity = [cold_air_heat_capacity]; hot_air_heat_capacity = [hot_air_heat_capacity]"
if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0)
var/efficiency = 0.65
if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0)
var/efficiency = 0.65
var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity+cold_air_heat_capacity)
var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity+cold_air_heat_capacity)
var/heat = energy_transfer*(1-efficiency)
lastgen = energy_transfer*efficiency
var/heat = energy_transfer*(1-efficiency)
lastgen = energy_transfer*efficiency
//world << "lastgen = [lastgen]; heat = [heat]; delta_temperature = [delta_temperature]; hot_air_heat_capacity = [hot_air_heat_capacity]; cold_air_heat_capacity = [cold_air_heat_capacity];"
//world << "lastgen = [lastgen]; heat = [heat]; delta_temperature = [delta_temperature]; hot_air_heat_capacity = [hot_air_heat_capacity]; cold_air_heat_capacity = [cold_air_heat_capacity];"
hot_air.temperature = hot_air.temperature - energy_transfer/hot_air_heat_capacity
cold_air.temperature = cold_air.temperature + heat/cold_air_heat_capacity
hot_air.temperature = hot_air.temperature - energy_transfer/hot_air_heat_capacity
cold_air.temperature = cold_air.temperature + heat/cold_air_heat_capacity
world << "POWER: [lastgen] W generated at [efficiency*100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]"
world << "POWER: [lastgen] W generated at [efficiency*100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]"
add_avail(lastgen)
// update icon overlays only if displayed level has changed
add_avail(lastgen)
// update icon overlays only if displayed level has changed
if(hot_air)
circ2.air2.merge(hot_air)
if(hot_air)
circ2.air2.merge(hot_air)
if(cold_air)
circ1.air2.merge(cold_air)
if(cold_air)
circ1.air2.merge(cold_air)
var/genlev = max(0, min( round(11*lastgen / 100000), 11))
if(genlev != lastgenlev)
lastgenlev = genlev
var/genlev = max(0, min( round(11*lastgen / 100000), 11))
if(genlev != lastgenlev)
lastgenlev = genlev
updateicon()
src.updateDialog()
attack_ai(mob/user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
attack_hand(mob/user)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
proc/interact(mob/user)
if ( (get_dist(src, user) > 1 ) && (!istype(user, /mob/living/silicon/ai)))
user.machine = null
user << browse(null, "window=teg")
return
user.machine = src
var/t = "<PRE><B>Thermo-Electric Generator</B><HR>"
t += "Output : [round(lastgen)] W<BR><BR>"
t += "<B>Cold loop</B><BR>"
t += "Temperature Inlet: [round(circ1.air1.temperature, 0.1)] K Outlet: [round(circ1.air2.temperature, 0.1)] K<BR>"
t += "Pressure Inlet: [round(circ1.air1.return_pressure(), 0.1)] kPa Outlet: [round(circ1.air2.return_pressure(), 0.1)] kPa<BR>"
t += "<B>Hot loop</B><BR>"
t += "Temperature Inlet: [round(circ2.air1.temperature, 0.1)] K Outlet: [round(circ2.air2.temperature, 0.1)] K<BR>"
t += "Pressure Inlet: [round(circ2.air1.return_pressure(), 0.1)] kPa Outlet: [round(circ2.air2.return_pressure(), 0.1)] kPa<BR>"
t += "<BR><HR><A href='?src=\ref[src];close=1'>Close</A>"
t += "</PRE>"
user << browse(t, "window=teg;size=460x300")
onclose(user, "teg")
return 1
Topic(href, href_list)
..()
if( href_list["close"] )
usr << browse(null, "window=teg")
usr.machine = null
return 0
return 1
power_change()
..()
updateicon()
src.updateDialog()
/obj/machinery/power/generator/attack_ai(mob/user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
/obj/machinery/power/generator/attack_hand(mob/user)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
/obj/machinery/power/generator/proc/interact(mob/user)
if ( (get_dist(src, user) > 1 ) && (!istype(user, /mob/living/silicon/ai)))
user.machine = null
user << browse(null, "window=teg")
return
user.machine = src
var/t = "<PRE><B>Thermo-Electric Generator</B><HR>"
t += "Output : [round(lastgen)] W<BR><BR>"
t += "<B>Cold loop</B><BR>"
t += "Temperature Inlet: [round(circ1.air1.temperature, 0.1)] K Outlet: [round(circ1.air2.temperature, 0.1)] K<BR>"
t += "Pressure Inlet: [round(circ1.air1.return_pressure(), 0.1)] kPa Outlet: [round(circ1.air2.return_pressure(), 0.1)] kPa<BR>"
t += "<B>Hot loop</B><BR>"
t += "Temperature Inlet: [round(circ2.air1.temperature, 0.1)] K Outlet: [round(circ2.air2.temperature, 0.1)] K<BR>"
t += "Pressure Inlet: [round(circ2.air1.return_pressure(), 0.1)] kPa Outlet: [round(circ2.air2.return_pressure(), 0.1)] kPa<BR>"
t += "<BR><HR><A href='?src=\ref[src];close=1'>Close</A>"
t += "</PRE>"
user << browse(t, "window=teg;size=460x300")
onclose(user, "teg")
return 1
/obj/machinery/power/generator/Topic(href, href_list)
..()
if( href_list["close"] )
usr << browse(null, "window=teg")
usr.machine = null
return 0
return 1
/obj/machinery/power/generator/power_change()
..()
updateicon()
+99 -85
View File
@@ -1,128 +1,142 @@
/obj/machinery/power/generator_type2/New()
..()
/obj/machinery/power/generator_type2
name = "thermoelectric generator"
desc = "It's a high efficiency thermoelectric generator."
icon_state = "teg"
anchored = 1
density = 1
spawn(5)
input1 = locate(/obj/machinery/atmospherics/unary/generator_input) in get_step(src,WEST)
input2 = locate(/obj/machinery/atmospherics/unary/generator_input) in get_step(src,EAST)
if(!input1 || !input2)
stat |= BROKEN
var/obj/machinery/atmospherics/unary/generator_input/input1
var/obj/machinery/atmospherics/unary/generator_input/input2
updateicon()
var/lastgen = 0
var/lastgenlev = -1
/obj/machinery/power/generator_type2/proc/updateicon()
if(stat & (NOPOWER|BROKEN))
overlays = null
else
overlays = null
New()
..()
spawn(5)
input1 = locate(/obj/machinery/atmospherics/unary/generator_input) in get_step(src,WEST)
input2 = locate(/obj/machinery/atmospherics/unary/generator_input) in get_step(src,EAST)
if(!input1 || !input2)
stat |= BROKEN
updateicon()
if(lastgenlev != 0)
overlays += image('power.dmi', "teg-op[lastgenlev]")
proc/updateicon()
if(stat & (NOPOWER|BROKEN))
overlays = null
else
overlays = null
if(lastgenlev != 0)
overlays += image('power.dmi', "teg-op[lastgenlev]")
#define GENRATE 800 // generator output coefficient from Q
/obj/machinery/power/generator_type2/process()
if(!input1 || !input2)
return
process()
if(!input1 || !input2)
return
var/datum/gas_mixture/air1 = input1.return_exchange_air()
var/datum/gas_mixture/air2 = input2.return_exchange_air()
var/datum/gas_mixture/air1 = input1.return_exchange_air()
var/datum/gas_mixture/air2 = input2.return_exchange_air()
lastgen = 0
lastgen = 0
if(air1 && air2)
var/datum/gas_mixture/hot_air = air1
var/datum/gas_mixture/cold_air = air2
if(hot_air.temperature < cold_air.temperature)
hot_air = air2
cold_air = air1
if(air1 && air2)
var/datum/gas_mixture/hot_air = air1
var/datum/gas_mixture/cold_air = air2
if(hot_air.temperature < cold_air.temperature)
hot_air = air2
cold_air = air1
var/hot_air_heat_capacity = hot_air.heat_capacity()
var/cold_air_heat_capacity = cold_air.heat_capacity()
var/hot_air_heat_capacity = hot_air.heat_capacity()
var/cold_air_heat_capacity = cold_air.heat_capacity()
var/delta_temperature = hot_air.temperature - cold_air.temperature
var/delta_temperature = hot_air.temperature - cold_air.temperature
if(delta_temperature > 1 && cold_air_heat_capacity > 0.01 && hot_air_heat_capacity > 0.01)
var/efficiency = (1 - cold_air.temperature/hot_air.temperature)*0.65 //65% of Carnot efficiency
if(delta_temperature > 1 && cold_air_heat_capacity > 0.01 && hot_air_heat_capacity > 0.01)
var/efficiency = (1 - cold_air.temperature/hot_air.temperature)*0.65 //65% of Carnot efficiency
var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity+cold_air_heat_capacity)
var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity+cold_air_heat_capacity)
var/heat = energy_transfer*(1-efficiency)
lastgen = energy_transfer*efficiency
var/heat = energy_transfer*(1-efficiency)
lastgen = energy_transfer*efficiency
hot_air.temperature = hot_air.temperature - energy_transfer/hot_air_heat_capacity
cold_air.temperature = cold_air.temperature + heat/cold_air_heat_capacity
hot_air.temperature = hot_air.temperature - energy_transfer/hot_air_heat_capacity
cold_air.temperature = cold_air.temperature + heat/cold_air_heat_capacity
world << "POWER: [lastgen] W generated at [efficiency*100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]"
world << "POWER: [lastgen] W generated at [efficiency*100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]"
if(input1.network)
input1.network.update = 1
if(input1.network)
input1.network.update = 1
if(input2.network)
input2.network.update = 1
if(input2.network)
input2.network.update = 1
add_avail(lastgen)
// update icon overlays only if displayed level has changed
add_avail(lastgen)
// update icon overlays only if displayed level has changed
var/genlev = max(0, min( round(11*lastgen / 100000), 11))
if(genlev != lastgenlev)
lastgenlev = genlev
updateicon()
var/genlev = max(0, min( round(11*lastgen / 100000), 11))
if(genlev != lastgenlev)
lastgenlev = genlev
updateicon()
src.updateDialog()
src.updateDialog()
/obj/machinery/power/generator_type2/attack_ai(mob/user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
attack_ai(mob/user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
/obj/machinery/power/generator_type2/attack_hand(mob/user)
add_fingerprint(user)
attack_hand(mob/user)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
proc/interact(mob/user)
if ( (get_dist(src, user) > 1 ) && (!istype(user, /mob/living/silicon/ai)))
user.machine = null
user << browse(null, "window=teg")
return
/obj/machinery/power/generator_type2/proc/interact(mob/user)
if ( (get_dist(src, user) > 1 ) && (!istype(user, /mob/living/silicon/ai)))
user.machine = null
user << browse(null, "window=teg")
return
user.machine = src
user.machine = src
var/t = "<PRE><B>Thermo-Electric Generator</B><HR>"
var/t = "<PRE><B>Thermo-Electric Generator</B><HR>"
t += "Output : [round(lastgen)] W<BR><BR>"
t += "Output : [round(lastgen)] W<BR><BR>"
t += "<B>Cold loop</B><BR>"
t += "Temperature: [round(input1.air_contents.temperature, 0.1)] K<BR>"
t += "Pressure: [round(input1.air_contents.return_pressure(), 0.1)] kPa<BR>"
t += "<B>Cold loop</B><BR>"
t += "Temperature: [round(input1.air_contents.temperature, 0.1)] K<BR>"
t += "Pressure: [round(input1.air_contents.return_pressure(), 0.1)] kPa<BR>"
t += "<B>Hot loop</B><BR>"
t += "Temperature: [round(input2.air_contents.temperature, 0.1)] K<BR>"
t += "Pressure: [round(input2.air_contents.return_pressure(), 0.1)] kPa<BR>"
t += "<B>Hot loop</B><BR>"
t += "Temperature: [round(input2.air_contents.temperature, 0.1)] K<BR>"
t += "Pressure: [round(input2.air_contents.return_pressure(), 0.1)] kPa<BR>"
t += "<BR><HR><A href='?src=\ref[src];close=1'>Close</A>"
t += "<BR><HR><A href='?src=\ref[src];close=1'>Close</A>"
t += "</PRE>"
user << browse(t, "window=teg;size=460x300")
onclose(user, "teg")
return 1
t += "</PRE>"
user << browse(t, "window=teg;size=460x300")
onclose(user, "teg")
return 1
/obj/machinery/power/generator_type2/Topic(href, href_list)
..()
Topic(href, href_list)
..()
if( href_list["close"] )
usr << browse(null, "window=teg")
usr.machine = null
return 0
if( href_list["close"] )
usr << browse(null, "window=teg")
usr.machine = null
return 0
return 1
return 1
/obj/machinery/power/generator_type2/power_change()
..()
updateicon()
power_change()
..()
updateicon()