mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-29 16:19:36 +01:00
Merge remote-tracking branch 'upstream/dev' into pacman
Conflicts: code/modules/power/port_gen.dm
This commit is contained in:
@@ -206,7 +206,7 @@ proc/cardinalrange(var/center)
|
||||
icon_state = "box"
|
||||
item_state = "electronic"
|
||||
w_class = 4.0
|
||||
flags = FPRINT | TABLEPASS | CONDUCT
|
||||
flags = CONDUCT
|
||||
throwforce = 5
|
||||
throw_speed = 1
|
||||
throw_range = 2
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
var/lastused_light = 0
|
||||
var/lastused_equip = 0
|
||||
var/lastused_environ = 0
|
||||
var/lastused_charging = 0
|
||||
var/lastused_total = 0
|
||||
var/main_status = 0
|
||||
var/wiresexposed = 0
|
||||
@@ -116,7 +117,7 @@
|
||||
if(terminal)
|
||||
terminal.connect_to_network()
|
||||
|
||||
/obj/machinery/power/apc/drain_power(var/drain_check, var/surge)
|
||||
/obj/machinery/power/apc/drain_power(var/drain_check, var/surge, var/amount = 0)
|
||||
|
||||
if(drain_check)
|
||||
return 1
|
||||
@@ -131,7 +132,10 @@
|
||||
update_icon()
|
||||
return 0
|
||||
|
||||
return cell.drain_power(drain_check)
|
||||
if(terminal && terminal.powernet)
|
||||
terminal.powernet.trigger_warning()
|
||||
|
||||
return cell.drain_power(drain_check, surge, amount)
|
||||
|
||||
/obj/machinery/power/apc/New(turf/loc, var/ndir, var/building=0)
|
||||
..()
|
||||
@@ -178,10 +182,10 @@
|
||||
del(cell) // qdel
|
||||
if(terminal)
|
||||
disconnect_terminal()
|
||||
|
||||
|
||||
//If there's no more APC then there shouldn't be a cause for alarm I guess
|
||||
area.poweralert(1, src) //so that alarms don't go on forever
|
||||
|
||||
|
||||
..()
|
||||
|
||||
/obj/machinery/power/apc/proc/make_terminal()
|
||||
@@ -720,6 +724,11 @@
|
||||
// do APC interaction
|
||||
src.interact(user)
|
||||
|
||||
/obj/machinery/power/apc/attack_ghost(user as mob)
|
||||
if(stat & (BROKEN|MAINT))
|
||||
return
|
||||
return ui_interact(user)
|
||||
|
||||
/obj/machinery/power/apc/interact(mob/user)
|
||||
if(!user)
|
||||
return
|
||||
@@ -756,7 +765,8 @@
|
||||
"powerCellStatus" = cell ? cell.percent() : null,
|
||||
"chargeMode" = chargemode,
|
||||
"chargingStatus" = charging,
|
||||
"totalLoad" = round(lastused_equip + lastused_light + lastused_environ),
|
||||
"totalLoad" = round(lastused_total),
|
||||
"totalCharging" = round(lastused_charging),
|
||||
"coverLocked" = coverlocked,
|
||||
"siliconUser" = istype(user, /mob/living/silicon),
|
||||
"malfStatus" = get_malf_status(user),
|
||||
@@ -1176,6 +1186,7 @@
|
||||
|
||||
// now trickle-charge the cell
|
||||
|
||||
lastused_charging = 0 // Clear the variable for new use.
|
||||
if(src.attempt_charging())
|
||||
if(excess > 0) // check to make sure we have enough to charge
|
||||
// Max charge is capped to % per second constant
|
||||
@@ -1183,7 +1194,8 @@
|
||||
|
||||
ch = draw_power(ch/CELLRATE) // Removes the power we're taking from the grid
|
||||
cell.give(ch*CELLRATE) // actually recharge the cell
|
||||
|
||||
lastused_charging = ch
|
||||
lastused_total += ch // Sensors need this to stop reporting APC charging as "Other" load
|
||||
else
|
||||
charging = 0 // stop charging
|
||||
chargecount = 0
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
//directwired = 0
|
||||
var/icon_state_on = "bbox_on"
|
||||
var/icon_state_off = "bbox_off"
|
||||
flags = FPRINT
|
||||
density = 1
|
||||
anchored = 1
|
||||
var/on = 0
|
||||
|
||||
@@ -36,7 +36,7 @@ By design, d1 is the smallest direction and d2 is the highest
|
||||
color = COLOR_RED
|
||||
var/obj/machinery/power/breakerbox/breaker_box
|
||||
|
||||
/obj/structure/cable/drain_power(var/drain_check)
|
||||
/obj/structure/cable/drain_power(var/drain_check, var/surge, var/amount = 0)
|
||||
|
||||
if(drain_check)
|
||||
return 1
|
||||
@@ -44,18 +44,7 @@ By design, d1 is the smallest direction and d2 is the highest
|
||||
var/datum/powernet/PN = get_powernet()
|
||||
if(!PN) return 0
|
||||
|
||||
var/drained_power = round(rand(200,400)/2)
|
||||
var/drained_this_tick = PN.draw_power(drained_power)
|
||||
|
||||
if(drained_this_tick < drained_power)
|
||||
for(var/obj/machinery/power/terminal/T in PN.nodes)
|
||||
if(istype(T.master, /obj/machinery/power/apc))
|
||||
var/obj/machinery/power/apc/AP = T.master
|
||||
if(AP.emagged)
|
||||
continue
|
||||
drained_power += AP.drain_power() //Indirect draw won't emag the APC, should this be amended?
|
||||
|
||||
return drained_power
|
||||
return PN.draw_power(amount)
|
||||
|
||||
/obj/structure/cable/yellow
|
||||
color = COLOR_YELLOW
|
||||
@@ -488,7 +477,7 @@ obj/structure/cable/proc/cableColor(var/colorC)
|
||||
throw_speed = 2
|
||||
throw_range = 5
|
||||
matter = list("metal" = 50, "glass" = 20)
|
||||
flags = TABLEPASS | FPRINT | CONDUCT
|
||||
flags = CONDUCT
|
||||
slot_flags = SLOT_BELT
|
||||
item_state = "coil"
|
||||
attack_verb = list("whipped", "lashed", "disciplined", "flogged")
|
||||
|
||||
@@ -9,16 +9,17 @@
|
||||
spawn(5)
|
||||
updateicon()
|
||||
|
||||
/obj/item/weapon/cell/drain_power(var/drain_check)
|
||||
/obj/item/weapon/cell/drain_power(var/drain_check, var/surge, var/amount = 0)
|
||||
|
||||
if(drain_check)
|
||||
return 1
|
||||
|
||||
var/drained_power = rand(200,400)
|
||||
if(charge < drained_power)
|
||||
drained_power = charge
|
||||
use(drained_power)
|
||||
return drained_power
|
||||
if(charge <= 0)
|
||||
return 0
|
||||
|
||||
var/cell_amt = min((amount * CELLRATE), charge)
|
||||
use(cell_amt)
|
||||
return cell_amt / CELLRATE
|
||||
|
||||
/obj/item/weapon/cell/proc/updateicon()
|
||||
overlays.Cut()
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
desc = "Used for building lights."
|
||||
icon = 'icons/obj/lighting.dmi'
|
||||
icon_state = "tube-construct-item"
|
||||
flags = FPRINT | TABLEPASS| CONDUCT
|
||||
flags = CONDUCT
|
||||
var/fixture_type = "tube"
|
||||
var/obj/machinery/light/newlight = null
|
||||
var/sheets_refunded = 2
|
||||
@@ -63,7 +63,7 @@
|
||||
desc = "Used for building small lights."
|
||||
icon = 'icons/obj/lighting.dmi'
|
||||
icon_state = "bulb-construct-item"
|
||||
flags = FPRINT | TABLEPASS| CONDUCT
|
||||
flags = CONDUCT
|
||||
fixture_type = "bulb"
|
||||
sheets_refunded = 1
|
||||
|
||||
@@ -637,7 +637,6 @@
|
||||
|
||||
/obj/item/weapon/light
|
||||
icon = 'icons/obj/lighting.dmi'
|
||||
flags = FPRINT | TABLEPASS
|
||||
force = 2
|
||||
throwforce = 5
|
||||
w_class = 2
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
icon_state = initial(icon_state)
|
||||
handleInactive()
|
||||
|
||||
/obj/machinery/power/powered()
|
||||
return 1 //doesn't require an external power source
|
||||
|
||||
/obj/machinery/power/port_gen/attack_hand(mob/user as mob)
|
||||
if(..())
|
||||
return
|
||||
@@ -85,7 +88,7 @@
|
||||
|
||||
var/sheet_name = "solid plasma sheet"
|
||||
var/sheet_path = /obj/item/stack/sheet/mineral/phoron
|
||||
var/board_path = "/obj/item/weapon/circuitboard/pacman"
|
||||
var/board_path = "/obj/item/weapon/circuitboard/pacman"
|
||||
|
||||
/*
|
||||
These values were chosen so that the generator can run safely up to 80 kW
|
||||
@@ -103,7 +106,7 @@
|
||||
var/sheets = 0 //How many sheets of material are loaded in the generator
|
||||
var/sheet_left = 0 //How much is left of the current sheet
|
||||
var/temperature = 0 //The current temperature
|
||||
var/overheating = 0 //if this gets high enough the generator explodes
|
||||
var/overheating = 0 //if this gets high enough the generator explodes
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/initialize()
|
||||
..()
|
||||
@@ -389,13 +392,13 @@
|
||||
L.apply_effect(max(20, round(rads/get_dist(L,src))), IRRADIATE)
|
||||
|
||||
explosion(src.loc, 3, 3, 5, 3)
|
||||
del(src)
|
||||
del(src)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/mrs
|
||||
name = "M.R.S.P.A.C.M.A.N.-type Portable Generator"
|
||||
desc = "An advanced power generator that runs on tritium. Rated for 200 kW maximum safe output!"
|
||||
icon_state = "portgen2"
|
||||
sheet_path = /obj/item/stack/sheet/mineral/tritium
|
||||
sheet_path = /obj/item/stack/sheet/mineral/tritium
|
||||
|
||||
//I don't think tritium has any other use, so we might as well make this rewarding for players
|
||||
//max safe power output (power level = 8) is 200 kW and lasts for 1 hour - 3 or 4 of these could power the station
|
||||
@@ -409,4 +412,4 @@
|
||||
/obj/machinery/power/port_gen/pacman/mrs/explode()
|
||||
//no special effects, but the explosion is pretty big (same as a supermatter shard).
|
||||
explosion(src.loc, 3, 6, 12, 16, 1)
|
||||
del(src)
|
||||
del(src)
|
||||
|
||||
@@ -24,6 +24,14 @@
|
||||
//////////////////////////////
|
||||
|
||||
// common helper procs for all power machines
|
||||
/obj/machinery/power/drain_power(var/drain_check, var/surge, var/amount = 0)
|
||||
if(drain_check)
|
||||
return 1
|
||||
|
||||
if(powernet && powernet.avail)
|
||||
powernet.trigger_warning()
|
||||
return powernet.draw_power(amount)
|
||||
|
||||
/obj/machinery/power/proc/add_avail(var/amount)
|
||||
if(powernet)
|
||||
powernet.newavail += amount
|
||||
@@ -286,6 +294,8 @@
|
||||
for(var/obj/structure/cable/Cable in net2.cables) //merge cables
|
||||
net1.add_cable(Cable)
|
||||
|
||||
if(!net2) return net1
|
||||
|
||||
for(var/obj/machinery/power/Node in net2.nodes) //merge power machines
|
||||
if(!Node.connect_to_network())
|
||||
Node.disconnect_from_network() //if somehow we can't connect the machine to the new powernet, disconnect it from the old nonetheless
|
||||
@@ -299,12 +309,6 @@
|
||||
//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
|
||||
@@ -330,6 +334,23 @@
|
||||
else
|
||||
log_admin("ERROR: /proc/electrocute_mob([M], [power_source], [source]): wrong power_source")
|
||||
return 0
|
||||
//Triggers powernet warning, but only for 5 ticks (if applicable)
|
||||
//If following checks determine user is protected we won't alarm for long.
|
||||
if(PN)
|
||||
PN.trigger_warning(5)
|
||||
if(istype(M,/mob/living/carbon/human))
|
||||
var/mob/living/carbon/human/H = M
|
||||
if(H.species.siemens_coefficient == 0)
|
||||
return
|
||||
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
|
||||
|
||||
//Checks again. If we are still here subject will be shocked, trigger standard 20 tick warning
|
||||
//Since this one is longer it will override the original one.
|
||||
if(PN)
|
||||
PN.trigger_warning()
|
||||
|
||||
if (!cell && !PN)
|
||||
return 0
|
||||
var/PN_damage = 0
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
/datum/powernet/New()
|
||||
powernets += src
|
||||
..()
|
||||
|
||||
/datum/powernet/Del()
|
||||
powernets -= src
|
||||
..()
|
||||
|
||||
//Returns the amount of excess power (before refunding to SMESs) from last tick.
|
||||
//This is for machines that might adjust their power consumption using this data.
|
||||
@@ -110,8 +112,7 @@
|
||||
S.restore() // and restore some of the power that was used
|
||||
|
||||
//updates the viewed load (as seen on power computers)
|
||||
viewload = 0.8*viewload + 0.2*load
|
||||
viewload = round(viewload)
|
||||
viewload = round(load)
|
||||
|
||||
//reset the powernet
|
||||
load = 0
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
|
||||
//reactor areas
|
||||
|
||||
/area/engine
|
||||
icon_state = "engine"
|
||||
|
||||
fore
|
||||
name = "\improper Fore"
|
||||
|
||||
construction_storage
|
||||
name = "\improper Construction storage"
|
||||
|
||||
atmos_storage
|
||||
name = "\improper Atmos storage"
|
||||
icon_state = "engine_storage"
|
||||
|
||||
control
|
||||
name = "\improper Control"
|
||||
icon_state = "engine_control"
|
||||
|
||||
electrical_storage
|
||||
name = "\improper Electrical storage"
|
||||
|
||||
reactor_core
|
||||
name = "\improper Reactor Core"
|
||||
//icon_state = "engine_core"
|
||||
|
||||
reactor_gas
|
||||
name = "Reactor Gas Storage"
|
||||
//icon_state = "engine_atmos"
|
||||
|
||||
aux_control
|
||||
name = "Reactor Auxiliary Control"
|
||||
//icon_state = "engine_aux"
|
||||
|
||||
turbine_control
|
||||
name = "Turbine Control"
|
||||
//icon_state = "engine_turbine"
|
||||
|
||||
reactor_airlock
|
||||
name = "\improper Reactor Primary Entrance"
|
||||
//icon_state = "engine_airlock"
|
||||
|
||||
reactor_fuel_storage
|
||||
name = "Reactor Fuel Storage"
|
||||
//icon_state = "engine_fuel"
|
||||
|
||||
reactor_fuel_ports
|
||||
name = "\improper Reactor Fuel Ports"
|
||||
//icon_state = "engine_port"
|
||||
|
||||
generators
|
||||
name = "\improper Generator Room"
|
||||
//icon_state = "engine_generators"
|
||||
|
||||
port_gyro_bay
|
||||
name = "\improper Port Gyrotron Bay"
|
||||
//icon_state = "engine_starboardgyro"
|
||||
|
||||
starboard_gyro_bay
|
||||
name = "\improper Starboard Gyrotron Bay"
|
||||
//icon_state = "engine_portgyro"
|
||||
|
||||
storage
|
||||
name = "\improper Engineering Storage"
|
||||
icon_state = "engine_storage"
|
||||
|
||||
storage_hard
|
||||
name = "\improper Engineering Hard Storage"
|
||||
icon_state = "engine_storage"
|
||||
@@ -0,0 +1,120 @@
|
||||
#define IMPRINTER 1 //For circuits. Uses glass/chemicals.
|
||||
//////////////////////////////////////
|
||||
// RUST Core Control computer
|
||||
|
||||
/obj/item/weapon/circuitboard/rust_core_control
|
||||
name = "Circuit board (RUST core controller)"
|
||||
build_path = "/obj/machinery/computer/rust_core_control"
|
||||
origin_tech = "programming=4;engineering=4"
|
||||
|
||||
datum/design/rust_core_control
|
||||
name = "Circuit Design (RUST core controller)"
|
||||
desc = "Allows for the construction of circuit boards used to build a core control console for the RUST fusion engine."
|
||||
id = "rust_core_control"
|
||||
req_tech = list("programming" = 4, "engineering" = 4)
|
||||
build_type = IMPRINTER
|
||||
materials = list("$glass" = 2000, "sacid" = 20)
|
||||
build_path = "/obj/item/weapon/circuitboard/rust_core_control"
|
||||
|
||||
//////////////////////////////////////
|
||||
// RUST Fuel Control computer
|
||||
|
||||
/obj/item/weapon/circuitboard/rust_fuel_control
|
||||
name = "Circuit board (RUST fuel controller)"
|
||||
build_path = "/obj/machinery/computer/rust_fuel_control"
|
||||
origin_tech = "programming=4;engineering=4"
|
||||
|
||||
datum/design/rust_fuel_control
|
||||
name = "Circuit Design (RUST fuel controller)"
|
||||
desc = "Allows for the construction of circuit boards used to build a fuel injector control console for the RUST fusion engine."
|
||||
id = "rust_fuel_control"
|
||||
req_tech = list("programming" = 4, "engineering" = 4)
|
||||
build_type = IMPRINTER
|
||||
materials = list("$glass" = 2000, "sacid" = 20)
|
||||
build_path = "/obj/item/weapon/circuitboard/rust_fuel_control"
|
||||
|
||||
//////////////////////////////////////
|
||||
// RUST Fuel Port board
|
||||
|
||||
/obj/item/weapon/module/rust_fuel_port
|
||||
name = "Internal circuitry (RUST fuel port)"
|
||||
icon_state = "card_mod"
|
||||
origin_tech = "engineering=4;materials=5"
|
||||
|
||||
datum/design/rust_fuel_port
|
||||
name = "Internal circuitry (RUST fuel port)"
|
||||
desc = "Allows for the construction of circuit boards used to build a fuel injection port for the RUST fusion engine."
|
||||
id = "rust_fuel_port"
|
||||
req_tech = list("engineering" = 4, "materials" = 5)
|
||||
build_type = IMPRINTER
|
||||
materials = list("$glass" = 2000, "sacid" = 20, "$uranium" = 3000)
|
||||
build_path = "/obj/item/weapon/module/rust_fuel_port"
|
||||
|
||||
//////////////////////////////////////
|
||||
// RUST Fuel Compressor board
|
||||
|
||||
/obj/item/weapon/module/rust_fuel_compressor
|
||||
name = "Internal circuitry (RUST fuel compressor)"
|
||||
icon_state = "card_mod"
|
||||
origin_tech = "materials=6;phorontech=4"
|
||||
|
||||
datum/design/rust_fuel_compressor
|
||||
name = "Circuit Design (RUST fuel compressor)"
|
||||
desc = "Allows for the construction of circuit boards used to build a fuel compressor of the RUST fusion engine."
|
||||
id = "rust_fuel_compressor"
|
||||
req_tech = list("materials" = 6, "phorontech" = 4)
|
||||
build_type = IMPRINTER
|
||||
materials = list("$glass" = 2000, "sacid" = 20, "$phoron" = 3000, "$diamond" = 1000)
|
||||
build_path = "/obj/item/weapon/module/rust_fuel_compressor"
|
||||
|
||||
//////////////////////////////////////
|
||||
// RUST Tokamak Core board
|
||||
|
||||
/obj/item/weapon/circuitboard/rust_core
|
||||
name = "Internal circuitry (RUST tokamak core)"
|
||||
build_path = "/obj/machinery/power/rust_core"
|
||||
board_type = "machine"
|
||||
origin_tech = "bluespace=3;phorontech=4;magnets=5;powerstorage=6"
|
||||
frame_desc = "Requires 2 Pico Manipulators, 1 Ultra Micro-Laser, 5 Pieces of Cable, 1 Subspace Crystal and 1 Console Screen."
|
||||
req_components = list(
|
||||
"/obj/item/weapon/stock_parts/manipulator/pico" = 2,
|
||||
"/obj/item/weapon/stock_parts/micro_laser/ultra" = 1,
|
||||
"/obj/item/weapon/stock_parts/subspace/crystal" = 1,
|
||||
"/obj/item/weapon/stock_parts/console_screen" = 1,
|
||||
"/obj/item/stack/cable_coil" = 5)
|
||||
|
||||
datum/design/rust_core
|
||||
name = "Internal circuitry (RUST tokamak core)"
|
||||
desc = "The circuit board that for a RUST-pattern tokamak fusion core."
|
||||
id = "pacman"
|
||||
req_tech = list(bluespace = 3, phorontech = 4, magnets = 5, powerstorage = 6)
|
||||
build_type = IMPRINTER
|
||||
reliability_base = 79
|
||||
materials = list("$glass" = 2000, "sacid" = 20, "$phoron" = 3000, "$diamond" = 2000)
|
||||
build_path = "/obj/item/weapon/circuitboard/rust_core"
|
||||
|
||||
//////////////////////////////////////
|
||||
// RUST Fuel Injector board
|
||||
|
||||
/obj/item/weapon/circuitboard/rust_injector
|
||||
name = "Internal circuitry (RUST fuel injector)"
|
||||
build_path = "/obj/machinery/power/rust_fuel_injector"
|
||||
board_type = "machine"
|
||||
origin_tech = "powerstorage=3;engineering=4;phorontech=4;materials=6"
|
||||
frame_desc = "Requires 2 Pico Manipulators, 1 Phasic Scanning Module, 1 Super Matter Bin, 1 Console Screen and 5 Pieces of Cable."
|
||||
req_components = list(
|
||||
"/obj/item/weapon/stock_parts/manipulator/pico" = 2,
|
||||
"/obj/item/weapon/stock_parts/scanning_module/phasic" = 1,
|
||||
"/obj/item/weapon/stock_parts/matter_bin/super" = 1,
|
||||
"/obj/item/weapon/stock_parts/console_screen" = 1,
|
||||
"/obj/item/stack/cable_coil" = 5)
|
||||
|
||||
datum/design/rust_injector
|
||||
name = "Internal circuitry (RUST tokamak core)"
|
||||
desc = "The circuit board that for a RUST-pattern particle accelerator."
|
||||
id = "pacman"
|
||||
req_tech = list(powerstorage = 3, engineering = 4, phorontech = 4, materials = 6)
|
||||
build_type = IMPRINTER
|
||||
reliability_base = 79
|
||||
materials = list("$glass" = 2000, "sacid" = 20, "$phoron" = 3000, "$uranium" = 2000)
|
||||
build_path = "/obj/item/weapon/circuitboard/rust_core"
|
||||
@@ -0,0 +1,143 @@
|
||||
|
||||
/obj/machinery/computer/rust_core_control
|
||||
name = "RUST Core Control"
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "core_control"
|
||||
var/list/connected_devices = list()
|
||||
var/id_tag = "allan remember to update this before you leave"
|
||||
var/scan_range = 25
|
||||
|
||||
//currently viewed
|
||||
var/obj/machinery/power/rust_core/cur_viewed_device
|
||||
|
||||
/obj/machinery/computer/rust_core_control/process()
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
return
|
||||
|
||||
/obj/machinery/computer/rust_core_control/attack_ai(mob/user)
|
||||
attack_hand(user)
|
||||
|
||||
/obj/machinery/computer/rust_core_control/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/computer/rust_core_control/interact(mob/user)
|
||||
if(stat & BROKEN)
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=core_control")
|
||||
return
|
||||
if (!istype(user, /mob/living/silicon) && (get_dist(src, user) > 1 ))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=core_control")
|
||||
return
|
||||
|
||||
var/dat = ""
|
||||
if(stat & NOPOWER)
|
||||
dat += "<i>The console is dark and nonresponsive.</i>"
|
||||
else
|
||||
dat += "<B>Reactor Core Primary Monitor</B><BR>"
|
||||
if(cur_viewed_device && cur_viewed_device.stat & (BROKEN|NOPOWER))
|
||||
cur_viewed_device = null
|
||||
if(cur_viewed_device && !cur_viewed_device.remote_access_enabled)
|
||||
cur_viewed_device = null
|
||||
|
||||
if(cur_viewed_device)
|
||||
dat += "<b>Device tag:</b> [cur_viewed_device.id_tag ? cur_viewed_device.id_tag : "UNSET"]<br>"
|
||||
dat += "<font color=blue>Device [cur_viewed_device.owned_field ? "activated" : "deactivated"].</font><br>"
|
||||
dat += "<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];toggle_active=1'>\[Bring field [cur_viewed_device.owned_field ? "offline" : "online"]\]</a><br>"
|
||||
dat += "<b>Device [cur_viewed_device.anchored ? "secured" : "unsecured"].</b><br>"
|
||||
dat += "<hr>"
|
||||
dat += "<b>Field encumbrance:</b> [cur_viewed_device.owned_field ? 0 : "NA"]<br>"
|
||||
dat += "<b>Field strength:</b> [cur_viewed_device.field_strength] Wm^3<br>"
|
||||
dat += "<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];str=-1000'>\[----\]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];str=-100'>\[--- \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];str=-10'>\[-- \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];str=-1'>\[- \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];str=1'>\[+ \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];str=10'>\[++ \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];str=100'>\[+++ \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];str=1000'>\[++++\]</a><br>"
|
||||
dat += "<b>Field frequency:</b> [cur_viewed_device.field_frequency] MHz<br>"
|
||||
dat += "<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];freq=-1000'>\[----\]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];freq=-100'>\[--- \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];freq=-10'>\[-- \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];freq=-1'>\[- \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];freq=1'>\[+ \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];freq=10'>\[++ \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];freq=100'>\[+++ \]</a> \
|
||||
<a href='?src=\ref[cur_viewed_device];extern_update=\ref[src];freq=1000'>\[++++\]</a><br>"
|
||||
|
||||
var/power_stat = "Good"
|
||||
if(cur_viewed_device.cached_power_avail < cur_viewed_device.active_power_usage)
|
||||
power_stat = "Insufficient"
|
||||
else if(cur_viewed_device.cached_power_avail < cur_viewed_device.active_power_usage * 2)
|
||||
power_stat = "Check"
|
||||
dat += "<b>Power status:</b> [power_stat]<br>"
|
||||
else
|
||||
dat += "<a href='?src=\ref[src];scan=1'>\[Refresh device list\]</a><br><br>"
|
||||
if(connected_devices.len)
|
||||
dat += "<table width='100%' border=1>"
|
||||
dat += "<tr>"
|
||||
dat += "<td><b>Device tag</b></td>"
|
||||
dat += "<td></td>"
|
||||
dat += "</tr>"
|
||||
for(var/obj/machinery/power/rust_core/C in connected_devices)
|
||||
if(!check_core_status(C))
|
||||
connected_devices.Remove(C)
|
||||
continue
|
||||
|
||||
dat += "<tr>"
|
||||
dat += "<td>[C.id_tag]</td>"
|
||||
dat += "<td><a href='?src=\ref[src];manage_individual=\ref[C]'>\[Manage\]</a></td>"
|
||||
dat += "</tr>"
|
||||
dat += "</table>"
|
||||
else
|
||||
dat += "No devices connected.<br>"
|
||||
|
||||
dat += "<hr>"
|
||||
dat += "<a href='?src=\ref[src];refresh=1'>Refresh</a> "
|
||||
dat += "<a href='?src=\ref[src];close=1'>Close</a>"
|
||||
|
||||
user << browse(dat, "window=core_control;size=500x400")
|
||||
onclose(user, "core_control")
|
||||
user.set_machine(src)
|
||||
|
||||
/obj/machinery/computer/rust_core_control/Topic(href, href_list)
|
||||
..()
|
||||
|
||||
if( href_list["goto_scanlist"] )
|
||||
cur_viewed_device = null
|
||||
|
||||
if( href_list["manage_individual"] )
|
||||
cur_viewed_device = locate(href_list["manage_individual"])
|
||||
|
||||
if( href_list["scan"] )
|
||||
connected_devices = list()
|
||||
for(var/obj/machinery/power/rust_core/C in range(scan_range, src))
|
||||
if(check_core_status(C))
|
||||
connected_devices.Add(C)
|
||||
|
||||
if( href_list["startup"] )
|
||||
if(cur_viewed_device)
|
||||
cur_viewed_device.Startup()
|
||||
|
||||
if( href_list["shutdown"] )
|
||||
if(cur_viewed_device)
|
||||
cur_viewed_device.Shutdown()
|
||||
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=core_control")
|
||||
usr.unset_machine()
|
||||
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/computer/rust_core_control/proc/check_core_status(var/obj/machinery/power/rust_core/C)
|
||||
if(!C)
|
||||
return 0
|
||||
|
||||
if(C.stat & (BROKEN|NOPOWER) || !C.remote_access_enabled || !C.id_tag)
|
||||
if(connected_devices.Find(C))
|
||||
connected_devices.Remove(C)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
@@ -0,0 +1,437 @@
|
||||
//the em field is where the fun happens
|
||||
/*
|
||||
Deuterium-deuterium fusion : 40 x 10^7 K
|
||||
Deuterium-tritium fusion: 4.5 x 10^7 K
|
||||
*/
|
||||
|
||||
//#DEFINE MAX_STORED_ENERGY (held_phoron.phoron * held_phoron.phoron * SPECIFIC_HEAT_TOXIN)
|
||||
|
||||
/obj/effect/rust_em_field
|
||||
name = "EM Field"
|
||||
desc = "A coruscating, barely visible field of energy. It is shaped like a slightly flattened torus."
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "emfield_s1"
|
||||
//
|
||||
var/major_radius = 0 //longer radius in meters = field_strength * 0.21875, max = 8.75
|
||||
var/minor_radius = 0 //shorter radius in meters = field_strength * 0.2125, max = 8.625
|
||||
var/size = 1 //diameter in tiles
|
||||
var/volume_covered = 0 //atmospheric volume covered
|
||||
//
|
||||
var/obj/machinery/power/rust_core/owned_core
|
||||
var/list/dormant_reactant_quantities = new
|
||||
//luminosity = 1
|
||||
layer = 3.1
|
||||
//
|
||||
var/energy = 0
|
||||
var/mega_energy = 0
|
||||
var/radiation = 0
|
||||
var/frequency = 1
|
||||
var/field_strength = 0.01 //in teslas, max is 50T
|
||||
|
||||
var/obj/machinery/rust/rad_source/radiator
|
||||
var/datum/gas_mixture/held_phoron = new
|
||||
var/particle_catchers[13]
|
||||
|
||||
var/emp_overload = 0
|
||||
|
||||
/obj/effect/rust_em_field/New()
|
||||
..()
|
||||
//create radiator
|
||||
for(var/obj/machinery/rust/rad_source/rad in range(0))
|
||||
radiator = rad
|
||||
if(!radiator)
|
||||
radiator = new()
|
||||
|
||||
//make sure there's a field generator
|
||||
for(var/obj/machinery/power/rust_core/core in loc)
|
||||
owned_core = core
|
||||
|
||||
if(!owned_core)
|
||||
del(src)
|
||||
|
||||
//create the gimmicky things to handle field collisions
|
||||
var/obj/effect/rust_particle_catcher/catcher
|
||||
//
|
||||
catcher = new (locate(src.x,src.y,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(1)
|
||||
particle_catchers.Add(catcher)
|
||||
//
|
||||
catcher = new (locate(src.x-1,src.y,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(3)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x+1,src.y,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(3)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x,src.y+1,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(3)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x,src.y-1,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(3)
|
||||
particle_catchers.Add(catcher)
|
||||
//
|
||||
catcher = new (locate(src.x-2,src.y,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(5)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x+2,src.y,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(5)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x,src.y+2,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(5)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x,src.y-2,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(5)
|
||||
particle_catchers.Add(catcher)
|
||||
//
|
||||
catcher = new (locate(src.x-3,src.y,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(7)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x+3,src.y,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(7)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x,src.y+3,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(7)
|
||||
particle_catchers.Add(catcher)
|
||||
catcher = new (locate(src.x,src.y-3,src.z))
|
||||
catcher.parent = src
|
||||
catcher.SetSize(7)
|
||||
particle_catchers.Add(catcher)
|
||||
|
||||
//init values
|
||||
major_radius = field_strength * 0.21875// max = 8.75
|
||||
minor_radius = field_strength * 0.2125// max = 8.625
|
||||
volume_covered = M_PI * major_radius * minor_radius * 2.5 * 2.5 * 1000
|
||||
|
||||
processing_objects.Add(src)
|
||||
|
||||
/obj/effect/rust_em_field/process()
|
||||
//make sure the field generator is still intact
|
||||
if(!owned_core)
|
||||
del(src)
|
||||
|
||||
//handle radiation
|
||||
if(!radiator)
|
||||
radiator = new /obj/machinery/rust/rad_source()
|
||||
radiator.mega_energy += radiation
|
||||
radiator.source_alive++
|
||||
radiation = 0
|
||||
|
||||
//update values
|
||||
var/transfer_ratio = field_strength / 50 //higher field strength will result in faster phoron aggregation
|
||||
major_radius = field_strength * 0.21875// max = 8.75m
|
||||
minor_radius = field_strength * 0.2125// max = 8.625m
|
||||
volume_covered = M_PI * major_radius * minor_radius * 2.5 * 2.5 * 2.5 * 7 * 7 * transfer_ratio //one tile = 2.5m*2.5m*2.5m
|
||||
|
||||
//add phoron from the surrounding environment
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
|
||||
//hack in some stuff to remove phoron from the air because SCIENCE
|
||||
//the amount of phoron pulled in each update is relative to the field strength, with 50T (max field strength) = 100% of area covered by the field
|
||||
//at minimum strength, 0.25% of the field volume is pulled in per update (?)
|
||||
//have a max of 1000 moles suspended
|
||||
if(held_phoron.gas["phoron"] < transfer_ratio * 1000)
|
||||
var/moles_covered = environment.return_pressure()*volume_covered/(environment.temperature * R_IDEAL_GAS_EQUATION)
|
||||
//world << "\blue moles_covered: [moles_covered]"
|
||||
//
|
||||
var/datum/gas_mixture/gas_covered = environment.remove(moles_covered)
|
||||
var/datum/gas_mixture/phoron_captured = new /datum/gas_mixture()
|
||||
//
|
||||
phoron_captured.gas["phoron"] = round(gas_covered.gas["phoron"] * transfer_ratio)
|
||||
//world << "\blue[phoron_captured.phoron] moles of phoron captured"
|
||||
phoron_captured.temperature = gas_covered.temperature
|
||||
phoron_captured.update_values()
|
||||
//
|
||||
gas_covered.adjust_gas("phoron", -phoron_captured.gas["phoron"])
|
||||
//
|
||||
held_phoron.merge(phoron_captured)
|
||||
//
|
||||
environment.merge(gas_covered)
|
||||
|
||||
//let the particles inside the field react
|
||||
React()
|
||||
|
||||
//forcibly radiate any excess energy
|
||||
/*var/energy_max = transfer_ratio * 100000
|
||||
if(mega_energy > energy_max)
|
||||
var/energy_lost = rand( 1.5 * (mega_energy - energy_max), 2.5 * (mega_energy - energy_max) )
|
||||
mega_energy -= energy_lost
|
||||
radiation += energy_lost*/
|
||||
|
||||
//change held phoron temp according to energy levels
|
||||
//SPECIFIC_HEAT_TOXIN
|
||||
if(mega_energy > 0 && held_phoron.gas["phoron"])
|
||||
var/heat_capacity = held_phoron.heat_capacity()//200 * number of phoron moles
|
||||
if(heat_capacity > 0.0003) //formerly MINIMUM_HEAT_CAPACITY
|
||||
held_phoron.temperature = (heat_capacity + mega_energy * 35000)/heat_capacity
|
||||
|
||||
//if there is too much phoron in the field, lose some
|
||||
/*if( held_phoron.phoron > (MOLES_CELLSTANDARD * 7) * (50 / field_strength) )
|
||||
LosePhoron()*/
|
||||
if(held_phoron.gas["phoron"] > 1)
|
||||
//lose a random amount of phoron back into the air, increased by the field strength (want to switch this over to frequency eventually)
|
||||
var/loss_ratio = rand() * (0.05 + (0.05 * 50 / field_strength))
|
||||
//world << "lost [loss_ratio*100]% of held phoron"
|
||||
//
|
||||
var/datum/gas_mixture/phoron_lost = new
|
||||
phoron_lost.temperature = held_phoron.temperature
|
||||
//
|
||||
phoron_lost.gas["phoron"] = held_phoron.gas["phoron"] * loss_ratio
|
||||
//phoron_lost.update_values()
|
||||
held_phoron.gas["phoron"] -= held_phoron.gas["phoron"] * loss_ratio
|
||||
//held_phoron.update_values()
|
||||
//
|
||||
environment.merge(phoron_lost)
|
||||
radiation += loss_ratio * mega_energy * 0.1
|
||||
mega_energy -= loss_ratio * mega_energy * 0.1
|
||||
else
|
||||
held_phoron.gas["phoron"] = null
|
||||
//held_phoron.update_values()
|
||||
|
||||
//handle some reactants formatting
|
||||
for(var/reactant in dormant_reactant_quantities)
|
||||
var/amount = dormant_reactant_quantities[reactant]
|
||||
if(amount < 1)
|
||||
dormant_reactant_quantities.Remove(reactant)
|
||||
else if(amount >= 1000000)
|
||||
var/radiate = rand(3 * amount / 4, amount / 4)
|
||||
dormant_reactant_quantities[reactant] -= radiate
|
||||
radiation += radiate
|
||||
|
||||
return 1
|
||||
|
||||
/obj/effect/rust_em_field/proc/ChangeFieldStrength(var/new_strength)
|
||||
var/calc_size = 1
|
||||
emp_overload = 0
|
||||
if(new_strength <= 50)
|
||||
calc_size = 1
|
||||
else if(new_strength <= 200)
|
||||
calc_size = 3
|
||||
else if(new_strength <= 500)
|
||||
calc_size = 5
|
||||
else
|
||||
calc_size = 7
|
||||
if(new_strength > 900)
|
||||
emp_overload = 1
|
||||
//
|
||||
field_strength = new_strength
|
||||
change_size(calc_size)
|
||||
|
||||
/obj/effect/rust_em_field/proc/ChangeFieldFrequency(var/new_frequency)
|
||||
frequency = new_frequency
|
||||
|
||||
/obj/effect/rust_em_field/proc/AddEnergy(var/a_energy, var/a_mega_energy, var/a_frequency)
|
||||
var/energy_loss_ratio = 0
|
||||
if(a_frequency != src.frequency)
|
||||
energy_loss_ratio = 1 / abs(a_frequency - src.frequency)
|
||||
energy += a_energy - a_energy * energy_loss_ratio
|
||||
mega_energy += a_mega_energy - a_mega_energy * energy_loss_ratio
|
||||
|
||||
while(energy > 100000)
|
||||
energy -= 100000
|
||||
mega_energy += 0.1
|
||||
|
||||
/obj/effect/rust_em_field/proc/AddParticles(var/name, var/quantity = 1)
|
||||
if(name in dormant_reactant_quantities)
|
||||
dormant_reactant_quantities[name] += quantity
|
||||
else if(name != "proton" && name != "electron" && name != "neutron")
|
||||
dormant_reactant_quantities.Add(name)
|
||||
dormant_reactant_quantities[name] = quantity
|
||||
|
||||
/obj/effect/rust_em_field/proc/RadiateAll(var/ratio_lost = 1)
|
||||
for(var/particle in dormant_reactant_quantities)
|
||||
radiation += dormant_reactant_quantities[particle]
|
||||
dormant_reactant_quantities.Remove(particle)
|
||||
radiation += mega_energy
|
||||
mega_energy = 0
|
||||
|
||||
//lose all held phoron back into the air
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
environment.merge(held_phoron)
|
||||
|
||||
/obj/effect/rust_em_field/proc/change_size(var/newsize = 1)
|
||||
//
|
||||
var/changed = 0
|
||||
switch(newsize)
|
||||
if(1)
|
||||
size = 1
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "emfield_s1"
|
||||
pixel_x = 0
|
||||
pixel_y = 0
|
||||
//
|
||||
changed = 1
|
||||
if(3)
|
||||
size = 3
|
||||
icon = 'icons/effects/96x96.dmi'
|
||||
icon_state = "emfield_s3"
|
||||
pixel_x = -32
|
||||
pixel_y = -32
|
||||
//
|
||||
changed = 3
|
||||
if(5)
|
||||
size = 5
|
||||
icon = 'icons/effects/160x160.dmi'
|
||||
icon_state = "emfield_s5"
|
||||
pixel_x = -64
|
||||
pixel_y = -64
|
||||
//
|
||||
changed = 5
|
||||
if(7)
|
||||
size = 7
|
||||
icon = 'icons/effects/224x224.dmi'
|
||||
icon_state = "emfield_s7"
|
||||
pixel_x = -96
|
||||
pixel_y = -96
|
||||
//
|
||||
changed = 7
|
||||
|
||||
for(var/obj/effect/rust_particle_catcher/catcher in particle_catchers)
|
||||
catcher.UpdateSize()
|
||||
return changed
|
||||
|
||||
//the !!fun!! part
|
||||
/obj/effect/rust_em_field/proc/React()
|
||||
//loop through the reactants in random order
|
||||
var/list/reactants_reacting_pool = dormant_reactant_quantities.Copy()
|
||||
/*
|
||||
for(var/reagent in dormant_reactant_quantities)
|
||||
world << " before: [reagent]: [dormant_reactant_quantities[reagent]]"
|
||||
*/
|
||||
|
||||
//cant have any reactions if there aren't any reactants present
|
||||
if(reactants_reacting_pool.len)
|
||||
//determine a random amount to actually react this cycle, and remove it from the standard pool
|
||||
//this is a hack, and quite nonrealistic :(
|
||||
for(var/reactant in reactants_reacting_pool)
|
||||
reactants_reacting_pool[reactant] = rand(0,reactants_reacting_pool[reactant])
|
||||
dormant_reactant_quantities[reactant] -= reactants_reacting_pool[reactant]
|
||||
if(!reactants_reacting_pool[reactant])
|
||||
reactants_reacting_pool -= reactant
|
||||
|
||||
//loop through all the reacting reagents, picking out random reactions for them
|
||||
var/list/produced_reactants = new/list
|
||||
var/list/primary_reactant_pool = reactants_reacting_pool.Copy()
|
||||
while(primary_reactant_pool.len)
|
||||
//pick one of the unprocessed reacting reagents randomly
|
||||
var/cur_primary_reactant = pick(primary_reactant_pool)
|
||||
primary_reactant_pool.Remove(cur_primary_reactant)
|
||||
//world << "\blue primary reactant chosen: [cur_primary_reactant]"
|
||||
|
||||
//grab all the possible reactants to have a reaction with
|
||||
var/list/possible_secondary_reactants = reactants_reacting_pool.Copy()
|
||||
//if there is only one of a particular reactant, then it can not react with itself so remove it
|
||||
possible_secondary_reactants[cur_primary_reactant] -= 1
|
||||
if(possible_secondary_reactants[cur_primary_reactant] < 1)
|
||||
possible_secondary_reactants.Remove(cur_primary_reactant)
|
||||
|
||||
//loop through and work out all the possible reactions
|
||||
var/list/possible_reactions = new/list
|
||||
for(var/cur_secondary_reactant in possible_secondary_reactants)
|
||||
if(possible_secondary_reactants[cur_secondary_reactant] < 1)
|
||||
continue
|
||||
var/datum/fusion_reaction/cur_reaction = get_fusion_reaction(cur_primary_reactant, cur_secondary_reactant)
|
||||
if(cur_reaction)
|
||||
//world << "\blue secondary reactant: [cur_secondary_reactant], [reaction_products.len]"
|
||||
possible_reactions.Add(cur_reaction)
|
||||
|
||||
//if there are no possible reactions here, abandon this primary reactant and move on
|
||||
if(!possible_reactions.len)
|
||||
//world << "\blue no reactions"
|
||||
continue
|
||||
|
||||
//split up the reacting atoms between the possible reactions
|
||||
while(possible_reactions.len)
|
||||
//pick a random substance to react with
|
||||
var/datum/fusion_reaction/cur_reaction = pick(possible_reactions)
|
||||
possible_reactions.Remove(cur_reaction)
|
||||
|
||||
//set the randmax to be the lower of the two involved reactants
|
||||
var/max_num_reactants = reactants_reacting_pool[cur_reaction.primary_reactant] > reactants_reacting_pool[cur_reaction.secondary_reactant] ? \
|
||||
reactants_reacting_pool[cur_reaction.secondary_reactant] : reactants_reacting_pool[cur_reaction.primary_reactant]
|
||||
if(max_num_reactants < 1)
|
||||
continue
|
||||
|
||||
//make sure we have enough energy
|
||||
if(mega_energy < max_num_reactants * cur_reaction.energy_consumption)
|
||||
max_num_reactants = round(mega_energy / cur_reaction.energy_consumption)
|
||||
if(max_num_reactants < 1)
|
||||
continue
|
||||
|
||||
//randomly determined amount to react
|
||||
var/amount_reacting = rand(1, max_num_reactants)
|
||||
|
||||
//removing the reacting substances from the list of substances that are primed to react this cycle
|
||||
//if there aren't enough of that substance (there should be) then modify the reactant amounts accordingly
|
||||
if( reactants_reacting_pool[cur_reaction.primary_reactant] - amount_reacting >= 0 )
|
||||
reactants_reacting_pool[cur_reaction.primary_reactant] -= amount_reacting
|
||||
else
|
||||
amount_reacting = reactants_reacting_pool[cur_reaction.primary_reactant]
|
||||
reactants_reacting_pool[cur_reaction.primary_reactant] = 0
|
||||
//same again for secondary reactant
|
||||
if( reactants_reacting_pool[cur_reaction.secondary_reactant] - amount_reacting >= 0 )
|
||||
reactants_reacting_pool[cur_reaction.secondary_reactant] -= amount_reacting
|
||||
else
|
||||
reactants_reacting_pool[cur_reaction.primary_reactant] += amount_reacting - reactants_reacting_pool[cur_reaction.primary_reactant]
|
||||
amount_reacting = reactants_reacting_pool[cur_reaction.secondary_reactant]
|
||||
reactants_reacting_pool[cur_reaction.secondary_reactant] = 0
|
||||
|
||||
//remove the consumed energy
|
||||
mega_energy -= max_num_reactants * cur_reaction.energy_consumption
|
||||
|
||||
//add any produced energy
|
||||
mega_energy += max_num_reactants * cur_reaction.energy_production
|
||||
|
||||
//add any produced radiation
|
||||
radiation += max_num_reactants * cur_reaction.radiation
|
||||
|
||||
//create the reaction products
|
||||
for(var/reactant in cur_reaction.products)
|
||||
var/success = 0
|
||||
for(var/check_reactant in produced_reactants)
|
||||
if(check_reactant == reactant)
|
||||
produced_reactants[reactant] += cur_reaction.products[reactant] * amount_reacting
|
||||
success = 1
|
||||
break
|
||||
if(!success)
|
||||
produced_reactants[reactant] = cur_reaction.products[reactant] * amount_reacting
|
||||
|
||||
//this reaction is done, and can't be repeated this sub-cycle
|
||||
possible_reactions.Remove(cur_reaction.secondary_reactant)
|
||||
|
||||
//
|
||||
/*if(new_radiation)
|
||||
if(!radiating)
|
||||
radiating = 1
|
||||
PeriodicRadiate()*/
|
||||
|
||||
//loop through the newly produced reactants and add them to the pool
|
||||
//var/list/neutronic_radiation = new
|
||||
//var/list/protonic_radiation = new
|
||||
for(var/reactant in produced_reactants)
|
||||
AddParticles(reactant, produced_reactants[reactant])
|
||||
//world << "produced: [reactant], [dormant_reactant_quantities[reactant]]"
|
||||
|
||||
//check whether there are reactants left, and add them back to the pool
|
||||
for(var/reactant in reactants_reacting_pool)
|
||||
AddParticles(reactant, reactants_reacting_pool[reactant])
|
||||
//world << "retained: [reactant], [reactants_reacting_pool[reactant]]"
|
||||
|
||||
/obj/effect/rust_em_field/Del()
|
||||
//radiate everything in one giant burst
|
||||
for(var/obj/effect/rust_particle_catcher/catcher in particle_catchers)
|
||||
del (catcher)
|
||||
RadiateAll()
|
||||
|
||||
processing_objects.Remove(src)
|
||||
..()
|
||||
@@ -0,0 +1,284 @@
|
||||
//the core [tokamaka generator] big funky solenoid, it generates an EM field
|
||||
|
||||
/*
|
||||
when the core is turned on, it generates [creates] an electromagnetic field
|
||||
the em field attracts phoron, and suspends it in a controlled torus (doughnut) shape, oscillating around the core
|
||||
|
||||
the field strength is directly controllable by the user
|
||||
field strength = sqrt(energy used by the field generator)
|
||||
|
||||
the size of the EM field = field strength / k
|
||||
(k is an arbitrary constant to make the calculated size into tilewidths)
|
||||
|
||||
1 tilewidth = below 5T
|
||||
3 tilewidth = between 5T and 12T
|
||||
5 tilewidth = between 10T and 25T
|
||||
7 tilewidth = between 20T and 50T
|
||||
(can't go higher than 40T)
|
||||
|
||||
energy is added by a gyrotron, and lost when phoron escapes
|
||||
energy transferred from the gyrotron beams is reduced by how different the frequencies are (closer frequencies = more energy transferred)
|
||||
|
||||
frequency = field strength * (stored energy / stored moles of phoron) * x
|
||||
(where x is an arbitrary constant to make the frequency something realistic)
|
||||
the gyrotron beams' frequency and energy are hardcapped low enough that they won't heat the phoron much
|
||||
|
||||
energy is generated in considerable amounts by fusion reactions from injected particles
|
||||
fusion reactions only occur when the existing energy is above a certain level, and it's near the max operating level of the gyrotron. higher energy reactions only occur at higher energy levels
|
||||
a small amount of energy constantly bleeds off in the form of radiation
|
||||
|
||||
the field is constantly pulling in phoron from the surrounding [local] atmosphere
|
||||
at random intervals, the field releases a random percentage of stored phoron in addition to a percentage of energy as intense radiation
|
||||
|
||||
the amount of phoron is a percentage of the field strength, increased by frequency
|
||||
*/
|
||||
|
||||
/*
|
||||
- VALUES -
|
||||
|
||||
max volume of phoron storeable by the field = the total volume of a number of tiles equal to the (field tilewidth)^2
|
||||
|
||||
*/
|
||||
|
||||
#define MAX_FIELD_FREQ 1000
|
||||
#define MIN_FIELD_FREQ 1
|
||||
#define MAX_FIELD_STR 1000
|
||||
#define MIN_FIELD_STR 1
|
||||
|
||||
/obj/machinery/power/rust_core
|
||||
name = "RUST Tokamak core"
|
||||
desc = "Enormous solenoid for generating extremely high power electromagnetic fields"
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "core0"
|
||||
density = 1
|
||||
var/obj/effect/rust_em_field/owned_field
|
||||
var/field_strength = 1//0.01
|
||||
var/field_frequency = 1
|
||||
var/id_tag = "allan, don't forget to set the ID of this one too"
|
||||
req_access = list(access_engine)
|
||||
//
|
||||
use_power = 1
|
||||
idle_power_usage = 50
|
||||
active_power_usage = 500 //multiplied by field strength
|
||||
var/cached_power_avail = 0
|
||||
anchored = 0
|
||||
|
||||
var/state = 0
|
||||
var/locked = 1
|
||||
var/remote_access_enabled = 1
|
||||
|
||||
/obj/machinery/power/rust_core/process()
|
||||
if(stat & BROKEN || !powernet)
|
||||
Shutdown()
|
||||
|
||||
cached_power_avail = avail()
|
||||
//luminosity = round(owned_field.field_strength/10)
|
||||
//luminosity = max(luminosity,1)
|
||||
|
||||
/obj/machinery/power/rust_core/attackby(obj/item/W, mob/user)
|
||||
|
||||
if(istype(W, /obj/item/weapon/wrench))
|
||||
if(owned_field)
|
||||
user << "Turn off [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(owned_field)
|
||||
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()
|
||||
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()
|
||||
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(owned_field)
|
||||
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
|
||||
|
||||
/obj/machinery/power/rust_core/attack_ai(mob/user)
|
||||
attack_hand(user)
|
||||
|
||||
/obj/machinery/power/rust_core/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/rust_core/interact(mob/user)
|
||||
if(stat & BROKEN)
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=core_gen")
|
||||
return
|
||||
if(!istype(user, /mob/living/silicon) && get_dist(src, user) > 1)
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=core_gen")
|
||||
return
|
||||
|
||||
var/dat = ""
|
||||
if(stat & NOPOWER || locked || state != 2)
|
||||
dat += "<i>The console is dark and nonresponsive.</i>"
|
||||
else
|
||||
dat += "<b>RUST Tokamak pattern Electromagnetic Field Generator</b><br>"
|
||||
dat += "<b>Device ID tag: </b> [id_tag ? id_tag : "UNSET"] <a href='?src=\ref[src];new_id_tag=1'>\[Modify\]</a><br>"
|
||||
dat += "<a href='?src=\ref[src];toggle_active=1'>\[[owned_field ? "Deactivate" : "Activate"]\]</a><br>"
|
||||
dat += "<a href='?src=\ref[src];toggle_remote=1'>\[[remote_access_enabled ? "Disable remote access to this device" : "Enable remote access to this device"]\]</a><br>"
|
||||
dat += "<hr>"
|
||||
dat += "<b>Field strength:</b> [field_strength]Wm^3<br>"
|
||||
dat += "<a href='?src=\ref[src];str=-1000'>\[----\]</a> \
|
||||
<a href='?src=\ref[src];str=-100'>\[--- \]</a> \
|
||||
<a href='?src=\ref[src];str=-10'>\[-- \]</a> \
|
||||
<a href='?src=\ref[src];str=-1'>\[- \]</a> \
|
||||
<a href='?src=\ref[src];str=1'>\[+ \]</a> \
|
||||
<a href='?src=\ref[src];str=10'>\[++ \]</a> \
|
||||
<a href='?src=\ref[src];str=100'>\[+++ \]</a> \
|
||||
<a href='?src=\ref[src];str=1000'>\[++++\]</a><br>"
|
||||
|
||||
dat += "<b>Field frequency:</b> [field_frequency]MHz<br>"
|
||||
dat += "<a href='?src=\ref[src];freq=-1000'>\[----\]</a> \
|
||||
<a href='?src=\ref[src];freq=-100'>\[--- \]</a> \
|
||||
<a href='?src=\ref[src];freq=-10'>\[-- \]</a> \
|
||||
<a href='?src=\ref[src];freq=-1'>\[- \]</a> \
|
||||
<a href='?src=\ref[src];freq=1'>\[+ \]</a> \
|
||||
<a href='?src=\ref[src];freq=10'>\[++ \]</a> \
|
||||
<a href='?src=\ref[src];freq=100'>\[+++ \]</a> \
|
||||
<a href='?src=\ref[src];freq=1000'>\[++++\]</a><br>"
|
||||
|
||||
var/font_colour = "green"
|
||||
if(cached_power_avail < active_power_usage)
|
||||
font_colour = "red"
|
||||
else if(cached_power_avail < active_power_usage * 2)
|
||||
font_colour = "orange"
|
||||
dat += "<b>Power status:</b> <font color=[font_colour]>[active_power_usage]/[cached_power_avail] W</font><br>"
|
||||
|
||||
user << browse(dat, "window=core_gen;size=500x300")
|
||||
onclose(user, "core_gen")
|
||||
user.set_machine(src)
|
||||
|
||||
/obj/machinery/power/rust_core/Topic(href, href_list)
|
||||
if(href_list["str"])
|
||||
var/dif = text2num(href_list["str"])
|
||||
field_strength = min(max(field_strength + dif, MIN_FIELD_STR), MAX_FIELD_STR)
|
||||
active_power_usage = 5 * field_strength //change to 500 later
|
||||
if(owned_field)
|
||||
owned_field.ChangeFieldStrength(field_strength)
|
||||
|
||||
if(href_list["freq"])
|
||||
var/dif = text2num(href_list["freq"])
|
||||
field_frequency = min(max(field_frequency + dif, MIN_FIELD_FREQ), MAX_FIELD_FREQ)
|
||||
if(owned_field)
|
||||
owned_field.ChangeFieldFrequency(field_frequency)
|
||||
|
||||
if(href_list["toggle_active"])
|
||||
if(!Startup())
|
||||
Shutdown()
|
||||
|
||||
if( href_list["toggle_remote"] )
|
||||
remote_access_enabled = !remote_access_enabled
|
||||
|
||||
if(href_list["new_id_tag"])
|
||||
if(usr)
|
||||
id_tag = input("Enter a new ID tag", "Tokamak core ID tag", id_tag) as text|null
|
||||
|
||||
if(href_list["close"])
|
||||
usr << browse(null, "window=core_gen")
|
||||
usr.unset_machine()
|
||||
|
||||
if(href_list["extern_update"])
|
||||
var/obj/machinery/computer/rust_core_control/C = locate(href_list["extern_update"])
|
||||
if(C)
|
||||
C.updateDialog()
|
||||
|
||||
src.updateDialog()
|
||||
|
||||
/obj/machinery/power/rust_core/proc/Startup()
|
||||
if(owned_field)
|
||||
return
|
||||
owned_field = new(src.loc)
|
||||
owned_field.ChangeFieldStrength(field_strength)
|
||||
owned_field.ChangeFieldFrequency(field_frequency)
|
||||
icon_state = "core1"
|
||||
luminosity = 1
|
||||
use_power = 2
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/rust_core/proc/Shutdown()
|
||||
//todo: safety checks for field status
|
||||
if(owned_field)
|
||||
icon_state = "core0"
|
||||
del(owned_field)
|
||||
luminosity = 0
|
||||
use_power = 1
|
||||
|
||||
/obj/machinery/power/rust_core/proc/AddParticles(var/name, var/quantity = 1)
|
||||
if(owned_field)
|
||||
owned_field.AddParticles(name, quantity)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/rust_core/bullet_act(var/obj/item/projectile/Proj)
|
||||
if(owned_field)
|
||||
return owned_field.bullet_act(Proj)
|
||||
return 0
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
/obj/item/weapon/fuel_assembly
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "fuel_assembly"
|
||||
name = "Fuel Rod Assembly"
|
||||
var/list/rod_quantities
|
||||
var/percent_depleted = 1
|
||||
layer = 3.1
|
||||
//
|
||||
New()
|
||||
rod_quantities = new/list
|
||||
|
||||
//these can be abstracted away for now
|
||||
/*
|
||||
/obj/item/weapon/fuel_rod
|
||||
/obj/item/weapon/control_rod
|
||||
*/
|
||||
@@ -0,0 +1,102 @@
|
||||
|
||||
|
||||
/obj/machinery/rust_fuel_assembly_port
|
||||
name = "Fuel Assembly Port"
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "port2"
|
||||
density = 0
|
||||
var/obj/item/weapon/fuel_assembly/cur_assembly
|
||||
var/busy = 0
|
||||
anchored = 1
|
||||
|
||||
var/opened = 1 //0=closed, 1=opened
|
||||
var/has_electronics = 0 // 0 - none, bit 1 - circuitboard, bit 2 - wires
|
||||
|
||||
/obj/machinery/rust_fuel_assembly_port/attackby(var/obj/item/I, var/mob/user)
|
||||
if(istype(I,/obj/item/weapon/fuel_assembly) && !opened)
|
||||
if(cur_assembly)
|
||||
user << "\red There is already a fuel rod assembly in there!"
|
||||
else
|
||||
cur_assembly = I
|
||||
user.drop_item()
|
||||
I.loc = src
|
||||
icon_state = "port1"
|
||||
user << "\blue You insert [I] into [src]. Touch the panel again to insert [I] into the injector."
|
||||
|
||||
/obj/machinery/rust_fuel_assembly_port/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
if(stat & (BROKEN|NOPOWER) || opened)
|
||||
return
|
||||
|
||||
if(cur_assembly)
|
||||
if(try_insert_assembly())
|
||||
user << "\blue \icon[src] [src] inserts it's fuel rod assembly into an injector."
|
||||
else
|
||||
if(eject_assembly())
|
||||
user << "\red \icon[src] [src] ejects it's fuel assembly. Check the fuel injector status."
|
||||
else if(try_draw_assembly())
|
||||
user << "\blue \icon[src] [src] draws a fuel rod assembly from an injector."
|
||||
else if(try_draw_assembly())
|
||||
user << "\blue \icon[src] [src] draws a fuel rod assembly from an injector."
|
||||
else
|
||||
user << "\red \icon[src] [src] was unable to draw a fuel rod assembly from an injector."
|
||||
|
||||
/obj/machinery/rust_fuel_assembly_port/proc/try_insert_assembly()
|
||||
var/success = 0
|
||||
if(cur_assembly)
|
||||
var/turf/check_turf = get_step(get_turf(src), src.dir)
|
||||
check_turf = get_step(check_turf, src.dir)
|
||||
for(var/obj/machinery/power/rust_fuel_injector/I in check_turf)
|
||||
if(I.stat & (BROKEN|NOPOWER))
|
||||
break
|
||||
if(I.cur_assembly)
|
||||
break
|
||||
if(I.state != 2)
|
||||
break
|
||||
|
||||
I.cur_assembly = cur_assembly
|
||||
cur_assembly.loc = I
|
||||
cur_assembly = null
|
||||
icon_state = "port0"
|
||||
success = 1
|
||||
|
||||
return success
|
||||
|
||||
/obj/machinery/rust_fuel_assembly_port/proc/eject_assembly()
|
||||
if(cur_assembly)
|
||||
cur_assembly.loc = src.loc//get_step(get_turf(src), src.dir)
|
||||
cur_assembly = null
|
||||
icon_state = "port0"
|
||||
return 1
|
||||
|
||||
/obj/machinery/rust_fuel_assembly_port/proc/try_draw_assembly()
|
||||
var/success = 0
|
||||
if(!cur_assembly)
|
||||
var/turf/check_turf = get_step(get_turf(src), src.dir)
|
||||
check_turf = get_step(check_turf, src.dir)
|
||||
for(var/obj/machinery/power/rust_fuel_injector/I in check_turf)
|
||||
if(I.stat & (BROKEN|NOPOWER))
|
||||
break
|
||||
if(!I.cur_assembly)
|
||||
break
|
||||
if(I.injecting)
|
||||
break
|
||||
if(I.state != 2)
|
||||
break
|
||||
|
||||
cur_assembly = I.cur_assembly
|
||||
cur_assembly.loc = src
|
||||
I.cur_assembly = null
|
||||
icon_state = "port1"
|
||||
success = 1
|
||||
break
|
||||
|
||||
return success
|
||||
|
||||
/obj/machinery/rust_fuel_assembly_port/verb/eject_assembly_verb()
|
||||
set name = "Eject assembly from port"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
eject_assembly()
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
|
||||
//frame assembly
|
||||
|
||||
/obj/item/rust_fuel_assembly_port_frame
|
||||
name = "Fuel Assembly Port frame"
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "port2"
|
||||
w_class = 4
|
||||
flags = CONDUCT
|
||||
|
||||
/obj/item/rust_fuel_assembly_port_frame/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if (istype(W, /obj/item/weapon/wrench))
|
||||
new /obj/item/stack/sheet/plasteel( get_turf(src.loc), 12 )
|
||||
del(src)
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/item/rust_fuel_assembly_port_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(usr)
|
||||
var/area/A = loc.loc
|
||||
if (!istype(loc, /turf/simulated/floor))
|
||||
usr << "\red Port cannot be placed on this spot."
|
||||
return
|
||||
if (A.requires_power == 0 || A.name == "Space")
|
||||
usr << "\red Port cannot be placed in this area."
|
||||
return
|
||||
new /obj/machinery/rust_fuel_assembly_port(loc, ndir, 1)
|
||||
del(src)
|
||||
|
||||
//construction steps
|
||||
/obj/machinery/rust_fuel_assembly_port/New(turf/loc, var/ndir, var/building=0)
|
||||
..()
|
||||
|
||||
// offset 24 pixels in direction of dir
|
||||
// this allows the APC to be embedded in a wall, yet still inside an area
|
||||
if (building)
|
||||
set_dir(ndir)
|
||||
else
|
||||
has_electronics = 3
|
||||
opened = 0
|
||||
icon_state = "port0"
|
||||
|
||||
//20% easier to read than apc code
|
||||
pixel_x = (dir & 3)? 0 : (dir == 4 ? 32 : -32)
|
||||
pixel_y = (dir & 3)? (dir ==1 ? 32 : -32) : 0
|
||||
|
||||
/obj/machinery/rust_fuel_assembly_port/attackby(obj/item/W, mob/user)
|
||||
|
||||
if (istype(user, /mob/living/silicon) && get_dist(src,user)>1)
|
||||
return src.attack_hand(user)
|
||||
if (istype(W, /obj/item/weapon/crowbar))
|
||||
if(opened)
|
||||
if(has_electronics & 1)
|
||||
playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1)
|
||||
user << "You begin removing the circuitboard" //lpeters - fixed grammar issues
|
||||
if(do_after(user, 50))
|
||||
user.visible_message(\
|
||||
"\red [user.name] has removed the circuitboard from [src.name]!",\
|
||||
"\blue You remove the circuitboard.")
|
||||
has_electronics = 0
|
||||
new /obj/item/weapon/module/rust_fuel_port(loc)
|
||||
has_electronics &= ~1
|
||||
else
|
||||
opened = 0
|
||||
icon_state = "port0"
|
||||
user << "\blue You close the maintenance cover."
|
||||
else
|
||||
if(cur_assembly)
|
||||
user << "\red You cannot open the cover while there is a fuel assembly inside."
|
||||
else
|
||||
opened = 1
|
||||
user << "\blue You open the maintenance cover."
|
||||
icon_state = "port2"
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/stack/cable_coil) && opened && !(has_electronics & 2))
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(C.amount < 10)
|
||||
user << "\red You need more wires."
|
||||
return
|
||||
user << "You start adding cables to the frame..."
|
||||
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 20) && C.amount >= 10)
|
||||
C.use(10)
|
||||
user.visible_message(\
|
||||
"\red [user.name] has added cables to the port frame!",\
|
||||
"You add cables to the port frame.")
|
||||
has_electronics &= 2
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/weapon/wirecutters) && opened && (has_electronics & 2))
|
||||
user << "You begin to cut the cables..."
|
||||
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 50))
|
||||
new /obj/item/stack/cable_coil(loc,10)
|
||||
user.visible_message(\
|
||||
"\red [user.name] cut the cabling inside the port.",\
|
||||
"You cut the cabling inside the port.")
|
||||
has_electronics &= ~2
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/weapon/module/rust_fuel_port) && opened && !(has_electronics & 1))
|
||||
user << "You trying to insert the port control board into the frame..."
|
||||
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 10))
|
||||
has_electronics &= 1
|
||||
user << "You place the port control board inside the frame."
|
||||
del(W)
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/weapon/weldingtool) && opened && !has_electronics)
|
||||
var/obj/item/weapon/weldingtool/WT = W
|
||||
if (WT.get_fuel() < 3)
|
||||
user << "\blue You need more welding fuel to complete this task."
|
||||
return
|
||||
user << "You start welding the port frame..."
|
||||
playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
|
||||
if(do_after(user, 50))
|
||||
if(!src || !WT.remove_fuel(3, user)) return
|
||||
new /obj/item/rust_fuel_assembly_port_frame(loc)
|
||||
user.visible_message(\
|
||||
"\red [src] has been cut away from the wall by [user.name].",\
|
||||
"You detached the port frame.",\
|
||||
"\red You hear welding.")
|
||||
del(src)
|
||||
return
|
||||
|
||||
..()
|
||||
@@ -0,0 +1,116 @@
|
||||
var/const/max_assembly_amount = 300
|
||||
|
||||
/obj/machinery/rust_fuel_compressor
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "fuel_compressor1"
|
||||
name = "Fuel Compressor"
|
||||
var/list/new_assembly_quantities = list("Deuterium" = 150,"Tritium" = 150,"Rodinium-6" = 0,"Stravium-7" = 0, "Pergium" = 0, "Dilithium" = 0)
|
||||
var/compressed_matter = 0
|
||||
anchored = 1
|
||||
layer = 2.9
|
||||
|
||||
var/opened = 1 //0=closed, 1=opened
|
||||
var/locked = 0
|
||||
var/has_electronics = 0 // 0 - none, bit 1 - circuitboard, bit 2 - wires
|
||||
|
||||
/obj/machinery/rust_fuel_compressor/attack_ai(mob/user)
|
||||
attack_hand(user)
|
||||
|
||||
/obj/machinery/rust_fuel_compressor/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
/*if(stat & (BROKEN|NOPOWER))
|
||||
return*/
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/rust_fuel_compressor/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if (istype(W, /obj/item/weapon/rcd_ammo))
|
||||
compressed_matter += 10
|
||||
del(W)
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/machinery/rust_fuel_compressor/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=fuelcomp")
|
||||
return
|
||||
|
||||
var/t = "<B>Reactor Fuel Rod Compressor / Assembler</B><BR>"
|
||||
t += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
if(locked)
|
||||
t += "Swipe your ID to unlock this console."
|
||||
else
|
||||
t += "Compressed matter in storage: [compressed_matter] <A href='?src=\ref[src];eject_matter=1'>\[Eject all\]</a><br>"
|
||||
t += "<A href='?src=\ref[src];activate=1'><b>Activate Fuel Synthesis</b></A><BR> (fuel assemblies require no more than [max_assembly_amount] rods).<br>"
|
||||
t += "<hr>"
|
||||
t += "- New fuel assembly constituents:- <br>"
|
||||
for(var/reagent in new_assembly_quantities)
|
||||
t += " [reagent] rods: [new_assembly_quantities[reagent]] \[<A href='?src=\ref[src];change_reagent=[reagent]'>Modify</A>\]<br>"
|
||||
t += "<hr>"
|
||||
t += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
|
||||
user << browse(t, "window=fuelcomp;size=500x300")
|
||||
user.set_machine(src)
|
||||
|
||||
//var/locked
|
||||
//var/coverlocked
|
||||
|
||||
/obj/machinery/rust_fuel_compressor/Topic(href, href_list)
|
||||
..()
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=fuelcomp")
|
||||
usr.machine = null
|
||||
|
||||
if( href_list["eject_matter"] )
|
||||
var/ejected = 0
|
||||
while(compressed_matter > 10)
|
||||
new /obj/item/weapon/rcd_ammo(get_step(get_turf(src), src.dir))
|
||||
compressed_matter -= 10
|
||||
ejected = 1
|
||||
if(ejected)
|
||||
usr << "\blue \icon[src] [src] ejects some compressed matter units."
|
||||
else
|
||||
usr << "\red \icon[src] there are no more compressed matter units in [src]."
|
||||
|
||||
if( href_list["activate"] )
|
||||
//world << "\blue New fuel rod assembly"
|
||||
var/obj/item/weapon/fuel_assembly/F = new(src)
|
||||
var/fail = 0
|
||||
var/old_matter = compressed_matter
|
||||
for(var/reagent in new_assembly_quantities)
|
||||
var/req_matter = round(new_assembly_quantities[reagent] / 30)
|
||||
//world << "[reagent] matter: [req_matter]/[compressed_matter]"
|
||||
if(req_matter <= compressed_matter)
|
||||
F.rod_quantities[reagent] = new_assembly_quantities[reagent]
|
||||
compressed_matter -= req_matter
|
||||
if(compressed_matter < 1)
|
||||
compressed_matter = 0
|
||||
else
|
||||
/*world << "bad reagent: [reagent], [req_matter > compressed_matter ? "req_matter > compressed_matter"\
|
||||
: (req_matter < compressed_matter ? "req_matter < compressed_matter" : "req_matter == compressed_matter")]"*/
|
||||
fail = 1
|
||||
break
|
||||
//world << "\blue [reagent]: new_assembly_quantities[reagent]<br>"
|
||||
if(fail)
|
||||
del(F)
|
||||
compressed_matter = old_matter
|
||||
usr << "\red \icon[src] [src] flashes red: \'Out of matter.\'"
|
||||
else
|
||||
F.loc = src.loc//get_step(get_turf(src), src.dir)
|
||||
F.percent_depleted = 0
|
||||
if(compressed_matter < 0.034)
|
||||
compressed_matter = 0
|
||||
|
||||
if( href_list["change_reagent"] )
|
||||
var/cur_reagent = href_list["change_reagent"]
|
||||
var/avail_rods = 300
|
||||
for(var/rod in new_assembly_quantities)
|
||||
avail_rods -= new_assembly_quantities[rod]
|
||||
avail_rods += new_assembly_quantities[cur_reagent]
|
||||
avail_rods = max(avail_rods, 0)
|
||||
|
||||
var/new_amount = min(input("Enter new [cur_reagent] rod amount (max [avail_rods])", "Fuel Assembly Rod Composition ([cur_reagent])") as num, avail_rods)
|
||||
new_assembly_quantities[cur_reagent] = new_amount
|
||||
|
||||
updateDialog()
|
||||
@@ -0,0 +1,160 @@
|
||||
|
||||
//frame assembly
|
||||
|
||||
/obj/item/rust_fuel_compressor_frame
|
||||
name = "Fuel Compressor frame"
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "fuel_compressor0"
|
||||
w_class = 4
|
||||
flags = CONDUCT
|
||||
|
||||
/obj/item/rust_fuel_compressor_frame/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if (istype(W, /obj/item/weapon/wrench))
|
||||
new /obj/item/stack/sheet/plasteel( get_turf(src.loc), 12 )
|
||||
del(src)
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/item/rust_fuel_compressor_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(usr)
|
||||
var/area/A = loc.loc
|
||||
if (!istype(loc, /turf/simulated/floor))
|
||||
usr << "\red Compressor cannot be placed on this spot."
|
||||
return
|
||||
if (A.requires_power == 0 || A.name == "Space")
|
||||
usr << "\red Compressor cannot be placed in this area."
|
||||
return
|
||||
new /obj/machinery/rust_fuel_assembly_port(loc, ndir, 1)
|
||||
del(src)
|
||||
|
||||
//construction steps
|
||||
/obj/machinery/rust_fuel_compressor/New(turf/loc, var/ndir, var/building=0)
|
||||
..()
|
||||
|
||||
// offset 24 pixels in direction of dir
|
||||
// this allows the APC to be embedded in a wall, yet still inside an area
|
||||
if (building)
|
||||
set_dir(ndir)
|
||||
else
|
||||
has_electronics = 3
|
||||
opened = 0
|
||||
locked = 0
|
||||
icon_state = "fuel_compressor1"
|
||||
|
||||
//20% easier to read than apc code
|
||||
pixel_x = (dir & 3)? 0 : (dir == 4 ? 32 : -32)
|
||||
pixel_y = (dir & 3)? (dir ==1 ? 32 : -32) : 0
|
||||
|
||||
/obj/machinery/rust_fuel_compressor/attackby(obj/item/W, mob/user)
|
||||
|
||||
if (istype(user, /mob/living/silicon) && get_dist(src,user)>1)
|
||||
return src.attack_hand(user)
|
||||
if (istype(W, /obj/item/weapon/crowbar))
|
||||
if(opened)
|
||||
if(has_electronics & 1)
|
||||
playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1)
|
||||
user << "You begin removing the circuitboard" //lpeters - fixed grammar issues
|
||||
if(do_after(user, 50))
|
||||
user.visible_message(\
|
||||
"\red [user.name] has removed the circuitboard from [src.name]!",\
|
||||
"\blue You remove the circuitboard board.")
|
||||
has_electronics = 0
|
||||
new /obj/item/weapon/module/rust_fuel_compressor(loc)
|
||||
has_electronics &= ~1
|
||||
else
|
||||
opened = 0
|
||||
icon_state = "fuel_compressor0"
|
||||
user << "\blue You close the maintenance cover."
|
||||
else
|
||||
if(compressed_matter > 0)
|
||||
user << "\red You cannot open the cover while there is compressed matter inside."
|
||||
else
|
||||
opened = 1
|
||||
user << "\blue You open the maintenance cover."
|
||||
icon_state = "fuel_compressor1"
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda)) // trying to unlock the interface with an ID card
|
||||
if(opened)
|
||||
user << "You must close the cover to swipe an ID card."
|
||||
else
|
||||
if(src.allowed(usr))
|
||||
locked = !locked
|
||||
user << "You [ locked ? "lock" : "unlock"] the compressor interface."
|
||||
update_icon()
|
||||
else
|
||||
user << "\red Access denied."
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/weapon/card/emag) && !emagged) // trying to unlock with an emag card
|
||||
if(opened)
|
||||
user << "You must close the cover to swipe an ID card."
|
||||
else
|
||||
flick("apc-spark", src)
|
||||
if (do_after(user,6))
|
||||
if(prob(50))
|
||||
emagged = 1
|
||||
locked = 0
|
||||
user << "You emag the port interface."
|
||||
else
|
||||
user << "You fail to [ locked ? "unlock" : "lock"] the compressor interface."
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/stack/cable_coil) && opened && !(has_electronics & 2))
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(C.amount < 10)
|
||||
user << "\red You need more wires."
|
||||
return
|
||||
user << "You start adding cables to the compressor frame..."
|
||||
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 20) && C.amount >= 10)
|
||||
C.use(10)
|
||||
user.visible_message(\
|
||||
"\red [user.name] has added cables to the compressor frame!",\
|
||||
"You add cables to the port frame.")
|
||||
has_electronics &= 2
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/weapon/wirecutters) && opened && (has_electronics & 2))
|
||||
user << "You begin to cut the cables..."
|
||||
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 50))
|
||||
new /obj/item/stack/cable_coil(loc,10)
|
||||
user.visible_message(\
|
||||
"\red [user.name] cut the cabling inside the compressor.",\
|
||||
"You cut the cabling inside the port.")
|
||||
has_electronics &= ~2
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/weapon/module/rust_fuel_compressor) && opened && !(has_electronics & 1))
|
||||
user << "You trying to insert the circuitboard into the frame..."
|
||||
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 10))
|
||||
has_electronics &= 1
|
||||
user << "You place the circuitboard inside the frame."
|
||||
del(W)
|
||||
return
|
||||
|
||||
else if (istype(W, /obj/item/weapon/weldingtool) && opened && !has_electronics)
|
||||
var/obj/item/weapon/weldingtool/WT = W
|
||||
if (WT.get_fuel() < 3)
|
||||
user << "\blue You need more welding fuel to complete this task."
|
||||
return
|
||||
user << "You start welding the compressor frame..."
|
||||
playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
|
||||
if(do_after(user, 50))
|
||||
if(!src || !WT.remove_fuel(3, user)) return
|
||||
new /obj/item/rust_fuel_assembly_port_frame(loc)
|
||||
user.visible_message(\
|
||||
"\red [src] has been cut away from the wall by [user.name].",\
|
||||
"You detached the compressor frame.",\
|
||||
"\red You hear welding.")
|
||||
del(src)
|
||||
return
|
||||
|
||||
..()
|
||||
@@ -0,0 +1,192 @@
|
||||
|
||||
/obj/machinery/computer/rust_fuel_control
|
||||
name = "RUST Fuel Injection Control"
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "fuel"
|
||||
var/list/connected_injectors = list()
|
||||
var/list/active_stages = list()
|
||||
var/list/proceeding_stages = list()
|
||||
var/list/stage_times = list()
|
||||
//var/list/stage_status
|
||||
var/announce_fueldepletion = 0
|
||||
var/announce_stageprogression = 0
|
||||
var/scan_range = 25
|
||||
var/ticks_this_stage = 0
|
||||
|
||||
/*/obj/machinery/computer/rust_fuel_control/New()
|
||||
..()
|
||||
//these are the only three stages we can accept
|
||||
//we have another console for SCRAM
|
||||
fuel_injectors = new/list
|
||||
stage_status = new/list
|
||||
|
||||
fuel_injectors.Add("One")
|
||||
fuel_injectors["One"] = new/list
|
||||
stage_status.Add("One")
|
||||
stage_status["One"] = 0
|
||||
fuel_injectors.Add("Two")
|
||||
fuel_injectors["Two"] = new/list
|
||||
stage_status.Add("Two")
|
||||
stage_status["Two"] = 0
|
||||
fuel_injectors.Add("Three")
|
||||
fuel_injectors["Three"] = new/list
|
||||
stage_status.Add("Three")
|
||||
stage_status["Three"] = 0
|
||||
fuel_injectors.Add("SCRAM")
|
||||
fuel_injectors["SCRAM"] = new/list
|
||||
stage_status.Add("SCRAM")
|
||||
stage_status["SCRAM"] = 0
|
||||
|
||||
spawn(0)
|
||||
for(var/obj/machinery/power/rust_fuel_injector/Injector in world)
|
||||
if(Injector.stage in fuel_injectors)
|
||||
var/list/targetlist = fuel_injectors[Injector.stage]
|
||||
targetlist.Add(Injector)*/
|
||||
|
||||
/obj/machinery/computer/rust_fuel_control/attack_ai(mob/user)
|
||||
attack_hand(user)
|
||||
|
||||
/obj/machinery/computer/rust_fuel_control/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/computer/rust_fuel_control/interact(mob/user)
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=fuel_control")
|
||||
return
|
||||
|
||||
if (!istype(user, /mob/living/silicon) && get_dist(src, user) > 1)
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=fuel_control")
|
||||
return
|
||||
|
||||
var/dat = "<B>Reactor Core Fuel Control</B><BR>"
|
||||
/*dat += "<b>Fuel depletion announcement:</b> "
|
||||
dat += "[announce_fueldepletion == 0 ? "Disabled" : "<a href='?src=\ref[src];announce_fueldepletion=0'>\[Disable\]</a>"] "
|
||||
dat += "[announce_fueldepletion == 1 ? "Announcing" : "<a href='?src=\ref[src];announce_fueldepletion=1'>\[Announce\]</a>"] "
|
||||
dat += "[announce_fueldepletion == 2 ? "Broadcasting" : "<a href='?src=\ref[src];announce_fueldepletion=2'>\[Broadcast\]</a>"]<br>"
|
||||
dat += "<b>Stage progression announcement:</b> "
|
||||
dat += "[announce_stageprogression == 0 ? "Disabled" : "<a href='?src=\ref[src];announce_stageprogression=0'>\[Disable\]</a>"] "
|
||||
dat += "[announce_stageprogression == 1 ? "Announcing" : "<a href='?src=\ref[src];announce_stageprogression=1'>\[Announce\]</a>"] "
|
||||
dat += "[announce_stageprogression == 2 ? "Broadcasting" : "<a href='?src=\ref[src];announce_stageprogression=2'>\[Broadcast\]</a>"]<br>"*/
|
||||
dat += "<hr>"
|
||||
|
||||
dat += "<b>Detected devices</b> <a href='?src=\ref[src];scan=1'>\[Refresh list\]</a>"
|
||||
dat += "<table border=1 width='100%'>"
|
||||
dat += "<tr>"
|
||||
dat += "<td><b>ID</b></td>"
|
||||
dat += "<td><b>Assembly</b></td>"
|
||||
dat += "<td><b>Consumption</b></td>"
|
||||
dat += "<td><b>Depletion</b></td>"
|
||||
dat += "<td><b>Duration</b></td>"
|
||||
dat += "<td><b>Next stage</b></td>"
|
||||
dat += "<td></td>"
|
||||
dat += "<td></td>"
|
||||
dat += "</tr>"
|
||||
|
||||
for(var/obj/machinery/power/rust_fuel_injector/I in connected_injectors)
|
||||
dat += "<tr>"
|
||||
dat += "<td>[I.id_tag]</td>"
|
||||
if(I.cur_assembly)
|
||||
dat += "<td><a href='?src=\ref[I];toggle_injecting=1;update_extern=\ref[src]'>\[[I.injecting ? "Halt injecting" : "Begin injecting"]\]</a></td>"
|
||||
else
|
||||
dat += "<td>None</td>"
|
||||
dat += "<td>[I.fuel_usage * 100]%</td>"
|
||||
if(I.cur_assembly)
|
||||
dat += "<td>[I.cur_assembly.percent_depleted * 100]%</td>"
|
||||
else
|
||||
dat += "<td>NA</td>"
|
||||
if(stage_times.Find(I.id_tag))
|
||||
dat += "<td>[ticks_this_stage]/[stage_times[I.id_tag]]s <a href='?src=\ref[src];stage_time=[I.id_tag]'>Modify</td>"
|
||||
else
|
||||
dat += "<td>[ticks_this_stage]s <a href='?src=\ref[src];stage_time=[I.id_tag]'>Set</td>"
|
||||
if(proceeding_stages.Find(I.id_tag))
|
||||
dat += "<td><a href='?src=\ref[src];set_next_stage=[I.id_tag]'>[proceeding_stages[I.id_tag]]</a></td>"
|
||||
else
|
||||
dat += "<td>None <a href='?src=\ref[src];set_next_stage=[I.id_tag]'>\[modify\]</a></td>"
|
||||
dat += "<td><a href='?src=\ref[src];toggle_stage=[I.id_tag]'>\[[active_stages.Find(I.id_tag) ? "Deactivate stage" : "Activate stage "] \]</a></td>"
|
||||
dat += "</tr>"
|
||||
dat += "</table>"
|
||||
|
||||
dat += "<hr>"
|
||||
dat += "<A href='?src=\ref[src];refresh=1'>Refresh</A> "
|
||||
dat += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
user << browse(dat, "window=fuel_control;size=800x400")
|
||||
user.set_machine(src)
|
||||
|
||||
/obj/machinery/computer/rust_fuel_control/Topic(href, href_list)
|
||||
..()
|
||||
|
||||
if( href_list["scan"] )
|
||||
connected_injectors = list()
|
||||
for(var/obj/machinery/power/rust_fuel_injector/I in range(scan_range, src))
|
||||
if(check_injector_status(I))
|
||||
connected_injectors.Add(I)
|
||||
|
||||
if( href_list["toggle_stage"] )
|
||||
var/cur_stage = href_list["toggle_stage"]
|
||||
if(active_stages.Find(cur_stage))
|
||||
active_stages.Remove(cur_stage)
|
||||
for(var/obj/machinery/power/rust_fuel_injector/I in connected_injectors)
|
||||
if(I.id_tag == cur_stage && check_injector_status(I))
|
||||
I.StopInjecting()
|
||||
else
|
||||
active_stages.Add(cur_stage)
|
||||
for(var/obj/machinery/power/rust_fuel_injector/I in connected_injectors)
|
||||
if(I.id_tag == cur_stage && check_injector_status(I))
|
||||
I.BeginInjecting()
|
||||
|
||||
if( href_list["cooldown"] )
|
||||
for(var/obj/machinery/power/rust_fuel_injector/I in connected_injectors)
|
||||
if(check_injector_status(I))
|
||||
I.StopInjecting()
|
||||
active_stages = list()
|
||||
|
||||
if( href_list["warmup"] )
|
||||
for(var/obj/machinery/power/rust_fuel_injector/I in connected_injectors)
|
||||
if(check_injector_status(I))
|
||||
I.BeginInjecting()
|
||||
if(!active_stages.Find(I.id_tag))
|
||||
active_stages.Add(I.id_tag)
|
||||
|
||||
if( href_list["stage_time"] )
|
||||
var/cur_stage = href_list["stage_time"]
|
||||
var/new_duration = input("Enter new stage duration in seconds", "Stage duration") as num
|
||||
if(new_duration)
|
||||
stage_times[cur_stage] = new_duration
|
||||
else if(stage_times.Find(cur_stage))
|
||||
stage_times.Remove(cur_stage)
|
||||
|
||||
if( href_list["announce_fueldepletion"] )
|
||||
announce_fueldepletion = text2num(href_list["announce_fueldepletion"])
|
||||
|
||||
if( href_list["announce_stageprogression"] )
|
||||
announce_stageprogression = text2num(href_list["announce_stageprogression"])
|
||||
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=fuel_control")
|
||||
usr.unset_machine()
|
||||
|
||||
if( href_list["set_next_stage"] )
|
||||
var/cur_stage = href_list["set_next_stage"]
|
||||
if(!proceeding_stages.Find(cur_stage))
|
||||
proceeding_stages.Add(cur_stage)
|
||||
var/next_stage = input("Enter next stage ID", "Automated stage procession") as text|null
|
||||
if(next_stage)
|
||||
proceeding_stages[cur_stage] = next_stage
|
||||
else
|
||||
proceeding_stages.Remove(cur_stage)
|
||||
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/computer/rust_fuel_control/proc/check_injector_status(var/obj/machinery/power/rust_fuel_injector/I)
|
||||
if(!I)
|
||||
return 0
|
||||
|
||||
if(I.stat & (BROKEN|NOPOWER) || !I.remote_access_enabled || !I.id_tag)
|
||||
if(connected_injectors.Find(I))
|
||||
connected_injectors.Remove(I)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
@@ -0,0 +1,307 @@
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector
|
||||
name = "Fuel Injector"
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "injector0"
|
||||
|
||||
density = 1
|
||||
anchored = 0
|
||||
var/state = 0
|
||||
var/locked = 0
|
||||
req_access = list(access_engine)
|
||||
|
||||
var/obj/item/weapon/fuel_assembly/cur_assembly
|
||||
var/fuel_usage = 0.0001 //percentage of available fuel to use per cycle
|
||||
var/id_tag = "One"
|
||||
var/injecting = 0
|
||||
var/trying_to_swap_fuel = 0
|
||||
|
||||
use_power = 1
|
||||
idle_power_usage = 10
|
||||
active_power_usage = 500
|
||||
var/remote_access_enabled = 1
|
||||
var/cached_power_avail = 0
|
||||
var/emergency_insert_ready = 0
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/process()
|
||||
if(injecting)
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
StopInjecting()
|
||||
else
|
||||
Inject()
|
||||
|
||||
cached_power_avail = avail()
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/attackby(obj/item/W, mob/user)
|
||||
|
||||
if(istype(W, /obj/item/weapon/wrench))
|
||||
if(injecting)
|
||||
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(injecting)
|
||||
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))
|
||||
src.locked = !src.locked
|
||||
user << "The controls are now [src.locked ? "locked." : "unlocked."]"
|
||||
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
|
||||
|
||||
if(istype(W, /obj/item/weapon/fuel_assembly) && !cur_assembly)
|
||||
if(emergency_insert_ready)
|
||||
cur_assembly = W
|
||||
user.drop_item()
|
||||
W.loc = src
|
||||
emergency_insert_ready = 0
|
||||
return
|
||||
|
||||
..()
|
||||
return
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/attack_ai(mob/user)
|
||||
attack_hand(user)
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/interact(mob/user)
|
||||
if(stat & BROKEN)
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=fuel_injector")
|
||||
return
|
||||
if(get_dist(src, user) > 1 )
|
||||
if (!istype(user, /mob/living/silicon))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=fuel_injector")
|
||||
return
|
||||
|
||||
var/dat = ""
|
||||
if (stat & NOPOWER || locked || state != 2)
|
||||
dat += "<i>The console is dark and nonresponsive.</i>"
|
||||
else
|
||||
dat += "<B>Reactor Core Fuel Injector</B><hr>"
|
||||
dat += "<b>Device ID tag:</b> [id_tag] <a href='?src=\ref[src];modify_tag=1'>\[Modify\]</a><br>"
|
||||
dat += "<b>Status:</b> [injecting ? "<font color=green>Active</font> <a href='?src=\ref[src];toggle_injecting=1'>\[Disable\]</a>" : "<font color=blue>Standby</font> <a href='?src=\ref[src];toggle_injecting=1'>\[Enable\]</a>"]<br>"
|
||||
dat += "<b>Fuel usage:</b> [fuel_usage*100]% <a href='?src=\ref[src];fuel_usage=1'>\[Modify\]</a><br>"
|
||||
dat += "<b>Fuel assembly port:</b> "
|
||||
dat += "<a href='?src=\ref[src];fuel_assembly=1'>\[[cur_assembly ? "Eject assembly to port" : "Draw assembly from port"]\]</a> "
|
||||
if(cur_assembly)
|
||||
dat += "<a href='?src=\ref[src];emergency_fuel_assembly=1'>\[Emergency eject\]</a><br>"
|
||||
else
|
||||
dat += "<a href='?src=\ref[src];emergency_fuel_assembly=1'>\[[emergency_insert_ready ? "Cancel emergency insertion" : "Emergency insert"]\]</a><br>"
|
||||
var/font_colour = "green"
|
||||
if(cached_power_avail < active_power_usage)
|
||||
font_colour = "red"
|
||||
else if(cached_power_avail < active_power_usage * 2)
|
||||
font_colour = "orange"
|
||||
dat += "<b>Power status:</b> <font color=[font_colour]>[active_power_usage]/[cached_power_avail] W</font><br>"
|
||||
dat += "<a href='?src=\ref[src];toggle_remote=1'>\[[remote_access_enabled ? "Disable remote access" : "Enable remote access"]\]</a><br>"
|
||||
|
||||
dat += "<hr>"
|
||||
dat += "<A href='?src=\ref[src];refresh=1'>Refresh</A> "
|
||||
dat += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
|
||||
user << browse(dat, "window=fuel_injector;size=500x300")
|
||||
onclose(user, "fuel_injector")
|
||||
user.set_machine(src)
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/Topic(href, href_list)
|
||||
..()
|
||||
|
||||
if( href_list["modify_tag"] )
|
||||
id_tag = input("Enter new ID tag", "Modifying ID tag") as text|null
|
||||
|
||||
if( href_list["fuel_assembly"] )
|
||||
attempt_fuel_swap()
|
||||
|
||||
if( href_list["emergency_fuel_assembly"] )
|
||||
if(cur_assembly)
|
||||
cur_assembly.loc = src.loc
|
||||
cur_assembly = null
|
||||
//irradiate!
|
||||
else
|
||||
emergency_insert_ready = !emergency_insert_ready
|
||||
|
||||
if( href_list["toggle_injecting"] )
|
||||
if(injecting)
|
||||
StopInjecting()
|
||||
else
|
||||
BeginInjecting()
|
||||
|
||||
if( href_list["toggle_remote"] )
|
||||
remote_access_enabled = !remote_access_enabled
|
||||
|
||||
if( href_list["fuel_usage"] )
|
||||
var/new_usage = text2num(input("Enter new fuel usage (0.01% - 100%)", "Modifying fuel usage", fuel_usage * 100))
|
||||
if(!new_usage)
|
||||
usr << "\red That's not a valid number."
|
||||
return
|
||||
new_usage = max(new_usage, 0.01)
|
||||
new_usage = min(new_usage, 100)
|
||||
fuel_usage = new_usage / 100
|
||||
active_power_usage = 500 + 1000 * fuel_usage
|
||||
|
||||
if( href_list["update_extern"] )
|
||||
var/obj/machinery/computer/rust_fuel_control/C = locate(href_list["update_extern"])
|
||||
if(C)
|
||||
C.updateDialog()
|
||||
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=fuel_injector")
|
||||
usr.unset_machine()
|
||||
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/proc/BeginInjecting()
|
||||
if(!injecting && cur_assembly)
|
||||
icon_state = "injector1"
|
||||
injecting = 1
|
||||
use_power = 1
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/proc/StopInjecting()
|
||||
if(injecting)
|
||||
injecting = 0
|
||||
icon_state = "injector0"
|
||||
use_power = 0
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/proc/Inject()
|
||||
if(!injecting)
|
||||
return
|
||||
if(cur_assembly)
|
||||
var/amount_left = 0
|
||||
for(var/reagent in cur_assembly.rod_quantities)
|
||||
//world << "checking [reagent]"
|
||||
if(cur_assembly.rod_quantities[reagent] > 0)
|
||||
//world << " rods left: [cur_assembly.rod_quantities[reagent]]"
|
||||
var/amount = cur_assembly.rod_quantities[reagent] * fuel_usage
|
||||
var/numparticles = round(amount * 1000)
|
||||
if(numparticles < 1)
|
||||
numparticles = 1
|
||||
//world << " amount: [amount]"
|
||||
//world << " numparticles: [numparticles]"
|
||||
//
|
||||
|
||||
var/obj/effect/accelerated_particle/A = new/obj/effect/accelerated_particle(get_turf(src), dir)
|
||||
A.particle_type = reagent
|
||||
A.additional_particles = numparticles - 1
|
||||
//A.target = target_field
|
||||
//
|
||||
cur_assembly.rod_quantities[reagent] -= amount
|
||||
amount_left += cur_assembly.rod_quantities[reagent]
|
||||
cur_assembly.percent_depleted = amount_left / 300
|
||||
flick("injector-emitting",src)
|
||||
else
|
||||
StopInjecting()
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/proc/attempt_fuel_swap()
|
||||
var/rev_dir = reverse_direction(dir)
|
||||
var/turf/mid = get_step(src, rev_dir)
|
||||
var/success = 0
|
||||
for(var/obj/machinery/rust_fuel_assembly_port/check_port in get_step(mid, rev_dir))
|
||||
if(cur_assembly)
|
||||
if(!check_port.cur_assembly)
|
||||
check_port.cur_assembly = cur_assembly
|
||||
cur_assembly.loc = check_port
|
||||
cur_assembly = null
|
||||
check_port.icon_state = "port1"
|
||||
success = 1
|
||||
else
|
||||
if(check_port.cur_assembly)
|
||||
cur_assembly = check_port.cur_assembly
|
||||
cur_assembly.loc = src
|
||||
check_port.cur_assembly = null
|
||||
check_port.icon_state = "port0"
|
||||
success = 1
|
||||
|
||||
break
|
||||
if(success)
|
||||
src.visible_message("\blue \icon[src] a green light flashes on [src].")
|
||||
updateDialog()
|
||||
else
|
||||
src.visible_message("\red \icon[src] a red light flashes on [src].")
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/verb/rotate_clock()
|
||||
set category = "Object"
|
||||
set name = "Rotate Generator (Clockwise)"
|
||||
set src in view(1)
|
||||
|
||||
if (usr.stat || usr.restrained() || anchored)
|
||||
return
|
||||
|
||||
src.set_dir(turn(src.dir, 90))
|
||||
|
||||
/obj/machinery/power/rust_fuel_injector/verb/rotate_anticlock()
|
||||
set category = "Object"
|
||||
set name = "Rotate Generator (Counterclockwise)"
|
||||
set src in view(1)
|
||||
|
||||
if (usr.stat || usr.restrained() || anchored)
|
||||
return
|
||||
|
||||
src.set_dir(turn(src.dir, -90))
|
||||
@@ -0,0 +1,160 @@
|
||||
|
||||
datum/fusion_reaction
|
||||
var/primary_reactant = ""
|
||||
var/secondary_reactant = ""
|
||||
var/energy_consumption = 0
|
||||
var/energy_production = 0
|
||||
var/radiation = 0
|
||||
var/list/products = list()
|
||||
|
||||
/datum/controller/game_controller/var/list/fusion_reactions
|
||||
|
||||
proc/get_fusion_reaction(var/primary_reactant, var/secondary_reactant)
|
||||
if(!master_controller.fusion_reactions)
|
||||
populate_fusion_reactions()
|
||||
if(master_controller.fusion_reactions.Find(primary_reactant))
|
||||
var/list/secondary_reactions = master_controller.fusion_reactions[primary_reactant]
|
||||
if(secondary_reactions.Find(secondary_reactant))
|
||||
return master_controller.fusion_reactions[primary_reactant][secondary_reactant]
|
||||
|
||||
proc/populate_fusion_reactions()
|
||||
if(!master_controller.fusion_reactions)
|
||||
master_controller.fusion_reactions = list()
|
||||
for(var/cur_reaction_type in typesof(/datum/fusion_reaction) - /datum/fusion_reaction)
|
||||
var/datum/fusion_reaction/cur_reaction = new cur_reaction_type()
|
||||
if(!master_controller.fusion_reactions[cur_reaction.primary_reactant])
|
||||
master_controller.fusion_reactions[cur_reaction.primary_reactant] = list()
|
||||
master_controller.fusion_reactions[cur_reaction.primary_reactant][cur_reaction.secondary_reactant] = cur_reaction
|
||||
if(!master_controller.fusion_reactions[cur_reaction.secondary_reactant])
|
||||
master_controller.fusion_reactions[cur_reaction.secondary_reactant] = list()
|
||||
master_controller.fusion_reactions[cur_reaction.secondary_reactant][cur_reaction.primary_reactant] = cur_reaction
|
||||
|
||||
//Fake elements and fake reactions, but its nicer gameplay-wise
|
||||
//Deuterium
|
||||
//Tritium
|
||||
//Uridium-3
|
||||
//Obdurium
|
||||
//Solonium
|
||||
//Rodinium-6
|
||||
//Dilithium
|
||||
//Trilithium
|
||||
//Pergium
|
||||
//Stravium-7
|
||||
|
||||
//Primary Production Reactions
|
||||
|
||||
datum/fusion_reaction/tritium_deuterium
|
||||
primary_reactant = "Tritium"
|
||||
secondary_reactant = "Deuterium"
|
||||
energy_consumption = 1
|
||||
energy_production = 5
|
||||
radiation = 0
|
||||
|
||||
//Secondary Production Reactions
|
||||
|
||||
datum/fusion_reaction/deuterium_deuterium
|
||||
primary_reactant = "Deuterium"
|
||||
secondary_reactant = "Deuterium"
|
||||
energy_consumption = 1
|
||||
energy_production = 4
|
||||
radiation = 1
|
||||
products = list("Obdurium" = 2)
|
||||
|
||||
datum/fusion_reaction/tritium_tritium
|
||||
primary_reactant = "Tritium"
|
||||
secondary_reactant = "Tritium"
|
||||
energy_consumption = 1
|
||||
energy_production = 4
|
||||
radiation = 1
|
||||
products = list("Solonium" = 2)
|
||||
|
||||
//Cleanup Reactions
|
||||
|
||||
datum/fusion_reaction/rodinium6_obdurium
|
||||
primary_reactant = "Rodinium-6"
|
||||
secondary_reactant = "Obdurium"
|
||||
energy_consumption = 1
|
||||
energy_production = 2
|
||||
radiation = 2
|
||||
|
||||
datum/fusion_reaction/rodinium6_solonium
|
||||
primary_reactant = "Rodinium-6"
|
||||
secondary_reactant = "Solonium"
|
||||
energy_consumption = 1
|
||||
energy_production = 2
|
||||
radiation = 2
|
||||
|
||||
//Breeder Reactions
|
||||
|
||||
datum/fusion_reaction/dilithium_obdurium
|
||||
primary_reactant = "Dilithium"
|
||||
secondary_reactant = "Obdurium"
|
||||
energy_consumption = 1
|
||||
energy_production = 1
|
||||
radiation = 3
|
||||
products = list("Deuterium" = 1, "Dilithium" = 1)
|
||||
|
||||
datum/fusion_reaction/dilithium_solonium
|
||||
primary_reactant = "Dilithium"
|
||||
secondary_reactant = "Solonium"
|
||||
energy_consumption = 1
|
||||
energy_production = 1
|
||||
radiation = 3
|
||||
products = list("Tritium" = 1, "Dilithium" = 1)
|
||||
|
||||
//Breeder Inhibitor Reactions
|
||||
|
||||
datum/fusion_reaction/stravium7_dilithium
|
||||
primary_reactant = "Stravium-7"
|
||||
secondary_reactant = "Dilithium"
|
||||
energy_consumption = 2
|
||||
energy_production = 1
|
||||
radiation = 4
|
||||
|
||||
//Enhanced Breeder Reactions
|
||||
|
||||
datum/fusion_reaction/trilithium_obdurium
|
||||
primary_reactant = "Trilithium"
|
||||
secondary_reactant = "Obdurium"
|
||||
energy_consumption = 1
|
||||
energy_production = 2
|
||||
radiation = 5
|
||||
products = list("Dilithium" = 1, "Trilithium" = 1, "Deuterium" = 1)
|
||||
|
||||
datum/fusion_reaction/trilithium_solonium
|
||||
primary_reactant = "Trilithium"
|
||||
secondary_reactant = "Solonium"
|
||||
energy_consumption = 1
|
||||
energy_production = 2
|
||||
radiation = 5
|
||||
products = list("Dilithium" = 1, "Trilithium" = 1, "Tritium" = 1)
|
||||
|
||||
//Control Reactions
|
||||
|
||||
datum/fusion_reaction/pergium_deuterium
|
||||
primary_reactant = "Pergium"
|
||||
secondary_reactant = "Deuterium"
|
||||
energy_consumption = 5
|
||||
energy_production = 0
|
||||
radiation = 5
|
||||
|
||||
datum/fusion_reaction/pergium_tritium
|
||||
primary_reactant = "Pergium"
|
||||
secondary_reactant = "Tritium"
|
||||
energy_consumption = 5
|
||||
energy_production = 0
|
||||
radiation = 5
|
||||
|
||||
datum/fusion_reaction/pergium_obdurium
|
||||
primary_reactant = "Pergium"
|
||||
secondary_reactant = "Obdurium"
|
||||
energy_consumption = 5
|
||||
energy_production = 0
|
||||
radiation = 5
|
||||
|
||||
datum/fusion_reaction/pergium_solonium
|
||||
primary_reactant = "Pergium"
|
||||
secondary_reactant = "Solonium"
|
||||
energy_consumption = 5
|
||||
energy_production = 0
|
||||
radiation = 5
|
||||
@@ -0,0 +1,188 @@
|
||||
|
||||
//high frequency photon (laser beam)
|
||||
/obj/item/projectile/beam/ehf_beam
|
||||
|
||||
/obj/machinery/rust/gyrotron
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "emitter-off"
|
||||
name = "Gyrotron"
|
||||
anchored = 1
|
||||
density = 0
|
||||
layer = 4
|
||||
var/frequency = 1
|
||||
var/emitting = 0
|
||||
var/rate = 10
|
||||
var/mega_energy = 0.001
|
||||
var/on = 1
|
||||
var/remoteenabled = 1
|
||||
//
|
||||
req_access = list(access_engine)
|
||||
//
|
||||
use_power = 1
|
||||
idle_power_usage = 10
|
||||
active_power_usage = 300
|
||||
|
||||
New()
|
||||
..()
|
||||
//pixel_x = (dir & 3)? 0 : (dir == 4 ? -24 : 24)
|
||||
//pixel_y = (dir & 3)? (dir ==1 ? -24 : 24) : 0
|
||||
|
||||
Topic(href, href_list)
|
||||
..()
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=gyro_monitor")
|
||||
usr.machine = null
|
||||
return
|
||||
if( href_list["modifypower"] )
|
||||
var/new_val = text2num(input("Enter new emission power level (0.001 - 0.01)", "Modifying power level (MeV)", mega_energy))
|
||||
if(!new_val)
|
||||
usr << "\red That's not a valid number."
|
||||
return
|
||||
new_val = min(new_val,0.01)
|
||||
new_val = max(new_val,0.001)
|
||||
mega_energy = new_val
|
||||
for(var/obj/machinery/computer/rust_gyrotron_controller/comp in range(25))
|
||||
comp.updateDialog()
|
||||
return
|
||||
if( href_list["modifyrate"] )
|
||||
var/new_val = text2num(input("Enter new emission rate (1 - 10)", "Modifying emission rate (sec)", rate))
|
||||
if(!new_val)
|
||||
usr << "\red That's not a valid number."
|
||||
return
|
||||
new_val = min(new_val,1)
|
||||
new_val = max(new_val,10)
|
||||
rate = new_val
|
||||
for(var/obj/machinery/computer/rust_gyrotron_controller/comp in range(25))
|
||||
comp.updateDialog()
|
||||
return
|
||||
if( href_list["modifyfreq"] )
|
||||
var/new_val = text2num(input("Enter new emission frequency (1 - 50000)", "Modifying emission frequency (GHz)", frequency))
|
||||
if(!new_val)
|
||||
usr << "\red That's not a valid number."
|
||||
return
|
||||
new_val = min(new_val,1)
|
||||
new_val = max(new_val,50000)
|
||||
frequency = new_val
|
||||
for(var/obj/machinery/computer/rust_gyrotron_controller/comp in range(25))
|
||||
comp.updateDialog()
|
||||
return
|
||||
if( href_list["activate"] )
|
||||
emitting = 1
|
||||
spawn(rate)
|
||||
Emit()
|
||||
for(var/obj/machinery/computer/rust_gyrotron_controller/comp in range(25))
|
||||
comp.updateDialog()
|
||||
return
|
||||
if( href_list["deactivate"] )
|
||||
emitting = 0
|
||||
for(var/obj/machinery/computer/rust_gyrotron_controller/comp in range(25))
|
||||
comp.updateDialog()
|
||||
return
|
||||
if( href_list["enableremote"] )
|
||||
remoteenabled = 1
|
||||
for(var/obj/machinery/computer/rust_gyrotron_controller/comp in range(25))
|
||||
comp.updateDialog()
|
||||
return
|
||||
if( href_list["disableremote"] )
|
||||
remoteenabled = 0
|
||||
for(var/obj/machinery/computer/rust_gyrotron_controller/comp in range(25))
|
||||
comp.updateDialog()
|
||||
return
|
||||
/*
|
||||
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.set_dir(src.dir)
|
||||
if(src.dir == 1)//Up
|
||||
A.yo = 20
|
||||
A.xo = 0
|
||||
else if(src.dir == 2)//Down
|
||||
A.yo = -20
|
||||
A.xo = 0
|
||||
else if(src.dir == 4)//Right
|
||||
A.yo = 0
|
||||
A.xo = 20
|
||||
else if(src.dir == 8)//Left
|
||||
A.yo = 0
|
||||
A.xo = -20
|
||||
else // Any other
|
||||
A.yo = -20
|
||||
A.xo = 0
|
||||
A.fired()
|
||||
*/
|
||||
proc/Emit()
|
||||
var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc )
|
||||
A.frequency = frequency
|
||||
A.damage = mega_energy * 500
|
||||
//
|
||||
A.icon_state = "emitter"
|
||||
playsound(src.loc, 'sound/weapons/emitter.ogg', 25, 1)
|
||||
use_power(100 * mega_energy + 500)
|
||||
/*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.set_dir(src.dir)
|
||||
if(src.dir == 1)//Up
|
||||
A.yo = 20
|
||||
A.xo = 0
|
||||
else if(src.dir == 2)//Down
|
||||
A.yo = -20
|
||||
A.xo = 0
|
||||
else if(src.dir == 4)//Right
|
||||
A.yo = 0
|
||||
A.xo = 20
|
||||
else if(src.dir == 8)//Left
|
||||
A.yo = 0
|
||||
A.xo = -20
|
||||
else // Any other
|
||||
A.yo = -20
|
||||
A.xo = 0
|
||||
A.process()
|
||||
//
|
||||
flick("emitter-active",src)
|
||||
if(emitting)
|
||||
spawn(rate)
|
||||
Emit()
|
||||
|
||||
proc/UpdateIcon()
|
||||
if(on)
|
||||
icon_state = "emitter-on"
|
||||
else
|
||||
icon_state = "emitter-off"
|
||||
|
||||
/obj/machinery/rust/gyrotron/control_panel
|
||||
icon_state = "control_panel"
|
||||
name = "Control panel"
|
||||
var/obj/machinery/rust/gyrotron/owned_gyrotron
|
||||
New()
|
||||
..()
|
||||
pixel_x = -pixel_x
|
||||
pixel_y = -pixel_y
|
||||
|
||||
interact(mob/user)
|
||||
if ( (get_dist(src, user) > 1 ) || (stat & (BROKEN|NOPOWER)) )
|
||||
if (!istype(user, /mob/living/silicon))
|
||||
user.machine = null
|
||||
user << browse(null, "window=gyro_monitor")
|
||||
return
|
||||
var/t = "<B>Free electron MASER (Gyrotron) Control Panel</B><BR>"
|
||||
if(owned_gyrotron && owned_gyrotron.on)
|
||||
t += "<font color=green>Gyrotron operational</font><br>"
|
||||
t += "Operational mode: <font color=blue>"
|
||||
if(owned_gyrotron.emitting)
|
||||
t += "Emitting</font> <a href='?src=\ref[owned_gyrotron];deactivate=1'>\[Deactivate\]</a><br>"
|
||||
else
|
||||
t += "Not emitting</font> <a href='?src=\ref[owned_gyrotron];activate=1'>\[Activate\]</a><br>"
|
||||
t += "Emission rate: [owned_gyrotron.rate] <a href='?src=\ref[owned_gyrotron];modifyrate=1'>\[Modify\]</a><br>"
|
||||
t += "Beam frequency: [owned_gyrotron.frequency] <a href='?src=\ref[owned_gyrotron];modifyfreq=1'>\[Modify\]</a><br>"
|
||||
t += "Beam power: [owned_gyrotron.mega_energy] <a href='?src=\ref[owned_gyrotron];modifypower=1'>\[Modify\]</a><br>"
|
||||
else
|
||||
t += "<b><font color=red>Gyrotron unresponsive</font></b>"
|
||||
t += "<hr>"
|
||||
t += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
user << browse(t, "window=gyro_monitor;size=500x800")
|
||||
user.machine = src
|
||||
@@ -0,0 +1,88 @@
|
||||
|
||||
/obj/machinery/computer/rust_gyrotron_controller
|
||||
name = "Gyrotron Remote Controller"
|
||||
icon = 'icons/rust.dmi'
|
||||
icon_state = "engine"
|
||||
var/updating = 1
|
||||
|
||||
New()
|
||||
..()
|
||||
|
||||
Topic(href, href_list)
|
||||
..()
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=gyrotron_controller")
|
||||
usr.machine = null
|
||||
return
|
||||
if( href_list["target"] )
|
||||
var/obj/machinery/rust/gyrotron/gyro = locate(href_list["target"])
|
||||
gyro.Topic(href, href_list)
|
||||
return
|
||||
|
||||
process()
|
||||
..()
|
||||
if(updating)
|
||||
src.updateDialog()
|
||||
|
||||
interact(mob/user)
|
||||
if ( (get_dist(src, user) > 1 ) || (stat & (BROKEN|NOPOWER)) )
|
||||
if (!istype(user, /mob/living/silicon))
|
||||
user.machine = null
|
||||
user << browse(null, "window=gyrotron_controller")
|
||||
return
|
||||
var/t = "<B>Gyrotron Remote Control Console</B><BR>"
|
||||
t += "<hr>"
|
||||
for(var/obj/machinery/rust/gyrotron/gyro in world)
|
||||
if(gyro.remoteenabled && gyro.on)
|
||||
t += "<font color=green>Gyrotron operational</font><br>"
|
||||
t += "Operational mode: <font color=blue>"
|
||||
if(gyro.emitting)
|
||||
t += "Emitting</font> <a href='?src=\ref[gyro];deactivate=1'>\[Deactivate\]</a><br>"
|
||||
else
|
||||
t += "Not emitting</font> <a href='?src=\ref[gyro];activate=1'>\[Activate\]</a><br>"
|
||||
t += "Emission rate: [gyro.rate] <a href='?src=\ref[gyro];modifyrate=1'>\[Modify\]</a><br>"
|
||||
t += "Beam frequency: [gyro.frequency] <a href='?src=\ref[gyro];modifyfreq=1'>\[Modify\]</a><br>"
|
||||
t += "Beam power: [gyro.mega_energy] <a href='?src=\ref[gyro];modifypower=1'>\[Modify\]</a><br>"
|
||||
else
|
||||
t += "<b><font color=red>Gyrotron unresponsive</font></b>"
|
||||
t += "<hr>"
|
||||
/*
|
||||
var/t = "<B>Reactor Core Fuel Control</B><BR>"
|
||||
t += "Current fuel injection stage: [active_stage]<br>"
|
||||
if(active_stage == "Cooling")
|
||||
//t += "<a href='?src=\ref[src];restart=1;'>Restart injection cycle</a><br>"
|
||||
t += "----<br>"
|
||||
else
|
||||
t += "<a href='?src=\ref[src];cooldown=1;'>Enter cooldown phase</a><br>"
|
||||
t += "Fuel depletion announcement: "
|
||||
t += "[announce_fueldepletion ? "<a href='?src=\ref[src];disable_fueldepletion=1'>Disable</a>" : "<b>Disabled</b>"] "
|
||||
t += "[announce_fueldepletion == 1 ? "<b>Announcing</b>" : "<a href='?src=\ref[src];announce_fueldepletion=1'>Announce</a>"] "
|
||||
t += "[announce_fueldepletion == 2 ? "<b>Broadcasting</b>" : "<a href='?src=\ref[src];broadcast_fueldepletion=1'>Broadcast</a>"]<br>"
|
||||
t += "Stage progression announcement: "
|
||||
t += "[announce_stageprogression ? "<a href='?src=\ref[src];disable_stageprogression=1'>Disable</a>" : "<b>Disabled</b>"] "
|
||||
t += "[announce_stageprogression == 1 ? "<b>Announcing</b>" : "<a href='?src=\ref[src];announce_stageprogression=1'>Announce</a>"] "
|
||||
t += "[announce_stageprogression == 2 ? "<b>Broadcasting</b>" : "<a href='?src=\ref[src];broadcast_stageprogression=1'>Broadcast</a>"] "
|
||||
t += "<hr>"
|
||||
t += "<table border=1><tr>"
|
||||
t += "<td><b>Injector Status</b></td>"
|
||||
t += "<td><b>Injection interval (sec)</b></td>"
|
||||
t += "<td><b>Assembly consumption per injection</b></td>"
|
||||
t += "<td><b>Fuel Assembly Port</b></td>"
|
||||
t += "<td><b>Assembly depletion percentage</b></td>"
|
||||
t += "</tr>"
|
||||
for(var/stage in fuel_injectors)
|
||||
var/list/cur_stage = fuel_injectors[stage]
|
||||
t += "<tr><td colspan=5><b>Fuel Injection Stage:</b> <font color=blue>[stage]</font> [active_stage == stage ? "<font color=green> (Currently active)</font>" : "<a href='?src=\ref[src];beginstage=[stage]'>Activate</a>"]</td></tr>"
|
||||
for(var/obj/machinery/rust/fuel_injector/Injector in cur_stage)
|
||||
t += "<tr>"
|
||||
t += "<td>[Injector.on && Injector.remote_enabled ? "<font color=green>Operational</font>" : "<font color=red>Unresponsive</font>"]</td>"
|
||||
t += "<td>[Injector.rate/10] <a href='?src=\ref[Injector];cyclerate=1'>Modify</a></td>"
|
||||
t += "<td>[Injector.fuel_usage*100]% <a href='?src=\ref[Injector];fuel_usage=1'>Modify</a></td>"
|
||||
t += "<td>[Injector.owned_assembly_port ? "[Injector.owned_assembly_port.cur_assembly ? "<font color=green>Loaded</font>": "<font color=blue>Empty</font>"]" : "<font color=red>Disconnected</font>" ]</td>"
|
||||
t += "<td>[Injector.owned_assembly_port && Injector.owned_assembly_port.cur_assembly ? "[Injector.owned_assembly_port.cur_assembly.amount_depleted*100]%" : ""]</td>"
|
||||
t += "</tr>"
|
||||
t += "</table>"
|
||||
*/
|
||||
t += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
user << browse(t, "window=gyrotron_controller;size=500x400")
|
||||
user.machine = src
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
/obj/machinery/rust/rad_source
|
||||
var/mega_energy = 0
|
||||
var/time_alive = 0
|
||||
var/source_alive = 2
|
||||
New()
|
||||
..()
|
||||
|
||||
process()
|
||||
..()
|
||||
//fade away over time
|
||||
if(source_alive > 0)
|
||||
time_alive++
|
||||
source_alive--
|
||||
else
|
||||
time_alive -= 0.1
|
||||
if(time_alive < 0)
|
||||
del(src)
|
||||
|
||||
//radiate mobs nearby here
|
||||
//
|
||||
|
||||
/*
|
||||
/obj/machinery/rust
|
||||
proc/RadiateParticle(var/energy, var/ionizing, var/dir = 0)
|
||||
if(!dir)
|
||||
RadiateParticleRand(energy, ionizing)
|
||||
var/obj/effect/accelerated_particle/particle = new
|
||||
particle.set_dir(dir)
|
||||
particle.ionizing = ionizing
|
||||
if(energy)
|
||||
particle.energy = energy
|
||||
//particle.invisibility = 2
|
||||
//
|
||||
return particle
|
||||
|
||||
proc/RadiateParticleRand(var/energy, var/ionizing)
|
||||
var/turf/target
|
||||
var/particle_range = 3 * round(energy) + rand(3,20)
|
||||
if(energy > 1)
|
||||
//for penetrating radiation
|
||||
for(var/mob/M in range(particle_range))
|
||||
var/dist_ratio = particle_range / get_dist(M, src)
|
||||
//particles are more likely to hit a person if the person is closer
|
||||
// 1/8 = 12.5% (closest)
|
||||
// 1/360 = 0.27% (furthest)
|
||||
// variation of 12.2%
|
||||
if( rand() < (0.25 + dist_ratio * 12.5) )
|
||||
target = get_turf(M)
|
||||
break
|
||||
if(!target)
|
||||
target = pick(range(particle_range))
|
||||
else
|
||||
//for slower, non-penetrating radiation
|
||||
for(var/mob/M in view(particle_range))
|
||||
var/dist_ratio = particle_range / get_dist(M, src)
|
||||
if( rand() < (0.25 + dist_ratio * 12.5) )
|
||||
target = get_turf(M)
|
||||
break
|
||||
if(!target)
|
||||
target = pick(view(particle_range))
|
||||
var/obj/effect/accelerated_particle/particle = new
|
||||
particle.target = target
|
||||
particle.ionizing = ionizing
|
||||
if(energy)
|
||||
particle.energy = energy
|
||||
//particle.invisibility = 2
|
||||
//
|
||||
return particle
|
||||
*/
|
||||
|
||||
/obj/machinery/computer/rust_radiation_monitor
|
||||
name = "Radiation Monitor"
|
||||
icon_state = "power"
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
//gimmicky hack to collect particles and direct them into the field
|
||||
/obj/effect/rust_particle_catcher
|
||||
icon = 'icons/effects/effects.dmi'
|
||||
density = 0
|
||||
anchored = 1
|
||||
layer = 4
|
||||
var/obj/effect/rust_em_field/parent
|
||||
var/mysize = 0
|
||||
|
||||
invisibility = 101
|
||||
|
||||
/*/obj/effect/rust_particle_catcher/New()
|
||||
for(var/obj/machinery/rust/em_field/field in range(6))
|
||||
parent = field
|
||||
if(!parent)
|
||||
del(src)*/
|
||||
|
||||
/obj/effect/rust_particle_catcher/process()
|
||||
if(!parent)
|
||||
del(src)
|
||||
|
||||
/obj/effect/rust_particle_catcher/proc/SetSize(var/newsize)
|
||||
name = "collector [newsize]"
|
||||
mysize = newsize
|
||||
UpdateSize()
|
||||
|
||||
/obj/effect/rust_particle_catcher/proc/AddParticles(var/name, var/quantity = 1)
|
||||
if(parent && parent.size >= mysize)
|
||||
parent.AddParticles(name, quantity)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/effect/rust_particle_catcher/proc/UpdateSize()
|
||||
if(parent.size >= mysize)
|
||||
density = 1
|
||||
//invisibility = 0
|
||||
name = "collector [mysize] ON"
|
||||
else
|
||||
density = 0
|
||||
//invisibility = 101
|
||||
name = "collector [mysize] OFF"
|
||||
|
||||
/obj/effect/rust_particle_catcher/bullet_act(var/obj/item/projectile/Proj)
|
||||
if(Proj.flag != "bullet" && parent)
|
||||
parent.AddEnergy(Proj.damage * 20, 0, 1)
|
||||
update_icon()
|
||||
return 0
|
||||
|
||||
/obj/effect/rust_particle_catcher/Bumped(atom/AM)
|
||||
if(ismob(AM) && density && prob(10))
|
||||
AM << "\red A powerful force pushes you back."
|
||||
..()
|
||||
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
********** POWERNET SENSOR **********
|
||||
- Simple machine which detects power levels in cables under it.
|
||||
- Used with power_monitor.dm to measure power levels around station.
|
||||
- Can have ID tag for organisation purposes.
|
||||
*/
|
||||
// POWERNET SENSOR
|
||||
//
|
||||
// Last Change 31.12.2014 by Atlantis
|
||||
//
|
||||
// Powernet sensors are devices which relay information about connected powernet. This information may be relayed
|
||||
// via two procs. Proc return_reading_text will return fully HTML styled string which contains all information. This
|
||||
// may be used in PDAs or similar applications. Second proc, return_reading_data will return list containing needed data.
|
||||
// This is used in NanoUI, for example.
|
||||
|
||||
/obj/machinery/power/sensor
|
||||
name = "Powernet Sensor"
|
||||
@@ -17,31 +19,91 @@
|
||||
var/name_tag = "#UNKN#" // ID tag displayed in list of powernet sensors. Each sensor should have it's own tag!
|
||||
var/long_range = 0 // If 1, sensor reading will show on all computers, regardless of Zlevel
|
||||
|
||||
// Proc: New()
|
||||
// Parameters: None
|
||||
// Description: Automatically assigns name according to ID tag.
|
||||
/obj/machinery/power/sensor/New()
|
||||
..()
|
||||
name = "[name_tag] - Powernet Sensor" // Auto-name according to name_tag
|
||||
auto_set_name()
|
||||
|
||||
/obj/machinery/power/sensor/proc/RefreshGrid()
|
||||
// Proc: auto_set_name()
|
||||
// Parameters: None
|
||||
// Description: Sets name of this sensor according to the ID tag.
|
||||
/obj/machinery/power/sensor/proc/auto_set_name()
|
||||
name = "[name_tag] - Powernet Sensor"
|
||||
|
||||
// Proc: check_grid_warning()
|
||||
// Parameters: None
|
||||
// Description: Checks connected powernet for warnings. If warning is found returns 1
|
||||
/obj/machinery/power/sensor/proc/check_grid_warning()
|
||||
connect_to_network()
|
||||
if(powernet)
|
||||
if(powernet.problem)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/sensor/proc/ReturnReading()
|
||||
var/out = ""
|
||||
RefreshGrid() // First try to refresh the grid.
|
||||
if(!powernet) // No powernet.
|
||||
out = "# SYSTEM ERROR - NO POWERNET #"
|
||||
return out
|
||||
// Proc: process()
|
||||
// Parameters: None
|
||||
// Description: This has to be here because we need sensors to remain in Machines list.
|
||||
/obj/machinery/power/sensor/process()
|
||||
return 1
|
||||
|
||||
// Proc: reading_to_text()
|
||||
// Parameters: 1 (amount - Power in Watts to be converted to W, kW or MW)
|
||||
// Description: Helper proc that converts reading in Watts to kW or MW (returns string version of amount parameter)
|
||||
/obj/machinery/power/sensor/proc/reading_to_text(var/amount = 0)
|
||||
var/units = ""
|
||||
// 10kW and less - Watts
|
||||
if(amount < 10000)
|
||||
units = "W"
|
||||
// 10MW and less - KiloWatts
|
||||
else if(amount < 10000000)
|
||||
units = "kW"
|
||||
amount = (round(amount/100) / 10)
|
||||
// More than 10MW - MegaWatts
|
||||
else
|
||||
units = "MW"
|
||||
amount = (round(amount/10000) / 100)
|
||||
if (units == "W")
|
||||
return "[amount] W"
|
||||
else
|
||||
return "~[amount] [units]" //kW and MW are only approximate readings, therefore add "~"
|
||||
|
||||
// Proc: find_apcs()
|
||||
// Parameters: None
|
||||
// Description: Searches powernet for APCs and returns them in a list.
|
||||
/obj/machinery/power/sensor/proc/find_apcs()
|
||||
if(!powernet)
|
||||
return
|
||||
|
||||
// Attempt to locate APCs in powernet
|
||||
var/list/L = list()
|
||||
for(var/obj/machinery/power/terminal/term in powernet.nodes)
|
||||
if(istype(term.master, /obj/machinery/power/apc))
|
||||
var/obj/machinery/power/apc/A = term.master
|
||||
L += A
|
||||
|
||||
return L
|
||||
|
||||
|
||||
// Proc: return_reading_text()
|
||||
// Parameters: None
|
||||
// Description: Generates string which contains HTML table with reading data.
|
||||
/obj/machinery/power/sensor/proc/return_reading_text()
|
||||
// No powernet. Try to connect to one first.
|
||||
if(!powernet)
|
||||
connect_to_network()
|
||||
var/out = ""
|
||||
if(!powernet) // No powernet.
|
||||
out = "# SYSTEM ERROR - NO POWERNET #"
|
||||
return out
|
||||
|
||||
|
||||
var/list/L = find_apcs()
|
||||
var/total_apc_load = 0
|
||||
if(L.len <= 0) // No APCs found.
|
||||
out = "<b>No APCs located in connected powernet!</b>"
|
||||
else // APCs found. Create very ugly (but working!) HTML table.
|
||||
var/total_load = 0
|
||||
|
||||
out += "<table><tr><th>Name<th>EQUIP<th>LIGHT<th>ENVIRON<th>CELL<th>LOAD"
|
||||
|
||||
// These lists are used as replacement for number based APC settings
|
||||
@@ -57,38 +119,75 @@
|
||||
else
|
||||
out += "<td>NO CELL"
|
||||
var/load = A.lastused_total // Load.
|
||||
total_load += load
|
||||
if(load > 1000)
|
||||
load = "~[round(load/100)/10]kW" // If above 1000W convert to Kilowatts.
|
||||
else
|
||||
load = "[round(load)]W" // Below 1000W, leave it in Watts
|
||||
out += "<td>[load]" // Add load info
|
||||
total_apc_load += load
|
||||
load = reading_to_text(load)
|
||||
out += "<td>[load]"
|
||||
|
||||
if (total_load > 1000)
|
||||
total_load = "~[round(total_load/100)/10] kW"
|
||||
else
|
||||
total_load = "[round(total_load)] W"
|
||||
|
||||
out += "</table><br><b>TOTAL GRID LOAD: [total_load]</b>"
|
||||
|
||||
var/textavail = powernet.avail
|
||||
if(textavail > 1000)
|
||||
textavail = "[round(textavail/100)/10] kW"
|
||||
else
|
||||
textavail = "[textavail] W"
|
||||
out += "<br><b>TOTAL AVAILABLE: [textavail]</b>"
|
||||
out += "<br><b>TOTAL AVAILABLE: [reading_to_text(powernet.avail)]</b>"
|
||||
out += "<br><b>APC LOAD: [reading_to_text(total_apc_load)]</b>"
|
||||
out += "<br><b>OTHER LOAD: [reading_to_text(max(powernet.load - total_apc_load, 0))]</b>"
|
||||
out += "<br><b>TOTAL GRID LOAD: [reading_to_text(powernet.viewload)] ([round((powernet.load / powernet.avail) * 100)]%)</b>"
|
||||
|
||||
if(powernet.problem)
|
||||
out += "<br><b>WARNING: Abnormal grid activity detected!</b>"
|
||||
return out
|
||||
|
||||
/obj/machinery/power/sensor/proc/check_grid_warning()
|
||||
RefreshGrid()
|
||||
if(powernet)
|
||||
if(powernet.problem)
|
||||
return 1
|
||||
return 0
|
||||
// Proc: return_reading_data()
|
||||
// Parameters: None
|
||||
// Description: Generates list containing all powernet data. Optimised for usage with NanoUI
|
||||
/obj/machinery/power/sensor/proc/return_reading_data()
|
||||
// No powernet. Try to connect to one first.
|
||||
if(!powernet)
|
||||
connect_to_network()
|
||||
var/list/data = list()
|
||||
data["name"] = name_tag
|
||||
if(!powernet)
|
||||
data["error"] = "# SYSTEM ERROR - NO POWERNET #"
|
||||
data["alarm"] = 0 // Runtime Prevention
|
||||
return data
|
||||
|
||||
var/list/L = find_apcs()
|
||||
var/total_apc_load = 0
|
||||
var/list/APC_data = list()
|
||||
if(L.len > 0)
|
||||
// These lists are used as replacement for number based APC settings
|
||||
var/list/S = list("M-OFF","A-OFF","M-ON", "A-ON")
|
||||
var/list/chg = list("N","C","F")
|
||||
|
||||
for(var/obj/machinery/power/apc/A in L)
|
||||
var/list/APC_entry = list()
|
||||
// Channel Statuses
|
||||
APC_entry["s_equipment"] = S[A.equipment+1]
|
||||
APC_entry["s_lighting"] = S[A.lighting+1]
|
||||
APC_entry["s_environment"] = S[A.environ+1]
|
||||
// Cell Status
|
||||
APC_entry["cell_charge"] = A.cell ? round(A.cell.percent()) : "NO CELL"
|
||||
APC_entry["cell_status"] = A.cell ? chg[A.charging+1] : "N"
|
||||
// Other info
|
||||
APC_entry["total_load"] = reading_to_text(A.lastused_total)
|
||||
// Hopefully removes those goddamn \improper s which are screwing up the UI
|
||||
var/N = A.area.name
|
||||
if(findtext(N, "ÿ"))
|
||||
N = copytext(N, 3)
|
||||
APC_entry["name"] = N
|
||||
// Add data into main list of APC data.
|
||||
APC_data += list(APC_entry)
|
||||
// Add load of this APC to total APC load calculation
|
||||
total_apc_load += A.lastused_total
|
||||
data["apc_data"] = APC_data
|
||||
data["total_avail"] = reading_to_text(max(powernet.avail, 0))
|
||||
data["total_used_apc"] = reading_to_text(max(total_apc_load, 0))
|
||||
data["total_used_other"] = reading_to_text(max(powernet.viewload - total_apc_load, 0))
|
||||
data["total_used_all"] = reading_to_text(max(powernet.viewload, 0))
|
||||
// Prevents runtimes when avail is 0 (division by zero)
|
||||
if(powernet.avail)
|
||||
data["load_percentage"] = round((powernet.viewload / powernet.avail) * 100)
|
||||
else
|
||||
data["load_percentage"] = 100
|
||||
data["alarm"] = powernet.problem ? 1 : 0
|
||||
return data
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Has to be here as we need it to be in Machines list.
|
||||
/obj/machinery/power/sensor/process()
|
||||
return 1
|
||||
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
********** SENSOR MONITOR **********
|
||||
- Remotely monitors sensors around the station and displays their readings.
|
||||
- Should filter out most duplicities.
|
||||
*/
|
||||
// POWERNET SENSOR MONITORING CONSOLE
|
||||
//
|
||||
// Last Change 31.12.2014 by Atlantis
|
||||
//
|
||||
// Connects to powernet sensors and loads data from them. Shows this data to the user.
|
||||
// Newly supports NanoUI.
|
||||
|
||||
|
||||
/obj/machinery/computer/power_monitor
|
||||
name = "Power Monitoring Console"
|
||||
@@ -14,193 +16,111 @@
|
||||
density = 1
|
||||
anchored = 1.0
|
||||
circuit = /obj/item/weapon/circuitboard/powermonitor
|
||||
var/list/grid_sensors = null
|
||||
var/list/sensors_by_powernet = null
|
||||
var/update_counter = 0 // Next icon update when this reaches 5 (ie every 5 ticks)
|
||||
var/list/grid_sensors
|
||||
var/alerting = 0
|
||||
var/active_sensor = null //name_tag of the currently selected sensor
|
||||
use_power = 1
|
||||
idle_power_usage = 300
|
||||
active_power_usage = 300
|
||||
|
||||
// Update icon every 5 ticks.
|
||||
// Proc: process()
|
||||
// Parameters: None
|
||||
// Description: Checks the sensors for alerts. If change (alerts cleared or detected) occurs, calls for icon update.
|
||||
/obj/machinery/computer/power_monitor/process()
|
||||
update_counter++
|
||||
if(update_counter > 4)
|
||||
var/alert = check_warnings()
|
||||
if(alert != alerting)
|
||||
alerting = !alerting
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/computer/power_monitor/New()
|
||||
..()
|
||||
refresh_sensors()
|
||||
|
||||
|
||||
/obj/machinery/computer/power_monitor/proc/refresh_sensors()
|
||||
grid_sensors = list()
|
||||
sensors_by_powernet = list()
|
||||
for(var/obj/machinery/power/sensor/S in machines)
|
||||
if((S.loc.z == src.loc.z) || (S.long_range)) // Consoles have range on their Z-Level. Sensors with long_range var will work between Z levels.
|
||||
if(S.name_tag == "#UNKN#") // Default name. Shouldn't happen!
|
||||
error("Powernet sensor with unset ID Tag! [S.x]X [S.y]Y [S.z]Z")
|
||||
else
|
||||
grid_sensors[S.name_tag] = S
|
||||
|
||||
var/pnet = (S.powernet)? S.powernet : "none"
|
||||
if (pnet in sensors_by_powernet)
|
||||
sensors_by_powernet[pnet] += S
|
||||
else
|
||||
sensors_by_powernet[pnet] = list(S)
|
||||
|
||||
|
||||
/obj/machinery/computer/power_monitor/attack_ai(mob/user)
|
||||
add_fingerprint(user)
|
||||
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/computer/power_monitor/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/computer/power_monitor/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=powcomp")
|
||||
return
|
||||
|
||||
refresh_sensors()
|
||||
|
||||
user.set_machine(src)
|
||||
var/t = "<TT><B>Station Power Monitoring</B><HR>"
|
||||
if(active_sensor)
|
||||
|
||||
t += "<BR><A href='?src=\ref[src];update=1'>Refresh</A>"
|
||||
t += "<BR><A href='?src=\ref[src];clear=1'>Sensor List</A>"
|
||||
t += "<BR><A href='?src=\ref[src];close=1'>Close</A><BR><HR>"
|
||||
|
||||
if(!grid_sensors)
|
||||
t += "No sensors available."
|
||||
else
|
||||
if (active_sensor in grid_sensors)
|
||||
var/obj/machinery/power/sensor/OKS = grid_sensors[active_sensor]
|
||||
t += "<B>[OKS.name_tag] - Sensor Reading</B><BR>"
|
||||
t += OKS.ReturnReading()
|
||||
else
|
||||
t += "Unable to connect to sensor!"
|
||||
|
||||
|
||||
else
|
||||
t += "<BR><A href='?src=\ref[src];update=1'>Refresh</A>"
|
||||
t += "<BR><A href='?src=\ref[src];close=1'>Close</A><BR><HR>"
|
||||
|
||||
t += render_sensor_list()
|
||||
|
||||
user << browse(t, "window=powcomp;size=600x900")
|
||||
onclose(user, "powcomp")
|
||||
|
||||
/obj/machinery/computer/power_monitor/proc/render_sensor_list()
|
||||
if((!grid_sensors) || (!grid_sensors.len))
|
||||
return "<B>ERROR - No Active Sensors Detected!</B>"
|
||||
|
||||
var/html = "<table border='0'><tr><th>Power Network</th><th>Sensors</th></tr>"
|
||||
for (var/pnet in sensors_by_powernet)
|
||||
if (pnet && pnet != "none")
|
||||
html += "<tr><td valign='top'>[uppertext("\ref[pnet]")]</td><td>"
|
||||
for(var/obj/machinery/power/sensor/S in sensors_by_powernet[pnet])
|
||||
//really, if one of them has a warning, they all should - but the interface doesn't guarantee that so whatever
|
||||
if(S.check_grid_warning()) // Display grids with active alarms in bold text
|
||||
html += "<B><A href='?src=\ref[src];setsensor=[S.name_tag]'>[S.name]</A></B><BR>"
|
||||
else
|
||||
html += "<A href='?src=\ref[src];setsensor=[S.name_tag]'>[S.name]</A><BR>"
|
||||
html += "</td></tr>"
|
||||
|
||||
if ("none" in sensors_by_powernet)
|
||||
html += "<tr><td>\[N/A\]</td><td>"
|
||||
for(var/obj/machinery/power/sensor/S in sensors_by_powernet["none"])
|
||||
html += "<A href='?src=\ref[src];setsensor=[S.name_tag]'>[S.name]</A><BR>"
|
||||
html += "</td></tr>"
|
||||
html += "</table>"
|
||||
|
||||
return html
|
||||
|
||||
/obj/machinery/computer/power_monitor/Topic(href, href_list)
|
||||
..()
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=powcomp")
|
||||
usr.unset_machine()
|
||||
return
|
||||
if( href_list["update"] )
|
||||
src.updateDialog()
|
||||
return
|
||||
if( href_list["clear"] )
|
||||
active_sensor = null
|
||||
src.updateDialog()
|
||||
return
|
||||
if( href_list["setsensor"] )
|
||||
active_sensor = href_list["setsensor"]
|
||||
src.updateDialog()
|
||||
|
||||
// Proc: update_icon()
|
||||
// Parameters: None
|
||||
// Description: Updates icon of this computer according to current status.
|
||||
/obj/machinery/computer/power_monitor/update_icon()
|
||||
update_counter = 0 // Reset the icon update counter.
|
||||
if(stat & BROKEN)
|
||||
icon_state = "powerb"
|
||||
return
|
||||
if(stat & NOPOWER)
|
||||
icon_state = "power0"
|
||||
return
|
||||
if(check_warnings())
|
||||
if(alerting)
|
||||
icon_state = "power_alert"
|
||||
return
|
||||
|
||||
icon_state = "power"
|
||||
|
||||
/obj/machinery/computer/power_monitor/proc/check_warnings()
|
||||
var/warn = 0
|
||||
if(grid_sensors)
|
||||
for(var/obj/machinery/power/sensor/S in grid_sensors)
|
||||
if(S.check_grid_warning())
|
||||
warn = 1
|
||||
return warn
|
||||
|
||||
|
||||
/obj/machinery/computer/power_monitor/power_change()
|
||||
// Proc: New()
|
||||
// Parameters: None
|
||||
// Description: On creation automatically connects to active sensors. This is delayed to ensure sensors already exist.
|
||||
/obj/machinery/computer/power_monitor/New()
|
||||
..()
|
||||
spawn(50)
|
||||
refresh_sensors()
|
||||
|
||||
// Leaving this here to preserve that delayed shutdown effect when power goes out.
|
||||
if (stat & NOPOWER)
|
||||
spawn(rand(0, 15))
|
||||
update_icon()
|
||||
else
|
||||
update_icon()
|
||||
|
||||
/*
|
||||
//copied from computer.dm
|
||||
/obj/machinery/power/monitor/attackby(I as obj, user as mob)
|
||||
if(istype(I, /obj/item/weapon/screwdriver) && circuit)
|
||||
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
|
||||
if(do_after(user, 20))
|
||||
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
|
||||
var/obj/item/weapon/circuitboard/M = new circuit( A )
|
||||
A.circuit = M
|
||||
A.anchored = 1
|
||||
for (var/obj/C in src)
|
||||
C.loc = src.loc
|
||||
if (src.stat & BROKEN)
|
||||
user << "\blue The broken glass falls out."
|
||||
new /obj/item/weapon/shard( src.loc )
|
||||
A.state = 3
|
||||
A.icon_state = "3"
|
||||
// Proc: refresh_sensors()
|
||||
// Parameters: None
|
||||
// Description: Refreshes list of active sensors kept on this computer.
|
||||
/obj/machinery/computer/power_monitor/proc/refresh_sensors()
|
||||
grid_sensors = list()
|
||||
for(var/obj/machinery/power/sensor/S in machines)
|
||||
if((S.loc.z == src.loc.z) || (S.long_range)) // Consoles have range on their Z-Level. Sensors with long_range var will work between Z levels.
|
||||
if(S.name_tag == "#UNKN#") // Default name. Shouldn't happen!
|
||||
warning("Powernet sensor with unset ID Tag! [S.x]X [S.y]Y [S.z]Z")
|
||||
else
|
||||
user << "\blue You disconnect the monitor."
|
||||
A.state = 4
|
||||
A.icon_state = "4"
|
||||
M.deconstruct(src)
|
||||
del(src)
|
||||
else
|
||||
src.attack_hand(user)
|
||||
return
|
||||
*/
|
||||
grid_sensors += S
|
||||
|
||||
// Proc: attack_hand()
|
||||
// Parameters: None
|
||||
// Description: On user click opens the UI of this computer.
|
||||
/obj/machinery/computer/power_monitor/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
return
|
||||
ui_interact(user)
|
||||
|
||||
// Proc: Topic()
|
||||
// Parameters: 2 (href, href_list - allows us to process UI clicks)
|
||||
// Description: Allows us to process UI clicks, which are relayed in form of hrefs.
|
||||
/obj/machinery/computer/power_monitor/Topic(href, href_list)
|
||||
..()
|
||||
if( href_list["clear"] )
|
||||
active_sensor = null
|
||||
else if( href_list["setsensor"] )
|
||||
active_sensor = href_list["setsensor"]
|
||||
|
||||
// Proc: check_warnings()
|
||||
// Parameters: None
|
||||
// Description: Verifies if any warnings were registered by connected sensors.
|
||||
/obj/machinery/computer/power_monitor/proc/check_warnings()
|
||||
for(var/obj/machinery/power/sensor/S in grid_sensors)
|
||||
if(S.check_grid_warning())
|
||||
return 1
|
||||
return 0
|
||||
|
||||
// Proc: ui_interact()
|
||||
// Parameters: 4 (standard NanoUI parameters)
|
||||
// Description: Uses dark magic to operate the NanoUI of this computer.
|
||||
/obj/machinery/computer/power_monitor/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
var/list/data = list()
|
||||
var/list/sensors = list()
|
||||
// Focus: If it remains null if no sensor is selected and UI will display sensor list, otherwise it will display sensor reading.
|
||||
var/obj/machinery/power/sensor/focus = null
|
||||
|
||||
// Build list of data from sensor readings.
|
||||
for(var/obj/machinery/power/sensor/S in grid_sensors)
|
||||
sensors.Add(list(list(
|
||||
"name" = S.name_tag,
|
||||
"alarm" = S.check_grid_warning()
|
||||
)))
|
||||
if(S.name_tag == active_sensor)
|
||||
focus = S
|
||||
|
||||
data["all_sensors"] = sensors
|
||||
if(focus)
|
||||
data["focus"] = focus.return_reading_data()
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "power_monitor.tmpl", "Power Monitoring Console", 800, 500)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
@@ -1,4 +1,4 @@
|
||||
/area/engine/engineering/poweralert(var/state, var/source)
|
||||
/area/engineering/poweralert(var/state, var/source)
|
||||
if (state != poweralm)
|
||||
investigate_log("has a power alarm!","singulo")
|
||||
..()
|
||||
@@ -206,8 +206,6 @@ var/global/list/uneatable = list(
|
||||
|
||||
/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)
|
||||
@@ -226,9 +224,6 @@ var/global/list/uneatable = list(
|
||||
// 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
|
||||
|
||||
|
||||
@@ -567,11 +562,7 @@ var/global/list/uneatable = list(
|
||||
|
||||
/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
|
||||
|
||||
+17
-17
@@ -1,6 +1,7 @@
|
||||
// the SMES
|
||||
// stores power
|
||||
|
||||
#define SMESRATE 0.05
|
||||
#define SMESMAXCHARGELEVEL 250000
|
||||
#define SMESMAXOUTPUT 250000
|
||||
|
||||
@@ -43,22 +44,15 @@
|
||||
var/obj/machinery/power/terminal/terminal = null
|
||||
var/should_be_mapped = 0 // If this is set to 0 it will send out warning on New()
|
||||
|
||||
/obj/machinery/power/smes/drain_power(var/drain_check)
|
||||
/obj/machinery/power/smes/drain_power(var/drain_check, var/surge, var/amount = 0)
|
||||
|
||||
if(drain_check)
|
||||
return 1
|
||||
|
||||
if(!charge)
|
||||
return 0
|
||||
var/smes_amt = min((amount * SMESRATE), charge)
|
||||
charge -= smes_amt
|
||||
return smes_amt / SMESRATE
|
||||
|
||||
if(charge)
|
||||
var/drained_power = rand(200,400)
|
||||
if(charge < drained_power)
|
||||
drained_power = charge
|
||||
charge -= drained_power
|
||||
return drained_power
|
||||
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/smes/New()
|
||||
..()
|
||||
@@ -112,9 +106,6 @@
|
||||
/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
|
||||
|
||||
@@ -227,6 +218,8 @@
|
||||
add_fingerprint(user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/smes/attack_ghost(mob/user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/smes/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
@@ -310,6 +303,13 @@
|
||||
data["outputMax"] = output_level_max
|
||||
data["outputLoad"] = round(output_used)
|
||||
|
||||
if(outputting)
|
||||
data["outputting"] = 2 // smes is outputting
|
||||
else if(!outputting && output_attempt)
|
||||
data["outputting"] = 1 // smes is online but not outputting because it's charge level is too low
|
||||
else
|
||||
data["outputting"] = 0 // smes is not outputting
|
||||
|
||||
// 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, force_open)
|
||||
if (!ui)
|
||||
@@ -331,11 +331,11 @@
|
||||
return 1
|
||||
|
||||
if( href_list["cmode"] )
|
||||
inputting(!inputting)
|
||||
inputting(!input_attempt)
|
||||
update_icon()
|
||||
|
||||
else if( href_list["online"] )
|
||||
outputting(!outputting)
|
||||
outputting(!output_attempt)
|
||||
update_icon()
|
||||
else if( href_list["input"] )
|
||||
switch( href_list["input"] )
|
||||
@@ -420,4 +420,4 @@
|
||||
|
||||
/obj/machinery/power/smes/magical/process()
|
||||
charge = 5000000
|
||||
..()
|
||||
..()
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
// Constructable SMES version (based on SMES Coils)
|
||||
// BUILDABLE SMES(Superconducting Magnetic Energy Storage) UNIT
|
||||
//
|
||||
// Last Change 1.1.2015 by Atlantis - Happy New Year!
|
||||
//
|
||||
// This is subtype of SMES that should be normally used. It can be constructed, deconstructed and hacked.
|
||||
// It also supports RCON System which allows you to operate it remotely, if properly set.
|
||||
|
||||
//Construction Items
|
||||
//Construction Item
|
||||
/obj/item/weapon/smes_coil
|
||||
name = "superconductive magnetic coil"
|
||||
desc = "Heavy duty superconductive magnetic coil, mainly used in construction of SMES units."
|
||||
@@ -23,6 +28,10 @@
|
||||
charge = 0
|
||||
should_be_mapped = 1
|
||||
|
||||
// Proc: process()
|
||||
// Parameters: None
|
||||
// Description: Uses parent process, but if grounding wire is cut causes sparks to fly around.
|
||||
// This also causes the SMES to quickly discharge, and has small chance of damaging output APCs.
|
||||
/obj/machinery/power/smes/buildable/process()
|
||||
if(!grounding && (Percentage() > 5))
|
||||
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
||||
@@ -34,13 +43,18 @@
|
||||
|
||||
..()
|
||||
|
||||
|
||||
// Proc: attack_ai()
|
||||
// Parameters: None
|
||||
// Description: AI requires the RCON wire to be intact to operate the SMES.
|
||||
/obj/machinery/power/smes/buildable/attack_ai()
|
||||
if(RCon)
|
||||
..()
|
||||
else // RCON wire cut
|
||||
usr << "<span class='warning'>Connection error: Destination Unreachable.</span>"
|
||||
|
||||
// Proc: New()
|
||||
// Parameters: None
|
||||
// Description: Adds standard components for this SMES, and forces recalculation of properties.
|
||||
/obj/machinery/power/smes/buildable/New()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stack/cable_coil(src,30)
|
||||
@@ -54,11 +68,17 @@
|
||||
recalc_coils()
|
||||
..()
|
||||
|
||||
// Proc: attack_hand()
|
||||
// Parameters: None
|
||||
// Description: Opens the UI as usual, and if cover is removed opens the wiring panel.
|
||||
/obj/machinery/power/smes/buildable/attack_hand()
|
||||
..()
|
||||
if(open_hatch)
|
||||
wires.Interact(usr)
|
||||
|
||||
// Proc: recalc_coils()
|
||||
// Parameters: None
|
||||
// Description: Updates properties (IO, capacity, etc.) of this SMES by checking internal components.
|
||||
/obj/machinery/power/smes/buildable/proc/recalc_coils()
|
||||
if ((cur_coils <= max_coils) && (cur_coils >= 1))
|
||||
capacity = 0
|
||||
@@ -73,6 +93,10 @@
|
||||
else
|
||||
return 0
|
||||
|
||||
// Proc: total_system_failure()
|
||||
// Parameters: 2 (intensity - how strong the failure is, user - person which caused the failure)
|
||||
// Description: Checks the sensors for alerts. If change (alerts cleared or detected) occurs, calls for icon update.
|
||||
/obj/machinery/power/smes/buildable/proc/total_system_failure(var/intensity = 0, var/mob/user as mob)
|
||||
// SMESs store very large amount of power. If someone screws up (ie: Disables safeties and attempts to modify the SMES) very bad things happen.
|
||||
// Bad things are based on charge percentage.
|
||||
// Possible effects:
|
||||
@@ -82,7 +106,7 @@
|
||||
// Light Overload - X% chance to overload each lighting circuit in connected powernet. APC based.
|
||||
// APC Failure - X% chance to destroy APC causing very weak explosion too. Won't cause hull breach or serious harm.
|
||||
// SMES Explosion - X% chance to destroy the SMES, in moderate explosion. May cause small hull breach.
|
||||
/obj/machinery/power/smes/buildable/proc/total_system_failure(var/intensity = 0, var/mob/user as mob)
|
||||
|
||||
if (!intensity)
|
||||
return
|
||||
|
||||
@@ -187,7 +211,9 @@
|
||||
|
||||
|
||||
|
||||
// Gets powernet APCs and overloads lights or breaks the APC completely, depending on percentages.
|
||||
// Proc: apcs_overload()
|
||||
// Parameters: 2 (failure_chance - chance to actually break the APC, overload_chance - Chance of breaking lights)
|
||||
// Description: Damages output powernet by power surge. Destroys few APCs and lights, depending on parameters.
|
||||
/obj/machinery/power/smes/buildable/proc/apcs_overload(var/failure_chance, var/overload_chance)
|
||||
if (!src.powernet)
|
||||
return
|
||||
@@ -200,7 +226,9 @@
|
||||
if (prob(failure_chance))
|
||||
A.set_broken()
|
||||
|
||||
// Failing SMES has special icon overlay.
|
||||
// Proc: update_icon()
|
||||
// Parameters: None
|
||||
// Description: Allows us to use special icon overlay for critical SMESs
|
||||
/obj/machinery/power/smes/buildable/update_icon()
|
||||
if (failing)
|
||||
overlays.Cut()
|
||||
@@ -208,6 +236,9 @@
|
||||
else
|
||||
..()
|
||||
|
||||
// Proc: attackby()
|
||||
// Parameters: 2 (W - object that was used on this machine, user - person which used the object)
|
||||
// Description: Handles tool interaction. Allows deconstruction/upgrading/fixing.
|
||||
/obj/machinery/power/smes/buildable/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
|
||||
// No more disassembling of overloaded SMESs. You broke it, now enjoy the consequences.
|
||||
if (failing)
|
||||
@@ -283,18 +314,30 @@
|
||||
else
|
||||
usr << "\red You can't insert more coils to this SMES unit!"
|
||||
|
||||
// Proc: toggle_input()
|
||||
// Parameters: None
|
||||
// Description: Switches the input on/off depending on previous setting
|
||||
/obj/machinery/power/smes/buildable/proc/toggle_input()
|
||||
input_attempt = !input_attempt
|
||||
update_icon()
|
||||
|
||||
// Proc: toggle_output()
|
||||
// Parameters: None
|
||||
// Description: Switches the output on/off depending on previous setting
|
||||
/obj/machinery/power/smes/buildable/proc/toggle_output()
|
||||
output_attempt = !output_attempt
|
||||
update_icon()
|
||||
|
||||
// Proc: set_input()
|
||||
// Parameters: 1 (new_input - New input value in Watts)
|
||||
// Description: Sets input setting on this SMES. Trims it if limits are exceeded.
|
||||
/obj/machinery/power/smes/buildable/proc/set_input(var/new_input = 0)
|
||||
input_level = new_input
|
||||
input_level = between(0, new_input, input_level_max)
|
||||
update_icon()
|
||||
|
||||
// Proc: set_output()
|
||||
// Parameters: 1 (new_output - New output value in Watts)
|
||||
// Description: Sets output setting on this SMES. Trims it if limits are exceeded.
|
||||
/obj/machinery/power/smes/buildable/proc/set_output(var/new_output = 0)
|
||||
output_level = new_output
|
||||
output_level = between(0, new_output, output_level_max)
|
||||
update_icon()
|
||||
@@ -34,7 +34,7 @@
|
||||
anchored = 1
|
||||
density = 1
|
||||
var/obj/machinery/compressor/compressor
|
||||
var/list/obj/machinery/door/poddoor/doors
|
||||
var/list/obj/machinery/door/blast/doors
|
||||
var/id = 0
|
||||
var/door_status = 0
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
if(id == C.comp_id)
|
||||
compressor = C
|
||||
doors = new /list()
|
||||
for(var/obj/machinery/door/poddoor/P in machines)
|
||||
for(var/obj/machinery/door/blast/P in machines)
|
||||
if(P.id == id)
|
||||
doors += P
|
||||
|
||||
@@ -296,7 +296,7 @@
|
||||
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)
|
||||
for(var/obj/machinery/door/blast/D in src.doors)
|
||||
if (door_status == 0)
|
||||
spawn( 0 )
|
||||
D.open()
|
||||
|
||||
Reference in New Issue
Block a user