Merge pull request #2038 from EuroNumbers/master

Pushing Turbine to be included in compile. Fixes interact() compile problem.
This commit is contained in:
Cheridan
2013-12-16 12:30:45 -08:00
2 changed files with 70 additions and 118 deletions
+69 -118
View File
@@ -6,8 +6,8 @@
// Not everything is included yet so the turbine can run out of fuel quiet quickly. The best thing about the turbine is that even
// though something is on fire that passes through it, it won't be on fire as it passes out of it. So the exhaust fumes can still
// containt unreacted fuel - plasma and oxygen that needs to be filtered out and re-routed back. This of course requires smart piping
// For a computer to work with the turbine the compressor requires a comp_id matching with the turbine computer's id. This will be
// subjected to a change in the near future mind you. Right now this method of generating power is a good backup but don't expect it
// For a computer to work with the turbine the compressor requires a comp_id matching with the turbine computer's id. This will be
// subjected to a change in the near future mind you. Right now this method of generating power is a good backup but don't expect it
// become a main power source unless some work is done. Have fun. At 50k RPM it generates 60k power. So more than one turbine is needed!
//
// - Numbers
@@ -38,6 +38,7 @@
var/capacity = 1e6
var/comp_id = 0
/obj/machinery/power/turbine
name = "gas turbine generator"
desc = "A gas turbine used for backup power generation."
@@ -45,7 +46,7 @@
icon_state = "turbine"
anchored = 1
density = 1
var/opened = 0
var/opened = 0
var/obj/machinery/compressor/compressor
directwired = 1
var/turf/simulated/outturf
@@ -85,8 +86,8 @@
// OLD FIX - explanation given down below.
// /obj/machinery/power/compressor/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
// return !density
/obj/machinery/power/compressor/CanAtmosPass(var/turf/T)
return !density
@@ -101,9 +102,9 @@
return
rpm = 0.9* rpm + 0.1 * rpmtarget
var/datum/gas_mixture/environment = inturf.return_air()
// It's a simplified version taking only 1/10 of the moles from the turf nearby. It should be later changed into a better version
var/transfer_moles = environment.total_moles()/10
//var/transfer_moles = rpm/10000*capacity
var/datum/gas_mixture/removed = inturf.remove_air(transfer_moles)
@@ -134,8 +135,8 @@
overlays += image('icons/obj/pipes.dmi', "comp-o1", FLY_LAYER)
//TODO: DEFERRED
// These are crucial to working of a turbine - the stats modify the power output. TurbGenQ modifies how much raw energy can you get from
// rpms, TurbGenG modifies the shape of the curve - the lower the value the less straight the curve is.
// These are crucial to working of a turbine - the stats modify the power output. TurbGenQ modifies how much raw energy can you get from
// rpms, TurbGenG modifies the shape of the curve - the lower the value the less straight the curve is.
#define TURBPRES 9000000
#define TURBGENQ 100000
@@ -144,7 +145,7 @@
/obj/machinery/power/turbine/New()
..()
// The outlet is pointed at the direction of the turbine component
// The outlet is pointed at the direction of the turbine component
outturf = get_step(src, dir)
@@ -171,26 +172,27 @@
/obj/machinery/power/turbine/process()
if(!compressor.starter)
return
overlays.Cut()
if(stat & BROKEN)
return
if(!compressor)
stat |= BROKEN
return
// This is the power generation function. If anything is needed it's good to plot it in EXCEL before modifying
// the TURBGENQ and TURBGENG values
if(!compressor.starter)
return
overlays.Cut()
// This is the power generation function. If anything is needed it's good to plot it in EXCEL before modifying
// the TURBGENQ and TURBGENG values
lastgen = ((compressor.rpm / TURBGENQ)**TURBGENG) *TURBGENQ
add_avail(lastgen)
// Weird function but it works. Should be something else...
var/newrpm = ((compressor.gas_contained.temperature) * compressor.gas_contained.total_moles())/4
newrpm = max(0, newrpm)
if(!compressor.starter || newrpm > 1000)
@@ -206,72 +208,55 @@
if(lastgen > 100)
overlays += image('icons/obj/pipes.dmi', "turb-o", FLY_LAYER)
for(var/mob/M in viewers(1, src))
if ((M.client && M.machine == src))
src.interact(M)
AutoUpdateAI(src)
// AI can't use it!
/obj/machinery/power/turbine/attack_ai(mob/user)
if(stat & (BROKEN|NOPOWER))
return
interact(user)
updateDialog()
/obj/machinery/power/turbine/attack_hand(mob/user)
add_fingerprint(user)
if(..())
return
if(stat & (BROKEN|NOPOWER))
return
interact(user)
interact(user)
/obj/machinery/power/turbine/proc/interact(mob/user)
if ( (get_dist(src, user) > 1 ) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon/ai)) )
user.machine = null
user << browse(null, "window=turbine")
return
/obj/machinery/power/turbine/interact(mob/user)
user.machine = src
if ( (get_dist(src, user) > 1 ) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon/ai)) )
user.unset_machine(src)
user << browse(null, "window=turbine")
return
var/t = "<TT><B>Gas Turbine Generator</B><HR><PRE>"
var/t = "<TT><B>Gas Turbine Generator</B><HR><PRE>"
t += "Generated power : [round(lastgen)] W<BR><BR>"
t += "Generated power : [round(lastgen)] W<BR><BR>"
t += "Turbine: [round(compressor.rpm)] RPM<BR>"
t += "Turbine: [round(compressor.rpm)] RPM<BR>"
t += "Starter: [ compressor.starter ? "<A href='?src=\ref[src];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=\ref[src];str=1'>On</A>"]"
t += "Starter: [ compressor.starter ? "<A href='?src=\ref[src];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=\ref[src];str=1'>On</A>"]"
t += "</PRE><HR><A href='?src=\ref[src];close=1'>Close</A>"
t += "</PRE><HR><A href='?src=\ref[src];close=1'>Close</A>"
t += "</TT>"
user << browse(t, "window=turbine")
onclose(user, "turbine")
t += "</TT>"
var/datum/browser/popup = new(user, "turbine", name)
popup.set_content(t)
popup.open()
return
return
/obj/machinery/power/turbine/Topic(href, href_list)
if(..())
return
if(..())
return
if( href_list["close"] )
usr << browse(null, "window=turbine")
usr.machine = null
return
if( href_list["close"] )
usr << browse(null, "window=turbine")
usr.unset_machine(src)
return
else if( href_list["str"] )
compressor.starter = !compressor.starter
else if( href_list["str"] )
if(compressor)
compressor.starter = !compressor.starter
spawn(0)
for(var/mob/M in viewers(1, src))
if ((M.client && M.machine == src))
src.interact(M)
updateDialog()
@@ -290,80 +275,46 @@
for(var/obj/machinery/compressor/C in world)
if(id == C.comp_id)
compressor = C
/obj/machinery/computer/turbine_computer/attackby(I as obj, user as mob)
if(istype(I, /obj/item/weapon/screwdriver))
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
if(do_after(user, 20))
if (src.stat & BROKEN)
user << "\blue The broken glass falls out."
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
new /obj/item/weapon/shard( src.loc )
var/obj/item/weapon/circuitboard/turbine_control/M = new /obj/item/weapon/circuitboard/turbine_control( A )
for (var/obj/C in src)
C.loc = src.loc
M.id = src.id
A.circuit = M
A.state = 3
A.icon_state = "3"
A.anchored = 1
del(src)
else
user << "\blue You disconnect the monitor."
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
var/obj/item/weapon/circuitboard/turbine_control/M = new /obj/item/weapon/circuitboard/turbine_control( A )
for (var/obj/C in src)
C.loc = src.loc
M.id = src.id
A.circuit = M
A.state = 4
A.icon_state = "4"
A.anchored = 1
del(src)
else
src.attack_hand(user)
return
/obj/machinery/computer/turbine_computer/attack_hand(var/mob/user as mob)
user.machine = src
if(..())
return
interact(user)
/obj/machinery/computer/turbine_computer/interact(mob/user)
var/dat
if(src.compressor)
if(compressor)
dat += {"<BR><B>Gas turbine remote control system</B><HR>
\nTurbine status: [ src.compressor.starter ? "<A href='?src=\ref[src];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=\ref[src];str=1'>On</A>"]
\n<BR>
\nTurbine speed: [src.compressor.rpm]rpm<BR>
\nPower currently being generated: [src.compressor.turbine.lastgen]W<BR>
\nInternal gas temperature: [src.compressor.gas_contained.temperature]K<BR>
\n</PRE><HR><A href='?src=\ref[src];view=1'>View</A>
\n</PRE><HR><A href='?src=\ref[src];close=1'>Close</A>
\n<BR>
\n"}
else
dat += "\red<B>No compatible attached compressor found."
user << browse(dat, "window=computer;size=400x500")
onclose(user, "computer")
var/datum/browser/popup = new(user, "turbinecomputer", name)
popup.set_content(dat)
popup.open()
return
/obj/machinery/computer/turbine_computer/Topic(href, href_list)
if(..())
return
if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon)))
usr.machine = src
if( href_list["view"] )
usr.client.eye = src.compressor
else if( href_list["str"] )
src.compressor.starter = !src.compressor.starter
else if( href_list["close"] )
usr << browse(null, "window=computer")
usr.machine = null
return
else if( href_list["str"] )
if(compressor)
compressor.starter = !compressor.starter
else if( href_list["close"] )
usr << browse(null, "window=turbinecomputer")
usr.unset_machine(src)
return
src.add_fingerprint(usr)
src.updateUsrDialog()
return