Initial Commit

This commit is contained in:
skull132
2014-03-11 09:03:52 +02:00
commit a8d9450c7e
3486 changed files with 415920 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
//This file was auto-corrected by findeclaration.exe on 29/05/2012 15:03:05
#define STATE_DEFAULT 1
#define STATE_INJECTOR 2
#define STATE_ENGINE 3
/obj/machinery/computer/am_engine
name = "Antimatter Engine Console"
icon = 'icons/obj/stationobjs.dmi'
icon_state = "comm_computer"
req_access = list(ACCESS_ENGINE)
var/engine_id = 0
var/authenticated = 0
var/obj/machinery/power/am_engine/engine/connected_E = null
var/obj/machinery/power/am_engine/injector/connected_I = null
var/state = STATE_DEFAULT
/obj/machinery/computer/am_engine/New()
..()
spawn( 24 )
for(var/obj/machinery/power/am_engine/engine/E in world)
if(E.engine_id == src.engine_id)
src.connected_E = E
for(var/obj/machinery/power/am_engine/injector/I in world)
if(I.engine_id == src.engine_id)
src.connected_I = I
return
/obj/machinery/computer/am_engine/Topic(href, href_list)
if(..())
return
usr.machine = src
if(!href_list["operation"])
return
switch(href_list["operation"])
// main interface
if("activate")
src.connected_E.engine_process()
if("engine")
src.state = STATE_ENGINE
if("injector")
src.state = STATE_INJECTOR
if("main")
src.state = STATE_DEFAULT
if("login")
var/mob/M = usr
var/obj/item/weapon/card/id/I = M.equipped()
if (I && istype(I))
if(src.check_access(I))
authenticated = 1
if("deactivate")
src.connected_E.stopping = 1
if("logout")
authenticated = 0
src.updateUsrDialog()
/obj/machinery/computer/am_engine/attack_ai(var/mob/user as mob)
return src.attack_hand(user)
/obj/machinery/computer/am_engine/attack_paw(var/mob/user as mob)
return src.attack_hand(user)
/obj/machinery/computer/am_engine/attack_hand(var/mob/user as mob)
if(..())
return
user.machine = src
var/dat = "<head><title>Engine Computer</title></head><body>"
switch(src.state)
if(STATE_DEFAULT)
if (src.authenticated)
dat += "<BR>\[ <A HREF='?src=\ref[src];operation=logout'>Log Out</A> \]<br>"
dat += "<BR>\[ <A HREF='?src=\ref[src];operation=engine'>Engine Menu</A> \]"
dat += "<BR>\[ <A HREF='?src=\ref[src];operation=injector'>Injector Menu</A> \]"
else
dat += "<BR>\[ <A HREF='?src=\ref[src];operation=login'>Log In</A> \]"
if(STATE_INJECTOR)
if(src.connected_I.injecting)
dat += "<BR>\[ Injecting \]<br>"
else
dat += "<BR>\[ Injecting not in progress \]<br>"
if(STATE_ENGINE)
if(src.connected_E.stopping)
dat += "<BR>\[ STOPPING \]"
else if(src.connected_E.operating && !src.connected_E.stopping)
dat += "<BR>\[ <A HREF='?src=\ref[src];operation=deactivate'>Emergency Stop</A> \]"
else
dat += "<BR>\[ <A HREF='?src=\ref[src];operation=activate'>Activate Engine</A> \]"
dat += "<BR>Contents:<br>[src.connected_E.H_fuel]kg of Hydrogen<br>[src.connected_E.antiH_fuel]kg of Anti-Hydrogen<br>"
dat += "<BR>\[ [(src.state != STATE_DEFAULT) ? "<A HREF='?src=\ref[src];operation=main'>Main Menu</A> | " : ""]<A HREF='?src=\ref[user];mach_close=communications'>Close</A> \]"
user << browse(dat, "window=communications;size=400x500")
onclose(user, "communications")
@@ -0,0 +1,41 @@
/obj/item/weapon/am_containment
name = "antimatter containment jar"
desc = "Holds antimatter."
icon = 'icons/obj/machines/antimatter.dmi'
icon_state = "jar"
density = 0
anchored = 0
force = 8
throwforce = 10
throw_speed = 1
throw_range = 2
var/fuel = 10000
var/fuel_max = 10000//Lets try this for now
var/stability = 100//TODO: add all the stability things to this so its not very safe if you keep hitting in on things
/obj/item/weapon/am_containment/ex_act(severity)
switch(severity)
if(1.0)
explosion(get_turf(src), 1, 2, 3, 5)//Should likely be larger but this works fine for now I guess
if(src)
del(src)
return
if(2.0)
if(prob((fuel/10)-stability))
explosion(get_turf(src), 1, 2, 3, 5)
if(src)
del(src)
return
stability -= 40
if(3.0)
stability -= 20
//check_stability()
return
/obj/item/weapon/am_containment/proc/usefuel(var/wanted)
if(fuel < wanted)
wanted = fuel
fuel -= wanted
return wanted
+339
View File
@@ -0,0 +1,339 @@
/obj/machinery/power/am_control_unit
name = "antimatter control unit"
desc = "This device injects antimatter into connected shielding units, the more antimatter injected the more power produced. Wrench the device to set it up."
icon = 'icons/obj/machines/antimatter.dmi'
icon_state = "control"
anchored = 1
density = 1
use_power = 1
idle_power_usage = 100
active_power_usage = 1000
var/list/obj/machinery/am_shielding/linked_shielding
var/list/obj/machinery/am_shielding/linked_cores
var/obj/item/weapon/am_containment/fueljar
var/update_shield_icons = 0
var/stability = 100
var/exploding = 0
var/active = 0//On or not
var/fuel_injection = 2//How much fuel to inject
var/shield_icon_delay = 0//delays resetting for a short time
var/reported_core_efficiency = 0
var/power_cycle = 0
var/power_cycle_delay = 4//How many ticks till produce_power is called
var/stored_core_stability = 0
var/stored_core_stability_delay = 0
var/stored_power = 0//Power to deploy per tick
/obj/machinery/power/am_control_unit/New()
..()
linked_shielding = list()
linked_cores = list()
/obj/machinery/power/am_control_unit/Del()//Perhaps damage and run stability checks rather than just del on the others
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
del(AMS)
..()
/obj/machinery/power/am_control_unit/process()
if(exploding)
explosion(get_turf(src),8,12,18,12)
if(src) del(src)
if(update_shield_icons && !shield_icon_delay)
check_shield_icons()
update_shield_icons = 0
if(stat & (NOPOWER|BROKEN) || !active)//can update the icons even without power
return
if(!fueljar)//No fuel but we are on, shutdown
toggle_power()
//Angry buzz or such here
return
add_avail(stored_power)
power_cycle++
if(power_cycle >= power_cycle_delay)
produce_power()
power_cycle = 0
return
/obj/machinery/power/am_control_unit/proc/produce_power()
playsound(src.loc, 'sound/effects/bang.ogg', 25, 1)
var/core_power = reported_core_efficiency//Effectively how much fuel we can safely deal with
if(core_power <= 0) return 0//Something is wrong
var/core_damage = 0
var/fuel = fueljar.usefuel(fuel_injection)
stored_power = (fuel/core_power)*fuel*200000
//Now check if the cores could deal with it safely, this is done after so you can overload for more power if needed, still a bad idea
if(fuel > (2*core_power))//More fuel has been put in than the current cores can deal with
if(prob(50))core_damage = 1//Small chance of damage
if((fuel-core_power) > 5) core_damage = 5//Now its really starting to overload the cores
if((fuel-core_power) > 10) core_damage = 20//Welp now you did it, they wont stand much of this
if(core_damage == 0) return
for(var/obj/machinery/am_shielding/AMS in linked_cores)
AMS.stability -= core_damage
AMS.check_stability(1)
playsound(src.loc, 'sound/effects/bang.ogg', 50, 1)
return
/obj/machinery/power/am_control_unit/emp_act(severity)
switch(severity)
if(1)
if(active) toggle_power()
stability -= rand(15,30)
if(2)
if(active) toggle_power()
stability -= rand(10,20)
..()
return 0
/obj/machinery/power/am_control_unit/blob_act()
stability -= 20
if(prob(100-stability))//Might infect the rest of the machine
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
AMS.blob_act()
spawn(0)
//Likely explode
del(src)
return
check_stability()
return
/obj/machinery/power/am_control_unit/ex_act(severity)
switch(severity)
if(1.0)
stability -= 60
if(2.0)
stability -= 40
if(3.0)
stability -= 20
check_stability()
return
/obj/machinery/power/am_control_unit/bullet_act(var/obj/item/projectile/Proj)
if(Proj.flag != "bullet")
stability -= Proj.force
return 0
/obj/machinery/power/am_control_unit/power_change()
..()
if(stat & NOPOWER && active)
toggle_power()
return
/obj/machinery/power/am_control_unit/update_icon()
if(active) icon_state = "control_on"
else icon_state = "control"
//No other icons for it atm
/obj/machinery/power/am_control_unit/attackby(obj/item/W, mob/user)
if(!istype(W) || !user) return
if(istype(W, /obj/item/weapon/wrench))
if(!anchored)
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
user.visible_message("[user.name] secures the [src.name] to the floor.", \
"You secure the anchor bolts to the floor.", \
"You hear a ratchet")
src.anchored = 1
connect_to_network()
else if(!linked_shielding.len > 0)
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
user.visible_message("[user.name] unsecures the [src.name].", \
"You remove the anchor bolts.", \
"You hear a ratchet")
src.anchored = 0
disconnect_from_network()
else
user << "\red Once bolted and linked to a shielding unit it the [src.name] is unable to be moved!"
return
if(istype(W, /obj/item/weapon/am_containment))
if(fueljar)
user << "\red There is already a [fueljar] inside!"
return
fueljar = W
W.loc = src
if(user.client)
user.client.screen -= W
user.u_equip(W)
user.update_icons()
user.visible_message("[user.name] loads an [W.name] into the [src.name].", \
"You load an [W.name].", \
"You hear a thunk.")
return
if(W.force >= 20)
stability -= W.force/2
check_stability()
..()
return
/obj/machinery/power/am_control_unit/attack_hand(mob/user as mob)
if(anchored)
interact(user)
return
/obj/machinery/power/am_control_unit/proc/add_shielding(var/obj/machinery/am_shielding/AMS, var/AMS_linking = 0)
if(!istype(AMS)) return 0
if(!anchored) return 0
if(!AMS_linking && !AMS.link_control(src)) return 0
linked_shielding.Add(AMS)
update_shield_icons = 1
return 1
/obj/machinery/power/am_control_unit/proc/remove_shielding(var/obj/machinery/am_shielding/AMS)
if(!istype(AMS)) return 0
linked_shielding.Remove(AMS)
update_shield_icons = 2
if(active) toggle_power()
return 1
/obj/machinery/power/am_control_unit/proc/check_stability()//TODO: make it break when low also might want to add a way to fix it like a part or such that can be replaced
if(stability <= 0)
del(src)
return
/obj/machinery/power/am_control_unit/proc/toggle_power()
active = !active
if(active)
use_power = 2
visible_message("The [src.name] starts up.")
else
use_power = 1
visible_message("The [src.name] shuts down.")
update_icon()
return
/obj/machinery/power/am_control_unit/proc/check_shield_icons()//Forces icon_update for all shields
if(shield_icon_delay) return
shield_icon_delay = 1
if(update_shield_icons == 2)//2 means to clear everything and rebuild
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
if(AMS.processing) AMS.shutdown_core()
AMS.control_unit = null
spawn(10)
AMS.controllerscan()
linked_shielding = list()
else
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
AMS.update_icon()
spawn(20)
shield_icon_delay = 0
return
/obj/machinery/power/am_control_unit/proc/check_core_stability()
if(stored_core_stability_delay || linked_cores.len <= 0) return
stored_core_stability_delay = 1
stored_core_stability = 0
for(var/obj/machinery/am_shielding/AMS in linked_cores)
stored_core_stability += AMS.stability
stored_core_stability/=linked_cores.len
spawn(40)
stored_core_stability_delay = 0
return
/obj/machinery/power/am_control_unit/interact(mob/user)
if((get_dist(src, user) > 1) || (stat & (BROKEN|NOPOWER)))
if(!istype(user, /mob/living/silicon/ai))
user.unset_machine()
user << browse(null, "window=AMcontrol")
return
user.set_machine(src)
var/dat = ""
dat += "AntiMatter Control Panel<BR>"
dat += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
dat += "<A href='?src=\ref[src];refresh=1'>Refresh</A><BR>"
dat += "<A href='?src=\ref[src];refreshicons=1'>Force Shielding Update</A><BR><BR>"
dat += "Status: [(active?"Injecting":"Standby")] <BR>"
dat += "<A href='?src=\ref[src];togglestatus=1'>Toggle Status</A><BR>"
dat += "Stability: [stability]%<BR>"
dat += "Reactor parts: [linked_shielding.len]<BR>"//TODO: perhaps add some sort of stability check
dat += "Cores: [linked_cores.len]<BR><BR>"
dat += "-Current Efficiency: [reported_core_efficiency]<BR>"
dat += "-Average Stability: [stored_core_stability] <A href='?src=\ref[src];refreshstability=1'>(update)</A><BR>"
dat += "Last Produced: [stored_power]<BR>"
dat += "Fuel: "
if(!fueljar)
dat += "<BR>No fuel receptacle detected."
else
dat += "<A href='?src=\ref[src];ejectjar=1'>Eject</A><BR>"
dat += "- [fueljar.fuel]/[fueljar.fuel_max] Units<BR>"
dat += "- Injecting: [fuel_injection] units<BR>"
dat += "- <A href='?src=\ref[src];strengthdown=1'>--</A>|<A href='?src=\ref[src];strengthup=1'>++</A><BR><BR>"
user << browse(dat, "window=AMcontrol;size=420x500")
onclose(user, "AMcontrol")
return
/obj/machinery/power/am_control_unit/Topic(href, href_list)
..()
//Ignore input if we are broken or guy is not touching us, AI can control from a ways away
if(stat & (BROKEN|NOPOWER) || (get_dist(src, usr) > 1 && !istype(usr, /mob/living/silicon/ai)))
usr.unset_machine()
usr << browse(null, "window=AMcontrol")
return
if(href_list["close"])
usr << browse(null, "window=AMcontrol")
usr.unset_machine()
return
if(href_list["togglestatus"])
toggle_power()
if(href_list["refreshicons"])
update_shield_icons = 1
if(href_list["ejectjar"])
if(fueljar)
fueljar.loc = src.loc
fueljar = null
//fueljar.control_unit = null currently it does not care where it is
//update_icon() when we have the icon for it
if(href_list["strengthup"])
fuel_injection++
if(href_list["strengthdown"])
fuel_injection--
if(fuel_injection < 0) fuel_injection = 0
if(href_list["refreshstability"])
check_core_stability()
updateDialog()
return
+207
View File
@@ -0,0 +1,207 @@
/obj/machinery/power/am_engine
icon = 'icons/am_engine.dmi'
density = 1
anchored = 1.0
flags = ON_BORDER
/obj/machinery/power/am_engine/bits
name = "Antimatter Engine"
icon_state = "1"
/obj/machinery/power/am_engine/engine
name = "Antimatter Engine"
icon_state = "am_engine"
var/engine_id = 0
var/H_fuel = 0
var/antiH_fuel = 0
var/operating = 0
var/stopping = 0
var/obj/machinery/power/am_engine/injector/connected = null
/obj/machinery/power/am_engine/injector
name = "Injector"
icon_state = "injector"
var/engine_id = 0
var/injecting = 0
var/fuel = 0
var/obj/machinery/power/am_engine/engine/connected = null
//injector
/obj/machinery/power/am_engine/injector/New()
..()
spawn( 13 )
var/loc = get_step(src, NORTH)
src.connected = locate(/obj/machinery/power/am_engine/engine, get_step(loc, NORTH))
return
return
/obj/machinery/power/am_engine/injector/attackby(obj/item/weapon/fuel/F, mob/user)
if( (stat & BROKEN) || !connected) return
if(istype(F, /obj/item/weapon/fuel/H))
if(injecting)
user << "Theres already a fuel rod in the injector!"
return
user << "You insert the rod into the injector"
injecting = 1
var/fuel = F.fuel
del(F)
spawn( 300 )
injecting = 0
new/obj/item/weapon/fuel(src.loc)
connected.H_fuel += fuel
if(istype(F, /obj/item/weapon/fuel/antiH))
if(injecting)
user << "Theres already a fuel rod in the injector!"
return
user << "You insert the rod into the injector"
injecting = 1
var/fuel = F.fuel
del(F)
spawn( 300 )
injecting = 0
new /obj/item/weapon/fuel(src.loc)
connected.antiH_fuel += fuel
return
//engine
/obj/machinery/power/am_engine/engine/New()
..()
spawn( 7 )
var/loc = get_step(src, SOUTH)
src.connected = locate(/obj/machinery/power/am_engine/injector, get_step(loc, SOUTH))
return
return
/obj/machinery/power/am_engine/engine/proc/engine_go()
if( (!src.connected) || (stat & BROKEN) )
return
if(!antiH_fuel || !H_fuel)
return
operating = 1
var/energy = 0
if(antiH_fuel == H_fuel)
var/mass = antiH_fuel + H_fuel
energy = convert2energy(mass)
H_fuel = 0
antiH_fuel = 0
else
var/residual_matter = modulus(H_fuel - antiH_fuel)
var/mass = antiH_fuel + H_fuel - residual_matter
energy = convert2energy(mass)
if( H_fuel > antiH_fuel )
H_fuel = residual_matter
antiH_fuel = 0
else
H_fuel = 0
antiH_fuel = residual_matter
for(var/mob/M in hearers(src, null))
M.show_message(text("\red You hear a loud bang!"))
//Q = k x (delta T)
energy = energy*0.75
operating = 0
//TODO: DEFERRED Heat tile
return
/obj/machinery/power/am_engine/engine/proc/engine_process()
do
if( (!src.connected) || (stat & BROKEN) )
return
if(!antiH_fuel || !H_fuel)
return
if(operating)
return
operating = 1
sleep(50)
var/energy //energy from the reaction
var/H //residual matter if H
var/antiH //residual matter if antiH
var/mass //total mass
if(antiH_fuel == H_fuel) //if they're equal then convert the whole mass to energy
mass = antiH_fuel + H_fuel
energy = convert2energy(mass)
else //else if they're not equal determine which isn't equal
//and set it equal to either H or antiH so we don't lose anything
var/residual_matter = modulus(H_fuel - antiH_fuel)
mass = antiH_fuel + H_fuel - residual_matter
energy = convert2energy(mass)
if( H_fuel > antiH_fuel )
H = residual_matter
else
antiH = residual_matter
if(energy > convert2energy(8e-12)) //TOO MUCH ENERGY
for(var/mob/M in hearers(src, null))
M.show_message(text("\red You hear a loud whirring!"))
sleep(20)
//Q = k x (delta T)
//Too much energy so machine panics and dissapates half of it as heat
//The rest of the energetic photons then form into H and anti H particles again!
H_fuel -= H
antiH_fuel -= antiH
antiH_fuel = antiH_fuel/2
H_fuel = H_fuel/2
energy = convert2energy(H_fuel + antiH_fuel)
H_fuel += H
antiH_fuel += antiH
if(energy > convert2energy(8e-12)) //FAR TOO MUCH ENERGY STILL
for(var/mob/M in hearers(src, null))
M.show_message(text("\red <big>BANG!</big>"))
new /obj/effect/bhole(src.loc)
else //this amount of energy is okay so it does the proper output thing
sleep(60)
//E = Pt
//Lets say its 86% efficient
var/output = 0.86*energy/20
add_avail(output)
//yeah the machine realises that something isn't right and accounts for it if H or antiH
H_fuel -= H
antiH_fuel -= antiH
antiH_fuel = antiH_fuel/4
H_fuel = H_fuel/4
H_fuel += H
antiH_fuel += antiH
operating = 0
sleep(100)
while(!stopping)
stopping = 0
return
+100
View File
@@ -0,0 +1,100 @@
/obj/item/weapon/fuel
name = "Magnetic Storage Ring"
desc = "A magnetic storage ring."
icon = 'icons/obj/items.dmi'
icon_state = "rcdammo"
opacity = 0
density = 0
anchored = 0.0
var/fuel = 0
var/s_time = 1.0
var/content = null
/obj/item/weapon/fuel/H
name = "Hydrogen storage ring"
content = "Hydrogen"
fuel = 1e-12 //pico-kilogram
/obj/item/weapon/fuel/antiH
name = "Anti-Hydrogen storage ring"
content = "Anti-Hydrogen"
fuel = 1e-12 //pico-kilogram
/obj/item/weapon/fuel/attackby(obj/item/weapon/fuel/F, mob/user)
..()
if(istype(src, /obj/item/weapon/fuel/antiH))
if(istype(F, /obj/item/weapon/fuel/antiH))
src.fuel += F.fuel
F.fuel = 0
user << "You have added the anti-Hydrogen to the storage ring, it now contains [src.fuel]kg"
if(istype(F, /obj/item/weapon/fuel/H))
src.fuel += F.fuel
del(F)
src:annihilation(src.fuel)
if(istype(src, /obj/item/weapon/fuel/H))
if(istype(F, /obj/item/weapon/fuel/H))
src.fuel += F.fuel
F.fuel = 0
user << "You have added the Hydrogen to the storage ring, it now contains [src.fuel]kg"
if(istype(F, /obj/item/weapon/fuel/antiH))
src.fuel += F.fuel
del(src)
F:annihilation(F.fuel)
/obj/item/weapon/fuel/antiH/proc/annihilation(var/mass)
var/strength = convert2energy(mass)
if (strength < 773.0)
var/turf/T = get_turf(src)
if (strength > (450+T0C))
explosion(T, 0, 1, 2, 4)
else
if (strength > (300+T0C))
explosion(T, 0, 0, 2, 3)
del(src)
return
var/turf/ground_zero = get_turf(loc)
var/ground_zero_range = round(strength / 387)
explosion(ground_zero, ground_zero_range, ground_zero_range*2, ground_zero_range*3, ground_zero_range*4)
//SN src = null
del(src)
return
/obj/item/weapon/fuel/examine()
set src in view(1)
if(usr && !usr.stat)
usr << "A magnetic storage ring, it contains [fuel]kg of [content ? content : "nothing"]."
/obj/item/weapon/fuel/proc/injest(mob/M as mob)
switch(content)
if("Anti-Hydrogen")
M.gib()
if("Hydrogen")
M << "\blue You feel very light, as if you might just float away..."
del(src)
return
/obj/item/weapon/fuel/attack(mob/M as mob, mob/user as mob)
if (user != M)
var/obj/effect/equip_e/human/O = new /obj/effect/equip_e/human( )
O.source = user
O.target = M
O.item = src
O.s_loc = user.loc
O.t_loc = M.loc
O.place = "fuel"
M.requests += O
spawn( 0 )
O.process()
return
else
for(var/mob/O in viewers(M, null))
O.show_message(text("\red [M] ate the [content ? content : "empty canister"]!"), 1)
src.injest(M)
+222
View File
@@ -0,0 +1,222 @@
//like orange but only checks north/south/east/west for one step
proc/cardinalrange(var/center)
var/list/things = list()
for(var/direction in cardinal)
var/turf/T = get_step(center, direction)
if(!T) continue
things += T.contents
return things
/obj/machinery/am_shielding
name = "antimatter reactor section"
desc = "This device was built using a plasma life-form that seems to increase plasma's natural ability to react with neutrinos while reducing the combustibility."
icon = 'icons/obj/machines/antimatter.dmi'
icon_state = "shield"
anchored = 1
density = 1
dir = 1
use_power = 0//Living things generally dont use power
idle_power_usage = 0
active_power_usage = 0
var/obj/machinery/power/am_control_unit/control_unit = null
var/processing = 0//To track if we are in the update list or not, we need to be when we are damaged and if we ever
var/stability = 100//If this gets low bad things tend to happen
var/efficiency = 1//How many cores this core counts for when doing power processing, plasma in the air and stability could affect this
/obj/machinery/am_shielding/New(loc)
..(loc)
spawn(10)
controllerscan()
return
/obj/machinery/am_shielding/proc/controllerscan(var/priorscan = 0)
//Make sure we are the only one here
if(!istype(src.loc, /turf))
del(src)
return
for(var/obj/machinery/am_shielding/AMS in loc.contents)
if(AMS == src) continue
spawn(0)
del(src)
return
//Search for shielding first
for(var/obj/machinery/am_shielding/AMS in cardinalrange(src))
if(AMS && AMS.control_unit && link_control(AMS.control_unit))
break
if(!control_unit)//No other guys nearby look for a control unit
for(var/direction in cardinal)
for(var/obj/machinery/power/am_control_unit/AMC in cardinalrange(src))
if(AMC.add_shielding(src))
break
if(!control_unit)
if(!priorscan)
spawn(20)
controllerscan(1)//Last chance
return
spawn(0)
del(src)
return
/obj/machinery/am_shielding/Del()
if(control_unit) control_unit.remove_shielding(src)
if(processing) shutdown_core()
visible_message("\red The [src.name] melts!")
//Might want to have it leave a mess on the floor but no sprites for now
..()
return
/obj/machinery/am_shielding/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(air_group || (height==0)) return 1
return 0
/obj/machinery/am_shielding/process()
if(!processing) . = PROCESS_KILL
//TODO: core functions and stability
//TODO: think about checking the airmix for plasma and increasing power output
return
/obj/machinery/am_shielding/emp_act()//Immune due to not really much in the way of electronics.
return 0
/obj/machinery/am_shielding/blob_act()
stability -= 20
if(prob(100-stability))
if(prob(10))//Might create a node
new /obj/effect/blob/node(src.loc,150)
else
new /obj/effect/blob(src.loc,60)
spawn(0)
del(src)
return
check_stability()
return
/obj/machinery/am_shielding/ex_act(severity)
switch(severity)
if(1.0)
stability -= 80
if(2.0)
stability -= 40
if(3.0)
stability -= 20
check_stability()
return
/obj/machinery/am_shielding/bullet_act(var/obj/item/projectile/Proj)
if(Proj.flag != "bullet")
stability -= Proj.force/2
return 0
/obj/machinery/am_shielding/update_icon()
overlays.Cut()
for(var/direction in alldirs)
var/machine = locate(/obj/machinery, get_step(loc, direction))
if((istype(machine, /obj/machinery/am_shielding) && machine:control_unit == control_unit)||(istype(machine, /obj/machinery/power/am_control_unit) && machine == control_unit))
overlays += "shield_[direction]"
if(core_check())
overlays += "core"
if(!processing) setup_core()
else if(processing) shutdown_core()
/obj/machinery/am_shielding/attackby(obj/item/W, mob/user)
if(!istype(W) || !user) return
if(W.force > 10)
stability -= W.force/2
check_stability()
..()
return
//Call this to link a detected shilding unit to the controller
/obj/machinery/am_shielding/proc/link_control(var/obj/machinery/power/am_control_unit/AMC)
if(!istype(AMC)) return 0
if(control_unit && control_unit != AMC) return 0//Already have one
control_unit = AMC
control_unit.add_shielding(src,1)
return 1
//Scans cards for shields or the control unit and if all there it
/obj/machinery/am_shielding/proc/core_check()
for(var/direction in alldirs)
var/machine = locate(/obj/machinery, get_step(loc, direction))
if(!machine) return 0//Need all for a core
if(!istype(machine, /obj/machinery/am_shielding) && !istype(machine, /obj/machinery/power/am_control_unit)) return 0
return 1
/obj/machinery/am_shielding/proc/setup_core()
processing = 1
machines.Add(src)
if(!control_unit) return
control_unit.linked_cores.Add(src)
control_unit.reported_core_efficiency += efficiency
return
/obj/machinery/am_shielding/proc/shutdown_core()
processing = 0
if(!control_unit) return
control_unit.linked_cores.Remove(src)
control_unit.reported_core_efficiency -= efficiency
return
/obj/machinery/am_shielding/proc/check_stability(var/injecting_fuel = 0)
if(stability > 0) return
if(injecting_fuel && control_unit)
control_unit.exploding = 1
if(src)
del(src)
return
/obj/machinery/am_shielding/proc/recalc_efficiency(var/new_efficiency)//tbh still not 100% sure how I want to deal with efficiency so this is likely temp
if(!control_unit || !processing) return
if(stability < 50)
new_efficiency /= 2
control_unit.reported_core_efficiency += (new_efficiency - efficiency)
efficiency = new_efficiency
return
/obj/item/device/am_shielding_container
name = "packaged antimatter reactor section"
desc = "A small storage unit containing an antimatter reactor section. To use place near an antimatter control unit or deployed antimatter reactor section and use a multitool to activate this package."
icon = 'icons/obj/machines/antimatter.dmi'
icon_state = "box"
item_state = "electronic"
w_class = 4.0
flags = FPRINT | TABLEPASS | CONDUCT
throwforce = 5
throw_speed = 1
throw_range = 2
m_amt = 100
w_amt = 2000
/obj/item/device/am_shielding_container/attackby(var/obj/item/I, var/mob/user)
if(istype(I, /obj/item/device/multitool) && istype(src.loc,/turf))
new/obj/machinery/am_shielding(src.loc)
del(src)
return
..()
return
File diff suppressed because it is too large Load Diff
+570
View File
@@ -0,0 +1,570 @@
// attach a wire to a power machine - leads from the turf you are standing on
/obj/machinery/power/attackby(obj/item/weapon/W, mob/user)
if(istype(W, /obj/item/weapon/cable_coil))
var/obj/item/weapon/cable_coil/coil = W
var/turf/T = user.loc
if(T.intact || !istype(T, /turf/simulated/floor))
return
if(get_dist(src, user) > 1)
return
if(!directwired) // only for attaching to directwired machines
return
coil.turf_place(T, user)
return
else
..()
return
// the power cable object
/obj/structure/cable/New()
..()
// ensure d1 & d2 reflect the icon_state for entering and exiting cable
var/dash = findtext(icon_state, "-")
d1 = text2num( copytext( icon_state, 1, dash ) )
d2 = text2num( copytext( icon_state, dash+1 ) )
var/turf/T = src.loc // hide if turf is not intact
if(level==1) hide(T.intact)
cable_list += src
/obj/structure/cable/Del() // called when a cable is deleted
if(!defer_powernet_rebuild) // set if network will be rebuilt manually
if(powernet)
powernet.cut_cable(src) // update the powernets
cable_list -= src
..() // then go ahead and delete the cable
/obj/structure/cable/hide(var/i)
if(level == 1 && istype(loc, /turf))
invisibility = i ? 101 : 0
updateicon()
/obj/structure/cable/proc/updateicon()
if(invisibility)
icon_state = "[d1]-[d2]-f"
else
icon_state = "[d1]-[d2]"
// returns the powernet this cable belongs to
/obj/structure/cable/proc/get_powernet() //TODO: remove this as it is obsolete
return powernet
/obj/structure/cable/attack_tk(mob/user)
return
/obj/structure/cable/attackby(obj/item/W, mob/user)
var/turf/T = src.loc
if(T.intact)
return
if(istype(W, /obj/item/weapon/wirecutters))
// if(power_switch)
// user << "\red This piece of cable is tied to a power switch. Flip the switch to remove it."
// return
if (shock(user, 50))
return
if(src.d1) // 0-X cables are 1 unit, X-X cables are 2 units long
new/obj/item/weapon/cable_coil(T, 2, cable_color)
else
new/obj/item/weapon/cable_coil(T, 1, cable_color)
for(var/mob/O in viewers(src, null))
O.show_message("\red [user] cuts the cable.", 1)
del(src)
return // not needed, but for clarity
else if(istype(W, /obj/item/weapon/cable_coil))
var/obj/item/weapon/cable_coil/coil = W
coil.cable_join(src, user)
else if(istype(W, /obj/item/device/multitool))
var/datum/powernet/PN = get_powernet() // find the powernet
if(PN && (PN.avail > 0)) // is it powered?
user << "\red [PN.avail]W in power network."
else
user << "\red The cable is not powered."
shock(user, 5, 0.2)
else
if (W.flags & CONDUCT)
shock(user, 50, 0.7)
src.add_fingerprint(user)
// shock the user with probability prb
/obj/structure/cable/proc/shock(mob/user, prb, var/siemens_coeff = 1.0)
if(!prob(prb))
return 0
if (electrocute_mob(user, powernet, src, siemens_coeff))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
return 1
else
return 0
/obj/structure/cable/ex_act(severity)
switch(severity)
if(1.0)
del(src)
if(2.0)
if (prob(50))
new/obj/item/weapon/cable_coil(src.loc, src.d1 ? 2 : 1, cable_color)
del(src)
if(3.0)
if (prob(25))
new/obj/item/weapon/cable_coil(src.loc, src.d1 ? 2 : 1, cable_color)
del(src)
return
// the cable coil object, used for laying cable
#define MAXCOIL 30
/obj/item/weapon/cable_coil
name = "cable coil"
icon = 'icons/obj/power.dmi'
icon_state = "coil_red"
var/amount = MAXCOIL
item_color = "red"
desc = "A coil of power cable."
throwforce = 10
w_class = 2.0
throw_speed = 2
throw_range = 5
m_amt = 50
g_amt = 20
flags = TABLEPASS | FPRINT | CONDUCT
slot_flags = SLOT_BELT
item_state = "coil_red"
attack_verb = list("whipped", "lashed", "disciplined", "flogged")
suicide_act(mob/user)
viewers(user) << "\red <b>[user] is strangling \himself with the [src.name]! It looks like \he's trying to commit suicide.</b>"
return(OXYLOSS)
/obj/item/weapon/cable_coil/New(loc, length = MAXCOIL, var/param_color = null)
..()
src.amount = length
if (param_color)
item_color = param_color
pixel_x = rand(-2,2)
pixel_y = rand(-2,2)
updateicon()
/obj/item/weapon/cable_coil/proc/updateicon()
if (!item_color)
item_color = pick("red", "yellow", "blue", "green")
if(amount == 1)
icon_state = "coil_[item_color]1"
name = "cable piece"
else if(amount == 2)
icon_state = "coil_[item_color]2"
name = "cable piece"
else
icon_state = "coil_[item_color]"
name = "cable coil"
/obj/item/weapon/cable_coil/examine()
set src in view(1)
if(amount == 1)
usr << "A short piece of power cable."
else if(amount == 2)
usr << "A piece of power cable."
else
usr << "A coil of power cable. There are [amount] lengths of cable in the coil."
/obj/item/weapon/cable_coil/verb/make_restraint()
set name = "Make Cable Restraints"
set category = "Object"
var/mob/M = usr
if(ishuman(M) && !M.restrained() && !M.stat && !M.paralysis && ! M.stunned)
if(!istype(usr.loc,/turf)) return
if(src.amount <= 14)
usr << "\red You need at least 15 lengths to make restraints!"
return
var/obj/item/weapon/handcuffs/cable/B = new /obj/item/weapon/handcuffs/cable(usr.loc)
B.icon_state = "cuff_[item_color]"
usr << "\blue You wind some cable together to make some restraints."
src.use(15)
else
usr << "\blue You cannot do that."
..()
/obj/item/weapon/cable_coil/attackby(obj/item/weapon/W, mob/user)
..()
if( istype(W, /obj/item/weapon/wirecutters) && src.amount > 1)
src.amount--
new/obj/item/weapon/cable_coil(user.loc, 1,item_color)
user << "You cut a piece off the cable coil."
src.updateicon()
return
else if( istype(W, /obj/item/weapon/cable_coil) )
var/obj/item/weapon/cable_coil/C = W
if(C.amount == MAXCOIL)
user << "The coil is too long, you cannot add any more cable to it."
return
if( (C.amount + src.amount <= MAXCOIL) )
C.amount += src.amount
user << "You join the cable coils together."
C.updateicon()
del(src)
return
else
user << "You transfer [MAXCOIL - src.amount ] length\s of cable from one coil to the other."
src.amount -= (MAXCOIL-C.amount)
src.updateicon()
C.amount = MAXCOIL
C.updateicon()
return
/obj/item/weapon/cable_coil/proc/use(var/used)
if(src.amount < used)
return 0
else if (src.amount == used)
del(src)
else
amount -= used
updateicon()
return 1
// called when cable_coil is clicked on a turf/simulated/floor
/obj/item/weapon/cable_coil/proc/turf_place(turf/simulated/floor/F, mob/user)
if(!isturf(user.loc))
return
if(get_dist(F,user) > 1)
user << "You can't lay cable at a place that far away."
return
if(F.intact) // if floor is intact, complain
user << "You can't lay cable there unless the floor tiles are removed."
return
else
var/dirn
if(user.loc == F)
dirn = user.dir // if laying on the tile we're on, lay in the direction we're facing
else
dirn = get_dir(F, user)
for(var/obj/structure/cable/LC in F)
if((LC.d1 == dirn && LC.d2 == 0 ) || ( LC.d2 == dirn && LC.d1 == 0))
user << "There's already a cable at that position."
return
var/obj/structure/cable/C = new(F)
C.cableColor(item_color)
C.d1 = 0
C.d2 = dirn
C.add_fingerprint(user)
C.updateicon()
C.powernet = new()
powernets += C.powernet
C.powernet.cables += C
C.mergeConnectedNetworks(C.d2)
C.mergeConnectedNetworksOnTurf()
use(1)
if (C.shock(user, 50))
if (prob(50)) //fail
new/obj/item/weapon/cable_coil(C.loc, 1, C.cable_color)
del(C)
//src.laying = 1
//last = C
// called when cable_coil is click on an installed obj/cable
/obj/item/weapon/cable_coil/proc/cable_join(obj/structure/cable/C, mob/user)
var/turf/U = user.loc
if(!isturf(U))
return
var/turf/T = C.loc
if(!isturf(T) || T.intact) // sanity checks, also stop use interacting with T-scanner revealed cable
return
if(get_dist(C, user) > 1) // make sure it's close enough
user << "You can't lay cable at a place that far away."
return
if(U == T) // do nothing if we clicked a cable we're standing on
return // may change later if can think of something logical to do
var/dirn = get_dir(C, user)
if(C.d1 == dirn || C.d2 == dirn) // one end of the clicked cable is pointing towards us
if(U.intact) // can't place a cable if the floor is complete
user << "You can't lay cable there unless the floor tiles are removed."
return
else
// cable is pointing at us, we're standing on an open tile
// so create a stub pointing at the clicked cable on our tile
var/fdirn = turn(dirn, 180) // the opposite direction
for(var/obj/structure/cable/LC in U) // check to make sure there's not a cable there already
if(LC.d1 == fdirn || LC.d2 == fdirn)
user << "There's already a cable at that position."
return
var/obj/structure/cable/NC = new(U)
NC.cableColor(item_color)
NC.d1 = 0
NC.d2 = fdirn
NC.add_fingerprint()
NC.updateicon()
if(C.powernet)
NC.powernet = C.powernet
NC.powernet.cables += NC
NC.mergeConnectedNetworks(NC.d2)
NC.mergeConnectedNetworksOnTurf()
use(1)
if (NC.shock(user, 50))
if (prob(50)) //fail
new/obj/item/weapon/cable_coil(NC.loc, 1, NC.cable_color)
del(NC)
return
else if(C.d1 == 0) // exisiting cable doesn't point at our position, so see if it's a stub
// if so, make it a full cable pointing from it's old direction to our dirn
var/nd1 = C.d2 // these will be the new directions
var/nd2 = dirn
if(nd1 > nd2) // swap directions to match icons/states
nd1 = dirn
nd2 = C.d2
for(var/obj/structure/cable/LC in T) // check to make sure there's no matching cable
if(LC == C) // skip the cable we're interacting with
continue
if((LC.d1 == nd1 && LC.d2 == nd2) || (LC.d1 == nd2 && LC.d2 == nd1) ) // make sure no cable matches either direction
user << "There's already a cable at that position."
return
C.cableColor(item_color)
C.d1 = nd1
C.d2 = nd2
C.add_fingerprint()
C.updateicon()
C.mergeConnectedNetworks(C.d1)
C.mergeConnectedNetworks(C.d2)
C.mergeConnectedNetworksOnTurf()
use(1)
if (C.shock(user, 50))
if (prob(50)) //fail
new/obj/item/weapon/cable_coil(C.loc, 2, C.cable_color)
del(C)
return
/obj/structure/cable/proc/mergeConnectedNetworks(var/direction)
var/turf/TB
if(!(d1 == direction || d2 == direction))
return
TB = get_step(src, direction)
for(var/obj/structure/cable/TC in TB)
if(!TC)
continue
if(src == TC)
continue
var/fdir = (!direction)? 0 : turn(direction, 180)
if(TC.d1 == fdir || TC.d2 == fdir)
if(!TC.powernet)
TC.powernet = new()
powernets += TC.powernet
TC.powernet.cables += TC
if(powernet)
merge_powernets(powernet,TC.powernet)
else
powernet = TC.powernet
powernet.cables += src
/obj/structure/cable/proc/mergeConnectedNetworksOnTurf()
if(!powernet)
powernet = new()
powernets += powernet
powernet.cables += src
for(var/AM in loc)
if(istype(AM,/obj/structure/cable))
var/obj/structure/cable/C = AM
if(C.powernet == powernet) continue
if(C.powernet)
merge_powernets(powernet, C.powernet)
else
C.powernet = powernet
powernet.cables += C
else if(istype(AM,/obj/machinery/power/apc))
var/obj/machinery/power/apc/N = AM
if(!N.terminal) continue
if(N.terminal.powernet)
merge_powernets(powernet, N.terminal.powernet)
else
N.terminal.powernet = powernet
powernet.nodes[N.terminal] = N.terminal
else if(istype(AM,/obj/machinery/power))
var/obj/machinery/power/M = AM
if(M.powernet == powernet) continue
if(M.powernet)
merge_powernets(powernet, M.powernet)
else
M.powernet = powernet
powernet.nodes[M] = M
obj/structure/cable/proc/cableColor(var/colorC)
var/color_n = "red"
if(colorC)
color_n = colorC
cable_color = color_n
switch(colorC)
if("red")
icon = 'icons/obj/power_cond_red.dmi'
if("yellow")
icon = 'icons/obj/power_cond_yellow.dmi'
if("green")
icon = 'icons/obj/power_cond_green.dmi'
if("blue")
icon = 'icons/obj/power_cond_blue.dmi'
if("pink")
icon = 'icons/obj/power_cond_pink.dmi'
if("orange")
icon = 'icons/obj/power_cond_orange.dmi'
if("cyan")
icon = 'icons/obj/power_cond_cyan.dmi'
if("white")
icon = 'icons/obj/power_cond_white.dmi'
/obj/item/weapon/cable_coil/cut
item_state = "coil_red2"
/obj/item/weapon/cable_coil/cut/New(loc)
..()
src.amount = rand(1,2)
pixel_x = rand(-2,2)
pixel_y = rand(-2,2)
updateicon()
/obj/item/weapon/cable_coil/yellow
item_color = "yellow"
icon_state = "coil_yellow"
/obj/item/weapon/cable_coil/blue
item_color = "blue"
icon_state = "coil_blue"
/obj/item/weapon/cable_coil/green
item_color = "green"
icon_state = "coil_green"
/obj/item/weapon/cable_coil/pink
item_color = "pink"
icon_state = "coil_pink"
/obj/item/weapon/cable_coil/orange
item_color = "orange"
icon_state = "coil_orange"
/obj/item/weapon/cable_coil/cyan
item_color = "cyan"
icon_state = "coil_cyan"
/obj/item/weapon/cable_coil/white
item_color = "white"
icon_state = "coil_white"
/obj/item/weapon/cable_coil/random/New()
item_color = pick("red","yellow","green","blue","pink")
icon_state = "coil_[item_color]"
..()
/obj/item/weapon/cable_coil/attack(mob/M as mob, mob/user as mob)
if(hasorgans(M))
var/datum/organ/external/S = M:get_organ(user.zone_sel.selecting)
if(!(S.status & ORGAN_ROBOT) || user.a_intent != "help")
return ..()
if(S.burn_dam > 0 && use(1))
S.heal_damage(0,15,0,1)
if(user != M)
user.visible_message("\red \The [user] repairs some burn damage on their [S.display_name] with \the [src]",\
"\red You repair some burn damage on your [S.display_name]",\
"You hear wires being cut.")
else
user.visible_message("\red \The [user] repairs some burn damage on their [S.display_name] with \the [src]",\
"\red You repair some burn damage on your [S.display_name]",\
"You hear wires being cut.")
else
user << "Nothing to fix!"
else
return ..()
+28
View File
@@ -0,0 +1,28 @@
/obj/item/weapon/cable_coil/heavyduty
name = "heavy cable coil"
icon = 'icons/obj/power.dmi'
icon_state = "wire"
/obj/structure/cable/heavyduty
icon = 'icons/obj/power_cond_heavy.dmi'
name = "large power cable"
desc = "This cable is tough. It cannot be cut with simple hand tools."
layer = 2.39 //Just below pipes, which are at 2.4
/obj/structure/cable/heavyduty/attackby(obj/item/W, mob/user)
var/turf/T = src.loc
if(T.intact)
return
if(istype(W, /obj/item/weapon/wirecutters))
usr << "\blue These cables are too tough to be cut with those [W.name]."
return
else if(istype(W, /obj/item/weapon/cable_coil))
usr << "\blue You will need heavier cables to connect to these."
return
else
..()
/obj/structure/cable/heavyduty/cableColor(var/colorC)
return
+292
View File
@@ -0,0 +1,292 @@
#define LOGIC_HIGH 5
//Indicators only have one input and no outputs
/obj/machinery/logic/indicator
//Input is searched from the 'dir' direction
var/obj/structure/cable/input
/obj/machinery/logic/indicator/process()
if(input)
return 1
if(!input)
var/turf/T = get_step(src, dir)
if(T)
var/inv_dir = turn(dir, 180)
for(var/obj/structure/cable/C in T)
if(C.d1 == inv_dir || C.d2 == inv_dir)
input = C
return 1
return 0 //If it gets to here, it means no suitable wire to link to was found.
/obj/machinery/logic/indicator/bulb
icon = 'icons/obj/lighting.dmi'
icon_state = "bulb0"
/obj/machinery/logic/indicator/bulb/process()
if(!..()) //Parent proc checks if input1 exists.
return
var/datum/powernet/pn_input = input.powernet
if(!pn_input)
return
if(pn_input.avail >= LOGIC_HIGH)
icon_state = "bulb1"
else
icon_state = "bulb0"
//Sensors only have one output and no inputs
/obj/machinery/logic/sensor
//Output is searched from the 'dir' direction
var/obj/structure/cable/output
/obj/machinery/logic/sensor/process()
if(output)
return 1
if(!output)
var/turf/T = get_step(src, dir)
if(T)
var/inv_dir = turn(dir, 180)
for(var/obj/structure/cable/C in T)
if(C.d1 == inv_dir || C.d2 == inv_dir)
output = C
return 1
return 0 //If it gets to here, it means no suitable wire to link to was found.
//Constant high generator. This will continue to send a signal of LOGIC_HIGH as long as it exists.
/obj/machinery/logic/sensor/constant_high
icon = 'icons/obj/atmospherics/outlet_injector.dmi'
icon_state = "off"
/obj/machinery/logic/sensor/constant_high/process()
if(!..()) //Parent proc checks if input1 exists.
return
var/datum/powernet/pn_output = output.powernet
if(!pn_output)
return
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH)
//ONE INPUT logic elements have one input and one output
/obj/machinery/logic/oneinput
var/dir_input = 2
var/dir_output = 1
var/obj/structure/cable/input
var/obj/structure/cable/output
icon = 'icons/obj/pipes/heat.dmi'
icon_state = "intact"
/obj/machinery/logic/oneinput/process()
if(input && output)
return 1
if(!dir_input || !dir_output)
return 0
if(!input)
var/turf/T = get_step(src, dir_input)
if(T)
var/inv_dir = turn(dir_input, 180)
for(var/obj/structure/cable/C in T)
if(C.d1 == inv_dir || C.d2 == inv_dir)
input = C
if(!output)
var/turf/T = get_step(src, dir_output)
if(T)
var/inv_dir = turn(dir_output, 180)
for(var/obj/structure/cable/C in T)
if(C.d1 == inv_dir || C.d2 == inv_dir)
output = C
return 0 //On the process() call, where everything is still being searched for, it returns 0. It will return 1 on the next process() call.
//NOT GATE
/obj/machinery/logic/oneinput/not/process()
if(!..()) //Parent proc checks if input1, input2 and output exist.
return
var/datum/powernet/pn_input = input.powernet
if(!pn_input)
return
var/datum/powernet/pn_output = output.powernet
if(!pn_output)
return
if( !(pn_input.avail >= LOGIC_HIGH))
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
else
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
//TWO INPUT logic elements have two inputs and one output
/obj/machinery/logic/twoinput
var/dir_input1 = 2
var/dir_input2 = 8
var/dir_output = 1
var/obj/structure/cable/input1
var/obj/structure/cable/input2
var/obj/structure/cable/output
icon = 'icons/obj/atmospherics/mixer.dmi'
icon_state = "intact_off"
/obj/machinery/logic/twoinput/process()
if(input1 && input2 && output)
return 1
if(!dir_input1 || !dir_input2 || !dir_output)
return 0
if(!input1)
var/turf/T = get_step(src, dir_input1)
if(T)
var/inv_dir = turn(dir_input1, 180)
for(var/obj/structure/cable/C in T)
if(C.d1 == inv_dir || C.d2 == inv_dir)
input1 = C
if(!input2)
var/turf/T = get_step(src, dir_input2)
if(T)
var/inv_dir = turn(dir_input2, 180)
for(var/obj/structure/cable/C in T)
if(C.d1 == inv_dir || C.d2 == inv_dir)
input2 = C
if(!output)
var/turf/T = get_step(src, dir_output)
if(T)
var/inv_dir = turn(dir_output, 180)
for(var/obj/structure/cable/C in T)
if(C.d1 == inv_dir || C.d2 == inv_dir)
output = C
return 0 //On the process() call, where everything is still being searched for, it returns 0. It will return 1 on the next process() call.
//AND GATE
/obj/machinery/logic/twoinput/and/process()
if(!..()) //Parent proc checks if input1, input2 and output exist.
return
var/datum/powernet/pn_input1 = input1.powernet
var/datum/powernet/pn_input2 = input2.powernet
if(!pn_input1 || !pn_input2)
return
var/datum/powernet/pn_output = output.powernet
if(!pn_output)
return
if( (pn_input1.avail >= LOGIC_HIGH) && (pn_input2.avail >= LOGIC_HIGH) )
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
else
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
//OR GATE
/obj/machinery/logic/twoinput/or/process()
if(!..()) //Parent proc checks if input1, input2 and output exist.
return
var/datum/powernet/pn_input1 = input1.powernet
var/datum/powernet/pn_input2 = input2.powernet
if(!pn_input1 || !pn_input2)
return
var/datum/powernet/pn_output = output.powernet
if(!pn_output)
return
if( (pn_input1.avail >= LOGIC_HIGH) || (pn_input2.avail >= LOGIC_HIGH) )
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
else
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
//XOR GATE
/obj/machinery/logic/twoinput/xor/process()
if(!..()) //Parent proc checks if input1, input2 and output exist.
return
var/datum/powernet/pn_input1 = input1.powernet
var/datum/powernet/pn_input2 = input2.powernet
if(!pn_input1 || !pn_input2)
return
var/datum/powernet/pn_output = output.powernet
if(!pn_output)
return
if( (pn_input1.avail >= LOGIC_HIGH) != (pn_input2.avail >= LOGIC_HIGH) )
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
else
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
//XNOR GATE (EQUIVALENCE)
/obj/machinery/logic/twoinput/xnor/process()
if(!..()) //Parent proc checks if input1, input2 and output exist.
return
var/datum/powernet/pn_input1 = input1.powernet
var/datum/powernet/pn_input2 = input2.powernet
if(!pn_input1 || !pn_input2)
return
var/datum/powernet/pn_output = output.powernet
if(!pn_output)
return
if( (pn_input1.avail >= LOGIC_HIGH) == (pn_input2.avail >= LOGIC_HIGH) )
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
else
pn_output.newload += LOGIC_HIGH //Otherwise increase the load to 5
#define RELAY_POWER_TRANSFER 2000 //How much power a relay transfers through.
//RELAY - input1 governs the flow from input2 to output
/obj/machinery/logic/twoinput/relay/process()
if(!..()) //Parent proc checks if input1, input2 and output exist.
return
var/datum/powernet/pn_input1 = input1.powernet
if(!pn_input1)
return
if( pn_input1.avail >= LOGIC_HIGH )
var/datum/powernet/pn_input2 = input2.powernet
var/datum/powernet/pn_output = output.powernet
if(!pn_output)
return
if(pn_input2.avail >= RELAY_POWER_TRANSFER)
pn_input2.newload += RELAY_POWER_TRANSFER
pn_output.newavail += RELAY_POWER_TRANSFER
#undef RELAY_POWER_TRANSFER
#undef LOGIC_HIGH
+183
View File
@@ -0,0 +1,183 @@
// the power cell
// charge from 0 to 100%
// fits in APC to provide backup power
/obj/item/weapon/cell/New()
..()
charge = maxcharge
spawn(5)
updateicon()
/obj/item/weapon/cell/proc/updateicon()
overlays.Cut()
if(charge < 0.01)
return
else if(charge/maxcharge >=0.995)
overlays += image('icons/obj/power.dmi', "cell-o2")
else
overlays += image('icons/obj/power.dmi', "cell-o1")
/obj/item/weapon/cell/proc/percent() // return % charge of cell
return 100.0*charge/maxcharge
// use power from a cell
/obj/item/weapon/cell/proc/use(var/amount)
if(rigged && amount > 0)
explode()
return 0
if(charge < amount) return 0
charge = (charge - amount)
return 1
// recharge the cell
/obj/item/weapon/cell/proc/give(var/amount)
if(rigged && amount > 0)
explode()
return 0
if(maxcharge < amount) return 0
var/power_used = min(maxcharge-charge,amount)
if(crit_fail) return 0
if(!prob(reliability))
minor_fault++
if(prob(minor_fault))
crit_fail = 1
return 0
charge += power_used
return power_used
/obj/item/weapon/cell/examine()
set src in view(1)
if(usr /*&& !usr.stat*/)
if(maxcharge <= 2500)
usr << "[desc]\nThe manufacturer's label states this cell has a power rating of [maxcharge], and that you should not swallow it.\nThe charge meter reads [round(src.percent() )]%."
else
usr << "This power cell has an exciting chrome finish, as it is an uber-capacity cell type! It has a power rating of [maxcharge]!\nThe charge meter reads [round(src.percent() )]%."
if(crit_fail)
usr << "\red This power cell seems to be faulty."
/obj/item/weapon/cell/attack_self(mob/user as mob)
src.add_fingerprint(user)
if(ishuman(user))
var/mob/living/carbon/human/H = user
var/obj/item/clothing/gloves/space_ninja/SNG = H.gloves
if(!istype(SNG) || !SNG.candrain || !SNG.draining) return
SNG.drain("CELL",src,H.wear_suit)
return
/obj/item/weapon/cell/attackby(obj/item/W, mob/user)
..()
if(istype(W, /obj/item/weapon/reagent_containers/syringe))
var/obj/item/weapon/reagent_containers/syringe/S = W
user << "You inject the solution into the power cell."
if(S.reagents.has_reagent("plasma", 5))
rigged = 1
log_admin("LOG: [user.name] ([user.ckey]) injected a power cell with plasma, rigging it to explode.")
message_admins("LOG: [user.name] ([user.ckey]) injected a power cell with plasma, rigging it to explode.")
S.reagents.clear_reagents()
/obj/item/weapon/cell/proc/explode()
var/turf/T = get_turf(src.loc)
/*
* 1000-cell explosion(T, -1, 0, 1, 1)
* 2500-cell explosion(T, -1, 0, 1, 1)
* 10000-cell explosion(T, -1, 1, 3, 3)
* 15000-cell explosion(T, -1, 2, 4, 4)
* */
if (charge==0)
return
var/devastation_range = -1 //round(charge/11000)
var/heavy_impact_range = round(sqrt(charge)/60)
var/light_impact_range = round(sqrt(charge)/30)
var/flash_range = light_impact_range
if (light_impact_range==0)
rigged = 0
corrupt()
return
//explosion(T, 0, 1, 2, 2)
log_admin("LOG: Rigged power cell explosion, last touched by [fingerprintslast]")
message_admins("LOG: Rigged power cell explosion, last touched by [fingerprintslast]")
explosion(T, devastation_range, heavy_impact_range, light_impact_range, flash_range)
spawn(1)
del(src)
/obj/item/weapon/cell/proc/corrupt()
charge /= 2
maxcharge /= 2
if (prob(10))
rigged = 1 //broken batterys are dangerous
/obj/item/weapon/cell/emp_act(severity)
charge -= 1000 / severity
if (charge < 0)
charge = 0
if(reliability != 100 && prob(50/severity))
reliability -= 10 / severity
..()
/obj/item/weapon/cell/ex_act(severity)
switch(severity)
if(1.0)
del(src)
return
if(2.0)
if (prob(50))
del(src)
return
if (prob(50))
corrupt()
if(3.0)
if (prob(25))
del(src)
return
if (prob(25))
corrupt()
return
/obj/item/weapon/cell/blob_act()
if(prob(75))
explode()
/obj/item/weapon/cell/proc/get_electrocute_damage()
switch (charge)
/* if (9000 to INFINITY)
return min(rand(90,150),rand(90,150))
if (2500 to 9000-1)
return min(rand(70,145),rand(70,145))
if (1750 to 2500-1)
return min(rand(35,110),rand(35,110))
if (1500 to 1750-1)
return min(rand(30,100),rand(30,100))
if (750 to 1500-1)
return min(rand(25,90),rand(25,90))
if (250 to 750-1)
return min(rand(20,80),rand(20,80))
if (100 to 250-1)
return min(rand(20,65),rand(20,65))*/
if (1000000 to INFINITY)
return min(rand(50,160),rand(50,160))
if (200000 to 1000000-1)
return min(rand(25,80),rand(25,80))
if (100000 to 200000-1)//Ave powernet
return min(rand(20,60),rand(20,60))
if (50000 to 100000-1)
return min(rand(15,40),rand(15,40))
if (1000 to 50000-1)
return min(rand(10,20),rand(10,20))
else
return 0
+40
View File
@@ -0,0 +1,40 @@
/turf/simulated/floor/engine/attack_paw(var/mob/user as mob)
return src.attack_hand(user)
/turf/simulated/floor/engine/attack_hand(var/mob/user as mob)
if ((!( user.canmove ) || user.restrained() || !( user.pulling )))
return
if (user.pulling.anchored)
return
if ((user.pulling.loc != user.loc && get_dist(user, user.pulling) > 1))
return
if (ismob(user.pulling))
var/mob/M = user.pulling
var/atom/movable/t = M.pulling
M.stop_pulling()
step(user.pulling, get_dir(user.pulling.loc, src))
M.start_pulling(t)
else
step(user.pulling, get_dir(user.pulling.loc, src))
return
/turf/simulated/floor/engine/ex_act(severity)
switch(severity)
if(1.0)
ChangeTurf(/turf/space)
del(src)
return
if(2.0)
if (prob(50))
ChangeTurf(/turf/space)
del(src)
return
else
return
/turf/simulated/floor/engine/blob_act()
if (prob(25))
ChangeTurf(/turf/space)
del(src)
return
return
+202
View File
@@ -0,0 +1,202 @@
/obj/machinery/power/generator
name = "thermoelectric generator"
desc = "It's a high efficiency thermoelectric generator."
icon_state = "teg"
density = 1
anchored = 0
use_power = 1
idle_power_usage = 100 //Watts, I hope. Just enough to do the computer and display things.
var/obj/machinery/atmospherics/binary/circulator/circ1
var/obj/machinery/atmospherics/binary/circulator/circ2
var/lastgen = 0
var/lastgenlev = -1
/obj/machinery/power/generator/New()
..()
spawn(1)
reconnect()
//generators connect in dir and reverse_dir(dir) directions
//mnemonic to determine circulator/generator directions: the cirulators orbit clockwise around the generator
//so a circulator to the NORTH of the generator connects first to the EAST, then to the WEST
//and a circulator to the WEST of the generator connects first to the NORTH, then to the SOUTH
//note that the circulator's outlet dir is it's always facing dir, and it's inlet is always the reverse
/obj/machinery/power/generator/proc/reconnect()
circ1 = null
circ2 = null
if(src.loc && anchored)
if(src.dir & (EAST|WEST))
circ1 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,EAST)
circ2 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,WEST)
if(circ1 && circ2)
if(circ1.dir != SOUTH || circ2.dir != NORTH)
circ1 = null
circ2 = null
else if(src.dir & (NORTH|SOUTH))
circ1 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,NORTH)
circ2 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,SOUTH)
if(circ1 && circ2 && (circ1.dir != EAST || circ2.dir != WEST))
circ1 = null
circ2 = null
/obj/machinery/power/generator/proc/updateicon()
if(stat & (NOPOWER|BROKEN))
overlays.Cut()
else
overlays.Cut()
if(lastgenlev != 0)
overlays += image('icons/obj/power.dmi', "teg-op[lastgenlev]")
/obj/machinery/power/generator/process()
if(!circ1 || !circ2 || !anchored || stat & (BROKEN|NOPOWER))
return
updateDialog()
var/datum/gas_mixture/air1 = circ1.return_transfer_air()
var/datum/gas_mixture/air2 = circ2.return_transfer_air()
lastgen = 0
if(air1 && air2)
var/air1_heat_capacity = air1.heat_capacity()
var/air2_heat_capacity = air2.heat_capacity()
var/delta_temperature = abs(air2.temperature - air1.temperature)
if(delta_temperature > 0 && air1_heat_capacity > 0 && air2_heat_capacity > 0)
var/efficiency = 0.65
var/energy_transfer = delta_temperature*air2_heat_capacity*air1_heat_capacity/(air2_heat_capacity+air1_heat_capacity)
var/heat = energy_transfer*(1-efficiency)
lastgen = energy_transfer*efficiency*0.05
if(air2.temperature > air1.temperature)
air2.temperature = air2.temperature - energy_transfer/air2_heat_capacity
air1.temperature = air1.temperature + heat/air1_heat_capacity
else
air2.temperature = air2.temperature + heat/air2_heat_capacity
air1.temperature = air1.temperature - energy_transfer/air1_heat_capacity
//Transfer the air
circ1.air2.merge(air1)
circ2.air2.merge(air2)
//Update the gas networks
if(circ1.network2)
circ1.network2.update = 1
if(circ2.network2)
circ2.network2.update = 1
// update icon overlays and power usage only if displayed level has changed
if(lastgen > 250000 && prob(10))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)
s.start()
lastgen *= 0.5
var/genlev = max(0, min( round(11*lastgen / 250000), 11))
if(lastgen > 100 && genlev == 0)
genlev = 1
if(genlev != lastgenlev)
lastgenlev = genlev
updateicon()
add_avail(lastgen)
/obj/machinery/power/generator/attack_ai(mob/user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
/obj/machinery/power/generator/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/wrench))
anchored = !anchored
user << "\blue You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor."
use_power = anchored
reconnect()
else
..()
/obj/machinery/power/generator/attack_hand(mob/user)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER) || !anchored) return
interact(user)
/obj/machinery/power/generator/interact(mob/user)
if ( (get_dist(src, user) > 1 ) && (!istype(user, /mob/living/silicon/ai)))
user.unset_machine()
user << browse(null, "window=teg")
return
user.set_machine(src)
var/t = "<PRE><B>Thermo-Electric Generator</B><HR>"
if(circ1 && circ2)
t += "Output : [round(lastgen)] W<BR><BR>"
t += "<B>Primary Circulator (top or right)</B><BR>"
t += "Inlet Pressure: [round(circ1.air1.return_pressure(), 0.1)] kPa<BR>"
t += "Inlet Temperature: [round(circ1.air1.temperature, 0.1)] K<BR>"
t += "Outlet Pressure: [round(circ1.air2.return_pressure(), 0.1)] kPa<BR>"
t += "Outlet Temperature: [round(circ1.air2.temperature, 0.1)] K<BR>"
t += "<B>Secondary Circulator (bottom or left)</B><BR>"
t += "Inlet Pressure: [round(circ2.air1.return_pressure(), 0.1)] kPa<BR>"
t += "Inlet Temperature: [round(circ2.air1.temperature, 0.1)] K<BR>"
t += "Outlet Pressure: [round(circ2.air2.return_pressure(), 0.1)] kPa<BR>"
t += "Outlet Temperature: [round(circ2.air2.temperature, 0.1)] K<BR>"
else
t += "Unable to connect to circulators.<br>"
t += "Ensure both are in position and wrenched into place."
t += "<BR>"
t += "<HR>"
t += "<A href='?src=\ref[src]'>Refresh</A> <A href='?src=\ref[src];close=1'>Close</A>"
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.unset_machine()
return 0
updateDialog()
return 1
/obj/machinery/power/generator/power_change()
..()
updateicon()
/obj/machinery/power/generator/verb/rotate_clock()
set category = "Object"
set name = "Rotate Generator (Clockwise)"
set src in view(1)
if (usr.stat || usr.restrained() || anchored)
return
src.dir = turn(src.dir, 90)
/obj/machinery/power/generator/verb/rotate_anticlock()
set category = "Object"
set name = "Rotate Generator (Counterclockwise)"
set src in view(1)
if (usr.stat || usr.restrained() || anchored)
return
src.dir = turn(src.dir, -90)
+143
View File
@@ -0,0 +1,143 @@
/obj/machinery/power/generator_type2
name = "thermoelectric generator"
desc = "It's a high efficiency thermoelectric generator."
icon_state = "teg"
anchored = 1
density = 1
use_power = 0
var/obj/machinery/atmospherics/unary/generator_input/input1
var/obj/machinery/atmospherics/unary/generator_input/input2
var/lastgen = 0
var/lastgenlev = -1
/obj/machinery/power/generator_type2/New()
..()
spawn(5)
input1 = locate(/obj/machinery/atmospherics/unary/generator_input) in get_step(src,turn(dir, 90))
input2 = locate(/obj/machinery/atmospherics/unary/generator_input) in get_step(src,turn(dir, -90))
if(!input1 || !input2)
stat |= BROKEN
updateicon()
/obj/machinery/power/generator_type2/proc/updateicon()
if(stat & (NOPOWER|BROKEN))
overlays.Cut()
else
overlays.Cut()
if(lastgenlev != 0)
overlays += image('icons/obj/power.dmi', "teg-op[lastgenlev]")
#define GENRATE 800 // generator output coefficient from Q
/obj/machinery/power/generator_type2/process()
if(!input1 || !input2)
return
var/datum/gas_mixture/air1 = input1.return_exchange_air()
var/datum/gas_mixture/air2 = input2.return_exchange_air()
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
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
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/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
//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(input2.network)
input2.network.update = 1
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()
src.updateDialog()
/obj/machinery/power/generator_type2/attack_ai(mob/user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
/obj/machinery/power/generator_type2/attack_hand(mob/user)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER)) return
interact(user)
/obj/machinery/power/generator_type2/interact(mob/user)
if ( (get_dist(src, user) > 1 ) && (!istype(user, /mob/living/silicon/ai)))
user.unset_machine()
user << browse(null, "window=teg")
return
user.set_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: [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 += "<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_type2/Topic(href, href_list)
..()
if( href_list["close"] )
usr << browse(null, "window=teg")
usr.unset_machine()
return 0
return 1
/obj/machinery/power/generator_type2/power_change()
..()
updateicon()
+144
View File
@@ -0,0 +1,144 @@
// It.. uses a lot of power. Everything under power is engineering stuff, at least.
/obj/machinery/computer/gravity_control_computer
name = "Gravity Generator Control"
desc = "A computer to control a local gravity generator. Qualified personnel only."
icon = 'icons/obj/computer.dmi'
icon_state = "airtunnel0e"
anchored = 1
density = 1
var/obj/machinery/gravity_generator = null
/obj/machinery/gravity_generator/
name = "Gravitational Generator"
desc = "A device which produces a gravaton field when set up."
icon = 'icons/obj/singularity.dmi'
icon_state = "TheSingGen"
anchored = 1
density = 1
use_power = 1
idle_power_usage = 200
active_power_usage = 1000
var/on = 1
var/list/localareas = list()
var/effectiverange = 25
// Borrows code from cloning computer
/obj/machinery/computer/gravity_control_computer/New()
..()
spawn(5)
updatemodules()
return
return
/obj/machinery/gravity_generator/New()
..()
spawn(5)
locatelocalareas()
return
return
/obj/machinery/computer/gravity_control_computer/proc/updatemodules()
src.gravity_generator = findgenerator()
/obj/machinery/gravity_generator/proc/locatelocalareas()
for(var/area/A in range(src,effectiverange))
if(A.name == "Space")
continue // No (de)gravitizing space.
if(A.master && !( A.master in localareas) )
localareas += A.master
/obj/machinery/computer/gravity_control_computer/proc/findgenerator()
var/obj/machinery/gravity_generator/foundgenerator = null
for(dir in list(NORTH,EAST,SOUTH,WEST))
//world << "SEARCHING IN [dir]"
foundgenerator = locate(/obj/machinery/gravity_generator/, get_step(src, dir))
if (!isnull(foundgenerator))
//world << "FOUND"
break
return foundgenerator
/obj/machinery/computer/gravity_control_computer/attack_paw(mob/user as mob)
return attack_hand(user)
/obj/machinery/computer/gravity_control_computer/attack_ai(mob/user as mob)
return attack_hand(user)
/obj/machinery/computer/gravity_control_computer/attack_hand(mob/user as mob)
user.set_machine(src)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER))
return
updatemodules()
var/dat = "<h3>Generator Control System</h3>"
//dat += "<font size=-1><a href='byond://?src=\ref[src];refresh=1'>Refresh</a></font>"
if(gravity_generator)
if(gravity_generator:on)
dat += "<font color=green><br><tt>Gravity Status: ON</tt></font><br>"
else
dat += "<font color=red><br><tt>Gravity Status: OFF</tt></font><br>"
dat += "<br><tt>Currently Supplying Gravitons To:</tt><br>"
for(var/area/A in gravity_generator:localareas)
if(A.has_gravity && gravity_generator:on)
dat += "<tt><font color=green>[A]</tt></font><br>"
else if (A.has_gravity)
dat += "<tt><font color=yellow>[A]</tt></font><br>"
else
dat += "<tt><font color=red>[A]</tt></font><br>"
dat += "<br><tt>Maintainence Functions:</tt><br>"
if(gravity_generator:on)
dat += "<a href='byond://?src=\ref[src];gentoggle=1'><font color=red> TURN GRAVITY GENERATOR OFF. </font></a>"
else
dat += "<a href='byond://?src=\ref[src];gentoggle=1'><font color=green> TURN GRAVITY GENERATOR ON. </font></a>"
else
dat += "No local gravity generator detected!"
user << browse(dat, "window=gravgen")
onclose(user, "gravgen")
/obj/machinery/computer/gravity_control_computer/Topic(href, href_list)
set background = 1
..()
if ( (get_dist(src, usr) > 1 ))
if (!istype(usr, /mob/living/silicon))
usr.unset_machine()
usr << browse(null, "window=air_alarm")
return
if(href_list["gentoggle"])
if(gravity_generator:on)
gravity_generator:on = 0
for(var/area/A in gravity_generator:localareas)
var/obj/machinery/gravity_generator/G
for(G in machines)
if((A.master in G.localareas) && (G.on))
break
if(!G)
A.gravitychange(0,A)
else
for(var/area/A in gravity_generator:localareas)
gravity_generator:on = 1
A.gravitychange(1,A)
src.updateUsrDialog()
return
+752
View File
@@ -0,0 +1,752 @@
// The lighting system
//
// consists of light fixtures (/obj/machinery/light) and light tube/bulb items (/obj/item/weapon/light)
// status values shared between lighting fixtures and items
#define LIGHT_OK 0
#define LIGHT_EMPTY 1
#define LIGHT_BROKEN 2
#define LIGHT_BURNED 3
/obj/item/light_fixture_frame
name = "light fixture frame"
desc = "Used for building lights."
icon = 'icons/obj/lighting.dmi'
icon_state = "tube-construct-item"
flags = FPRINT | TABLEPASS| CONDUCT
var/fixture_type = "tube"
var/obj/machinery/light/newlight = null
var/sheets_refunded = 2
/obj/item/light_fixture_frame/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/wrench))
new /obj/item/stack/sheet/metal( get_turf(src.loc), sheets_refunded )
del(src)
return
..()
/obj/item/light_fixture_frame/proc/try_build(turf/on_wall)
if (get_dist(on_wall,usr)>1)
return
var/ndir = get_dir(usr,on_wall)
if (!(ndir in cardinal))
return
var/turf/loc = get_turf_loc(usr)
if (!istype(loc, /turf/simulated/floor))
usr << "\red [src.name] cannot be placed on this spot."
return
usr << "Attaching [src] to the wall."
playsound(src.loc, 'sound/machines/click.ogg', 75, 1)
var/constrdir = usr.dir
var/constrloc = usr.loc
if (!do_after(usr, 30))
return
switch(fixture_type)
if("bulb")
newlight = new /obj/machinery/light_construct/small(constrloc)
if("tube")
newlight = new /obj/machinery/light_construct(constrloc)
newlight.dir = constrdir
newlight.fingerprints = src.fingerprints
newlight.fingerprintshidden = src.fingerprintshidden
newlight.fingerprintslast = src.fingerprintslast
usr.visible_message("[usr.name] attaches [src] to the wall.", \
"You attach [src] to the wall.")
del(src)
/obj/item/light_fixture_frame/small
name = "small light fixture frame"
desc = "Used for building small lights."
icon = 'icons/obj/lighting.dmi'
icon_state = "bulb-construct-item"
flags = FPRINT | TABLEPASS| CONDUCT
fixture_type = "bulb"
sheets_refunded = 1
/obj/machinery/light_construct
name = "light fixture frame"
desc = "A light fixture under construction."
icon = 'icons/obj/lighting.dmi'
icon_state = "tube-construct-stage1"
anchored = 1
layer = 5
var/stage = 1
var/fixture_type = "tube"
var/sheets_refunded = 2
var/obj/machinery/light/newlight = null
/obj/machinery/light_construct/New()
..()
if (fixture_type == "bulb")
icon_state = "bulb-construct-stage1"
/obj/machinery/light_construct/examine()
set src in view()
..()
if (!(usr in view(2))) return
switch(src.stage)
if(1)
usr << "It's an empty frame."
return
if(2)
usr << "It's wired."
return
if(3)
usr << "The casing is closed."
return
/obj/machinery/light_construct/attackby(obj/item/weapon/W as obj, mob/user as mob)
src.add_fingerprint(user)
if (istype(W, /obj/item/weapon/wrench))
if (src.stage == 1)
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
usr << "You begin deconstructing [src]."
if (!do_after(usr, 30))
return
new /obj/item/stack/sheet/metal( get_turf(src.loc), sheets_refunded )
user.visible_message("[user.name] deconstructs [src].", \
"You deconstruct [src].", "You hear a noise.")
playsound(src.loc, 'sound/items/Deconstruct.ogg', 75, 1)
del(src)
if (src.stage == 2)
usr << "You have to remove the wires first."
return
if (src.stage == 3)
usr << "You have to unscrew the case first."
return
if(istype(W, /obj/item/weapon/wirecutters))
if (src.stage != 2) return
src.stage = 1
switch(fixture_type)
if ("tube")
src.icon_state = "tube-construct-stage1"
if("bulb")
src.icon_state = "bulb-construct-stage1"
new /obj/item/weapon/cable_coil(get_turf(src.loc), 1, "red")
user.visible_message("[user.name] removes the wiring from [src].", \
"You remove the wiring from [src].", "You hear a noise.")
playsound(src.loc, 'sound/items/Wirecutter.ogg', 100, 1)
return
if(istype(W, /obj/item/weapon/cable_coil))
if (src.stage != 1) return
var/obj/item/weapon/cable_coil/coil = W
coil.use(1)
switch(fixture_type)
if ("tube")
src.icon_state = "tube-construct-stage2"
if("bulb")
src.icon_state = "bulb-construct-stage2"
src.stage = 2
user.visible_message("[user.name] adds wires to [src].", \
"You add wires to [src].")
return
if(istype(W, /obj/item/weapon/screwdriver))
if (src.stage == 2)
switch(fixture_type)
if ("tube")
src.icon_state = "tube-empty"
if("bulb")
src.icon_state = "bulb-empty"
src.stage = 3
user.visible_message("[user.name] closes [src]'s casing.", \
"You close [src]'s casing.", "You hear a noise.")
playsound(src.loc, 'sound/items/Screwdriver.ogg', 75, 1)
switch(fixture_type)
if("tube")
newlight = new /obj/machinery/light/built(src.loc)
if ("bulb")
newlight = new /obj/machinery/light/small/built(src.loc)
newlight.dir = src.dir
src.transfer_fingerprints_to(newlight)
del(src)
return
..()
/obj/machinery/light_construct/small
name = "small light fixture frame"
desc = "A small light fixture under construction."
icon = 'icons/obj/lighting.dmi'
icon_state = "bulb-construct-stage1"
anchored = 1
layer = 5
stage = 1
fixture_type = "bulb"
sheets_refunded = 1
// the standard tube light fixture
/obj/machinery/light
name = "light fixture"
icon = 'icons/obj/lighting.dmi'
var/base_state = "tube" // base description and icon_state
icon_state = "tube1"
desc = "A lighting fixture."
anchored = 1
layer = 5 // They were appearing under mobs which is a little weird - Ostaf
use_power = 2
idle_power_usage = 2
active_power_usage = 20
power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list
var/on = 0 // 1 if on, 0 if off
var/on_gs = 0
var/brightness = 8 // luminosity when on, also used in power calculation
var/status = LIGHT_OK // LIGHT_OK, _EMPTY, _BURNED or _BROKEN
var/flickering = 0
var/light_type = /obj/item/weapon/light/tube // the type of light item
var/fitting = "tube"
var/switchcount = 0 // count of number of times switched on/off
// this is used to calc the probability the light burns out
var/rigged = 0 // true if rigged to explode
// the smaller bulb light fixture
/obj/machinery/light/small
icon_state = "bulb1"
base_state = "bulb"
fitting = "bulb"
brightness = 4
desc = "A small lighting fixture."
light_type = /obj/item/weapon/light/bulb
/obj/machinery/light/spot
name = "spotlight"
fitting = "large tube"
light_type = /obj/item/weapon/light/tube/large
brightness = 12
/obj/machinery/light/built/New()
status = LIGHT_EMPTY
update(0)
..()
/obj/machinery/light/small/built/New()
status = LIGHT_EMPTY
update(0)
..()
// create a new lighting fixture
/obj/machinery/light/New()
..()
spawn(2)
switch(fitting)
if("tube")
brightness = 8
if(prob(2))
broken(1)
if("bulb")
brightness = 4
if(prob(5))
broken(1)
spawn(1)
update(0)
/obj/machinery/light/Del()
var/area/A = get_area(src)
if(A)
on = 0
// A.update_lights()
..()
/obj/machinery/light/update_icon()
switch(status) // set icon_states
if(LIGHT_OK)
icon_state = "[base_state][on]"
if(LIGHT_EMPTY)
icon_state = "[base_state]-empty"
on = 0
if(LIGHT_BURNED)
icon_state = "[base_state]-burned"
on = 0
if(LIGHT_BROKEN)
icon_state = "[base_state]-broken"
on = 0
return
// update the icon_state and luminosity of the light depending on its state
/obj/machinery/light/proc/update(var/trigger = 1)
update_icon()
if(on)
if(luminosity != brightness)
switchcount++
if(rigged)
if(status == LIGHT_OK && trigger)
log_admin("LOG: Rigged light explosion, last touched by [fingerprintslast]")
message_admins("LOG: Rigged light explosion, last touched by [fingerprintslast]")
explode()
else if( prob( min(60, switchcount*switchcount*0.01) ) )
if(status == LIGHT_OK && trigger)
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
on = 0
SetLuminosity(0)
else
use_power = 2
SetLuminosity(brightness)
else
use_power = 1
SetLuminosity(0)
active_power_usage = (luminosity * 10)
if(on != on_gs)
on_gs = on
// attempt to set the light's on/off status
// will not switch on if broken/burned/empty
/obj/machinery/light/proc/seton(var/s)
on = (s && status == LIGHT_OK)
update()
// examine verb
/obj/machinery/light/examine()
set src in oview(1)
if(usr && !usr.stat)
switch(status)
if(LIGHT_OK)
usr << "[desc] It is turned [on? "on" : "off"]."
if(LIGHT_EMPTY)
usr << "[desc] The [fitting] has been removed."
if(LIGHT_BURNED)
usr << "[desc] The [fitting] is burnt out."
if(LIGHT_BROKEN)
usr << "[desc] The [fitting] has been smashed."
// attack with item - insert light (if right type), otherwise try to break the light
/obj/machinery/light/attackby(obj/item/W, mob/user)
//Light replacer code
if(istype(W, /obj/item/device/lightreplacer))
var/obj/item/device/lightreplacer/LR = W
if(isliving(user))
var/mob/living/U = user
LR.ReplaceLight(src, U)
return
// attempt to insert light
if(istype(W, /obj/item/weapon/light))
if(status != LIGHT_EMPTY)
user << "There is a [fitting] already inserted."
return
else
src.add_fingerprint(user)
var/obj/item/weapon/light/L = W
if(istype(L, light_type))
status = L.status
user << "You insert the [L.name]."
switchcount = L.switchcount
rigged = L.rigged
brightness = L.brightness
on = has_power()
update()
user.drop_item() //drop the item to update overlays and such
del(L)
if(on && rigged)
log_admin("LOG: Rigged light explosion, last touched by [fingerprintslast]")
message_admins("LOG: Rigged light explosion, last touched by [fingerprintslast]")
explode()
else
user << "This type of light requires a [fitting]."
return
// attempt to break the light
//If xenos decide they want to smash a light bulb with a toolbox, who am I to stop them? /N
else if(status != LIGHT_BROKEN && status != LIGHT_EMPTY)
if(prob(1+W.force * 5))
user << "You hit the light, and it smashes!"
for(var/mob/M in viewers(src))
if(M == user)
continue
M.show_message("[user.name] smashed the light!", 3, "You hear a tinkle of breaking glass", 2)
if(on && (W.flags & CONDUCT))
//if(!user.mutations & COLD_RESISTANCE)
if (prob(12))
electrocute_mob(user, get_area(src), src, 0.3)
broken()
else
user << "You hit the light!"
// attempt to stick weapon into light socket
else if(status == LIGHT_EMPTY)
if(istype(W, /obj/item/weapon/screwdriver)) //If it's a screwdriver open it.
playsound(src.loc, 'sound/items/Screwdriver.ogg', 75, 1)
user.visible_message("[user.name] opens [src]'s casing.", \
"You open [src]'s casing.", "You hear a noise.")
var/obj/machinery/light_construct/newlight = null
switch(fitting)
if("tube")
newlight = new /obj/machinery/light_construct(src.loc)
newlight.icon_state = "tube-construct-stage2"
if("bulb")
newlight = new /obj/machinery/light_construct/small(src.loc)
newlight.icon_state = "bulb-construct-stage2"
newlight.dir = src.dir
newlight.stage = 2
newlight.fingerprints = src.fingerprints
newlight.fingerprintshidden = src.fingerprintshidden
newlight.fingerprintslast = src.fingerprintslast
del(src)
return
user << "You stick \the [W] into the light socket!"
if(has_power() && (W.flags & CONDUCT))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)
s.start()
//if(!user.mutations & COLD_RESISTANCE)
if (prob(75))
electrocute_mob(user, get_area(src), src, rand(0.7,1.0))
// returns whether this light has power
// true if area has power and lightswitch is on
/obj/machinery/light/proc/has_power()
var/area/A = src.loc.loc
return A.master.lightswitch && A.master.power_light
/obj/machinery/light/proc/flicker(var/amount = rand(10, 20))
if(flickering) return
flickering = 1
spawn(0)
if(on && status == LIGHT_OK)
for(var/i = 0; i < amount; i++)
if(status != LIGHT_OK) break
on = !on
update(0)
sleep(rand(5, 15))
on = (status == LIGHT_OK)
update(0)
flickering = 0
// ai attack - make lights flicker, because why not
/obj/machinery/light/attack_ai(mob/user)
src.flicker(1)
return
// Aliens smash the bulb but do not get electrocuted./N
/obj/machinery/light/attack_alien(mob/living/carbon/alien/humanoid/user)//So larva don't go breaking light bulbs.
if(status == LIGHT_EMPTY||status == LIGHT_BROKEN)
user << "\green That object is useless to you."
return
else if (status == LIGHT_OK||status == LIGHT_BURNED)
for(var/mob/M in viewers(src))
M.show_message("\red [user.name] smashed the light!", 3, "You hear a tinkle of breaking glass", 2)
broken()
return
/obj/machinery/light/attack_animal(mob/living/simple_animal/M)
if(M.melee_damage_upper == 0) return
if(status == LIGHT_EMPTY||status == LIGHT_BROKEN)
M << "\red That object is useless to you."
return
else if (status == LIGHT_OK||status == LIGHT_BURNED)
for(var/mob/O in viewers(src))
O.show_message("\red [M.name] smashed the light!", 3, "You hear a tinkle of breaking glass", 2)
broken()
return
// attack with hand - remove tube/bulb
// if hands aren't protected and the light is on, burn the player
/obj/machinery/light/attack_hand(mob/user)
add_fingerprint(user)
if(status == LIGHT_EMPTY)
user << "There is no [fitting] in this light."
return
// make it burn hands if not wearing fire-insulated gloves
if(on)
var/prot = 0
var/mob/living/carbon/human/H = user
if(istype(H))
if(H.gloves)
var/obj/item/clothing/gloves/G = H.gloves
if(G.max_heat_protection_temperature)
prot = (G.max_heat_protection_temperature > 360)
else
prot = 1
if(prot > 0 || (COLD_RESISTANCE in user.mutations))
user << "You remove the light [fitting]"
else if(TK in user.mutations)
user << "You telekinetically remove the light [fitting]."
else
user << "You try to remove the light [fitting], but it's too hot and you don't want to burn your hand."
return // if burned, don't remove the light
else
user << "You remove the light [fitting]."
// create a light tube/bulb item and put it in the user's hand
var/obj/item/weapon/light/L = new light_type()
L.status = status
L.rigged = rigged
L.brightness = src.brightness
// light item inherits the switchcount, then zero it
L.switchcount = switchcount
switchcount = 0
L.update()
L.add_fingerprint(user)
user.put_in_active_hand(L) //puts it in our active hand
status = LIGHT_EMPTY
update()
/obj/machinery/light/attack_tk(mob/user)
if(status == LIGHT_EMPTY)
user << "There is no [fitting] in this light."
return
user << "You telekinetically remove the light [fitting]."
// create a light tube/bulb item and put it in the user's hand
var/obj/item/weapon/light/L = new light_type()
L.status = status
L.rigged = rigged
L.brightness = brightness
// light item inherits the switchcount, then zero it
L.switchcount = switchcount
switchcount = 0
L.update()
L.add_fingerprint(user)
L.loc = loc
status = LIGHT_EMPTY
update()
// break the light and make sparks if was on
/obj/machinery/light/proc/broken(var/skip_sound_and_sparks = 0)
if(status == LIGHT_EMPTY)
return
if(!skip_sound_and_sparks)
if(status == LIGHT_OK || status == LIGHT_BURNED)
playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1)
if(on)
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)
s.start()
status = LIGHT_BROKEN
update()
/obj/machinery/light/proc/fix()
if(status == LIGHT_OK)
return
status = LIGHT_OK
brightness = initial(brightness)
on = 1
update()
// explosion effect
// destroy the whole light fixture or just shatter it
/obj/machinery/light/ex_act(severity)
switch(severity)
if(1.0)
del(src)
return
if(2.0)
if (prob(75))
broken()
if(3.0)
if (prob(50))
broken()
return
//blob effect
/obj/machinery/light/blob_act()
if(prob(75))
broken()
// timed process
// use power
#define LIGHTING_POWER_FACTOR 20 //20W per unit luminosity
/obj/machinery/light/process()//TODO: remove/add this from machines to save on processing as needed ~Carn PRIORITY
if(on)
use_power(luminosity * LIGHTING_POWER_FACTOR, LIGHT)
// called when area power state changes
/obj/machinery/light/power_change()
spawn(10)
var/area/A = src.loc.loc
A = A.master
seton(A.lightswitch && A.power_light)
// called when on fire
/obj/machinery/light/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(prob(max(0, exposed_temperature - 673))) //0% at <400C, 100% at >500C
broken()
// explode the light
/obj/machinery/light/proc/explode()
var/turf/T = get_turf(src.loc)
spawn(0)
broken() // break it first to give a warning
sleep(2)
explosion(T, 0, 0, 2, 2)
sleep(1)
del(src)
// the light item
// can be tube or bulb subtypes
// will fit into empty /obj/machinery/light of the corresponding type
/obj/item/weapon/light
icon = 'icons/obj/lighting.dmi'
flags = FPRINT | TABLEPASS
force = 2
throwforce = 5
w_class = 1
var/status = 0 // LIGHT_OK, LIGHT_BURNED or LIGHT_BROKEN
var/base_state
var/switchcount = 0 // number of times switched
m_amt = 60
var/rigged = 0 // true if rigged to explode
var/brightness = 2 //how much light it gives off
/obj/item/weapon/light/tube
name = "light tube"
desc = "A replacement light tube."
icon_state = "ltube"
base_state = "ltube"
item_state = "c_tube"
g_amt = 100
brightness = 8
/obj/item/weapon/light/tube/large
w_class = 2
name = "large light tube"
brightness = 15
/obj/item/weapon/light/bulb
name = "light bulb"
desc = "A replacement light bulb."
icon_state = "lbulb"
base_state = "lbulb"
item_state = "contvapour"
g_amt = 100
brightness = 5
/obj/item/weapon/light/throw_impact(atom/hit_atom)
..()
shatter()
/obj/item/weapon/light/bulb/fire
name = "fire bulb"
desc = "A replacement fire bulb."
icon_state = "fbulb"
base_state = "fbulb"
item_state = "egg4"
g_amt = 100
brightness = 5
// update the icon state and description of the light
/obj/item/weapon/light/proc/update()
switch(status)
if(LIGHT_OK)
icon_state = base_state
desc = "A replacement [name]."
if(LIGHT_BURNED)
icon_state = "[base_state]-burned"
desc = "A burnt-out [name]."
if(LIGHT_BROKEN)
icon_state = "[base_state]-broken"
desc = "A broken [name]."
/obj/item/weapon/light/New()
..()
switch(name)
if("light tube")
brightness = rand(6,9)
if("light bulb")
brightness = rand(4,6)
update()
// attack bulb/tube with object
// if a syringe, can inject plasma to make it explode
/obj/item/weapon/light/attackby(var/obj/item/I, var/mob/user)
..()
if(istype(I, /obj/item/weapon/reagent_containers/syringe))
var/obj/item/weapon/reagent_containers/syringe/S = I
user << "You inject the solution into the [src]."
if(S.reagents.has_reagent("plasma", 5))
log_admin("LOG: [user.name] ([user.ckey]) injected a light with plasma, rigging it to explode.")
message_admins("LOG: [user.name] ([user.ckey]) injected a light with plasma, rigging it to explode.")
rigged = 1
S.reagents.clear_reagents()
else
..()
return
// called after an attack with a light item
// shatter light, unless it was an attempt to put it in a light socket
// now only shatter if the intent was harm
/obj/item/weapon/light/afterattack(atom/target, mob/user, proximity)
if(!proximity) return
if(istype(target, /obj/machinery/light))
return
if(user.a_intent != "hurt")
return
shatter()
/obj/item/weapon/light/proc/shatter()
if(status == LIGHT_OK || status == LIGHT_BURNED)
src.visible_message("\red [name] shatters.","\red You hear a small glass object shatter.")
status = LIGHT_BROKEN
force = 5
playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1)
update()
+181
View File
@@ -0,0 +1,181 @@
//This file was auto-corrected by findeclaration.exe on 29/05/2012 15:03:05
//Baseline portable generator. Has all the default handling. Not intended to be used on it's own (since it generates unlimited power).
/obj/machinery/power/port_gen/pacman2
name = "Pacman II"
desc = "P.A.C.M.A.N. type II portable generator. Uses liquid plasma as a fuel source."
power_gen = 4500
var/obj/item/weapon/tank/plasma/P = null
var/board_path = "/obj/item/weapon/circuitboard/pacman2"
var/emagged = 0
var/heat = 0
/*
process()
if(P)
if(P.air_contents.toxins <= 0)
P.air_contents.toxins = 0
eject()
else
P.air_contents.toxins -= 0.001
return
*/
HasFuel()
if(P.air_contents.toxins >= 0.1)
return 1
return 0
UseFuel()
P.air_contents.toxins -= 0.01
return
New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/micro_laser(src)
component_parts += new /obj/item/weapon/cable_coil(src)
component_parts += new /obj/item/weapon/cable_coil(src)
component_parts += new /obj/item/weapon/stock_parts/capacitor(src)
component_parts += new board_path(src)
RefreshParts()
RefreshParts()
var/temp_rating = 0
var/temp_reliability = 0
for(var/obj/item/weapon/stock_parts/SP in component_parts)
if(istype(SP, /obj/item/weapon/stock_parts/matter_bin))
//max_coins = SP.rating * SP.rating * 1000
else if(istype(SP, /obj/item/weapon/stock_parts/micro_laser) || istype(SP, /obj/item/weapon/stock_parts/capacitor))
temp_rating += SP.rating
for(var/obj/item/weapon/CP in component_parts)
temp_reliability += CP.reliability
reliability = min(round(temp_reliability / 4), 100)
power_gen = round(initial(power_gen) * (max(2, temp_rating) / 2))
examine()
..()
usr << "\blue The generator has [P.air_contents.toxins] units of fuel left, producing [power_gen] per cycle."
if(crit_fail) usr << "\red The generator seems to have broken down."
handleInactive()
heat -= 2
if (heat < 0)
heat = 0
else
for(var/mob/M in viewers(1, src))
if (M.client && M.machine == src)
src.updateUsrDialog()
proc
overheat()
explosion(get_turf(src), 2, 5, 2, -1)
attackby(var/obj/item/O as obj, var/mob/user as mob)
if(istype(O, /obj/item/weapon/tank/plasma))
if(P)
user << "\red The generator already has a plasma tank loaded!"
return
P = O
user.drop_item()
O.loc = src
user << "\blue You add the plasma tank to the generator."
else if (istype(O, /obj/item/weapon/card/emag))
var/obj/item/weapon/card/emag/E = O
if(E.uses)
E.uses--
else
return
emagged = 1
emp_act(1)
else if(!active)
if(istype(O, /obj/item/weapon/wrench))
anchored = !anchored
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
if(anchored)
user << "\blue You secure the generator to the floor."
else
user << "\blue You unsecure the generator from the floor."
makepowernets()
else if(istype(O, /obj/item/weapon/screwdriver))
open = !open
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
if(open)
user << "\blue You open the access panel."
else
user << "\blue You close the access panel."
else if(istype(O, /obj/item/weapon/crowbar) && !open)
var/obj/machinery/constructable_frame/machine_frame/new_frame = new /obj/machinery/constructable_frame/machine_frame(src.loc)
for(var/obj/item/I in component_parts)
if(I.reliability < 100)
I.crit_fail = 1
I.loc = src.loc
new_frame.state = 2
new_frame.icon_state = "box_1"
del(src)
attack_hand(mob/user as mob)
..()
if (!anchored)
return
interact(user)
attack_ai(mob/user as mob)
interact(user)
attack_paw(mob/user as mob)
interact(user)
proc
interact(mob/user)
if (get_dist(src, user) > 1 )
if (!istype(user, /mob/living/silicon/ai))
user.machine = null
user << browse(null, "window=port_gen")
return
user.machine = src
var/dat = text("<b>[name]</b><br>")
if (active)
dat += text("Generator: <A href='?src=\ref[src];action=disable'>On</A><br>")
else
dat += text("Generator: <A href='?src=\ref[src];action=enable'>Off</A><br>")
if(P)
dat += text("Currently loaded plasma tank: [P.air_contents.toxins]<br>")
else
dat += text("No plasma tank currently loaded.<br>")
dat += text("Power output: <A href='?src=\ref[src];action=lower_power'>-</A> [power_gen * power_output] <A href='?src=\ref[src];action=higher_power'>+</A><br>")
dat += text("Heat: [heat]<br>")
dat += "<br><A href='?src=\ref[src];action=close'>Close</A>"
user << browse("[dat]", "window=port_gen")
Topic(href, href_list)
if(..())
return
src.add_fingerprint(usr)
if(href_list["action"])
if(href_list["action"] == "enable")
if(!active && HasFuel() && !crit_fail)
active = 1
icon_state = "portgen1"
src.updateUsrDialog()
if(href_list["action"] == "disable")
if (active)
active = 0
icon_state = "portgen0"
src.updateUsrDialog()
if(href_list["action"] == "lower_power")
if (power_output > 1)
power_output--
src.updateUsrDialog()
if (href_list["action"] == "higher_power")
if (power_output < 4 || emagged)
power_output++
src.updateUsrDialog()
if (href_list["action"] == "close")
usr << browse(null, "window=port_gen")
usr.machine = null
+345
View File
@@ -0,0 +1,345 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/* new portable generator - work in progress
/obj/machinery/power/port_gen
name = "portable generator"
desc = "A portable generator used for emergency backup power."
icon = 'generator.dmi'
icon_state = "off"
density = 1
anchored = 0
directwired = 0
var/t_status = 0
var/t_per = 5000
var/filter = 1
var/tank = null
var/turf/inturf
var/starter = 0
var/rpm = 0
var/rpmtarget = 0
var/capacity = 1e6
var/turf/outturf
var/lastgen
/obj/machinery/power/port_gen/process()
ideally we're looking to generate 5000
/obj/machinery/power/port_gen/attackby(obj/item/weapon/W, mob/user)
tank [un]loading stuff
/obj/machinery/power/port_gen/attack_hand(mob/user)
turn on/off
/obj/machinery/power/port_gen/examine()
display round(lastgen) and plasmatank amount
*/
//Previous code been here forever, adding new framework for portable generators
//Baseline portable generator. Has all the default handling. Not intended to be used on it's own (since it generates unlimited power).
/obj/machinery/power/port_gen
name = "Portable Generator"
desc = "A portable generator for emergency backup power"
icon = 'icons/obj/power.dmi'
icon_state = "portgen0"
density = 1
anchored = 0
directwired = 0
use_power = 0
var/active = 0
var/power_gen = 5000
var/open = 0
var/recent_fault = 0
var/power_output = 1
/obj/machinery/power/port_gen/proc/HasFuel() //Placeholder for fuel check.
return 1
/obj/machinery/power/port_gen/proc/UseFuel() //Placeholder for fuel use.
return
/obj/machinery/power/port_gen/proc/DropFuel()
return
/obj/machinery/power/port_gen/proc/handleInactive()
return
/obj/machinery/power/port_gen/process()
if(active && HasFuel() && !crit_fail && anchored && powernet)
add_avail(power_gen * power_output)
UseFuel()
src.updateDialog()
else
active = 0
icon_state = initial(icon_state)
handleInactive()
/obj/machinery/power/port_gen/attack_hand(mob/user as mob)
if(..())
return
if(!anchored)
return
/obj/machinery/power/port_gen/examine()
set src in oview(1)
if(active)
usr << "\blue The generator is on."
else
usr << "\blue The generator is off."
/obj/machinery/power/port_gen/pacman
name = "P.A.C.M.A.N.-type Portable Generator"
var/sheets = 0
var/max_sheets = 100
var/sheet_name = ""
var/sheet_path = /obj/item/stack/sheet/mineral/plasma
var/board_path = "/obj/item/weapon/circuitboard/pacman"
var/sheet_left = 0 // How much is left of the sheet
var/time_per_sheet = 40
var/heat = 0
/obj/machinery/power/port_gen/pacman/initialize()
..()
if(anchored)
connect_to_network()
/obj/machinery/power/port_gen/pacman/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/micro_laser(src)
component_parts += new /obj/item/weapon/cable_coil(src)
component_parts += new /obj/item/weapon/cable_coil(src)
component_parts += new /obj/item/weapon/stock_parts/capacitor(src)
component_parts += new board_path(src)
var/obj/sheet = new sheet_path(null)
sheet_name = sheet.name
RefreshParts()
/obj/machinery/power/port_gen/pacman/Del()
DropFuel()
..()
/obj/machinery/power/port_gen/pacman/RefreshParts()
var/temp_rating = 0
var/temp_reliability = 0
for(var/obj/item/weapon/stock_parts/SP in component_parts)
if(istype(SP, /obj/item/weapon/stock_parts/matter_bin))
max_sheets = SP.rating * SP.rating * 50
else if(istype(SP, /obj/item/weapon/stock_parts/micro_laser) || istype(SP, /obj/item/weapon/stock_parts/capacitor))
temp_rating += SP.rating
for(var/obj/item/weapon/CP in component_parts)
temp_reliability += CP.reliability
reliability = min(round(temp_reliability / 4), 100)
power_gen = round(initial(power_gen) * (max(2, temp_rating) / 2))
/obj/machinery/power/port_gen/pacman/examine()
..()
usr << "\blue The generator has [sheets] units of [sheet_name] fuel left, producing [power_gen] per cycle."
if(crit_fail) usr << "\red The generator seems to have broken down."
/obj/machinery/power/port_gen/pacman/HasFuel()
if(sheets >= 1 / (time_per_sheet / power_output) - sheet_left)
return 1
return 0
/obj/machinery/power/port_gen/pacman/DropFuel()
if(sheets)
var/fail_safe = 0
while(sheets > 0 && fail_safe < 100)
fail_safe += 1
var/obj/item/stack/sheet/S = new sheet_path(loc)
var/amount = min(sheets, S.max_amount)
S.amount = amount
sheets -= amount
/obj/machinery/power/port_gen/pacman/UseFuel()
var/needed_sheets = 1 / (time_per_sheet / power_output)
var/temp = min(needed_sheets, sheet_left)
needed_sheets -= temp
sheet_left -= temp
sheets -= round(needed_sheets)
needed_sheets -= round(needed_sheets)
if (sheet_left <= 0 && sheets > 0)
sheet_left = 1 - needed_sheets
sheets--
var/lower_limit = 56 + power_output * 10
var/upper_limit = 76 + power_output * 10
var/bias = 0
if (power_output > 4)
upper_limit = 400
bias = power_output * 3
if (heat < lower_limit)
heat += 3
else
heat += rand(-7 + bias, 7 + bias)
if (heat < lower_limit)
heat = lower_limit
if (heat > upper_limit)
heat = upper_limit
if (heat > 300)
overheat()
del(src)
return
/obj/machinery/power/port_gen/pacman/handleInactive()
if (heat > 0)
heat = max(heat - 2, 0)
src.updateDialog()
/obj/machinery/power/port_gen/pacman/proc/overheat()
explosion(src.loc, 2, 5, 2, -1)
/obj/machinery/power/port_gen/pacman/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(istype(O, sheet_path))
var/obj/item/stack/addstack = O
var/amount = min((max_sheets - sheets), addstack.amount)
if(amount < 1)
user << "\blue The [src.name] is full!"
return
user << "\blue You add [amount] sheets to the [src.name]."
sheets += amount
addstack.use(amount)
updateUsrDialog()
return
else if (istype(O, /obj/item/weapon/card/emag))
emagged = 1
emp_act(1)
else if(!active)
if(istype(O, /obj/item/weapon/wrench))
if(!anchored)
connect_to_network()
user << "\blue You secure the generator to the floor."
else
disconnect_from_network()
user << "\blue You unsecure the generator from the floor."
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
anchored = !anchored
else if(istype(O, /obj/item/weapon/screwdriver))
open = !open
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
if(open)
user << "\blue You open the access panel."
else
user << "\blue You close the access panel."
else if(istype(O, /obj/item/weapon/crowbar) && open)
var/obj/machinery/constructable_frame/machine_frame/new_frame = new /obj/machinery/constructable_frame/machine_frame(src.loc)
for(var/obj/item/I in component_parts)
if(I.reliability < 100)
I.crit_fail = 1
I.loc = src.loc
while ( sheets > 0 )
var/obj/item/stack/sheet/G = new sheet_path(src.loc)
if ( sheets > 50 )
G.amount = 50
else
G.amount = sheets
sheets -= G.amount
new_frame.state = 2
new_frame.icon_state = "box_1"
del(src)
/obj/machinery/power/port_gen/pacman/attack_hand(mob/user as mob)
..()
if (!anchored)
return
interact(user)
/obj/machinery/power/port_gen/pacman/attack_ai(mob/user as mob)
interact(user)
/obj/machinery/power/port_gen/pacman/attack_paw(mob/user as mob)
interact(user)
/obj/machinery/power/port_gen/pacman/interact(mob/user)
if (get_dist(src, user) > 1 )
if (!istype(user, /mob/living/silicon/ai))
user.unset_machine()
user << browse(null, "window=port_gen")
return
user.set_machine(src)
var/dat = text("<b>[name]</b><br>")
if (active)
dat += text("Generator: <A href='?src=\ref[src];action=disable'>On</A><br>")
else
dat += text("Generator: <A href='?src=\ref[src];action=enable'>Off</A><br>")
dat += text("[capitalize(sheet_name)]: [sheets] - <A href='?src=\ref[src];action=eject'>Eject</A><br>")
var/stack_percent = round(sheet_left * 100, 1)
dat += text("Current stack: [stack_percent]% <br>")
dat += text("Power output: <A href='?src=\ref[src];action=lower_power'>-</A> [power_gen * power_output] <A href='?src=\ref[src];action=higher_power'>+</A><br>")
dat += text("Power current: [(powernet == null ? "Unconnected" : "[avail()]")]<br>")
dat += text("Heat: [heat]<br>")
dat += "<br><A href='?src=\ref[src];action=close'>Close</A>"
user << browse("[dat]", "window=port_gen")
onclose(user, "port_gen")
/obj/machinery/power/port_gen/pacman/Topic(href, href_list)
if(..())
return
src.add_fingerprint(usr)
if(href_list["action"])
if(href_list["action"] == "enable")
if(!active && HasFuel() && !crit_fail)
active = 1
icon_state = "portgen1"
src.updateUsrDialog()
if(href_list["action"] == "disable")
if (active)
active = 0
icon_state = "portgen0"
src.updateUsrDialog()
if(href_list["action"] == "eject")
if(!active)
DropFuel()
src.updateUsrDialog()
if(href_list["action"] == "lower_power")
if (power_output > 1)
power_output--
src.updateUsrDialog()
if (href_list["action"] == "higher_power")
if (power_output < 4 || emagged)
power_output++
src.updateUsrDialog()
if (href_list["action"] == "close")
usr << browse(null, "window=port_gen")
usr.unset_machine()
/obj/machinery/power/port_gen/pacman/super
name = "S.U.P.E.R.P.A.C.M.A.N.-type Portable Generator"
icon_state = "portgen1"
sheet_path = /obj/item/stack/sheet/mineral/uranium
power_gen = 15000
time_per_sheet = 65
board_path = "/obj/item/weapon/circuitboard/pacman/super"
overheat()
explosion(src.loc, 3, 3, 3, -1)
/obj/machinery/power/port_gen/pacman/mrs
name = "M.R.S.P.A.C.M.A.N.-type Portable Generator"
icon_state = "portgen2"
sheet_path = /obj/item/stack/sheet/mineral/diamond
power_gen = 40000
time_per_sheet = 80
board_path = "/obj/item/weapon/circuitboard/pacman/mrs"
overheat()
explosion(src.loc, 4, 4, 4, -1)
+504
View File
@@ -0,0 +1,504 @@
/obj/machinery/power
name = null
icon = 'icons/obj/power.dmi'
anchored = 1.0
var/datum/powernet/powernet = null
var/directwired = 1 // by default, power machines are connected by a cable in a neighbouring turf
// if set to 0, requires a 0-X cable on this turf
use_power = 0
idle_power_usage = 0
active_power_usage = 0
/obj/machinery/power/Del()
disconnect_from_network()
..()
// common helper procs for all power machines
/obj/machinery/power/proc/add_avail(var/amount)
if(powernet)
powernet.newavail += amount
/obj/machinery/power/proc/add_load(var/amount)
if(powernet)
powernet.newload += amount
/obj/machinery/power/proc/surplus()
if(powernet)
return powernet.avail-powernet.load
else
return 0
/obj/machinery/power/proc/avail()
if(powernet)
return powernet.avail
else
return 0
// returns true if the area has power on given channel (or doesn't require power).
// defaults to power_channel
/obj/machinery/proc/powered(var/chan = -1)
if(!src.loc)
return 0
if(!use_power)
return 1
var/area/A = src.loc.loc // make sure it's in an area
if(!A || !isarea(A) || !A.master)
return 0 // if not, then not powered
if(chan == -1)
chan = power_channel
return A.master.powered(chan) // return power status of the area
// increment the power usage stats for an area
/obj/machinery/proc/use_power(var/amount, var/chan = -1) // defaults to power_channel
var/area/A = src.loc.loc // make sure it's in an area
if(!A || !isarea(A) || !A.master)
return
if(chan == -1)
chan = power_channel
A.master.use_power(amount, chan)
/obj/machinery/proc/power_change() // called whenever the power settings of the containing area change
// by default, check equipment channel & set flag
// can override if needed
if(powered(power_channel))
stat &= ~NOPOWER
else
stat |= NOPOWER
return
// the powernet datum
// each contiguous network of cables & nodes
// rebuild all power networks from scratch
/hook/startup/proc/buildPowernets()
return makepowernets()
/proc/makepowernets()
for(var/datum/powernet/PN in powernets)
del(PN)
powernets.Cut()
for(var/obj/structure/cable/PC in cable_list)
if(!PC.powernet)
PC.powernet = new()
powernets += PC.powernet
// if(Debug) world.log << "Starting mpn at [PC.x],[PC.y] ([PC.d1]/[PC.d2])"
powernet_nextlink(PC,PC.powernet)
// if(Debug) world.log << "[powernets.len] powernets found"
for(var/obj/structure/cable/C in cable_list)
if(!C.powernet) continue
C.powernet.cables += C
for(var/obj/machinery/power/M in machines)
if(!M.powernet) continue // APCs have powernet=0 so they don't count as network nodes directly
M.powernet.nodes[M] = M
return 1
// returns a list of all power-related objects (nodes, cable, junctions) in turf,
// excluding source, that match the direction d
// if unmarked==1, only return those with no powernet
/proc/power_list(var/turf/T, var/source, var/d, var/unmarked=0)
. = list()
var/fdir = (!d)? 0 : turn(d, 180) // the opposite direction to d (or 0 if d==0)
// world.log << "d=[d] fdir=[fdir]"
for(var/AM in T)
if(AM == source) continue //we don't want to return source
if(istype(AM,/obj/machinery/power))
var/obj/machinery/power/P = AM
if(P.powernet == 0) continue // exclude APCs which have powernet=0
if(!unmarked || !P.powernet) //if unmarked=1 we only return things with no powernet
if(P.directwired || (d == 0))
. += P
else if(istype(AM,/obj/structure/cable))
var/obj/structure/cable/C = AM
if(!unmarked || !C.powernet)
if(C.d1 == fdir || C.d2 == fdir)
. += C
else if(C.d1 == turn(C.d2, 180))
. += C
return .
/obj/structure/cable/proc/get_connections()
. = list() // this will be a list of all connected power objects
var/turf/T = loc
if(d1) T = get_step(src, d1)
if(T) . += power_list(T, src, d1, 1)
T = get_step(src, d2)
if(T) . += power_list(T, src, d2, 1)
return .
/obj/machinery/power/proc/get_connections()
. = list()
if(!directwired)
return get_indirect_connections()
var/cdir
for(var/card in cardinal)
var/turf/T = get_step(loc,card)
cdir = get_dir(T,loc)
for(var/obj/structure/cable/C in T)
if(C.powernet) continue
if(C.d1 == cdir || C.d2 == cdir)
. += C
return .
/obj/machinery/power/proc/get_indirect_connections()
. = list()
for(var/obj/structure/cable/C in loc)
if(C.powernet) continue
if(C.d1 == 0)
. += C
return .
/proc/powernet_nextlink(var/obj/O, var/datum/powernet/PN)
var/list/P
while(1)
if( istype(O,/obj/structure/cable) )
var/obj/structure/cable/C = O
C.powernet = PN
P = C.get_connections()
else if(O.anchored && istype(O,/obj/machinery/power))
var/obj/machinery/power/M = O
M.powernet = PN
P = M.get_connections()
else
return
if(P.len == 0) return
O = P[1]
for(var/L = 2 to P.len)
powernet_nextlink(P[L], PN)
// cut a powernet at this cable object
/datum/powernet/proc/cut_cable(var/obj/structure/cable/C)
var/turf/T1 = C.loc
if(!T1) return
var/node = 0
if(C.d1 == 0)
node = 1
var/turf/T2
if(C.d2) T2 = get_step(T1, C.d2)
if(C.d1) T1 = get_step(T1, C.d1)
var/list/P1 = power_list(T1, C, C.d1) // what joins on to cut cable in dir1
var/list/P2 = power_list(T2, C, C.d2) // what joins on to cut cable in dir2
// if(Debug)
// for(var/obj/O in P1)
// world.log << "P1: [O] at [O.x] [O.y] : [istype(O, /obj/structure/cable) ? "[O:d1]/[O:d2]" : null] "
// for(var/obj/O in P2)
// world.log << "P2: [O] at [O.x] [O.y] : [istype(O, /obj/structure/cable) ? "[O:d1]/[O:d2]" : null] "
if(P1.len == 0 || P2.len == 0)//if nothing in either list, then the cable was an endpoint no need to rebuild the powernet,
cables -= C //just remove cut cable from the list
// if(Debug) world.log << "Was end of cable"
return
//null the powernet reference of all cables & nodes in this powernet
var/i=1
while(i<=cables.len)
var/obj/structure/cable/Cable = cables[i]
if(Cable)
Cable.powernet = null
if(Cable == C)
cables.Cut(i,i+1)
continue
i++
i=1
while(i<=nodes.len)
var/obj/machinery/power/Node = nodes[i]
if(Node)
Node.powernet = null
i++
// remove the cut cable from the network
// C.netnum = -1
C.loc = null
powernet_nextlink(P1[1], src) // propagate network from 1st side of cable, using current netnum //TODO?
// now test to see if propagation reached to the other side
// if so, then there's a loop in the network
var/notlooped = 0
for(var/O in P2)
if( istype(O, /obj/machinery/power) )
var/obj/machinery/power/Machine = O
if(Machine.powernet != src)
notlooped = 1
break
else if( istype(O, /obj/structure/cable) )
var/obj/structure/cable/Cable = O
if(Cable.powernet != src)
notlooped = 1
break
if(notlooped)
// not looped, so make a new powernet
var/datum/powernet/PN = new()
powernets += PN
// if(Debug) world.log << "Was not looped: spliting PN#[number] ([cables.len];[nodes.len])"
i=1
while(i<=cables.len)
var/obj/structure/cable/Cable = cables[i]
if(Cable && !Cable.powernet) // non-connected cables will have powernet=null, since they weren't reached by propagation
Cable.powernet = PN
cables.Cut(i,i+1) // remove from old network & add to new one
PN.cables += Cable
continue
i++
i=1
while(i<=nodes.len)
var/obj/machinery/power/Node = nodes[i]
if(Node && !Node.powernet)
Node.powernet = PN
nodes.Cut(i,i+1)
PN.nodes[Node] = Node
continue
i++
// Disconnect machines connected to nodes
if(node)
for(var/obj/machinery/power/P in T1)
if(P.powernet && !P.powernet.nodes[src])
P.disconnect_from_network()
// if(Debug)
// world.log << "Old PN#[number] : ([cables.len];[nodes.len])"
// world.log << "New PN#[PN.number] : ([PN.cables.len];[PN.nodes.len])"
//
// else
// if(Debug)
// world.log << "Was looped."
// //there is a loop, so nothing to be done
// return
/datum/powernet/proc/reset()
load = newload
newload = 0
avail = newavail
newavail = 0
viewload = 0.8*viewload + 0.2*load
viewload = round(viewload)
var/numapc = 0
if(nodes && nodes.len) // Added to fix a bad list bug -- TLE
for(var/obj/machinery/power/terminal/term in nodes)
if( istype( term.master, /obj/machinery/power/apc ) )
numapc++
if(numapc)
perapc = avail/numapc
netexcess = avail - load
if( netexcess > 100) // if there was excess power last cycle
if(nodes && nodes.len)
for(var/obj/machinery/power/smes/S in nodes) // find the SMESes in the network
if(S.powernet == src)
S.restore() // and restore some of the power that was used
else
error("[S.name] (\ref[S]) had a [S.powernet ? "different (\ref[S.powernet])" : "null"] powernet to our powernet (\ref[src]).")
nodes.Remove(S)
/datum/powernet/proc/get_electrocute_damage()
switch(avail)/*
if (1300000 to INFINITY)
return min(rand(70,150),rand(70,150))
if (750000 to 1300000)
return min(rand(50,115),rand(50,115))
if (100000 to 750000-1)
return min(rand(35,101),rand(35,101))
if (75000 to 100000-1)
return min(rand(30,95),rand(30,95))
if (50000 to 75000-1)
return min(rand(25,80),rand(25,80))
if (25000 to 50000-1)
return min(rand(20,70),rand(20,70))
if (10000 to 25000-1)
return min(rand(20,65),rand(20,65))
if (1000 to 10000-1)
return min(rand(10,20),rand(10,20))*/
if (1000000 to INFINITY)
return min(rand(50,160),rand(50,160))
if (200000 to 1000000)
return min(rand(25,80),rand(25,80))
if (100000 to 200000)//Ave powernet
return min(rand(20,60),rand(20,60))
if (50000 to 100000)
return min(rand(15,40),rand(15,40))
if (1000 to 50000)
return min(rand(10,20),rand(10,20))
else
return 0
//The powernet that calls this proc will consume the other powernet - Rockdtben
//TODO: rewrite so the larger net absorbs the smaller net
/proc/merge_powernets(var/datum/powernet/net1, var/datum/powernet/net2)
if(!net1 || !net2) return
if(net1 == net2) return
//We assume net1 is larger. If net2 is in fact larger we are just going to make them switch places to reduce on code.
if(net1.cables.len < net2.cables.len) //net2 is larger than net1. Let's switch them around
var/temp = net1
net1 = net2
net2 = temp
for(var/i=1,i<=net2.nodes.len,i++) //merge net2 into net1
var/obj/machinery/power/Node = net2.nodes[i]
if(Node)
Node.powernet = net1
net1.nodes[Node] = Node
for(var/i=1,i<=net2.cables.len,i++)
var/obj/structure/cable/Cable = net2.cables[i]
if(Cable)
Cable.powernet = net1
net1.cables += Cable
del(net2)
return net1
/obj/machinery/power/proc/connect_to_network()
var/turf/T = src.loc
var/obj/structure/cable/C = T.get_cable_node()
if(!C || !C.powernet) return 0
// makepowernets() //TODO: find fast way //EWWWW what are you doing!?
powernet = C.powernet
powernet.nodes[src] = src
return 1
/obj/machinery/power/proc/disconnect_from_network()
if(!powernet)
//world << " no powernet"
return 0
powernet.nodes -= src
powernet = null
//world << "powernet null"
return 1
/turf/proc/get_cable_node()
if(!istype(src, /turf/simulated/floor))
return null
for(var/obj/structure/cable/C in src)
if(C.d1 == 0)
return C
return null
/area/proc/get_apc()
for(var/area/RA in src.related)
var/obj/machinery/power/apc/FINDME = locate() in RA
if (FINDME)
return FINDME
//Determines how strong could be shock, deals damage to mob, uses power.
//M is a mob who touched wire/whatever
//power_source is a source of electricity, can be powercell, area, apc, cable, powernet or null
//source is an object caused electrocuting (airlock, grille, etc)
//No animations will be performed by this proc.
/proc/electrocute_mob(mob/living/carbon/M as mob, var/power_source, var/obj/source, var/siemens_coeff = 1.0)
if(istype(M.loc,/obj/mecha)) return 0 //feckin mechs are dumb
if(istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(H.gloves)
var/obj/item/clothing/gloves/G = H.gloves
if(G.siemens_coefficient == 0) return 0 //to avoid spamming with insulated glvoes on
var/area/source_area
if(istype(power_source,/area))
source_area = power_source
power_source = source_area.get_apc()
if(istype(power_source,/obj/structure/cable))
var/obj/structure/cable/Cable = power_source
power_source = Cable.powernet
var/datum/powernet/PN
var/obj/item/weapon/cell/cell
if(istype(power_source,/datum/powernet))
PN = power_source
else if(istype(power_source,/obj/item/weapon/cell))
cell = power_source
else if(istype(power_source,/obj/machinery/power/apc))
var/obj/machinery/power/apc/apc = power_source
cell = apc.cell
if (apc.terminal)
PN = apc.terminal.powernet
else if (!power_source)
return 0
else
log_admin("ERROR: /proc/electrocute_mob([M], [power_source], [source]): wrong power_source")
return 0
if (!cell && !PN)
return 0
var/PN_damage = 0
var/cell_damage = 0
if (PN)
PN_damage = PN.get_electrocute_damage()
if (cell)
cell_damage = cell.get_electrocute_damage()
var/shock_damage = 0
if (PN_damage>=cell_damage)
power_source = PN
shock_damage = PN_damage
else
power_source = cell
shock_damage = cell_damage
var/drained_hp = M.electrocute_act(shock_damage, source, siemens_coeff) //zzzzzzap!
var/drained_energy = drained_hp*20
if (source_area)
source_area.use_power(drained_energy/CELLRATE)
else if (istype(power_source,/datum/powernet))
var/drained_power = drained_energy/CELLRATE //convert from "joules" to "watts"
PN.newload+=drained_power
else if (istype(power_source, /obj/item/weapon/cell))
cell.use(drained_energy)
return drained_energy
+151
View File
@@ -0,0 +1,151 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
var/global/list/rad_collectors = list()
/obj/machinery/power/rad_collector
name = "Radiation Collector Array"
desc = "A device which uses Hawking Radiation and plasma to produce power."
icon = 'icons/obj/singularity.dmi'
icon_state = "ca"
anchored = 0
density = 1
directwired = 1
req_access = list(access_engine_equip)
// use_power = 0
var/obj/item/weapon/tank/plasma/P = null
var/last_power = 0
var/active = 0
var/locked = 0
var/drainratio = 1
/obj/machinery/power/rad_collector/New()
..()
rad_collectors += src
/obj/machinery/power/rad_collector/Del()
rad_collectors -= src
..()
/obj/machinery/power/rad_collector/process()
if(P)
if(P.air_contents.toxins <= 0)
investigate_log("<font color='red'>out of fuel</font>.","singulo")
P.air_contents.toxins = 0
eject()
else
P.air_contents.adjust(tx = -0.001*drainratio)
return
/obj/machinery/power/rad_collector/attack_hand(mob/user as mob)
if(anchored)
if(!src.locked)
toggle_power()
user.visible_message("[user.name] turns the [src.name] [active? "on":"off"].", \
"You turn the [src.name] [active? "on":"off"].")
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [user.key]. [P?"Fuel: [round(P.air_contents.toxins/0.29)]%":"<font color='red'>It is empty</font>"].","singulo")
return
else
user << "\red The controls are locked!"
return
..()
/obj/machinery/power/rad_collector/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/device/analyzer))
user << "\blue The [W.name] detects that [last_power]W were recently produced."
return 1
else if(istype(W, /obj/item/weapon/tank/plasma))
if(!src.anchored)
user << "\red The [src] needs to be secured to the floor first."
return 1
if(src.P)
user << "\red There's already a plasma tank loaded."
return 1
user.drop_item()
src.P = W
W.loc = src
update_icons()
else if(istype(W, /obj/item/weapon/crowbar))
if(P && !src.locked)
eject()
return 1
else if(istype(W, /obj/item/weapon/wrench))
if(P)
user << "\blue Remove the plasma tank first."
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
src.anchored = !src.anchored
user.visible_message("[user.name] [anchored? "secures":"unsecures"] the [src.name].", \
"You [anchored? "secure":"undo"] the external bolts.", \
"You hear a ratchet")
if(anchored)
connect_to_network()
else
disconnect_from_network()
else if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda))
if (src.allowed(user))
if(active)
src.locked = !src.locked
user << "The controls are now [src.locked ? "locked." : "unlocked."]"
else
src.locked = 0 //just in case it somehow gets locked
user << "\red The controls can only be locked when the [src] is active"
else
user << "\red Access denied!"
return 1
else
..()
return 1
/obj/machinery/power/rad_collector/ex_act(severity)
switch(severity)
if(2, 3)
eject()
return ..()
/obj/machinery/power/rad_collector/proc/eject()
locked = 0
var/obj/item/weapon/tank/plasma/Z = src.P
if (!Z)
return
Z.loc = get_turf(src)
Z.layer = initial(Z.layer)
src.P = null
if(active)
toggle_power()
else
update_icons()
/obj/machinery/power/rad_collector/proc/receive_pulse(var/pulse_strength)
if(P && active)
var/power_produced = 0
power_produced = P.air_contents.toxins*pulse_strength*20
add_avail(power_produced)
last_power = power_produced
return
return
/obj/machinery/power/rad_collector/proc/update_icons()
overlays.Cut()
if(P)
overlays += image('icons/obj/singularity.dmi', "ptank")
if(stat & (NOPOWER|BROKEN))
return
if(active)
overlays += image('icons/obj/singularity.dmi', "on")
/obj/machinery/power/rad_collector/proc/toggle_power()
active = !active
if(active)
icon_state = "ca_on"
flick("ca_active", src)
else
icon_state = "ca"
flick("ca_deactive", src)
update_icons()
return
@@ -0,0 +1,109 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/machinery/containment_field
name = "Containment Field"
desc = "An energy field."
icon = 'icons/obj/singularity.dmi'
icon_state = "Contain_F"
anchored = 1
density = 0
unacidable = 1
use_power = 0
luminosity = 4
var/obj/machinery/field_generator/FG1 = null
var/obj/machinery/field_generator/FG2 = null
var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
/obj/machinery/containment_field/Del()
if(FG1 && !FG1.clean_up)
FG1.cleanup()
if(FG2 && !FG2.clean_up)
FG2.cleanup()
..()
/obj/machinery/containment_field/attack_hand(mob/user as mob)
if(get_dist(src, user) > 1)
return 0
else
shock(user)
return 1
/obj/machinery/containment_field/blob_act()
return 0
/obj/machinery/containment_field/ex_act(severity)
return 0
/obj/machinery/containment_field/meteorhit()
return 0
/obj/machinery/containment_field/HasProximity(atom/movable/AM as mob|obj)
if(istype(AM,/mob/living/silicon) && prob(40))
shock(AM)
return 1
if(istype(AM,/mob/living/carbon) && prob(50))
shock(AM)
return 1
return 0
/obj/machinery/containment_field/proc/shock(mob/living/user as mob)
if(hasShocked)
return 0
if(!FG1 || !FG2)
del(src)
return 0
if(iscarbon(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
hasShocked = 1
var/shock_damage = min(rand(30,40),rand(30,40))
user.burn_skin(shock_damage)
user.updatehealth()
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>You feel a powerful shock course through your body sending you flying!</B>", \
"\red You hear a heavy electrical crack")
var/stun = min(shock_damage, 15)
user.Stun(stun)
user.Weaken(10)
user.updatehealth()
var/atom/target = get_edge_target_turf(user, get_dir(src, get_step_away(user, src)))
user.throw_at(target, 200, 4)
sleep(20)
hasShocked = 0
return
else if(issilicon(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
hasShocked = 1
var/shock_damage = rand(15,30)
user.take_overall_damage(0,shock_damage)
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>Energy pulse detected, system damaged!</B>", \
"\red You hear an electrical crack")
if(prob(20))
user.Stun(2)
sleep(20)
hasShocked = 0
return
return
/obj/machinery/containment_field/proc/set_master(var/master1,var/master2)
if(!master1 || !master2)
return 0
FG1 = master1
FG2 = master2
return 1
+233
View File
@@ -0,0 +1,233 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/machinery/power/emitter
name = "Emitter"
desc = "A heavy duty industrial laser"
icon = 'icons/obj/singularity.dmi'
icon_state = "emitter"
anchored = 0
density = 1
req_access = list(access_engine_equip)
use_power = 0
idle_power_usage = 10
active_power_usage = 300
var/active = 0
var/powered = 0
var/fire_delay = 100
var/last_shot = 0
var/shot_number = 0
var/state = 0
var/locked = 0
/obj/machinery/power/emitter/verb/rotate()
set name = "Rotate"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
/obj/machinery/power/emitter/initialize()
..()
if(state == 2 && anchored)
connect_to_network()
src.directwired = 1
/obj/machinery/power/emitter/Del()
message_admins("Emitter deleted at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("Emitter deleted at ([x],[y],[z])")
investigate_log("<font color='red'>deleted</font> at ([x],[y],[z])","singulo")
..()
/obj/machinery/power/emitter/update_icon()
if (active && powernet && avail(active_power_usage))
icon_state = "emitter_+a"
else
icon_state = "emitter"
/obj/machinery/power/emitter/attack_hand(mob/user as mob)
src.add_fingerprint(user)
if(state == 2)
if(!powernet)
user << "The emitter isn't connected to a wire."
return 1
if(!src.locked)
if(src.active==1)
src.active = 0
user << "You turn off the [src]."
message_admins("Emitter turned off by [key_name(user, user.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[user]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("Emitter turned off by [user.ckey]([user]) in ([x],[y],[z])")
investigate_log("turned <font color='red'>off</font> by [user.key]","singulo")
else
src.active = 1
user << "You turn on the [src]."
src.shot_number = 0
src.fire_delay = 100
message_admins("Emitter turned on by [key_name(user, user.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[user]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("Emitter turned on by [user.ckey]([user]) in ([x],[y],[z])")
investigate_log("turned <font color='green'>on</font> by [user.key]","singulo")
update_icon()
else
user << "\red The controls are locked!"
else
user << "\red The [src] needs to be firmly secured to the floor first."
return 1
/obj/machinery/power/emitter/emp_act(var/severity)//Emitters are hardened but still might have issues
// add_load(1000)
/* if((severity == 1)&&prob(1)&&prob(1))
if(src.active)
src.active = 0
src.use_power = 1 */
return 1
/obj/machinery/containment_field/meteorhit()
return 0
/obj/machinery/power/emitter/process()
if(stat & (BROKEN))
return
if(src.state != 2 || (!powernet && active_power_usage))
src.active = 0
update_icon()
return
if(((src.last_shot + src.fire_delay) <= world.time) && (src.active == 1))
if(!active_power_usage || avail(active_power_usage))
add_load(active_power_usage)
if(!powered)
powered = 1
update_icon()
investigate_log("regained power and turned <font color='green'>on</font>","singulo")
else
if(powered)
powered = 0
update_icon()
investigate_log("lost power and turned <font color='red'>off</font>","singulo")
return
src.last_shot = world.time
if(src.shot_number < 3)
src.fire_delay = 2
src.shot_number ++
else
src.fire_delay = rand(20,100)
src.shot_number = 0
var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc )
playsound(src.loc, 'sound/weapons/emitter.ogg', 25, 1)
if(prob(35))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
A.dir = src.dir
switch(dir)
if(NORTH)
A.yo = 20
A.xo = 0
if(EAST)
A.yo = 0
A.xo = 20
if(WEST)
A.yo = 0
A.xo = -20
else // Any other
A.yo = -20
A.xo = 0
A.process() //TODO: Carn: check this out
/obj/machinery/power/emitter/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/weapon/wrench))
if(active)
user << "Turn off the [src] first."
return
switch(state)
if(0)
state = 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
user.visible_message("[user.name] secures [src.name] to the floor.", \
"You secure the external reinforcing bolts to the floor.", \
"You hear a ratchet")
src.anchored = 1
if(1)
state = 0
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
user.visible_message("[user.name] unsecures [src.name] reinforcing bolts from the floor.", \
"You undo the external reinforcing bolts.", \
"You hear a ratchet")
src.anchored = 0
if(2)
user << "\red The [src.name] needs to be unwelded from the floor."
return
if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
if(active)
user << "Turn off the [src] first."
return
switch(state)
if(0)
user << "\red The [src.name] needs to be wrenched to the floor."
if(1)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \
"You start to weld the [src] to the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 2
user << "You weld the [src] to the floor."
connect_to_network()
src.directwired = 1
else
user << "\red You need more welding fuel to complete this task."
if(2)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \
"You start to cut the [src] free from the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 1
user << "You cut the [src] free from the floor."
disconnect_from_network()
src.directwired = 0
else
user << "\red You need more welding fuel to complete this task."
return
if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda))
if(emagged)
user << "\red The lock seems to be broken"
return
if(src.allowed(user))
if(active)
src.locked = !src.locked
user << "The controls are now [src.locked ? "locked." : "unlocked."]"
else
src.locked = 0 //just in case it somehow gets locked
user << "\red The controls can only be locked when the [src] is online"
else
user << "\red Access denied."
return
if(istype(W, /obj/item/weapon/card/emag) && !emagged)
locked = 0
emagged = 1
user.visible_message("[user.name] emags the [src.name].","\red You short out the lock.")
return
..()
return
@@ -0,0 +1,355 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/*
field_generator power level display
The icon used for the field_generator need to have 'num_power_levels' number of icon states
named 'Field_Gen +p[num]' where 'num' ranges from 1 to 'num_power_levels'
The power level is displayed using overlays. The current displayed power level is stored in 'powerlevel'.
The overlay in use and the powerlevel variable must be kept in sync. A powerlevel equal to 0 means that
no power level overlay is currently in the overlays list.
-Aygar
*/
#define field_generator_max_power 250
/obj/machinery/field_generator
name = "Field Generator"
desc = "A large thermal battery that projects a high amount of energy when powered."
icon = 'icons/obj/machines/field_generator.dmi'
icon_state = "Field_Gen"
anchored = 0
density = 1
use_power = 0
var/const/num_power_levels = 6 // Total number of power level icon has
var/Varedit_start = 0
var/Varpower = 0
var/active = 0
var/power = 20 // Current amount of power
var/state = 0
var/warming_up = 0
var/list/obj/machinery/containment_field/fields
var/list/obj/machinery/field_generator/connected_gens
var/clean_up = 0
/obj/machinery/field_generator/update_icon()
overlays.Cut()
if(!active)
if(warming_up)
overlays += "+a[warming_up]"
if(fields.len)
overlays += "+on"
// Power level indicator
// Scale % power to % num_power_levels and truncate value
var/level = round(num_power_levels * power / field_generator_max_power)
// Clamp between 0 and num_power_levels for out of range power values
level = between(0, level, num_power_levels)
if(level)
overlays += "+p[level]"
return
/obj/machinery/field_generator/New()
..()
fields = list()
connected_gens = list()
return
/obj/machinery/field_generator/process()
if(Varedit_start == 1)
if(active == 0)
active = 1
state = 2
power = field_generator_max_power
anchored = 1
warming_up = 3
start_fields()
update_icon()
Varedit_start = 0
if(src.active == 2)
calc_power()
update_icon()
return
/obj/machinery/field_generator/attack_hand(mob/user as mob)
if(state == 2)
if(get_dist(src, user) <= 1)//Need to actually touch the thing to turn it on
if(src.active >= 1)
user << "You are unable to turn off the [src.name] once it is online."
return 1
else
user.visible_message("[user.name] turns on the [src.name]", \
"You turn on the [src.name].", \
"You hear heavy droning")
turn_on()
investigate_log("<font color='green'>activated</font> by [user.key].","singulo")
src.add_fingerprint(user)
else
user << "The [src] needs to be firmly secured to the floor first."
return
/obj/machinery/field_generator/attackby(obj/item/W, mob/user)
if(active)
user << "The [src] needs to be off."
return
else if(istype(W, /obj/item/weapon/wrench))
switch(state)
if(0)
state = 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
user.visible_message("[user.name] secures [src.name] to the floor.", \
"You secure the external reinforcing bolts to the floor.", \
"You hear ratchet")
src.anchored = 1
if(1)
state = 0
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
user.visible_message("[user.name] unsecures [src.name] reinforcing bolts from the floor.", \
"You undo the external reinforcing bolts.", \
"You hear ratchet")
src.anchored = 0
if(2)
user << "\red The [src.name] needs to be unwelded from the floor."
return
else if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
switch(state)
if(0)
user << "\red The [src.name] needs to be wrenched to the floor."
return
if(1)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \
"You start to weld the [src] to the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 2
user << "You weld the field generator to the floor."
else
return
if(2)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \
"You start to cut the [src] free from the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 1
user << "You cut the [src] free from the floor."
else
return
else
..()
return
/obj/machinery/field_generator/emp_act()
return 0
/obj/machinery/field_generator/blob_act()
if(active)
return 0
else
..()
/obj/machinery/containment_field/meteorhit()
return 0
/obj/machinery/field_generator/bullet_act(var/obj/item/projectile/Proj)
if(Proj.flag != "bullet")
power += Proj.damage
update_icon()
return 0
/obj/machinery/field_generator/Del()
src.cleanup()
..()
/obj/machinery/field_generator/proc/turn_off()
active = 0
spawn(1)
src.cleanup()
update_icon()
/obj/machinery/field_generator/proc/turn_on()
active = 1
warming_up = 1
spawn(1)
while (warming_up<3 && active)
sleep(50)
warming_up++
update_icon()
if(warming_up >= 3)
start_fields()
update_icon()
/obj/machinery/field_generator/proc/calc_power()
if(Varpower)
return 1
update_icon()
if(src.power > field_generator_max_power)
src.power = field_generator_max_power
var/power_draw = 2
for (var/obj/machinery/containment_field/F in fields)
if (isnull(F))
continue
power_draw++
if(draw_power(round(power_draw/2,1)))
return 1
else
for(var/mob/M in viewers(src))
M.show_message("\red The [src.name] shuts down!")
turn_off()
investigate_log("ran out of power and <font color='red'>deactivated</font>","singulo")
src.power = 0
return 0
//This could likely be better, it tends to start loopin if you have a complex generator loop setup. Still works well enough to run the engine fields will likely recode the field gens and fields sometime -Mport
/obj/machinery/field_generator/proc/draw_power(var/draw = 0, var/failsafe = 0, var/obj/machinery/field_generator/G = null, var/obj/machinery/field_generator/last = null)
if(Varpower)
return 1
if((G && G == src) || (failsafe >= 8))//Loopin, set fail
return 0
else
failsafe++
if(src.power >= draw)//We have enough power
src.power -= draw
return 1
else//Need more power
draw -= src.power
src.power = 0
for(var/obj/machinery/field_generator/FG in connected_gens)
if(isnull(FG))
continue
if(FG == last)//We just asked you
continue
if(G)//Another gen is askin for power and we dont have it
if(FG.draw_power(draw,failsafe,G,src))//Can you take the load
return 1
else
return 0
else//We are askin another for power
if(FG.draw_power(draw,failsafe,src,src))
return 1
else
return 0
/obj/machinery/field_generator/proc/start_fields()
if(!src.state == 2 || !anchored)
turn_off()
return
spawn(1)
setup_field(1)
spawn(2)
setup_field(2)
spawn(3)
setup_field(4)
spawn(4)
setup_field(8)
src.active = 2
/obj/machinery/field_generator/proc/setup_field(var/NSEW)
var/turf/T = src.loc
var/obj/machinery/field_generator/G
var/steps = 0
if(!NSEW)//Make sure its ran right
return
for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for another generator
T = get_step(T, NSEW)
if(T.density)//We cant shoot a field though this
return 0
for(var/atom/A in T.contents)
if(ismob(A))
continue
if(!istype(A,/obj/machinery/field_generator))
if((istype(A,/obj/machinery/door)||istype(A,/obj/machinery/the_singularitygen))&&(A.density))
return 0
steps += 1
G = locate(/obj/machinery/field_generator) in T
if(!isnull(G))
steps -= 1
if(!G.active)
return 0
break
if(isnull(G))
return
T = src.loc
for(var/dist = 0, dist < steps, dist += 1) // creates each field tile
var/field_dir = get_dir(T,get_step(G.loc, NSEW))
T = get_step(T, NSEW)
if(!locate(/obj/machinery/containment_field) in T)
var/obj/machinery/containment_field/CF = new/obj/machinery/containment_field()
CF.set_master(src,G)
fields += CF
G.fields += CF
CF.loc = T
CF.dir = field_dir
var/listcheck = 0
for(var/obj/machinery/field_generator/FG in connected_gens)
if (isnull(FG))
continue
if(FG == G)
listcheck = 1
break
if(!listcheck)
connected_gens.Add(G)
listcheck = 0
for(var/obj/machinery/field_generator/FG2 in G.connected_gens)
if (isnull(FG2))
continue
if(FG2 == src)
listcheck = 1
break
if(!listcheck)
G.connected_gens.Add(src)
/obj/machinery/field_generator/proc/cleanup()
clean_up = 1
for (var/obj/machinery/containment_field/F in fields)
if (isnull(F))
continue
del(F)
fields = list()
for(var/obj/machinery/field_generator/FG in connected_gens)
if (isnull(FG))
continue
FG.connected_gens.Remove(src)
if(!FG.clean_up)//Makes the other gens clean up as well
FG.cleanup()
connected_gens.Remove(FG)
connected_gens = list()
clean_up = 0
update_icon()
//This is here to help fight the "hurr durr, release singulo cos nobody will notice before the
//singulo eats the evidence". It's not fool-proof but better than nothing.
//I want to avoid using global variables.
spawn(1)
var/temp = 1 //stops spam
for(var/obj/machinery/singularity/O in machines)
if(O.last_warning && temp)
if((world.time - O.last_warning) > 50) //to stop message-spam
temp = 0
message_admins("A singulo exists and a containment field has failed.",1)
investigate_log("has <font color='red'>failed</font> whilst a singulo exists.","singulo")
O.last_warning = world.time
@@ -0,0 +1,31 @@
/////SINGULARITY SPAWNER
/obj/machinery/the_singularitygen/
name = "Gravitational Singularity Generator"
desc = "An Odd Device which produces a Gravitational Singularity when set up."
icon = 'icons/obj/singularity.dmi'
icon_state = "TheSingGen"
anchored = 0
density = 1
use_power = 0
var/energy = 0
/obj/machinery/the_singularitygen/process()
var/turf/T = get_turf(src)
if(src.energy >= 200)
new /obj/machinery/singularity/(T, 50)
if(src) del(src)
/obj/machinery/the_singularitygen/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/weapon/wrench))
anchored = !anchored
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
if(anchored)
user.visible_message("[user.name] secures [src.name] to the floor.", \
"You secure the [src.name] to the floor.", \
"You hear a ratchet")
else
user.visible_message("[user.name] unsecures [src.name] from the floor.", \
"You unsecure the [src.name] from the floor.", \
"You hear a ratchet")
return
return ..()
@@ -0,0 +1,4 @@
/area/engine/engineering/poweralert(var/state, var/source)
if (state != poweralm)
investigate_log("has a power alarm!","singulo")
..()
@@ -0,0 +1,107 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/effect/accelerated_particle
name = "Accelerated Particles"
desc = "Small things moving very fast."
icon = 'icons/obj/machines/particle_accelerator2.dmi'
icon_state = "particle"//Need a new icon for this
anchored = 1
density = 1
var/movement_range = 10
var/energy = 10 //energy in eV
var/mega_energy = 0 //energy in MeV
var/frequency = 1
var/ionizing = 0
var/particle_type
var/additional_particles = 0
var/turf/target
var/turf/source
var/movetotarget = 1
/obj/effect/accelerated_particle/weak
movement_range = 8
energy = 5
/obj/effect/accelerated_particle/strong
movement_range = 15
energy = 15
/obj/effect/accelerated_particle/New(loc, dir = 2)
src.loc = loc
src.dir = dir
if(movement_range > 20)
movement_range = 20
spawn(0)
move(1)
return
/obj/effect/accelerated_particle/Bump(atom/A)
if (A)
if(ismob(A))
toxmob(A)
if((istype(A,/obj/machinery/the_singularitygen))||(istype(A,/obj/machinery/singularity/)))
A:energy += energy
else if( istype(A,/obj/effect/rust_particle_catcher) )
var/obj/effect/rust_particle_catcher/collided_catcher = A
if(particle_type && particle_type != "neutron")
if(collided_catcher.AddParticles(particle_type, 1 + additional_particles))
collided_catcher.parent.AddEnergy(energy,mega_energy)
del (src)
else if( istype(A,/obj/machinery/power/rust_core) )
var/obj/machinery/power/rust_core/collided_core = A
if(particle_type && particle_type != "neutron")
if(collided_core.AddParticles(particle_type, 1 + additional_particles))
var/energy_loss_ratio = abs(collided_core.owned_field.frequency - frequency) / 1e9
collided_core.owned_field.mega_energy += mega_energy - mega_energy * energy_loss_ratio
collided_core.owned_field.energy += energy - energy * energy_loss_ratio
del (src)
return
/obj/effect/accelerated_particle/Bumped(atom/A)
if(ismob(A))
Bump(A)
return
/obj/effect/accelerated_particle/ex_act(severity)
del(src)
return
/obj/effect/accelerated_particle/proc/toxmob(var/mob/living/M)
var/radiation = (energy*2)
/* if(istype(M,/mob/living/carbon/human))
if(M:wear_suit) //TODO: check for radiation protection
radiation = round(radiation/2,1)
if(istype(M,/mob/living/carbon/monkey))
if(M:wear_suit) //TODO: check for radiation protection
radiation = round(radiation/2,1)*/
M.apply_effect((radiation*3),IRRADIATE,0)
M.updatehealth()
//M << "\red You feel odd."
return
/obj/effect/accelerated_particle/proc/move(var/lag)
if(target)
if(movetotarget)
if(!step_towards(src,target))
src.loc = get_step(src, get_dir(src,target))
if(get_dist(src,target) < 1)
movetotarget = 0
else
if(!step(src, get_step_away(src,source)))
src.loc = get_step(src, get_step_away(src,source))
else
if(!step(src,dir))
src.loc = get_step(src,dir)
movement_range--
if(movement_range <= 0)
del(src)
else
sleep(lag)
move(lag)
@@ -0,0 +1,410 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/*Composed of 7 parts
3 Particle emitters
proc
emit_particle()
1 power box
the only part of this thing that uses power, can hack to mess with the pa/make it better
1 fuel chamber
contains procs for mixing gas and whatever other fuel it uses
mix_gas()
1 gas holder WIP
acts like a tank valve on the ground that you wrench gas tanks onto
proc
extract_gas()
return_gas()
attach_tank()
remove_tank()
get_available_mix()
1 End Cap
1 Control computer
interface for the pa, acts like a computer with an html menu for diff parts and a status report
all other parts contain only a ref to this
a /machine/, tells the others to do work
contains ref for all parts
proc
process()
check_build()
Setup map
|EC|
CC|FC|
|PB|
PE|PE|PE
Icon Addemdum
Icon system is much more robust, and the icons are all variable based.
Each part has a reference string, powered, strength, and contruction values.
Using this the update_icon() proc is simplified a bit (using for absolutely was problematic with naming),
so the icon_state comes out be:
"[reference][strength]", with a switch controlling construction_states and ensuring that it doesn't
power on while being contructed, and all these variables are set by the computer through it's scan list
Essential order of the icons:
Standard - [reference]
Wrenched - [reference]
Wired - [reference]w
Closed - [reference]c
Powered - [reference]p[strength]
Strength being set by the computer and a null strength (Computer is powered off or inactive) returns a 'null', counting as empty
So, hopefully this is helpful if any more icons are to be added/changed/wondering what the hell is going on here
*/
/obj/structure/particle_accelerator
name = "Particle Accelerator"
desc = "Part of a Particle Accelerator."
icon = 'icons/obj/machines/particle_accelerator2.dmi'
icon_state = "none"
anchored = 0
density = 1
var/obj/machinery/particle_accelerator/control_box/master = null
var/construction_state = 0
var/reference = null
var/powered = 0
var/strength = null
var/desc_holder = null
/obj/structure/particle_accelerator/end_cap
name = "Alpha Particle Generation Array"
desc_holder = "This is where Alpha particles are generated from \[REDACTED\]"
icon_state = "end_cap"
reference = "end_cap"
/obj/structure/particle_accelerator/update_icon()
..()
return
/obj/structure/particle_accelerator/verb/rotate()
set name = "Rotate Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 270)
return 1
/obj/structure/particle_accelerator/verb/rotateccw()
set name = "Rotate Counter Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
/obj/structure/particle_accelerator/examine()
switch(src.construction_state)
if(0)
src.desc = text("A [name], looks like it's not attached to the flooring")
if(1)
src.desc = text("A [name], it is missing some cables")
if(2)
src.desc = text("A [name], the panel is open")
if(3)
src.desc = text("The [name] is assembled")
if(powered)
src.desc = src.desc_holder
..()
return
/obj/structure/particle_accelerator/attackby(obj/item/W, mob/user)
if(istool(W))
if(src.process_tool_hit(W,user))
return
..()
return
/obj/structure/particle_accelerator/Move()
..()
if(master && master.active)
master.toggle_power()
investigate_log("was moved whilst active; it <font color='red'>powered down</font>.","singulo")
/obj/structure/particle_accelerator/ex_act(severity)
switch(severity)
if(1.0)
del(src)
return
if(2.0)
if (prob(50))
del(src)
return
if(3.0)
if (prob(25))
del(src)
return
else
return
/obj/structure/particle_accelerator/blob_act()
if(prob(50))
del(src)
return
/obj/structure/particle_accelerator/meteorhit()
if(prob(50))
del(src)
return
/obj/structure/particle_accelerator/update_icon()
switch(construction_state)
if(0,1)
icon_state="[reference]"
if(2)
icon_state="[reference]w"
if(3)
if(powered)
icon_state="[reference]p[strength]"
else
icon_state="[reference]c"
return
/obj/structure/particle_accelerator/proc/update_state()
if(master)
master.update_state()
return 0
/obj/structure/particle_accelerator/proc/report_ready(var/obj/O)
if(O && (O == master))
if(construction_state >= 3)
return 1
return 0
/obj/structure/particle_accelerator/proc/report_master()
if(master)
return master
return 0
/obj/structure/particle_accelerator/proc/connect_master(var/obj/O)
if(O && istype(O,/obj/machinery/particle_accelerator/control_box))
if(O.dir == src.dir)
master = O
return 1
return 0
/obj/structure/particle_accelerator/proc/process_tool_hit(var/obj/O, var/mob/user)
if(!(O) || !(user))
return 0
if(!ismob(user) || !isobj(O))
return 0
var/temp_state = src.construction_state
switch(src.construction_state)//TODO:Might be more interesting to have it need several parts rather than a single list of steps
if(0)
if(iswrench(O))
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
src.anchored = 1
user.visible_message("[user.name] secures the [src.name] to the floor.", \
"You secure the external bolts.")
temp_state++
if(1)
if(iswrench(O))
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
src.anchored = 0
user.visible_message("[user.name] detaches the [src.name] from the floor.", \
"You remove the external bolts.")
temp_state--
else if(iscoil(O))
if(O:use(1,user))
user.visible_message("[user.name] adds wires to the [src.name].", \
"You add some wires.")
temp_state++
if(2)
if(iswirecutter(O))//TODO:Shock user if its on?
user.visible_message("[user.name] removes some wires from the [src.name].", \
"You remove some wires.")
temp_state--
else if(isscrewdriver(O))
user.visible_message("[user.name] closes the [src.name]'s access panel.", \
"You close the access panel.")
temp_state++
if(3)
if(isscrewdriver(O))
user.visible_message("[user.name] opens the [src.name]'s access panel.", \
"You open the access panel.")
temp_state--
if(temp_state == src.construction_state)//Nothing changed
return 0
else
src.construction_state = temp_state
if(src.construction_state < 3)//Was taken apart, update state
update_state()
update_icon()
return 1
return 0
/obj/machinery/particle_accelerator
name = "Particle Accelerator"
desc = "Part of a Particle Accelerator."
icon = 'icons/obj/machines/particle_accelerator2.dmi'
icon_state = "none"
anchored = 0
density = 1
use_power = 0
idle_power_usage = 0
active_power_usage = 0
var/construction_state = 0
var/active = 0
var/reference = null
var/powered = null
var/strength = 0
var/desc_holder = null
/obj/machinery/particle_accelerator/verb/rotate()
set name = "Rotate Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 270)
return 1
/obj/machinery/particle_accelerator/verb/rotateccw()
set name = "Rotate Counter-Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
/obj/machinery/particle_accelerator/update_icon()
return
/obj/machinery/particle_accelerator/examine()
switch(src.construction_state)
if(0)
src.desc = text("A [name], looks like it's not attached to the flooring")
if(1)
src.desc = text("A [name], it is missing some cables")
if(2)
src.desc = text("A [name], the panel is open")
if(3)
src.desc = text("The [name] is assembled")
if(powered)
src.desc = src.desc_holder
..()
return
/obj/machinery/particle_accelerator/attackby(obj/item/W, mob/user)
if(istool(W))
if(src.process_tool_hit(W,user))
return
..()
return
/obj/machinery/particle_accelerator/ex_act(severity)
switch(severity)
if(1.0)
del(src)
return
if(2.0)
if (prob(50))
del(src)
return
if(3.0)
if (prob(25))
del(src)
return
else
return
/obj/machinery/particle_accelerator/blob_act()
if(prob(50))
del(src)
return
/obj/machinery/particle_accelerator/meteorhit()
if(prob(50))
del(src)
return
/obj/machinery/particle_accelerator/proc/update_state()
return 0
/obj/machinery/particle_accelerator/proc/process_tool_hit(var/obj/O, var/mob/user)
if(!(O) || !(user))
return 0
if(!ismob(user) || !isobj(O))
return 0
var/temp_state = src.construction_state
switch(src.construction_state)//TODO:Might be more interesting to have it need several parts rather than a single list of steps
if(0)
if(iswrench(O))
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
src.anchored = 1
user.visible_message("[user.name] secures the [src.name] to the floor.", \
"You secure the external bolts.")
temp_state++
if(1)
if(iswrench(O))
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
src.anchored = 0
user.visible_message("[user.name] detaches the [src.name] from the floor.", \
"You remove the external bolts.")
temp_state--
else if(iscoil(O))
if(O:use(1))
user.visible_message("[user.name] adds wires to the [src.name].", \
"You add some wires.")
temp_state++
if(2)
if(iswirecutter(O))//TODO:Shock user if its on?
user.visible_message("[user.name] removes some wires from the [src.name].", \
"You remove some wires.")
temp_state--
else if(isscrewdriver(O))
user.visible_message("[user.name] closes the [src.name]'s access panel.", \
"You close the access panel.")
temp_state++
if(3)
if(isscrewdriver(O))
user.visible_message("[user.name] opens the [src.name]'s access panel.", \
"You open the access panel.")
temp_state--
active = 0
if(temp_state == src.construction_state)//Nothing changed
return 0
else
if(src.construction_state < 3)//Was taken apart, update state
update_state()
if(use_power)
use_power = 0
src.construction_state = temp_state
if(src.construction_state >= 3)
use_power = 1
update_icon()
return 1
return 0
@@ -0,0 +1,10 @@
/obj/structure/particle_accelerator/fuel_chamber
name = "EM Acceleration Chamber"
desc_holder = "This is where the Alpha particles are accelerated to <b><i>radical speeds</i></b>."
icon = 'icons/obj/machines/particle_accelerator2.dmi'
icon_state = "fuel_chamber"
reference = "fuel_chamber"
/obj/structure/particle_accelerator/fuel_chamber/update_icon()
..()
return
@@ -0,0 +1,233 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/machinery/particle_accelerator/control_box
name = "Particle Accelerator Control Computer"
desc = "This controls the density of the particles."
icon = 'icons/obj/machines/particle_accelerator2.dmi'
icon_state = "control_box"
reference = "control_box"
anchored = 0
density = 1
use_power = 0
idle_power_usage = 500
active_power_usage = 10000
construction_state = 0
active = 0
dir = 1
var/list/obj/structure/particle_accelerator/connected_parts
var/assembled = 0
var/parts = null
/obj/machinery/particle_accelerator/control_box/New()
connected_parts = list()
..()
/obj/machinery/particle_accelerator/control_box/attack_hand(mob/user as mob)
if(construction_state >= 3)
interact(user)
/obj/machinery/particle_accelerator/control_box/update_state()
if(construction_state < 3)
use_power = 0
assembled = 0
active = 0
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = null
part.powered = 0
part.update_icon()
connected_parts = list()
return
if(!part_scan())
use_power = 1
active = 0
connected_parts = list()
return
/obj/machinery/particle_accelerator/control_box/update_icon()
if(active)
icon_state = "[reference]p1"
else
if(use_power)
if(assembled)
icon_state = "[reference]p"
else
icon_state = "u[reference]p"
else
switch(construction_state)
if(0)
icon_state = "[reference]"
if(1)
icon_state = "[reference]"
if(2)
icon_state = "[reference]w"
else
icon_state = "[reference]c"
return
/obj/machinery/particle_accelerator/control_box/Topic(href, href_list)
..()
//Ignore input if we are broken, !silicon guy cant touch us, or nonai controlling from super far away
if(stat & (BROKEN|NOPOWER) || (get_dist(src, usr) > 1 && !istype(usr, /mob/living/silicon)) || (get_dist(src, usr) > 8 && !istype(usr, /mob/living/silicon/ai)))
usr.unset_machine()
usr << browse(null, "window=pacontrol")
return
if( href_list["close"] )
usr << browse(null, "window=pacontrol")
usr.unset_machine()
return
if(href_list["togglep"])
src.toggle_power()
investigate_log("turned [active?"<font color='red'>ON</font>":"<font color='green'>OFF</font>"] by [usr.key]","singulo")
if (active)
message_admins("PA Control Computer turned ON by [key_name(usr, usr.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("PA Control Computer turned ON by [usr.ckey]([usr]) in ([x],[y],[z])")
else if(href_list["scan"])
src.part_scan()
else if(href_list["strengthup"])
strength++
if(strength > 2)
strength = 2
else
message_admins("PA Control Computer increased to [strength] by [key_name(usr, usr.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("PA Control Computer increased to [strength] by [usr.ckey]([usr]) in ([x],[y],[z])")
investigate_log("increased to <font color='red'>[strength]</font> by [usr.key]","singulo")
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = strength
part.update_icon()
else if(href_list["strengthdown"])
strength--
if(strength < 0)
strength = 0
else
investigate_log("decreased to <font color='green'>[strength]</font> by [usr.key]","singulo")
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = strength
part.update_icon()
src.updateDialog()
src.update_icon()
return
/obj/machinery/particle_accelerator/control_box/power_change()
..()
if(stat & NOPOWER)
active = 0
use_power = 0
else if(!stat && construction_state == 3)
use_power = 1
return
/obj/machinery/particle_accelerator/control_box/process()
if(src.active)
//a part is missing!
if( length(connected_parts) < 6 )
investigate_log("lost a connected part; It <font color='red'>powered down</font>.","singulo")
src.toggle_power()
return
//emit some particles
for(var/obj/structure/particle_accelerator/particle_emitter/PE in connected_parts)
if(PE)
PE.emit_particle(src.strength)
return
/obj/machinery/particle_accelerator/control_box/proc/part_scan()
for(var/obj/structure/particle_accelerator/fuel_chamber/F in orange(1,src))
src.dir = F.dir
connected_parts = list()
var/tally = 0
var/ldir = turn(dir,-90)
var/rdir = turn(dir,90)
var/odir = turn(dir,180)
var/turf/T = src.loc
T = get_step(T,rdir)
if(check_part(T,/obj/structure/particle_accelerator/fuel_chamber))
tally++
T = get_step(T,odir)
if(check_part(T,/obj/structure/particle_accelerator/end_cap))
tally++
T = get_step(T,dir)
T = get_step(T,dir)
if(check_part(T,/obj/structure/particle_accelerator/power_box))
tally++
T = get_step(T,dir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/center))
tally++
T = get_step(T,ldir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/left))
tally++
T = get_step(T,rdir)
T = get_step(T,rdir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/right))
tally++
if(tally >= 6)
assembled = 1
return 1
else
assembled = 0
return 0
/obj/machinery/particle_accelerator/control_box/proc/check_part(var/turf/T, var/type)
if(!(T)||!(type))
return 0
var/obj/structure/particle_accelerator/PA = locate(/obj/structure/particle_accelerator) in T
if(istype(PA, type))
if(PA.connect_master(src))
if(PA.report_ready(src))
src.connected_parts.Add(PA)
return 1
return 0
/obj/machinery/particle_accelerator/control_box/proc/toggle_power()
src.active = !src.active
if(src.active)
src.use_power = 2
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = src.strength
part.powered = 1
part.update_icon()
else
src.use_power = 1
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = null
part.powered = 0
part.update_icon()
return 1
/obj/machinery/particle_accelerator/control_box/interact(mob/user)
if((get_dist(src, user) > 1) || (stat & (BROKEN|NOPOWER)))
if(!istype(user, /mob/living/silicon))
user.unset_machine()
user << browse(null, "window=pacontrol")
return
user.set_machine(src)
var/dat = ""
dat += "Particle Accelerator Control Panel<BR>"
dat += "<A href='?src=\ref[src];close=1'>Close</A><BR><BR>"
dat += "Status:<BR>"
if(!assembled)
dat += "Unable to detect all parts!<BR>"
dat += "<A href='?src=\ref[src];scan=1'>Run Scan</A><BR><BR>"
else
dat += "All parts in place.<BR><BR>"
dat += "Power:"
if(active)
dat += "On<BR>"
else
dat += "Off <BR>"
dat += "<A href='?src=\ref[src];togglep=1'>Toggle Power</A><BR><BR>"
dat += "Particle Strength: [src.strength] "
dat += "<A href='?src=\ref[src];strengthdown=1'>--</A>|<A href='?src=\ref[src];strengthup=1'>++</A><BR><BR>"
user << browse(dat, "window=pacontrol;size=420x500")
onclose(user, "pacontrol")
return
@@ -0,0 +1,49 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/structure/particle_accelerator/particle_emitter
name = "EM Containment Grid"
desc_holder = "This launchs the Alpha particles, might not want to stand near this end."
icon = 'icons/obj/machines/particle_accelerator2.dmi'
icon_state = "none"
var/fire_delay = 50
var/last_shot = 0
/obj/structure/particle_accelerator/particle_emitter/center
icon_state = "emitter_center"
reference = "emitter_center"
/obj/structure/particle_accelerator/particle_emitter/left
icon_state = "emitter_left"
reference = "emitter_left"
/obj/structure/particle_accelerator/particle_emitter/right
icon_state = "emitter_right"
reference = "emitter_right"
/obj/structure/particle_accelerator/particle_emitter/update_icon()
..()
return
/obj/structure/particle_accelerator/particle_emitter/proc/set_delay(var/delay)
if(delay && delay >= 0)
src.fire_delay = delay
return 1
return 0
/obj/structure/particle_accelerator/particle_emitter/proc/emit_particle(var/strength = 0)
if((src.last_shot + src.fire_delay) <= world.time)
src.last_shot = world.time
var/obj/effect/accelerated_particle/A = null
var/turf/T = get_step(src,dir)
switch(strength)
if(0)
A = new/obj/effect/accelerated_particle/weak(T, dir)
if(1)
A = new/obj/effect/accelerated_particle(T, dir)
if(2)
A = new/obj/effect/accelerated_particle/strong(T, dir)
if(A)
A.dir = src.dir
return 1
return 0
@@ -0,0 +1,10 @@
/obj/structure/particle_accelerator/power_box
name = "Particle Focusing EM Lens"
desc_holder = "This uses electromagnetic waves to focus the Alpha-Particles."
icon = 'icons/obj/machines/particle_accelerator2.dmi'
icon_state = "power_box"
reference = "power_box"
/obj/structure/particle_accelerator/power_box/update_icon()
..()
return
@@ -0,0 +1,570 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
var/global/list/uneatable = list(
/turf/space,
/obj/effect/overlay
)
/obj/machinery/singularity/
name = "Gravitational Singularity"
desc = "A Gravitational Singularity."
icon = 'icons/obj/singularity.dmi'
icon_state = "singularity_s1"
anchored = 1
density = 1
layer = 6
luminosity = 6
unacidable = 1 //Don't comment this out.
use_power = 0
var/current_size = 1
var/allowed_size = 1
var/contained = 1 //Are we going to move around?
var/energy = 100 //How strong are we?
var/dissipate = 1 //Do we lose energy over time?
var/dissipate_delay = 10
var/dissipate_track = 0
var/dissipate_strength = 1 //How much energy do we lose?
var/move_self = 1 //Do we move on our own?
var/grav_pull = 4 //How many tiles out do we pull?
var/consume_range = 0 //How many tiles out do we eat
var/event_chance = 15 //Prob for event each tick
var/target = null //its target. moves towards the target if it has one
var/last_failed_movement = 0//Will not move in the same dir if it couldnt before, will help with the getting stuck on fields thing
var/teleport_del = 0
var/last_warning
/obj/machinery/singularity/New(loc, var/starting_energy = 50, var/temp = 0)
//CARN: admin-alert for chuckle-fuckery.
admin_investigate_setup()
src.energy = starting_energy
if(temp)
spawn(temp)
del(src)
..()
for(var/obj/machinery/singularity_beacon/singubeacon in machines)
if(singubeacon.active)
target = singubeacon
break
return
/obj/machinery/singularity/attack_hand(mob/user as mob)
consume(user)
return 1
/obj/machinery/singularity/blob_act(severity)
return
/obj/machinery/singularity/ex_act(severity)
switch(severity)
if(1.0)
if(prob(25))
del(src)
return
else
energy += 50
if(2.0 to 3.0)
energy += round((rand(20,60)/2),1)
return
return
/obj/machinery/singularity/Bump(atom/A)
consume(A)
return
/obj/machinery/singularity/Bumped(atom/A)
consume(A)
return
/obj/machinery/singularity/process()
eat()
dissipate()
check_energy()
if(current_size >= 3)
move()
pulse()
if(prob(event_chance))//Chance for it to run a special event TODO:Come up with one or two more that fit
event()
return
/obj/machinery/singularity/attack_ai() //to prevent ais from gibbing themselves when they click on one.
return
/obj/machinery/singularity/proc/admin_investigate_setup()
last_warning = world.time
var/count = locate(/obj/machinery/containment_field) in orange(30, src)
if(!count) message_admins("A singulo has been created without containment fields active ([x],[y],[z])",1)
investigate_log("was created. [count?"":"<font color='red'>No containment fields were active</font>"]","singulo")
/obj/machinery/singularity/proc/dissipate()
if(!dissipate)
return
if(dissipate_track >= dissipate_delay)
src.energy -= dissipate_strength
dissipate_track = 0
else
dissipate_track++
/obj/machinery/singularity/proc/expand(var/force_size = 0)
var/temp_allowed_size = src.allowed_size
if(force_size)
temp_allowed_size = force_size
switch(temp_allowed_size)
if(1)
current_size = 1
icon = 'icons/obj/singularity.dmi'
icon_state = "singularity_s1"
pixel_x = 0
pixel_y = 0
grav_pull = 4
consume_range = 0
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 1
if(3)//1 to 3 does not check for the turfs if you put the gens right next to a 1x1 then its going to eat them
current_size = 3
icon = 'icons/effects/96x96.dmi'
icon_state = "singularity_s3"
pixel_x = -32
pixel_y = -32
grav_pull = 6
consume_range = 1
dissipate_delay = 5
dissipate_track = 0
dissipate_strength = 5
if(5)
if((check_turfs_in(1,2))&&(check_turfs_in(2,2))&&(check_turfs_in(4,2))&&(check_turfs_in(8,2)))
current_size = 5
icon = 'icons/effects/160x160.dmi'
icon_state = "singularity_s5"
pixel_x = -64
pixel_y = -64
grav_pull = 8
consume_range = 2
dissipate_delay = 4
dissipate_track = 0
dissipate_strength = 20
if(7)
if((check_turfs_in(1,3))&&(check_turfs_in(2,3))&&(check_turfs_in(4,3))&&(check_turfs_in(8,3)))
current_size = 7
icon = 'icons/effects/224x224.dmi'
icon_state = "singularity_s7"
pixel_x = -96
pixel_y = -96
grav_pull = 10
consume_range = 3
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 10
if(9)//this one also lacks a check for gens because it eats everything
current_size = 9
icon = 'icons/effects/288x288.dmi'
icon_state = "singularity_s9"
pixel_x = -128
pixel_y = -128
grav_pull = 10
consume_range = 4
dissipate = 0 //It cant go smaller due to e loss
if(current_size == allowed_size)
investigate_log("<font color='red'>grew to size [current_size]</font>","singulo")
return 1
else if(current_size < (--temp_allowed_size))
expand(temp_allowed_size)
else
return 0
/obj/machinery/singularity/proc/check_energy()
if(energy <= 0)
del(src)
return 0
switch(energy)//Some of these numbers might need to be changed up later -Mport
if(1 to 199)
allowed_size = 1
if(200 to 499)
allowed_size = 3
if(500 to 999)
allowed_size = 5
if(1000 to 1999)
allowed_size = 7
if(2000 to INFINITY)
allowed_size = 9
if(current_size != allowed_size)
expand()
return 1
/obj/machinery/singularity/proc/eat()
set background = 1
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
// Let's just make this one loop.
for(var/atom/X in orange(grav_pull,src))
var/dist = get_dist(X, src)
// Movable atoms only
if(dist > consume_range && istype(X, /atom/movable))
if(is_type_in_list(X, uneatable)) continue
if(((X) &&(!X:anchored) && (!istype(X,/mob/living/carbon/human)))|| (src.current_size >= 9))
step_towards(X,src)
else if(istype(X,/mob/living/carbon/human))
var/mob/living/carbon/human/H = X
if(istype(H.shoes,/obj/item/clothing/shoes/magboots))
var/obj/item/clothing/shoes/magboots/M = H.shoes
if(M.magpulse)
continue
step_towards(H,src)
// Turf and movable atoms
else if(dist <= consume_range && (isturf(X) || istype(X, /atom/movable)))
consume(X)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return
/obj/machinery/singularity/proc/consume(var/atom/A)
var/gain = 0
if(is_type_in_list(A, uneatable))
return 0
if (istype(A,/mob/living))//Mobs get gibbed
gain = 20
if(istype(A,/mob/living/carbon/human))
var/mob/living/carbon/human/H = A
if(H.mind)
if((H.mind.assigned_role == "Station Engineer") || (H.mind.assigned_role == "Chief Engineer") )
gain = 100
if(H.mind.assigned_role == "Clown")
gain = rand(-300, 300) // HONK
spawn()
A:gib()
sleep(1)
else if(istype(A,/obj/))
if (istype(A,/obj/item/weapon/storage/backpack/holding))
var/dist = max((current_size - 2),1)
explosion(src.loc,(dist),(dist*2),(dist*4))
return
if(istype(A, /obj/machinery/singularity))//Welp now you did it
var/obj/machinery/singularity/S = A
src.energy += (S.energy/2)//Absorb most of it
del(S)
var/dist = max((current_size - 2),1)
explosion(src.loc,(dist),(dist*2),(dist*4))
return//Quits here, the obj should be gone, hell we might be
if((teleport_del) && (!istype(A, /obj/machinery)))//Going to see if it does not lag less to tele items over to Z 2
var/obj/O = A
O.x = 2
O.y = 2
O.z = 2
else
A.ex_act(1.0)
if(A) del(A)
gain = 2
else if(isturf(A))
var/turf/T = A
if(T.intact)
for(var/obj/O in T.contents)
if(O.level != 1)
continue
if(O.invisibility == 101)
src.consume(O)
T.ChangeTurf(/turf/space)
gain = 2
src.energy += gain
return
/obj/machinery/singularity/proc/move(var/force_move = 0)
if(!move_self)
return 0
var/movement_dir = pick(alldirs - last_failed_movement)
if(force_move)
movement_dir = force_move
if(target && prob(60))
movement_dir = get_dir(src,target) //moves to a singulo beacon, if there is one
if(current_size >= 9)//The superlarge one does not care about things in its way
spawn(0)
step(src, movement_dir)
spawn(1)
step(src, movement_dir)
return 1
else if(check_turfs_in(movement_dir))
last_failed_movement = 0//Reset this because we moved
spawn(0)
step(src, movement_dir)
return 1
else
last_failed_movement = movement_dir
return 0
/obj/machinery/singularity/proc/check_turfs_in(var/direction = 0, var/step = 0)
if(!direction)
return 0
var/steps = 0
if(!step)
switch(current_size)
if(1)
steps = 1
if(3)
steps = 3//Yes this is right
if(5)
steps = 3
if(7)
steps = 4
if(9)
steps = 5
else
steps = step
var/list/turfs = list()
var/turf/T = src.loc
for(var/i = 1 to steps)
T = get_step(T,direction)
if(!isturf(T))
return 0
turfs.Add(T)
var/dir2 = 0
var/dir3 = 0
switch(direction)
if(NORTH||SOUTH)
dir2 = 4
dir3 = 8
if(EAST||WEST)
dir2 = 1
dir3 = 2
var/turf/T2 = T
for(var/j = 1 to steps)
T2 = get_step(T2,dir2)
if(!isturf(T2))
return 0
turfs.Add(T2)
for(var/k = 1 to steps)
T = get_step(T,dir3)
if(!isturf(T))
return 0
turfs.Add(T)
for(var/turf/T3 in turfs)
if(isnull(T3))
continue
if(!can_move(T3))
return 0
return 1
/obj/machinery/singularity/proc/can_move(var/turf/T)
if(!T)
return 0
if((locate(/obj/machinery/containment_field) in T)||(locate(/obj/machinery/shieldwall) in T))
return 0
else if(locate(/obj/machinery/field_generator) in T)
var/obj/machinery/field_generator/G = locate(/obj/machinery/field_generator) in T
if(G && G.active)
return 0
else if(locate(/obj/machinery/shieldwallgen) in T)
var/obj/machinery/shieldwallgen/S = locate(/obj/machinery/shieldwallgen) in T
if(S && S.active)
return 0
return 1
/obj/machinery/singularity/proc/event()
var/numb = pick(1,2,3,4,5,6)
switch(numb)
if(1)//EMP
emp_area()
if(2,3)//tox damage all carbon mobs in area
toxmob()
if(4)//Stun mobs who lack optic scanners
mezzer()
else
return 0
return 1
/obj/machinery/singularity/proc/toxmob()
var/toxrange = 10
var/toxdamage = 4
var/radiation = 15
var/radiationmin = 3
if (src.energy>200)
toxdamage = round(((src.energy-150)/50)*4,1)
radiation = round(((src.energy-150)/50)*5,1)
radiationmin = round((radiation/5),1)//
for(var/mob/living/M in view(toxrange, src.loc))
M.apply_effect(rand(radiationmin,radiation), IRRADIATE)
toxdamage = (toxdamage - (toxdamage*M.getarmor(null, "rad")))
M.apply_effect(toxdamage, TOX)
return
/obj/machinery/singularity/proc/mezzer()
for(var/mob/living/carbon/M in oviewers(8, src))
if(istype(M, /mob/living/carbon/brain)) //Ignore brains
continue
if(M.stat == CONSCIOUS)
if (istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(istype(H.glasses,/obj/item/clothing/glasses/meson))
H << "\blue You look directly into The [src.name], good thing you had your protective eyewear on!"
return
M << "\red You look directly into The [src.name] and feel weak."
M.apply_effect(3, STUN)
for(var/mob/O in viewers(M, null))
O.show_message(text("\red <B>[] stares blankly at The []!</B>", M, src), 1)
return
/obj/machinery/singularity/proc/emp_area()
empulse(src, 8, 10)
return
/obj/machinery/singularity/proc/pulse()
for(var/obj/machinery/power/rad_collector/R in rad_collectors)
if(get_dist(R, src) <= 15) // Better than using orange() every process
R.receive_pulse(energy)
return
/obj/machinery/singularity/narsie //Moving narsie to a child object of the singularity so it can be made to function differently. --NEO
name = "Nar-Sie"
desc = "Your mind begins to bubble and ooze as it tries to comprehend what it sees."
icon = 'icons/obj/magic_terror.dmi'
pixel_x = -89
pixel_y = -85
current_size = 9 //It moves/eats like a max-size singulo, aside from range. --NEO
contained = 0 //Are we going to move around?
dissipate = 0 //Do we lose energy over time?
move_self = 1 //Do we move on our own?
grav_pull = 10 //How many tiles out do we pull?
consume_range = 3 //How many tiles out do we eat
/obj/machinery/singularity/narsie/large
name = "Nar-Sie"
icon = 'icons/obj/narsie.dmi'
// Pixel stuff centers Narsie.
pixel_x = -236
pixel_y = -256
current_size = 12
move_self = 1 //Do we move on our own?
consume_range = 12 //How many tiles out do we eat
/obj/machinery/singularity/narsie/large/New()
..()
world << "<font size='28' color='red'><b>NAR-SIE HAS RISEN</b></font>"
if(emergency_shuttle)
emergency_shuttle.incall(0.5) // Cannot recall
/obj/machinery/singularity/narsie/process()
eat()
if(!target || prob(5))
pickcultist()
move()
if(prob(25))
mezzer()
/obj/machinery/singularity/narsie/consume(var/atom/A) //Has its own consume proc because it doesn't need energy and I don't want BoHs to explode it. --NEO
if(is_type_in_list(A, uneatable))
return 0
if (istype(A,/mob/living))//Mobs get gibbed
A:gib()
else if(istype(A,/obj/))
A:ex_act(1.0)
if(A) del(A)
else if(isturf(A))
var/turf/T = A
if(T.intact)
for(var/obj/O in T.contents)
if(O.level != 1)
continue
if(O.invisibility == 101)
src.consume(O)
A:ChangeTurf(/turf/space)
return
/obj/machinery/singularity/narsie/ex_act() //No throwing bombs at it either. --NEO
return
/obj/machinery/singularity/narsie/proc/pickcultist() //Narsie rewards his cultists with being devoured first, then picks a ghost to follow. --NEO
var/list/cultists = list()
for(var/datum/mind/cult_nh_mind in ticker.mode.cult)
if(!cult_nh_mind.current)
continue
if(cult_nh_mind.current.stat)
continue
var/turf/pos = get_turf(cult_nh_mind.current)
if(pos.z != src.z)
continue
cultists += cult_nh_mind.current
if(cultists.len)
acquire(pick(cultists))
return
//If there was living cultists, it picks one to follow.
for(var/mob/living/carbon/human/food in living_mob_list)
if(food.stat)
continue
var/turf/pos = get_turf(food)
if(pos.z != src.z)
continue
cultists += food
if(cultists.len)
acquire(pick(cultists))
return
//no living cultists, pick a living human instead.
for(var/mob/dead/observer/ghost in player_list)
if(!ghost.client)
continue
var/turf/pos = get_turf(ghost)
if(pos.z != src.z)
continue
cultists += ghost
if(cultists.len)
acquire(pick(cultists))
return
//no living humans, follow a ghost instead.
/obj/machinery/singularity/narsie/proc/acquire(var/mob/food)
target << "\blue <b>NAR-SIE HAS LOST INTEREST IN YOU</b>"
target = food
if(ishuman(target))
target << "\red <b>NAR-SIE HUNGERS FOR YOUR SOUL</b>"
else
target << "\red <b>NAR-SIE HAS CHOSEN YOU TO LEAD HIM TO HIS NEXT MEAL</b>"
//Wizard narsie
/obj/machinery/singularity/narsie/wizard
grav_pull = 0
/obj/machinery/singularity/narsie/wizard/eat()
set background = 1
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
for(var/atom/X in orange(consume_range,src))
if(isturf(X) || istype(X, /atom/movable))
consume(X)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return
+318
View File
@@ -0,0 +1,318 @@
// the SMES
// stores power
#define SMESMAXCHARGELEVEL 200000
#define SMESMAXOUTPUT 200000
/obj/machinery/power/smes
name = "power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit."
icon_state = "smes"
density = 1
anchored = 1
use_power = 0
var/output = 50000
var/lastout = 0
var/loaddemand = 0
var/capacity = 5e6
var/charge = 1e6
var/charging = 0
var/chargemode = 0
var/chargecount = 0
var/chargelevel = 50000
var/online = 1
var/name_tag = null
var/obj/machinery/power/terminal/terminal = null
//Holders for powerout event.
var/last_output = 0
var/last_charge = 0
var/last_online = 0
/obj/machinery/power/smes/New()
..()
spawn(5)
dir_loop:
for(var/d in cardinal)
var/turf/T = get_step(src, d)
for(var/obj/machinery/power/terminal/term in T)
if(term && term.dir == turn(d, 180))
terminal = term
break dir_loop
if(!terminal)
stat |= BROKEN
return
terminal.master = src
updateicon()
return
/obj/machinery/power/smes/proc/updateicon()
overlays.Cut()
if(stat & BROKEN) return
overlays += image('icons/obj/power.dmi', "smes-op[online]")
if(charging)
overlays += image('icons/obj/power.dmi', "smes-oc1")
else
if(chargemode)
overlays += image('icons/obj/power.dmi', "smes-oc0")
var/clevel = chargedisplay()
if(clevel>0)
overlays += image('icons/obj/power.dmi', "smes-og[clevel]")
return
/obj/machinery/power/smes/proc/chargedisplay()
return round(5.5*charge/(capacity ? capacity : 5e6))
#define SMESRATE 0.05 // rate of internal charge to external power
/obj/machinery/power/smes/process()
if(stat & BROKEN) return
//store machine state to see if we need to update the icon overlays
var/last_disp = chargedisplay()
var/last_chrg = charging
var/last_onln = online
if(terminal)
var/excess = terminal.surplus()
if(charging)
if(excess >= 0) // if there's power available, try to charge
var/load = min((capacity-charge)/SMESRATE, chargelevel) // charge at set rate, limited to spare capacity
charge += load * SMESRATE // increase the charge
add_load(load) // add the load to the terminal side network
else // if not enough capcity
charging = 0 // stop charging
chargecount = 0
else
if(chargemode)
if(chargecount > rand(3,6))
charging = 1
chargecount = 0
if(excess > chargelevel)
chargecount++
else
chargecount = 0
else
chargecount = 0
if(online) // if outputting
lastout = min( charge/SMESRATE, output) //limit output to that stored
charge -= lastout*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
add_avail(lastout) // add output to powernet (smes side)
if(charge < 0.0001)
online = 0 // stop output if charge falls to zero
// only update icon if state changed
if(last_disp != chargedisplay() || last_chrg != charging || last_onln != online)
updateicon()
return
// called after all power processes are finished
// restores charge level to smes if there was excess this ptick
/obj/machinery/power/smes/proc/restore()
if(stat & BROKEN)
return
if(!online)
loaddemand = 0
return
var/excess = powernet.netexcess // this was how much wasn't used on the network last ptick, minus any removed by other SMESes
excess = min(lastout, excess) // clamp it to how much was actually output by this SMES last ptick
excess = min((capacity-charge)/SMESRATE, excess) // for safety, also limit recharge by space capacity of SMES (shouldn't happen)
// now recharge this amount
var/clev = chargedisplay()
charge += excess * SMESRATE
powernet.netexcess -= excess // remove the excess from the powernet, so later SMESes don't try to use it
loaddemand = lastout-excess
if(clev != chargedisplay() )
updateicon()
return
/obj/machinery/power/smes/add_load(var/amount)
if(terminal && terminal.powernet)
terminal.powernet.newload += amount
/obj/machinery/power/smes/attack_ai(mob/user)
add_fingerprint(user)
ui_interact(user)
/obj/machinery/power/smes/attack_hand(mob/user)
add_fingerprint(user)
ui_interact(user)
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
if(stat & BROKEN)
return
// this is the data which will be sent to the ui
var/data[0]
data["nameTag"] = name_tag
data["storedCapacity"] = round(100.0*charge/capacity, 0.1)
data["charging"] = charging
data["chargeMode"] = chargemode
data["chargeLevel"] = chargelevel
data["chargeMax"] = SMESMAXCHARGELEVEL
data["outputOnline"] = online
data["outputLevel"] = output
data["outputMax"] = SMESMAXOUTPUT
data["outputLoad"] = round(loaddemand)
// update the ui if it exists, returns null if no ui is passed/found
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
if (!ui)
// the ui does not exist, so we'll create a new() one
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
ui = new(user, src, ui_key, "smes.tmpl", "SMES Power Storage Unit", 540, 380)
// when the ui is first opened this is the data it will use
ui.set_initial_data(data)
// open the new ui window
ui.open()
// auto update every Master Controller tick
ui.set_auto_update(1)
/obj/machinery/power/smes/Topic(href, href_list)
..()
if (usr.stat || usr.restrained() )
return
if (!(istype(usr, /mob/living/carbon/human) || ticker) && ticker.mode.name != "monkey")
if(!istype(usr, /mob/living/silicon/ai))
usr << "\red You don't have the dexterity to do this!"
return
//world << "[href] ; [href_list[href]]"
if (!istype(src.loc, /turf) && !istype(usr, /mob/living/silicon/))
return 0 // Do not update ui
if( href_list["cmode"] )
chargemode = !chargemode
if(!chargemode)
charging = 0
updateicon()
else if( href_list["online"] )
online = !online
updateicon()
else if( href_list["input"] )
switch( href_list["input"] )
if("min")
chargelevel = 0
if("max")
chargelevel = SMESMAXCHARGELEVEL //30000
if("set")
chargelevel = input(usr, "Enter new input level (0-[SMESMAXCHARGELEVEL])", "SMES Input Power Control", chargelevel) as num
chargelevel = max(0, min(SMESMAXCHARGELEVEL, chargelevel)) // clamp to range
else if( href_list["output"] )
switch( href_list["output"] )
if("min")
output = 0
if("max")
output = SMESMAXOUTPUT //30000
if("set")
output = input(usr, "Enter new output level (0-[SMESMAXOUTPUT])", "SMES Output Power Control", output) as num
output = max(0, min(SMESMAXOUTPUT, output)) // clamp to range
investigate_log("input/output; [chargelevel>output?"<font color='green'>":"<font color='red'>"][chargelevel]/[output]</font> | Output-mode: [online?"<font color='green'>on</font>":"<font color='red'>off</font>"] | Input-mode: [chargemode?"<font color='green'>auto</font>":"<font color='red'>off</font>"] by [usr.key]","singulo")
return 1
/obj/machinery/power/smes/proc/ion_act()
if(src.z == 1)
if(prob(1)) //explosion
world << "\red SMES explosion in [src.loc.loc]"
for(var/mob/M in viewers(src))
M.show_message("\red The [src.name] is making strange noises!", 3, "\red You hear sizzling electronics.", 2)
sleep(10*pick(4,5,6,7,10,14))
var/datum/effect/effect/system/smoke_spread/smoke = new /datum/effect/effect/system/smoke_spread()
smoke.set_up(3, 0, src.loc)
smoke.attach(src)
smoke.start()
explosion(src.loc, -1, 0, 1, 3, 0)
del(src)
return
if(prob(15)) //Power drain
world << "\red SMES power drain in [src.loc.loc]"
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)
s.start()
if(prob(50))
emp_act(1)
else
emp_act(2)
if(prob(5)) //smoke only
world << "\red SMES smoke in [src.loc.loc]"
var/datum/effect/effect/system/smoke_spread/smoke = new /datum/effect/effect/system/smoke_spread()
smoke.set_up(3, 0, src.loc)
smoke.attach(src)
smoke.start()
/obj/machinery/power/smes/emp_act(severity)
online = 0
charging = 0
output = 0
charge -= 1e6/severity
if (charge < 0)
charge = 0
spawn(100)
output = initial(output)
charging = initial(charging)
online = initial(online)
..()
/obj/machinery/power/smes/magical
name = "magical power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit. Magically produces power."
process()
capacity = INFINITY
charge = INFINITY
..()
/proc/rate_control(var/S, var/V, var/C, var/Min=1, var/Max=5, var/Limit=null)
var/href = "<A href='?src=\ref[S];rate control=1;[V]"
var/rate = "[href]=-[Max]'>-</A>[href]=-[Min]'>-</A> [(C?C : 0)] [href]=[Min]'>+</A>[href]=[Max]'>+</A>"
if(Limit) return "[href]=-[Limit]'>-</A>"+rate+"[href]=[Limit]'>+</A>"
return rate
#undef SMESRATE
+537
View File
@@ -0,0 +1,537 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
#define SOLAR_MAX_DIST 40
#define SOLARGENRATE 1500
var/list/solars_list = list()
// This will choose whether to get the solar list from the powernet or the powernet nodes,
// depending on the size of the nodes.
/obj/machinery/power/proc/get_solars_powernet()
if(!powernet)
return list()
if(solars_list.len < powernet.nodes)
return solars_list
else
return powernet.nodes
/obj/machinery/power/solar
name = "solar panel"
desc = "A solar electrical generator."
icon = 'icons/obj/power.dmi'
icon_state = "sp_base"
anchored = 1
density = 1
directwired = 1
use_power = 0
idle_power_usage = 0
active_power_usage = 0
var/id = 0
var/health = 10
var/obscured = 0
var/sunfrac = 0
var/adir = SOUTH
var/ndir = SOUTH
var/turn_angle = 0
var/obj/machinery/power/solar_control/control = null
/obj/machinery/power/solar/New(var/turf/loc, var/obj/item/solar_assembly/S, var/process = 1)
..(loc)
Make(S)
connect_to_network(process)
/obj/machinery/power/solar/disconnect_from_network()
..()
solars_list.Remove(src)
/obj/machinery/power/solar/connect_to_network(var/process)
..()
if(process)
solars_list.Add(src)
/obj/machinery/power/solar/proc/Make(var/obj/item/solar_assembly/S)
if(!S)
S = new /obj/item/solar_assembly(src)
S.glass_type = /obj/item/stack/sheet/glass
S.anchored = 1
S.loc = src
update_icon()
/obj/machinery/power/solar/attackby(obj/item/weapon/W, mob/user)
if(iscrowbar(W))
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
if(do_after(user, 50))
var/obj/item/solar_assembly/S = locate() in src
if(S)
S.loc = src.loc
S.give_glass()
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
user.visible_message("<span class='notice'>[user] takes the glass off the solar panel.</span>")
del(src)
return
else if (W)
src.add_fingerprint(user)
src.health -= W.force
src.healthcheck()
..()
/obj/machinery/power/solar/blob_act()
src.health--
src.healthcheck()
return
/obj/machinery/power/solar/proc/healthcheck()
if (src.health <= 0)
if(!(stat & BROKEN))
broken()
else
new /obj/item/weapon/shard(src.loc)
new /obj/item/weapon/shard(src.loc)
del(src)
return
return
/obj/machinery/power/solar/update_icon()
..()
overlays.Cut()
if(stat & BROKEN)
overlays += image('icons/obj/power.dmi', icon_state = "solar_panel-b", layer = FLY_LAYER)
else
overlays += image('icons/obj/power.dmi', icon_state = "solar_panel", layer = FLY_LAYER)
src.dir = angle2dir(adir)
return
/obj/machinery/power/solar/proc/update_solar_exposure()
if(!sun)
return
if(obscured)
sunfrac = 0
return
var/p_angle = abs((360+adir)%360 - (360+sun.angle)%360)
if(p_angle > 90) // if facing more than 90deg from sun, zero output
sunfrac = 0
return
sunfrac = cos(p_angle) ** 2
/obj/machinery/power/solar/process()//TODO: remove/add this from machines to save on processing as needed ~Carn PRIORITY
if(stat & BROKEN) return
if(!control) return
if(adir != ndir)
adir = (360+adir+dd_range(-10,10,ndir-adir))%360
update_icon()
update_solar_exposure()
if(obscured) return
var/sgen = SOLARGENRATE * sunfrac
add_avail(sgen)
if(powernet && control)
if(powernet.nodes[control])
control.gen += sgen
/obj/machinery/power/solar/proc/broken()
stat |= BROKEN
update_icon()
return
/obj/machinery/power/solar/meteorhit()
if(stat & !BROKEN)
broken()
else
del(src)
/obj/machinery/power/solar/ex_act(severity)
switch(severity)
if(1.0)
del(src)
if(prob(15))
new /obj/item/weapon/shard( src.loc )
return
if(2.0)
if (prob(25))
new /obj/item/weapon/shard( src.loc )
del(src)
return
if (prob(50))
broken()
if(3.0)
if (prob(25))
broken()
return
/obj/machinery/power/solar/blob_act()
if(prob(75))
broken()
src.density = 0
/obj/machinery/power/solar/fake/New(var/turf/loc, var/obj/item/solar_assembly/S)
..(loc, S, 0)
/obj/machinery/power/solar/fake/process()
. = PROCESS_KILL
return
//
// Solar Assembly - For construction of solar arrays.
//
/obj/item/solar_assembly
name = "solar panel assembly"
desc = "A solar panel assembly kit, allows constructions of a solar panel, or with a tracking circuit board, a solar tracker"
icon = 'icons/obj/power.dmi'
icon_state = "sp_base"
item_state = "electropack"
w_class = 4 // Pretty big!
anchored = 0
var/tracker = 0
var/glass_type = null
/obj/item/solar_assembly/attack_hand(var/mob/user)
if(!anchored && isturf(loc)) // You can't pick it up
..()
// Give back the glass type we were supplied with
/obj/item/solar_assembly/proc/give_glass()
if(glass_type)
var/obj/item/stack/sheet/S = new glass_type(src.loc)
S.amount = 2
glass_type = null
/obj/item/solar_assembly/attackby(var/obj/item/weapon/W, var/mob/user)
if(!anchored && isturf(loc))
if(iswrench(W))
anchored = 1
user.visible_message("<span class='notice'>[user] wrenches the solar assembly into place.</span>")
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
return 1
else
if(iswrench(W))
anchored = 0
user.visible_message("<span class='notice'>[user] unwrenches the solar assembly from it's place.</span>")
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
return 1
if(istype(W, /obj/item/stack/sheet/glass) || istype(W, /obj/item/stack/sheet/rglass))
var/obj/item/stack/sheet/S = W
if(S.amount >= 2)
glass_type = W.type
S.use(2)
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
user.visible_message("<span class='notice'>[user] places the glass on the solar assembly.</span>")
if(tracker)
new /obj/machinery/power/tracker(get_turf(src), src)
else
new /obj/machinery/power/solar(get_turf(src), src)
return 1
if(!tracker)
if(istype(W, /obj/item/weapon/tracker_electronics))
tracker = 1
user.drop_item()
del(W)
user.visible_message("<span class='notice'>[user] inserts the electronics into the solar assembly.</span>")
return 1
else
if(iscrowbar(W))
new /obj/item/weapon/tracker_electronics(src.loc)
tracker = 0
user.visible_message("<span class='notice'>[user] takes out the electronics from the solar assembly.</span>")
return 1
..()
//
// Solar Control Computer
//
/obj/machinery/power/solar_control
name = "solar panel control"
desc = "A controller for solar panel arrays."
icon = 'icons/obj/computer.dmi'
icon_state = "solar"
anchored = 1
density = 1
directwired = 1
use_power = 1
idle_power_usage = 5
active_power_usage = 20
var/id = 0
var/cdir = 0
var/gen = 0
var/lastgen = 0
var/track = 0 // 0=off 1=manual 2=automatic
var/trackrate = 60 // Measured in tenths of degree per minute (i.e. defaults to 6.0 deg/min)
var/trackdir = 1 // -1=CCW, 1=CW
var/nexttime = 0 // Next clock time that manual tracking will move the array
/obj/machinery/power/solar_control/New()
..()
if(ticker)
initialize()
connect_to_network()
/obj/machinery/power/solar_control/disconnect_from_network()
..()
solars_list.Remove(src)
/obj/machinery/power/solar_control/connect_to_network()
..()
if(powernet)
solars_list.Add(src)
/obj/machinery/power/solar_control/initialize()
..()
if(!powernet) return
set_panels(cdir)
/obj/machinery/power/solar_control/update_icon()
if(stat & BROKEN)
icon_state = "broken"
overlays.Cut()
return
if(stat & NOPOWER)
icon_state = "c_unpowered"
overlays.Cut()
return
icon_state = "solar"
overlays.Cut()
if(cdir > 0)
overlays += image('icons/obj/computer.dmi', "solcon-o", FLY_LAYER, angle2dir(cdir))
return
/obj/machinery/power/solar_control/attack_ai(mob/user)
add_fingerprint(user)
if(stat & (BROKEN | NOPOWER)) return
interact(user)
/obj/machinery/power/solar_control/attack_hand(mob/user)
add_fingerprint(user)
if(stat & (BROKEN | NOPOWER)) return
interact(user)
/obj/machinery/power/solar_control/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/solar_control/M = new /obj/item/weapon/circuitboard/solar_control( A )
for (var/obj/C in src)
C.loc = src.loc
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/solar_control/M = new /obj/item/weapon/circuitboard/solar_control( A )
for (var/obj/C in src)
C.loc = src.loc
A.circuit = M
A.state = 4
A.icon_state = "4"
A.anchored = 1
del(src)
else
src.attack_hand(user)
return
/obj/machinery/power/solar_control/process()
lastgen = gen
gen = 0
if(stat & (NOPOWER | BROKEN))
return
use_power(250)
if(track==1 && nexttime < world.time && trackdir*trackrate)
// Increments nexttime using itself and not world.time to prevent drift
nexttime = nexttime + 6000/trackrate
// Nudges array 1 degree in desired direction
cdir = (cdir+trackdir+360)%360
set_panels(cdir)
update_icon()
src.updateDialog()
// called by solar tracker when sun position changes
/obj/machinery/power/solar_control/proc/tracker_update(var/angle)
if(track != 2 || stat & (NOPOWER | BROKEN))
return
cdir = angle
set_panels(cdir)
update_icon()
src.updateDialog()
/obj/machinery/power/solar_control/interact(mob/user)
if(stat & (BROKEN | NOPOWER)) return
if ( (get_dist(src, user) > 1 ))
if (!istype(user, /mob/living/silicon))
user.unset_machine()
user << browse(null, "window=solcon")
return
add_fingerprint(user)
user.set_machine(src)
var/t = "<TT><B>Solar Generator Control</B><HR><PRE>"
t += "<B>Generated power</B> : [round(lastgen)] W<BR>"
t += "Station Rotational Period: [60/abs(sun.rate)] minutes<BR>"
t += "Station Rotational Direction: [sun.rate<0 ? "CCW" : "CW"]<BR>"
t += "Star Orientation: [sun.angle]&deg ([angle2text(sun.angle)])<BR>"
t += "Array Orientation: [rate_control(src,"cdir","[cdir]&deg",1,10,60)] ([angle2text(cdir)])<BR>"
t += "<BR><HR><BR>"
t += "Tracking: "
switch(track)
if(0)
t += "<B>Off</B> <A href='?src=\ref[src];track=1'>Manual</A> <A href='?src=\ref[src];track=2'>Automatic</A><BR>"
if(1)
t += "<A href='?src=\ref[src];track=0'>Off</A> <B>Manual</B> <A href='?src=\ref[src];track=2'>Automatic</A><BR>"
if(2)
t += "<A href='?src=\ref[src];track=0'>Off</A> <A href='?src=\ref[src];track=1'>Manual</A> <B>Automatic</B><BR>"
t += "Manual Tracking Rate: [rate_control(src,"tdir","[trackrate/10]&deg/min ([trackdir<0 ? "CCW" : "CW"])",1,10)]<BR>"
t += "Manual Tracking Direction: "
switch(trackdir)
if(-1)
t += "<A href='?src=\ref[src];trackdir=1'>CW</A> <B>CCW</B><BR>"
if(1)
t += "<B>CW</B> <A href='?src=\ref[src];trackdir=-1'>CCW</A><BR>"
t += "<A href='?src=\ref[src];close=1'>Close</A></TT>"
user << browse(t, "window=solcon")
onclose(user, "solcon")
return
/obj/machinery/power/solar_control/Topic(href, href_list)
if(..())
usr << browse(null, "window=solcon")
usr.unset_machine()
return
if(href_list["close"] )
usr << browse(null, "window=solcon")
usr.unset_machine()
return
if(href_list["dir"])
cdir = text2num(href_list["dir"])
set_panels(cdir)
update_icon()
if(href_list["rate control"])
if(href_list["cdir"])
src.cdir = dd_range(0,359,(360+src.cdir+text2num(href_list["cdir"]))%360)
spawn(1)
set_panels(cdir)
update_icon()
if(href_list["tdir"])
src.trackrate = dd_range(0,360,src.trackrate+text2num(href_list["tdir"]))
if(src.trackrate) nexttime = world.time + 6000/trackrate
if(href_list["track"])
if(src.trackrate) nexttime = world.time + 6000/trackrate
track = text2num(href_list["track"])
if(powernet && (track == 2))
if(!solars_list.Find(src,1,0))
solars_list.Add(src)
for(var/obj/machinery/power/tracker/T in get_solars_powernet())
if(powernet.nodes[T])
cdir = T.sun_angle
break
if(href_list["trackdir"])
trackdir = text2num(href_list["trackdir"])
set_panels(cdir)
update_icon()
src.updateUsrDialog()
return
/obj/machinery/power/solar_control/proc/set_panels(var/cdir)
if(!powernet) return
for(var/obj/machinery/power/solar/S in get_solars_powernet())
if(powernet.nodes[S])
if(get_dist(S, src) < SOLAR_MAX_DIST)
if(!S.control)
S.control = src
S.ndir = cdir
/obj/machinery/power/solar_control/power_change()
if(powered())
stat &= ~NOPOWER
update_icon()
else
spawn(rand(0, 15))
stat |= NOPOWER
update_icon()
/obj/machinery/power/solar_control/proc/broken()
stat |= BROKEN
update_icon()
/obj/machinery/power/solar_control/meteorhit()
broken()
return
/obj/machinery/power/solar_control/ex_act(severity)
switch(severity)
if(1.0)
//SN src = null
del(src)
return
if(2.0)
if (prob(50))
broken()
if(3.0)
if (prob(25))
broken()
return
/obj/machinery/power/solar_control/blob_act()
if (prob(75))
broken()
src.density = 0
//
// MISC
//
/obj/item/weapon/paper/solar
name = "paper- 'Going green! Setup your own solar array instructions.'"
info = "<h1>Welcome</h1><p>At greencorps we love the environment, and space. With this package you are able to help mother nature and produce energy without any usage of fossil fuel or plasma! Singularity energy is dangerous while solar energy is safe, which is why it's better. Now here is how you setup your own solar array.</p><p>You can make a solar panel by wrenching the solar assembly onto a cable node. Adding a glass panel, reinforced or regular glass will do, will finish the construction of your solar panel. It is that easy!.</p><p>Now after setting up 19 more of these solar panels you will want to create a solar tracker to keep track of our mother nature's gift, the sun. These are the same steps as before except you insert the tracker equipment circuit into the assembly before performing the final step of adding the glass. You now have a tracker! Now the last step is to add a computer to calculate the sun's movements and to send commands to the solar panels to change direction with the sun. Setting up the solar computer is the same as setting up any computer, so you should have no trouble in doing that. You do need to put a wire node under the computer, and the wire needs to be connected to the tracker.</p><p>Congratulations, you should have a working solar array. If you are having trouble, here are some tips. Make sure all solar equipment are on a cable node, even the computer. You can always deconstruct your creations if you make a mistake.</p><p>That's all to it, be safe, be green!</p>"
+85
View File
@@ -0,0 +1,85 @@
//This is a power switch. When turned on it looks at the cables around the tile that it's on and notes which cables are trying to connect to it.
//After it knows this it creates the number of cables from the center to each of the cables attempting to conenct. These cables cannot be removed
//with wirecutters. When the switch is turned off it removes all the cables on the tile it's on.
//The switch uses a 5s delay to prevent powernet change spamming.
/*
/obj/structure/powerswitch
name = "power switch"
desc = "A switch that controls power."
icon = 'icons/obj/power.dmi'
icon_state = "switch-dbl-up"
var/icon_state_on = "switch-dbl-down"
var/icon_state_off = "switch-dbl-up"
flags = FPRINT
density = 0
anchored = 1
var/on = 0 //up is off, down is on
var/busy = 0 //set to 1 when you start pulling
/obj/structure/powerswitch/simple
icon_state = "switch-up"
icon_state_on = "switch-down"
icon_state_off = "switch-up"
/obj/structure/powerswitch/examine()
..()
if(on)
usr << "The switch is in the on position"
else
usr << "The switch is in the off position"
/obj/structure/powerswitch/attack_ai(mob/user)
user << "\red You're an AI. This is a manual switch. It's not going to work."
return
/obj/structure/powerswitch/attack_hand(mob/user)
if(busy)
user << "\red This switch is already being toggled."
return
..()
busy = 1
for(var/mob/O in viewers(user))
O.show_message(text("\red [user] started pulling the [src]."), 1)
if(do_after(user, 50))
set_state(!on)
for(var/mob/O in viewers(user))
O.show_message(text("\red [user] flipped the [src] into the [on ? "on": "off"] position."), 1)
busy = 0
/obj/structure/powerswitch/proc/set_state(var/state)
on = state
if(on)
icon_state = icon_state_on
var/list/connection_dirs = list()
for(var/direction in list(1,2,4,8,5,6,9,10))
for(var/obj/structure/cable/C in get_step(src,direction))
if(C.d1 == turn(direction, 180) || C.d2 == turn(direction, 180))
connection_dirs += direction
break
for(var/direction in connection_dirs)
var/obj/structure/cable/C = new/obj/structure/cable(src.loc)
C.d1 = 0
C.d2 = direction
C.icon_state = "[C.d1]-[C.d2]"
C.power_switch = src
var/datum/powernet/PN = new()
PN.number = powernets.len + 1
powernets += PN
C.netnum = PN.number
PN.cables += C
C.mergeConnectedNetworks(C.d2)
C.mergeConnectedNetworksOnTurf()
else
icon_state = icon_state_off
for(var/obj/structure/cable/C in src.loc)
del(C)
*/
+32
View File
@@ -0,0 +1,32 @@
// the underfloor wiring terminal for the APC
// autogenerated when an APC is placed
// all conduit connects go to this object instead of the APC
// using this solves the problem of having the APC in a wall yet also inside an area
/obj/machinery/power/terminal
name = "terminal"
icon_state = "term"
desc = "It's an underfloor wiring terminal for power equipment."
level = 1
layer = TURF_LAYER
var/obj/machinery/power/master = null
anchored = 1
directwired = 0 // must have a cable on same turf connecting to terminal
layer = 2.6 // a bit above wires
/obj/machinery/power/terminal/New()
..()
var/turf/T = src.loc
if(level==1) hide(T.intact)
return
/obj/machinery/power/terminal/hide(var/i)
if(i)
invisibility = 101
icon_state = "term-f"
else
invisibility = 0
icon_state = "term"
+92
View File
@@ -0,0 +1,92 @@
//Solar tracker
//Machine that tracks the sun and reports it's direction to the solar controllers
//As long as this is working, solar panels on same powernet will track automatically
/obj/machinery/power/tracker
name = "solar tracker"
desc = "A solar directional tracker."
icon = 'icons/obj/power.dmi'
icon_state = "tracker"
anchored = 1
density = 1
directwired = 1
use_power = 0
var/sun_angle = 0 // sun angle as set by sun datum
/obj/machinery/power/tracker/New(var/turf/loc, var/obj/item/solar_assembly/S)
..(loc)
if(!S)
S = new /obj/item/solar_assembly(src)
S.glass_type = /obj/item/stack/sheet/glass
S.tracker = 1
S.anchored = 1
S.loc = src
connect_to_network()
/obj/machinery/power/tracker/disconnect_from_network()
..()
solars_list.Remove(src)
/obj/machinery/power/tracker/connect_to_network()
..()
solars_list.Add(src)
// called by datum/sun/calc_position() as sun's angle changes
/obj/machinery/power/tracker/proc/set_angle(var/angle)
sun_angle = angle
//set icon dir to show sun illumination
dir = turn(NORTH, -angle - 22.5) // 22.5 deg bias ensures, e.g. 67.5-112.5 is EAST
// check we can draw power
if(stat & NOPOWER)
return
// find all solar controls and update them
// currently, just update all controllers in world
// ***TODO: better communication system using network
if(powernet)
for(var/obj/machinery/power/solar_control/C in get_solars_powernet())
if(powernet.nodes[C])
if(get_dist(C, src) < SOLAR_MAX_DIST)
C.tracker_update(angle)
/obj/machinery/power/tracker/attackby(var/obj/item/weapon/W, var/mob/user)
if(iscrowbar(W))
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
if(do_after(user, 50))
var/obj/item/solar_assembly/S = locate() in src
if(S)
S.loc = src.loc
S.give_glass()
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
user.visible_message("<span class='notice'>[user] takes the glass off the tracker.</span>")
del(src)
return
..()
// timed process
// make sure we can draw power from the powernet
/obj/machinery/power/tracker/process()
var/avail = surplus()
if(avail > 500)
add_load(500)
stat &= ~NOPOWER
else
stat |= NOPOWER
// Tracker Electronic
/obj/item/weapon/tracker_electronics
name = "tracker electronics"
icon = 'icons/obj/doors/door_assembly.dmi'
icon_state = "door_electronics"
w_class = 2.0
+311
View File
@@ -0,0 +1,311 @@
/obj/machinery/compressor
name = "compressor"
desc = "The compressor stage of a gas turbine generator."
icon = 'icons/obj/pipes.dmi'
icon_state = "compressor"
anchored = 1
density = 1
var/obj/machinery/power/turbine/turbine
var/datum/gas_mixture/gas_contained
var/turf/simulated/inturf
var/starter = 0
var/rpm = 0
var/rpmtarget = 0
var/capacity = 1e6
var/comp_id = 0
/obj/machinery/power/turbine
name = "gas turbine generator"
desc = "A gas turbine used for backup power generation."
icon = 'icons/obj/pipes.dmi'
icon_state = "turbine"
anchored = 1
density = 1
var/obj/machinery/compressor/compressor
directwired = 1
var/turf/simulated/outturf
var/lastgen
/obj/machinery/computer/turbine_computer
name = "Gas turbine control computer"
desc = "A computer to remotely control a gas turbine"
icon = 'icons/obj/computer.dmi'
icon_state = "airtunnel0e"
anchored = 1
density = 1
var/obj/machinery/compressor/compressor
var/list/obj/machinery/door/poddoor/doors
var/id = 0
var/door_status = 0
// the inlet stage of the gas turbine electricity generator
/obj/machinery/compressor/New()
..()
gas_contained = new
inturf = get_step(src, dir)
spawn(5)
turbine = locate() in get_step(src, get_dir(inturf, src))
if(!turbine)
stat |= BROKEN
#define COMPFRICTION 5e5
#define COMPSTARTERLOAD 2800
/obj/machinery/compressor/process()
if(!starter)
return
overlays.Cut()
if(stat & BROKEN)
return
if(!turbine)
stat |= BROKEN
return
rpm = 0.9* rpm + 0.1 * rpmtarget
var/datum/gas_mixture/environment = inturf.return_air()
var/transfer_moles = environment.total_moles()/10
//var/transfer_moles = rpm/10000*capacity
var/datum/gas_mixture/removed = inturf.remove_air(transfer_moles)
gas_contained.merge(removed)
rpm = max(0, rpm - (rpm*rpm)/COMPFRICTION)
if(starter && !(stat & NOPOWER))
use_power(2800)
if(rpm<1000)
rpmtarget = 1000
else
if(rpm<1000)
rpmtarget = 0
if(rpm>50000)
overlays += image('icons/obj/pipes.dmi', "comp-o4", FLY_LAYER)
else if(rpm>10000)
overlays += image('icons/obj/pipes.dmi', "comp-o3", FLY_LAYER)
else if(rpm>2000)
overlays += image('icons/obj/pipes.dmi', "comp-o2", FLY_LAYER)
else if(rpm>500)
overlays += image('icons/obj/pipes.dmi', "comp-o1", FLY_LAYER)
//TODO: DEFERRED
/obj/machinery/power/turbine/New()
..()
outturf = get_step(src, dir)
spawn(5)
compressor = locate() in get_step(src, get_dir(outturf, src))
if(!compressor)
stat |= BROKEN
#define TURBPRES 9000000
#define TURBGENQ 20000
#define TURBGENG 0.8
/obj/machinery/power/turbine/process()
if(!compressor.starter)
return
overlays.Cut()
if(stat & BROKEN)
return
if(!compressor)
stat |= BROKEN
return
lastgen = ((compressor.rpm / TURBGENQ)**TURBGENG) *TURBGENQ
add_avail(lastgen)
var/newrpm = ((compressor.gas_contained.temperature) * compressor.gas_contained.total_moles())/4
newrpm = max(0, newrpm)
if(!compressor.starter || newrpm > 1000)
compressor.rpmtarget = newrpm
if(compressor.gas_contained.total_moles()>0)
var/oamount = min(compressor.gas_contained.total_moles(), (compressor.rpm+100)/35000*compressor.capacity)
var/datum/gas_mixture/removed = compressor.gas_contained.remove(oamount)
outturf.assume_air(removed)
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)
/obj/machinery/power/turbine/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
user.machine = src
var/t = "<TT><B>Gas Turbine Generator</B><HR><PRE>"
t += "Generated power : [round(lastgen)] W<BR><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 += "</PRE><HR><A href='?src=\ref[src];close=1'>Close</A>"
t += "</TT>"
user << browse(t, "window=turbine")
onclose(user, "turbine")
return
/obj/machinery/power/turbine/Topic(href, href_list)
..()
if(stat & BROKEN)
return
if (usr.stat || usr.restrained() )
return
if (!(istype(usr, /mob/living/carbon/human) || ticker) && ticker.mode.name != "monkey")
if(!istype(usr, /mob/living/silicon/ai))
usr << "\red You don't have the dexterity to do this!"
return
if (( usr.machine==src && ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai)))
if( href_list["close"] )
usr << browse(null, "window=turbine")
usr.machine = null
return
else if( href_list["str"] )
compressor.starter = !compressor.starter
spawn(0)
for(var/mob/M in viewers(1, src))
if ((M.client && M.machine == src))
src.interact(M)
else
usr << browse(null, "window=turbine")
usr.machine = null
return
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/obj/machinery/computer/turbine_computer/New()
..()
spawn(5)
for(var/obj/machinery/compressor/C in machines)
if(id == C.comp_id)
compressor = C
doors = new /list()
for(var/obj/machinery/door/poddoor/P in machines)
if(P.id == id)
doors += P
/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
var/dat
if(src.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>
\nVent doors: [ src.door_status ? "<A href='?src=\ref[src];doors=1'>Closed</A> <B>Open</B>" : "<B>Closed</B> <A href='?src=\ref[src];doors=1'>Open</A>"]
\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")
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["doors"])
for(var/obj/machinery/door/poddoor/D in src.doors)
if (door_status == 0)
spawn( 0 )
D.open()
door_status = 1
else
spawn( 0 )
D.close()
door_status = 0
else if( href_list["close"] )
usr << browse(null, "window=computer")
usr.machine = null
return
src.add_fingerprint(usr)
src.updateUsrDialog()
return
/obj/machinery/computer/turbine_computer/process()
src.updateDialog()
return