mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-19 02:54:41 +01:00
File standardisation (#13131)
* Adds the check components * Adds in trailing newlines * Converts all CRLF to LF * Post merge EOF * Post merge line endings * Final commit
This commit is contained in:
+1384
-1384
File diff suppressed because it is too large
Load Diff
+867
-867
File diff suppressed because it is too large
Load Diff
@@ -25,4 +25,4 @@
|
||||
..()
|
||||
|
||||
/obj/structure/cable/heavyduty/cable_color(var/colorC)
|
||||
return
|
||||
return
|
||||
|
||||
+292
-292
@@ -1,292 +1,292 @@
|
||||
#define LOGIC_HIGH 5
|
||||
|
||||
//Indicators only have one input and no outputs
|
||||
/obj/machinery/logic/indicator
|
||||
//Input is searched from the 'dir' direction
|
||||
var/obj/structure/cable/input
|
||||
|
||||
/obj/machinery/logic/indicator/process()
|
||||
if(input)
|
||||
return 1
|
||||
|
||||
|
||||
if(!input)
|
||||
var/turf/T = get_step(src, dir)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
input = C
|
||||
return 1
|
||||
|
||||
return 0 //If it gets to here, it means no suitable wire to link to was found.
|
||||
|
||||
/obj/machinery/logic/indicator/bulb
|
||||
icon = 'icons/obj/lighting.dmi'
|
||||
icon_state = "bulb0"
|
||||
|
||||
/obj/machinery/logic/indicator/bulb/process()
|
||||
if(!..()) //Parent proc checks if input1 exists.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input = input.powernet
|
||||
if(!pn_input)
|
||||
return
|
||||
|
||||
if(pn_input.avail >= LOGIC_HIGH)
|
||||
icon_state = "bulb1"
|
||||
else
|
||||
icon_state = "bulb0"
|
||||
|
||||
|
||||
|
||||
|
||||
//Sensors only have one output and no inputs
|
||||
/obj/machinery/logic/sensor
|
||||
//Output is searched from the 'dir' direction
|
||||
var/obj/structure/cable/output
|
||||
|
||||
/obj/machinery/logic/sensor/process()
|
||||
if(output)
|
||||
return 1
|
||||
|
||||
if(!output)
|
||||
var/turf/T = get_step(src, dir)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
output = C
|
||||
return 1
|
||||
|
||||
return 0 //If it gets to here, it means no suitable wire to link to was found.
|
||||
|
||||
//Constant high generator. This will continue to send a signal of LOGIC_HIGH as long as it exists.
|
||||
/obj/machinery/logic/sensor/constant_high
|
||||
icon = 'icons/obj/atmospherics/outlet_injector.dmi'
|
||||
icon_state = "off"
|
||||
|
||||
/obj/machinery/logic/sensor/constant_high/process()
|
||||
if(!..()) //Parent proc checks if input1 exists.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH)
|
||||
|
||||
|
||||
|
||||
|
||||
//ONE INPUT logic elements have one input and one output
|
||||
/obj/machinery/logic/oneinput
|
||||
var/dir_input = 2
|
||||
var/dir_output = 1
|
||||
var/obj/structure/cable/input
|
||||
var/obj/structure/cable/output
|
||||
icon = 'icons/atmos/heat.dmi'
|
||||
icon_state = "intact"
|
||||
|
||||
/obj/machinery/logic/oneinput/process()
|
||||
if(input && output)
|
||||
return 1
|
||||
|
||||
if(!dir_input || !dir_output)
|
||||
return 0
|
||||
|
||||
if(!input)
|
||||
var/turf/T = get_step(src, dir_input)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_input, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
input = C
|
||||
|
||||
if(!output)
|
||||
var/turf/T = get_step(src, dir_output)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_output, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
output = C
|
||||
|
||||
return 0 //On the process() call, where everything is still being searched for, it returns 0. It will return 1 on the next process() call.
|
||||
|
||||
//NOT GATE
|
||||
/obj/machinery/logic/oneinput/not/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input = input.powernet
|
||||
|
||||
if(!pn_input)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( !(pn_input.avail >= LOGIC_HIGH))
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//TWO INPUT logic elements have two inputs and one output
|
||||
/obj/machinery/logic/twoinput
|
||||
var/dir_input1 = 2
|
||||
var/dir_input2 = 8
|
||||
var/dir_output = 1
|
||||
var/obj/structure/cable/input1
|
||||
var/obj/structure/cable/input2
|
||||
var/obj/structure/cable/output
|
||||
icon = 'icons/obj/atmospherics/mixer.dmi'
|
||||
icon_state = "intact_off"
|
||||
|
||||
/obj/machinery/logic/twoinput/process()
|
||||
if(input1 && input2 && output)
|
||||
return 1
|
||||
|
||||
if(!dir_input1 || !dir_input2 || !dir_output)
|
||||
return 0
|
||||
|
||||
if(!input1)
|
||||
var/turf/T = get_step(src, dir_input1)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_input1, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
input1 = C
|
||||
|
||||
if(!input2)
|
||||
var/turf/T = get_step(src, dir_input2)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_input2, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
input2 = C
|
||||
|
||||
if(!output)
|
||||
var/turf/T = get_step(src, dir_output)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_output, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
output = C
|
||||
|
||||
return 0 //On the process() call, where everything is still being searched for, it returns 0. It will return 1 on the next process() call.
|
||||
|
||||
//AND GATE
|
||||
/obj/machinery/logic/twoinput/and/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
|
||||
if(!pn_input1 || !pn_input2)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) && (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//OR GATE
|
||||
/obj/machinery/logic/twoinput/or/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
|
||||
if(!pn_input1 || !pn_input2)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) || (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//XOR GATE
|
||||
/obj/machinery/logic/twoinput/xor/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
|
||||
if(!pn_input1 || !pn_input2)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) != (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//XNOR GATE (EQUIVALENCE)
|
||||
/obj/machinery/logic/twoinput/xnor/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
|
||||
if(!pn_input1 || !pn_input2)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) == (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
#define RELAY_POWER_TRANSFER 2000 //How much power a relay transfers through.
|
||||
|
||||
//RELAY - input1 governs the flow from input2 to output
|
||||
/obj/machinery/logic/twoinput/relay/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
|
||||
if(!pn_input1)
|
||||
return
|
||||
|
||||
if( pn_input1.avail >= LOGIC_HIGH )
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if(pn_input2.avail >= RELAY_POWER_TRANSFER)
|
||||
pn_input2.load += RELAY_POWER_TRANSFER
|
||||
pn_output.newavail += RELAY_POWER_TRANSFER
|
||||
|
||||
|
||||
#undef RELAY_POWER_TRANSFER
|
||||
#undef LOGIC_HIGH
|
||||
#define LOGIC_HIGH 5
|
||||
|
||||
//Indicators only have one input and no outputs
|
||||
/obj/machinery/logic/indicator
|
||||
//Input is searched from the 'dir' direction
|
||||
var/obj/structure/cable/input
|
||||
|
||||
/obj/machinery/logic/indicator/process()
|
||||
if(input)
|
||||
return 1
|
||||
|
||||
|
||||
if(!input)
|
||||
var/turf/T = get_step(src, dir)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
input = C
|
||||
return 1
|
||||
|
||||
return 0 //If it gets to here, it means no suitable wire to link to was found.
|
||||
|
||||
/obj/machinery/logic/indicator/bulb
|
||||
icon = 'icons/obj/lighting.dmi'
|
||||
icon_state = "bulb0"
|
||||
|
||||
/obj/machinery/logic/indicator/bulb/process()
|
||||
if(!..()) //Parent proc checks if input1 exists.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input = input.powernet
|
||||
if(!pn_input)
|
||||
return
|
||||
|
||||
if(pn_input.avail >= LOGIC_HIGH)
|
||||
icon_state = "bulb1"
|
||||
else
|
||||
icon_state = "bulb0"
|
||||
|
||||
|
||||
|
||||
|
||||
//Sensors only have one output and no inputs
|
||||
/obj/machinery/logic/sensor
|
||||
//Output is searched from the 'dir' direction
|
||||
var/obj/structure/cable/output
|
||||
|
||||
/obj/machinery/logic/sensor/process()
|
||||
if(output)
|
||||
return 1
|
||||
|
||||
if(!output)
|
||||
var/turf/T = get_step(src, dir)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
output = C
|
||||
return 1
|
||||
|
||||
return 0 //If it gets to here, it means no suitable wire to link to was found.
|
||||
|
||||
//Constant high generator. This will continue to send a signal of LOGIC_HIGH as long as it exists.
|
||||
/obj/machinery/logic/sensor/constant_high
|
||||
icon = 'icons/obj/atmospherics/outlet_injector.dmi'
|
||||
icon_state = "off"
|
||||
|
||||
/obj/machinery/logic/sensor/constant_high/process()
|
||||
if(!..()) //Parent proc checks if input1 exists.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH)
|
||||
|
||||
|
||||
|
||||
|
||||
//ONE INPUT logic elements have one input and one output
|
||||
/obj/machinery/logic/oneinput
|
||||
var/dir_input = 2
|
||||
var/dir_output = 1
|
||||
var/obj/structure/cable/input
|
||||
var/obj/structure/cable/output
|
||||
icon = 'icons/atmos/heat.dmi'
|
||||
icon_state = "intact"
|
||||
|
||||
/obj/machinery/logic/oneinput/process()
|
||||
if(input && output)
|
||||
return 1
|
||||
|
||||
if(!dir_input || !dir_output)
|
||||
return 0
|
||||
|
||||
if(!input)
|
||||
var/turf/T = get_step(src, dir_input)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_input, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
input = C
|
||||
|
||||
if(!output)
|
||||
var/turf/T = get_step(src, dir_output)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_output, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
output = C
|
||||
|
||||
return 0 //On the process() call, where everything is still being searched for, it returns 0. It will return 1 on the next process() call.
|
||||
|
||||
//NOT GATE
|
||||
/obj/machinery/logic/oneinput/not/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input = input.powernet
|
||||
|
||||
if(!pn_input)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( !(pn_input.avail >= LOGIC_HIGH))
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//TWO INPUT logic elements have two inputs and one output
|
||||
/obj/machinery/logic/twoinput
|
||||
var/dir_input1 = 2
|
||||
var/dir_input2 = 8
|
||||
var/dir_output = 1
|
||||
var/obj/structure/cable/input1
|
||||
var/obj/structure/cable/input2
|
||||
var/obj/structure/cable/output
|
||||
icon = 'icons/obj/atmospherics/mixer.dmi'
|
||||
icon_state = "intact_off"
|
||||
|
||||
/obj/machinery/logic/twoinput/process()
|
||||
if(input1 && input2 && output)
|
||||
return 1
|
||||
|
||||
if(!dir_input1 || !dir_input2 || !dir_output)
|
||||
return 0
|
||||
|
||||
if(!input1)
|
||||
var/turf/T = get_step(src, dir_input1)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_input1, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
input1 = C
|
||||
|
||||
if(!input2)
|
||||
var/turf/T = get_step(src, dir_input2)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_input2, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
input2 = C
|
||||
|
||||
if(!output)
|
||||
var/turf/T = get_step(src, dir_output)
|
||||
if(T)
|
||||
var/inv_dir = turn(dir_output, 180)
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == inv_dir || C.d2 == inv_dir)
|
||||
output = C
|
||||
|
||||
return 0 //On the process() call, where everything is still being searched for, it returns 0. It will return 1 on the next process() call.
|
||||
|
||||
//AND GATE
|
||||
/obj/machinery/logic/twoinput/and/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
|
||||
if(!pn_input1 || !pn_input2)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) && (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//OR GATE
|
||||
/obj/machinery/logic/twoinput/or/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
|
||||
if(!pn_input1 || !pn_input2)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) || (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//XOR GATE
|
||||
/obj/machinery/logic/twoinput/xor/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
|
||||
if(!pn_input1 || !pn_input2)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) != (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
//XNOR GATE (EQUIVALENCE)
|
||||
/obj/machinery/logic/twoinput/xnor/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
|
||||
if(!pn_input1 || !pn_input2)
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if( (pn_input1.avail >= LOGIC_HIGH) == (pn_input2.avail >= LOGIC_HIGH) )
|
||||
pn_output.newavail = max(pn_output.avail, LOGIC_HIGH) //Set the output avilable power to 5 or whatever it was before.
|
||||
else
|
||||
pn_output.load += LOGIC_HIGH //Otherwise increase the load to 5
|
||||
|
||||
#define RELAY_POWER_TRANSFER 2000 //How much power a relay transfers through.
|
||||
|
||||
//RELAY - input1 governs the flow from input2 to output
|
||||
/obj/machinery/logic/twoinput/relay/process()
|
||||
if(!..()) //Parent proc checks if input1, input2 and output exist.
|
||||
return
|
||||
|
||||
var/datum/powernet/pn_input1 = input1.powernet
|
||||
|
||||
if(!pn_input1)
|
||||
return
|
||||
|
||||
if( pn_input1.avail >= LOGIC_HIGH )
|
||||
var/datum/powernet/pn_input2 = input2.powernet
|
||||
var/datum/powernet/pn_output = output.powernet
|
||||
|
||||
if(!pn_output)
|
||||
return
|
||||
|
||||
if(pn_input2.avail >= RELAY_POWER_TRANSFER)
|
||||
pn_input2.load += RELAY_POWER_TRANSFER
|
||||
pn_output.newavail += RELAY_POWER_TRANSFER
|
||||
|
||||
|
||||
#undef RELAY_POWER_TRANSFER
|
||||
#undef LOGIC_HIGH
|
||||
|
||||
+356
-356
@@ -1,356 +1,356 @@
|
||||
/obj/item/stock_parts/cell
|
||||
name = "power cell"
|
||||
desc = "A rechargeable electrochemical power cell."
|
||||
icon = 'icons/obj/power.dmi'
|
||||
icon_state = "cell"
|
||||
item_state = "cell"
|
||||
origin_tech = "powerstorage=1"
|
||||
force = 5
|
||||
throwforce = 5
|
||||
throw_speed = 2
|
||||
throw_range = 5
|
||||
w_class = WEIGHT_CLASS_SMALL
|
||||
var/charge = 0 // note %age conveted to actual charge in New
|
||||
var/maxcharge = 1000
|
||||
materials = list(MAT_METAL = 700, MAT_GLASS = 50)
|
||||
var/rigged = FALSE // true if rigged to explode
|
||||
var/chargerate = 100 //how much power is given every tick in a recharger
|
||||
var/self_recharge = 0 //does it self recharge, over time, or not?
|
||||
var/ratingdesc = TRUE
|
||||
var/grown_battery = FALSE // If it's a grown that acts as a battery, add a wire overlay to it.
|
||||
|
||||
/obj/item/stock_parts/cell/get_cell()
|
||||
return src
|
||||
|
||||
/obj/item/stock_parts/cell/New()
|
||||
..()
|
||||
START_PROCESSING(SSobj, src)
|
||||
charge = maxcharge
|
||||
if(ratingdesc)
|
||||
desc += " This one has a power rating of [DisplayPower(maxcharge)], and you should not swallow it."
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/Destroy()
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
return ..()
|
||||
|
||||
/obj/item/stock_parts/cell/vv_edit_var(var_name, var_value)
|
||||
switch(var_name)
|
||||
if("self_recharge")
|
||||
if(var_value)
|
||||
START_PROCESSING(SSobj, src)
|
||||
else
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
. = ..()
|
||||
|
||||
/obj/item/stock_parts/cell/process()
|
||||
if(self_recharge)
|
||||
give(chargerate * 0.25)
|
||||
else
|
||||
return PROCESS_KILL
|
||||
|
||||
/obj/item/stock_parts/cell/update_icon()
|
||||
overlays.Cut()
|
||||
if(grown_battery)
|
||||
overlays += image('icons/obj/power.dmi', "grown_wires")
|
||||
if(charge < 0.01)
|
||||
return
|
||||
else if(charge/maxcharge >=0.995)
|
||||
overlays += "cell-o2"
|
||||
else
|
||||
overlays += "cell-o1"
|
||||
|
||||
/obj/item/stock_parts/cell/proc/percent() // return % charge of cell
|
||||
return 100 * charge / maxcharge
|
||||
|
||||
// use power from a cell
|
||||
/obj/item/stock_parts/cell/use(amount)
|
||||
if(rigged && amount > 0)
|
||||
explode()
|
||||
return 0
|
||||
if(charge < amount)
|
||||
return 0
|
||||
charge = (charge - amount)
|
||||
return 1
|
||||
|
||||
// recharge the cell
|
||||
/obj/item/stock_parts/cell/proc/give(amount)
|
||||
if(rigged && amount > 0)
|
||||
explode()
|
||||
return 0
|
||||
if(maxcharge < amount)
|
||||
amount = maxcharge
|
||||
var/power_used = min(maxcharge - charge, amount)
|
||||
charge += power_used
|
||||
return power_used
|
||||
|
||||
/obj/item/stock_parts/cell/examine(mob/user)
|
||||
. = ..()
|
||||
if(rigged)
|
||||
. += "<span class='danger'>This power cell seems to be faulty!</span>"
|
||||
else
|
||||
. += "The charge meter reads [round(percent() )]%."
|
||||
|
||||
/obj/item/stock_parts/cell/suicide_act(mob/user)
|
||||
to_chat(viewers(user), "<span class='suicide'>[user] is licking the electrodes of the [src]! It looks like [user.p_theyre()] trying to commit suicide.</span>")
|
||||
return FIRELOSS
|
||||
|
||||
/obj/item/stock_parts/cell/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/reagent_containers/syringe))
|
||||
var/obj/item/reagent_containers/syringe/S = W
|
||||
|
||||
to_chat(user, "You inject the solution into the power cell.")
|
||||
|
||||
if(S.reagents.has_reagent("plasma", 5) || S.reagents.has_reagent("plasma_dust", 5))
|
||||
|
||||
rigged = TRUE
|
||||
|
||||
log_admin("LOG: [key_name(user)] injected a power cell with plasma, rigging it to explode.")
|
||||
message_admins("LOG: [key_name_admin(user)] injected a power cell with plasma, rigging it to explode.")
|
||||
|
||||
S.reagents.clear_reagents()
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/item/stock_parts/cell/proc/explode()
|
||||
var/turf/T = get_turf(loc)
|
||||
if(charge == 0)
|
||||
return
|
||||
var/devastation_range = -1 //round(charge/11000)
|
||||
var/heavy_impact_range = round(sqrt(charge) / 60)
|
||||
var/light_impact_range = round(sqrt(charge) / 30)
|
||||
var/flash_range = light_impact_range
|
||||
if(light_impact_range == 0)
|
||||
rigged = FALSE
|
||||
corrupt()
|
||||
return
|
||||
//explosion(T, 0, 1, 2, 2)
|
||||
log_admin("LOG: Rigged power cell explosion, last touched by [fingerprintslast]")
|
||||
message_admins("LOG: Rigged power cell explosion, last touched by [fingerprintslast]")
|
||||
|
||||
explosion(T, devastation_range, heavy_impact_range, light_impact_range, flash_range)
|
||||
qdel(src)
|
||||
|
||||
/obj/item/stock_parts/cell/proc/corrupt()
|
||||
charge /= 2
|
||||
maxcharge = max(maxcharge / 2, chargerate)
|
||||
if(prob(10))
|
||||
rigged = TRUE //broken batterys are dangerous
|
||||
|
||||
/obj/item/stock_parts/cell/emp_act(severity)
|
||||
charge -= 1000 / severity
|
||||
if(charge < 0)
|
||||
charge = 0
|
||||
..()
|
||||
|
||||
/obj/item/stock_parts/cell/ex_act(severity)
|
||||
..()
|
||||
if(!QDELETED(src))
|
||||
switch(severity)
|
||||
if(2)
|
||||
if(prob(50))
|
||||
corrupt()
|
||||
if(3)
|
||||
if(prob(25))
|
||||
corrupt()
|
||||
|
||||
/obj/item/stock_parts/cell/blob_act(obj/structure/blob/B)
|
||||
ex_act(EXPLODE_DEVASTATE)
|
||||
|
||||
/obj/item/stock_parts/cell/proc/get_electrocute_damage()
|
||||
if(charge >= 1000)
|
||||
return Clamp(20 + round(charge / 25000), 20, 195) + rand(-5, 5)
|
||||
else
|
||||
return 0
|
||||
|
||||
// Cell variants
|
||||
/obj/item/stock_parts/cell/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
|
||||
/obj/item/stock_parts/cell/crap
|
||||
name = "\improper Nanotrasen brand rechargeable AA battery"
|
||||
desc = "You can't top the plasma top." //TOTALLY TRADEMARK INFRINGEMENT
|
||||
maxcharge = 500
|
||||
materials = list(MAT_GLASS = 40)
|
||||
rating = 2
|
||||
|
||||
/obj/item/stock_parts/cell/crap/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/upgraded
|
||||
name = "upgraded power cell"
|
||||
desc = "A power cell with a slightly higher capacity than normal!"
|
||||
maxcharge = 2500
|
||||
materials = list(MAT_GLASS = 50)
|
||||
rating = 2
|
||||
chargerate = 1000
|
||||
|
||||
/obj/item/stock_parts/cell/upgraded/plus
|
||||
name = "upgraded power cell+"
|
||||
desc = "A power cell with an even higher capacity than the base model!"
|
||||
maxcharge = 5000
|
||||
|
||||
/obj/item/stock_parts/cell/secborg
|
||||
name = "security borg rechargeable D battery"
|
||||
origin_tech = null
|
||||
maxcharge = 600 //600 max charge / 100 charge per shot = six shots
|
||||
materials = list(MAT_GLASS = 40)
|
||||
rating = 2.5
|
||||
|
||||
/obj/item/stock_parts/cell/secborg/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/pulse //200 pulse shots
|
||||
name = "pulse rifle power cell"
|
||||
maxcharge = 40000
|
||||
rating = 3
|
||||
chargerate = 1500
|
||||
|
||||
/obj/item/stock_parts/cell/pulse/carbine //25 pulse shots
|
||||
name = "pulse carbine power cell"
|
||||
maxcharge = 5000
|
||||
|
||||
/obj/item/stock_parts/cell/pulse/pistol //10 pulse shots
|
||||
name = "pulse pistol power cell"
|
||||
maxcharge = 2000
|
||||
|
||||
/obj/item/stock_parts/cell/high
|
||||
name = "high-capacity power cell"
|
||||
origin_tech = "powerstorage=2"
|
||||
icon_state = "hcell"
|
||||
maxcharge = 10000
|
||||
materials = list(MAT_GLASS = 60)
|
||||
rating = 3
|
||||
chargerate = 1500
|
||||
|
||||
/obj/item/stock_parts/cell/high/plus
|
||||
name = "high-capacity power cell+"
|
||||
desc = "Where did these come from?"
|
||||
icon_state = "h+cell"
|
||||
maxcharge = 15000
|
||||
chargerate = 2250
|
||||
|
||||
/obj/item/stock_parts/cell/high/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/super
|
||||
name = "super-capacity power cell"
|
||||
origin_tech = "powerstorage=3;materials=3"
|
||||
icon_state = "scell"
|
||||
maxcharge = 20000
|
||||
materials = list(MAT_GLASS = 300)
|
||||
rating = 4
|
||||
chargerate = 2000
|
||||
|
||||
/obj/item/stock_parts/cell/super/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/hyper
|
||||
name = "hyper-capacity power cell"
|
||||
origin_tech = "powerstorage=4;engineering=4;materials=4"
|
||||
icon_state = "hpcell"
|
||||
maxcharge = 30000
|
||||
materials = list(MAT_GLASS = 400)
|
||||
rating = 5
|
||||
chargerate = 3000
|
||||
|
||||
/obj/item/stock_parts/cell/hyper/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/bluespace
|
||||
name = "bluespace power cell"
|
||||
desc = "A rechargeable transdimensional power cell."
|
||||
origin_tech = "powerstorage=5;bluespace=4;materials=4;engineering=4"
|
||||
icon_state = "bscell"
|
||||
maxcharge = 40000
|
||||
materials = list(MAT_GLASS = 600)
|
||||
rating = 6
|
||||
chargerate = 4000
|
||||
|
||||
/obj/item/stock_parts/cell/bluespace/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/infinite
|
||||
name = "infinite-capacity power cell!"
|
||||
icon_state = "icell"
|
||||
origin_tech = "powerstorage=7"
|
||||
maxcharge = 30000
|
||||
materials = list(MAT_GLASS=1000)
|
||||
rating = 6
|
||||
chargerate = 30000
|
||||
|
||||
/obj/item/stock_parts/cell/infinite/use()
|
||||
return 1
|
||||
|
||||
/obj/item/stock_parts/cell/infinite/abductor
|
||||
name = "void core"
|
||||
desc = "An alien power cell that produces energy seemingly out of nowhere."
|
||||
icon = 'icons/obj/abductor.dmi'
|
||||
icon_state = "cell"
|
||||
maxcharge = 50000
|
||||
rating = 12
|
||||
ratingdesc = FALSE
|
||||
|
||||
/obj/item/stock_parts/cell/infinite/abductor/update_icon()
|
||||
return
|
||||
|
||||
|
||||
/obj/item/stock_parts/cell/potato
|
||||
name = "potato battery"
|
||||
desc = "A rechargeable starch based power cell."
|
||||
icon = 'icons/obj/hydroponics/harvest.dmi'
|
||||
icon_state = "potato"
|
||||
origin_tech = "powerstorage=1;biotech=1"
|
||||
charge = 100
|
||||
maxcharge = 300
|
||||
materials = list()
|
||||
rating = 1
|
||||
grown_battery = TRUE //it has the overlays for wires
|
||||
|
||||
/obj/item/stock_parts/cell/high/slime
|
||||
name = "charged slime core"
|
||||
desc = "A yellow slime core infused with plasma, it crackles with power."
|
||||
origin_tech = "powerstorage=5;biotech=4"
|
||||
icon = 'icons/mob/slimes.dmi'
|
||||
icon_state = "yellow slime extract"
|
||||
materials = list()
|
||||
rating = 5 //self-recharge makes these desirable
|
||||
self_recharge = 1 // Infused slime cores self-recharge, over time
|
||||
chargerate = 500
|
||||
|
||||
/obj/item/stock_parts/cell/emproof
|
||||
name = "\improper EMP-proof cell"
|
||||
desc = "An EMP-proof cell."
|
||||
maxcharge = 500
|
||||
rating = 3
|
||||
|
||||
/obj/item/stock_parts/cell/emproof/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/emproof/emp_act(severity)
|
||||
return
|
||||
|
||||
/obj/item/stock_parts/cell/emproof/corrupt()
|
||||
return
|
||||
|
||||
/obj/item/stock_parts/cell/ninja
|
||||
name = "spider-clan power cell"
|
||||
desc = "A standard ninja-suit power cell."
|
||||
maxcharge = 10000
|
||||
materials = list(MAT_GLASS = 60)
|
||||
/obj/item/stock_parts/cell
|
||||
name = "power cell"
|
||||
desc = "A rechargeable electrochemical power cell."
|
||||
icon = 'icons/obj/power.dmi'
|
||||
icon_state = "cell"
|
||||
item_state = "cell"
|
||||
origin_tech = "powerstorage=1"
|
||||
force = 5
|
||||
throwforce = 5
|
||||
throw_speed = 2
|
||||
throw_range = 5
|
||||
w_class = WEIGHT_CLASS_SMALL
|
||||
var/charge = 0 // note %age conveted to actual charge in New
|
||||
var/maxcharge = 1000
|
||||
materials = list(MAT_METAL = 700, MAT_GLASS = 50)
|
||||
var/rigged = FALSE // true if rigged to explode
|
||||
var/chargerate = 100 //how much power is given every tick in a recharger
|
||||
var/self_recharge = 0 //does it self recharge, over time, or not?
|
||||
var/ratingdesc = TRUE
|
||||
var/grown_battery = FALSE // If it's a grown that acts as a battery, add a wire overlay to it.
|
||||
|
||||
/obj/item/stock_parts/cell/get_cell()
|
||||
return src
|
||||
|
||||
/obj/item/stock_parts/cell/New()
|
||||
..()
|
||||
START_PROCESSING(SSobj, src)
|
||||
charge = maxcharge
|
||||
if(ratingdesc)
|
||||
desc += " This one has a power rating of [DisplayPower(maxcharge)], and you should not swallow it."
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/Destroy()
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
return ..()
|
||||
|
||||
/obj/item/stock_parts/cell/vv_edit_var(var_name, var_value)
|
||||
switch(var_name)
|
||||
if("self_recharge")
|
||||
if(var_value)
|
||||
START_PROCESSING(SSobj, src)
|
||||
else
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
. = ..()
|
||||
|
||||
/obj/item/stock_parts/cell/process()
|
||||
if(self_recharge)
|
||||
give(chargerate * 0.25)
|
||||
else
|
||||
return PROCESS_KILL
|
||||
|
||||
/obj/item/stock_parts/cell/update_icon()
|
||||
overlays.Cut()
|
||||
if(grown_battery)
|
||||
overlays += image('icons/obj/power.dmi', "grown_wires")
|
||||
if(charge < 0.01)
|
||||
return
|
||||
else if(charge/maxcharge >=0.995)
|
||||
overlays += "cell-o2"
|
||||
else
|
||||
overlays += "cell-o1"
|
||||
|
||||
/obj/item/stock_parts/cell/proc/percent() // return % charge of cell
|
||||
return 100 * charge / maxcharge
|
||||
|
||||
// use power from a cell
|
||||
/obj/item/stock_parts/cell/use(amount)
|
||||
if(rigged && amount > 0)
|
||||
explode()
|
||||
return 0
|
||||
if(charge < amount)
|
||||
return 0
|
||||
charge = (charge - amount)
|
||||
return 1
|
||||
|
||||
// recharge the cell
|
||||
/obj/item/stock_parts/cell/proc/give(amount)
|
||||
if(rigged && amount > 0)
|
||||
explode()
|
||||
return 0
|
||||
if(maxcharge < amount)
|
||||
amount = maxcharge
|
||||
var/power_used = min(maxcharge - charge, amount)
|
||||
charge += power_used
|
||||
return power_used
|
||||
|
||||
/obj/item/stock_parts/cell/examine(mob/user)
|
||||
. = ..()
|
||||
if(rigged)
|
||||
. += "<span class='danger'>This power cell seems to be faulty!</span>"
|
||||
else
|
||||
. += "The charge meter reads [round(percent() )]%."
|
||||
|
||||
/obj/item/stock_parts/cell/suicide_act(mob/user)
|
||||
to_chat(viewers(user), "<span class='suicide'>[user] is licking the electrodes of the [src]! It looks like [user.p_theyre()] trying to commit suicide.</span>")
|
||||
return FIRELOSS
|
||||
|
||||
/obj/item/stock_parts/cell/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/reagent_containers/syringe))
|
||||
var/obj/item/reagent_containers/syringe/S = W
|
||||
|
||||
to_chat(user, "You inject the solution into the power cell.")
|
||||
|
||||
if(S.reagents.has_reagent("plasma", 5) || S.reagents.has_reagent("plasma_dust", 5))
|
||||
|
||||
rigged = TRUE
|
||||
|
||||
log_admin("LOG: [key_name(user)] injected a power cell with plasma, rigging it to explode.")
|
||||
message_admins("LOG: [key_name_admin(user)] injected a power cell with plasma, rigging it to explode.")
|
||||
|
||||
S.reagents.clear_reagents()
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/item/stock_parts/cell/proc/explode()
|
||||
var/turf/T = get_turf(loc)
|
||||
if(charge == 0)
|
||||
return
|
||||
var/devastation_range = -1 //round(charge/11000)
|
||||
var/heavy_impact_range = round(sqrt(charge) / 60)
|
||||
var/light_impact_range = round(sqrt(charge) / 30)
|
||||
var/flash_range = light_impact_range
|
||||
if(light_impact_range == 0)
|
||||
rigged = FALSE
|
||||
corrupt()
|
||||
return
|
||||
//explosion(T, 0, 1, 2, 2)
|
||||
log_admin("LOG: Rigged power cell explosion, last touched by [fingerprintslast]")
|
||||
message_admins("LOG: Rigged power cell explosion, last touched by [fingerprintslast]")
|
||||
|
||||
explosion(T, devastation_range, heavy_impact_range, light_impact_range, flash_range)
|
||||
qdel(src)
|
||||
|
||||
/obj/item/stock_parts/cell/proc/corrupt()
|
||||
charge /= 2
|
||||
maxcharge = max(maxcharge / 2, chargerate)
|
||||
if(prob(10))
|
||||
rigged = TRUE //broken batterys are dangerous
|
||||
|
||||
/obj/item/stock_parts/cell/emp_act(severity)
|
||||
charge -= 1000 / severity
|
||||
if(charge < 0)
|
||||
charge = 0
|
||||
..()
|
||||
|
||||
/obj/item/stock_parts/cell/ex_act(severity)
|
||||
..()
|
||||
if(!QDELETED(src))
|
||||
switch(severity)
|
||||
if(2)
|
||||
if(prob(50))
|
||||
corrupt()
|
||||
if(3)
|
||||
if(prob(25))
|
||||
corrupt()
|
||||
|
||||
/obj/item/stock_parts/cell/blob_act(obj/structure/blob/B)
|
||||
ex_act(EXPLODE_DEVASTATE)
|
||||
|
||||
/obj/item/stock_parts/cell/proc/get_electrocute_damage()
|
||||
if(charge >= 1000)
|
||||
return Clamp(20 + round(charge / 25000), 20, 195) + rand(-5, 5)
|
||||
else
|
||||
return 0
|
||||
|
||||
// Cell variants
|
||||
/obj/item/stock_parts/cell/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
|
||||
/obj/item/stock_parts/cell/crap
|
||||
name = "\improper Nanotrasen brand rechargeable AA battery"
|
||||
desc = "You can't top the plasma top." //TOTALLY TRADEMARK INFRINGEMENT
|
||||
maxcharge = 500
|
||||
materials = list(MAT_GLASS = 40)
|
||||
rating = 2
|
||||
|
||||
/obj/item/stock_parts/cell/crap/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/upgraded
|
||||
name = "upgraded power cell"
|
||||
desc = "A power cell with a slightly higher capacity than normal!"
|
||||
maxcharge = 2500
|
||||
materials = list(MAT_GLASS = 50)
|
||||
rating = 2
|
||||
chargerate = 1000
|
||||
|
||||
/obj/item/stock_parts/cell/upgraded/plus
|
||||
name = "upgraded power cell+"
|
||||
desc = "A power cell with an even higher capacity than the base model!"
|
||||
maxcharge = 5000
|
||||
|
||||
/obj/item/stock_parts/cell/secborg
|
||||
name = "security borg rechargeable D battery"
|
||||
origin_tech = null
|
||||
maxcharge = 600 //600 max charge / 100 charge per shot = six shots
|
||||
materials = list(MAT_GLASS = 40)
|
||||
rating = 2.5
|
||||
|
||||
/obj/item/stock_parts/cell/secborg/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/pulse //200 pulse shots
|
||||
name = "pulse rifle power cell"
|
||||
maxcharge = 40000
|
||||
rating = 3
|
||||
chargerate = 1500
|
||||
|
||||
/obj/item/stock_parts/cell/pulse/carbine //25 pulse shots
|
||||
name = "pulse carbine power cell"
|
||||
maxcharge = 5000
|
||||
|
||||
/obj/item/stock_parts/cell/pulse/pistol //10 pulse shots
|
||||
name = "pulse pistol power cell"
|
||||
maxcharge = 2000
|
||||
|
||||
/obj/item/stock_parts/cell/high
|
||||
name = "high-capacity power cell"
|
||||
origin_tech = "powerstorage=2"
|
||||
icon_state = "hcell"
|
||||
maxcharge = 10000
|
||||
materials = list(MAT_GLASS = 60)
|
||||
rating = 3
|
||||
chargerate = 1500
|
||||
|
||||
/obj/item/stock_parts/cell/high/plus
|
||||
name = "high-capacity power cell+"
|
||||
desc = "Where did these come from?"
|
||||
icon_state = "h+cell"
|
||||
maxcharge = 15000
|
||||
chargerate = 2250
|
||||
|
||||
/obj/item/stock_parts/cell/high/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/super
|
||||
name = "super-capacity power cell"
|
||||
origin_tech = "powerstorage=3;materials=3"
|
||||
icon_state = "scell"
|
||||
maxcharge = 20000
|
||||
materials = list(MAT_GLASS = 300)
|
||||
rating = 4
|
||||
chargerate = 2000
|
||||
|
||||
/obj/item/stock_parts/cell/super/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/hyper
|
||||
name = "hyper-capacity power cell"
|
||||
origin_tech = "powerstorage=4;engineering=4;materials=4"
|
||||
icon_state = "hpcell"
|
||||
maxcharge = 30000
|
||||
materials = list(MAT_GLASS = 400)
|
||||
rating = 5
|
||||
chargerate = 3000
|
||||
|
||||
/obj/item/stock_parts/cell/hyper/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/bluespace
|
||||
name = "bluespace power cell"
|
||||
desc = "A rechargeable transdimensional power cell."
|
||||
origin_tech = "powerstorage=5;bluespace=4;materials=4;engineering=4"
|
||||
icon_state = "bscell"
|
||||
maxcharge = 40000
|
||||
materials = list(MAT_GLASS = 600)
|
||||
rating = 6
|
||||
chargerate = 4000
|
||||
|
||||
/obj/item/stock_parts/cell/bluespace/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/infinite
|
||||
name = "infinite-capacity power cell!"
|
||||
icon_state = "icell"
|
||||
origin_tech = "powerstorage=7"
|
||||
maxcharge = 30000
|
||||
materials = list(MAT_GLASS=1000)
|
||||
rating = 6
|
||||
chargerate = 30000
|
||||
|
||||
/obj/item/stock_parts/cell/infinite/use()
|
||||
return 1
|
||||
|
||||
/obj/item/stock_parts/cell/infinite/abductor
|
||||
name = "void core"
|
||||
desc = "An alien power cell that produces energy seemingly out of nowhere."
|
||||
icon = 'icons/obj/abductor.dmi'
|
||||
icon_state = "cell"
|
||||
maxcharge = 50000
|
||||
rating = 12
|
||||
ratingdesc = FALSE
|
||||
|
||||
/obj/item/stock_parts/cell/infinite/abductor/update_icon()
|
||||
return
|
||||
|
||||
|
||||
/obj/item/stock_parts/cell/potato
|
||||
name = "potato battery"
|
||||
desc = "A rechargeable starch based power cell."
|
||||
icon = 'icons/obj/hydroponics/harvest.dmi'
|
||||
icon_state = "potato"
|
||||
origin_tech = "powerstorage=1;biotech=1"
|
||||
charge = 100
|
||||
maxcharge = 300
|
||||
materials = list()
|
||||
rating = 1
|
||||
grown_battery = TRUE //it has the overlays for wires
|
||||
|
||||
/obj/item/stock_parts/cell/high/slime
|
||||
name = "charged slime core"
|
||||
desc = "A yellow slime core infused with plasma, it crackles with power."
|
||||
origin_tech = "powerstorage=5;biotech=4"
|
||||
icon = 'icons/mob/slimes.dmi'
|
||||
icon_state = "yellow slime extract"
|
||||
materials = list()
|
||||
rating = 5 //self-recharge makes these desirable
|
||||
self_recharge = 1 // Infused slime cores self-recharge, over time
|
||||
chargerate = 500
|
||||
|
||||
/obj/item/stock_parts/cell/emproof
|
||||
name = "\improper EMP-proof cell"
|
||||
desc = "An EMP-proof cell."
|
||||
maxcharge = 500
|
||||
rating = 3
|
||||
|
||||
/obj/item/stock_parts/cell/emproof/empty/New()
|
||||
..()
|
||||
charge = 0
|
||||
update_icon()
|
||||
|
||||
/obj/item/stock_parts/cell/emproof/emp_act(severity)
|
||||
return
|
||||
|
||||
/obj/item/stock_parts/cell/emproof/corrupt()
|
||||
return
|
||||
|
||||
/obj/item/stock_parts/cell/ninja
|
||||
name = "spider-clan power cell"
|
||||
desc = "A standard ninja-suit power cell."
|
||||
maxcharge = 10000
|
||||
materials = list(MAT_GLASS = 60)
|
||||
|
||||
+250
-250
@@ -1,250 +1,250 @@
|
||||
/obj/machinery/power/generator
|
||||
name = "thermoelectric generator"
|
||||
desc = "It's a high efficiency thermoelectric generator."
|
||||
icon_state = "teg"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
|
||||
var/obj/machinery/atmospherics/binary/circulator/cold_circ
|
||||
var/obj/machinery/atmospherics/binary/circulator/hot_circ
|
||||
|
||||
var/cold_dir = WEST
|
||||
var/hot_dir = EAST
|
||||
|
||||
var/lastgen = 0
|
||||
var/lastgenlev = -1
|
||||
var/lastcirc = "00"
|
||||
|
||||
/obj/machinery/power/generator/New()
|
||||
..()
|
||||
update_desc()
|
||||
|
||||
/obj/machinery/power/generator/proc/update_desc()
|
||||
desc = initial(desc) + " Its cold circulator is located on the [dir2text(cold_dir)] side, and its heat circulator is located on the [dir2text(hot_dir)] side."
|
||||
|
||||
/obj/machinery/power/generator/Destroy()
|
||||
disconnect()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/generator/proc/disconnect()
|
||||
if(cold_circ)
|
||||
cold_circ.generator = null
|
||||
if(hot_circ)
|
||||
hot_circ.generator = null
|
||||
if(powernet)
|
||||
disconnect_from_network()
|
||||
|
||||
/obj/machinery/power/generator/Initialize()
|
||||
..()
|
||||
connect()
|
||||
|
||||
/obj/machinery/power/generator/proc/connect()
|
||||
connect_to_network()
|
||||
|
||||
var/obj/machinery/atmospherics/binary/circulator/circpath = /obj/machinery/atmospherics/binary/circulator
|
||||
cold_circ = locate(circpath) in get_step(src, cold_dir)
|
||||
hot_circ = locate(circpath) in get_step(src, hot_dir)
|
||||
|
||||
if(cold_circ && cold_circ.side == cold_dir)
|
||||
cold_circ.generator = src
|
||||
cold_circ.update_icon()
|
||||
else
|
||||
cold_circ = null
|
||||
|
||||
if(hot_circ && hot_circ.side == hot_dir)
|
||||
hot_circ.generator = src
|
||||
hot_circ.update_icon()
|
||||
else
|
||||
hot_circ = null
|
||||
|
||||
power_change()
|
||||
update_icon()
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/power/generator/power_change()
|
||||
if(!anchored)
|
||||
stat |= NOPOWER
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/machinery/power/generator/update_icon()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
overlays.Cut()
|
||||
else
|
||||
overlays.Cut()
|
||||
|
||||
if(lastgenlev != 0)
|
||||
overlays += image('icons/obj/power.dmi', "teg-op[lastgenlev]")
|
||||
|
||||
overlays += image('icons/obj/power.dmi', "teg-oc[lastcirc]")
|
||||
|
||||
/obj/machinery/power/generator/process()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
|
||||
if(!cold_circ || !hot_circ)
|
||||
return
|
||||
|
||||
lastgen = 0
|
||||
|
||||
if(powernet)
|
||||
|
||||
//log_debug("cold_circ and hot_circ pass")
|
||||
|
||||
var/datum/gas_mixture/cold_air = cold_circ.return_transfer_air()
|
||||
var/datum/gas_mixture/hot_air = hot_circ.return_transfer_air()
|
||||
|
||||
//log_debug("hot_air = [hot_air]; cold_air = [cold_air];")
|
||||
|
||||
if(cold_air && hot_air)
|
||||
|
||||
//log_debug("hot_air = [hot_air] temperature = [hot_air.temperature]; cold_air = [cold_air] temperature = [hot_air.temperature];")
|
||||
|
||||
//log_debug("coldair and hotair pass")
|
||||
var/cold_air_heat_capacity = cold_air.heat_capacity()
|
||||
var/hot_air_heat_capacity = hot_air.heat_capacity()
|
||||
|
||||
var/delta_temperature = hot_air.temperature - cold_air.temperature
|
||||
|
||||
//log_debug("delta_temperature = [delta_temperature]; cold_air_heat_capacity = [cold_air_heat_capacity]; hot_air_heat_capacity = [hot_air_heat_capacity]")
|
||||
|
||||
if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0)
|
||||
var/efficiency = 0.65
|
||||
|
||||
var/energy_transfer = delta_temperature * hot_air_heat_capacity * cold_air_heat_capacity / (hot_air_heat_capacity + cold_air_heat_capacity)
|
||||
|
||||
var/heat = energy_transfer * (1 - efficiency)
|
||||
lastgen = energy_transfer * efficiency
|
||||
|
||||
//log_debug("lastgen = [lastgen]; heat = [heat]; delta_temperature = [delta_temperature]; hot_air_heat_capacity = [hot_air_heat_capacity]; cold_air_heat_capacity = [cold_air_heat_capacity];")
|
||||
|
||||
hot_air.temperature = hot_air.temperature - energy_transfer / hot_air_heat_capacity
|
||||
cold_air.temperature = cold_air.temperature + heat / cold_air_heat_capacity
|
||||
|
||||
//log_debug("POWER: [lastgen] W generated at [efficiency * 100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]")
|
||||
|
||||
add_avail(lastgen)
|
||||
// update icon overlays only if displayed level has changed
|
||||
|
||||
if(hot_air)
|
||||
var/datum/gas_mixture/hot_circ_air1 = hot_circ.get_outlet_air()
|
||||
hot_circ_air1.merge(hot_air)
|
||||
|
||||
if(cold_air)
|
||||
var/datum/gas_mixture/cold_circ_air1 = cold_circ.get_outlet_air()
|
||||
cold_circ_air1.merge(cold_air)
|
||||
|
||||
var/genlev = max(0, min( round(11 * lastgen / 100000), 11))
|
||||
var/circ = "[cold_circ && cold_circ.last_pressure_delta > 0 ? "1" : "0"][hot_circ && hot_circ.last_pressure_delta > 0 ? "1" : "0"]"
|
||||
if((genlev != lastgenlev) || (circ != lastcirc))
|
||||
lastgenlev = genlev
|
||||
lastcirc = circ
|
||||
update_icon()
|
||||
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/power/generator/attack_ai(mob/user)
|
||||
return attack_hand(user)
|
||||
|
||||
/obj/machinery/power/generator/attack_ghost(mob/user)
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/generator/attack_hand(mob/user)
|
||||
if(..())
|
||||
user << browse(null, "window=teg")
|
||||
return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/generator/multitool_act(mob/user, obj/item/I)
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(cold_dir == WEST)
|
||||
cold_dir = EAST
|
||||
hot_dir = WEST
|
||||
else if(cold_dir == NORTH)
|
||||
cold_dir = SOUTH
|
||||
hot_dir = NORTH
|
||||
else if(cold_dir == EAST)
|
||||
cold_dir = WEST
|
||||
hot_dir = EAST
|
||||
else
|
||||
cold_dir = NORTH
|
||||
hot_dir = SOUTH
|
||||
connect()
|
||||
to_chat(user, "<span class='notice'>You reverse the generator's circulator settings. The cold circulator is now on the [dir2text(cold_dir)] side, and the heat circulator is now on the [dir2text(hot_dir)] side.</span>")
|
||||
update_desc()
|
||||
|
||||
/obj/machinery/power/generator/wrench_act(mob/user, obj/item/I)
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
anchored = !anchored
|
||||
if(!anchored)
|
||||
disconnect()
|
||||
power_change()
|
||||
else
|
||||
connect()
|
||||
to_chat(user, "<span class='notice'>You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.</span>")
|
||||
|
||||
/obj/machinery/power/generator/proc/get_menu(include_link = 1)
|
||||
var/t = ""
|
||||
if(!powernet)
|
||||
t += "<span class='bad'>Unable to connect to the power network!</span>"
|
||||
t += "<BR><A href='?src=[UID()];check=1'>Retry</A>"
|
||||
else if(cold_circ && hot_circ)
|
||||
var/datum/gas_mixture/cold_circ_air1 = cold_circ.get_outlet_air()
|
||||
var/datum/gas_mixture/cold_circ_air2 = cold_circ.get_inlet_air()
|
||||
var/datum/gas_mixture/hot_circ_air1 = hot_circ.get_outlet_air()
|
||||
var/datum/gas_mixture/hot_circ_air2 = hot_circ.get_inlet_air()
|
||||
|
||||
t += "<div class='statusDisplay'>"
|
||||
|
||||
t += "Output: [round(lastgen)] W"
|
||||
|
||||
t += "<BR>"
|
||||
|
||||
t += "<B><font color='blue'>Cold loop</font></B><BR>"
|
||||
t += "Temperature Inlet: [round(cold_circ_air2.temperature, 0.1)] K / Outlet: [round(cold_circ_air1.temperature, 0.1)] K<BR>"
|
||||
t += "Pressure Inlet: [round(cold_circ_air2.return_pressure(), 0.1)] kPa / Outlet: [round(cold_circ_air1.return_pressure(), 0.1)] kPa<BR>"
|
||||
|
||||
t += "<B><font color='red'>Hot loop</font></B><BR>"
|
||||
t += "Temperature Inlet: [round(hot_circ_air2.temperature, 0.1)] K / Outlet: [round(hot_circ_air1.temperature, 0.1)] K<BR>"
|
||||
t += "Pressure Inlet: [round(hot_circ_air2.return_pressure(), 0.1)] kPa / Outlet: [round(hot_circ_air1.return_pressure(), 0.1)] kPa<BR>"
|
||||
|
||||
t += "</div>"
|
||||
else
|
||||
t += "<span class='bad'>Unable to locate all parts!</span>"
|
||||
t += "<BR><A href='?src=[UID()];check=1'>Retry</A>"
|
||||
if(include_link)
|
||||
t += "<BR><A href='?src=[UID()];close=1'>Close</A>"
|
||||
|
||||
return t
|
||||
|
||||
/obj/machinery/power/generator/interact(mob/user)
|
||||
user.set_machine(src)
|
||||
|
||||
var/datum/browser/popup = new(user, "teg", "Thermo-Electric Generator", 460, 300)
|
||||
popup.set_content(get_menu())
|
||||
popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
|
||||
popup.open()
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/generator/Topic(href, href_list)
|
||||
if(..())
|
||||
return 0
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=teg")
|
||||
usr.unset_machine()
|
||||
return 0
|
||||
if( href_list["check"] )
|
||||
if(!powernet || !cold_circ || !hot_circ)
|
||||
connect()
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/generator/power_change()
|
||||
..()
|
||||
update_icon()
|
||||
/obj/machinery/power/generator
|
||||
name = "thermoelectric generator"
|
||||
desc = "It's a high efficiency thermoelectric generator."
|
||||
icon_state = "teg"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
|
||||
var/obj/machinery/atmospherics/binary/circulator/cold_circ
|
||||
var/obj/machinery/atmospherics/binary/circulator/hot_circ
|
||||
|
||||
var/cold_dir = WEST
|
||||
var/hot_dir = EAST
|
||||
|
||||
var/lastgen = 0
|
||||
var/lastgenlev = -1
|
||||
var/lastcirc = "00"
|
||||
|
||||
/obj/machinery/power/generator/New()
|
||||
..()
|
||||
update_desc()
|
||||
|
||||
/obj/machinery/power/generator/proc/update_desc()
|
||||
desc = initial(desc) + " Its cold circulator is located on the [dir2text(cold_dir)] side, and its heat circulator is located on the [dir2text(hot_dir)] side."
|
||||
|
||||
/obj/machinery/power/generator/Destroy()
|
||||
disconnect()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/generator/proc/disconnect()
|
||||
if(cold_circ)
|
||||
cold_circ.generator = null
|
||||
if(hot_circ)
|
||||
hot_circ.generator = null
|
||||
if(powernet)
|
||||
disconnect_from_network()
|
||||
|
||||
/obj/machinery/power/generator/Initialize()
|
||||
..()
|
||||
connect()
|
||||
|
||||
/obj/machinery/power/generator/proc/connect()
|
||||
connect_to_network()
|
||||
|
||||
var/obj/machinery/atmospherics/binary/circulator/circpath = /obj/machinery/atmospherics/binary/circulator
|
||||
cold_circ = locate(circpath) in get_step(src, cold_dir)
|
||||
hot_circ = locate(circpath) in get_step(src, hot_dir)
|
||||
|
||||
if(cold_circ && cold_circ.side == cold_dir)
|
||||
cold_circ.generator = src
|
||||
cold_circ.update_icon()
|
||||
else
|
||||
cold_circ = null
|
||||
|
||||
if(hot_circ && hot_circ.side == hot_dir)
|
||||
hot_circ.generator = src
|
||||
hot_circ.update_icon()
|
||||
else
|
||||
hot_circ = null
|
||||
|
||||
power_change()
|
||||
update_icon()
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/power/generator/power_change()
|
||||
if(!anchored)
|
||||
stat |= NOPOWER
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/machinery/power/generator/update_icon()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
overlays.Cut()
|
||||
else
|
||||
overlays.Cut()
|
||||
|
||||
if(lastgenlev != 0)
|
||||
overlays += image('icons/obj/power.dmi', "teg-op[lastgenlev]")
|
||||
|
||||
overlays += image('icons/obj/power.dmi', "teg-oc[lastcirc]")
|
||||
|
||||
/obj/machinery/power/generator/process()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
|
||||
if(!cold_circ || !hot_circ)
|
||||
return
|
||||
|
||||
lastgen = 0
|
||||
|
||||
if(powernet)
|
||||
|
||||
//log_debug("cold_circ and hot_circ pass")
|
||||
|
||||
var/datum/gas_mixture/cold_air = cold_circ.return_transfer_air()
|
||||
var/datum/gas_mixture/hot_air = hot_circ.return_transfer_air()
|
||||
|
||||
//log_debug("hot_air = [hot_air]; cold_air = [cold_air];")
|
||||
|
||||
if(cold_air && hot_air)
|
||||
|
||||
//log_debug("hot_air = [hot_air] temperature = [hot_air.temperature]; cold_air = [cold_air] temperature = [hot_air.temperature];")
|
||||
|
||||
//log_debug("coldair and hotair pass")
|
||||
var/cold_air_heat_capacity = cold_air.heat_capacity()
|
||||
var/hot_air_heat_capacity = hot_air.heat_capacity()
|
||||
|
||||
var/delta_temperature = hot_air.temperature - cold_air.temperature
|
||||
|
||||
//log_debug("delta_temperature = [delta_temperature]; cold_air_heat_capacity = [cold_air_heat_capacity]; hot_air_heat_capacity = [hot_air_heat_capacity]")
|
||||
|
||||
if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0)
|
||||
var/efficiency = 0.65
|
||||
|
||||
var/energy_transfer = delta_temperature * hot_air_heat_capacity * cold_air_heat_capacity / (hot_air_heat_capacity + cold_air_heat_capacity)
|
||||
|
||||
var/heat = energy_transfer * (1 - efficiency)
|
||||
lastgen = energy_transfer * efficiency
|
||||
|
||||
//log_debug("lastgen = [lastgen]; heat = [heat]; delta_temperature = [delta_temperature]; hot_air_heat_capacity = [hot_air_heat_capacity]; cold_air_heat_capacity = [cold_air_heat_capacity];")
|
||||
|
||||
hot_air.temperature = hot_air.temperature - energy_transfer / hot_air_heat_capacity
|
||||
cold_air.temperature = cold_air.temperature + heat / cold_air_heat_capacity
|
||||
|
||||
//log_debug("POWER: [lastgen] W generated at [efficiency * 100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]")
|
||||
|
||||
add_avail(lastgen)
|
||||
// update icon overlays only if displayed level has changed
|
||||
|
||||
if(hot_air)
|
||||
var/datum/gas_mixture/hot_circ_air1 = hot_circ.get_outlet_air()
|
||||
hot_circ_air1.merge(hot_air)
|
||||
|
||||
if(cold_air)
|
||||
var/datum/gas_mixture/cold_circ_air1 = cold_circ.get_outlet_air()
|
||||
cold_circ_air1.merge(cold_air)
|
||||
|
||||
var/genlev = max(0, min( round(11 * lastgen / 100000), 11))
|
||||
var/circ = "[cold_circ && cold_circ.last_pressure_delta > 0 ? "1" : "0"][hot_circ && hot_circ.last_pressure_delta > 0 ? "1" : "0"]"
|
||||
if((genlev != lastgenlev) || (circ != lastcirc))
|
||||
lastgenlev = genlev
|
||||
lastcirc = circ
|
||||
update_icon()
|
||||
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/power/generator/attack_ai(mob/user)
|
||||
return attack_hand(user)
|
||||
|
||||
/obj/machinery/power/generator/attack_ghost(mob/user)
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/generator/attack_hand(mob/user)
|
||||
if(..())
|
||||
user << browse(null, "window=teg")
|
||||
return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/generator/multitool_act(mob/user, obj/item/I)
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(cold_dir == WEST)
|
||||
cold_dir = EAST
|
||||
hot_dir = WEST
|
||||
else if(cold_dir == NORTH)
|
||||
cold_dir = SOUTH
|
||||
hot_dir = NORTH
|
||||
else if(cold_dir == EAST)
|
||||
cold_dir = WEST
|
||||
hot_dir = EAST
|
||||
else
|
||||
cold_dir = NORTH
|
||||
hot_dir = SOUTH
|
||||
connect()
|
||||
to_chat(user, "<span class='notice'>You reverse the generator's circulator settings. The cold circulator is now on the [dir2text(cold_dir)] side, and the heat circulator is now on the [dir2text(hot_dir)] side.</span>")
|
||||
update_desc()
|
||||
|
||||
/obj/machinery/power/generator/wrench_act(mob/user, obj/item/I)
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
anchored = !anchored
|
||||
if(!anchored)
|
||||
disconnect()
|
||||
power_change()
|
||||
else
|
||||
connect()
|
||||
to_chat(user, "<span class='notice'>You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.</span>")
|
||||
|
||||
/obj/machinery/power/generator/proc/get_menu(include_link = 1)
|
||||
var/t = ""
|
||||
if(!powernet)
|
||||
t += "<span class='bad'>Unable to connect to the power network!</span>"
|
||||
t += "<BR><A href='?src=[UID()];check=1'>Retry</A>"
|
||||
else if(cold_circ && hot_circ)
|
||||
var/datum/gas_mixture/cold_circ_air1 = cold_circ.get_outlet_air()
|
||||
var/datum/gas_mixture/cold_circ_air2 = cold_circ.get_inlet_air()
|
||||
var/datum/gas_mixture/hot_circ_air1 = hot_circ.get_outlet_air()
|
||||
var/datum/gas_mixture/hot_circ_air2 = hot_circ.get_inlet_air()
|
||||
|
||||
t += "<div class='statusDisplay'>"
|
||||
|
||||
t += "Output: [round(lastgen)] W"
|
||||
|
||||
t += "<BR>"
|
||||
|
||||
t += "<B><font color='blue'>Cold loop</font></B><BR>"
|
||||
t += "Temperature Inlet: [round(cold_circ_air2.temperature, 0.1)] K / Outlet: [round(cold_circ_air1.temperature, 0.1)] K<BR>"
|
||||
t += "Pressure Inlet: [round(cold_circ_air2.return_pressure(), 0.1)] kPa / Outlet: [round(cold_circ_air1.return_pressure(), 0.1)] kPa<BR>"
|
||||
|
||||
t += "<B><font color='red'>Hot loop</font></B><BR>"
|
||||
t += "Temperature Inlet: [round(hot_circ_air2.temperature, 0.1)] K / Outlet: [round(hot_circ_air1.temperature, 0.1)] K<BR>"
|
||||
t += "Pressure Inlet: [round(hot_circ_air2.return_pressure(), 0.1)] kPa / Outlet: [round(hot_circ_air1.return_pressure(), 0.1)] kPa<BR>"
|
||||
|
||||
t += "</div>"
|
||||
else
|
||||
t += "<span class='bad'>Unable to locate all parts!</span>"
|
||||
t += "<BR><A href='?src=[UID()];check=1'>Retry</A>"
|
||||
if(include_link)
|
||||
t += "<BR><A href='?src=[UID()];close=1'>Close</A>"
|
||||
|
||||
return t
|
||||
|
||||
/obj/machinery/power/generator/interact(mob/user)
|
||||
user.set_machine(src)
|
||||
|
||||
var/datum/browser/popup = new(user, "teg", "Thermo-Electric Generator", 460, 300)
|
||||
popup.set_content(get_menu())
|
||||
popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
|
||||
popup.open()
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/generator/Topic(href, href_list)
|
||||
if(..())
|
||||
return 0
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=teg")
|
||||
usr.unset_machine()
|
||||
return 0
|
||||
if( href_list["check"] )
|
||||
if(!powernet || !cold_circ || !hot_circ)
|
||||
connect()
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/generator/power_change()
|
||||
..()
|
||||
update_icon()
|
||||
|
||||
+740
-740
File diff suppressed because it is too large
Load Diff
+459
-459
@@ -1,459 +1,459 @@
|
||||
//Baseline portable generator. Has all the default handling. Not intended to be used on it's own (since it generates unlimited power).
|
||||
/obj/machinery/power/port_gen
|
||||
name = "Placeholder Generator" //seriously, don't use this. It can't be anchored without VV magic.
|
||||
desc = "A portable generator for emergency backup power"
|
||||
icon = 'icons/obj/power.dmi'
|
||||
icon_state = "portgen0_0"
|
||||
density = 1
|
||||
anchored = 0
|
||||
use_power = NO_POWER_USE
|
||||
|
||||
var/active = 0
|
||||
var/power_gen = 5000
|
||||
var/open = 0
|
||||
var/recent_fault = 0
|
||||
var/power_output = 1
|
||||
var/base_icon = "portgen0"
|
||||
|
||||
/obj/machinery/power/port_gen/proc/IsBroken()
|
||||
return (stat & (BROKEN|EMPED))
|
||||
|
||||
/obj/machinery/power/port_gen/proc/HasFuel() //Placeholder for fuel check.
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/port_gen/proc/UseFuel() //Placeholder for fuel use.
|
||||
return
|
||||
|
||||
/obj/machinery/power/port_gen/proc/DropFuel()
|
||||
return
|
||||
|
||||
/obj/machinery/power/port_gen/proc/handleInactive()
|
||||
return
|
||||
|
||||
/obj/machinery/power/port_gen/update_icon()
|
||||
icon_state = "[base_icon]_[active]"
|
||||
|
||||
/obj/machinery/power/port_gen/process()
|
||||
if(active && HasFuel() && !IsBroken() && anchored && powernet)
|
||||
add_avail(power_gen * power_output)
|
||||
UseFuel()
|
||||
else
|
||||
active = 0
|
||||
handleInactive()
|
||||
update_icon()
|
||||
|
||||
/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
|
||||
if(!anchored)
|
||||
return
|
||||
|
||||
/obj/machinery/power/port_gen/examine(mob/user)
|
||||
. = ..()
|
||||
if(!in_range(user, src))
|
||||
if(active)
|
||||
. += "<span class='notice'>The generator is on.</span>"
|
||||
else
|
||||
. += "<span class='notice'>The generator is off.</span>"
|
||||
|
||||
/obj/machinery/power/port_gen/emp_act(severity)
|
||||
var/duration = 6000 //ten minutes
|
||||
switch(severity)
|
||||
if(1)
|
||||
stat &= BROKEN
|
||||
if(prob(75)) explode()
|
||||
if(2)
|
||||
if(prob(25)) stat &= BROKEN
|
||||
if(prob(10)) explode()
|
||||
if(3)
|
||||
if(prob(10)) stat &= BROKEN
|
||||
duration = 300
|
||||
|
||||
stat |= EMPED
|
||||
if(duration)
|
||||
spawn(duration)
|
||||
stat &= ~EMPED
|
||||
|
||||
/obj/machinery/power/port_gen/proc/explode()
|
||||
explosion(src.loc, -1, 3, 5, -1)
|
||||
qdel(src)
|
||||
|
||||
#define TEMPERATURE_DIVISOR 40
|
||||
#define TEMPERATURE_CHANGE_MAX 20
|
||||
|
||||
//A power generator that runs on solid plasma sheets.
|
||||
/obj/machinery/power/port_gen/pacman
|
||||
name = "\improper P.A.C.M.A.N.-type Portable Generator"
|
||||
desc = "A power generator that runs on solid plasma sheets. Rated for 80 kW max safe output."
|
||||
|
||||
var/sheet_name = "Plasma Sheets"
|
||||
var/sheet_path = /obj/item/stack/sheet/mineral/plasma
|
||||
var/board_path = /obj/item/circuitboard/pacman
|
||||
|
||||
/*
|
||||
These values were chosen so that the generator can run safely up to 80 kW
|
||||
A full 50 plasma sheet stack should last 20 minutes at power_output = 4
|
||||
temperature_gain and max_temperature are set so that the max safe power level is 4.
|
||||
Setting to 5 or higher can only be done temporarily before the generator overheats.
|
||||
*/
|
||||
power_gen = 20000 //Watts output per power_output level
|
||||
var/max_power_output = 5 //The maximum power setting without emagging.
|
||||
var/max_safe_output = 4 // For UI use, maximal output that won't cause overheat.
|
||||
var/time_per_sheet = 96 //fuel efficiency - how long 1 sheet lasts at power level 1
|
||||
var/max_sheets = 100 //max capacity of the hopper
|
||||
var/max_temperature = 300 //max temperature before overheating increases
|
||||
var/temperature_gain = 50 //how much the temperature increases per power output level, in degrees per level
|
||||
|
||||
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
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/Initialize()
|
||||
..()
|
||||
if(anchored)
|
||||
connect_to_network()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/New()
|
||||
..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stock_parts/matter_bin(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(null)
|
||||
component_parts += new board_path(null)
|
||||
RefreshParts()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/upgraded/New()
|
||||
..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stock_parts/matter_bin/super(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser/ultra(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stock_parts/capacitor/super(null)
|
||||
component_parts += new board_path(null)
|
||||
RefreshParts()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/Destroy()
|
||||
DropFuel()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/RefreshParts()
|
||||
var/temp_rating = 0
|
||||
for(var/obj/item/stock_parts/SP in component_parts)
|
||||
if(istype(SP, /obj/item/stock_parts/matter_bin))
|
||||
max_sheets = SP.rating * SP.rating * 50
|
||||
else if(istype(SP, /obj/item/stock_parts/micro_laser) || istype(SP, /obj/item/stock_parts/capacitor))
|
||||
temp_rating += SP.rating
|
||||
|
||||
power_gen = round(initial(power_gen) * (max(2, temp_rating) / 2))
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/examine(mob/user)
|
||||
. = ..()
|
||||
. += "\The [src] appears to be producing [power_gen*power_output] W."
|
||||
. += "There [sheets == 1 ? "is" : "are"] [sheets] sheet\s left in the hopper."
|
||||
if(IsBroken())
|
||||
. += "<span class='warning'>\The [src] seems to have broken down.</span>"
|
||||
if(overheating)
|
||||
. += "<span class='danger'>\The [src] is overheating!</span>"
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/HasFuel()
|
||||
var/needed_sheets = power_output / time_per_sheet
|
||||
if(sheets >= needed_sheets - sheet_left)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//Removes one stack's worth of material from the generator.
|
||||
/obj/machinery/power/port_gen/pacman/DropFuel()
|
||||
if(sheets)
|
||||
var/obj/item/stack/sheet/mineral/S = new sheet_path(loc)
|
||||
var/amount = min(sheets, S.max_amount)
|
||||
S.amount = amount
|
||||
sheets -= amount
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/UseFuel()
|
||||
|
||||
//how much material are we using this iteration?
|
||||
var/needed_sheets = power_output / time_per_sheet
|
||||
|
||||
//HasFuel() should guarantee us that there is enough fuel left, so no need to check that
|
||||
//the only thing we need to worry about is if we are going to rollover to the next sheet
|
||||
if(needed_sheets > sheet_left)
|
||||
sheets--
|
||||
sheet_left = (1 + sheet_left) - needed_sheets
|
||||
else
|
||||
sheet_left -= needed_sheets
|
||||
|
||||
//calculate the "target" temperature range
|
||||
//This should probably depend on the external temperature somehow, but whatever.
|
||||
var/lower_limit = 56 + power_output * temperature_gain
|
||||
var/upper_limit = 76 + power_output * temperature_gain
|
||||
|
||||
/*
|
||||
Hot or cold environments can affect the equilibrium temperature
|
||||
The lower the pressure the less effect it has. I guess it cools using a radiator or something when in vacuum.
|
||||
Gives traitors more opportunities to sabotage the generator or allows enterprising engineers to build additional
|
||||
cooling in order to get more power out.
|
||||
*/
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
if(environment)
|
||||
var/ratio = min(environment.return_pressure()/ONE_ATMOSPHERE, 1)
|
||||
var/ambient = environment.temperature - T20C
|
||||
lower_limit += ambient*ratio
|
||||
upper_limit += ambient*ratio
|
||||
|
||||
var/average = (upper_limit + lower_limit)/2
|
||||
|
||||
//calculate the temperature increase
|
||||
var/bias = 0
|
||||
if(temperature < lower_limit)
|
||||
bias = min(round((average - temperature)/TEMPERATURE_DIVISOR, 1), TEMPERATURE_CHANGE_MAX)
|
||||
else if(temperature > upper_limit)
|
||||
bias = max(round((temperature - average)/TEMPERATURE_DIVISOR, 1), -TEMPERATURE_CHANGE_MAX)
|
||||
|
||||
//limit temperature increase so that it cannot raise temperature above upper_limit,
|
||||
//or if it is already above upper_limit, limit the increase to 0.
|
||||
var/inc_limit = max(upper_limit - temperature, 0)
|
||||
var/dec_limit = min(temperature - lower_limit, 0)
|
||||
temperature += between(dec_limit, rand(-7 + bias, 7 + bias), inc_limit)
|
||||
|
||||
if(temperature > max_temperature)
|
||||
overheat()
|
||||
else if(overheating > 0)
|
||||
overheating--
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/handleInactive()
|
||||
var/cooling_temperature = 20
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
if(environment)
|
||||
var/ratio = min(environment.return_pressure()/ONE_ATMOSPHERE, 1)
|
||||
var/ambient = environment.temperature - T20C
|
||||
cooling_temperature += ambient*ratio
|
||||
|
||||
if(temperature > cooling_temperature)
|
||||
var/temp_loss = (temperature - cooling_temperature)/TEMPERATURE_DIVISOR
|
||||
temp_loss = between(2, round(temp_loss, 1), TEMPERATURE_CHANGE_MAX)
|
||||
temperature = max(temperature - temp_loss, cooling_temperature)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
if(overheating)
|
||||
overheating--
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/proc/overheat()
|
||||
overheating++
|
||||
if(overheating > 60)
|
||||
explode()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/explode()
|
||||
//Vapourize all the plasma
|
||||
//When ground up in a grinder, 1 sheet produces 20 u of plasma -- Chemistry-Machinery.dm
|
||||
//1 mol = 10 u? I dunno. 1 mol of carbon is definitely bigger than a pill
|
||||
/*var/plasma = (sheets+sheet_left)*20
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
if(environment)
|
||||
environment.adjust_gas("plasma", plasma/10, temperature + T0C)*/
|
||||
|
||||
sheets = 0
|
||||
sheet_left = 0
|
||||
..()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/emag_act(var/remaining_charges, var/mob/user)
|
||||
if(active && prob(25))
|
||||
explode() //if they're foolish enough to emag while it's running
|
||||
|
||||
if(!emagged)
|
||||
emagged = 1
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/attackby(var/obj/item/O as obj, var/mob/user as mob)
|
||||
if(istype(O, sheet_path))
|
||||
var/obj/item/stack/addstack = O
|
||||
var/amount = min((max_sheets - sheets), addstack.amount)
|
||||
if(amount < 1)
|
||||
to_chat(user, "<span class='notice'>The [src.name] is full!</span>")
|
||||
return
|
||||
to_chat(user, "<span class='notice'>You add [amount] sheet\s to the [src.name].</span>")
|
||||
sheets += amount
|
||||
addstack.use(amount)
|
||||
SSnanoui.update_uis(src)
|
||||
return
|
||||
else if(!active)
|
||||
if(istype(O, /obj/item/wrench))
|
||||
|
||||
if(!anchored)
|
||||
connect_to_network()
|
||||
to_chat(user, "<span class='notice'>You secure the generator to the floor.</span>")
|
||||
else
|
||||
disconnect_from_network()
|
||||
to_chat(user, "<span class='notice'>You unsecure the generator from the floor.</span>")
|
||||
|
||||
playsound(src.loc, O.usesound, 50, 1)
|
||||
anchored = !anchored
|
||||
|
||||
else if(istype(O, /obj/item/screwdriver))
|
||||
panel_open = !panel_open
|
||||
playsound(src.loc, O.usesound, 50, 1)
|
||||
if(panel_open)
|
||||
to_chat(user, "<span class='notice'>You open the access panel.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='notice'>You close the access panel.</span>")
|
||||
else if(istype(O, /obj/item/storage/part_replacer) && panel_open)
|
||||
exchange_parts(user, O)
|
||||
return
|
||||
else if(istype(O, /obj/item/crowbar) && panel_open)
|
||||
default_deconstruction_crowbar(user, O)
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/attack_hand(mob/user as mob)
|
||||
..()
|
||||
if(!anchored)
|
||||
return
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/attack_ai(var/mob/user as mob)
|
||||
src.add_hiddenprint(user)
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/attack_ghost(var/mob/user)
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(IsBroken())
|
||||
return
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "pacman.tmpl", src.name, 500, 560)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/ui_data(mob/user, ui_key = "main", datum/topic_state/state = default_state)
|
||||
var/data[0]
|
||||
|
||||
data["active"] = active
|
||||
if(istype(user, /mob/living/silicon/ai))
|
||||
data["is_ai"] = 1
|
||||
else if(istype(user, /mob/living/silicon/robot) && !Adjacent(user))
|
||||
data["is_ai"] = 1
|
||||
else
|
||||
data["is_ai"] = 0
|
||||
|
||||
data["output_set"] = power_output
|
||||
data["output_max"] = max_power_output
|
||||
data["output_safe"] = max_safe_output
|
||||
data["output_watts"] = power_output * power_gen
|
||||
data["temperature_current"] = src.temperature
|
||||
data["temperature_max"] = src.max_temperature
|
||||
data["temperature_overheat"] = overheating
|
||||
// 1 sheet = 1000cm3?
|
||||
data["fuel_stored"] = round((sheets * 1000) + (sheet_left * 1000))
|
||||
data["fuel_capacity"] = round(max_sheets * 1000, 0.1)
|
||||
data["fuel_usage"] = active ? round((power_output / time_per_sheet) * 1000) : 0
|
||||
data["fuel_type"] = sheet_name
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
src.add_fingerprint(usr)
|
||||
if(href_list["action"])
|
||||
if(href_list["action"] == "enable")
|
||||
if(!active && HasFuel() && !IsBroken())
|
||||
active = 1
|
||||
update_icon()
|
||||
if(href_list["action"] == "disable")
|
||||
if(active)
|
||||
active = 0
|
||||
update_icon()
|
||||
if(href_list["action"] == "eject")
|
||||
if(!active)
|
||||
DropFuel()
|
||||
if(href_list["action"] == "lower_power")
|
||||
if(power_output > 1)
|
||||
power_output--
|
||||
if(href_list["action"] == "higher_power")
|
||||
if(power_output < max_power_output || (emagged && power_output < round(max_power_output*2.5)))
|
||||
power_output++
|
||||
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/super
|
||||
name = "S.U.P.E.R.P.A.C.M.A.N.-type Portable Generator"
|
||||
desc = "A power generator that utilizes uranium sheets as fuel. Can run for much longer than the standard PACMAN type generators. Rated for 80 kW max safe output."
|
||||
icon_state = "portgen1_0"
|
||||
base_icon = "portgen1"
|
||||
sheet_path = /obj/item/stack/sheet/mineral/uranium
|
||||
sheet_name = "Uranium Sheets"
|
||||
time_per_sheet = 576 //same power output, but a 50 sheet stack will last 2 hours at max safe power
|
||||
board_path = /obj/item/circuitboard/pacman/super
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/super/upgraded/New()
|
||||
..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stock_parts/matter_bin/super(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser/ultra(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stock_parts/capacitor/super(null)
|
||||
component_parts += new board_path(null)
|
||||
RefreshParts()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/super/UseFuel()
|
||||
//produces a tiny amount of radiation when in use
|
||||
if(prob(2*power_output))
|
||||
for(var/mob/living/L in range(src, 5))
|
||||
L.apply_effect(1, IRRADIATE) //should amount to ~5 rads per minute at max safe power
|
||||
..()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/super/explode()
|
||||
//a nice burst of radiation
|
||||
var/rads = 50 + (sheets + sheet_left)*1.5
|
||||
for(var/mob/living/L in range(src, 10))
|
||||
//should really fall with the square of the distance, but that makes the rads value drop too fast
|
||||
//I dunno, maybe physics works different when you live in 2D -- SM radiation also works like this, apparently
|
||||
L.apply_effect(max(20, round(rads/get_dist(L,src))), IRRADIATE)
|
||||
|
||||
explosion(src.loc, 3, 3, 5, 3)
|
||||
qdel(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 diamonds. Rated for 200 kW maximum safe output!"
|
||||
icon_state = "portgen2_0"
|
||||
base_icon = "portgen2"
|
||||
sheet_path = /obj/item/stack/sheet/mineral/diamond
|
||||
sheet_name = "Diamond Sheets"
|
||||
|
||||
//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
|
||||
power_gen = 25000 //watts
|
||||
max_power_output = 10
|
||||
max_safe_output = 8
|
||||
time_per_sheet = 576
|
||||
max_temperature = 800
|
||||
temperature_gain = 90
|
||||
board_path = /obj/item/circuitboard/pacman/mrs
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/mrs/upgraded/New()
|
||||
..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stock_parts/matter_bin/super(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser/ultra(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stock_parts/capacitor/super(null)
|
||||
component_parts += new board_path(null)
|
||||
RefreshParts()
|
||||
|
||||
/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)
|
||||
qdel(src)
|
||||
//Baseline portable generator. Has all the default handling. Not intended to be used on it's own (since it generates unlimited power).
|
||||
/obj/machinery/power/port_gen
|
||||
name = "Placeholder Generator" //seriously, don't use this. It can't be anchored without VV magic.
|
||||
desc = "A portable generator for emergency backup power"
|
||||
icon = 'icons/obj/power.dmi'
|
||||
icon_state = "portgen0_0"
|
||||
density = 1
|
||||
anchored = 0
|
||||
use_power = NO_POWER_USE
|
||||
|
||||
var/active = 0
|
||||
var/power_gen = 5000
|
||||
var/open = 0
|
||||
var/recent_fault = 0
|
||||
var/power_output = 1
|
||||
var/base_icon = "portgen0"
|
||||
|
||||
/obj/machinery/power/port_gen/proc/IsBroken()
|
||||
return (stat & (BROKEN|EMPED))
|
||||
|
||||
/obj/machinery/power/port_gen/proc/HasFuel() //Placeholder for fuel check.
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/port_gen/proc/UseFuel() //Placeholder for fuel use.
|
||||
return
|
||||
|
||||
/obj/machinery/power/port_gen/proc/DropFuel()
|
||||
return
|
||||
|
||||
/obj/machinery/power/port_gen/proc/handleInactive()
|
||||
return
|
||||
|
||||
/obj/machinery/power/port_gen/update_icon()
|
||||
icon_state = "[base_icon]_[active]"
|
||||
|
||||
/obj/machinery/power/port_gen/process()
|
||||
if(active && HasFuel() && !IsBroken() && anchored && powernet)
|
||||
add_avail(power_gen * power_output)
|
||||
UseFuel()
|
||||
else
|
||||
active = 0
|
||||
handleInactive()
|
||||
update_icon()
|
||||
|
||||
/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
|
||||
if(!anchored)
|
||||
return
|
||||
|
||||
/obj/machinery/power/port_gen/examine(mob/user)
|
||||
. = ..()
|
||||
if(!in_range(user, src))
|
||||
if(active)
|
||||
. += "<span class='notice'>The generator is on.</span>"
|
||||
else
|
||||
. += "<span class='notice'>The generator is off.</span>"
|
||||
|
||||
/obj/machinery/power/port_gen/emp_act(severity)
|
||||
var/duration = 6000 //ten minutes
|
||||
switch(severity)
|
||||
if(1)
|
||||
stat &= BROKEN
|
||||
if(prob(75)) explode()
|
||||
if(2)
|
||||
if(prob(25)) stat &= BROKEN
|
||||
if(prob(10)) explode()
|
||||
if(3)
|
||||
if(prob(10)) stat &= BROKEN
|
||||
duration = 300
|
||||
|
||||
stat |= EMPED
|
||||
if(duration)
|
||||
spawn(duration)
|
||||
stat &= ~EMPED
|
||||
|
||||
/obj/machinery/power/port_gen/proc/explode()
|
||||
explosion(src.loc, -1, 3, 5, -1)
|
||||
qdel(src)
|
||||
|
||||
#define TEMPERATURE_DIVISOR 40
|
||||
#define TEMPERATURE_CHANGE_MAX 20
|
||||
|
||||
//A power generator that runs on solid plasma sheets.
|
||||
/obj/machinery/power/port_gen/pacman
|
||||
name = "\improper P.A.C.M.A.N.-type Portable Generator"
|
||||
desc = "A power generator that runs on solid plasma sheets. Rated for 80 kW max safe output."
|
||||
|
||||
var/sheet_name = "Plasma Sheets"
|
||||
var/sheet_path = /obj/item/stack/sheet/mineral/plasma
|
||||
var/board_path = /obj/item/circuitboard/pacman
|
||||
|
||||
/*
|
||||
These values were chosen so that the generator can run safely up to 80 kW
|
||||
A full 50 plasma sheet stack should last 20 minutes at power_output = 4
|
||||
temperature_gain and max_temperature are set so that the max safe power level is 4.
|
||||
Setting to 5 or higher can only be done temporarily before the generator overheats.
|
||||
*/
|
||||
power_gen = 20000 //Watts output per power_output level
|
||||
var/max_power_output = 5 //The maximum power setting without emagging.
|
||||
var/max_safe_output = 4 // For UI use, maximal output that won't cause overheat.
|
||||
var/time_per_sheet = 96 //fuel efficiency - how long 1 sheet lasts at power level 1
|
||||
var/max_sheets = 100 //max capacity of the hopper
|
||||
var/max_temperature = 300 //max temperature before overheating increases
|
||||
var/temperature_gain = 50 //how much the temperature increases per power output level, in degrees per level
|
||||
|
||||
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
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/Initialize()
|
||||
..()
|
||||
if(anchored)
|
||||
connect_to_network()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/New()
|
||||
..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stock_parts/matter_bin(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(null)
|
||||
component_parts += new board_path(null)
|
||||
RefreshParts()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/upgraded/New()
|
||||
..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stock_parts/matter_bin/super(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser/ultra(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stock_parts/capacitor/super(null)
|
||||
component_parts += new board_path(null)
|
||||
RefreshParts()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/Destroy()
|
||||
DropFuel()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/RefreshParts()
|
||||
var/temp_rating = 0
|
||||
for(var/obj/item/stock_parts/SP in component_parts)
|
||||
if(istype(SP, /obj/item/stock_parts/matter_bin))
|
||||
max_sheets = SP.rating * SP.rating * 50
|
||||
else if(istype(SP, /obj/item/stock_parts/micro_laser) || istype(SP, /obj/item/stock_parts/capacitor))
|
||||
temp_rating += SP.rating
|
||||
|
||||
power_gen = round(initial(power_gen) * (max(2, temp_rating) / 2))
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/examine(mob/user)
|
||||
. = ..()
|
||||
. += "\The [src] appears to be producing [power_gen*power_output] W."
|
||||
. += "There [sheets == 1 ? "is" : "are"] [sheets] sheet\s left in the hopper."
|
||||
if(IsBroken())
|
||||
. += "<span class='warning'>\The [src] seems to have broken down.</span>"
|
||||
if(overheating)
|
||||
. += "<span class='danger'>\The [src] is overheating!</span>"
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/HasFuel()
|
||||
var/needed_sheets = power_output / time_per_sheet
|
||||
if(sheets >= needed_sheets - sheet_left)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//Removes one stack's worth of material from the generator.
|
||||
/obj/machinery/power/port_gen/pacman/DropFuel()
|
||||
if(sheets)
|
||||
var/obj/item/stack/sheet/mineral/S = new sheet_path(loc)
|
||||
var/amount = min(sheets, S.max_amount)
|
||||
S.amount = amount
|
||||
sheets -= amount
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/UseFuel()
|
||||
|
||||
//how much material are we using this iteration?
|
||||
var/needed_sheets = power_output / time_per_sheet
|
||||
|
||||
//HasFuel() should guarantee us that there is enough fuel left, so no need to check that
|
||||
//the only thing we need to worry about is if we are going to rollover to the next sheet
|
||||
if(needed_sheets > sheet_left)
|
||||
sheets--
|
||||
sheet_left = (1 + sheet_left) - needed_sheets
|
||||
else
|
||||
sheet_left -= needed_sheets
|
||||
|
||||
//calculate the "target" temperature range
|
||||
//This should probably depend on the external temperature somehow, but whatever.
|
||||
var/lower_limit = 56 + power_output * temperature_gain
|
||||
var/upper_limit = 76 + power_output * temperature_gain
|
||||
|
||||
/*
|
||||
Hot or cold environments can affect the equilibrium temperature
|
||||
The lower the pressure the less effect it has. I guess it cools using a radiator or something when in vacuum.
|
||||
Gives traitors more opportunities to sabotage the generator or allows enterprising engineers to build additional
|
||||
cooling in order to get more power out.
|
||||
*/
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
if(environment)
|
||||
var/ratio = min(environment.return_pressure()/ONE_ATMOSPHERE, 1)
|
||||
var/ambient = environment.temperature - T20C
|
||||
lower_limit += ambient*ratio
|
||||
upper_limit += ambient*ratio
|
||||
|
||||
var/average = (upper_limit + lower_limit)/2
|
||||
|
||||
//calculate the temperature increase
|
||||
var/bias = 0
|
||||
if(temperature < lower_limit)
|
||||
bias = min(round((average - temperature)/TEMPERATURE_DIVISOR, 1), TEMPERATURE_CHANGE_MAX)
|
||||
else if(temperature > upper_limit)
|
||||
bias = max(round((temperature - average)/TEMPERATURE_DIVISOR, 1), -TEMPERATURE_CHANGE_MAX)
|
||||
|
||||
//limit temperature increase so that it cannot raise temperature above upper_limit,
|
||||
//or if it is already above upper_limit, limit the increase to 0.
|
||||
var/inc_limit = max(upper_limit - temperature, 0)
|
||||
var/dec_limit = min(temperature - lower_limit, 0)
|
||||
temperature += between(dec_limit, rand(-7 + bias, 7 + bias), inc_limit)
|
||||
|
||||
if(temperature > max_temperature)
|
||||
overheat()
|
||||
else if(overheating > 0)
|
||||
overheating--
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/handleInactive()
|
||||
var/cooling_temperature = 20
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
if(environment)
|
||||
var/ratio = min(environment.return_pressure()/ONE_ATMOSPHERE, 1)
|
||||
var/ambient = environment.temperature - T20C
|
||||
cooling_temperature += ambient*ratio
|
||||
|
||||
if(temperature > cooling_temperature)
|
||||
var/temp_loss = (temperature - cooling_temperature)/TEMPERATURE_DIVISOR
|
||||
temp_loss = between(2, round(temp_loss, 1), TEMPERATURE_CHANGE_MAX)
|
||||
temperature = max(temperature - temp_loss, cooling_temperature)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
if(overheating)
|
||||
overheating--
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/proc/overheat()
|
||||
overheating++
|
||||
if(overheating > 60)
|
||||
explode()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/explode()
|
||||
//Vapourize all the plasma
|
||||
//When ground up in a grinder, 1 sheet produces 20 u of plasma -- Chemistry-Machinery.dm
|
||||
//1 mol = 10 u? I dunno. 1 mol of carbon is definitely bigger than a pill
|
||||
/*var/plasma = (sheets+sheet_left)*20
|
||||
var/datum/gas_mixture/environment = loc.return_air()
|
||||
if(environment)
|
||||
environment.adjust_gas("plasma", plasma/10, temperature + T0C)*/
|
||||
|
||||
sheets = 0
|
||||
sheet_left = 0
|
||||
..()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/emag_act(var/remaining_charges, var/mob/user)
|
||||
if(active && prob(25))
|
||||
explode() //if they're foolish enough to emag while it's running
|
||||
|
||||
if(!emagged)
|
||||
emagged = 1
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/attackby(var/obj/item/O as obj, var/mob/user as mob)
|
||||
if(istype(O, sheet_path))
|
||||
var/obj/item/stack/addstack = O
|
||||
var/amount = min((max_sheets - sheets), addstack.amount)
|
||||
if(amount < 1)
|
||||
to_chat(user, "<span class='notice'>The [src.name] is full!</span>")
|
||||
return
|
||||
to_chat(user, "<span class='notice'>You add [amount] sheet\s to the [src.name].</span>")
|
||||
sheets += amount
|
||||
addstack.use(amount)
|
||||
SSnanoui.update_uis(src)
|
||||
return
|
||||
else if(!active)
|
||||
if(istype(O, /obj/item/wrench))
|
||||
|
||||
if(!anchored)
|
||||
connect_to_network()
|
||||
to_chat(user, "<span class='notice'>You secure the generator to the floor.</span>")
|
||||
else
|
||||
disconnect_from_network()
|
||||
to_chat(user, "<span class='notice'>You unsecure the generator from the floor.</span>")
|
||||
|
||||
playsound(src.loc, O.usesound, 50, 1)
|
||||
anchored = !anchored
|
||||
|
||||
else if(istype(O, /obj/item/screwdriver))
|
||||
panel_open = !panel_open
|
||||
playsound(src.loc, O.usesound, 50, 1)
|
||||
if(panel_open)
|
||||
to_chat(user, "<span class='notice'>You open the access panel.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='notice'>You close the access panel.</span>")
|
||||
else if(istype(O, /obj/item/storage/part_replacer) && panel_open)
|
||||
exchange_parts(user, O)
|
||||
return
|
||||
else if(istype(O, /obj/item/crowbar) && panel_open)
|
||||
default_deconstruction_crowbar(user, O)
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/attack_hand(mob/user as mob)
|
||||
..()
|
||||
if(!anchored)
|
||||
return
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/attack_ai(var/mob/user as mob)
|
||||
src.add_hiddenprint(user)
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/attack_ghost(var/mob/user)
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(IsBroken())
|
||||
return
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "pacman.tmpl", src.name, 500, 560)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/ui_data(mob/user, ui_key = "main", datum/topic_state/state = default_state)
|
||||
var/data[0]
|
||||
|
||||
data["active"] = active
|
||||
if(istype(user, /mob/living/silicon/ai))
|
||||
data["is_ai"] = 1
|
||||
else if(istype(user, /mob/living/silicon/robot) && !Adjacent(user))
|
||||
data["is_ai"] = 1
|
||||
else
|
||||
data["is_ai"] = 0
|
||||
|
||||
data["output_set"] = power_output
|
||||
data["output_max"] = max_power_output
|
||||
data["output_safe"] = max_safe_output
|
||||
data["output_watts"] = power_output * power_gen
|
||||
data["temperature_current"] = src.temperature
|
||||
data["temperature_max"] = src.max_temperature
|
||||
data["temperature_overheat"] = overheating
|
||||
// 1 sheet = 1000cm3?
|
||||
data["fuel_stored"] = round((sheets * 1000) + (sheet_left * 1000))
|
||||
data["fuel_capacity"] = round(max_sheets * 1000, 0.1)
|
||||
data["fuel_usage"] = active ? round((power_output / time_per_sheet) * 1000) : 0
|
||||
data["fuel_type"] = sheet_name
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
src.add_fingerprint(usr)
|
||||
if(href_list["action"])
|
||||
if(href_list["action"] == "enable")
|
||||
if(!active && HasFuel() && !IsBroken())
|
||||
active = 1
|
||||
update_icon()
|
||||
if(href_list["action"] == "disable")
|
||||
if(active)
|
||||
active = 0
|
||||
update_icon()
|
||||
if(href_list["action"] == "eject")
|
||||
if(!active)
|
||||
DropFuel()
|
||||
if(href_list["action"] == "lower_power")
|
||||
if(power_output > 1)
|
||||
power_output--
|
||||
if(href_list["action"] == "higher_power")
|
||||
if(power_output < max_power_output || (emagged && power_output < round(max_power_output*2.5)))
|
||||
power_output++
|
||||
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/super
|
||||
name = "S.U.P.E.R.P.A.C.M.A.N.-type Portable Generator"
|
||||
desc = "A power generator that utilizes uranium sheets as fuel. Can run for much longer than the standard PACMAN type generators. Rated for 80 kW max safe output."
|
||||
icon_state = "portgen1_0"
|
||||
base_icon = "portgen1"
|
||||
sheet_path = /obj/item/stack/sheet/mineral/uranium
|
||||
sheet_name = "Uranium Sheets"
|
||||
time_per_sheet = 576 //same power output, but a 50 sheet stack will last 2 hours at max safe power
|
||||
board_path = /obj/item/circuitboard/pacman/super
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/super/upgraded/New()
|
||||
..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stock_parts/matter_bin/super(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser/ultra(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stock_parts/capacitor/super(null)
|
||||
component_parts += new board_path(null)
|
||||
RefreshParts()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/super/UseFuel()
|
||||
//produces a tiny amount of radiation when in use
|
||||
if(prob(2*power_output))
|
||||
for(var/mob/living/L in range(src, 5))
|
||||
L.apply_effect(1, IRRADIATE) //should amount to ~5 rads per minute at max safe power
|
||||
..()
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/super/explode()
|
||||
//a nice burst of radiation
|
||||
var/rads = 50 + (sheets + sheet_left)*1.5
|
||||
for(var/mob/living/L in range(src, 10))
|
||||
//should really fall with the square of the distance, but that makes the rads value drop too fast
|
||||
//I dunno, maybe physics works different when you live in 2D -- SM radiation also works like this, apparently
|
||||
L.apply_effect(max(20, round(rads/get_dist(L,src))), IRRADIATE)
|
||||
|
||||
explosion(src.loc, 3, 3, 5, 3)
|
||||
qdel(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 diamonds. Rated for 200 kW maximum safe output!"
|
||||
icon_state = "portgen2_0"
|
||||
base_icon = "portgen2"
|
||||
sheet_path = /obj/item/stack/sheet/mineral/diamond
|
||||
sheet_name = "Diamond Sheets"
|
||||
|
||||
//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
|
||||
power_gen = 25000 //watts
|
||||
max_power_output = 10
|
||||
max_safe_output = 8
|
||||
time_per_sheet = 576
|
||||
max_temperature = 800
|
||||
temperature_gain = 90
|
||||
board_path = /obj/item/circuitboard/pacman/mrs
|
||||
|
||||
/obj/machinery/power/port_gen/pacman/mrs/upgraded/New()
|
||||
..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/stock_parts/matter_bin/super(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser/ultra(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 1)
|
||||
component_parts += new /obj/item/stock_parts/capacitor/super(null)
|
||||
component_parts += new board_path(null)
|
||||
RefreshParts()
|
||||
|
||||
/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)
|
||||
qdel(src)
|
||||
|
||||
+380
-380
@@ -1,380 +1,380 @@
|
||||
//////////////////////////////
|
||||
// POWER MACHINERY BASE CLASS
|
||||
//////////////////////////////
|
||||
|
||||
/////////////////////////////
|
||||
// Definitions
|
||||
/////////////////////////////
|
||||
|
||||
/obj/machinery/power
|
||||
name = null
|
||||
icon = 'icons/obj/power.dmi'
|
||||
anchored = TRUE
|
||||
on_blueprints = TRUE
|
||||
var/datum/powernet/powernet = null
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 0
|
||||
|
||||
/obj/machinery/power/Destroy()
|
||||
disconnect_from_network()
|
||||
return ..()
|
||||
|
||||
///////////////////////////////
|
||||
// General procedures
|
||||
//////////////////////////////
|
||||
|
||||
// common helper procs for all power machines
|
||||
// All power generation handled in add_avail()
|
||||
// Machines should use add_load(), surplus(), avail()
|
||||
// Non-machines should use add_delayedload(), delayed_surplus(), newavail()
|
||||
|
||||
/obj/machinery/power/proc/add_avail(amount)
|
||||
if(powernet)
|
||||
powernet.newavail += amount
|
||||
return TRUE
|
||||
else
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/power/proc/add_load(amount)
|
||||
if(powernet)
|
||||
powernet.load += amount
|
||||
|
||||
/obj/machinery/power/proc/surplus()
|
||||
if(powernet)
|
||||
return Clamp(powernet.avail-powernet.load, 0, powernet.avail)
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/avail()
|
||||
if(powernet)
|
||||
return powernet.avail
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/add_delayedload(amount)
|
||||
if(powernet)
|
||||
powernet.delayedload += amount
|
||||
|
||||
/obj/machinery/power/proc/delayed_surplus()
|
||||
if(powernet)
|
||||
return Clamp(powernet.newavail - powernet.delayedload, 0, powernet.newavail)
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/newavail()
|
||||
if(powernet)
|
||||
return powernet.newavail
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/disconnect_terminal() // machines without a terminal will just return, no harm no fowl.
|
||||
return
|
||||
|
||||
// returns true if the area has power on given channel (or doesn't require power).
|
||||
// defaults to power_channel
|
||||
/obj/machinery/proc/powered(var/chan = -1) // defaults to power_channel
|
||||
if(!loc)
|
||||
return FALSE
|
||||
if(!use_power)
|
||||
return TRUE
|
||||
|
||||
var/area/A = get_area(src) // make sure it's in an area
|
||||
if(!A)
|
||||
return FALSE // if not, then not powered
|
||||
if(chan == -1)
|
||||
chan = power_channel
|
||||
return A.powered(chan) // return power status of the area
|
||||
|
||||
// increment the power usage stats for an area
|
||||
/obj/machinery/proc/use_power(amount, chan = -1) // defaults to power_channel
|
||||
var/area/A = get_area(src) // make sure it's in an area
|
||||
if(!A)
|
||||
return
|
||||
if(chan == -1)
|
||||
chan = power_channel
|
||||
A.use_power(amount, chan)
|
||||
|
||||
/obj/machinery/proc/addStaticPower(value, powerchannel)
|
||||
var/area/A = get_area(src)
|
||||
if(!A)
|
||||
return
|
||||
A.addStaticPower(value, powerchannel)
|
||||
|
||||
/obj/machinery/proc/removeStaticPower(value, powerchannel)
|
||||
addStaticPower(-value, powerchannel)
|
||||
|
||||
/obj/machinery/proc/power_change() // called whenever the power settings of the containing area change
|
||||
// by default, check equipment channel & set flag
|
||||
// can override if needed
|
||||
if(powered(power_channel))
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
|
||||
stat |= NOPOWER
|
||||
return
|
||||
|
||||
// connect the machine to a powernet if a node cable is present on the turf
|
||||
/obj/machinery/power/proc/connect_to_network()
|
||||
var/turf/T = src.loc
|
||||
if(!T || !istype(T))
|
||||
return FALSE
|
||||
|
||||
var/obj/structure/cable/C = T.get_cable_node() //check if we have a node cable on the machine turf, the first found is picked
|
||||
if(!C || !C.powernet)
|
||||
return FALSE
|
||||
|
||||
C.powernet.add_machine(src)
|
||||
return TRUE
|
||||
|
||||
// remove and disconnect the machine from its current powernet
|
||||
/obj/machinery/power/proc/disconnect_from_network()
|
||||
if(!powernet)
|
||||
return FALSE
|
||||
powernet.remove_machine(src)
|
||||
return TRUE
|
||||
|
||||
// attach a wire to a power machine - leads from the turf you are standing on
|
||||
//almost never called, overwritten by all power machines but terminal and generator
|
||||
/obj/machinery/power/attackby(obj/item/I, mob/user, params)
|
||||
if(istype(I, /obj/item/stack/cable_coil))
|
||||
var/obj/item/stack/cable_coil/coil = I
|
||||
var/turf/T = user.loc
|
||||
if(T.intact || !isfloorturf(T))
|
||||
return
|
||||
if(get_dist(src, user) > 1)
|
||||
return
|
||||
coil.place_turf(T, user)
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Powernet handling helpers
|
||||
//////////////////////////////////////////
|
||||
|
||||
//returns all the cables WITHOUT a powernet in neighbors turfs,
|
||||
//pointing towards the turf the machine is located at
|
||||
/obj/machinery/power/proc/get_connections()
|
||||
|
||||
. = list()
|
||||
|
||||
var/cdir
|
||||
var/turf/T
|
||||
|
||||
for(var/card in cardinal)
|
||||
T = get_step(loc,card)
|
||||
cdir = get_dir(T,loc)
|
||||
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.powernet)
|
||||
continue
|
||||
if(C.d1 == cdir || C.d2 == cdir)
|
||||
. += C
|
||||
return .
|
||||
|
||||
//returns all the cables in neighbors turfs,
|
||||
//pointing towards the turf the machine is located at
|
||||
/obj/machinery/power/proc/get_marked_connections()
|
||||
|
||||
. = list()
|
||||
|
||||
var/cdir
|
||||
var/turf/T
|
||||
|
||||
for(var/card in cardinal)
|
||||
T = get_step(loc,card)
|
||||
cdir = get_dir(T,loc)
|
||||
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == cdir || C.d2 == cdir)
|
||||
. += C
|
||||
return .
|
||||
|
||||
//returns all the NODES (O-X) cables WITHOUT a powernet in the turf the machine is located at
|
||||
/obj/machinery/power/proc/get_indirect_connections()
|
||||
. = list()
|
||||
for(var/obj/structure/cable/C in loc)
|
||||
if(C.powernet)
|
||||
continue
|
||||
if(C.d1 == 0) // the cable is a node cable
|
||||
. += C
|
||||
return .
|
||||
|
||||
///////////////////////////////////////////
|
||||
// GLOBAL PROCS for powernets handling
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
// returns a list of all power-related objects (nodes, cable, junctions) in turf,
|
||||
// excluding source, that match the direction d
|
||||
// if unmarked==1, only return those with no powernet
|
||||
/proc/power_list(turf/T, source, d, unmarked=0, cable_only = 0)
|
||||
. = list()
|
||||
|
||||
for(var/AM in T)
|
||||
if(AM == source)
|
||||
continue //we don't want to return source
|
||||
|
||||
if(!cable_only && istype(AM, /obj/machinery/power))
|
||||
var/obj/machinery/power/P = AM
|
||||
if(P.powernet == 0)
|
||||
continue // exclude APCs which have powernet=0
|
||||
|
||||
if(!unmarked || !P.powernet) //if unmarked=1 we only return things with no powernet
|
||||
if(d == 0)
|
||||
. += P
|
||||
|
||||
else if(istype(AM, /obj/structure/cable))
|
||||
var/obj/structure/cable/C = AM
|
||||
|
||||
if(!unmarked || !C.powernet)
|
||||
if(C.d1 == d || C.d2 == d)
|
||||
. += C
|
||||
return .
|
||||
|
||||
//remove the old powernet and replace it with a new one throughout the network.
|
||||
/proc/propagate_network(obj/O, datum/powernet/PN)
|
||||
var/list/worklist = list()
|
||||
var/list/found_machines = list()
|
||||
var/index = 1
|
||||
var/obj/P = null
|
||||
|
||||
worklist+=O //start propagating from the passed object
|
||||
|
||||
while(index<=worklist.len) //until we've exhausted all power objects
|
||||
P = worklist[index] //get the next power object found
|
||||
index++
|
||||
|
||||
if(istype(P, /obj/structure/cable))
|
||||
var/obj/structure/cable/C = P
|
||||
if(C.powernet != PN) //add it to the powernet, if it isn't already there
|
||||
PN.add_cable(C)
|
||||
worklist |= C.get_connections() //get adjacents power objects, with or without a powernet
|
||||
|
||||
else if(P.anchored && istype(P, /obj/machinery/power))
|
||||
var/obj/machinery/power/M = P
|
||||
found_machines |= M //we wait until the powernet is fully propagates to connect the machines
|
||||
|
||||
else
|
||||
continue
|
||||
|
||||
//now that the powernet is set, connect found machines to it
|
||||
for(var/obj/machinery/power/PM in found_machines)
|
||||
if(!PM.connect_to_network()) //couldn't find a node on its turf...
|
||||
PM.disconnect_from_network() //... so disconnect if already on a powernet
|
||||
|
||||
|
||||
//Merge two powernets, the bigger (in cable length term) absorbing the other
|
||||
/proc/merge_powernets(datum/powernet/net1, datum/powernet/net2)
|
||||
if(!net1 || !net2) //if one of the powernet doesn't exist, return
|
||||
return
|
||||
|
||||
if(net1 == net2) //don't merge same powernets
|
||||
return
|
||||
|
||||
//We assume net1 is larger. If net2 is in fact larger we are just going to make them switch places to reduce on code.
|
||||
if(net1.cables.len < net2.cables.len) //net2 is larger than net1. Let's switch them around
|
||||
var/temp = net1
|
||||
net1 = net2
|
||||
net2 = temp
|
||||
|
||||
//merge net2 into net1
|
||||
for(var/obj/structure/cable/Cable in net2.cables) //merge cables
|
||||
net1.add_cable(Cable)
|
||||
|
||||
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
|
||||
|
||||
return net1
|
||||
|
||||
//Determines how strong could be shock, deals damage to mob, uses power.
|
||||
//M is a mob who touched wire/whatever
|
||||
//power_source is a source of electricity, can be powercell, area, apc, cable, powernet or null
|
||||
//source is an object caused electrocuting (airlock, grille, etc)
|
||||
//No animations will be performed by this proc.
|
||||
/proc/electrocute_mob(mob/living/M, power_source, obj/source, siemens_coeff = 1, dist_check = FALSE)
|
||||
if(!M || ismecha(M.loc))
|
||||
return FALSE //feckin mechs are dumb
|
||||
if(dist_check)
|
||||
if(!in_range(source, M))
|
||||
return FALSE
|
||||
if(ishuman(M))
|
||||
var/mob/living/carbon/human/H = M
|
||||
if(H.gloves)
|
||||
var/obj/item/clothing/gloves/G = H.gloves
|
||||
if(G.siemens_coefficient == 0)
|
||||
return FALSE //to avoid spamming with insulated glvoes on
|
||||
|
||||
var/area/source_area
|
||||
if(istype(power_source, /area))
|
||||
source_area = power_source
|
||||
power_source = source_area.get_apc()
|
||||
if(istype(power_source, /obj/structure/cable))
|
||||
var/obj/structure/cable/Cable = power_source
|
||||
power_source = Cable.powernet
|
||||
|
||||
var/datum/powernet/PN
|
||||
var/obj/item/stock_parts/cell/cell
|
||||
|
||||
if(istype(power_source, /datum/powernet))
|
||||
PN = power_source
|
||||
else if(istype(power_source, /obj/item/stock_parts/cell))
|
||||
cell = power_source
|
||||
else if(istype(power_source, /obj/machinery/power/apc))
|
||||
var/obj/machinery/power/apc/apc = power_source
|
||||
cell = apc.cell
|
||||
if(apc.terminal)
|
||||
PN = apc.terminal.powernet
|
||||
else if(!power_source)
|
||||
return 0
|
||||
else
|
||||
log_admin("ERROR: /proc/electrocute_mob([M], [power_source], [source]): wrong power_source")
|
||||
return 0
|
||||
if(!cell && !PN)
|
||||
return 0
|
||||
var/PN_damage = 0
|
||||
var/cell_damage = 0
|
||||
if(PN)
|
||||
PN_damage = PN.get_electrocute_damage()
|
||||
if(cell)
|
||||
cell_damage = cell.get_electrocute_damage()
|
||||
var/shock_damage = 0
|
||||
if(PN_damage >= cell_damage)
|
||||
power_source = PN
|
||||
shock_damage = PN_damage
|
||||
else
|
||||
power_source = cell
|
||||
shock_damage = cell_damage
|
||||
var/drained_hp = M.electrocute_act(shock_damage, source, siemens_coeff) //zzzzzzap!
|
||||
var/drained_energy = drained_hp*20
|
||||
|
||||
if(source_area)
|
||||
source_area.use_power(drained_energy/GLOB.CELLRATE)
|
||||
else if(istype(power_source, /datum/powernet))
|
||||
var/drained_power = drained_energy/GLOB.CELLRATE //convert from "joules" to "watts"
|
||||
PN.delayedload += (min(drained_power, max(PN.newavail - PN.delayedload, 0)))
|
||||
else if (istype(power_source, /obj/item/stock_parts/cell))
|
||||
cell.use(drained_energy)
|
||||
return drained_energy
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Misc.
|
||||
///////////////////////////////////////////////
|
||||
|
||||
|
||||
// return a knot cable (O-X) if one is present in the turf
|
||||
// null if there's none
|
||||
/turf/proc/get_cable_node()
|
||||
if(!can_have_cabling())
|
||||
return null
|
||||
for(var/obj/structure/cable/C in src)
|
||||
if(C.d1 == 0)
|
||||
return C
|
||||
return null
|
||||
|
||||
/area/proc/get_apc()
|
||||
for(var/obj/machinery/power/apc/APC in GLOB.apcs)
|
||||
if(APC.area == src)
|
||||
return APC
|
||||
//////////////////////////////
|
||||
// POWER MACHINERY BASE CLASS
|
||||
//////////////////////////////
|
||||
|
||||
/////////////////////////////
|
||||
// Definitions
|
||||
/////////////////////////////
|
||||
|
||||
/obj/machinery/power
|
||||
name = null
|
||||
icon = 'icons/obj/power.dmi'
|
||||
anchored = TRUE
|
||||
on_blueprints = TRUE
|
||||
var/datum/powernet/powernet = null
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 0
|
||||
|
||||
/obj/machinery/power/Destroy()
|
||||
disconnect_from_network()
|
||||
return ..()
|
||||
|
||||
///////////////////////////////
|
||||
// General procedures
|
||||
//////////////////////////////
|
||||
|
||||
// common helper procs for all power machines
|
||||
// All power generation handled in add_avail()
|
||||
// Machines should use add_load(), surplus(), avail()
|
||||
// Non-machines should use add_delayedload(), delayed_surplus(), newavail()
|
||||
|
||||
/obj/machinery/power/proc/add_avail(amount)
|
||||
if(powernet)
|
||||
powernet.newavail += amount
|
||||
return TRUE
|
||||
else
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/power/proc/add_load(amount)
|
||||
if(powernet)
|
||||
powernet.load += amount
|
||||
|
||||
/obj/machinery/power/proc/surplus()
|
||||
if(powernet)
|
||||
return Clamp(powernet.avail-powernet.load, 0, powernet.avail)
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/avail()
|
||||
if(powernet)
|
||||
return powernet.avail
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/add_delayedload(amount)
|
||||
if(powernet)
|
||||
powernet.delayedload += amount
|
||||
|
||||
/obj/machinery/power/proc/delayed_surplus()
|
||||
if(powernet)
|
||||
return Clamp(powernet.newavail - powernet.delayedload, 0, powernet.newavail)
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/newavail()
|
||||
if(powernet)
|
||||
return powernet.newavail
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/disconnect_terminal() // machines without a terminal will just return, no harm no fowl.
|
||||
return
|
||||
|
||||
// returns true if the area has power on given channel (or doesn't require power).
|
||||
// defaults to power_channel
|
||||
/obj/machinery/proc/powered(var/chan = -1) // defaults to power_channel
|
||||
if(!loc)
|
||||
return FALSE
|
||||
if(!use_power)
|
||||
return TRUE
|
||||
|
||||
var/area/A = get_area(src) // make sure it's in an area
|
||||
if(!A)
|
||||
return FALSE // if not, then not powered
|
||||
if(chan == -1)
|
||||
chan = power_channel
|
||||
return A.powered(chan) // return power status of the area
|
||||
|
||||
// increment the power usage stats for an area
|
||||
/obj/machinery/proc/use_power(amount, chan = -1) // defaults to power_channel
|
||||
var/area/A = get_area(src) // make sure it's in an area
|
||||
if(!A)
|
||||
return
|
||||
if(chan == -1)
|
||||
chan = power_channel
|
||||
A.use_power(amount, chan)
|
||||
|
||||
/obj/machinery/proc/addStaticPower(value, powerchannel)
|
||||
var/area/A = get_area(src)
|
||||
if(!A)
|
||||
return
|
||||
A.addStaticPower(value, powerchannel)
|
||||
|
||||
/obj/machinery/proc/removeStaticPower(value, powerchannel)
|
||||
addStaticPower(-value, powerchannel)
|
||||
|
||||
/obj/machinery/proc/power_change() // called whenever the power settings of the containing area change
|
||||
// by default, check equipment channel & set flag
|
||||
// can override if needed
|
||||
if(powered(power_channel))
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
|
||||
stat |= NOPOWER
|
||||
return
|
||||
|
||||
// connect the machine to a powernet if a node cable is present on the turf
|
||||
/obj/machinery/power/proc/connect_to_network()
|
||||
var/turf/T = src.loc
|
||||
if(!T || !istype(T))
|
||||
return FALSE
|
||||
|
||||
var/obj/structure/cable/C = T.get_cable_node() //check if we have a node cable on the machine turf, the first found is picked
|
||||
if(!C || !C.powernet)
|
||||
return FALSE
|
||||
|
||||
C.powernet.add_machine(src)
|
||||
return TRUE
|
||||
|
||||
// remove and disconnect the machine from its current powernet
|
||||
/obj/machinery/power/proc/disconnect_from_network()
|
||||
if(!powernet)
|
||||
return FALSE
|
||||
powernet.remove_machine(src)
|
||||
return TRUE
|
||||
|
||||
// attach a wire to a power machine - leads from the turf you are standing on
|
||||
//almost never called, overwritten by all power machines but terminal and generator
|
||||
/obj/machinery/power/attackby(obj/item/I, mob/user, params)
|
||||
if(istype(I, /obj/item/stack/cable_coil))
|
||||
var/obj/item/stack/cable_coil/coil = I
|
||||
var/turf/T = user.loc
|
||||
if(T.intact || !isfloorturf(T))
|
||||
return
|
||||
if(get_dist(src, user) > 1)
|
||||
return
|
||||
coil.place_turf(T, user)
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Powernet handling helpers
|
||||
//////////////////////////////////////////
|
||||
|
||||
//returns all the cables WITHOUT a powernet in neighbors turfs,
|
||||
//pointing towards the turf the machine is located at
|
||||
/obj/machinery/power/proc/get_connections()
|
||||
|
||||
. = list()
|
||||
|
||||
var/cdir
|
||||
var/turf/T
|
||||
|
||||
for(var/card in cardinal)
|
||||
T = get_step(loc,card)
|
||||
cdir = get_dir(T,loc)
|
||||
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.powernet)
|
||||
continue
|
||||
if(C.d1 == cdir || C.d2 == cdir)
|
||||
. += C
|
||||
return .
|
||||
|
||||
//returns all the cables in neighbors turfs,
|
||||
//pointing towards the turf the machine is located at
|
||||
/obj/machinery/power/proc/get_marked_connections()
|
||||
|
||||
. = list()
|
||||
|
||||
var/cdir
|
||||
var/turf/T
|
||||
|
||||
for(var/card in cardinal)
|
||||
T = get_step(loc,card)
|
||||
cdir = get_dir(T,loc)
|
||||
|
||||
for(var/obj/structure/cable/C in T)
|
||||
if(C.d1 == cdir || C.d2 == cdir)
|
||||
. += C
|
||||
return .
|
||||
|
||||
//returns all the NODES (O-X) cables WITHOUT a powernet in the turf the machine is located at
|
||||
/obj/machinery/power/proc/get_indirect_connections()
|
||||
. = list()
|
||||
for(var/obj/structure/cable/C in loc)
|
||||
if(C.powernet)
|
||||
continue
|
||||
if(C.d1 == 0) // the cable is a node cable
|
||||
. += C
|
||||
return .
|
||||
|
||||
///////////////////////////////////////////
|
||||
// GLOBAL PROCS for powernets handling
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
// returns a list of all power-related objects (nodes, cable, junctions) in turf,
|
||||
// excluding source, that match the direction d
|
||||
// if unmarked==1, only return those with no powernet
|
||||
/proc/power_list(turf/T, source, d, unmarked=0, cable_only = 0)
|
||||
. = list()
|
||||
|
||||
for(var/AM in T)
|
||||
if(AM == source)
|
||||
continue //we don't want to return source
|
||||
|
||||
if(!cable_only && istype(AM, /obj/machinery/power))
|
||||
var/obj/machinery/power/P = AM
|
||||
if(P.powernet == 0)
|
||||
continue // exclude APCs which have powernet=0
|
||||
|
||||
if(!unmarked || !P.powernet) //if unmarked=1 we only return things with no powernet
|
||||
if(d == 0)
|
||||
. += P
|
||||
|
||||
else if(istype(AM, /obj/structure/cable))
|
||||
var/obj/structure/cable/C = AM
|
||||
|
||||
if(!unmarked || !C.powernet)
|
||||
if(C.d1 == d || C.d2 == d)
|
||||
. += C
|
||||
return .
|
||||
|
||||
//remove the old powernet and replace it with a new one throughout the network.
|
||||
/proc/propagate_network(obj/O, datum/powernet/PN)
|
||||
var/list/worklist = list()
|
||||
var/list/found_machines = list()
|
||||
var/index = 1
|
||||
var/obj/P = null
|
||||
|
||||
worklist+=O //start propagating from the passed object
|
||||
|
||||
while(index<=worklist.len) //until we've exhausted all power objects
|
||||
P = worklist[index] //get the next power object found
|
||||
index++
|
||||
|
||||
if(istype(P, /obj/structure/cable))
|
||||
var/obj/structure/cable/C = P
|
||||
if(C.powernet != PN) //add it to the powernet, if it isn't already there
|
||||
PN.add_cable(C)
|
||||
worklist |= C.get_connections() //get adjacents power objects, with or without a powernet
|
||||
|
||||
else if(P.anchored && istype(P, /obj/machinery/power))
|
||||
var/obj/machinery/power/M = P
|
||||
found_machines |= M //we wait until the powernet is fully propagates to connect the machines
|
||||
|
||||
else
|
||||
continue
|
||||
|
||||
//now that the powernet is set, connect found machines to it
|
||||
for(var/obj/machinery/power/PM in found_machines)
|
||||
if(!PM.connect_to_network()) //couldn't find a node on its turf...
|
||||
PM.disconnect_from_network() //... so disconnect if already on a powernet
|
||||
|
||||
|
||||
//Merge two powernets, the bigger (in cable length term) absorbing the other
|
||||
/proc/merge_powernets(datum/powernet/net1, datum/powernet/net2)
|
||||
if(!net1 || !net2) //if one of the powernet doesn't exist, return
|
||||
return
|
||||
|
||||
if(net1 == net2) //don't merge same powernets
|
||||
return
|
||||
|
||||
//We assume net1 is larger. If net2 is in fact larger we are just going to make them switch places to reduce on code.
|
||||
if(net1.cables.len < net2.cables.len) //net2 is larger than net1. Let's switch them around
|
||||
var/temp = net1
|
||||
net1 = net2
|
||||
net2 = temp
|
||||
|
||||
//merge net2 into net1
|
||||
for(var/obj/structure/cable/Cable in net2.cables) //merge cables
|
||||
net1.add_cable(Cable)
|
||||
|
||||
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
|
||||
|
||||
return net1
|
||||
|
||||
//Determines how strong could be shock, deals damage to mob, uses power.
|
||||
//M is a mob who touched wire/whatever
|
||||
//power_source is a source of electricity, can be powercell, area, apc, cable, powernet or null
|
||||
//source is an object caused electrocuting (airlock, grille, etc)
|
||||
//No animations will be performed by this proc.
|
||||
/proc/electrocute_mob(mob/living/M, power_source, obj/source, siemens_coeff = 1, dist_check = FALSE)
|
||||
if(!M || ismecha(M.loc))
|
||||
return FALSE //feckin mechs are dumb
|
||||
if(dist_check)
|
||||
if(!in_range(source, M))
|
||||
return FALSE
|
||||
if(ishuman(M))
|
||||
var/mob/living/carbon/human/H = M
|
||||
if(H.gloves)
|
||||
var/obj/item/clothing/gloves/G = H.gloves
|
||||
if(G.siemens_coefficient == 0)
|
||||
return FALSE //to avoid spamming with insulated glvoes on
|
||||
|
||||
var/area/source_area
|
||||
if(istype(power_source, /area))
|
||||
source_area = power_source
|
||||
power_source = source_area.get_apc()
|
||||
if(istype(power_source, /obj/structure/cable))
|
||||
var/obj/structure/cable/Cable = power_source
|
||||
power_source = Cable.powernet
|
||||
|
||||
var/datum/powernet/PN
|
||||
var/obj/item/stock_parts/cell/cell
|
||||
|
||||
if(istype(power_source, /datum/powernet))
|
||||
PN = power_source
|
||||
else if(istype(power_source, /obj/item/stock_parts/cell))
|
||||
cell = power_source
|
||||
else if(istype(power_source, /obj/machinery/power/apc))
|
||||
var/obj/machinery/power/apc/apc = power_source
|
||||
cell = apc.cell
|
||||
if(apc.terminal)
|
||||
PN = apc.terminal.powernet
|
||||
else if(!power_source)
|
||||
return 0
|
||||
else
|
||||
log_admin("ERROR: /proc/electrocute_mob([M], [power_source], [source]): wrong power_source")
|
||||
return 0
|
||||
if(!cell && !PN)
|
||||
return 0
|
||||
var/PN_damage = 0
|
||||
var/cell_damage = 0
|
||||
if(PN)
|
||||
PN_damage = PN.get_electrocute_damage()
|
||||
if(cell)
|
||||
cell_damage = cell.get_electrocute_damage()
|
||||
var/shock_damage = 0
|
||||
if(PN_damage >= cell_damage)
|
||||
power_source = PN
|
||||
shock_damage = PN_damage
|
||||
else
|
||||
power_source = cell
|
||||
shock_damage = cell_damage
|
||||
var/drained_hp = M.electrocute_act(shock_damage, source, siemens_coeff) //zzzzzzap!
|
||||
var/drained_energy = drained_hp*20
|
||||
|
||||
if(source_area)
|
||||
source_area.use_power(drained_energy/GLOB.CELLRATE)
|
||||
else if(istype(power_source, /datum/powernet))
|
||||
var/drained_power = drained_energy/GLOB.CELLRATE //convert from "joules" to "watts"
|
||||
PN.delayedload += (min(drained_power, max(PN.newavail - PN.delayedload, 0)))
|
||||
else if (istype(power_source, /obj/item/stock_parts/cell))
|
||||
cell.use(drained_energy)
|
||||
return drained_energy
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Misc.
|
||||
///////////////////////////////////////////////
|
||||
|
||||
|
||||
// return a knot cable (O-X) if one is present in the turf
|
||||
// null if there's none
|
||||
/turf/proc/get_cable_node()
|
||||
if(!can_have_cabling())
|
||||
return null
|
||||
for(var/obj/structure/cable/C in src)
|
||||
if(C.d1 == 0)
|
||||
return C
|
||||
return null
|
||||
|
||||
/area/proc/get_apc()
|
||||
for(var/obj/machinery/power/apc/APC in GLOB.apcs)
|
||||
if(APC.area == src)
|
||||
return APC
|
||||
|
||||
@@ -99,4 +99,4 @@
|
||||
if(avail >= 1000)
|
||||
return Clamp(20 + round(avail / 25000), 20, 195) + rand(-5, 5)
|
||||
else
|
||||
return 0
|
||||
return 0
|
||||
|
||||
@@ -1,148 +1,148 @@
|
||||
var/global/list/rad_collectors = list()
|
||||
|
||||
/obj/machinery/power/rad_collector
|
||||
name = "Radiation Collector Array"
|
||||
desc = "A device which uses Hawking Radiation and plasma to produce power."
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "ca"
|
||||
anchored = 0
|
||||
density = 1
|
||||
req_access = list(ACCESS_ENGINE_EQUIP)
|
||||
// use_power = NO_POWER_USE
|
||||
max_integrity = 350
|
||||
integrity_failure = 80
|
||||
var/obj/item/tank/plasma/P = null
|
||||
var/last_power = 0
|
||||
var/active = 0
|
||||
var/locked = 0
|
||||
var/drainratio = 1
|
||||
|
||||
/obj/machinery/power/rad_collector/Initialize(mapload)
|
||||
. = ..()
|
||||
rad_collectors += src
|
||||
|
||||
/obj/machinery/power/rad_collector/Destroy()
|
||||
rad_collectors -= src
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/rad_collector/process()
|
||||
if(P)
|
||||
if(P.air_contents.toxins <= 0)
|
||||
investigate_log("<font color='red'>out of fuel</font>.","singulo")
|
||||
P.air_contents.toxins = 0
|
||||
eject()
|
||||
else
|
||||
P.air_contents.toxins -= 0.001*drainratio
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/attack_hand(mob/user as mob)
|
||||
if(anchored)
|
||||
if(!src.locked)
|
||||
toggle_power()
|
||||
user.visible_message("[user.name] turns the [src.name] [active? "on":"off"].", \
|
||||
"You turn the [src.name] [active? "on":"off"].")
|
||||
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [user.key]. [P?"Fuel: [round(P.air_contents.toxins/0.29)]%":"<font color='red'>It is empty</font>"].","singulo")
|
||||
return
|
||||
else
|
||||
to_chat(user, "<span class='warning'>The controls are locked!</span>")
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/multitool))
|
||||
to_chat(user, "<span class='notice'>The [W.name] detects that [last_power]W were recently produced.</span>")
|
||||
return 1
|
||||
else if(istype(W, /obj/item/analyzer) && P)
|
||||
atmosanalyzer_scan(P.air_contents, user)
|
||||
else if(istype(W, /obj/item/tank/plasma))
|
||||
if(!src.anchored)
|
||||
to_chat(user, "<span class='warning'>The [src] needs to be secured to the floor first.</span>")
|
||||
return 1
|
||||
if(src.P)
|
||||
to_chat(user, "<span class='warning'>There's already a plasma tank loaded.</span>")
|
||||
return 1
|
||||
user.drop_item()
|
||||
src.P = W
|
||||
W.loc = src
|
||||
update_icons()
|
||||
else if(istype(W, /obj/item/crowbar))
|
||||
if(P && !src.locked)
|
||||
eject()
|
||||
return 1
|
||||
else if(istype(W, /obj/item/wrench))
|
||||
if(P)
|
||||
to_chat(user, "<span class='notice'>Remove the plasma tank first.</span>")
|
||||
return 1
|
||||
playsound(src.loc, W.usesound, 75, 1)
|
||||
src.anchored = !src.anchored
|
||||
user.visible_message("[user.name] [anchored? "secures":"unsecures"] the [src.name].", \
|
||||
"You [anchored? "secure":"undo"] the external bolts.", \
|
||||
"You hear a ratchet")
|
||||
if(anchored)
|
||||
connect_to_network()
|
||||
else
|
||||
disconnect_from_network()
|
||||
else if(istype(W, /obj/item/card/id)||istype(W, /obj/item/pda))
|
||||
if(src.allowed(user))
|
||||
if(active)
|
||||
src.locked = !src.locked
|
||||
to_chat(user, "The controls are now [src.locked ? "locked." : "unlocked."]")
|
||||
else
|
||||
src.locked = 0 //just in case it somehow gets locked
|
||||
to_chat(user, "<span class='warning'>The controls can only be locked when the [src] is active</span>")
|
||||
else
|
||||
to_chat(user, "<span class='warning'>Access denied!</span>")
|
||||
return 1
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/rad_collector/obj_break(damage_flag)
|
||||
if(!(stat & BROKEN) && !(flags & NODECONSTRUCT))
|
||||
eject()
|
||||
stat |= BROKEN
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/eject()
|
||||
locked = 0
|
||||
var/obj/item/tank/plasma/Z = src.P
|
||||
if(!Z)
|
||||
return
|
||||
Z.loc = get_turf(src)
|
||||
Z.layer = initial(Z.layer)
|
||||
Z.plane = initial(Z.plane)
|
||||
src.P = null
|
||||
if(active)
|
||||
toggle_power()
|
||||
else
|
||||
update_icons()
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/receive_pulse(var/pulse_strength)
|
||||
if(P && active)
|
||||
var/power_produced = 0
|
||||
power_produced = P.air_contents.toxins*pulse_strength*20
|
||||
add_avail(power_produced)
|
||||
last_power = power_produced
|
||||
return
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/update_icons()
|
||||
overlays.Cut()
|
||||
if(P)
|
||||
overlays += image('icons/obj/singularity.dmi', "ptank")
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
if(active)
|
||||
overlays += image('icons/obj/singularity.dmi', "on")
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/toggle_power()
|
||||
active = !active
|
||||
if(active)
|
||||
icon_state = "ca_on"
|
||||
flick("ca_active", src)
|
||||
else
|
||||
icon_state = "ca"
|
||||
flick("ca_deactive", src)
|
||||
update_icons()
|
||||
return
|
||||
var/global/list/rad_collectors = list()
|
||||
|
||||
/obj/machinery/power/rad_collector
|
||||
name = "Radiation Collector Array"
|
||||
desc = "A device which uses Hawking Radiation and plasma to produce power."
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "ca"
|
||||
anchored = 0
|
||||
density = 1
|
||||
req_access = list(ACCESS_ENGINE_EQUIP)
|
||||
// use_power = NO_POWER_USE
|
||||
max_integrity = 350
|
||||
integrity_failure = 80
|
||||
var/obj/item/tank/plasma/P = null
|
||||
var/last_power = 0
|
||||
var/active = 0
|
||||
var/locked = 0
|
||||
var/drainratio = 1
|
||||
|
||||
/obj/machinery/power/rad_collector/Initialize(mapload)
|
||||
. = ..()
|
||||
rad_collectors += src
|
||||
|
||||
/obj/machinery/power/rad_collector/Destroy()
|
||||
rad_collectors -= src
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/rad_collector/process()
|
||||
if(P)
|
||||
if(P.air_contents.toxins <= 0)
|
||||
investigate_log("<font color='red'>out of fuel</font>.","singulo")
|
||||
P.air_contents.toxins = 0
|
||||
eject()
|
||||
else
|
||||
P.air_contents.toxins -= 0.001*drainratio
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/attack_hand(mob/user as mob)
|
||||
if(anchored)
|
||||
if(!src.locked)
|
||||
toggle_power()
|
||||
user.visible_message("[user.name] turns the [src.name] [active? "on":"off"].", \
|
||||
"You turn the [src.name] [active? "on":"off"].")
|
||||
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [user.key]. [P?"Fuel: [round(P.air_contents.toxins/0.29)]%":"<font color='red'>It is empty</font>"].","singulo")
|
||||
return
|
||||
else
|
||||
to_chat(user, "<span class='warning'>The controls are locked!</span>")
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/multitool))
|
||||
to_chat(user, "<span class='notice'>The [W.name] detects that [last_power]W were recently produced.</span>")
|
||||
return 1
|
||||
else if(istype(W, /obj/item/analyzer) && P)
|
||||
atmosanalyzer_scan(P.air_contents, user)
|
||||
else if(istype(W, /obj/item/tank/plasma))
|
||||
if(!src.anchored)
|
||||
to_chat(user, "<span class='warning'>The [src] needs to be secured to the floor first.</span>")
|
||||
return 1
|
||||
if(src.P)
|
||||
to_chat(user, "<span class='warning'>There's already a plasma tank loaded.</span>")
|
||||
return 1
|
||||
user.drop_item()
|
||||
src.P = W
|
||||
W.loc = src
|
||||
update_icons()
|
||||
else if(istype(W, /obj/item/crowbar))
|
||||
if(P && !src.locked)
|
||||
eject()
|
||||
return 1
|
||||
else if(istype(W, /obj/item/wrench))
|
||||
if(P)
|
||||
to_chat(user, "<span class='notice'>Remove the plasma tank first.</span>")
|
||||
return 1
|
||||
playsound(src.loc, W.usesound, 75, 1)
|
||||
src.anchored = !src.anchored
|
||||
user.visible_message("[user.name] [anchored? "secures":"unsecures"] the [src.name].", \
|
||||
"You [anchored? "secure":"undo"] the external bolts.", \
|
||||
"You hear a ratchet")
|
||||
if(anchored)
|
||||
connect_to_network()
|
||||
else
|
||||
disconnect_from_network()
|
||||
else if(istype(W, /obj/item/card/id)||istype(W, /obj/item/pda))
|
||||
if(src.allowed(user))
|
||||
if(active)
|
||||
src.locked = !src.locked
|
||||
to_chat(user, "The controls are now [src.locked ? "locked." : "unlocked."]")
|
||||
else
|
||||
src.locked = 0 //just in case it somehow gets locked
|
||||
to_chat(user, "<span class='warning'>The controls can only be locked when the [src] is active</span>")
|
||||
else
|
||||
to_chat(user, "<span class='warning'>Access denied!</span>")
|
||||
return 1
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/rad_collector/obj_break(damage_flag)
|
||||
if(!(stat & BROKEN) && !(flags & NODECONSTRUCT))
|
||||
eject()
|
||||
stat |= BROKEN
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/eject()
|
||||
locked = 0
|
||||
var/obj/item/tank/plasma/Z = src.P
|
||||
if(!Z)
|
||||
return
|
||||
Z.loc = get_turf(src)
|
||||
Z.layer = initial(Z.layer)
|
||||
Z.plane = initial(Z.plane)
|
||||
src.P = null
|
||||
if(active)
|
||||
toggle_power()
|
||||
else
|
||||
update_icons()
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/receive_pulse(var/pulse_strength)
|
||||
if(P && active)
|
||||
var/power_produced = 0
|
||||
power_produced = P.air_contents.toxins*pulse_strength*20
|
||||
add_avail(power_produced)
|
||||
last_power = power_produced
|
||||
return
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/update_icons()
|
||||
overlays.Cut()
|
||||
if(P)
|
||||
overlays += image('icons/obj/singularity.dmi', "ptank")
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
if(active)
|
||||
overlays += image('icons/obj/singularity.dmi', "on")
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/proc/toggle_power()
|
||||
active = !active
|
||||
if(active)
|
||||
icon_state = "ca_on"
|
||||
flick("ca_active", src)
|
||||
else
|
||||
icon_state = "ca"
|
||||
flick("ca_deactive", src)
|
||||
update_icons()
|
||||
return
|
||||
|
||||
@@ -1,126 +1,126 @@
|
||||
/obj/machinery/field/containment
|
||||
name = "Containment Field"
|
||||
desc = "An energy field."
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "Contain_F"
|
||||
anchored = 1
|
||||
density = 0
|
||||
move_resist = INFINITY
|
||||
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
|
||||
use_power = NO_POWER_USE
|
||||
light_range = 4
|
||||
layer = OBJ_LAYER + 0.1
|
||||
var/obj/machinery/field/generator/FG1 = null
|
||||
var/obj/machinery/field/generator/FG2 = null
|
||||
|
||||
/obj/machinery/field/containment/Destroy()
|
||||
FG1.fields -= src
|
||||
FG2.fields -= src
|
||||
return ..()
|
||||
|
||||
/obj/machinery/field/containment/attack_hand(mob/user)
|
||||
if(get_dist(src, user) > 1)
|
||||
return 0
|
||||
else
|
||||
shock_field(user)
|
||||
return 1
|
||||
|
||||
/obj/machinery/field/containment/attackby(obj/item/W, mob/user, params)
|
||||
shock(user)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/field/containment/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
|
||||
switch(damage_type)
|
||||
if(BURN)
|
||||
playsound(loc, 'sound/effects/empulse.ogg', 75, TRUE)
|
||||
if(BRUTE)
|
||||
playsound(loc, 'sound/effects/empulse.ogg', 75, TRUE)
|
||||
|
||||
/obj/machinery/field/containment/blob_act(obj/structure/blob/B)
|
||||
return FALSE
|
||||
|
||||
|
||||
/obj/machinery/field/containment/ex_act(severity)
|
||||
return 0
|
||||
|
||||
/obj/machinery/field/containment/attack_animal(mob/living/simple_animal/M)
|
||||
if(!FG1 || !FG2)
|
||||
qdel(src)
|
||||
return
|
||||
if(ismegafauna(M))
|
||||
M.visible_message("<span class='warning'>[M] glows fiercely as the containment field flickers out!</span>")
|
||||
FG1.calc_power(INFINITY) //rip that 'containment' field
|
||||
M.adjustHealth(-M.obj_damage)
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/machinery/field/containment/Crossed(mob/mover, oldloc)
|
||||
if(isliving(mover))
|
||||
shock_field(mover)
|
||||
|
||||
if(istype(mover, /obj/machinery) || istype(mover, /obj/structure) || istype(mover, /obj/mecha))
|
||||
bump_field(mover)
|
||||
|
||||
/obj/machinery/field/containment/proc/set_master(master1,master2)
|
||||
if(!master1 || !master2)
|
||||
return 0
|
||||
FG1 = master1
|
||||
FG2 = master2
|
||||
return 1
|
||||
|
||||
/obj/machinery/field/containment/shock_field(mob/living/user)
|
||||
if(!FG1 || !FG2)
|
||||
qdel(src)
|
||||
return 0
|
||||
..()
|
||||
|
||||
/obj/machinery/field/containment/Move()
|
||||
qdel(src)
|
||||
|
||||
// Abstract Field Class
|
||||
// Used for overriding certain procs
|
||||
|
||||
/obj/machinery/field
|
||||
var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
|
||||
|
||||
/obj/machinery/field/CanPass(atom/movable/mover, turf/target, height=0)
|
||||
if(hasShocked)
|
||||
return 0
|
||||
if(isliving(mover)) // Don't let mobs through
|
||||
shock_field(mover)
|
||||
return 0
|
||||
if(istype(mover, /obj/machinery) || istype(mover, /obj/structure) || istype(mover, /obj/mecha))
|
||||
bump_field(mover)
|
||||
return 0
|
||||
return ..()
|
||||
|
||||
/obj/machinery/field/proc/shock_field(mob/living/user)
|
||||
if(isliving(user))
|
||||
var/shock_damage = min(rand(30,40),rand(30,40))
|
||||
|
||||
if(isliving(user) && !issilicon(user))
|
||||
var/stun = min(shock_damage, 15)
|
||||
user.Stun(stun)
|
||||
user.Weaken(10)
|
||||
user.electrocute_act(shock_damage, src, 1)
|
||||
|
||||
else if(issilicon(user))
|
||||
if(prob(20))
|
||||
user.Stun(2)
|
||||
user.take_overall_damage(0, shock_damage)
|
||||
user.visible_message("<span class='danger'>[user.name] was shocked by the [src.name]!</span>", \
|
||||
"<span class='userdanger'>Energy pulse detected, system damaged!</span>", \
|
||||
"<span class='italics'>You hear an electrical crack.</span>")
|
||||
|
||||
user.updatehealth()
|
||||
bump_field(user)
|
||||
|
||||
/obj/machinery/field/proc/bump_field(atom/movable/AM as mob|obj)
|
||||
if(hasShocked)
|
||||
return 0
|
||||
hasShocked = 1
|
||||
do_sparks(5, 1, AM.loc)
|
||||
var/atom/target = get_edge_target_turf(AM, get_dir(src, get_step_away(AM, src)))
|
||||
AM.throw_at(target, 200, 4)
|
||||
spawn(5)
|
||||
hasShocked = 0
|
||||
/obj/machinery/field/containment
|
||||
name = "Containment Field"
|
||||
desc = "An energy field."
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "Contain_F"
|
||||
anchored = 1
|
||||
density = 0
|
||||
move_resist = INFINITY
|
||||
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
|
||||
use_power = NO_POWER_USE
|
||||
light_range = 4
|
||||
layer = OBJ_LAYER + 0.1
|
||||
var/obj/machinery/field/generator/FG1 = null
|
||||
var/obj/machinery/field/generator/FG2 = null
|
||||
|
||||
/obj/machinery/field/containment/Destroy()
|
||||
FG1.fields -= src
|
||||
FG2.fields -= src
|
||||
return ..()
|
||||
|
||||
/obj/machinery/field/containment/attack_hand(mob/user)
|
||||
if(get_dist(src, user) > 1)
|
||||
return 0
|
||||
else
|
||||
shock_field(user)
|
||||
return 1
|
||||
|
||||
/obj/machinery/field/containment/attackby(obj/item/W, mob/user, params)
|
||||
shock(user)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/field/containment/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
|
||||
switch(damage_type)
|
||||
if(BURN)
|
||||
playsound(loc, 'sound/effects/empulse.ogg', 75, TRUE)
|
||||
if(BRUTE)
|
||||
playsound(loc, 'sound/effects/empulse.ogg', 75, TRUE)
|
||||
|
||||
/obj/machinery/field/containment/blob_act(obj/structure/blob/B)
|
||||
return FALSE
|
||||
|
||||
|
||||
/obj/machinery/field/containment/ex_act(severity)
|
||||
return 0
|
||||
|
||||
/obj/machinery/field/containment/attack_animal(mob/living/simple_animal/M)
|
||||
if(!FG1 || !FG2)
|
||||
qdel(src)
|
||||
return
|
||||
if(ismegafauna(M))
|
||||
M.visible_message("<span class='warning'>[M] glows fiercely as the containment field flickers out!</span>")
|
||||
FG1.calc_power(INFINITY) //rip that 'containment' field
|
||||
M.adjustHealth(-M.obj_damage)
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/machinery/field/containment/Crossed(mob/mover, oldloc)
|
||||
if(isliving(mover))
|
||||
shock_field(mover)
|
||||
|
||||
if(istype(mover, /obj/machinery) || istype(mover, /obj/structure) || istype(mover, /obj/mecha))
|
||||
bump_field(mover)
|
||||
|
||||
/obj/machinery/field/containment/proc/set_master(master1,master2)
|
||||
if(!master1 || !master2)
|
||||
return 0
|
||||
FG1 = master1
|
||||
FG2 = master2
|
||||
return 1
|
||||
|
||||
/obj/machinery/field/containment/shock_field(mob/living/user)
|
||||
if(!FG1 || !FG2)
|
||||
qdel(src)
|
||||
return 0
|
||||
..()
|
||||
|
||||
/obj/machinery/field/containment/Move()
|
||||
qdel(src)
|
||||
|
||||
// Abstract Field Class
|
||||
// Used for overriding certain procs
|
||||
|
||||
/obj/machinery/field
|
||||
var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
|
||||
|
||||
/obj/machinery/field/CanPass(atom/movable/mover, turf/target, height=0)
|
||||
if(hasShocked)
|
||||
return 0
|
||||
if(isliving(mover)) // Don't let mobs through
|
||||
shock_field(mover)
|
||||
return 0
|
||||
if(istype(mover, /obj/machinery) || istype(mover, /obj/structure) || istype(mover, /obj/mecha))
|
||||
bump_field(mover)
|
||||
return 0
|
||||
return ..()
|
||||
|
||||
/obj/machinery/field/proc/shock_field(mob/living/user)
|
||||
if(isliving(user))
|
||||
var/shock_damage = min(rand(30,40),rand(30,40))
|
||||
|
||||
if(isliving(user) && !issilicon(user))
|
||||
var/stun = min(shock_damage, 15)
|
||||
user.Stun(stun)
|
||||
user.Weaken(10)
|
||||
user.electrocute_act(shock_damage, src, 1)
|
||||
|
||||
else if(issilicon(user))
|
||||
if(prob(20))
|
||||
user.Stun(2)
|
||||
user.take_overall_damage(0, shock_damage)
|
||||
user.visible_message("<span class='danger'>[user.name] was shocked by the [src.name]!</span>", \
|
||||
"<span class='userdanger'>Energy pulse detected, system damaged!</span>", \
|
||||
"<span class='italics'>You hear an electrical crack.</span>")
|
||||
|
||||
user.updatehealth()
|
||||
bump_field(user)
|
||||
|
||||
/obj/machinery/field/proc/bump_field(atom/movable/AM as mob|obj)
|
||||
if(hasShocked)
|
||||
return 0
|
||||
hasShocked = 1
|
||||
do_sparks(5, 1, AM.loc)
|
||||
var/atom/target = get_edge_target_turf(AM, get_dir(src, get_step_away(AM, src)))
|
||||
AM.throw_at(target, 200, 4)
|
||||
spawn(5)
|
||||
hasShocked = 0
|
||||
|
||||
@@ -1,346 +1,346 @@
|
||||
/obj/machinery/power/emitter
|
||||
name = "Emitter"
|
||||
desc = "A heavy duty industrial laser"
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "emitter"
|
||||
anchored = 0
|
||||
density = 1
|
||||
req_access = list(ACCESS_ENGINE_EQUIP)
|
||||
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 10
|
||||
active_power_usage = 300
|
||||
|
||||
var/active = 0
|
||||
var/powered = 0
|
||||
var/fire_delay = 100
|
||||
var/maximum_fire_delay = 100
|
||||
var/minimum_fire_delay = 20
|
||||
var/last_shot = 0
|
||||
var/shot_number = 0
|
||||
var/state = 0
|
||||
var/locked = 0
|
||||
|
||||
var/frequency = 0
|
||||
var/id_tag = null
|
||||
var/projectile_type = /obj/item/projectile/beam/emitter
|
||||
var/projectile_sound = 'sound/weapons/emitter.ogg'
|
||||
var/datum/radio_frequency/radio_connection
|
||||
var/datum/effect_system/spark_spread/sparks
|
||||
|
||||
/obj/machinery/power/emitter/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/emitter(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
RefreshParts()
|
||||
if(state == 2 && anchored)
|
||||
connect_to_network()
|
||||
sparks = new
|
||||
sparks.attach(src)
|
||||
sparks.set_up(5, 1, src)
|
||||
if(frequency)
|
||||
set_frequency(frequency)
|
||||
|
||||
/obj/machinery/power/emitter/RefreshParts()
|
||||
var/max_firedelay = 120
|
||||
var/firedelay = 120
|
||||
var/min_firedelay = 24
|
||||
var/power_usage = 350
|
||||
for(var/obj/item/stock_parts/micro_laser/L in component_parts)
|
||||
max_firedelay -= 20 * L.rating
|
||||
min_firedelay -= 4 * L.rating
|
||||
firedelay -= 20 * L.rating
|
||||
maximum_fire_delay = max_firedelay
|
||||
minimum_fire_delay = min_firedelay
|
||||
fire_delay = firedelay
|
||||
for(var/obj/item/stock_parts/manipulator/M in component_parts)
|
||||
power_usage -= 50 * M.rating
|
||||
active_power_usage = power_usage
|
||||
|
||||
//Radio remote control
|
||||
/obj/machinery/power/emitter/proc/set_frequency(new_frequency)
|
||||
SSradio.remove_object(src, frequency)
|
||||
frequency = new_frequency
|
||||
if(frequency)
|
||||
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
|
||||
|
||||
|
||||
/obj/machinery/power/emitter/verb/rotate()
|
||||
set name = "Rotate"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(src.anchored || usr:stat)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
src.dir = turn(src.dir, 90)
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/emitter/AltClick(mob/user)
|
||||
if(user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!Adjacent(user))
|
||||
return
|
||||
rotate()
|
||||
|
||||
/obj/machinery/power/emitter/multitool_menu(var/mob/user,var/obj/item/multitool/P)
|
||||
return {"
|
||||
<ul>
|
||||
<li><b>Frequency:</b> <a href="?src=[UID()];set_freq=-1">[format_frequency(frequency)] GHz</a> (<a href="?src=[UID()];set_freq=[ENGINE_FREQ]">Reset</a>)</li>
|
||||
<li>[format_tag("ID Tag","id_tag","set_id")]</a></li>
|
||||
</ul>
|
||||
"}
|
||||
|
||||
/obj/machinery/power/emitter/receive_signal(datum/signal/signal)
|
||||
if(!signal.data["tag"] || (signal.data["tag"] != id_tag))
|
||||
return 0
|
||||
|
||||
var/on=0
|
||||
switch(signal.data["command"])
|
||||
if("on")
|
||||
on=1
|
||||
|
||||
if("off")
|
||||
on=0
|
||||
|
||||
if("set")
|
||||
on = signal.data["state"] > 0
|
||||
|
||||
if("toggle")
|
||||
on = !active
|
||||
|
||||
if(anchored && state == 2 && on != active)
|
||||
active=on
|
||||
var/statestr=on?"on":"off"
|
||||
// Spammy message_admins("Emitter turned [statestr] by radio signal ([signal.data["command"]] @ [frequency]) in [formatJumpTo(src)]",0,1)
|
||||
log_game("Emitter turned [statestr] by radio signal ([signal.data["command"]] @ [frequency]) in ([x], [y], [z]) AAC prints: [jointext(signal.data["hiddenprints"], "")]")
|
||||
investigate_log("turned <font color='orange'>[statestr]</font> by radio signal ([signal.data["command"]] @ [frequency]) AAC prints: [jointext(signal.data["hiddenprints"], "")]","singulo")
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/power/emitter/Destroy()
|
||||
if(SSradio)
|
||||
SSradio.remove_object(src, frequency)
|
||||
radio_connection = null
|
||||
msg_admin_attack("Emitter deleted at ([x],[y],[z] - [ADMIN_JMP(src)])", ATKLOG_FEW)
|
||||
log_game("Emitter deleted at ([x],[y],[z])")
|
||||
investigate_log("<font color='red'>deleted</font> at ([x],[y],[z])","singulo")
|
||||
QDEL_NULL(sparks)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/emitter/update_icon()
|
||||
if(active && powernet && avail(active_power_usage))
|
||||
icon_state = "emitter_+a"
|
||||
else
|
||||
icon_state = "emitter"
|
||||
|
||||
|
||||
/obj/machinery/power/emitter/attack_hand(mob/user as mob)
|
||||
src.add_fingerprint(user)
|
||||
if(state == 2)
|
||||
if(!powernet)
|
||||
to_chat(user, "The emitter isn't connected to a wire.")
|
||||
return 1
|
||||
if(!src.locked)
|
||||
if(src.active==1)
|
||||
src.active = 0
|
||||
to_chat(user, "You turn off the [src].")
|
||||
message_admins("Emitter turned off by [key_name_admin(user)] in ([x], [y], [z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("Emitter turned off by [key_name(user)] in [x], [y], [z]")
|
||||
investigate_log("turned <font color='red'>off</font> by [key_name(usr)]","singulo")
|
||||
else
|
||||
src.active = 1
|
||||
to_chat(user, "You turn on the [src].")
|
||||
src.shot_number = 0
|
||||
src.fire_delay = maximum_fire_delay
|
||||
message_admins("Emitter turned on by [key_name_admin(user)] in ([x], [y], [z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("Emitter turned on by [key_name(user)] in [x], [y], [z]")
|
||||
investigate_log("turned <font color='green'>on</font> by [key_name(usr)]","singulo")
|
||||
update_icon()
|
||||
else
|
||||
to_chat(user, "<span class='warning'>The controls are locked!</span>")
|
||||
else
|
||||
to_chat(user, "<span class='warning'>The [src] needs to be firmly secured to the floor first.</span>")
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/power/emitter/emp_act(var/severity)//Emitters are hardened but still might have issues
|
||||
// add_load(1000)
|
||||
/* if((severity == 1)&&prob(1)&&prob(1))
|
||||
if(src.active)
|
||||
src.active = 0
|
||||
src.use_power = IDLE_POWER_USE */
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/emitter/attack_animal(mob/living/simple_animal/M)
|
||||
if(ismegafauna(M) && anchored)
|
||||
state = 0
|
||||
anchored = FALSE
|
||||
M.visible_message("<span class='warning'>[M] rips [src] free from its moorings!</span>")
|
||||
else
|
||||
..()
|
||||
if(!anchored)
|
||||
step(src, get_dir(M, src))
|
||||
|
||||
/obj/machinery/power/emitter/process()
|
||||
if(stat & (BROKEN))
|
||||
return
|
||||
if(src.state != 2 || (!powernet && active_power_usage))
|
||||
src.active = 0
|
||||
update_icon()
|
||||
return
|
||||
if(active == TRUE)
|
||||
if(!active_power_usage || surplus() >= active_power_usage)
|
||||
add_load(active_power_usage)
|
||||
if(!powered)
|
||||
powered = 1
|
||||
update_icon()
|
||||
investigate_log("regained power and turned <font color='green'>on</font>","singulo")
|
||||
else
|
||||
if(powered)
|
||||
powered = 0
|
||||
update_icon()
|
||||
investigate_log("lost power and turned <font color='red'>off</font>","singulo")
|
||||
return
|
||||
|
||||
if(!check_delay())
|
||||
return FALSE
|
||||
fire_beam()
|
||||
|
||||
/obj/machinery/power/emitter/proc/check_delay()
|
||||
if((last_shot + fire_delay) <= world.time)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/power/emitter/proc/fire_beam()
|
||||
var/obj/item/projectile/P = new projectile_type(get_turf(src))
|
||||
playsound(get_turf(src), projectile_sound, 50, TRUE)
|
||||
if(prob(35))
|
||||
sparks.start()
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
P.yo = 20
|
||||
P.xo = 0
|
||||
if(NORTHEAST)
|
||||
P.yo = 20
|
||||
P.xo = 20
|
||||
if(EAST)
|
||||
P.yo = 0
|
||||
P.xo = 20
|
||||
if(SOUTHEAST)
|
||||
P.yo = -20
|
||||
P.xo = 20
|
||||
if(WEST)
|
||||
P.yo = 0
|
||||
P.xo = -20
|
||||
if(SOUTHWEST)
|
||||
P.yo = -20
|
||||
P.xo = -20
|
||||
if(NORTHWEST)
|
||||
P.yo = 20
|
||||
P.xo = -20
|
||||
else // Any other
|
||||
P.yo = -20
|
||||
P.xo = 0
|
||||
|
||||
last_shot = world.time
|
||||
if(shot_number < 3)
|
||||
fire_delay = 20
|
||||
shot_number ++
|
||||
else
|
||||
fire_delay = rand(minimum_fire_delay, maximum_fire_delay)
|
||||
shot_number = 0
|
||||
P.setDir(dir)
|
||||
P.starting = loc
|
||||
P.Angle = null
|
||||
P.fire()
|
||||
return P
|
||||
|
||||
/obj/machinery/power/emitter/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/multitool))
|
||||
update_multitool_menu(user)
|
||||
return 1
|
||||
|
||||
if(istype(W, /obj/item/wrench))
|
||||
if(active)
|
||||
to_chat(user, "Turn off the [src] first.")
|
||||
return
|
||||
switch(state)
|
||||
if(0)
|
||||
state = 1
|
||||
playsound(src.loc, W.usesound, 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,W.usesound, 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)
|
||||
to_chat(user, "<span class='warning'>The [src.name] needs to be unwelded from the floor.</span>")
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/card/id) || istype(W, /obj/item/pda))
|
||||
if(emagged)
|
||||
to_chat(user, "<span class='warning'>The lock seems to be broken</span>")
|
||||
return
|
||||
if(src.allowed(user))
|
||||
if(active)
|
||||
src.locked = !src.locked
|
||||
to_chat(user, "The controls are now [src.locked ? "locked." : "unlocked."]")
|
||||
else
|
||||
src.locked = 0 //just in case it somehow gets locked
|
||||
to_chat(user, "<span class='warning'>The controls can only be locked when the [src] is online</span>")
|
||||
else
|
||||
to_chat(user, "<span class='warning'>Access denied.</span>")
|
||||
return
|
||||
|
||||
if(default_deconstruction_screwdriver(user, "emitter_open", "emitter", W))
|
||||
return
|
||||
|
||||
if(exchange_parts(user, W))
|
||||
return
|
||||
|
||||
if(default_deconstruction_crowbar(user, W))
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/emitter/emag_act(var/mob/living/user as mob)
|
||||
if(!emagged)
|
||||
locked = 0
|
||||
emagged = 1
|
||||
if(user)
|
||||
user.visible_message("[user.name] emags the [src.name].","<span class='warning'>You short out the lock.</span>")
|
||||
|
||||
|
||||
/obj/machinery/power/emitter/welder_act(mob/user, obj/item/I)
|
||||
if(active)
|
||||
to_chat(user, "<span class='notice'>Turn off [src] first.</span>")
|
||||
return
|
||||
if(state == 0)
|
||||
to_chat(user, "<span class='warning'>[src] needs to be wrenched to the floor.</span>")
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.tool_use_check(user, 0))
|
||||
return
|
||||
if(state == 1)
|
||||
WELDER_ATTEMPT_FLOOR_WELD_MESSAGE
|
||||
else if(state == 2)
|
||||
WELDER_ATTEMPT_FLOOR_SLICE_MESSAGE
|
||||
if(!I.use_tool(src, user, 20, volume = I.tool_volume))
|
||||
return
|
||||
if(state == 1)
|
||||
WELDER_FLOOR_WELD_SUCCESS_MESSAGE
|
||||
connect_to_network()
|
||||
state = 2
|
||||
else if(state == 2)
|
||||
WELDER_FLOOR_SLICE_SUCCESS_MESSAGE
|
||||
disconnect_from_network()
|
||||
state = 1
|
||||
/obj/machinery/power/emitter
|
||||
name = "Emitter"
|
||||
desc = "A heavy duty industrial laser"
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "emitter"
|
||||
anchored = 0
|
||||
density = 1
|
||||
req_access = list(ACCESS_ENGINE_EQUIP)
|
||||
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 10
|
||||
active_power_usage = 300
|
||||
|
||||
var/active = 0
|
||||
var/powered = 0
|
||||
var/fire_delay = 100
|
||||
var/maximum_fire_delay = 100
|
||||
var/minimum_fire_delay = 20
|
||||
var/last_shot = 0
|
||||
var/shot_number = 0
|
||||
var/state = 0
|
||||
var/locked = 0
|
||||
|
||||
var/frequency = 0
|
||||
var/id_tag = null
|
||||
var/projectile_type = /obj/item/projectile/beam/emitter
|
||||
var/projectile_sound = 'sound/weapons/emitter.ogg'
|
||||
var/datum/radio_frequency/radio_connection
|
||||
var/datum/effect_system/spark_spread/sparks
|
||||
|
||||
/obj/machinery/power/emitter/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/emitter(null)
|
||||
component_parts += new /obj/item/stock_parts/micro_laser(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
RefreshParts()
|
||||
if(state == 2 && anchored)
|
||||
connect_to_network()
|
||||
sparks = new
|
||||
sparks.attach(src)
|
||||
sparks.set_up(5, 1, src)
|
||||
if(frequency)
|
||||
set_frequency(frequency)
|
||||
|
||||
/obj/machinery/power/emitter/RefreshParts()
|
||||
var/max_firedelay = 120
|
||||
var/firedelay = 120
|
||||
var/min_firedelay = 24
|
||||
var/power_usage = 350
|
||||
for(var/obj/item/stock_parts/micro_laser/L in component_parts)
|
||||
max_firedelay -= 20 * L.rating
|
||||
min_firedelay -= 4 * L.rating
|
||||
firedelay -= 20 * L.rating
|
||||
maximum_fire_delay = max_firedelay
|
||||
minimum_fire_delay = min_firedelay
|
||||
fire_delay = firedelay
|
||||
for(var/obj/item/stock_parts/manipulator/M in component_parts)
|
||||
power_usage -= 50 * M.rating
|
||||
active_power_usage = power_usage
|
||||
|
||||
//Radio remote control
|
||||
/obj/machinery/power/emitter/proc/set_frequency(new_frequency)
|
||||
SSradio.remove_object(src, frequency)
|
||||
frequency = new_frequency
|
||||
if(frequency)
|
||||
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
|
||||
|
||||
|
||||
/obj/machinery/power/emitter/verb/rotate()
|
||||
set name = "Rotate"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(src.anchored || usr:stat)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
src.dir = turn(src.dir, 90)
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/emitter/AltClick(mob/user)
|
||||
if(user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!Adjacent(user))
|
||||
return
|
||||
rotate()
|
||||
|
||||
/obj/machinery/power/emitter/multitool_menu(var/mob/user,var/obj/item/multitool/P)
|
||||
return {"
|
||||
<ul>
|
||||
<li><b>Frequency:</b> <a href="?src=[UID()];set_freq=-1">[format_frequency(frequency)] GHz</a> (<a href="?src=[UID()];set_freq=[ENGINE_FREQ]">Reset</a>)</li>
|
||||
<li>[format_tag("ID Tag","id_tag","set_id")]</a></li>
|
||||
</ul>
|
||||
"}
|
||||
|
||||
/obj/machinery/power/emitter/receive_signal(datum/signal/signal)
|
||||
if(!signal.data["tag"] || (signal.data["tag"] != id_tag))
|
||||
return 0
|
||||
|
||||
var/on=0
|
||||
switch(signal.data["command"])
|
||||
if("on")
|
||||
on=1
|
||||
|
||||
if("off")
|
||||
on=0
|
||||
|
||||
if("set")
|
||||
on = signal.data["state"] > 0
|
||||
|
||||
if("toggle")
|
||||
on = !active
|
||||
|
||||
if(anchored && state == 2 && on != active)
|
||||
active=on
|
||||
var/statestr=on?"on":"off"
|
||||
// Spammy message_admins("Emitter turned [statestr] by radio signal ([signal.data["command"]] @ [frequency]) in [formatJumpTo(src)]",0,1)
|
||||
log_game("Emitter turned [statestr] by radio signal ([signal.data["command"]] @ [frequency]) in ([x], [y], [z]) AAC prints: [jointext(signal.data["hiddenprints"], "")]")
|
||||
investigate_log("turned <font color='orange'>[statestr]</font> by radio signal ([signal.data["command"]] @ [frequency]) AAC prints: [jointext(signal.data["hiddenprints"], "")]","singulo")
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/power/emitter/Destroy()
|
||||
if(SSradio)
|
||||
SSradio.remove_object(src, frequency)
|
||||
radio_connection = null
|
||||
msg_admin_attack("Emitter deleted at ([x],[y],[z] - [ADMIN_JMP(src)])", ATKLOG_FEW)
|
||||
log_game("Emitter deleted at ([x],[y],[z])")
|
||||
investigate_log("<font color='red'>deleted</font> at ([x],[y],[z])","singulo")
|
||||
QDEL_NULL(sparks)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/emitter/update_icon()
|
||||
if(active && powernet && avail(active_power_usage))
|
||||
icon_state = "emitter_+a"
|
||||
else
|
||||
icon_state = "emitter"
|
||||
|
||||
|
||||
/obj/machinery/power/emitter/attack_hand(mob/user as mob)
|
||||
src.add_fingerprint(user)
|
||||
if(state == 2)
|
||||
if(!powernet)
|
||||
to_chat(user, "The emitter isn't connected to a wire.")
|
||||
return 1
|
||||
if(!src.locked)
|
||||
if(src.active==1)
|
||||
src.active = 0
|
||||
to_chat(user, "You turn off the [src].")
|
||||
message_admins("Emitter turned off by [key_name_admin(user)] in ([x], [y], [z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("Emitter turned off by [key_name(user)] in [x], [y], [z]")
|
||||
investigate_log("turned <font color='red'>off</font> by [key_name(usr)]","singulo")
|
||||
else
|
||||
src.active = 1
|
||||
to_chat(user, "You turn on the [src].")
|
||||
src.shot_number = 0
|
||||
src.fire_delay = maximum_fire_delay
|
||||
message_admins("Emitter turned on by [key_name_admin(user)] in ([x], [y], [z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("Emitter turned on by [key_name(user)] in [x], [y], [z]")
|
||||
investigate_log("turned <font color='green'>on</font> by [key_name(usr)]","singulo")
|
||||
update_icon()
|
||||
else
|
||||
to_chat(user, "<span class='warning'>The controls are locked!</span>")
|
||||
else
|
||||
to_chat(user, "<span class='warning'>The [src] needs to be firmly secured to the floor first.</span>")
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/power/emitter/emp_act(var/severity)//Emitters are hardened but still might have issues
|
||||
// add_load(1000)
|
||||
/* if((severity == 1)&&prob(1)&&prob(1))
|
||||
if(src.active)
|
||||
src.active = 0
|
||||
src.use_power = IDLE_POWER_USE */
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/emitter/attack_animal(mob/living/simple_animal/M)
|
||||
if(ismegafauna(M) && anchored)
|
||||
state = 0
|
||||
anchored = FALSE
|
||||
M.visible_message("<span class='warning'>[M] rips [src] free from its moorings!</span>")
|
||||
else
|
||||
..()
|
||||
if(!anchored)
|
||||
step(src, get_dir(M, src))
|
||||
|
||||
/obj/machinery/power/emitter/process()
|
||||
if(stat & (BROKEN))
|
||||
return
|
||||
if(src.state != 2 || (!powernet && active_power_usage))
|
||||
src.active = 0
|
||||
update_icon()
|
||||
return
|
||||
if(active == TRUE)
|
||||
if(!active_power_usage || surplus() >= active_power_usage)
|
||||
add_load(active_power_usage)
|
||||
if(!powered)
|
||||
powered = 1
|
||||
update_icon()
|
||||
investigate_log("regained power and turned <font color='green'>on</font>","singulo")
|
||||
else
|
||||
if(powered)
|
||||
powered = 0
|
||||
update_icon()
|
||||
investigate_log("lost power and turned <font color='red'>off</font>","singulo")
|
||||
return
|
||||
|
||||
if(!check_delay())
|
||||
return FALSE
|
||||
fire_beam()
|
||||
|
||||
/obj/machinery/power/emitter/proc/check_delay()
|
||||
if((last_shot + fire_delay) <= world.time)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/power/emitter/proc/fire_beam()
|
||||
var/obj/item/projectile/P = new projectile_type(get_turf(src))
|
||||
playsound(get_turf(src), projectile_sound, 50, TRUE)
|
||||
if(prob(35))
|
||||
sparks.start()
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
P.yo = 20
|
||||
P.xo = 0
|
||||
if(NORTHEAST)
|
||||
P.yo = 20
|
||||
P.xo = 20
|
||||
if(EAST)
|
||||
P.yo = 0
|
||||
P.xo = 20
|
||||
if(SOUTHEAST)
|
||||
P.yo = -20
|
||||
P.xo = 20
|
||||
if(WEST)
|
||||
P.yo = 0
|
||||
P.xo = -20
|
||||
if(SOUTHWEST)
|
||||
P.yo = -20
|
||||
P.xo = -20
|
||||
if(NORTHWEST)
|
||||
P.yo = 20
|
||||
P.xo = -20
|
||||
else // Any other
|
||||
P.yo = -20
|
||||
P.xo = 0
|
||||
|
||||
last_shot = world.time
|
||||
if(shot_number < 3)
|
||||
fire_delay = 20
|
||||
shot_number ++
|
||||
else
|
||||
fire_delay = rand(minimum_fire_delay, maximum_fire_delay)
|
||||
shot_number = 0
|
||||
P.setDir(dir)
|
||||
P.starting = loc
|
||||
P.Angle = null
|
||||
P.fire()
|
||||
return P
|
||||
|
||||
/obj/machinery/power/emitter/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/multitool))
|
||||
update_multitool_menu(user)
|
||||
return 1
|
||||
|
||||
if(istype(W, /obj/item/wrench))
|
||||
if(active)
|
||||
to_chat(user, "Turn off the [src] first.")
|
||||
return
|
||||
switch(state)
|
||||
if(0)
|
||||
state = 1
|
||||
playsound(src.loc, W.usesound, 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,W.usesound, 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)
|
||||
to_chat(user, "<span class='warning'>The [src.name] needs to be unwelded from the floor.</span>")
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/card/id) || istype(W, /obj/item/pda))
|
||||
if(emagged)
|
||||
to_chat(user, "<span class='warning'>The lock seems to be broken</span>")
|
||||
return
|
||||
if(src.allowed(user))
|
||||
if(active)
|
||||
src.locked = !src.locked
|
||||
to_chat(user, "The controls are now [src.locked ? "locked." : "unlocked."]")
|
||||
else
|
||||
src.locked = 0 //just in case it somehow gets locked
|
||||
to_chat(user, "<span class='warning'>The controls can only be locked when the [src] is online</span>")
|
||||
else
|
||||
to_chat(user, "<span class='warning'>Access denied.</span>")
|
||||
return
|
||||
|
||||
if(default_deconstruction_screwdriver(user, "emitter_open", "emitter", W))
|
||||
return
|
||||
|
||||
if(exchange_parts(user, W))
|
||||
return
|
||||
|
||||
if(default_deconstruction_crowbar(user, W))
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/emitter/emag_act(var/mob/living/user as mob)
|
||||
if(!emagged)
|
||||
locked = 0
|
||||
emagged = 1
|
||||
if(user)
|
||||
user.visible_message("[user.name] emags the [src.name].","<span class='warning'>You short out the lock.</span>")
|
||||
|
||||
|
||||
/obj/machinery/power/emitter/welder_act(mob/user, obj/item/I)
|
||||
if(active)
|
||||
to_chat(user, "<span class='notice'>Turn off [src] first.</span>")
|
||||
return
|
||||
if(state == 0)
|
||||
to_chat(user, "<span class='warning'>[src] needs to be wrenched to the floor.</span>")
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.tool_use_check(user, 0))
|
||||
return
|
||||
if(state == 1)
|
||||
WELDER_ATTEMPT_FLOOR_WELD_MESSAGE
|
||||
else if(state == 2)
|
||||
WELDER_ATTEMPT_FLOOR_SLICE_MESSAGE
|
||||
if(!I.use_tool(src, user, 20, volume = I.tool_volume))
|
||||
return
|
||||
if(state == 1)
|
||||
WELDER_FLOOR_WELD_SUCCESS_MESSAGE
|
||||
connect_to_network()
|
||||
state = 2
|
||||
else if(state == 2)
|
||||
WELDER_FLOOR_SLICE_SUCCESS_MESSAGE
|
||||
disconnect_from_network()
|
||||
state = 1
|
||||
|
||||
@@ -1,337 +1,337 @@
|
||||
/*
|
||||
field_generator power level display
|
||||
The icon used for the field_generator need to have 'num_power_levels' number of icon states
|
||||
named 'Field_Gen +p[num]' where 'num' ranges from 1 to 'num_power_levels'
|
||||
|
||||
The power level is displayed using overlays. The current displayed power level is stored in 'powerlevel'.
|
||||
The overlay in use and the powerlevel variable must be kept in sync. A powerlevel equal to 0 means that
|
||||
no power level overlay is currently in the overlays list.
|
||||
-Aygar
|
||||
*/
|
||||
|
||||
#define field_generator_max_power 250
|
||||
|
||||
#define FG_UNSECURED 0
|
||||
#define FG_SECURED 1
|
||||
#define FG_WELDED 2
|
||||
|
||||
#define FG_OFFLINE 0
|
||||
#define FG_CHARGING 1
|
||||
#define FG_ONLINE 2
|
||||
|
||||
/obj/machinery/field/generator
|
||||
name = "Field Generator"
|
||||
desc = "A large thermal battery that projects a high amount of energy when powered."
|
||||
icon = 'icons/obj/machines/field_generator.dmi'
|
||||
icon_state = "Field_Gen"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
max_integrity = 500
|
||||
//100% immune to lasers and energy projectiles since it absorbs their energy.
|
||||
armor = list("melee" = 25, "bullet" = 10, "laser" = 100, "energy" = 100, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 50, "acid" = 70)
|
||||
var/const/num_power_levels = 6 // Total number of power level icon has
|
||||
var/power_level = 0
|
||||
var/active = FG_OFFLINE
|
||||
var/power = 20 // Current amount of power
|
||||
var/state = FG_UNSECURED
|
||||
var/warming_up = 0
|
||||
var/list/obj/machinery/field/containment/fields
|
||||
var/list/obj/machinery/field/generator/connected_gens
|
||||
var/clean_up = 0
|
||||
|
||||
/obj/machinery/field/generator/update_icon()
|
||||
overlays.Cut()
|
||||
if(warming_up)
|
||||
overlays += "+a[warming_up]"
|
||||
if(fields.len)
|
||||
overlays += "+on"
|
||||
if(power_level)
|
||||
overlays += "+p[power_level]"
|
||||
|
||||
|
||||
/obj/machinery/field/generator/Initialize(mapload)
|
||||
. = ..()
|
||||
fields = list()
|
||||
connected_gens = list()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/process()
|
||||
if(active == FG_ONLINE)
|
||||
calc_power()
|
||||
|
||||
/obj/machinery/field/generator/attack_hand(mob/user)
|
||||
if(state == FG_WELDED)
|
||||
if(get_dist(src, user) <= 1)//Need to actually touch the thing to turn it on
|
||||
if(active >= FG_CHARGING)
|
||||
to_chat(user, "<span class='warning'>You are unable to turn off the [name] once it is online!</span>")
|
||||
return 1
|
||||
else
|
||||
user.visible_message("[user.name] turns on the [name].", \
|
||||
"<span class='notice'>You turn on the [name].</span>", \
|
||||
"<span class='italics'>You hear heavy droning.</span>")
|
||||
turn_on()
|
||||
investigate_log("<font color='green'>activated</font> by [user.key].","singulo")
|
||||
|
||||
add_fingerprint(user)
|
||||
else
|
||||
to_chat(user, "<span class='warning'>[src] needs to be firmly secured to the floor first!</span>")
|
||||
|
||||
|
||||
/obj/machinery/field/generator/attackby(obj/item/W, mob/user, params)
|
||||
if(active)
|
||||
to_chat(user, "<span class='warning'>[src] needs to be off!</span>")
|
||||
return
|
||||
else if(istype(W, /obj/item/wrench))
|
||||
switch(state)
|
||||
if(FG_UNSECURED)
|
||||
if(isinspace()) return
|
||||
state = FG_SECURED
|
||||
playsound(loc, W.usesound, 75, 1)
|
||||
user.visible_message("[user.name] secures [name] to the floor.", \
|
||||
"<span class='notice'>You secure the external reinforcing bolts to the floor.</span>", \
|
||||
"<span class='italics'>You hear ratchet.</span>")
|
||||
anchored = 1
|
||||
if(FG_SECURED)
|
||||
state = FG_UNSECURED
|
||||
playsound(loc, W.usesound, 75, 1)
|
||||
user.visible_message("[user.name] unsecures [name] reinforcing bolts from the floor.", \
|
||||
"<span class='notice'>You undo the external reinforcing bolts.</span>", \
|
||||
"<span class='italics'>You hear ratchet.</span>")
|
||||
anchored = 0
|
||||
if(FG_WELDED)
|
||||
to_chat(user, "<span class='warning'>The [name] needs to be unwelded from the floor!</span>")
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/welder_act(mob/user, obj/item/I)
|
||||
. = TRUE
|
||||
if(state == FG_UNSECURED)
|
||||
to_chat(user, "<span class='warning'>[src] needs to be wrenched to the floor!</span>")
|
||||
return
|
||||
if(!I.tool_use_check(user, 0))
|
||||
return
|
||||
if(state == FG_SECURED)
|
||||
WELDER_ATTEMPT_FLOOR_SLICE_MESSAGE
|
||||
else if(state == FG_WELDED)
|
||||
WELDER_ATTEMPT_FLOOR_WELD_MESSAGE
|
||||
if(I.use_tool(src, user, 20, volume = I.tool_volume))
|
||||
if(state == FG_SECURED)
|
||||
WELDER_FLOOR_SLICE_SUCCESS_MESSAGE
|
||||
state = FG_WELDED
|
||||
else if(state == FG_WELDED)
|
||||
WELDER_FLOOR_WELD_SUCCESS_MESSAGE
|
||||
state = FG_SECURED
|
||||
|
||||
/obj/machinery/field/generator/emp_act()
|
||||
return 0
|
||||
|
||||
/obj/machinery/field/generator/attack_animal(mob/living/simple_animal/M)
|
||||
if(M.environment_smash & ENVIRONMENT_SMASH_RWALLS && active == FG_OFFLINE && state != FG_UNSECURED)
|
||||
state = FG_UNSECURED
|
||||
anchored = FALSE
|
||||
M.visible_message("<span class='warning'>[M] rips [src] free from its moorings!</span>")
|
||||
else
|
||||
..()
|
||||
if(!anchored)
|
||||
step(src, get_dir(M, src))
|
||||
|
||||
/obj/machinery/field/generator/blob_act(obj/structure/blob/B)
|
||||
if(active)
|
||||
return 0
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/machinery/field/generator/bullet_act(obj/item/projectile/Proj)
|
||||
if(Proj.flag != "bullet")
|
||||
power = min(power + Proj.damage, field_generator_max_power)
|
||||
check_power_level()
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/field/generator/Destroy()
|
||||
cleanup()
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/check_power_level()
|
||||
var/new_level = round(num_power_levels * power / field_generator_max_power)
|
||||
if(new_level != power_level)
|
||||
power_level = new_level
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/field/generator/proc/turn_off()
|
||||
active = FG_OFFLINE
|
||||
spawn(1)
|
||||
cleanup()
|
||||
while(warming_up > 0 && !active)
|
||||
sleep(50)
|
||||
warming_up--
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/field/generator/proc/turn_on()
|
||||
active = FG_CHARGING
|
||||
spawn(1)
|
||||
while(warming_up < 3 && active)
|
||||
sleep(50)
|
||||
warming_up++
|
||||
update_icon()
|
||||
if(warming_up >= 3)
|
||||
start_fields()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/calc_power()
|
||||
var/power_draw = 2 + fields.len
|
||||
|
||||
if(draw_power(round(power_draw/2, 1)))
|
||||
check_power_level()
|
||||
return 1
|
||||
else
|
||||
visible_message("<span class='danger'>The [name] shuts down!</span>", "<span class='italics'>You hear something shutting down.</span>")
|
||||
turn_off()
|
||||
investigate_log("ran out of power and <font color='red'>deactivated</font>","singulo")
|
||||
power = 0
|
||||
check_power_level()
|
||||
return 0
|
||||
|
||||
//This could likely be better, it tends to start loopin if you have a complex generator loop setup. Still works well enough to run the engine fields will likely recode the field gens and fields sometime -Mport
|
||||
/obj/machinery/field/generator/proc/draw_power(draw = 0, failsafe = 0, obj/machinery/field/generator/G = null, obj/machinery/field/generator/last = null)
|
||||
if((G && (G == src)) || (failsafe >= 8))//Loopin, set fail
|
||||
return 0
|
||||
else
|
||||
failsafe++
|
||||
|
||||
if(power >= draw)//We have enough power
|
||||
power -= draw
|
||||
return 1
|
||||
|
||||
else//Need more power
|
||||
draw -= power
|
||||
power = 0
|
||||
for(var/CG in connected_gens)
|
||||
var/obj/machinery/field/generator/FG = CG
|
||||
if(FG == last)//We just asked you
|
||||
continue
|
||||
if(G)//Another gen is askin for power and we dont have it
|
||||
if(FG.draw_power(draw,failsafe,G,src))//Can you take the load
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
else//We are askin another for power
|
||||
if(FG.draw_power(draw,failsafe,src,src))
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/start_fields()
|
||||
if(state != FG_WELDED || !anchored)
|
||||
turn_off()
|
||||
return
|
||||
spawn(1)
|
||||
setup_field(1)
|
||||
spawn(2)
|
||||
setup_field(2)
|
||||
spawn(3)
|
||||
setup_field(4)
|
||||
spawn(4)
|
||||
setup_field(8)
|
||||
spawn(5)
|
||||
active = FG_ONLINE
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/setup_field(NSEW)
|
||||
var/turf/T = loc
|
||||
if(!istype(T))
|
||||
return 0
|
||||
|
||||
var/obj/machinery/field/generator/G = null
|
||||
var/steps = 0
|
||||
if(!NSEW)//Make sure its ran right
|
||||
return 0
|
||||
for(var/dist in 0 to 7) // checks out to 8 tiles away for another generator
|
||||
T = get_step(T, NSEW)
|
||||
if(T.density)//We cant shoot a field though this
|
||||
return 0
|
||||
|
||||
G = locate(/obj/machinery/field/generator) in T
|
||||
if(G)
|
||||
steps -= 1
|
||||
if(!G.active)
|
||||
return 0
|
||||
break
|
||||
|
||||
for(var/TC in T.contents)
|
||||
var/atom/A = TC
|
||||
if(ismob(A))
|
||||
continue
|
||||
if(A.density)
|
||||
return 0
|
||||
|
||||
steps++
|
||||
|
||||
if(!G)
|
||||
return 0
|
||||
|
||||
T = loc
|
||||
for(var/dist in 0 to steps) // creates each field tile
|
||||
var/field_dir = get_dir(T,get_step(G.loc, NSEW))
|
||||
T = get_step(T, NSEW)
|
||||
if(!locate(/obj/machinery/field/containment) in T)
|
||||
var/obj/machinery/field/containment/CF = new/obj/machinery/field/containment()
|
||||
CF.set_master(src,G)
|
||||
CF.loc = T
|
||||
CF.dir = field_dir
|
||||
fields += CF
|
||||
G.fields += CF
|
||||
for(var/mob/living/L in T)
|
||||
CF.Crossed(L, null)
|
||||
|
||||
connected_gens |= G
|
||||
G.connected_gens |= src
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/cleanup()
|
||||
clean_up = 1
|
||||
for(var/F in fields)
|
||||
qdel(F)
|
||||
|
||||
for(var/CG in connected_gens)
|
||||
var/obj/machinery/field/generator/FG = CG
|
||||
FG.connected_gens -= src
|
||||
if(!FG.clean_up)//Makes the other gens clean up as well
|
||||
FG.cleanup()
|
||||
connected_gens -= FG
|
||||
clean_up = 0
|
||||
update_icon()
|
||||
|
||||
//This is here to help fight the "hurr durr, release singulo cos nobody will notice before the
|
||||
//singulo eats the evidence". It's not fool-proof but better than nothing.
|
||||
//I want to avoid using global variables.
|
||||
spawn(1)
|
||||
var/temp = 1 //stops spam
|
||||
for(var/obj/singularity/O in GLOB.singularities)
|
||||
if(O.last_warning && temp)
|
||||
if((world.time - O.last_warning) > 50) //to stop message-spam
|
||||
temp = 0
|
||||
message_admins("A singulo exists and a containment field has failed. Location: [get_area(src)] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</A>)",1)
|
||||
investigate_log("has <font color='red'>failed</font> whilst a singulo exists.","singulo")
|
||||
O.last_warning = world.time
|
||||
|
||||
/obj/machinery/field/generator/shock_field(mob/living/user)
|
||||
if(fields.len)
|
||||
..()
|
||||
|
||||
/obj/machinery/field/generator/bump_field(atom/movable/AM as mob|obj)
|
||||
if(fields.len)
|
||||
..()
|
||||
|
||||
#undef FG_UNSECURED
|
||||
#undef FG_SECURED
|
||||
#undef FG_WELDED
|
||||
|
||||
#undef FG_OFFLINE
|
||||
#undef FG_CHARGING
|
||||
#undef FG_ONLINE
|
||||
/*
|
||||
field_generator power level display
|
||||
The icon used for the field_generator need to have 'num_power_levels' number of icon states
|
||||
named 'Field_Gen +p[num]' where 'num' ranges from 1 to 'num_power_levels'
|
||||
|
||||
The power level is displayed using overlays. The current displayed power level is stored in 'powerlevel'.
|
||||
The overlay in use and the powerlevel variable must be kept in sync. A powerlevel equal to 0 means that
|
||||
no power level overlay is currently in the overlays list.
|
||||
-Aygar
|
||||
*/
|
||||
|
||||
#define field_generator_max_power 250
|
||||
|
||||
#define FG_UNSECURED 0
|
||||
#define FG_SECURED 1
|
||||
#define FG_WELDED 2
|
||||
|
||||
#define FG_OFFLINE 0
|
||||
#define FG_CHARGING 1
|
||||
#define FG_ONLINE 2
|
||||
|
||||
/obj/machinery/field/generator
|
||||
name = "Field Generator"
|
||||
desc = "A large thermal battery that projects a high amount of energy when powered."
|
||||
icon = 'icons/obj/machines/field_generator.dmi'
|
||||
icon_state = "Field_Gen"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
max_integrity = 500
|
||||
//100% immune to lasers and energy projectiles since it absorbs their energy.
|
||||
armor = list("melee" = 25, "bullet" = 10, "laser" = 100, "energy" = 100, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 50, "acid" = 70)
|
||||
var/const/num_power_levels = 6 // Total number of power level icon has
|
||||
var/power_level = 0
|
||||
var/active = FG_OFFLINE
|
||||
var/power = 20 // Current amount of power
|
||||
var/state = FG_UNSECURED
|
||||
var/warming_up = 0
|
||||
var/list/obj/machinery/field/containment/fields
|
||||
var/list/obj/machinery/field/generator/connected_gens
|
||||
var/clean_up = 0
|
||||
|
||||
/obj/machinery/field/generator/update_icon()
|
||||
overlays.Cut()
|
||||
if(warming_up)
|
||||
overlays += "+a[warming_up]"
|
||||
if(fields.len)
|
||||
overlays += "+on"
|
||||
if(power_level)
|
||||
overlays += "+p[power_level]"
|
||||
|
||||
|
||||
/obj/machinery/field/generator/Initialize(mapload)
|
||||
. = ..()
|
||||
fields = list()
|
||||
connected_gens = list()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/process()
|
||||
if(active == FG_ONLINE)
|
||||
calc_power()
|
||||
|
||||
/obj/machinery/field/generator/attack_hand(mob/user)
|
||||
if(state == FG_WELDED)
|
||||
if(get_dist(src, user) <= 1)//Need to actually touch the thing to turn it on
|
||||
if(active >= FG_CHARGING)
|
||||
to_chat(user, "<span class='warning'>You are unable to turn off the [name] once it is online!</span>")
|
||||
return 1
|
||||
else
|
||||
user.visible_message("[user.name] turns on the [name].", \
|
||||
"<span class='notice'>You turn on the [name].</span>", \
|
||||
"<span class='italics'>You hear heavy droning.</span>")
|
||||
turn_on()
|
||||
investigate_log("<font color='green'>activated</font> by [user.key].","singulo")
|
||||
|
||||
add_fingerprint(user)
|
||||
else
|
||||
to_chat(user, "<span class='warning'>[src] needs to be firmly secured to the floor first!</span>")
|
||||
|
||||
|
||||
/obj/machinery/field/generator/attackby(obj/item/W, mob/user, params)
|
||||
if(active)
|
||||
to_chat(user, "<span class='warning'>[src] needs to be off!</span>")
|
||||
return
|
||||
else if(istype(W, /obj/item/wrench))
|
||||
switch(state)
|
||||
if(FG_UNSECURED)
|
||||
if(isinspace()) return
|
||||
state = FG_SECURED
|
||||
playsound(loc, W.usesound, 75, 1)
|
||||
user.visible_message("[user.name] secures [name] to the floor.", \
|
||||
"<span class='notice'>You secure the external reinforcing bolts to the floor.</span>", \
|
||||
"<span class='italics'>You hear ratchet.</span>")
|
||||
anchored = 1
|
||||
if(FG_SECURED)
|
||||
state = FG_UNSECURED
|
||||
playsound(loc, W.usesound, 75, 1)
|
||||
user.visible_message("[user.name] unsecures [name] reinforcing bolts from the floor.", \
|
||||
"<span class='notice'>You undo the external reinforcing bolts.</span>", \
|
||||
"<span class='italics'>You hear ratchet.</span>")
|
||||
anchored = 0
|
||||
if(FG_WELDED)
|
||||
to_chat(user, "<span class='warning'>The [name] needs to be unwelded from the floor!</span>")
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/welder_act(mob/user, obj/item/I)
|
||||
. = TRUE
|
||||
if(state == FG_UNSECURED)
|
||||
to_chat(user, "<span class='warning'>[src] needs to be wrenched to the floor!</span>")
|
||||
return
|
||||
if(!I.tool_use_check(user, 0))
|
||||
return
|
||||
if(state == FG_SECURED)
|
||||
WELDER_ATTEMPT_FLOOR_SLICE_MESSAGE
|
||||
else if(state == FG_WELDED)
|
||||
WELDER_ATTEMPT_FLOOR_WELD_MESSAGE
|
||||
if(I.use_tool(src, user, 20, volume = I.tool_volume))
|
||||
if(state == FG_SECURED)
|
||||
WELDER_FLOOR_SLICE_SUCCESS_MESSAGE
|
||||
state = FG_WELDED
|
||||
else if(state == FG_WELDED)
|
||||
WELDER_FLOOR_WELD_SUCCESS_MESSAGE
|
||||
state = FG_SECURED
|
||||
|
||||
/obj/machinery/field/generator/emp_act()
|
||||
return 0
|
||||
|
||||
/obj/machinery/field/generator/attack_animal(mob/living/simple_animal/M)
|
||||
if(M.environment_smash & ENVIRONMENT_SMASH_RWALLS && active == FG_OFFLINE && state != FG_UNSECURED)
|
||||
state = FG_UNSECURED
|
||||
anchored = FALSE
|
||||
M.visible_message("<span class='warning'>[M] rips [src] free from its moorings!</span>")
|
||||
else
|
||||
..()
|
||||
if(!anchored)
|
||||
step(src, get_dir(M, src))
|
||||
|
||||
/obj/machinery/field/generator/blob_act(obj/structure/blob/B)
|
||||
if(active)
|
||||
return 0
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/machinery/field/generator/bullet_act(obj/item/projectile/Proj)
|
||||
if(Proj.flag != "bullet")
|
||||
power = min(power + Proj.damage, field_generator_max_power)
|
||||
check_power_level()
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/field/generator/Destroy()
|
||||
cleanup()
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/check_power_level()
|
||||
var/new_level = round(num_power_levels * power / field_generator_max_power)
|
||||
if(new_level != power_level)
|
||||
power_level = new_level
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/field/generator/proc/turn_off()
|
||||
active = FG_OFFLINE
|
||||
spawn(1)
|
||||
cleanup()
|
||||
while(warming_up > 0 && !active)
|
||||
sleep(50)
|
||||
warming_up--
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/field/generator/proc/turn_on()
|
||||
active = FG_CHARGING
|
||||
spawn(1)
|
||||
while(warming_up < 3 && active)
|
||||
sleep(50)
|
||||
warming_up++
|
||||
update_icon()
|
||||
if(warming_up >= 3)
|
||||
start_fields()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/calc_power()
|
||||
var/power_draw = 2 + fields.len
|
||||
|
||||
if(draw_power(round(power_draw/2, 1)))
|
||||
check_power_level()
|
||||
return 1
|
||||
else
|
||||
visible_message("<span class='danger'>The [name] shuts down!</span>", "<span class='italics'>You hear something shutting down.</span>")
|
||||
turn_off()
|
||||
investigate_log("ran out of power and <font color='red'>deactivated</font>","singulo")
|
||||
power = 0
|
||||
check_power_level()
|
||||
return 0
|
||||
|
||||
//This could likely be better, it tends to start loopin if you have a complex generator loop setup. Still works well enough to run the engine fields will likely recode the field gens and fields sometime -Mport
|
||||
/obj/machinery/field/generator/proc/draw_power(draw = 0, failsafe = 0, obj/machinery/field/generator/G = null, obj/machinery/field/generator/last = null)
|
||||
if((G && (G == src)) || (failsafe >= 8))//Loopin, set fail
|
||||
return 0
|
||||
else
|
||||
failsafe++
|
||||
|
||||
if(power >= draw)//We have enough power
|
||||
power -= draw
|
||||
return 1
|
||||
|
||||
else//Need more power
|
||||
draw -= power
|
||||
power = 0
|
||||
for(var/CG in connected_gens)
|
||||
var/obj/machinery/field/generator/FG = CG
|
||||
if(FG == last)//We just asked you
|
||||
continue
|
||||
if(G)//Another gen is askin for power and we dont have it
|
||||
if(FG.draw_power(draw,failsafe,G,src))//Can you take the load
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
else//We are askin another for power
|
||||
if(FG.draw_power(draw,failsafe,src,src))
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/start_fields()
|
||||
if(state != FG_WELDED || !anchored)
|
||||
turn_off()
|
||||
return
|
||||
spawn(1)
|
||||
setup_field(1)
|
||||
spawn(2)
|
||||
setup_field(2)
|
||||
spawn(3)
|
||||
setup_field(4)
|
||||
spawn(4)
|
||||
setup_field(8)
|
||||
spawn(5)
|
||||
active = FG_ONLINE
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/setup_field(NSEW)
|
||||
var/turf/T = loc
|
||||
if(!istype(T))
|
||||
return 0
|
||||
|
||||
var/obj/machinery/field/generator/G = null
|
||||
var/steps = 0
|
||||
if(!NSEW)//Make sure its ran right
|
||||
return 0
|
||||
for(var/dist in 0 to 7) // checks out to 8 tiles away for another generator
|
||||
T = get_step(T, NSEW)
|
||||
if(T.density)//We cant shoot a field though this
|
||||
return 0
|
||||
|
||||
G = locate(/obj/machinery/field/generator) in T
|
||||
if(G)
|
||||
steps -= 1
|
||||
if(!G.active)
|
||||
return 0
|
||||
break
|
||||
|
||||
for(var/TC in T.contents)
|
||||
var/atom/A = TC
|
||||
if(ismob(A))
|
||||
continue
|
||||
if(A.density)
|
||||
return 0
|
||||
|
||||
steps++
|
||||
|
||||
if(!G)
|
||||
return 0
|
||||
|
||||
T = loc
|
||||
for(var/dist in 0 to steps) // creates each field tile
|
||||
var/field_dir = get_dir(T,get_step(G.loc, NSEW))
|
||||
T = get_step(T, NSEW)
|
||||
if(!locate(/obj/machinery/field/containment) in T)
|
||||
var/obj/machinery/field/containment/CF = new/obj/machinery/field/containment()
|
||||
CF.set_master(src,G)
|
||||
CF.loc = T
|
||||
CF.dir = field_dir
|
||||
fields += CF
|
||||
G.fields += CF
|
||||
for(var/mob/living/L in T)
|
||||
CF.Crossed(L, null)
|
||||
|
||||
connected_gens |= G
|
||||
G.connected_gens |= src
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/machinery/field/generator/proc/cleanup()
|
||||
clean_up = 1
|
||||
for(var/F in fields)
|
||||
qdel(F)
|
||||
|
||||
for(var/CG in connected_gens)
|
||||
var/obj/machinery/field/generator/FG = CG
|
||||
FG.connected_gens -= src
|
||||
if(!FG.clean_up)//Makes the other gens clean up as well
|
||||
FG.cleanup()
|
||||
connected_gens -= FG
|
||||
clean_up = 0
|
||||
update_icon()
|
||||
|
||||
//This is here to help fight the "hurr durr, release singulo cos nobody will notice before the
|
||||
//singulo eats the evidence". It's not fool-proof but better than nothing.
|
||||
//I want to avoid using global variables.
|
||||
spawn(1)
|
||||
var/temp = 1 //stops spam
|
||||
for(var/obj/singularity/O in GLOB.singularities)
|
||||
if(O.last_warning && temp)
|
||||
if((world.time - O.last_warning) > 50) //to stop message-spam
|
||||
temp = 0
|
||||
message_admins("A singulo exists and a containment field has failed. Location: [get_area(src)] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</A>)",1)
|
||||
investigate_log("has <font color='red'>failed</font> whilst a singulo exists.","singulo")
|
||||
O.last_warning = world.time
|
||||
|
||||
/obj/machinery/field/generator/shock_field(mob/living/user)
|
||||
if(fields.len)
|
||||
..()
|
||||
|
||||
/obj/machinery/field/generator/bump_field(atom/movable/AM as mob|obj)
|
||||
if(fields.len)
|
||||
..()
|
||||
|
||||
#undef FG_UNSECURED
|
||||
#undef FG_SECURED
|
||||
#undef FG_WELDED
|
||||
|
||||
#undef FG_OFFLINE
|
||||
#undef FG_CHARGING
|
||||
#undef FG_ONLINE
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
/////SINGULARITY SPAWNER
|
||||
/obj/machinery/the_singularitygen
|
||||
name = "Gravitational Singularity Generator"
|
||||
desc = "An odd device which produces a Gravitational Singularity when set up."
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "TheSingGen"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
resistance_flags = FIRE_PROOF
|
||||
var/energy = 0
|
||||
var/creation_type = /obj/singularity
|
||||
|
||||
/obj/machinery/the_singularitygen/process()
|
||||
var/turf/T = get_turf(src)
|
||||
if(src.energy >= 200)
|
||||
message_admins("A [creation_type] has been created at [x], [y], [z] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)")
|
||||
investigate_log("A [creation_type] has been created at [x], [y], [z]","singulo")
|
||||
|
||||
var/obj/singularity/S = new creation_type(T, 50)
|
||||
transfer_fingerprints_to(S)
|
||||
if(src) qdel(src)
|
||||
|
||||
/obj/machinery/the_singularitygen/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/wrench))
|
||||
anchored = !anchored
|
||||
playsound(src.loc, W.usesound, 75, 1)
|
||||
if(anchored)
|
||||
user.visible_message("[user.name] secures [src.name] to the floor.", \
|
||||
"You secure the [src.name] to the floor.", \
|
||||
"You hear a ratchet")
|
||||
src.add_hiddenprint(user)
|
||||
else
|
||||
user.visible_message("[user.name] unsecures [src.name] from the floor.", \
|
||||
"You unsecure the [src.name] from the floor.", \
|
||||
"You hear a ratchet")
|
||||
return
|
||||
return ..()
|
||||
/////SINGULARITY SPAWNER
|
||||
/obj/machinery/the_singularitygen
|
||||
name = "Gravitational Singularity Generator"
|
||||
desc = "An odd device which produces a Gravitational Singularity when set up."
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "TheSingGen"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
resistance_flags = FIRE_PROOF
|
||||
var/energy = 0
|
||||
var/creation_type = /obj/singularity
|
||||
|
||||
/obj/machinery/the_singularitygen/process()
|
||||
var/turf/T = get_turf(src)
|
||||
if(src.energy >= 200)
|
||||
message_admins("A [creation_type] has been created at [x], [y], [z] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)")
|
||||
investigate_log("A [creation_type] has been created at [x], [y], [z]","singulo")
|
||||
|
||||
var/obj/singularity/S = new creation_type(T, 50)
|
||||
transfer_fingerprints_to(S)
|
||||
if(src) qdel(src)
|
||||
|
||||
/obj/machinery/the_singularitygen/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/wrench))
|
||||
anchored = !anchored
|
||||
playsound(src.loc, W.usesound, 75, 1)
|
||||
if(anchored)
|
||||
user.visible_message("[user.name] secures [src.name] to the floor.", \
|
||||
"You secure the [src.name] to the floor.", \
|
||||
"You hear a ratchet")
|
||||
src.add_hiddenprint(user)
|
||||
else
|
||||
user.visible_message("[user.name] unsecures [src.name] from the floor.", \
|
||||
"You unsecure the [src.name] from the floor.", \
|
||||
"You hear a ratchet")
|
||||
return
|
||||
return ..()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/area/engine/engineering/power_alert(var/alarming)
|
||||
if(alarming)
|
||||
investigate_log("has a power alarm!","singulo")
|
||||
..()
|
||||
..()
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
/obj/effect/accelerated_particle
|
||||
name = "Accelerated Particles"
|
||||
desc = "Small things moving very fast."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "particle"
|
||||
anchored = TRUE
|
||||
density = FALSE
|
||||
var/movement_range = 10
|
||||
var/energy = 10
|
||||
var/speed = 1
|
||||
|
||||
/obj/effect/accelerated_particle/weak
|
||||
movement_range = 8
|
||||
energy = 5
|
||||
|
||||
/obj/effect/accelerated_particle/strong
|
||||
movement_range = 15
|
||||
energy = 15
|
||||
|
||||
/obj/effect/accelerated_particle/powerful
|
||||
movement_range = 20
|
||||
energy = 50
|
||||
|
||||
|
||||
/obj/effect/accelerated_particle/Initialize(loc)
|
||||
. = ..()
|
||||
addtimer(CALLBACK(src, .proc/propagate), 1)
|
||||
RegisterSignal(src, COMSIG_CROSSED_MOVABLE, .proc/try_irradiate)
|
||||
RegisterSignal(src, COMSIG_MOVABLE_CROSSED, .proc/try_irradiate)
|
||||
QDEL_IN(src, movement_range)
|
||||
|
||||
/obj/effect/accelerated_particle/proc/try_irradiate(src, atom/A)
|
||||
if(isliving(A))
|
||||
var/mob/living/L = A
|
||||
L.apply_effect((energy * 6), IRRADIATE, 0)
|
||||
else if(istype(A, /obj/machinery/the_singularitygen))
|
||||
var/obj/machinery/the_singularitygen/S = A
|
||||
S.energy += energy
|
||||
else if(istype(A, /obj/structure/blob))
|
||||
var/obj/structure/blob/B = A
|
||||
B.take_damage(energy * 0.6)
|
||||
movement_range = 0
|
||||
|
||||
/obj/effect/accelerated_particle/Bump(obj/singularity/S)
|
||||
if(!istype(S))
|
||||
return ..()
|
||||
S.energy += energy
|
||||
|
||||
|
||||
/obj/effect/accelerated_particle/ex_act(severity)
|
||||
qdel(src)
|
||||
|
||||
/obj/effect/accelerated_particle/singularity_pull()
|
||||
return
|
||||
|
||||
/obj/effect/accelerated_particle/proc/propagate()
|
||||
addtimer(CALLBACK(src, .proc/propagate), 1)
|
||||
if(!step(src,dir))
|
||||
forceMove(get_step(src, dir))
|
||||
/obj/effect/accelerated_particle
|
||||
name = "Accelerated Particles"
|
||||
desc = "Small things moving very fast."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "particle"
|
||||
anchored = TRUE
|
||||
density = FALSE
|
||||
var/movement_range = 10
|
||||
var/energy = 10
|
||||
var/speed = 1
|
||||
|
||||
/obj/effect/accelerated_particle/weak
|
||||
movement_range = 8
|
||||
energy = 5
|
||||
|
||||
/obj/effect/accelerated_particle/strong
|
||||
movement_range = 15
|
||||
energy = 15
|
||||
|
||||
/obj/effect/accelerated_particle/powerful
|
||||
movement_range = 20
|
||||
energy = 50
|
||||
|
||||
|
||||
/obj/effect/accelerated_particle/Initialize(loc)
|
||||
. = ..()
|
||||
addtimer(CALLBACK(src, .proc/propagate), 1)
|
||||
RegisterSignal(src, COMSIG_CROSSED_MOVABLE, .proc/try_irradiate)
|
||||
RegisterSignal(src, COMSIG_MOVABLE_CROSSED, .proc/try_irradiate)
|
||||
QDEL_IN(src, movement_range)
|
||||
|
||||
/obj/effect/accelerated_particle/proc/try_irradiate(src, atom/A)
|
||||
if(isliving(A))
|
||||
var/mob/living/L = A
|
||||
L.apply_effect((energy * 6), IRRADIATE, 0)
|
||||
else if(istype(A, /obj/machinery/the_singularitygen))
|
||||
var/obj/machinery/the_singularitygen/S = A
|
||||
S.energy += energy
|
||||
else if(istype(A, /obj/structure/blob))
|
||||
var/obj/structure/blob/B = A
|
||||
B.take_damage(energy * 0.6)
|
||||
movement_range = 0
|
||||
|
||||
/obj/effect/accelerated_particle/Bump(obj/singularity/S)
|
||||
if(!istype(S))
|
||||
return ..()
|
||||
S.energy += energy
|
||||
|
||||
|
||||
/obj/effect/accelerated_particle/ex_act(severity)
|
||||
qdel(src)
|
||||
|
||||
/obj/effect/accelerated_particle/singularity_pull()
|
||||
return
|
||||
|
||||
/obj/effect/accelerated_particle/proc/propagate()
|
||||
addtimer(CALLBACK(src, .proc/propagate), 1)
|
||||
if(!step(src,dir))
|
||||
forceMove(get_step(src, dir))
|
||||
|
||||
@@ -1,360 +1,360 @@
|
||||
/*Composed of 7 parts
|
||||
3 Particle emitters
|
||||
proc
|
||||
emit_particle()
|
||||
|
||||
1 power box
|
||||
the only part of this thing that uses power, can hack to mess with the pa/make it better
|
||||
|
||||
1 fuel chamber
|
||||
contains procs for mixing gas and whatever other fuel it uses
|
||||
mix_gas()
|
||||
|
||||
1 gas holder WIP
|
||||
acts like a tank valve on the ground that you wrench gas tanks onto
|
||||
proc
|
||||
extract_gas()
|
||||
return_gas()
|
||||
attach_tank()
|
||||
remove_tank()
|
||||
get_available_mix()
|
||||
|
||||
1 End Cap
|
||||
|
||||
1 Control computer
|
||||
interface for the pa, acts like a computer with an html menu for diff parts and a status report
|
||||
all other parts contain only a ref to this
|
||||
a /machine/, tells the others to do work
|
||||
contains ref for all parts
|
||||
proc
|
||||
process()
|
||||
check_build()
|
||||
|
||||
Setup map
|
||||
|EC|
|
||||
CC|FC|
|
||||
|PB|
|
||||
PE|PE|PE
|
||||
|
||||
|
||||
Icon Addemdum
|
||||
Icon system is much more robust, and the icons are all variable based.
|
||||
Each part has a reference string, powered, strength, and contruction values.
|
||||
Using this the update_icon() proc is simplified a bit (using for absolutely was problematic with naming),
|
||||
so the icon_state comes out be:
|
||||
"[reference][strength]", with a switch controlling construction_states and ensuring that it doesn't
|
||||
power on while being contructed, and all these variables are set by the computer through it's scan list
|
||||
Essential order of the icons:
|
||||
Standard - [reference]
|
||||
Wrenched - [reference]
|
||||
Wired - [reference]w
|
||||
Closed - [reference]c
|
||||
Powered - [reference]p[strength]
|
||||
Strength being set by the computer and a null strength (Computer is powered off or inactive) returns a 'null', counting as empty
|
||||
So, hopefully this is helpful if any more icons are to be added/changed/wondering what the hell is going on here
|
||||
|
||||
*/
|
||||
#define ACCELERATOR_UNWRENCHED 0
|
||||
#define ACCELERATOR_WRENCHED 1
|
||||
#define ACCELERATOR_WIRED 2
|
||||
#define ACCELERATOR_READY 3
|
||||
|
||||
/obj/structure/particle_accelerator
|
||||
name = "Particle Accelerator"
|
||||
desc = "Part of a Particle Accelerator."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "none"
|
||||
anchored = 0
|
||||
density = 1
|
||||
max_integrity = 500
|
||||
armor = list("melee" = 30, "bullet" = 20, "laser" = 20, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 90, "acid" = 80)
|
||||
var/obj/machinery/particle_accelerator/control_box/master = null
|
||||
var/construction_state = 0
|
||||
var/reference = null
|
||||
var/powered = 0
|
||||
var/strength = null
|
||||
var/desc_holder = null
|
||||
|
||||
/obj/structure/particle_accelerator/Destroy()
|
||||
construction_state = 0
|
||||
if(master)
|
||||
master.part_scan()
|
||||
return ..()
|
||||
|
||||
/obj/structure/particle_accelerator/end_cap
|
||||
name = "Alpha Particle Generation Array"
|
||||
desc_holder = "This is where Alpha particles are generated from \[REDACTED\]"
|
||||
icon_state = "end_cap"
|
||||
reference = "end_cap"
|
||||
|
||||
/obj/structure/particle_accelerator/update_icon()
|
||||
..()
|
||||
return
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/verb/rotate()
|
||||
set name = "Rotate Clockwise"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
if(anchored)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
dir = turn(dir, 270)
|
||||
return 1
|
||||
|
||||
/obj/structure/particle_accelerator/AltClick(mob/user)
|
||||
if(user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!Adjacent(user))
|
||||
return
|
||||
rotate()
|
||||
|
||||
/obj/structure/particle_accelerator/verb/rotateccw()
|
||||
set name = "Rotate Counter Clockwise"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
if(anchored)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
dir = turn(dir, 90)
|
||||
return 1
|
||||
|
||||
/obj/structure/particle_accelerator/examine(mob/user)
|
||||
switch(construction_state)
|
||||
if(0)
|
||||
desc = text("A [name], looks like it's not attached to the flooring")
|
||||
if(1)
|
||||
desc = text("A [name], it is missing some cables")
|
||||
if(2)
|
||||
desc = text("A [name], the panel is open")
|
||||
if(3)
|
||||
desc = text("The [name] is assembled")
|
||||
if(powered)
|
||||
desc = desc_holder
|
||||
. = ..()
|
||||
|
||||
/obj/structure/particle_accelerator/deconstruct(disassembled = TRUE)
|
||||
if(!(flags & NODECONSTRUCT))
|
||||
new /obj/item/stack/sheet/metal (loc, 5)
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/particle_accelerator/Move()
|
||||
. = ..()
|
||||
if(master && master.active)
|
||||
master.toggle_power()
|
||||
investigate_log("was moved whilst active; it <font color='red'>powered down</font>.","singulo")
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/blob_act(obj/structure/blob/B)
|
||||
if(prob(50))
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/particle_accelerator/update_icon()
|
||||
switch(construction_state)
|
||||
if(0,1)
|
||||
icon_state="[reference]"
|
||||
if(2)
|
||||
icon_state="[reference]w"
|
||||
if(3)
|
||||
if(powered)
|
||||
icon_state="[reference]p[strength]"
|
||||
else
|
||||
icon_state="[reference]c"
|
||||
return
|
||||
|
||||
/obj/structure/particle_accelerator/proc/update_state()
|
||||
if(master)
|
||||
master.update_state()
|
||||
return 0
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/proc/report_ready(var/obj/O)
|
||||
if(O && (O == master))
|
||||
if(construction_state >= 3)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/proc/report_master()
|
||||
if(master)
|
||||
return master
|
||||
return 0
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/proc/connect_master(var/obj/O)
|
||||
if(O && istype(O,/obj/machinery/particle_accelerator/control_box))
|
||||
if(O.dir == dir)
|
||||
master = O
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/structure/particle_accelerator/attackby(obj/item/W, mob/user, params)
|
||||
if(!iscoil(W))
|
||||
return ..()
|
||||
if(construction_state == ACCELERATOR_WRENCHED)
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(C.use(1))
|
||||
playsound(loc, C.usesound, 50, 1)
|
||||
user.visible_message("[user.name] adds wires to the [name].", \
|
||||
"You add some wires.")
|
||||
construction_state = ACCELERATOR_WIRED
|
||||
update_icon()
|
||||
|
||||
/obj/structure/particle_accelerator/screwdriver_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_WIRED && construction_state != ACCELERATOR_READY)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(construction_state == ACCELERATOR_WIRED)
|
||||
SCREWDRIVER_CLOSE_PANEL_MESSAGE
|
||||
construction_state = ACCELERATOR_READY
|
||||
|
||||
else
|
||||
construction_state = ACCELERATOR_WIRED
|
||||
SCREWDRIVER_OPEN_PANEL_MESSAGE
|
||||
update_state()
|
||||
update_icon()
|
||||
|
||||
/obj/structure/particle_accelerator/wirecutter_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_WIRED)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
WIRECUTTER_SNIP_MESSAGE
|
||||
construction_state = ACCELERATOR_WRENCHED
|
||||
|
||||
/obj/structure/particle_accelerator/wrench_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_UNWRENCHED && construction_state != ACCELERATOR_WRENCHED)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(construction_state == ACCELERATOR_UNWRENCHED)
|
||||
anchored = TRUE
|
||||
WRENCH_ANCHOR_MESSAGE
|
||||
construction_state = ACCELERATOR_WRENCHED
|
||||
else
|
||||
anchored = FALSE
|
||||
WRENCH_UNANCHOR_MESSAGE
|
||||
construction_state = ACCELERATOR_UNWRENCHED
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator
|
||||
name = "Particle Accelerator"
|
||||
desc = "Part of a Particle Accelerator."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "none"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 0
|
||||
var/construction_state = 0
|
||||
var/active = 0
|
||||
var/reference = null
|
||||
var/powered = null
|
||||
var/strength = 0
|
||||
var/desc_holder = null
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/verb/rotate()
|
||||
set name = "Rotate Clockwise"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
if(anchored)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
dir = turn(dir, 270)
|
||||
return 1
|
||||
|
||||
/obj/machinery/particle_accelerator/verb/rotateccw()
|
||||
set name = "Rotate Counter-Clockwise"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
if(anchored)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
dir = turn(dir, 90)
|
||||
return 1
|
||||
|
||||
/obj/machinery/particle_accelerator/update_icon()
|
||||
return
|
||||
|
||||
/obj/machinery/particle_accelerator/attackby(obj/item/W, mob/user, params)
|
||||
if(!iscoil(W))
|
||||
return ..()
|
||||
if(construction_state == ACCELERATOR_WRENCHED)
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(C.use(1))
|
||||
playsound(loc, C.usesound, 50, 1)
|
||||
user.visible_message("[user.name] adds wires to the [name].", \
|
||||
"You add some wires.")
|
||||
construction_state = ACCELERATOR_WIRED
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/screwdriver_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_WIRED && construction_state != ACCELERATOR_READY)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(construction_state == ACCELERATOR_WIRED)
|
||||
SCREWDRIVER_CLOSE_PANEL_MESSAGE
|
||||
construction_state = ACCELERATOR_READY
|
||||
use_power = IDLE_POWER_USE
|
||||
else
|
||||
construction_state = ACCELERATOR_WIRED
|
||||
SCREWDRIVER_OPEN_PANEL_MESSAGE
|
||||
use_power = NO_POWER_USE
|
||||
update_state()
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/wirecutter_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_WIRED)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
WIRECUTTER_SNIP_MESSAGE
|
||||
construction_state = ACCELERATOR_WRENCHED
|
||||
|
||||
/obj/machinery/particle_accelerator/wrench_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_UNWRENCHED && construction_state != ACCELERATOR_WRENCHED)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(construction_state == ACCELERATOR_UNWRENCHED)
|
||||
anchored = TRUE
|
||||
WRENCH_ANCHOR_MESSAGE
|
||||
construction_state = ACCELERATOR_WRENCHED
|
||||
else
|
||||
anchored = FALSE
|
||||
WRENCH_UNANCHOR_MESSAGE
|
||||
construction_state = ACCELERATOR_UNWRENCHED
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/proc/update_state()
|
||||
return 0
|
||||
|
||||
|
||||
#undef ACCELERATOR_UNWRENCHED
|
||||
#undef ACCELERATOR_WRENCHED
|
||||
#undef ACCELERATOR_WIRED
|
||||
#undef ACCELERATOR_READY
|
||||
/*Composed of 7 parts
|
||||
3 Particle emitters
|
||||
proc
|
||||
emit_particle()
|
||||
|
||||
1 power box
|
||||
the only part of this thing that uses power, can hack to mess with the pa/make it better
|
||||
|
||||
1 fuel chamber
|
||||
contains procs for mixing gas and whatever other fuel it uses
|
||||
mix_gas()
|
||||
|
||||
1 gas holder WIP
|
||||
acts like a tank valve on the ground that you wrench gas tanks onto
|
||||
proc
|
||||
extract_gas()
|
||||
return_gas()
|
||||
attach_tank()
|
||||
remove_tank()
|
||||
get_available_mix()
|
||||
|
||||
1 End Cap
|
||||
|
||||
1 Control computer
|
||||
interface for the pa, acts like a computer with an html menu for diff parts and a status report
|
||||
all other parts contain only a ref to this
|
||||
a /machine/, tells the others to do work
|
||||
contains ref for all parts
|
||||
proc
|
||||
process()
|
||||
check_build()
|
||||
|
||||
Setup map
|
||||
|EC|
|
||||
CC|FC|
|
||||
|PB|
|
||||
PE|PE|PE
|
||||
|
||||
|
||||
Icon Addemdum
|
||||
Icon system is much more robust, and the icons are all variable based.
|
||||
Each part has a reference string, powered, strength, and contruction values.
|
||||
Using this the update_icon() proc is simplified a bit (using for absolutely was problematic with naming),
|
||||
so the icon_state comes out be:
|
||||
"[reference][strength]", with a switch controlling construction_states and ensuring that it doesn't
|
||||
power on while being contructed, and all these variables are set by the computer through it's scan list
|
||||
Essential order of the icons:
|
||||
Standard - [reference]
|
||||
Wrenched - [reference]
|
||||
Wired - [reference]w
|
||||
Closed - [reference]c
|
||||
Powered - [reference]p[strength]
|
||||
Strength being set by the computer and a null strength (Computer is powered off or inactive) returns a 'null', counting as empty
|
||||
So, hopefully this is helpful if any more icons are to be added/changed/wondering what the hell is going on here
|
||||
|
||||
*/
|
||||
#define ACCELERATOR_UNWRENCHED 0
|
||||
#define ACCELERATOR_WRENCHED 1
|
||||
#define ACCELERATOR_WIRED 2
|
||||
#define ACCELERATOR_READY 3
|
||||
|
||||
/obj/structure/particle_accelerator
|
||||
name = "Particle Accelerator"
|
||||
desc = "Part of a Particle Accelerator."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "none"
|
||||
anchored = 0
|
||||
density = 1
|
||||
max_integrity = 500
|
||||
armor = list("melee" = 30, "bullet" = 20, "laser" = 20, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 90, "acid" = 80)
|
||||
var/obj/machinery/particle_accelerator/control_box/master = null
|
||||
var/construction_state = 0
|
||||
var/reference = null
|
||||
var/powered = 0
|
||||
var/strength = null
|
||||
var/desc_holder = null
|
||||
|
||||
/obj/structure/particle_accelerator/Destroy()
|
||||
construction_state = 0
|
||||
if(master)
|
||||
master.part_scan()
|
||||
return ..()
|
||||
|
||||
/obj/structure/particle_accelerator/end_cap
|
||||
name = "Alpha Particle Generation Array"
|
||||
desc_holder = "This is where Alpha particles are generated from \[REDACTED\]"
|
||||
icon_state = "end_cap"
|
||||
reference = "end_cap"
|
||||
|
||||
/obj/structure/particle_accelerator/update_icon()
|
||||
..()
|
||||
return
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/verb/rotate()
|
||||
set name = "Rotate Clockwise"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
if(anchored)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
dir = turn(dir, 270)
|
||||
return 1
|
||||
|
||||
/obj/structure/particle_accelerator/AltClick(mob/user)
|
||||
if(user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!Adjacent(user))
|
||||
return
|
||||
rotate()
|
||||
|
||||
/obj/structure/particle_accelerator/verb/rotateccw()
|
||||
set name = "Rotate Counter Clockwise"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
if(anchored)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
dir = turn(dir, 90)
|
||||
return 1
|
||||
|
||||
/obj/structure/particle_accelerator/examine(mob/user)
|
||||
switch(construction_state)
|
||||
if(0)
|
||||
desc = text("A [name], looks like it's not attached to the flooring")
|
||||
if(1)
|
||||
desc = text("A [name], it is missing some cables")
|
||||
if(2)
|
||||
desc = text("A [name], the panel is open")
|
||||
if(3)
|
||||
desc = text("The [name] is assembled")
|
||||
if(powered)
|
||||
desc = desc_holder
|
||||
. = ..()
|
||||
|
||||
/obj/structure/particle_accelerator/deconstruct(disassembled = TRUE)
|
||||
if(!(flags & NODECONSTRUCT))
|
||||
new /obj/item/stack/sheet/metal (loc, 5)
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/particle_accelerator/Move()
|
||||
. = ..()
|
||||
if(master && master.active)
|
||||
master.toggle_power()
|
||||
investigate_log("was moved whilst active; it <font color='red'>powered down</font>.","singulo")
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/blob_act(obj/structure/blob/B)
|
||||
if(prob(50))
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/particle_accelerator/update_icon()
|
||||
switch(construction_state)
|
||||
if(0,1)
|
||||
icon_state="[reference]"
|
||||
if(2)
|
||||
icon_state="[reference]w"
|
||||
if(3)
|
||||
if(powered)
|
||||
icon_state="[reference]p[strength]"
|
||||
else
|
||||
icon_state="[reference]c"
|
||||
return
|
||||
|
||||
/obj/structure/particle_accelerator/proc/update_state()
|
||||
if(master)
|
||||
master.update_state()
|
||||
return 0
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/proc/report_ready(var/obj/O)
|
||||
if(O && (O == master))
|
||||
if(construction_state >= 3)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/proc/report_master()
|
||||
if(master)
|
||||
return master
|
||||
return 0
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/proc/connect_master(var/obj/O)
|
||||
if(O && istype(O,/obj/machinery/particle_accelerator/control_box))
|
||||
if(O.dir == dir)
|
||||
master = O
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/structure/particle_accelerator/attackby(obj/item/W, mob/user, params)
|
||||
if(!iscoil(W))
|
||||
return ..()
|
||||
if(construction_state == ACCELERATOR_WRENCHED)
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(C.use(1))
|
||||
playsound(loc, C.usesound, 50, 1)
|
||||
user.visible_message("[user.name] adds wires to the [name].", \
|
||||
"You add some wires.")
|
||||
construction_state = ACCELERATOR_WIRED
|
||||
update_icon()
|
||||
|
||||
/obj/structure/particle_accelerator/screwdriver_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_WIRED && construction_state != ACCELERATOR_READY)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(construction_state == ACCELERATOR_WIRED)
|
||||
SCREWDRIVER_CLOSE_PANEL_MESSAGE
|
||||
construction_state = ACCELERATOR_READY
|
||||
|
||||
else
|
||||
construction_state = ACCELERATOR_WIRED
|
||||
SCREWDRIVER_OPEN_PANEL_MESSAGE
|
||||
update_state()
|
||||
update_icon()
|
||||
|
||||
/obj/structure/particle_accelerator/wirecutter_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_WIRED)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
WIRECUTTER_SNIP_MESSAGE
|
||||
construction_state = ACCELERATOR_WRENCHED
|
||||
|
||||
/obj/structure/particle_accelerator/wrench_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_UNWRENCHED && construction_state != ACCELERATOR_WRENCHED)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(construction_state == ACCELERATOR_UNWRENCHED)
|
||||
anchored = TRUE
|
||||
WRENCH_ANCHOR_MESSAGE
|
||||
construction_state = ACCELERATOR_WRENCHED
|
||||
else
|
||||
anchored = FALSE
|
||||
WRENCH_UNANCHOR_MESSAGE
|
||||
construction_state = ACCELERATOR_UNWRENCHED
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator
|
||||
name = "Particle Accelerator"
|
||||
desc = "Part of a Particle Accelerator."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "none"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 0
|
||||
var/construction_state = 0
|
||||
var/active = 0
|
||||
var/reference = null
|
||||
var/powered = null
|
||||
var/strength = 0
|
||||
var/desc_holder = null
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/verb/rotate()
|
||||
set name = "Rotate Clockwise"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
if(anchored)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
dir = turn(dir, 270)
|
||||
return 1
|
||||
|
||||
/obj/machinery/particle_accelerator/verb/rotateccw()
|
||||
set name = "Rotate Counter-Clockwise"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
if(anchored)
|
||||
to_chat(usr, "It is fastened to the floor!")
|
||||
return 0
|
||||
dir = turn(dir, 90)
|
||||
return 1
|
||||
|
||||
/obj/machinery/particle_accelerator/update_icon()
|
||||
return
|
||||
|
||||
/obj/machinery/particle_accelerator/attackby(obj/item/W, mob/user, params)
|
||||
if(!iscoil(W))
|
||||
return ..()
|
||||
if(construction_state == ACCELERATOR_WRENCHED)
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(C.use(1))
|
||||
playsound(loc, C.usesound, 50, 1)
|
||||
user.visible_message("[user.name] adds wires to the [name].", \
|
||||
"You add some wires.")
|
||||
construction_state = ACCELERATOR_WIRED
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/screwdriver_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_WIRED && construction_state != ACCELERATOR_READY)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(construction_state == ACCELERATOR_WIRED)
|
||||
SCREWDRIVER_CLOSE_PANEL_MESSAGE
|
||||
construction_state = ACCELERATOR_READY
|
||||
use_power = IDLE_POWER_USE
|
||||
else
|
||||
construction_state = ACCELERATOR_WIRED
|
||||
SCREWDRIVER_OPEN_PANEL_MESSAGE
|
||||
use_power = NO_POWER_USE
|
||||
update_state()
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/wirecutter_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_WIRED)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
WIRECUTTER_SNIP_MESSAGE
|
||||
construction_state = ACCELERATOR_WRENCHED
|
||||
|
||||
/obj/machinery/particle_accelerator/wrench_act(mob/user, obj/item/I)
|
||||
if(construction_state != ACCELERATOR_UNWRENCHED && construction_state != ACCELERATOR_WRENCHED)
|
||||
return
|
||||
. = TRUE
|
||||
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
|
||||
return
|
||||
if(construction_state == ACCELERATOR_UNWRENCHED)
|
||||
anchored = TRUE
|
||||
WRENCH_ANCHOR_MESSAGE
|
||||
construction_state = ACCELERATOR_WRENCHED
|
||||
else
|
||||
anchored = FALSE
|
||||
WRENCH_UNANCHOR_MESSAGE
|
||||
construction_state = ACCELERATOR_UNWRENCHED
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/proc/update_state()
|
||||
return 0
|
||||
|
||||
|
||||
#undef ACCELERATOR_UNWRENCHED
|
||||
#undef ACCELERATOR_WRENCHED
|
||||
#undef ACCELERATOR_WIRED
|
||||
#undef ACCELERATOR_READY
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/obj/structure/particle_accelerator/fuel_chamber
|
||||
name = "EM Acceleration Chamber"
|
||||
desc_holder = "This part is where the Alpha particles are accelerated to <b><i>radical speeds</i></b>."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "fuel_chamber"
|
||||
reference = "fuel_chamber"
|
||||
|
||||
/obj/structure/particle_accelerator/fuel_chamber/update_icon()
|
||||
..()
|
||||
return
|
||||
/obj/structure/particle_accelerator/fuel_chamber
|
||||
name = "EM Acceleration Chamber"
|
||||
desc_holder = "This part is where the Alpha particles are accelerated to <b><i>radical speeds</i></b>."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "fuel_chamber"
|
||||
reference = "fuel_chamber"
|
||||
|
||||
/obj/structure/particle_accelerator/fuel_chamber/update_icon()
|
||||
..()
|
||||
return
|
||||
|
||||
@@ -1,279 +1,279 @@
|
||||
/obj/machinery/particle_accelerator/control_box
|
||||
name = "Particle Accelerator Control Console"
|
||||
desc = "This part controls the density of the particles."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "control_box"
|
||||
reference = "control_box"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 500
|
||||
active_power_usage = 10000
|
||||
construction_state = 0
|
||||
active = 0
|
||||
dir = 1
|
||||
var/strength_upper_limit = 2
|
||||
var/interface_control = 1
|
||||
var/list/obj/structure/particle_accelerator/connected_parts
|
||||
var/assembled = 0
|
||||
var/parts = null
|
||||
var/datum/wires/particle_acc/control_box/wires = null
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/Initialize(mapload)
|
||||
. = ..()
|
||||
wires = new(src)
|
||||
connected_parts = list()
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/Destroy()
|
||||
if(active)
|
||||
toggle_power()
|
||||
QDEL_NULL(wires)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/attack_ghost(user as mob)
|
||||
return attack_hand(user)
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/attack_hand(mob/user as mob)
|
||||
if(construction_state >= 3)
|
||||
interact(user)
|
||||
else if(construction_state == 2) // Wires exposed
|
||||
wires.Interact(user)
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/update_state()
|
||||
if(construction_state < 3)
|
||||
use_power = NO_POWER_USE
|
||||
assembled = 0
|
||||
active = 0
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = null
|
||||
part.powered = 0
|
||||
part.update_icon()
|
||||
connected_parts = list()
|
||||
return
|
||||
if(!part_scan())
|
||||
use_power = IDLE_POWER_USE
|
||||
active = 0
|
||||
connected_parts = list()
|
||||
|
||||
return
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/update_icon()
|
||||
if(active)
|
||||
icon_state = "[reference]p[strength]"
|
||||
else
|
||||
if(stat & NOPOWER)
|
||||
icon_state = "[reference]w"
|
||||
return
|
||||
else if(use_power && assembled)
|
||||
icon_state = "[reference]p"
|
||||
else
|
||||
switch(construction_state)
|
||||
if(0)
|
||||
icon_state = "[reference]"
|
||||
if(1)
|
||||
icon_state = "[reference]"
|
||||
if(2)
|
||||
icon_state = "[reference]w"
|
||||
else
|
||||
icon_state = "[reference]c"
|
||||
return
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/Topic(href, href_list)
|
||||
if(..(href, href_list))
|
||||
return 1
|
||||
|
||||
if(!interface_control)
|
||||
to_chat(usr, "<span class='error'>ERROR: Request timed out. Check wire contacts.</span>")
|
||||
return
|
||||
|
||||
if(href_list["close"])
|
||||
usr << browse(null, "window=pacontrol")
|
||||
usr.unset_machine()
|
||||
return
|
||||
if(href_list["togglep"])
|
||||
if(!wires.IsIndexCut(PARTICLE_TOGGLE_WIRE))
|
||||
toggle_power()
|
||||
|
||||
else if(href_list["scan"])
|
||||
part_scan()
|
||||
|
||||
else if(href_list["strengthup"])
|
||||
if(!wires.IsIndexCut(PARTICLE_STRENGTH_WIRE))
|
||||
add_strength()
|
||||
|
||||
else if(href_list["strengthdown"])
|
||||
if(!wires.IsIndexCut(PARTICLE_STRENGTH_WIRE))
|
||||
remove_strength()
|
||||
|
||||
updateDialog()
|
||||
update_icon()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/strength_change()
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = strength
|
||||
part.update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/add_strength(var/s)
|
||||
if(assembled)
|
||||
strength++
|
||||
if(strength > strength_upper_limit)
|
||||
strength = strength_upper_limit
|
||||
else
|
||||
message_admins("PA Control Computer increased to [strength] by [key_name_admin(usr)] in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer increased to [strength] by [key_name(usr)] in ([x],[y],[z])")
|
||||
investigate_log("increased to <font color='red'>[strength]</font> by [key_name(usr)]","singulo")
|
||||
use_log += text("\[[time_stamp()]\] <font color='red'>[usr.name] ([key_name(usr)]) has increased the PA Control Computer to [strength].</font>")
|
||||
|
||||
investigate_log("increased to <font color='red'>[strength]</font> by [usr.key]","singulo")
|
||||
strength_change()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/remove_strength(var/s)
|
||||
if(assembled)
|
||||
strength--
|
||||
if(strength < 0)
|
||||
strength = 0
|
||||
else
|
||||
message_admins("PA Control Computer decreased to [strength] by [key_name_admin(usr)] in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer decreased to [strength] by [key_name(usr)] in ([x],[y],[z])")
|
||||
investigate_log("decreased to <font color='green'>[strength]</font> by [key_name(usr)]","singulo")
|
||||
use_log += text("\[[time_stamp()]\] <font color='orange'>[usr.name] ([key_name(usr)]) has decreased the PA Control Computer to [strength].</font>")
|
||||
|
||||
strength_change()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/power_change()
|
||||
..()
|
||||
if(stat & NOPOWER)
|
||||
active = 0
|
||||
use_power = NO_POWER_USE
|
||||
else if(!stat && construction_state <= 3)
|
||||
use_power = IDLE_POWER_USE
|
||||
update_icon()
|
||||
|
||||
if((stat & NOPOWER) || (!stat && construction_state <= 3)) //Only update the part icons if something's changed (i.e. any of the above condition sets are met).
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = null
|
||||
part.powered = 0
|
||||
part.update_icon()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/process()
|
||||
if(active)
|
||||
//a part is missing!
|
||||
if(length(connected_parts) < 6)
|
||||
investigate_log("lost a connected part; It <font color='red'>powered down</font>.","singulo")
|
||||
toggle_power()
|
||||
return
|
||||
//emit some particles
|
||||
for(var/obj/structure/particle_accelerator/particle_emitter/PE in connected_parts)
|
||||
if(PE)
|
||||
PE.emit_particle(strength)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/part_scan()
|
||||
for(var/obj/structure/particle_accelerator/fuel_chamber/F in orange(1,src))
|
||||
dir = F.dir
|
||||
connected_parts = list()
|
||||
var/tally = 0
|
||||
var/ldir = turn(dir,-90)
|
||||
var/rdir = turn(dir,90)
|
||||
var/odir = turn(dir,180)
|
||||
var/turf/T = loc
|
||||
T = get_step(T,rdir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/fuel_chamber))
|
||||
tally++
|
||||
T = get_step(T,odir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/end_cap))
|
||||
tally++
|
||||
T = get_step(T,dir)
|
||||
T = get_step(T,dir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/power_box))
|
||||
tally++
|
||||
T = get_step(T,dir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/center))
|
||||
tally++
|
||||
T = get_step(T,ldir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/left))
|
||||
tally++
|
||||
T = get_step(T,rdir)
|
||||
T = get_step(T,rdir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/right))
|
||||
tally++
|
||||
if(tally >= 6)
|
||||
assembled = 1
|
||||
return 1
|
||||
else
|
||||
assembled = 0
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/check_part(var/turf/T, var/type)
|
||||
if(!(T)||!(type))
|
||||
return 0
|
||||
var/obj/structure/particle_accelerator/PA = locate(/obj/structure/particle_accelerator) in T
|
||||
if(istype(PA, type))
|
||||
if(PA.connect_master(src))
|
||||
if(PA.report_ready(src))
|
||||
connected_parts.Add(PA)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/toggle_power()
|
||||
active = !active
|
||||
investigate_log("turned [active?"<font color='red'>ON</font>":"<font color='green'>OFF</font>"] by [usr ? usr.key : "outside forces"]","singulo")
|
||||
if(active)
|
||||
msg_admin_attack("PA Control Computer turned ON by [key_name_admin(usr)]", ATKLOG_FEW)
|
||||
log_game("PA Control Computer turned ON by [key_name(usr)] in ([x],[y],[z])")
|
||||
use_log += text("\[[time_stamp()]\] <font color='red'>[key_name(usr)] has turned on the PA Control Computer.</font>")
|
||||
if(active)
|
||||
use_power = ACTIVE_POWER_USE
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = strength
|
||||
part.powered = 1
|
||||
part.update_icon()
|
||||
else
|
||||
use_power = IDLE_POWER_USE
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = null
|
||||
part.powered = 0
|
||||
part.update_icon()
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/interact(mob/user)
|
||||
if(((get_dist(src, user) > 1) && !isobserver(user)) || (stat & (BROKEN|NOPOWER)))
|
||||
if(!istype(user, /mob/living/silicon))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=pacontrol")
|
||||
return
|
||||
user.set_machine(src)
|
||||
|
||||
var/dat = ""
|
||||
dat += "<A href='?src=[UID()];close=1'>Close</A><BR><BR>"
|
||||
dat += "<h3>Status</h3>"
|
||||
if(!assembled)
|
||||
dat += "Unable to detect all parts!<BR>"
|
||||
dat += "<A href='?src=[UID()];scan=1'>Run Scan</A><BR><BR>"
|
||||
else
|
||||
dat += "All parts in place.<BR><BR>"
|
||||
dat += "Power:"
|
||||
if(active)
|
||||
dat += "On<BR>"
|
||||
else
|
||||
dat += "Off <BR>"
|
||||
dat += "<A href='?src=[UID()];togglep=1'>Toggle Power</A><BR><BR>"
|
||||
dat += "Particle Strength: [strength] "
|
||||
dat += "<A href='?src=[UID()];strengthdown=1'>--</A>|<A href='?src=[UID()];strengthup=1'>++</A><BR><BR>"
|
||||
|
||||
//user << browse(dat, "window=pacontrol;size=420x500")
|
||||
//onclose(user, "pacontrol")
|
||||
var/datum/browser/popup = new(user, "pacontrol", name, 420, 500)
|
||||
popup.set_content(dat)
|
||||
popup.set_title_image(user.browse_rsc_icon(icon, icon_state))
|
||||
popup.open()
|
||||
return
|
||||
/obj/machinery/particle_accelerator/control_box
|
||||
name = "Particle Accelerator Control Console"
|
||||
desc = "This part controls the density of the particles."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "control_box"
|
||||
reference = "control_box"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 500
|
||||
active_power_usage = 10000
|
||||
construction_state = 0
|
||||
active = 0
|
||||
dir = 1
|
||||
var/strength_upper_limit = 2
|
||||
var/interface_control = 1
|
||||
var/list/obj/structure/particle_accelerator/connected_parts
|
||||
var/assembled = 0
|
||||
var/parts = null
|
||||
var/datum/wires/particle_acc/control_box/wires = null
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/Initialize(mapload)
|
||||
. = ..()
|
||||
wires = new(src)
|
||||
connected_parts = list()
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/Destroy()
|
||||
if(active)
|
||||
toggle_power()
|
||||
QDEL_NULL(wires)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/attack_ghost(user as mob)
|
||||
return attack_hand(user)
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/attack_hand(mob/user as mob)
|
||||
if(construction_state >= 3)
|
||||
interact(user)
|
||||
else if(construction_state == 2) // Wires exposed
|
||||
wires.Interact(user)
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/update_state()
|
||||
if(construction_state < 3)
|
||||
use_power = NO_POWER_USE
|
||||
assembled = 0
|
||||
active = 0
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = null
|
||||
part.powered = 0
|
||||
part.update_icon()
|
||||
connected_parts = list()
|
||||
return
|
||||
if(!part_scan())
|
||||
use_power = IDLE_POWER_USE
|
||||
active = 0
|
||||
connected_parts = list()
|
||||
|
||||
return
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/update_icon()
|
||||
if(active)
|
||||
icon_state = "[reference]p[strength]"
|
||||
else
|
||||
if(stat & NOPOWER)
|
||||
icon_state = "[reference]w"
|
||||
return
|
||||
else if(use_power && assembled)
|
||||
icon_state = "[reference]p"
|
||||
else
|
||||
switch(construction_state)
|
||||
if(0)
|
||||
icon_state = "[reference]"
|
||||
if(1)
|
||||
icon_state = "[reference]"
|
||||
if(2)
|
||||
icon_state = "[reference]w"
|
||||
else
|
||||
icon_state = "[reference]c"
|
||||
return
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/Topic(href, href_list)
|
||||
if(..(href, href_list))
|
||||
return 1
|
||||
|
||||
if(!interface_control)
|
||||
to_chat(usr, "<span class='error'>ERROR: Request timed out. Check wire contacts.</span>")
|
||||
return
|
||||
|
||||
if(href_list["close"])
|
||||
usr << browse(null, "window=pacontrol")
|
||||
usr.unset_machine()
|
||||
return
|
||||
if(href_list["togglep"])
|
||||
if(!wires.IsIndexCut(PARTICLE_TOGGLE_WIRE))
|
||||
toggle_power()
|
||||
|
||||
else if(href_list["scan"])
|
||||
part_scan()
|
||||
|
||||
else if(href_list["strengthup"])
|
||||
if(!wires.IsIndexCut(PARTICLE_STRENGTH_WIRE))
|
||||
add_strength()
|
||||
|
||||
else if(href_list["strengthdown"])
|
||||
if(!wires.IsIndexCut(PARTICLE_STRENGTH_WIRE))
|
||||
remove_strength()
|
||||
|
||||
updateDialog()
|
||||
update_icon()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/strength_change()
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = strength
|
||||
part.update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/add_strength(var/s)
|
||||
if(assembled)
|
||||
strength++
|
||||
if(strength > strength_upper_limit)
|
||||
strength = strength_upper_limit
|
||||
else
|
||||
message_admins("PA Control Computer increased to [strength] by [key_name_admin(usr)] in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer increased to [strength] by [key_name(usr)] in ([x],[y],[z])")
|
||||
investigate_log("increased to <font color='red'>[strength]</font> by [key_name(usr)]","singulo")
|
||||
use_log += text("\[[time_stamp()]\] <font color='red'>[usr.name] ([key_name(usr)]) has increased the PA Control Computer to [strength].</font>")
|
||||
|
||||
investigate_log("increased to <font color='red'>[strength]</font> by [usr.key]","singulo")
|
||||
strength_change()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/remove_strength(var/s)
|
||||
if(assembled)
|
||||
strength--
|
||||
if(strength < 0)
|
||||
strength = 0
|
||||
else
|
||||
message_admins("PA Control Computer decreased to [strength] by [key_name_admin(usr)] in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer decreased to [strength] by [key_name(usr)] in ([x],[y],[z])")
|
||||
investigate_log("decreased to <font color='green'>[strength]</font> by [key_name(usr)]","singulo")
|
||||
use_log += text("\[[time_stamp()]\] <font color='orange'>[usr.name] ([key_name(usr)]) has decreased the PA Control Computer to [strength].</font>")
|
||||
|
||||
strength_change()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/power_change()
|
||||
..()
|
||||
if(stat & NOPOWER)
|
||||
active = 0
|
||||
use_power = NO_POWER_USE
|
||||
else if(!stat && construction_state <= 3)
|
||||
use_power = IDLE_POWER_USE
|
||||
update_icon()
|
||||
|
||||
if((stat & NOPOWER) || (!stat && construction_state <= 3)) //Only update the part icons if something's changed (i.e. any of the above condition sets are met).
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = null
|
||||
part.powered = 0
|
||||
part.update_icon()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/process()
|
||||
if(active)
|
||||
//a part is missing!
|
||||
if(length(connected_parts) < 6)
|
||||
investigate_log("lost a connected part; It <font color='red'>powered down</font>.","singulo")
|
||||
toggle_power()
|
||||
return
|
||||
//emit some particles
|
||||
for(var/obj/structure/particle_accelerator/particle_emitter/PE in connected_parts)
|
||||
if(PE)
|
||||
PE.emit_particle(strength)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/part_scan()
|
||||
for(var/obj/structure/particle_accelerator/fuel_chamber/F in orange(1,src))
|
||||
dir = F.dir
|
||||
connected_parts = list()
|
||||
var/tally = 0
|
||||
var/ldir = turn(dir,-90)
|
||||
var/rdir = turn(dir,90)
|
||||
var/odir = turn(dir,180)
|
||||
var/turf/T = loc
|
||||
T = get_step(T,rdir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/fuel_chamber))
|
||||
tally++
|
||||
T = get_step(T,odir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/end_cap))
|
||||
tally++
|
||||
T = get_step(T,dir)
|
||||
T = get_step(T,dir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/power_box))
|
||||
tally++
|
||||
T = get_step(T,dir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/center))
|
||||
tally++
|
||||
T = get_step(T,ldir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/left))
|
||||
tally++
|
||||
T = get_step(T,rdir)
|
||||
T = get_step(T,rdir)
|
||||
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/right))
|
||||
tally++
|
||||
if(tally >= 6)
|
||||
assembled = 1
|
||||
return 1
|
||||
else
|
||||
assembled = 0
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/check_part(var/turf/T, var/type)
|
||||
if(!(T)||!(type))
|
||||
return 0
|
||||
var/obj/structure/particle_accelerator/PA = locate(/obj/structure/particle_accelerator) in T
|
||||
if(istype(PA, type))
|
||||
if(PA.connect_master(src))
|
||||
if(PA.report_ready(src))
|
||||
connected_parts.Add(PA)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/toggle_power()
|
||||
active = !active
|
||||
investigate_log("turned [active?"<font color='red'>ON</font>":"<font color='green'>OFF</font>"] by [usr ? usr.key : "outside forces"]","singulo")
|
||||
if(active)
|
||||
msg_admin_attack("PA Control Computer turned ON by [key_name_admin(usr)]", ATKLOG_FEW)
|
||||
log_game("PA Control Computer turned ON by [key_name(usr)] in ([x],[y],[z])")
|
||||
use_log += text("\[[time_stamp()]\] <font color='red'>[key_name(usr)] has turned on the PA Control Computer.</font>")
|
||||
if(active)
|
||||
use_power = ACTIVE_POWER_USE
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = strength
|
||||
part.powered = 1
|
||||
part.update_icon()
|
||||
else
|
||||
use_power = IDLE_POWER_USE
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = null
|
||||
part.powered = 0
|
||||
part.update_icon()
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/interact(mob/user)
|
||||
if(((get_dist(src, user) > 1) && !isobserver(user)) || (stat & (BROKEN|NOPOWER)))
|
||||
if(!istype(user, /mob/living/silicon))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=pacontrol")
|
||||
return
|
||||
user.set_machine(src)
|
||||
|
||||
var/dat = ""
|
||||
dat += "<A href='?src=[UID()];close=1'>Close</A><BR><BR>"
|
||||
dat += "<h3>Status</h3>"
|
||||
if(!assembled)
|
||||
dat += "Unable to detect all parts!<BR>"
|
||||
dat += "<A href='?src=[UID()];scan=1'>Run Scan</A><BR><BR>"
|
||||
else
|
||||
dat += "All parts in place.<BR><BR>"
|
||||
dat += "Power:"
|
||||
if(active)
|
||||
dat += "On<BR>"
|
||||
else
|
||||
dat += "Off <BR>"
|
||||
dat += "<A href='?src=[UID()];togglep=1'>Toggle Power</A><BR><BR>"
|
||||
dat += "Particle Strength: [strength] "
|
||||
dat += "<A href='?src=[UID()];strengthdown=1'>--</A>|<A href='?src=[UID()];strengthup=1'>++</A><BR><BR>"
|
||||
|
||||
//user << browse(dat, "window=pacontrol;size=420x500")
|
||||
//onclose(user, "pacontrol")
|
||||
var/datum/browser/popup = new(user, "pacontrol", name, 420, 500)
|
||||
popup.set_content(dat)
|
||||
popup.set_title_image(user.browse_rsc_icon(icon, icon_state))
|
||||
popup.open()
|
||||
return
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
/obj/structure/particle_accelerator/particle_emitter
|
||||
name = "EM Containment Grid"
|
||||
desc_holder = "This part launches the Alpha particles. You might not want to stand near this end."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "none"
|
||||
var/fire_delay = 50
|
||||
var/last_shot = 0
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/center
|
||||
icon_state = "emitter_center"
|
||||
reference = "emitter_center"
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/left
|
||||
icon_state = "emitter_left"
|
||||
reference = "emitter_left"
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/right
|
||||
icon_state = "emitter_right"
|
||||
reference = "emitter_right"
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/update_icon()
|
||||
..()
|
||||
return
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/proc/set_delay(var/delay)
|
||||
if(delay && delay >= 0)
|
||||
fire_delay = delay
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/proc/emit_particle(strength = 0)
|
||||
if((last_shot + fire_delay) <= world.time)
|
||||
last_shot = world.time
|
||||
var/turf/T = get_turf(src)
|
||||
var/obj/effect/accelerated_particle/P
|
||||
switch(strength)
|
||||
if(0)
|
||||
P = new/obj/effect/accelerated_particle/weak(T)
|
||||
if(1)
|
||||
P = new/obj/effect/accelerated_particle(T)
|
||||
if(2)
|
||||
P = new/obj/effect/accelerated_particle/strong(T)
|
||||
if(3)
|
||||
P = new/obj/effect/accelerated_particle/powerful(T)
|
||||
P.setDir(dir)
|
||||
return TRUE
|
||||
return FALSE
|
||||
/obj/structure/particle_accelerator/particle_emitter
|
||||
name = "EM Containment Grid"
|
||||
desc_holder = "This part launches the Alpha particles. You might not want to stand near this end."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "none"
|
||||
var/fire_delay = 50
|
||||
var/last_shot = 0
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/center
|
||||
icon_state = "emitter_center"
|
||||
reference = "emitter_center"
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/left
|
||||
icon_state = "emitter_left"
|
||||
reference = "emitter_left"
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/right
|
||||
icon_state = "emitter_right"
|
||||
reference = "emitter_right"
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/update_icon()
|
||||
..()
|
||||
return
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/proc/set_delay(var/delay)
|
||||
if(delay && delay >= 0)
|
||||
fire_delay = delay
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/structure/particle_accelerator/particle_emitter/proc/emit_particle(strength = 0)
|
||||
if((last_shot + fire_delay) <= world.time)
|
||||
last_shot = world.time
|
||||
var/turf/T = get_turf(src)
|
||||
var/obj/effect/accelerated_particle/P
|
||||
switch(strength)
|
||||
if(0)
|
||||
P = new/obj/effect/accelerated_particle/weak(T)
|
||||
if(1)
|
||||
P = new/obj/effect/accelerated_particle(T)
|
||||
if(2)
|
||||
P = new/obj/effect/accelerated_particle/strong(T)
|
||||
if(3)
|
||||
P = new/obj/effect/accelerated_particle/powerful(T)
|
||||
P.setDir(dir)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/obj/structure/particle_accelerator/power_box
|
||||
name = "Particle Focusing EM Lens"
|
||||
desc_holder = "This part uses electromagnetic waves to focus the Alpha particles."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "power_box"
|
||||
reference = "power_box"
|
||||
/obj/structure/particle_accelerator/power_box
|
||||
name = "Particle Focusing EM Lens"
|
||||
desc_holder = "This part uses electromagnetic waves to focus the Alpha particles."
|
||||
icon = 'icons/obj/machines/particle_accelerator.dmi'
|
||||
icon_state = "power_box"
|
||||
reference = "power_box"
|
||||
|
||||
@@ -1,443 +1,443 @@
|
||||
/obj/singularity
|
||||
name = "gravitational singularity"
|
||||
desc = "A gravitational singularity."
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "singularity_s1"
|
||||
anchored = 1
|
||||
density = 1
|
||||
layer = MASSIVE_OBJ_LAYER
|
||||
light_range = 6
|
||||
appearance_flags = 0
|
||||
var/current_size = 1
|
||||
var/allowed_size = 1
|
||||
var/contained = 1 //Are we going to move around?
|
||||
var/energy = 100 //How strong are we?
|
||||
var/dissipate = 1 //Do we lose energy over time?
|
||||
var/dissipate_delay = 10
|
||||
var/dissipate_track = 0
|
||||
var/dissipate_strength = 1 //How much energy do we lose?
|
||||
var/move_self = 1 //Do we move on our own?
|
||||
var/grav_pull = 4 //How many tiles out do we pull?
|
||||
move_resist = INFINITY //no, you don't get to push the singulo. Not even you OP wizard gateway statues
|
||||
var/consume_range = 0 //How many tiles out do we eat
|
||||
var/event_chance = 15 //Prob for event each tick
|
||||
var/target = null //its target. moves towards the target if it has one
|
||||
var/last_failed_movement = 0//Will not move in the same dir if it couldnt before, will help with the getting stuck on fields thing
|
||||
var/last_warning
|
||||
var/consumedSupermatter = 0 //If the singularity has eaten a supermatter shard and can go to stage six
|
||||
allow_spin = 0
|
||||
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF | FREEZE_PROOF
|
||||
|
||||
/obj/singularity/New(loc, var/starting_energy = 50, var/temp = 0)
|
||||
//CARN: admin-alert for chuckle-fuckery.
|
||||
admin_investigate_setup()
|
||||
|
||||
src.energy = starting_energy
|
||||
..()
|
||||
START_PROCESSING(SSobj, src)
|
||||
GLOB.poi_list |= src
|
||||
GLOB.singularities += src
|
||||
for(var/obj/machinery/power/singularity_beacon/singubeacon in GLOB.machines)
|
||||
if(singubeacon.active)
|
||||
target = singubeacon
|
||||
break
|
||||
|
||||
/obj/singularity/Destroy()
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
GLOB.poi_list.Remove(src)
|
||||
GLOB.singularities -= src
|
||||
target = null
|
||||
return ..()
|
||||
|
||||
/obj/singularity/Move(atom/newloc, direct)
|
||||
if(current_size >= STAGE_FIVE || check_turfs_in(direct))
|
||||
last_failed_movement = 0//Reset this because we moved
|
||||
return ..()
|
||||
else
|
||||
last_failed_movement = direct
|
||||
return 0
|
||||
|
||||
|
||||
/obj/singularity/attack_hand(mob/user)
|
||||
consume(user)
|
||||
return 1
|
||||
|
||||
/obj/singularity/attack_alien(mob/user)
|
||||
consume(user)
|
||||
|
||||
/obj/singularity/attack_animal(mob/user)
|
||||
consume(user)
|
||||
|
||||
/obj/singularity/attackby(obj/item/W, mob/user, params)
|
||||
consume(user)
|
||||
return 1
|
||||
|
||||
/obj/singularity/Process_Spacemove() //The singularity stops drifting for no man!
|
||||
return 0
|
||||
|
||||
/obj/singularity/blob_act(obj/structure/blob/B)
|
||||
return
|
||||
|
||||
/obj/singularity/ex_act(severity)
|
||||
switch(severity)
|
||||
if(1)
|
||||
if(current_size <= STAGE_TWO)
|
||||
investigate_log("has been destroyed by a heavy explosion.","singulo")
|
||||
qdel(src)
|
||||
return
|
||||
else
|
||||
energy -= round(((energy+1)/2),1)
|
||||
if(2)
|
||||
energy -= round(((energy+1)/3),1)
|
||||
if(3)
|
||||
energy -= round(((energy+1)/4),1)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/bullet_act(obj/item/projectile/P)
|
||||
qdel(P)
|
||||
return 0 //Will there be an impact? Who knows. Will we see it? No.
|
||||
|
||||
|
||||
/obj/singularity/Bump(atom/A)
|
||||
consume(A)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/Bumped(atom/A)
|
||||
consume(A)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/process()
|
||||
if(allowed_size >= STAGE_TWO)
|
||||
// Start moving even before we reach "true" stage two.
|
||||
// If we are stage one and are sufficiently energetic to be allowed to 2,
|
||||
// it might mean we are stuck in a corner somewere. So move around to try to expand.
|
||||
move()
|
||||
if(current_size >= STAGE_TWO)
|
||||
pulse()
|
||||
if(prob(event_chance))//Chance for it to run a special event TODO:Come up with one or two more that fit
|
||||
event()
|
||||
eat()
|
||||
dissipate()
|
||||
check_energy()
|
||||
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/attack_ai() //to prevent ais from gibbing themselves when they click on one.
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/admin_investigate_setup()
|
||||
last_warning = world.time
|
||||
var/count = locate(/obj/machinery/field/containment) in urange(30, src, 1)
|
||||
if(!count)
|
||||
message_admins("A singularity has been created without containment fields active at [x], [y], [z] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)")
|
||||
investigate_log("was created. [count?"":"<font color='red'>No containment fields were active</font>"]","singulo")
|
||||
|
||||
/obj/singularity/proc/dissipate()
|
||||
if(!dissipate)
|
||||
return
|
||||
if(dissipate_track >= dissipate_delay)
|
||||
src.energy -= dissipate_strength
|
||||
dissipate_track = 0
|
||||
else
|
||||
dissipate_track++
|
||||
|
||||
|
||||
/obj/singularity/proc/expand(force_size = 0)
|
||||
var/temp_allowed_size = src.allowed_size
|
||||
if(force_size)
|
||||
temp_allowed_size = force_size
|
||||
if(temp_allowed_size >= STAGE_SIX && !consumedSupermatter)
|
||||
temp_allowed_size = STAGE_FIVE
|
||||
switch(temp_allowed_size)
|
||||
if(STAGE_ONE)
|
||||
current_size = STAGE_ONE
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "singularity_s1"
|
||||
pixel_x = 0
|
||||
pixel_y = 0
|
||||
grav_pull = 4
|
||||
consume_range = 0
|
||||
dissipate_delay = 10
|
||||
dissipate_track = 0
|
||||
dissipate_strength = 1
|
||||
if(STAGE_TWO)
|
||||
if((check_turfs_in(1,1))&&(check_turfs_in(2,1))&&(check_turfs_in(4,1))&&(check_turfs_in(8,1)))
|
||||
current_size = STAGE_TWO
|
||||
icon = 'icons/effects/96x96.dmi'
|
||||
icon_state = "singularity_s3"
|
||||
pixel_x = -32
|
||||
pixel_y = -32
|
||||
grav_pull = 6
|
||||
consume_range = 1
|
||||
dissipate_delay = 5
|
||||
dissipate_track = 0
|
||||
dissipate_strength = 5
|
||||
if(STAGE_THREE)
|
||||
if((check_turfs_in(1,2))&&(check_turfs_in(2,2))&&(check_turfs_in(4,2))&&(check_turfs_in(8,2)))
|
||||
current_size = STAGE_THREE
|
||||
icon = 'icons/effects/160x160.dmi'
|
||||
icon_state = "singularity_s5"
|
||||
pixel_x = -64
|
||||
pixel_y = -64
|
||||
grav_pull = 8
|
||||
consume_range = 2
|
||||
dissipate_delay = 4
|
||||
dissipate_track = 0
|
||||
dissipate_strength = 20
|
||||
if(STAGE_FOUR)
|
||||
if((check_turfs_in(1,3))&&(check_turfs_in(2,3))&&(check_turfs_in(4,3))&&(check_turfs_in(8,3)))
|
||||
current_size = STAGE_FOUR
|
||||
icon = 'icons/effects/224x224.dmi'
|
||||
icon_state = "singularity_s7"
|
||||
pixel_x = -96
|
||||
pixel_y = -96
|
||||
grav_pull = 10
|
||||
consume_range = 3
|
||||
dissipate_delay = 10
|
||||
dissipate_track = 0
|
||||
dissipate_strength = 10
|
||||
if(STAGE_FIVE)//this one also lacks a check for gens because it eats everything
|
||||
current_size = STAGE_FIVE
|
||||
icon = 'icons/effects/288x288.dmi'
|
||||
icon_state = "singularity_s9"
|
||||
pixel_x = -128
|
||||
pixel_y = -128
|
||||
grav_pull = 10
|
||||
consume_range = 4
|
||||
dissipate = 0 //It cant go smaller due to e loss
|
||||
if(STAGE_SIX) //This only happens if a stage 5 singulo consumes a supermatter shard.
|
||||
current_size = STAGE_SIX
|
||||
icon = 'icons/effects/352x352.dmi'
|
||||
icon_state = "singularity_s11"
|
||||
pixel_x = -160
|
||||
pixel_y = -160
|
||||
grav_pull = 15
|
||||
consume_range = 5
|
||||
dissipate = 0
|
||||
if(current_size == allowed_size)
|
||||
investigate_log("<font color='red'>grew to size [current_size]</font>","singulo")
|
||||
return 1
|
||||
else if(current_size < (--temp_allowed_size))
|
||||
expand(temp_allowed_size)
|
||||
else
|
||||
return 0
|
||||
|
||||
|
||||
/obj/singularity/proc/check_energy()
|
||||
if(energy <= 0)
|
||||
investigate_log("collapsed.","singulo")
|
||||
qdel(src)
|
||||
return 0
|
||||
switch(energy)//Some of these numbers might need to be changed up later -Mport
|
||||
if(1 to 199)
|
||||
allowed_size = STAGE_ONE
|
||||
if(200 to 499)
|
||||
allowed_size = STAGE_TWO
|
||||
if(500 to 999)
|
||||
allowed_size = STAGE_THREE
|
||||
if(1000 to 1999)
|
||||
allowed_size = STAGE_FOUR
|
||||
if(2000 to INFINITY)
|
||||
if(energy >= 3000 && consumedSupermatter)
|
||||
allowed_size = STAGE_SIX
|
||||
else
|
||||
allowed_size = STAGE_FIVE
|
||||
if(current_size != allowed_size)
|
||||
expand()
|
||||
return 1
|
||||
|
||||
|
||||
/obj/singularity/proc/eat()
|
||||
set background = BACKGROUND_ENABLED
|
||||
for(var/tile in spiral_range_turfs(grav_pull, src))
|
||||
var/turf/T = tile
|
||||
if(!T || !isturf(loc))
|
||||
continue
|
||||
if(get_dist(T, src) > consume_range)
|
||||
T.singularity_pull(src, current_size)
|
||||
else
|
||||
consume(T)
|
||||
for(var/thing in T)
|
||||
if(isturf(loc) && thing != src)
|
||||
var/atom/movable/X = thing
|
||||
if(get_dist(X, src) > consume_range)
|
||||
X.singularity_pull(src, current_size)
|
||||
else
|
||||
consume(X)
|
||||
CHECK_TICK
|
||||
|
||||
|
||||
/obj/singularity/proc/consume(atom/A)
|
||||
var/gain = A.singularity_act(current_size)
|
||||
src.energy += gain
|
||||
if(istype(A, /obj/machinery/power/supermatter_shard) && !consumedSupermatter)
|
||||
desc = "[initial(desc)] It glows fiercely with inner fire."
|
||||
name = "supermatter-charged [initial(name)]"
|
||||
consumedSupermatter = 1
|
||||
set_light(10)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/move(force_move = 0)
|
||||
if(!move_self)
|
||||
return 0
|
||||
|
||||
var/movement_dir = pick(alldirs - last_failed_movement)
|
||||
|
||||
if(force_move)
|
||||
movement_dir = force_move
|
||||
|
||||
if(target && prob(60))
|
||||
movement_dir = get_dir(src,target) //moves to a singulo beacon, if there is one
|
||||
|
||||
step(src, movement_dir)
|
||||
|
||||
|
||||
/obj/singularity/proc/check_turfs_in(direction = 0, step = 0)
|
||||
if(!direction)
|
||||
return 0
|
||||
var/steps = 0
|
||||
if(!step)
|
||||
switch(current_size)
|
||||
if(STAGE_ONE)
|
||||
steps = 1
|
||||
if(STAGE_TWO)
|
||||
steps = 3//Yes this is right
|
||||
if(STAGE_THREE)
|
||||
steps = 3
|
||||
if(STAGE_FOUR)
|
||||
steps = 4
|
||||
if(STAGE_FIVE)
|
||||
steps = 5
|
||||
else
|
||||
steps = step
|
||||
var/list/turfs = list()
|
||||
var/turf/T = src.loc
|
||||
for(var/i = 1 to steps)
|
||||
T = get_step(T,direction)
|
||||
if(!isturf(T))
|
||||
return 0
|
||||
turfs.Add(T)
|
||||
var/dir2 = 0
|
||||
var/dir3 = 0
|
||||
switch(direction)
|
||||
if(NORTH||SOUTH)
|
||||
dir2 = 4
|
||||
dir3 = 8
|
||||
if(EAST||WEST)
|
||||
dir2 = 1
|
||||
dir3 = 2
|
||||
var/turf/T2 = T
|
||||
for(var/j = 1 to steps-1)
|
||||
T2 = get_step(T2,dir2)
|
||||
if(!isturf(T2))
|
||||
return 0
|
||||
turfs.Add(T2)
|
||||
for(var/k = 1 to steps-1)
|
||||
T = get_step(T,dir3)
|
||||
if(!isturf(T))
|
||||
return 0
|
||||
turfs.Add(T)
|
||||
for(var/turf/T3 in turfs)
|
||||
if(isnull(T3))
|
||||
continue
|
||||
if(!can_move(T3))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/obj/singularity/proc/can_move(turf/T)
|
||||
if(!T)
|
||||
return 0
|
||||
if((locate(/obj/machinery/field/containment) in T)||(locate(/obj/machinery/shieldwall) in T))
|
||||
return 0
|
||||
else if(locate(/obj/machinery/field/generator) in T)
|
||||
var/obj/machinery/field/generator/G = locate(/obj/machinery/field/generator) in T
|
||||
if(G && G.active)
|
||||
return 0
|
||||
else if(locate(/obj/machinery/shieldwallgen) in T)
|
||||
var/obj/machinery/shieldwallgen/S = locate(/obj/machinery/shieldwallgen) in T
|
||||
if(S && S.active)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/obj/singularity/proc/event()
|
||||
var/numb = pick(1,2,3,4,5,6)
|
||||
switch(numb)
|
||||
if(1)//EMP
|
||||
emp_area()
|
||||
if(2,3)//tox damage all carbon mobs in area
|
||||
toxmob()
|
||||
if(4)//Stun mobs who lack optic scanners
|
||||
mezzer()
|
||||
if(5,6) //Sets all nearby mobs on fire
|
||||
if(current_size < STAGE_SIX)
|
||||
return 0
|
||||
combust_mobs()
|
||||
else
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/obj/singularity/proc/toxmob()
|
||||
var/toxrange = 10
|
||||
var/radiation = 15
|
||||
var/radiationmin = 3
|
||||
if(energy>200)
|
||||
radiation += round((energy-150)/10,1)
|
||||
radiationmin = round((radiation/5),1)
|
||||
for(var/mob/living/M in view(toxrange, src.loc))
|
||||
M.apply_effect(rand(radiationmin,radiation), IRRADIATE)
|
||||
|
||||
|
||||
/obj/singularity/proc/combust_mobs()
|
||||
for(var/mob/living/carbon/C in urange(20, src, 1))
|
||||
C.visible_message("<span class='warning'>[C]'s skin bursts into flame!</span>", \
|
||||
"<span class='userdanger'>You feel an inner fire as your skin bursts into flames!</span>")
|
||||
C.adjust_fire_stacks(5)
|
||||
C.IgniteMob()
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/mezzer()
|
||||
for(var/mob/living/carbon/M in oviewers(8, src))
|
||||
if(istype(M, /mob/living/carbon/brain)) //Ignore brains
|
||||
continue
|
||||
|
||||
if(M.stat == CONSCIOUS)
|
||||
if(ishuman(M))
|
||||
var/mob/living/carbon/human/H = M
|
||||
if(istype(H.glasses, /obj/item/clothing/glasses/meson))
|
||||
var/obj/item/clothing/glasses/meson/MS = H.glasses
|
||||
if(MS.vision_flags == SEE_TURFS)
|
||||
to_chat(H, "<span class='notice'>You look directly into the [src.name], good thing you had your protective eyewear on!</span>")
|
||||
return
|
||||
|
||||
M.apply_effect(3, STUN)
|
||||
M.visible_message("<span class='danger'>[M] stares blankly at the [src.name]!</span>", \
|
||||
"<span class='userdanger'>You look directly into the [src.name] and feel weak.</span>")
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/emp_area()
|
||||
empulse(src, 8, 10)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/pulse()
|
||||
for(var/obj/machinery/power/rad_collector/R in rad_collectors)
|
||||
if(R.z == z && get_dist(R, src) <= 15) // Better than using orange() every process
|
||||
R.receive_pulse(energy)
|
||||
|
||||
/obj/singularity/singularity_act()
|
||||
var/gain = (energy/2)
|
||||
var/dist = max((current_size - 2),1)
|
||||
explosion(src.loc,(dist),(dist*2),(dist*4))
|
||||
qdel(src)
|
||||
return(gain)
|
||||
/obj/singularity
|
||||
name = "gravitational singularity"
|
||||
desc = "A gravitational singularity."
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "singularity_s1"
|
||||
anchored = 1
|
||||
density = 1
|
||||
layer = MASSIVE_OBJ_LAYER
|
||||
light_range = 6
|
||||
appearance_flags = 0
|
||||
var/current_size = 1
|
||||
var/allowed_size = 1
|
||||
var/contained = 1 //Are we going to move around?
|
||||
var/energy = 100 //How strong are we?
|
||||
var/dissipate = 1 //Do we lose energy over time?
|
||||
var/dissipate_delay = 10
|
||||
var/dissipate_track = 0
|
||||
var/dissipate_strength = 1 //How much energy do we lose?
|
||||
var/move_self = 1 //Do we move on our own?
|
||||
var/grav_pull = 4 //How many tiles out do we pull?
|
||||
move_resist = INFINITY //no, you don't get to push the singulo. Not even you OP wizard gateway statues
|
||||
var/consume_range = 0 //How many tiles out do we eat
|
||||
var/event_chance = 15 //Prob for event each tick
|
||||
var/target = null //its target. moves towards the target if it has one
|
||||
var/last_failed_movement = 0//Will not move in the same dir if it couldnt before, will help with the getting stuck on fields thing
|
||||
var/last_warning
|
||||
var/consumedSupermatter = 0 //If the singularity has eaten a supermatter shard and can go to stage six
|
||||
allow_spin = 0
|
||||
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF | FREEZE_PROOF
|
||||
|
||||
/obj/singularity/New(loc, var/starting_energy = 50, var/temp = 0)
|
||||
//CARN: admin-alert for chuckle-fuckery.
|
||||
admin_investigate_setup()
|
||||
|
||||
src.energy = starting_energy
|
||||
..()
|
||||
START_PROCESSING(SSobj, src)
|
||||
GLOB.poi_list |= src
|
||||
GLOB.singularities += src
|
||||
for(var/obj/machinery/power/singularity_beacon/singubeacon in GLOB.machines)
|
||||
if(singubeacon.active)
|
||||
target = singubeacon
|
||||
break
|
||||
|
||||
/obj/singularity/Destroy()
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
GLOB.poi_list.Remove(src)
|
||||
GLOB.singularities -= src
|
||||
target = null
|
||||
return ..()
|
||||
|
||||
/obj/singularity/Move(atom/newloc, direct)
|
||||
if(current_size >= STAGE_FIVE || check_turfs_in(direct))
|
||||
last_failed_movement = 0//Reset this because we moved
|
||||
return ..()
|
||||
else
|
||||
last_failed_movement = direct
|
||||
return 0
|
||||
|
||||
|
||||
/obj/singularity/attack_hand(mob/user)
|
||||
consume(user)
|
||||
return 1
|
||||
|
||||
/obj/singularity/attack_alien(mob/user)
|
||||
consume(user)
|
||||
|
||||
/obj/singularity/attack_animal(mob/user)
|
||||
consume(user)
|
||||
|
||||
/obj/singularity/attackby(obj/item/W, mob/user, params)
|
||||
consume(user)
|
||||
return 1
|
||||
|
||||
/obj/singularity/Process_Spacemove() //The singularity stops drifting for no man!
|
||||
return 0
|
||||
|
||||
/obj/singularity/blob_act(obj/structure/blob/B)
|
||||
return
|
||||
|
||||
/obj/singularity/ex_act(severity)
|
||||
switch(severity)
|
||||
if(1)
|
||||
if(current_size <= STAGE_TWO)
|
||||
investigate_log("has been destroyed by a heavy explosion.","singulo")
|
||||
qdel(src)
|
||||
return
|
||||
else
|
||||
energy -= round(((energy+1)/2),1)
|
||||
if(2)
|
||||
energy -= round(((energy+1)/3),1)
|
||||
if(3)
|
||||
energy -= round(((energy+1)/4),1)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/bullet_act(obj/item/projectile/P)
|
||||
qdel(P)
|
||||
return 0 //Will there be an impact? Who knows. Will we see it? No.
|
||||
|
||||
|
||||
/obj/singularity/Bump(atom/A)
|
||||
consume(A)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/Bumped(atom/A)
|
||||
consume(A)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/process()
|
||||
if(allowed_size >= STAGE_TWO)
|
||||
// Start moving even before we reach "true" stage two.
|
||||
// If we are stage one and are sufficiently energetic to be allowed to 2,
|
||||
// it might mean we are stuck in a corner somewere. So move around to try to expand.
|
||||
move()
|
||||
if(current_size >= STAGE_TWO)
|
||||
pulse()
|
||||
if(prob(event_chance))//Chance for it to run a special event TODO:Come up with one or two more that fit
|
||||
event()
|
||||
eat()
|
||||
dissipate()
|
||||
check_energy()
|
||||
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/attack_ai() //to prevent ais from gibbing themselves when they click on one.
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/admin_investigate_setup()
|
||||
last_warning = world.time
|
||||
var/count = locate(/obj/machinery/field/containment) in urange(30, src, 1)
|
||||
if(!count)
|
||||
message_admins("A singularity has been created without containment fields active at [x], [y], [z] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)")
|
||||
investigate_log("was created. [count?"":"<font color='red'>No containment fields were active</font>"]","singulo")
|
||||
|
||||
/obj/singularity/proc/dissipate()
|
||||
if(!dissipate)
|
||||
return
|
||||
if(dissipate_track >= dissipate_delay)
|
||||
src.energy -= dissipate_strength
|
||||
dissipate_track = 0
|
||||
else
|
||||
dissipate_track++
|
||||
|
||||
|
||||
/obj/singularity/proc/expand(force_size = 0)
|
||||
var/temp_allowed_size = src.allowed_size
|
||||
if(force_size)
|
||||
temp_allowed_size = force_size
|
||||
if(temp_allowed_size >= STAGE_SIX && !consumedSupermatter)
|
||||
temp_allowed_size = STAGE_FIVE
|
||||
switch(temp_allowed_size)
|
||||
if(STAGE_ONE)
|
||||
current_size = STAGE_ONE
|
||||
icon = 'icons/obj/singularity.dmi'
|
||||
icon_state = "singularity_s1"
|
||||
pixel_x = 0
|
||||
pixel_y = 0
|
||||
grav_pull = 4
|
||||
consume_range = 0
|
||||
dissipate_delay = 10
|
||||
dissipate_track = 0
|
||||
dissipate_strength = 1
|
||||
if(STAGE_TWO)
|
||||
if((check_turfs_in(1,1))&&(check_turfs_in(2,1))&&(check_turfs_in(4,1))&&(check_turfs_in(8,1)))
|
||||
current_size = STAGE_TWO
|
||||
icon = 'icons/effects/96x96.dmi'
|
||||
icon_state = "singularity_s3"
|
||||
pixel_x = -32
|
||||
pixel_y = -32
|
||||
grav_pull = 6
|
||||
consume_range = 1
|
||||
dissipate_delay = 5
|
||||
dissipate_track = 0
|
||||
dissipate_strength = 5
|
||||
if(STAGE_THREE)
|
||||
if((check_turfs_in(1,2))&&(check_turfs_in(2,2))&&(check_turfs_in(4,2))&&(check_turfs_in(8,2)))
|
||||
current_size = STAGE_THREE
|
||||
icon = 'icons/effects/160x160.dmi'
|
||||
icon_state = "singularity_s5"
|
||||
pixel_x = -64
|
||||
pixel_y = -64
|
||||
grav_pull = 8
|
||||
consume_range = 2
|
||||
dissipate_delay = 4
|
||||
dissipate_track = 0
|
||||
dissipate_strength = 20
|
||||
if(STAGE_FOUR)
|
||||
if((check_turfs_in(1,3))&&(check_turfs_in(2,3))&&(check_turfs_in(4,3))&&(check_turfs_in(8,3)))
|
||||
current_size = STAGE_FOUR
|
||||
icon = 'icons/effects/224x224.dmi'
|
||||
icon_state = "singularity_s7"
|
||||
pixel_x = -96
|
||||
pixel_y = -96
|
||||
grav_pull = 10
|
||||
consume_range = 3
|
||||
dissipate_delay = 10
|
||||
dissipate_track = 0
|
||||
dissipate_strength = 10
|
||||
if(STAGE_FIVE)//this one also lacks a check for gens because it eats everything
|
||||
current_size = STAGE_FIVE
|
||||
icon = 'icons/effects/288x288.dmi'
|
||||
icon_state = "singularity_s9"
|
||||
pixel_x = -128
|
||||
pixel_y = -128
|
||||
grav_pull = 10
|
||||
consume_range = 4
|
||||
dissipate = 0 //It cant go smaller due to e loss
|
||||
if(STAGE_SIX) //This only happens if a stage 5 singulo consumes a supermatter shard.
|
||||
current_size = STAGE_SIX
|
||||
icon = 'icons/effects/352x352.dmi'
|
||||
icon_state = "singularity_s11"
|
||||
pixel_x = -160
|
||||
pixel_y = -160
|
||||
grav_pull = 15
|
||||
consume_range = 5
|
||||
dissipate = 0
|
||||
if(current_size == allowed_size)
|
||||
investigate_log("<font color='red'>grew to size [current_size]</font>","singulo")
|
||||
return 1
|
||||
else if(current_size < (--temp_allowed_size))
|
||||
expand(temp_allowed_size)
|
||||
else
|
||||
return 0
|
||||
|
||||
|
||||
/obj/singularity/proc/check_energy()
|
||||
if(energy <= 0)
|
||||
investigate_log("collapsed.","singulo")
|
||||
qdel(src)
|
||||
return 0
|
||||
switch(energy)//Some of these numbers might need to be changed up later -Mport
|
||||
if(1 to 199)
|
||||
allowed_size = STAGE_ONE
|
||||
if(200 to 499)
|
||||
allowed_size = STAGE_TWO
|
||||
if(500 to 999)
|
||||
allowed_size = STAGE_THREE
|
||||
if(1000 to 1999)
|
||||
allowed_size = STAGE_FOUR
|
||||
if(2000 to INFINITY)
|
||||
if(energy >= 3000 && consumedSupermatter)
|
||||
allowed_size = STAGE_SIX
|
||||
else
|
||||
allowed_size = STAGE_FIVE
|
||||
if(current_size != allowed_size)
|
||||
expand()
|
||||
return 1
|
||||
|
||||
|
||||
/obj/singularity/proc/eat()
|
||||
set background = BACKGROUND_ENABLED
|
||||
for(var/tile in spiral_range_turfs(grav_pull, src))
|
||||
var/turf/T = tile
|
||||
if(!T || !isturf(loc))
|
||||
continue
|
||||
if(get_dist(T, src) > consume_range)
|
||||
T.singularity_pull(src, current_size)
|
||||
else
|
||||
consume(T)
|
||||
for(var/thing in T)
|
||||
if(isturf(loc) && thing != src)
|
||||
var/atom/movable/X = thing
|
||||
if(get_dist(X, src) > consume_range)
|
||||
X.singularity_pull(src, current_size)
|
||||
else
|
||||
consume(X)
|
||||
CHECK_TICK
|
||||
|
||||
|
||||
/obj/singularity/proc/consume(atom/A)
|
||||
var/gain = A.singularity_act(current_size)
|
||||
src.energy += gain
|
||||
if(istype(A, /obj/machinery/power/supermatter_shard) && !consumedSupermatter)
|
||||
desc = "[initial(desc)] It glows fiercely with inner fire."
|
||||
name = "supermatter-charged [initial(name)]"
|
||||
consumedSupermatter = 1
|
||||
set_light(10)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/move(force_move = 0)
|
||||
if(!move_self)
|
||||
return 0
|
||||
|
||||
var/movement_dir = pick(alldirs - last_failed_movement)
|
||||
|
||||
if(force_move)
|
||||
movement_dir = force_move
|
||||
|
||||
if(target && prob(60))
|
||||
movement_dir = get_dir(src,target) //moves to a singulo beacon, if there is one
|
||||
|
||||
step(src, movement_dir)
|
||||
|
||||
|
||||
/obj/singularity/proc/check_turfs_in(direction = 0, step = 0)
|
||||
if(!direction)
|
||||
return 0
|
||||
var/steps = 0
|
||||
if(!step)
|
||||
switch(current_size)
|
||||
if(STAGE_ONE)
|
||||
steps = 1
|
||||
if(STAGE_TWO)
|
||||
steps = 3//Yes this is right
|
||||
if(STAGE_THREE)
|
||||
steps = 3
|
||||
if(STAGE_FOUR)
|
||||
steps = 4
|
||||
if(STAGE_FIVE)
|
||||
steps = 5
|
||||
else
|
||||
steps = step
|
||||
var/list/turfs = list()
|
||||
var/turf/T = src.loc
|
||||
for(var/i = 1 to steps)
|
||||
T = get_step(T,direction)
|
||||
if(!isturf(T))
|
||||
return 0
|
||||
turfs.Add(T)
|
||||
var/dir2 = 0
|
||||
var/dir3 = 0
|
||||
switch(direction)
|
||||
if(NORTH||SOUTH)
|
||||
dir2 = 4
|
||||
dir3 = 8
|
||||
if(EAST||WEST)
|
||||
dir2 = 1
|
||||
dir3 = 2
|
||||
var/turf/T2 = T
|
||||
for(var/j = 1 to steps-1)
|
||||
T2 = get_step(T2,dir2)
|
||||
if(!isturf(T2))
|
||||
return 0
|
||||
turfs.Add(T2)
|
||||
for(var/k = 1 to steps-1)
|
||||
T = get_step(T,dir3)
|
||||
if(!isturf(T))
|
||||
return 0
|
||||
turfs.Add(T)
|
||||
for(var/turf/T3 in turfs)
|
||||
if(isnull(T3))
|
||||
continue
|
||||
if(!can_move(T3))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/obj/singularity/proc/can_move(turf/T)
|
||||
if(!T)
|
||||
return 0
|
||||
if((locate(/obj/machinery/field/containment) in T)||(locate(/obj/machinery/shieldwall) in T))
|
||||
return 0
|
||||
else if(locate(/obj/machinery/field/generator) in T)
|
||||
var/obj/machinery/field/generator/G = locate(/obj/machinery/field/generator) in T
|
||||
if(G && G.active)
|
||||
return 0
|
||||
else if(locate(/obj/machinery/shieldwallgen) in T)
|
||||
var/obj/machinery/shieldwallgen/S = locate(/obj/machinery/shieldwallgen) in T
|
||||
if(S && S.active)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/obj/singularity/proc/event()
|
||||
var/numb = pick(1,2,3,4,5,6)
|
||||
switch(numb)
|
||||
if(1)//EMP
|
||||
emp_area()
|
||||
if(2,3)//tox damage all carbon mobs in area
|
||||
toxmob()
|
||||
if(4)//Stun mobs who lack optic scanners
|
||||
mezzer()
|
||||
if(5,6) //Sets all nearby mobs on fire
|
||||
if(current_size < STAGE_SIX)
|
||||
return 0
|
||||
combust_mobs()
|
||||
else
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/obj/singularity/proc/toxmob()
|
||||
var/toxrange = 10
|
||||
var/radiation = 15
|
||||
var/radiationmin = 3
|
||||
if(energy>200)
|
||||
radiation += round((energy-150)/10,1)
|
||||
radiationmin = round((radiation/5),1)
|
||||
for(var/mob/living/M in view(toxrange, src.loc))
|
||||
M.apply_effect(rand(radiationmin,radiation), IRRADIATE)
|
||||
|
||||
|
||||
/obj/singularity/proc/combust_mobs()
|
||||
for(var/mob/living/carbon/C in urange(20, src, 1))
|
||||
C.visible_message("<span class='warning'>[C]'s skin bursts into flame!</span>", \
|
||||
"<span class='userdanger'>You feel an inner fire as your skin bursts into flames!</span>")
|
||||
C.adjust_fire_stacks(5)
|
||||
C.IgniteMob()
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/mezzer()
|
||||
for(var/mob/living/carbon/M in oviewers(8, src))
|
||||
if(istype(M, /mob/living/carbon/brain)) //Ignore brains
|
||||
continue
|
||||
|
||||
if(M.stat == CONSCIOUS)
|
||||
if(ishuman(M))
|
||||
var/mob/living/carbon/human/H = M
|
||||
if(istype(H.glasses, /obj/item/clothing/glasses/meson))
|
||||
var/obj/item/clothing/glasses/meson/MS = H.glasses
|
||||
if(MS.vision_flags == SEE_TURFS)
|
||||
to_chat(H, "<span class='notice'>You look directly into the [src.name], good thing you had your protective eyewear on!</span>")
|
||||
return
|
||||
|
||||
M.apply_effect(3, STUN)
|
||||
M.visible_message("<span class='danger'>[M] stares blankly at the [src.name]!</span>", \
|
||||
"<span class='userdanger'>You look directly into the [src.name] and feel weak.</span>")
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/emp_area()
|
||||
empulse(src, 8, 10)
|
||||
return
|
||||
|
||||
|
||||
/obj/singularity/proc/pulse()
|
||||
for(var/obj/machinery/power/rad_collector/R in rad_collectors)
|
||||
if(R.z == z && get_dist(R, src) <= 15) // Better than using orange() every process
|
||||
R.receive_pulse(energy)
|
||||
|
||||
/obj/singularity/singularity_act()
|
||||
var/gain = (energy/2)
|
||||
var/dist = max((current_size - 2),1)
|
||||
explosion(src.loc,(dist),(dist*2),(dist*4))
|
||||
qdel(src)
|
||||
return(gain)
|
||||
|
||||
+493
-493
@@ -1,493 +1,493 @@
|
||||
// the SMES
|
||||
// stores power
|
||||
|
||||
#define SMESMAXCHARGELEVEL 200000
|
||||
#define SMESMAXOUTPUT 200000
|
||||
#define SMESRATE 0.05 // rate of internal charge to external power
|
||||
|
||||
|
||||
|
||||
/obj/machinery/power/smes
|
||||
name = "power storage unit"
|
||||
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit."
|
||||
icon_state = "smes"
|
||||
density = TRUE
|
||||
use_power = NO_POWER_USE
|
||||
|
||||
var/capacity = 5e6 // maximum charge
|
||||
var/charge = 0 // actual charge
|
||||
|
||||
var/input_attempt = TRUE // 1 = attempting to charge, 0 = not attempting to charge
|
||||
var/inputting = TRUE // 1 = actually inputting, 0 = not inputting
|
||||
var/input_level = 50000 // amount of power the SMES attempts to charge by
|
||||
var/input_level_max = 200000 // cap on input_level
|
||||
var/input_available = 0 // amount of charge available from input last tick
|
||||
|
||||
var/output_attempt = TRUE // 1 = attempting to output, 0 = not attempting to output
|
||||
var/outputting = TRUE // 1 = actually outputting, 0 = not outputting
|
||||
var/output_level = 50000 // amount of power the SMES attempts to output
|
||||
var/output_level_max = 200000 // cap on output_level
|
||||
var/output_used = 0 // amount of power actually outputted. may be less than output_level if the powernet returns excess power
|
||||
|
||||
//Holders for powerout event.
|
||||
var/last_output_attempt = 0
|
||||
var/last_input_attempt = 0
|
||||
var/last_charge = 0
|
||||
|
||||
var/name_tag = null
|
||||
var/obj/machinery/power/terminal/terminal = null
|
||||
|
||||
/obj/machinery/power/smes/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/smes(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 5)
|
||||
RefreshParts()
|
||||
|
||||
dir_loop:
|
||||
for(var/d in cardinal)
|
||||
var/turf/T = get_step(src, d)
|
||||
for(var/obj/machinery/power/terminal/term in T)
|
||||
if(term && term.dir == turn(d, 180))
|
||||
terminal = term
|
||||
break dir_loop
|
||||
|
||||
if(!terminal)
|
||||
stat |= BROKEN
|
||||
return
|
||||
terminal.master = src
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/power/smes/upgraded/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/smes(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/capacitor/super(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 5)
|
||||
RefreshParts()
|
||||
|
||||
/obj/machinery/power/smes/RefreshParts()
|
||||
var/IO = 0
|
||||
var/C = 0
|
||||
for(var/obj/item/stock_parts/capacitor/CP in component_parts)
|
||||
IO += CP.rating
|
||||
input_level_max = 200000 * IO
|
||||
output_level_max = 200000 * IO
|
||||
for(var/obj/item/stock_parts/cell/PC in component_parts)
|
||||
C += PC.maxcharge
|
||||
capacity = C / (15000) * 1e6
|
||||
|
||||
/obj/machinery/power/smes/update_icon()
|
||||
overlays.Cut()
|
||||
if(stat & BROKEN) return
|
||||
|
||||
overlays += image('icons/obj/power.dmi', "smes-op[outputting]")
|
||||
|
||||
if(inputting == 2)
|
||||
overlays += image('icons/obj/power.dmi', "smes-oc2")
|
||||
else if(inputting == 1)
|
||||
overlays += image('icons/obj/power.dmi', "smes-oc1")
|
||||
else
|
||||
if(input_attempt)
|
||||
overlays += image('icons/obj/power.dmi', "smes-oc0")
|
||||
|
||||
var/clevel = chargedisplay()
|
||||
if(clevel>0)
|
||||
overlays += image('icons/obj/power.dmi', "smes-og[clevel]")
|
||||
return
|
||||
|
||||
/obj/machinery/power/smes/attackby(obj/item/I, mob/user, params)
|
||||
//opening using screwdriver
|
||||
if(default_deconstruction_screwdriver(user, "[initial(icon_state)]-o", initial(icon_state), I))
|
||||
update_icon()
|
||||
return
|
||||
|
||||
//changing direction using wrench
|
||||
if(default_change_direction_wrench(user, I))
|
||||
terminal = null
|
||||
var/turf/T = get_step(src, dir)
|
||||
for(var/obj/machinery/power/terminal/term in T)
|
||||
if(term && term.dir == turn(dir, 180))
|
||||
terminal = term
|
||||
terminal.master = src
|
||||
to_chat(user, "<span class='notice'>Terminal found.</span>")
|
||||
break
|
||||
if(!terminal)
|
||||
to_chat(user, "<span class='alert'>No power source found.</span>")
|
||||
return
|
||||
stat &= ~BROKEN
|
||||
update_icon()
|
||||
return
|
||||
|
||||
//exchanging parts using the RPE
|
||||
if(exchange_parts(user, I))
|
||||
return
|
||||
|
||||
//building and linking a terminal
|
||||
if(istype(I, /obj/item/stack/cable_coil))
|
||||
var/dir = get_dir(user,src)
|
||||
if(dir & (dir-1))//we don't want diagonal click
|
||||
return
|
||||
|
||||
if(terminal) //is there already a terminal ?
|
||||
to_chat(user, "<span class='alert'>This SMES already has a power terminal!</span>")
|
||||
return
|
||||
|
||||
if(!panel_open) //is the panel open ?
|
||||
to_chat(user, "<span class='alert'>You must open the maintenance panel first!</span>")
|
||||
return
|
||||
|
||||
var/turf/T = get_turf(user)
|
||||
if(T.intact) //is the floor plating removed ?
|
||||
to_chat(user, "<span class='alert'>You must first remove the floor plating!</span>")
|
||||
return
|
||||
|
||||
var/obj/item/stack/cable_coil/C = I
|
||||
if(C.amount < 10)
|
||||
to_chat(user, "<span class='alert'>You need more wires.</span>")
|
||||
return
|
||||
|
||||
if(user.loc == loc)
|
||||
to_chat(user, "<span class='warning'>You must not be on the same tile as the [src].</span>")
|
||||
return
|
||||
|
||||
//Direction the terminal will face to
|
||||
var/tempDir = get_dir(user, src)
|
||||
switch(tempDir)
|
||||
if(NORTHEAST, SOUTHEAST)
|
||||
tempDir = EAST
|
||||
if(NORTHWEST, SOUTHWEST)
|
||||
tempDir = WEST
|
||||
var/turf/tempLoc = get_step(src, reverse_direction(tempDir))
|
||||
if(istype(tempLoc, /turf/space))
|
||||
to_chat(user, "<span class='warning'>You can't build a terminal on space.</span>")
|
||||
return
|
||||
else if(istype(tempLoc))
|
||||
if(tempLoc.intact)
|
||||
to_chat(user, "<span class='warning'>You must remove the floor plating first.</span>")
|
||||
return
|
||||
|
||||
to_chat(user, "<span class='notice'>You start adding cable to the [src].</span>")
|
||||
playsound(loc, C.usesound, 50, 1)
|
||||
|
||||
if(do_after(user, 50, target = src))
|
||||
if(!terminal && panel_open)
|
||||
T = get_turf(user)
|
||||
var/obj/structure/cable/N = T.get_cable_node() //get the connecting node cable, if there's one
|
||||
if(prob(50) && electrocute_mob(usr, N, N, 1, TRUE)) //animate the electrocution if uncautious and unlucky
|
||||
do_sparks(5, 1, src)
|
||||
return
|
||||
|
||||
C.use(10) // make sure the cable gets used up
|
||||
user.visible_message(\
|
||||
"<span class='notice'>[user.name] adds the cables and connects the power terminal.</span>",\
|
||||
"<span class='notice'>You add the cables and connect the power terminal.</span>")
|
||||
|
||||
make_terminal(user, tempDir, tempLoc)
|
||||
terminal.connect_to_network()
|
||||
return
|
||||
|
||||
//disassembling the terminal
|
||||
if(istype(I, /obj/item/wirecutters) && terminal && panel_open)
|
||||
var/turf/T = get_turf(terminal)
|
||||
if(T.intact) //is the floor plating removed ?
|
||||
to_chat(user, "<span class='alert'>You must first expose the power terminal!</span>")
|
||||
return
|
||||
|
||||
to_chat(user, "<span class='notice'>You begin to dismantle the power terminal...</span>")
|
||||
playsound(src.loc, I.usesound, 50, 1)
|
||||
|
||||
if(do_after(user, 50 * I.toolspeed, target = src))
|
||||
if(terminal && panel_open)
|
||||
if(prob(50) && electrocute_mob(usr, terminal.powernet, terminal, 1, TRUE)) //animate the electrocution if uncautious and unlucky
|
||||
do_sparks(5, 1, src)
|
||||
return
|
||||
|
||||
//give the wires back and delete the terminal
|
||||
new /obj/item/stack/cable_coil(T,10)
|
||||
user.visible_message(\
|
||||
"<span class='alert'>[user.name] cuts the cables and dismantles the power terminal.</span>",\
|
||||
"<span class='notice'>You cut the cables and dismantle the power terminal.</span>")
|
||||
inputting = 0 //stop inputting, since we have don't have a terminal anymore
|
||||
qdel(terminal)
|
||||
return
|
||||
|
||||
//crowbarring it !
|
||||
if(default_deconstruction_crowbar(user, I))
|
||||
return
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/smes/disconnect_terminal()
|
||||
if(terminal)
|
||||
terminal.master = null
|
||||
terminal = null
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/smes/proc/make_terminal(user, tempDir, tempLoc)
|
||||
// create a terminal object at the same position as original turf loc
|
||||
// wires will attach to this
|
||||
terminal = new /obj/machinery/power/terminal(tempLoc)
|
||||
terminal.dir = tempDir
|
||||
terminal.master = src
|
||||
|
||||
/obj/machinery/power/smes/Destroy()
|
||||
if(SSticker && SSticker.current_state == GAME_STATE_PLAYING)
|
||||
var/area/area = get_area(src)
|
||||
if(area)
|
||||
message_admins("SMES deleted at (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>[area.name]</a>)")
|
||||
log_game("SMES deleted at ([area.name])")
|
||||
investigate_log("<font color='red'>deleted</font> at ([area.name])","singulo")
|
||||
if(terminal)
|
||||
disconnect_terminal()
|
||||
return ..()
|
||||
|
||||
return round(5.5*charge/(capacity ? capacity : 5e6))
|
||||
|
||||
/obj/machinery/power/smes/proc/chargedisplay()
|
||||
return round(5.5*charge/(capacity ? capacity : 5e6))
|
||||
|
||||
/obj/machinery/power/smes/process()
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
//store machine state to see if we need to update the icon overlays
|
||||
var/last_disp = chargedisplay()
|
||||
var/last_chrg = inputting
|
||||
var/last_onln = outputting
|
||||
|
||||
//inputting
|
||||
if(terminal && input_attempt)
|
||||
input_available = terminal.surplus()
|
||||
|
||||
if(inputting)
|
||||
if(input_available > 0) // if there's power available, try to charge
|
||||
|
||||
var/load = min(min((capacity-charge)/SMESRATE, input_level), input_available) // charge at set rate, limited to spare capacity
|
||||
|
||||
charge += load * SMESRATE // increase the charge
|
||||
|
||||
terminal.add_load(load) // add the load to the terminal side network
|
||||
|
||||
else // if not enough capcity
|
||||
inputting = FALSE // stop inputting
|
||||
|
||||
else
|
||||
if(input_attempt && input_available > 0)
|
||||
inputting = TRUE
|
||||
else
|
||||
inputting = FALSE
|
||||
|
||||
//outputting
|
||||
if(output_attempt)
|
||||
if(outputting)
|
||||
output_used = min( charge/SMESRATE, output_level) //limit output to that stored
|
||||
|
||||
if (add_avail(output_used)) // add output to powernet if it exists (smes side)
|
||||
charge -= output_used*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
|
||||
else
|
||||
outputting = FALSE
|
||||
|
||||
if(output_used < 0.0001) // either from no charge or set to 0
|
||||
outputting = FALSE
|
||||
investigate_log("lost power and turned <font color='red'>off</font>", "singulo")
|
||||
else if(output_attempt && charge > output_level && output_level > 0)
|
||||
outputting = TRUE
|
||||
else
|
||||
output_used = 0
|
||||
else
|
||||
outputting = FALSE
|
||||
|
||||
// only update icon if state changed
|
||||
if(last_disp != chargedisplay() || last_chrg != inputting || last_onln != outputting)
|
||||
update_icon()
|
||||
|
||||
|
||||
|
||||
// called after all power processes are finished
|
||||
// restores charge level to smes if there was excess this ptick
|
||||
/obj/machinery/power/smes/proc/restore()
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
if(!outputting)
|
||||
output_used = 0
|
||||
return
|
||||
|
||||
var/excess = powernet.netexcess // this was how much wasn't used on the network last ptick, minus any removed by other SMESes
|
||||
|
||||
excess = min(output_used, excess) // clamp it to how much was actually output by this SMES last ptick
|
||||
|
||||
excess = min((capacity-charge)/SMESRATE, excess) // for safety, also limit recharge by space capacity of SMES (shouldn't happen)
|
||||
|
||||
// now recharge this amount
|
||||
|
||||
var/clev = chargedisplay()
|
||||
|
||||
charge += excess * SMESRATE // restore unused power
|
||||
powernet.netexcess -= excess // remove the excess from the powernet, so later SMESes don't try to use it
|
||||
|
||||
output_used -= excess
|
||||
|
||||
if(clev != chargedisplay() ) //if needed updates the icons overlay
|
||||
update_icon()
|
||||
return
|
||||
|
||||
/obj/machinery/power/smes/attack_ai(mob/user)
|
||||
add_hiddenprint(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)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "smes.tmpl", "SMES Power Storage Unit", 540, 380)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/power/smes/ui_data(mob/user, ui_key = "main", datum/topic_state/state = default_state)
|
||||
var/data[0]
|
||||
|
||||
data["nameTag"] = name_tag
|
||||
data["storedCapacity"] = round(100.0*charge/capacity, 0.1)
|
||||
data["charging"] = inputting
|
||||
data["chargeMode"] = input_attempt
|
||||
data["chargeLevel"] = input_level
|
||||
data["chargeMax"] = input_level_max
|
||||
data["outputOnline"] = output_attempt
|
||||
data["outputLevel"] = output_level
|
||||
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
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/power/smes/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if( href_list["cmode"] )
|
||||
inputting(!input_attempt)
|
||||
update_icon()
|
||||
|
||||
else if( href_list["online"] )
|
||||
outputting(!output_attempt)
|
||||
update_icon()
|
||||
|
||||
else if( href_list["input"] )
|
||||
switch( href_list["input"] )
|
||||
if("min")
|
||||
input_level = 0
|
||||
if("max")
|
||||
input_level = input_level_max
|
||||
if("set")
|
||||
input_level = input(usr, "Enter new input level (0-[input_level_max])", "SMES Input Power Control", input_level) as num
|
||||
input_level = max(0, min(input_level_max, input_level)) // clamp to range
|
||||
|
||||
else if( href_list["output"] )
|
||||
switch( href_list["output"] )
|
||||
if("min")
|
||||
output_level = 0
|
||||
if("max")
|
||||
output_level = output_level_max
|
||||
if("set")
|
||||
output_level = input(usr, "Enter new output level (0-[output_level_max])", "SMES Output Power Control", output_level) as num
|
||||
output_level = max(0, min(output_level_max, output_level)) // clamp to range
|
||||
|
||||
investigate_log("input/output; [input_level>output_level?"<font color='green'>":"<font color='red'>"][input_level]/[output_level]</font> | Output-mode: [output_attempt?"<font color='green'>on</font>":"<font color='red'>off</font>"] | Input-mode: [input_attempt?"<font color='green'>auto</font>":"<font color='red'>off</font>"] by [usr.key]","singulo")
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/smes/proc/ion_act()
|
||||
if(is_station_level(src.z))
|
||||
if(prob(1)) //explosion
|
||||
for(var/mob/M in viewers(src))
|
||||
M.show_message("<span class='warning'>The [src.name] is making strange noises!</span>", 3, "<span class='warning'>You hear sizzling electronics.</span>", 2)
|
||||
sleep(10*pick(4,5,6,7,10,14))
|
||||
var/datum/effect_system/smoke_spread/smoke = new
|
||||
smoke.set_up(3, 0, src.loc)
|
||||
smoke.attach(src)
|
||||
smoke.start()
|
||||
explosion(src.loc, -1, 0, 1, 3, 1, 0)
|
||||
qdel(src)
|
||||
return
|
||||
if(prob(15)) //Power drain
|
||||
do_sparks(3, 1, src)
|
||||
if(prob(50))
|
||||
emp_act(1)
|
||||
else
|
||||
emp_act(2)
|
||||
if(prob(5)) //smoke only
|
||||
var/datum/effect_system/smoke_spread/smoke = new
|
||||
smoke.set_up(3, 0, src.loc)
|
||||
smoke.attach(src)
|
||||
smoke.start()
|
||||
|
||||
/obj/machinery/power/smes/proc/inputting(var/do_input)
|
||||
input_attempt = do_input
|
||||
if(!input_attempt)
|
||||
inputting = 0
|
||||
|
||||
/obj/machinery/power/smes/proc/outputting(var/do_output)
|
||||
output_attempt = do_output
|
||||
if(!output_attempt)
|
||||
outputting = 0
|
||||
|
||||
/obj/machinery/power/smes/emp_act(severity)
|
||||
inputting(rand(0,1))
|
||||
outputting(rand(0,1))
|
||||
output_level = rand(0, output_level_max)
|
||||
input_level = rand(0, input_level_max)
|
||||
charge -= 1e6/severity
|
||||
if(charge < 0)
|
||||
charge = 0
|
||||
update_icon()
|
||||
..()
|
||||
|
||||
/obj/machinery/power/smes/engineering
|
||||
charge = 2e6 // Engineering starts with some charge for singulo
|
||||
|
||||
/obj/machinery/power/smes/magical
|
||||
name = "magical power storage unit"
|
||||
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit. Magically produces power."
|
||||
capacity = 9000000
|
||||
output_level = 250000
|
||||
|
||||
/obj/machinery/power/smes/magical/process()
|
||||
capacity = INFINITY
|
||||
charge = INFINITY
|
||||
..()
|
||||
|
||||
#undef SMESRATE
|
||||
// the SMES
|
||||
// stores power
|
||||
|
||||
#define SMESMAXCHARGELEVEL 200000
|
||||
#define SMESMAXOUTPUT 200000
|
||||
#define SMESRATE 0.05 // rate of internal charge to external power
|
||||
|
||||
|
||||
|
||||
/obj/machinery/power/smes
|
||||
name = "power storage unit"
|
||||
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit."
|
||||
icon_state = "smes"
|
||||
density = TRUE
|
||||
use_power = NO_POWER_USE
|
||||
|
||||
var/capacity = 5e6 // maximum charge
|
||||
var/charge = 0 // actual charge
|
||||
|
||||
var/input_attempt = TRUE // 1 = attempting to charge, 0 = not attempting to charge
|
||||
var/inputting = TRUE // 1 = actually inputting, 0 = not inputting
|
||||
var/input_level = 50000 // amount of power the SMES attempts to charge by
|
||||
var/input_level_max = 200000 // cap on input_level
|
||||
var/input_available = 0 // amount of charge available from input last tick
|
||||
|
||||
var/output_attempt = TRUE // 1 = attempting to output, 0 = not attempting to output
|
||||
var/outputting = TRUE // 1 = actually outputting, 0 = not outputting
|
||||
var/output_level = 50000 // amount of power the SMES attempts to output
|
||||
var/output_level_max = 200000 // cap on output_level
|
||||
var/output_used = 0 // amount of power actually outputted. may be less than output_level if the powernet returns excess power
|
||||
|
||||
//Holders for powerout event.
|
||||
var/last_output_attempt = 0
|
||||
var/last_input_attempt = 0
|
||||
var/last_charge = 0
|
||||
|
||||
var/name_tag = null
|
||||
var/obj/machinery/power/terminal/terminal = null
|
||||
|
||||
/obj/machinery/power/smes/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/smes(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/high(null)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 5)
|
||||
RefreshParts()
|
||||
|
||||
dir_loop:
|
||||
for(var/d in cardinal)
|
||||
var/turf/T = get_step(src, d)
|
||||
for(var/obj/machinery/power/terminal/term in T)
|
||||
if(term && term.dir == turn(d, 180))
|
||||
terminal = term
|
||||
break dir_loop
|
||||
|
||||
if(!terminal)
|
||||
stat |= BROKEN
|
||||
return
|
||||
terminal.master = src
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/power/smes/upgraded/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/smes(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/cell/hyper(null)
|
||||
component_parts += new /obj/item/stock_parts/capacitor/super(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 5)
|
||||
RefreshParts()
|
||||
|
||||
/obj/machinery/power/smes/RefreshParts()
|
||||
var/IO = 0
|
||||
var/C = 0
|
||||
for(var/obj/item/stock_parts/capacitor/CP in component_parts)
|
||||
IO += CP.rating
|
||||
input_level_max = 200000 * IO
|
||||
output_level_max = 200000 * IO
|
||||
for(var/obj/item/stock_parts/cell/PC in component_parts)
|
||||
C += PC.maxcharge
|
||||
capacity = C / (15000) * 1e6
|
||||
|
||||
/obj/machinery/power/smes/update_icon()
|
||||
overlays.Cut()
|
||||
if(stat & BROKEN) return
|
||||
|
||||
overlays += image('icons/obj/power.dmi', "smes-op[outputting]")
|
||||
|
||||
if(inputting == 2)
|
||||
overlays += image('icons/obj/power.dmi', "smes-oc2")
|
||||
else if(inputting == 1)
|
||||
overlays += image('icons/obj/power.dmi', "smes-oc1")
|
||||
else
|
||||
if(input_attempt)
|
||||
overlays += image('icons/obj/power.dmi', "smes-oc0")
|
||||
|
||||
var/clevel = chargedisplay()
|
||||
if(clevel>0)
|
||||
overlays += image('icons/obj/power.dmi', "smes-og[clevel]")
|
||||
return
|
||||
|
||||
/obj/machinery/power/smes/attackby(obj/item/I, mob/user, params)
|
||||
//opening using screwdriver
|
||||
if(default_deconstruction_screwdriver(user, "[initial(icon_state)]-o", initial(icon_state), I))
|
||||
update_icon()
|
||||
return
|
||||
|
||||
//changing direction using wrench
|
||||
if(default_change_direction_wrench(user, I))
|
||||
terminal = null
|
||||
var/turf/T = get_step(src, dir)
|
||||
for(var/obj/machinery/power/terminal/term in T)
|
||||
if(term && term.dir == turn(dir, 180))
|
||||
terminal = term
|
||||
terminal.master = src
|
||||
to_chat(user, "<span class='notice'>Terminal found.</span>")
|
||||
break
|
||||
if(!terminal)
|
||||
to_chat(user, "<span class='alert'>No power source found.</span>")
|
||||
return
|
||||
stat &= ~BROKEN
|
||||
update_icon()
|
||||
return
|
||||
|
||||
//exchanging parts using the RPE
|
||||
if(exchange_parts(user, I))
|
||||
return
|
||||
|
||||
//building and linking a terminal
|
||||
if(istype(I, /obj/item/stack/cable_coil))
|
||||
var/dir = get_dir(user,src)
|
||||
if(dir & (dir-1))//we don't want diagonal click
|
||||
return
|
||||
|
||||
if(terminal) //is there already a terminal ?
|
||||
to_chat(user, "<span class='alert'>This SMES already has a power terminal!</span>")
|
||||
return
|
||||
|
||||
if(!panel_open) //is the panel open ?
|
||||
to_chat(user, "<span class='alert'>You must open the maintenance panel first!</span>")
|
||||
return
|
||||
|
||||
var/turf/T = get_turf(user)
|
||||
if(T.intact) //is the floor plating removed ?
|
||||
to_chat(user, "<span class='alert'>You must first remove the floor plating!</span>")
|
||||
return
|
||||
|
||||
var/obj/item/stack/cable_coil/C = I
|
||||
if(C.amount < 10)
|
||||
to_chat(user, "<span class='alert'>You need more wires.</span>")
|
||||
return
|
||||
|
||||
if(user.loc == loc)
|
||||
to_chat(user, "<span class='warning'>You must not be on the same tile as the [src].</span>")
|
||||
return
|
||||
|
||||
//Direction the terminal will face to
|
||||
var/tempDir = get_dir(user, src)
|
||||
switch(tempDir)
|
||||
if(NORTHEAST, SOUTHEAST)
|
||||
tempDir = EAST
|
||||
if(NORTHWEST, SOUTHWEST)
|
||||
tempDir = WEST
|
||||
var/turf/tempLoc = get_step(src, reverse_direction(tempDir))
|
||||
if(istype(tempLoc, /turf/space))
|
||||
to_chat(user, "<span class='warning'>You can't build a terminal on space.</span>")
|
||||
return
|
||||
else if(istype(tempLoc))
|
||||
if(tempLoc.intact)
|
||||
to_chat(user, "<span class='warning'>You must remove the floor plating first.</span>")
|
||||
return
|
||||
|
||||
to_chat(user, "<span class='notice'>You start adding cable to the [src].</span>")
|
||||
playsound(loc, C.usesound, 50, 1)
|
||||
|
||||
if(do_after(user, 50, target = src))
|
||||
if(!terminal && panel_open)
|
||||
T = get_turf(user)
|
||||
var/obj/structure/cable/N = T.get_cable_node() //get the connecting node cable, if there's one
|
||||
if(prob(50) && electrocute_mob(usr, N, N, 1, TRUE)) //animate the electrocution if uncautious and unlucky
|
||||
do_sparks(5, 1, src)
|
||||
return
|
||||
|
||||
C.use(10) // make sure the cable gets used up
|
||||
user.visible_message(\
|
||||
"<span class='notice'>[user.name] adds the cables and connects the power terminal.</span>",\
|
||||
"<span class='notice'>You add the cables and connect the power terminal.</span>")
|
||||
|
||||
make_terminal(user, tempDir, tempLoc)
|
||||
terminal.connect_to_network()
|
||||
return
|
||||
|
||||
//disassembling the terminal
|
||||
if(istype(I, /obj/item/wirecutters) && terminal && panel_open)
|
||||
var/turf/T = get_turf(terminal)
|
||||
if(T.intact) //is the floor plating removed ?
|
||||
to_chat(user, "<span class='alert'>You must first expose the power terminal!</span>")
|
||||
return
|
||||
|
||||
to_chat(user, "<span class='notice'>You begin to dismantle the power terminal...</span>")
|
||||
playsound(src.loc, I.usesound, 50, 1)
|
||||
|
||||
if(do_after(user, 50 * I.toolspeed, target = src))
|
||||
if(terminal && panel_open)
|
||||
if(prob(50) && electrocute_mob(usr, terminal.powernet, terminal, 1, TRUE)) //animate the electrocution if uncautious and unlucky
|
||||
do_sparks(5, 1, src)
|
||||
return
|
||||
|
||||
//give the wires back and delete the terminal
|
||||
new /obj/item/stack/cable_coil(T,10)
|
||||
user.visible_message(\
|
||||
"<span class='alert'>[user.name] cuts the cables and dismantles the power terminal.</span>",\
|
||||
"<span class='notice'>You cut the cables and dismantle the power terminal.</span>")
|
||||
inputting = 0 //stop inputting, since we have don't have a terminal anymore
|
||||
qdel(terminal)
|
||||
return
|
||||
|
||||
//crowbarring it !
|
||||
if(default_deconstruction_crowbar(user, I))
|
||||
return
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/smes/disconnect_terminal()
|
||||
if(terminal)
|
||||
terminal.master = null
|
||||
terminal = null
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/smes/proc/make_terminal(user, tempDir, tempLoc)
|
||||
// create a terminal object at the same position as original turf loc
|
||||
// wires will attach to this
|
||||
terminal = new /obj/machinery/power/terminal(tempLoc)
|
||||
terminal.dir = tempDir
|
||||
terminal.master = src
|
||||
|
||||
/obj/machinery/power/smes/Destroy()
|
||||
if(SSticker && SSticker.current_state == GAME_STATE_PLAYING)
|
||||
var/area/area = get_area(src)
|
||||
if(area)
|
||||
message_admins("SMES deleted at (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>[area.name]</a>)")
|
||||
log_game("SMES deleted at ([area.name])")
|
||||
investigate_log("<font color='red'>deleted</font> at ([area.name])","singulo")
|
||||
if(terminal)
|
||||
disconnect_terminal()
|
||||
return ..()
|
||||
|
||||
return round(5.5*charge/(capacity ? capacity : 5e6))
|
||||
|
||||
/obj/machinery/power/smes/proc/chargedisplay()
|
||||
return round(5.5*charge/(capacity ? capacity : 5e6))
|
||||
|
||||
/obj/machinery/power/smes/process()
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
//store machine state to see if we need to update the icon overlays
|
||||
var/last_disp = chargedisplay()
|
||||
var/last_chrg = inputting
|
||||
var/last_onln = outputting
|
||||
|
||||
//inputting
|
||||
if(terminal && input_attempt)
|
||||
input_available = terminal.surplus()
|
||||
|
||||
if(inputting)
|
||||
if(input_available > 0) // if there's power available, try to charge
|
||||
|
||||
var/load = min(min((capacity-charge)/SMESRATE, input_level), input_available) // charge at set rate, limited to spare capacity
|
||||
|
||||
charge += load * SMESRATE // increase the charge
|
||||
|
||||
terminal.add_load(load) // add the load to the terminal side network
|
||||
|
||||
else // if not enough capcity
|
||||
inputting = FALSE // stop inputting
|
||||
|
||||
else
|
||||
if(input_attempt && input_available > 0)
|
||||
inputting = TRUE
|
||||
else
|
||||
inputting = FALSE
|
||||
|
||||
//outputting
|
||||
if(output_attempt)
|
||||
if(outputting)
|
||||
output_used = min( charge/SMESRATE, output_level) //limit output to that stored
|
||||
|
||||
if (add_avail(output_used)) // add output to powernet if it exists (smes side)
|
||||
charge -= output_used*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
|
||||
else
|
||||
outputting = FALSE
|
||||
|
||||
if(output_used < 0.0001) // either from no charge or set to 0
|
||||
outputting = FALSE
|
||||
investigate_log("lost power and turned <font color='red'>off</font>", "singulo")
|
||||
else if(output_attempt && charge > output_level && output_level > 0)
|
||||
outputting = TRUE
|
||||
else
|
||||
output_used = 0
|
||||
else
|
||||
outputting = FALSE
|
||||
|
||||
// only update icon if state changed
|
||||
if(last_disp != chargedisplay() || last_chrg != inputting || last_onln != outputting)
|
||||
update_icon()
|
||||
|
||||
|
||||
|
||||
// called after all power processes are finished
|
||||
// restores charge level to smes if there was excess this ptick
|
||||
/obj/machinery/power/smes/proc/restore()
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
if(!outputting)
|
||||
output_used = 0
|
||||
return
|
||||
|
||||
var/excess = powernet.netexcess // this was how much wasn't used on the network last ptick, minus any removed by other SMESes
|
||||
|
||||
excess = min(output_used, excess) // clamp it to how much was actually output by this SMES last ptick
|
||||
|
||||
excess = min((capacity-charge)/SMESRATE, excess) // for safety, also limit recharge by space capacity of SMES (shouldn't happen)
|
||||
|
||||
// now recharge this amount
|
||||
|
||||
var/clev = chargedisplay()
|
||||
|
||||
charge += excess * SMESRATE // restore unused power
|
||||
powernet.netexcess -= excess // remove the excess from the powernet, so later SMESes don't try to use it
|
||||
|
||||
output_used -= excess
|
||||
|
||||
if(clev != chargedisplay() ) //if needed updates the icons overlay
|
||||
update_icon()
|
||||
return
|
||||
|
||||
/obj/machinery/power/smes/attack_ai(mob/user)
|
||||
add_hiddenprint(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)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "smes.tmpl", "SMES Power Storage Unit", 540, 380)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/power/smes/ui_data(mob/user, ui_key = "main", datum/topic_state/state = default_state)
|
||||
var/data[0]
|
||||
|
||||
data["nameTag"] = name_tag
|
||||
data["storedCapacity"] = round(100.0*charge/capacity, 0.1)
|
||||
data["charging"] = inputting
|
||||
data["chargeMode"] = input_attempt
|
||||
data["chargeLevel"] = input_level
|
||||
data["chargeMax"] = input_level_max
|
||||
data["outputOnline"] = output_attempt
|
||||
data["outputLevel"] = output_level
|
||||
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
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/power/smes/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if( href_list["cmode"] )
|
||||
inputting(!input_attempt)
|
||||
update_icon()
|
||||
|
||||
else if( href_list["online"] )
|
||||
outputting(!output_attempt)
|
||||
update_icon()
|
||||
|
||||
else if( href_list["input"] )
|
||||
switch( href_list["input"] )
|
||||
if("min")
|
||||
input_level = 0
|
||||
if("max")
|
||||
input_level = input_level_max
|
||||
if("set")
|
||||
input_level = input(usr, "Enter new input level (0-[input_level_max])", "SMES Input Power Control", input_level) as num
|
||||
input_level = max(0, min(input_level_max, input_level)) // clamp to range
|
||||
|
||||
else if( href_list["output"] )
|
||||
switch( href_list["output"] )
|
||||
if("min")
|
||||
output_level = 0
|
||||
if("max")
|
||||
output_level = output_level_max
|
||||
if("set")
|
||||
output_level = input(usr, "Enter new output level (0-[output_level_max])", "SMES Output Power Control", output_level) as num
|
||||
output_level = max(0, min(output_level_max, output_level)) // clamp to range
|
||||
|
||||
investigate_log("input/output; [input_level>output_level?"<font color='green'>":"<font color='red'>"][input_level]/[output_level]</font> | Output-mode: [output_attempt?"<font color='green'>on</font>":"<font color='red'>off</font>"] | Input-mode: [input_attempt?"<font color='green'>auto</font>":"<font color='red'>off</font>"] by [usr.key]","singulo")
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/smes/proc/ion_act()
|
||||
if(is_station_level(src.z))
|
||||
if(prob(1)) //explosion
|
||||
for(var/mob/M in viewers(src))
|
||||
M.show_message("<span class='warning'>The [src.name] is making strange noises!</span>", 3, "<span class='warning'>You hear sizzling electronics.</span>", 2)
|
||||
sleep(10*pick(4,5,6,7,10,14))
|
||||
var/datum/effect_system/smoke_spread/smoke = new
|
||||
smoke.set_up(3, 0, src.loc)
|
||||
smoke.attach(src)
|
||||
smoke.start()
|
||||
explosion(src.loc, -1, 0, 1, 3, 1, 0)
|
||||
qdel(src)
|
||||
return
|
||||
if(prob(15)) //Power drain
|
||||
do_sparks(3, 1, src)
|
||||
if(prob(50))
|
||||
emp_act(1)
|
||||
else
|
||||
emp_act(2)
|
||||
if(prob(5)) //smoke only
|
||||
var/datum/effect_system/smoke_spread/smoke = new
|
||||
smoke.set_up(3, 0, src.loc)
|
||||
smoke.attach(src)
|
||||
smoke.start()
|
||||
|
||||
/obj/machinery/power/smes/proc/inputting(var/do_input)
|
||||
input_attempt = do_input
|
||||
if(!input_attempt)
|
||||
inputting = 0
|
||||
|
||||
/obj/machinery/power/smes/proc/outputting(var/do_output)
|
||||
output_attempt = do_output
|
||||
if(!output_attempt)
|
||||
outputting = 0
|
||||
|
||||
/obj/machinery/power/smes/emp_act(severity)
|
||||
inputting(rand(0,1))
|
||||
outputting(rand(0,1))
|
||||
output_level = rand(0, output_level_max)
|
||||
input_level = rand(0, input_level_max)
|
||||
charge -= 1e6/severity
|
||||
if(charge < 0)
|
||||
charge = 0
|
||||
update_icon()
|
||||
..()
|
||||
|
||||
/obj/machinery/power/smes/engineering
|
||||
charge = 2e6 // Engineering starts with some charge for singulo
|
||||
|
||||
/obj/machinery/power/smes/magical
|
||||
name = "magical power storage unit"
|
||||
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit. Magically produces power."
|
||||
capacity = 9000000
|
||||
output_level = 250000
|
||||
|
||||
/obj/machinery/power/smes/magical/process()
|
||||
capacity = INFINITY
|
||||
charge = INFINITY
|
||||
..()
|
||||
|
||||
#undef SMESRATE
|
||||
|
||||
+521
-521
File diff suppressed because it is too large
Load Diff
@@ -1,76 +1,76 @@
|
||||
// the underfloor wiring terminal for the APC
|
||||
// autogenerated when an APC is placed
|
||||
// all conduit connects go to this object instead of the APC
|
||||
// using this solves the problem of having the APC in a wall yet also inside an area
|
||||
|
||||
/obj/machinery/power/terminal
|
||||
name = "terminal"
|
||||
icon_state = "term"
|
||||
desc = "It's an underfloor wiring terminal for power equipment."
|
||||
level = 1
|
||||
layer = WIRE_TERMINAL_LAYER //a bit above wires
|
||||
var/obj/machinery/power/master = null
|
||||
|
||||
|
||||
/obj/machinery/power/terminal/Initialize(mapload)
|
||||
. = ..()
|
||||
var/turf/T = get_turf(src)
|
||||
if(level == 1)
|
||||
hide(T.intact)
|
||||
|
||||
/obj/machinery/power/terminal/Destroy()
|
||||
if(master)
|
||||
master.disconnect_terminal()
|
||||
master = null
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/power/terminal/hide(i)
|
||||
if(i)
|
||||
invisibility = 101
|
||||
icon_state = "term-f"
|
||||
else
|
||||
invisibility = 0
|
||||
icon_state = "term"
|
||||
|
||||
/obj/machinery/power/proc/can_terminal_dismantle()
|
||||
. = 0
|
||||
|
||||
/obj/machinery/power/apc/can_terminal_dismantle()
|
||||
. = 0
|
||||
if(opened)
|
||||
. = 1
|
||||
|
||||
/obj/machinery/power/smes/can_terminal_dismantle()
|
||||
. = 0
|
||||
if(panel_open)
|
||||
. = 1
|
||||
|
||||
|
||||
/obj/machinery/power/terminal/proc/dismantle(mob/living/user, obj/item/W)
|
||||
if(isturf(loc))
|
||||
var/turf/T = loc
|
||||
if(T.intact)
|
||||
to_chat(user, "<span class='warning'>You must first expose the power terminal!</span>")
|
||||
return
|
||||
|
||||
if(!master || master.can_terminal_dismantle())
|
||||
user.visible_message("[user.name] dismantles the power terminal from [master].", \
|
||||
"<span class='notice'>You begin to cut the cables...</span>")
|
||||
|
||||
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 50*W.toolspeed, target = src))
|
||||
if(!master || master.can_terminal_dismantle())
|
||||
if(prob(50) && electrocute_mob(user, powernet, src, 1, TRUE))
|
||||
do_sparks(5, TRUE, master)
|
||||
return
|
||||
new /obj/item/stack/cable_coil(loc, 10)
|
||||
to_chat(user, "<span class='notice'>You cut the cables and dismantle the power terminal.</span>")
|
||||
qdel(src)
|
||||
|
||||
|
||||
/obj/machinery/power/terminal/attackby(obj/item/W, mob/living/user, params)
|
||||
if(istype(W, /obj/item/wirecutters))
|
||||
dismantle(user, W)
|
||||
else
|
||||
return ..()
|
||||
// the underfloor wiring terminal for the APC
|
||||
// autogenerated when an APC is placed
|
||||
// all conduit connects go to this object instead of the APC
|
||||
// using this solves the problem of having the APC in a wall yet also inside an area
|
||||
|
||||
/obj/machinery/power/terminal
|
||||
name = "terminal"
|
||||
icon_state = "term"
|
||||
desc = "It's an underfloor wiring terminal for power equipment."
|
||||
level = 1
|
||||
layer = WIRE_TERMINAL_LAYER //a bit above wires
|
||||
var/obj/machinery/power/master = null
|
||||
|
||||
|
||||
/obj/machinery/power/terminal/Initialize(mapload)
|
||||
. = ..()
|
||||
var/turf/T = get_turf(src)
|
||||
if(level == 1)
|
||||
hide(T.intact)
|
||||
|
||||
/obj/machinery/power/terminal/Destroy()
|
||||
if(master)
|
||||
master.disconnect_terminal()
|
||||
master = null
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/power/terminal/hide(i)
|
||||
if(i)
|
||||
invisibility = 101
|
||||
icon_state = "term-f"
|
||||
else
|
||||
invisibility = 0
|
||||
icon_state = "term"
|
||||
|
||||
/obj/machinery/power/proc/can_terminal_dismantle()
|
||||
. = 0
|
||||
|
||||
/obj/machinery/power/apc/can_terminal_dismantle()
|
||||
. = 0
|
||||
if(opened)
|
||||
. = 1
|
||||
|
||||
/obj/machinery/power/smes/can_terminal_dismantle()
|
||||
. = 0
|
||||
if(panel_open)
|
||||
. = 1
|
||||
|
||||
|
||||
/obj/machinery/power/terminal/proc/dismantle(mob/living/user, obj/item/W)
|
||||
if(isturf(loc))
|
||||
var/turf/T = loc
|
||||
if(T.intact)
|
||||
to_chat(user, "<span class='warning'>You must first expose the power terminal!</span>")
|
||||
return
|
||||
|
||||
if(!master || master.can_terminal_dismantle())
|
||||
user.visible_message("[user.name] dismantles the power terminal from [master].", \
|
||||
"<span class='notice'>You begin to cut the cables...</span>")
|
||||
|
||||
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 50*W.toolspeed, target = src))
|
||||
if(!master || master.can_terminal_dismantle())
|
||||
if(prob(50) && electrocute_mob(user, powernet, src, 1, TRUE))
|
||||
do_sparks(5, TRUE, master)
|
||||
return
|
||||
new /obj/item/stack/cable_coil(loc, 10)
|
||||
to_chat(user, "<span class='notice'>You cut the cables and dismantle the power terminal.</span>")
|
||||
qdel(src)
|
||||
|
||||
|
||||
/obj/machinery/power/terminal/attackby(obj/item/W, mob/living/user, params)
|
||||
if(istype(W, /obj/item/wirecutters))
|
||||
dismantle(user, W)
|
||||
else
|
||||
return ..()
|
||||
|
||||
@@ -288,4 +288,4 @@
|
||||
closest_blob.tesla_act(power, explosive)
|
||||
|
||||
else if(closest_structure)
|
||||
closest_structure.tesla_act(power, explosive)
|
||||
closest_structure.tesla_act(power, explosive)
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
|
||||
/obj/machinery/the_singularitygen/tesla/tesla_act(power, explosive = FALSE)
|
||||
if(explosive)
|
||||
energy += power
|
||||
energy += power
|
||||
|
||||
+100
-100
@@ -1,100 +1,100 @@
|
||||
//Solar tracker
|
||||
|
||||
//Machine that tracks the sun and reports it's direction to the solar controllers
|
||||
//As long as this is working, solar panels on same powernet will track automatically
|
||||
|
||||
/obj/machinery/power/tracker
|
||||
name = "solar tracker"
|
||||
desc = "A solar directional tracker."
|
||||
icon = 'icons/obj/power.dmi'
|
||||
icon_state = "tracker"
|
||||
density = TRUE
|
||||
use_power = NO_POWER_USE
|
||||
max_integrity = 250
|
||||
integrity_failure = 50
|
||||
|
||||
var/id = 0
|
||||
var/sun_angle = 0 // sun angle as set by sun datum
|
||||
var/obj/machinery/power/solar_control/control = null
|
||||
|
||||
/obj/machinery/power/tracker/Initialize(mapload, obj/item/solar_assembly/S)
|
||||
. = ..()
|
||||
Make(S)
|
||||
connect_to_network()
|
||||
|
||||
/obj/machinery/power/tracker/Destroy()
|
||||
unset_control() //remove from control computer
|
||||
return ..()
|
||||
|
||||
//set the control of the tracker to a given computer if closer than SOLAR_MAX_DIST
|
||||
/obj/machinery/power/tracker/proc/set_control(obj/machinery/power/solar_control/SC)
|
||||
if(SC && (get_dist(src, SC) > SOLAR_MAX_DIST))
|
||||
return 0
|
||||
control = SC
|
||||
SC.connected_tracker = src
|
||||
return 1
|
||||
|
||||
//set the control of the tracker to null and removes it from the previous control computer if needed
|
||||
/obj/machinery/power/tracker/proc/unset_control()
|
||||
if(control)
|
||||
control.connected_tracker = null
|
||||
control = null
|
||||
|
||||
/obj/machinery/power/tracker/proc/Make(obj/item/solar_assembly/S)
|
||||
if(!S)
|
||||
S = new /obj/item/solar_assembly(src)
|
||||
S.glass_type = /obj/item/stack/sheet/glass
|
||||
S.tracker = 1
|
||||
S.anchored = TRUE
|
||||
S.forceMove(src)
|
||||
update_icon()
|
||||
|
||||
//updates the tracker icon and the facing angle for the control computer
|
||||
/obj/machinery/power/tracker/proc/set_angle(angle)
|
||||
sun_angle = angle
|
||||
|
||||
//set icon dir to show sun illumination
|
||||
setDir(turn(NORTH, -angle - 22.5)) // 22.5 deg bias ensures, e.g. 67.5-112.5 is EAST
|
||||
|
||||
if(powernet && (powernet == control.powernet)) //update if we're still in the same powernet
|
||||
control.cdir = angle
|
||||
|
||||
/obj/machinery/power/tracker/crowbar_act(mob/user, obj/item/I)
|
||||
. = TRUE
|
||||
if(!I.tool_use_check(user, 0))
|
||||
return
|
||||
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
|
||||
user.visible_message("<span class='notice'>[user] begins to take the glass off the solar tracker.</span>")
|
||||
if(I.use_tool(src, user, 50, volume = I.tool_volume))
|
||||
user.visible_message("<span class='notice'>[user] takes the glass off the tracker.</span>")
|
||||
deconstruct(TRUE)
|
||||
|
||||
|
||||
/obj/machinery/power/tracker/obj_break(damage_flag)
|
||||
if(!(stat & BROKEN) && !(flags & NODECONSTRUCT))
|
||||
playsound(loc, 'sound/effects/glassbr3.ogg', 100, TRUE)
|
||||
stat |= BROKEN
|
||||
unset_control()
|
||||
|
||||
/obj/machinery/power/solar/deconstruct(disassembled = TRUE)
|
||||
if(!(flags & NODECONSTRUCT))
|
||||
if(disassembled)
|
||||
var/obj/item/solar_assembly/S = locate() in src
|
||||
if(S)
|
||||
S.forceMove(loc)
|
||||
S.give_glass(stat & BROKEN)
|
||||
else
|
||||
playsound(src, "shatter", 70, TRUE)
|
||||
new /obj/item/shard(src.loc)
|
||||
new /obj/item/shard(src.loc)
|
||||
qdel(src)
|
||||
|
||||
// Tracker Electronic
|
||||
|
||||
/obj/item/tracker_electronics
|
||||
|
||||
name = "tracker electronics"
|
||||
icon = 'icons/obj/doors/door_assembly.dmi'
|
||||
icon_state = "door_electronics"
|
||||
w_class = WEIGHT_CLASS_SMALL
|
||||
origin_tech = "engineering=2;programming=1"
|
||||
//Solar tracker
|
||||
|
||||
//Machine that tracks the sun and reports it's direction to the solar controllers
|
||||
//As long as this is working, solar panels on same powernet will track automatically
|
||||
|
||||
/obj/machinery/power/tracker
|
||||
name = "solar tracker"
|
||||
desc = "A solar directional tracker."
|
||||
icon = 'icons/obj/power.dmi'
|
||||
icon_state = "tracker"
|
||||
density = TRUE
|
||||
use_power = NO_POWER_USE
|
||||
max_integrity = 250
|
||||
integrity_failure = 50
|
||||
|
||||
var/id = 0
|
||||
var/sun_angle = 0 // sun angle as set by sun datum
|
||||
var/obj/machinery/power/solar_control/control = null
|
||||
|
||||
/obj/machinery/power/tracker/Initialize(mapload, obj/item/solar_assembly/S)
|
||||
. = ..()
|
||||
Make(S)
|
||||
connect_to_network()
|
||||
|
||||
/obj/machinery/power/tracker/Destroy()
|
||||
unset_control() //remove from control computer
|
||||
return ..()
|
||||
|
||||
//set the control of the tracker to a given computer if closer than SOLAR_MAX_DIST
|
||||
/obj/machinery/power/tracker/proc/set_control(obj/machinery/power/solar_control/SC)
|
||||
if(SC && (get_dist(src, SC) > SOLAR_MAX_DIST))
|
||||
return 0
|
||||
control = SC
|
||||
SC.connected_tracker = src
|
||||
return 1
|
||||
|
||||
//set the control of the tracker to null and removes it from the previous control computer if needed
|
||||
/obj/machinery/power/tracker/proc/unset_control()
|
||||
if(control)
|
||||
control.connected_tracker = null
|
||||
control = null
|
||||
|
||||
/obj/machinery/power/tracker/proc/Make(obj/item/solar_assembly/S)
|
||||
if(!S)
|
||||
S = new /obj/item/solar_assembly(src)
|
||||
S.glass_type = /obj/item/stack/sheet/glass
|
||||
S.tracker = 1
|
||||
S.anchored = TRUE
|
||||
S.forceMove(src)
|
||||
update_icon()
|
||||
|
||||
//updates the tracker icon and the facing angle for the control computer
|
||||
/obj/machinery/power/tracker/proc/set_angle(angle)
|
||||
sun_angle = angle
|
||||
|
||||
//set icon dir to show sun illumination
|
||||
setDir(turn(NORTH, -angle - 22.5)) // 22.5 deg bias ensures, e.g. 67.5-112.5 is EAST
|
||||
|
||||
if(powernet && (powernet == control.powernet)) //update if we're still in the same powernet
|
||||
control.cdir = angle
|
||||
|
||||
/obj/machinery/power/tracker/crowbar_act(mob/user, obj/item/I)
|
||||
. = TRUE
|
||||
if(!I.tool_use_check(user, 0))
|
||||
return
|
||||
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
|
||||
user.visible_message("<span class='notice'>[user] begins to take the glass off the solar tracker.</span>")
|
||||
if(I.use_tool(src, user, 50, volume = I.tool_volume))
|
||||
user.visible_message("<span class='notice'>[user] takes the glass off the tracker.</span>")
|
||||
deconstruct(TRUE)
|
||||
|
||||
|
||||
/obj/machinery/power/tracker/obj_break(damage_flag)
|
||||
if(!(stat & BROKEN) && !(flags & NODECONSTRUCT))
|
||||
playsound(loc, 'sound/effects/glassbr3.ogg', 100, TRUE)
|
||||
stat |= BROKEN
|
||||
unset_control()
|
||||
|
||||
/obj/machinery/power/solar/deconstruct(disassembled = TRUE)
|
||||
if(!(flags & NODECONSTRUCT))
|
||||
if(disassembled)
|
||||
var/obj/item/solar_assembly/S = locate() in src
|
||||
if(S)
|
||||
S.forceMove(loc)
|
||||
S.give_glass(stat & BROKEN)
|
||||
else
|
||||
playsound(src, "shatter", 70, TRUE)
|
||||
new /obj/item/shard(src.loc)
|
||||
new /obj/item/shard(src.loc)
|
||||
qdel(src)
|
||||
|
||||
// Tracker Electronic
|
||||
|
||||
/obj/item/tracker_electronics
|
||||
|
||||
name = "tracker electronics"
|
||||
icon = 'icons/obj/doors/door_assembly.dmi'
|
||||
icon_state = "door_electronics"
|
||||
w_class = WEIGHT_CLASS_SMALL
|
||||
origin_tech = "engineering=2;programming=1"
|
||||
|
||||
+405
-405
@@ -1,405 +1,405 @@
|
||||
// TURBINE v2 AKA rev4407 Engine reborn!
|
||||
|
||||
// How to use it? - Mappers
|
||||
//
|
||||
// This is a very good power generating mechanism. All you need is a blast furnace with soaring flames and output.
|
||||
// Not everything is included yet so the turbine can run out of fuel quiet quickly. The best thing about the turbine is that even
|
||||
// though something is on fire that passes through it, it won't be on fire as it passes out of it. So the exhaust fumes can still
|
||||
// containt unreacted fuel - plasma and oxygen that needs to be filtered out and re-routed back. This of course requires smart piping
|
||||
// For a computer to work with the turbine the compressor requires a comp_id matching with the turbine computer's id. This will be
|
||||
// subjected to a change in the near future mind you. Right now this method of generating power is a good backup but don't expect it
|
||||
// become a main power source unless some work is done. Have fun. At 50k RPM it generates 60k power. So more than one turbine is needed!
|
||||
//
|
||||
// - Numbers
|
||||
//
|
||||
// Example setup S - sparker
|
||||
// B - Blast doors into space for venting
|
||||
// *BBB****BBB* C - Compressor
|
||||
// S CT * T - Turbine
|
||||
// * ^ * * V * D - Doors with firedoor
|
||||
// **|***D**|** ^ - Fuel feed (Not vent, but a gas outlet)
|
||||
// | | V - Suction vent (Like the ones in atmos
|
||||
//
|
||||
|
||||
|
||||
/obj/machinery/power/compressor
|
||||
name = "compressor"
|
||||
desc = "The compressor stage of a gas turbine generator."
|
||||
icon = 'icons/obj/pipes.dmi'
|
||||
icon_state = "compressor"
|
||||
anchored = 1
|
||||
density = 1
|
||||
resistance_flags = FIRE_PROOF
|
||||
var/obj/machinery/power/turbine/turbine
|
||||
var/datum/gas_mixture/gas_contained
|
||||
var/turf/simulated/inturf
|
||||
var/starter = 0
|
||||
var/rpm = 0
|
||||
var/rpmtarget = 0
|
||||
var/capacity = 1e6
|
||||
var/comp_id = 0
|
||||
var/efficiency
|
||||
|
||||
|
||||
/obj/machinery/power/turbine
|
||||
name = "gas turbine generator"
|
||||
desc = "A gas turbine used for backup power generation."
|
||||
icon = 'icons/obj/pipes.dmi'
|
||||
icon_state = "turbine"
|
||||
anchored = 1
|
||||
density = 1
|
||||
resistance_flags = FIRE_PROOF
|
||||
var/opened = 0
|
||||
var/obj/machinery/power/compressor/compressor
|
||||
var/turf/simulated/outturf
|
||||
var/lastgen
|
||||
var/productivity = 1
|
||||
|
||||
/obj/machinery/computer/turbine_computer
|
||||
name = "gas turbine control computer"
|
||||
desc = "A computer to remotely control a gas turbine"
|
||||
icon_screen = "turbinecomp"
|
||||
icon_keyboard = "tech_key"
|
||||
circuit = /obj/item/circuitboard/turbine_computer
|
||||
var/obj/machinery/power/compressor/compressor
|
||||
var/id = 0
|
||||
|
||||
// the inlet stage of the gas turbine electricity generator
|
||||
|
||||
/obj/machinery/power/compressor/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/power_compressor(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 5)
|
||||
RefreshParts()
|
||||
// The inlet of the compressor is the direction it faces
|
||||
|
||||
gas_contained = new
|
||||
inturf = get_step(src, dir)
|
||||
locate_machinery()
|
||||
if(!turbine)
|
||||
stat |= BROKEN
|
||||
|
||||
|
||||
#define COMPFRICTION 5e5
|
||||
#define COMPSTARTERLOAD 2800
|
||||
|
||||
|
||||
// Crucial to make things work!!!!
|
||||
// OLD FIX - explanation given down below.
|
||||
// /obj/machinery/power/compressor/CanPass(atom/movable/mover, turf/target, height=0)
|
||||
// return !density
|
||||
|
||||
/obj/machinery/power/compressor/locate_machinery()
|
||||
if(turbine)
|
||||
return
|
||||
turbine = locate() in get_step(src, get_dir(inturf, src))
|
||||
if(turbine)
|
||||
turbine.locate_machinery()
|
||||
|
||||
/obj/machinery/power/compressor/RefreshParts()
|
||||
var/E = 0
|
||||
for(var/obj/item/stock_parts/manipulator/M in component_parts)
|
||||
E += M.rating
|
||||
efficiency = E / 6
|
||||
|
||||
/obj/machinery/power/compressor/attackby(obj/item/I, mob/user, params)
|
||||
if(default_change_direction_wrench(user, I))
|
||||
turbine = null
|
||||
inturf = get_step(src, dir)
|
||||
locate_machinery()
|
||||
if(turbine)
|
||||
to_chat(user, "<span class='notice'>Turbine connected.</span>")
|
||||
stat &= ~BROKEN
|
||||
else
|
||||
to_chat(user, "<span class='alert'>Turbine not connected.</span>")
|
||||
stat |= BROKEN
|
||||
return
|
||||
|
||||
if(exchange_parts(user, I))
|
||||
return
|
||||
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/compressor/crowbar_act(mob/user, obj/item/I)
|
||||
if(default_deconstruction_crowbar(user, I))
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/power/compressor/screwdriver_act(mob/user, obj/item/I)
|
||||
if(default_deconstruction_screwdriver(user, initial(icon_state), initial(icon_state), I))
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/power/compressor/CanAtmosPass(turf/T)
|
||||
return !density
|
||||
|
||||
/obj/machinery/power/compressor/process()
|
||||
if(!turbine)
|
||||
stat = BROKEN
|
||||
if(stat & BROKEN || panel_open)
|
||||
return
|
||||
if(!starter)
|
||||
return
|
||||
overlays.Cut()
|
||||
|
||||
rpm = 0.9* rpm + 0.1 * rpmtarget
|
||||
var/datum/gas_mixture/environment = inturf.return_air()
|
||||
|
||||
// It's a simplified version taking only 1/10 of the moles from the turf nearby. It should be later changed into a better version
|
||||
|
||||
var/transfer_moles = environment.total_moles()/10
|
||||
//var/transfer_moles = rpm/10000*capacity
|
||||
var/datum/gas_mixture/removed = inturf.remove_air(transfer_moles)
|
||||
gas_contained.merge(removed)
|
||||
|
||||
// RPM function to include compression friction - be advised that too low/high of a compfriction value can make things screwy
|
||||
|
||||
rpm = max(0, rpm - (rpm*rpm)/(COMPFRICTION*efficiency))
|
||||
|
||||
|
||||
if(starter && !(stat & NOPOWER))
|
||||
use_power(2800)
|
||||
if(rpm<1000)
|
||||
rpmtarget = 1000
|
||||
else
|
||||
if(rpm<1000)
|
||||
rpmtarget = 0
|
||||
|
||||
|
||||
if(rpm>50000)
|
||||
overlays += image('icons/obj/pipes.dmi', "comp-o4", FLY_LAYER)
|
||||
else if(rpm>10000)
|
||||
overlays += image('icons/obj/pipes.dmi', "comp-o3", FLY_LAYER)
|
||||
else if(rpm>2000)
|
||||
overlays += image('icons/obj/pipes.dmi', "comp-o2", FLY_LAYER)
|
||||
else if(rpm>500)
|
||||
overlays += image('icons/obj/pipes.dmi', "comp-o1", FLY_LAYER)
|
||||
//TODO: DEFERRED
|
||||
|
||||
// These are crucial to working of a turbine - the stats modify the power output. TurbGenQ modifies how much raw energy can you get from
|
||||
// rpms, TurbGenG modifies the shape of the curve - the lower the value the less straight the curve is.
|
||||
|
||||
#define TURBPRES 9000000
|
||||
#define TURBGENQ 100000
|
||||
#define TURBGENG 0.5
|
||||
|
||||
/obj/machinery/power/turbine/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/power_turbine(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stack/cable_coil(src, 5)
|
||||
RefreshParts()
|
||||
// The outlet is pointed at the direction of the turbine component
|
||||
|
||||
outturf = get_step(src, dir)
|
||||
locate_machinery()
|
||||
if(!compressor)
|
||||
stat |= BROKEN
|
||||
|
||||
/obj/machinery/power/turbine/RefreshParts()
|
||||
var/P = 0
|
||||
for(var/obj/item/stock_parts/capacitor/C in component_parts)
|
||||
P += C.rating
|
||||
productivity = P / 6
|
||||
|
||||
/obj/machinery/power/turbine/locate_machinery()
|
||||
if(compressor)
|
||||
return
|
||||
compressor = locate() in get_step(src, get_dir(outturf, src))
|
||||
if(compressor)
|
||||
compressor.locate_machinery()
|
||||
|
||||
/obj/machinery/power/turbine/CanAtmosPass(turf/T)
|
||||
return !density
|
||||
|
||||
/obj/machinery/power/turbine/process()
|
||||
|
||||
if(!compressor)
|
||||
stat = BROKEN
|
||||
|
||||
if((stat & BROKEN) || panel_open)
|
||||
return
|
||||
if(!compressor.starter)
|
||||
return
|
||||
overlays.Cut()
|
||||
|
||||
// This is the power generation function. If anything is needed it's good to plot it in EXCEL before modifying
|
||||
// the TURBGENQ and TURBGENG values
|
||||
|
||||
lastgen = ((compressor.rpm / TURBGENQ)**TURBGENG) * TURBGENQ * productivity
|
||||
|
||||
add_avail(lastgen)
|
||||
|
||||
// Weird function but it works. Should be something else...
|
||||
|
||||
var/newrpm = ((compressor.gas_contained.temperature) * compressor.gas_contained.total_moles())/4
|
||||
|
||||
newrpm = max(0, newrpm)
|
||||
|
||||
if(!compressor.starter || newrpm > 1000)
|
||||
compressor.rpmtarget = newrpm
|
||||
|
||||
if(compressor.gas_contained.total_moles()>0)
|
||||
var/oamount = min(compressor.gas_contained.total_moles(), (compressor.rpm+100)/35000*compressor.capacity)
|
||||
var/datum/gas_mixture/removed = compressor.gas_contained.remove(oamount)
|
||||
outturf.assume_air(removed)
|
||||
|
||||
// If it works, put an overlay that it works!
|
||||
|
||||
if(lastgen > 100)
|
||||
overlays += image('icons/obj/pipes.dmi', "turb-o", FLY_LAYER)
|
||||
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/power/turbine/attack_hand(mob/user)
|
||||
|
||||
if(..())
|
||||
return
|
||||
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/turbine/attackby(obj/item/I, mob/user, params)
|
||||
if(default_deconstruction_screwdriver(user, initial(icon_state), initial(icon_state), I))
|
||||
return
|
||||
|
||||
if(default_change_direction_wrench(user, I))
|
||||
compressor = null
|
||||
outturf = get_step(src, dir)
|
||||
locate_machinery()
|
||||
if(compressor)
|
||||
to_chat(user, "<span class='notice'>Compressor connected.</span>")
|
||||
stat &= ~BROKEN
|
||||
else
|
||||
to_chat(user, "<span class='alert'>Compressor not connected.</span>")
|
||||
stat |= BROKEN
|
||||
return
|
||||
|
||||
if(exchange_parts(user, I))
|
||||
return
|
||||
|
||||
if(default_deconstruction_crowbar(user, I))
|
||||
return
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/turbine/interact(mob/user)
|
||||
|
||||
if( !Adjacent(user) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon)) )
|
||||
user.unset_machine(src)
|
||||
user << browse(null, "window=turbine")
|
||||
return
|
||||
|
||||
var/t = "<TT><B>Gas Turbine Generator</B><HR><PRE>"
|
||||
|
||||
t += "Generated power : [round(lastgen)] W<BR><BR>"
|
||||
|
||||
t += "Turbine: [round(compressor.rpm)] RPM<BR>"
|
||||
|
||||
t += "Starter: [ compressor.starter ? "<A href='?src=[UID()];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=[UID()];str=1'>On</A>"]"
|
||||
|
||||
t += "</PRE><HR><A href='?src=[UID()];close=1'>Close</A>"
|
||||
|
||||
t += "</TT>"
|
||||
var/datum/browser/popup = new(user, "turbine", name)
|
||||
popup.set_content(t)
|
||||
popup.open()
|
||||
|
||||
return
|
||||
|
||||
/obj/machinery/power/turbine/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=turbine")
|
||||
usr.unset_machine(src)
|
||||
return
|
||||
|
||||
else if( href_list["str"] )
|
||||
if(compressor)
|
||||
compressor.starter = !compressor.starter
|
||||
|
||||
updateDialog()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// COMPUTER NEEDS A SERIOUS REWRITE.
|
||||
|
||||
|
||||
|
||||
/obj/machinery/computer/turbine_computer/Initialize()
|
||||
..()
|
||||
spawn(10)
|
||||
locate_machinery()
|
||||
|
||||
/obj/machinery/computer/turbine_computer/locate_machinery()
|
||||
compressor = locate(/obj/machinery/power/compressor) in range(5, src)
|
||||
|
||||
/obj/machinery/computer/turbine_computer/attack_hand(var/mob/user as mob)
|
||||
if(..())
|
||||
return
|
||||
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/computer/turbine_computer/interact(mob/user)
|
||||
|
||||
var/dat
|
||||
if(compressor && compressor.turbine)
|
||||
dat += "<BR><B>Gas turbine remote control system</B><HR>"
|
||||
if(compressor.stat || compressor.turbine.stat)
|
||||
dat += "[compressor.stat ? "<B>Compressor is inoperable</B><BR>" : "<B>Turbine is inoperable</B>"]"
|
||||
else
|
||||
dat += {"Turbine status: [ src.compressor.starter ? "<A href='?src=[UID()];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=[UID()];str=1'>On</A>"]
|
||||
\n<BR>
|
||||
\nTurbine speed: [src.compressor.rpm]rpm<BR>
|
||||
\nPower currently being generated: [src.compressor.turbine.lastgen]W<BR>
|
||||
\nInternal gas temperature: [src.compressor.gas_contained.temperature]K<BR>
|
||||
\n</PRE><HR><A href='?src=[UID()];close=1'>Close</A>
|
||||
\n<BR>
|
||||
\n"}
|
||||
else
|
||||
dat += "<B>There is [!compressor ? "no compressor" : " compressor[!compressor.turbine ? " but no turbine" : ""]"].</B><BR>"
|
||||
if(!compressor)
|
||||
dat += "<A href='?src=[UID()];search=1'>Search for compressor</A>"
|
||||
|
||||
var/datum/browser/popup = new(user, "turbinecomputer", name)
|
||||
popup.set_content(dat)
|
||||
popup.open()
|
||||
return
|
||||
|
||||
/obj/machinery/computer/turbine_computer/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
else if( href_list["str"] )
|
||||
if(compressor && compressor.turbine)
|
||||
compressor.starter = !compressor.starter
|
||||
else if( href_list["close"] )
|
||||
usr << browse(null, "window=turbinecomputer")
|
||||
usr.unset_machine(src)
|
||||
return
|
||||
else if(href_list["search"])
|
||||
locate_machinery()
|
||||
|
||||
src.updateUsrDialog()
|
||||
return
|
||||
|
||||
/obj/machinery/computer/turbine_computer/process()
|
||||
src.updateDialog()
|
||||
return
|
||||
// TURBINE v2 AKA rev4407 Engine reborn!
|
||||
|
||||
// How to use it? - Mappers
|
||||
//
|
||||
// This is a very good power generating mechanism. All you need is a blast furnace with soaring flames and output.
|
||||
// Not everything is included yet so the turbine can run out of fuel quiet quickly. The best thing about the turbine is that even
|
||||
// though something is on fire that passes through it, it won't be on fire as it passes out of it. So the exhaust fumes can still
|
||||
// containt unreacted fuel - plasma and oxygen that needs to be filtered out and re-routed back. This of course requires smart piping
|
||||
// For a computer to work with the turbine the compressor requires a comp_id matching with the turbine computer's id. This will be
|
||||
// subjected to a change in the near future mind you. Right now this method of generating power is a good backup but don't expect it
|
||||
// become a main power source unless some work is done. Have fun. At 50k RPM it generates 60k power. So more than one turbine is needed!
|
||||
//
|
||||
// - Numbers
|
||||
//
|
||||
// Example setup S - sparker
|
||||
// B - Blast doors into space for venting
|
||||
// *BBB****BBB* C - Compressor
|
||||
// S CT * T - Turbine
|
||||
// * ^ * * V * D - Doors with firedoor
|
||||
// **|***D**|** ^ - Fuel feed (Not vent, but a gas outlet)
|
||||
// | | V - Suction vent (Like the ones in atmos
|
||||
//
|
||||
|
||||
|
||||
/obj/machinery/power/compressor
|
||||
name = "compressor"
|
||||
desc = "The compressor stage of a gas turbine generator."
|
||||
icon = 'icons/obj/pipes.dmi'
|
||||
icon_state = "compressor"
|
||||
anchored = 1
|
||||
density = 1
|
||||
resistance_flags = FIRE_PROOF
|
||||
var/obj/machinery/power/turbine/turbine
|
||||
var/datum/gas_mixture/gas_contained
|
||||
var/turf/simulated/inturf
|
||||
var/starter = 0
|
||||
var/rpm = 0
|
||||
var/rpmtarget = 0
|
||||
var/capacity = 1e6
|
||||
var/comp_id = 0
|
||||
var/efficiency
|
||||
|
||||
|
||||
/obj/machinery/power/turbine
|
||||
name = "gas turbine generator"
|
||||
desc = "A gas turbine used for backup power generation."
|
||||
icon = 'icons/obj/pipes.dmi'
|
||||
icon_state = "turbine"
|
||||
anchored = 1
|
||||
density = 1
|
||||
resistance_flags = FIRE_PROOF
|
||||
var/opened = 0
|
||||
var/obj/machinery/power/compressor/compressor
|
||||
var/turf/simulated/outturf
|
||||
var/lastgen
|
||||
var/productivity = 1
|
||||
|
||||
/obj/machinery/computer/turbine_computer
|
||||
name = "gas turbine control computer"
|
||||
desc = "A computer to remotely control a gas turbine"
|
||||
icon_screen = "turbinecomp"
|
||||
icon_keyboard = "tech_key"
|
||||
circuit = /obj/item/circuitboard/turbine_computer
|
||||
var/obj/machinery/power/compressor/compressor
|
||||
var/id = 0
|
||||
|
||||
// the inlet stage of the gas turbine electricity generator
|
||||
|
||||
/obj/machinery/power/compressor/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/power_compressor(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stock_parts/manipulator(null)
|
||||
component_parts += new /obj/item/stack/cable_coil(null, 5)
|
||||
RefreshParts()
|
||||
// The inlet of the compressor is the direction it faces
|
||||
|
||||
gas_contained = new
|
||||
inturf = get_step(src, dir)
|
||||
locate_machinery()
|
||||
if(!turbine)
|
||||
stat |= BROKEN
|
||||
|
||||
|
||||
#define COMPFRICTION 5e5
|
||||
#define COMPSTARTERLOAD 2800
|
||||
|
||||
|
||||
// Crucial to make things work!!!!
|
||||
// OLD FIX - explanation given down below.
|
||||
// /obj/machinery/power/compressor/CanPass(atom/movable/mover, turf/target, height=0)
|
||||
// return !density
|
||||
|
||||
/obj/machinery/power/compressor/locate_machinery()
|
||||
if(turbine)
|
||||
return
|
||||
turbine = locate() in get_step(src, get_dir(inturf, src))
|
||||
if(turbine)
|
||||
turbine.locate_machinery()
|
||||
|
||||
/obj/machinery/power/compressor/RefreshParts()
|
||||
var/E = 0
|
||||
for(var/obj/item/stock_parts/manipulator/M in component_parts)
|
||||
E += M.rating
|
||||
efficiency = E / 6
|
||||
|
||||
/obj/machinery/power/compressor/attackby(obj/item/I, mob/user, params)
|
||||
if(default_change_direction_wrench(user, I))
|
||||
turbine = null
|
||||
inturf = get_step(src, dir)
|
||||
locate_machinery()
|
||||
if(turbine)
|
||||
to_chat(user, "<span class='notice'>Turbine connected.</span>")
|
||||
stat &= ~BROKEN
|
||||
else
|
||||
to_chat(user, "<span class='alert'>Turbine not connected.</span>")
|
||||
stat |= BROKEN
|
||||
return
|
||||
|
||||
if(exchange_parts(user, I))
|
||||
return
|
||||
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/compressor/crowbar_act(mob/user, obj/item/I)
|
||||
if(default_deconstruction_crowbar(user, I))
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/power/compressor/screwdriver_act(mob/user, obj/item/I)
|
||||
if(default_deconstruction_screwdriver(user, initial(icon_state), initial(icon_state), I))
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/power/compressor/CanAtmosPass(turf/T)
|
||||
return !density
|
||||
|
||||
/obj/machinery/power/compressor/process()
|
||||
if(!turbine)
|
||||
stat = BROKEN
|
||||
if(stat & BROKEN || panel_open)
|
||||
return
|
||||
if(!starter)
|
||||
return
|
||||
overlays.Cut()
|
||||
|
||||
rpm = 0.9* rpm + 0.1 * rpmtarget
|
||||
var/datum/gas_mixture/environment = inturf.return_air()
|
||||
|
||||
// It's a simplified version taking only 1/10 of the moles from the turf nearby. It should be later changed into a better version
|
||||
|
||||
var/transfer_moles = environment.total_moles()/10
|
||||
//var/transfer_moles = rpm/10000*capacity
|
||||
var/datum/gas_mixture/removed = inturf.remove_air(transfer_moles)
|
||||
gas_contained.merge(removed)
|
||||
|
||||
// RPM function to include compression friction - be advised that too low/high of a compfriction value can make things screwy
|
||||
|
||||
rpm = max(0, rpm - (rpm*rpm)/(COMPFRICTION*efficiency))
|
||||
|
||||
|
||||
if(starter && !(stat & NOPOWER))
|
||||
use_power(2800)
|
||||
if(rpm<1000)
|
||||
rpmtarget = 1000
|
||||
else
|
||||
if(rpm<1000)
|
||||
rpmtarget = 0
|
||||
|
||||
|
||||
if(rpm>50000)
|
||||
overlays += image('icons/obj/pipes.dmi', "comp-o4", FLY_LAYER)
|
||||
else if(rpm>10000)
|
||||
overlays += image('icons/obj/pipes.dmi', "comp-o3", FLY_LAYER)
|
||||
else if(rpm>2000)
|
||||
overlays += image('icons/obj/pipes.dmi', "comp-o2", FLY_LAYER)
|
||||
else if(rpm>500)
|
||||
overlays += image('icons/obj/pipes.dmi', "comp-o1", FLY_LAYER)
|
||||
//TODO: DEFERRED
|
||||
|
||||
// These are crucial to working of a turbine - the stats modify the power output. TurbGenQ modifies how much raw energy can you get from
|
||||
// rpms, TurbGenG modifies the shape of the curve - the lower the value the less straight the curve is.
|
||||
|
||||
#define TURBPRES 9000000
|
||||
#define TURBGENQ 100000
|
||||
#define TURBGENG 0.5
|
||||
|
||||
/obj/machinery/power/turbine/Initialize(mapload)
|
||||
. = ..()
|
||||
component_parts = list()
|
||||
component_parts += new /obj/item/circuitboard/power_turbine(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stock_parts/capacitor(src)
|
||||
component_parts += new /obj/item/stack/cable_coil(src, 5)
|
||||
RefreshParts()
|
||||
// The outlet is pointed at the direction of the turbine component
|
||||
|
||||
outturf = get_step(src, dir)
|
||||
locate_machinery()
|
||||
if(!compressor)
|
||||
stat |= BROKEN
|
||||
|
||||
/obj/machinery/power/turbine/RefreshParts()
|
||||
var/P = 0
|
||||
for(var/obj/item/stock_parts/capacitor/C in component_parts)
|
||||
P += C.rating
|
||||
productivity = P / 6
|
||||
|
||||
/obj/machinery/power/turbine/locate_machinery()
|
||||
if(compressor)
|
||||
return
|
||||
compressor = locate() in get_step(src, get_dir(outturf, src))
|
||||
if(compressor)
|
||||
compressor.locate_machinery()
|
||||
|
||||
/obj/machinery/power/turbine/CanAtmosPass(turf/T)
|
||||
return !density
|
||||
|
||||
/obj/machinery/power/turbine/process()
|
||||
|
||||
if(!compressor)
|
||||
stat = BROKEN
|
||||
|
||||
if((stat & BROKEN) || panel_open)
|
||||
return
|
||||
if(!compressor.starter)
|
||||
return
|
||||
overlays.Cut()
|
||||
|
||||
// This is the power generation function. If anything is needed it's good to plot it in EXCEL before modifying
|
||||
// the TURBGENQ and TURBGENG values
|
||||
|
||||
lastgen = ((compressor.rpm / TURBGENQ)**TURBGENG) * TURBGENQ * productivity
|
||||
|
||||
add_avail(lastgen)
|
||||
|
||||
// Weird function but it works. Should be something else...
|
||||
|
||||
var/newrpm = ((compressor.gas_contained.temperature) * compressor.gas_contained.total_moles())/4
|
||||
|
||||
newrpm = max(0, newrpm)
|
||||
|
||||
if(!compressor.starter || newrpm > 1000)
|
||||
compressor.rpmtarget = newrpm
|
||||
|
||||
if(compressor.gas_contained.total_moles()>0)
|
||||
var/oamount = min(compressor.gas_contained.total_moles(), (compressor.rpm+100)/35000*compressor.capacity)
|
||||
var/datum/gas_mixture/removed = compressor.gas_contained.remove(oamount)
|
||||
outturf.assume_air(removed)
|
||||
|
||||
// If it works, put an overlay that it works!
|
||||
|
||||
if(lastgen > 100)
|
||||
overlays += image('icons/obj/pipes.dmi', "turb-o", FLY_LAYER)
|
||||
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/power/turbine/attack_hand(mob/user)
|
||||
|
||||
if(..())
|
||||
return
|
||||
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/turbine/attackby(obj/item/I, mob/user, params)
|
||||
if(default_deconstruction_screwdriver(user, initial(icon_state), initial(icon_state), I))
|
||||
return
|
||||
|
||||
if(default_change_direction_wrench(user, I))
|
||||
compressor = null
|
||||
outturf = get_step(src, dir)
|
||||
locate_machinery()
|
||||
if(compressor)
|
||||
to_chat(user, "<span class='notice'>Compressor connected.</span>")
|
||||
stat &= ~BROKEN
|
||||
else
|
||||
to_chat(user, "<span class='alert'>Compressor not connected.</span>")
|
||||
stat |= BROKEN
|
||||
return
|
||||
|
||||
if(exchange_parts(user, I))
|
||||
return
|
||||
|
||||
if(default_deconstruction_crowbar(user, I))
|
||||
return
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/turbine/interact(mob/user)
|
||||
|
||||
if( !Adjacent(user) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon)) )
|
||||
user.unset_machine(src)
|
||||
user << browse(null, "window=turbine")
|
||||
return
|
||||
|
||||
var/t = "<TT><B>Gas Turbine Generator</B><HR><PRE>"
|
||||
|
||||
t += "Generated power : [round(lastgen)] W<BR><BR>"
|
||||
|
||||
t += "Turbine: [round(compressor.rpm)] RPM<BR>"
|
||||
|
||||
t += "Starter: [ compressor.starter ? "<A href='?src=[UID()];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=[UID()];str=1'>On</A>"]"
|
||||
|
||||
t += "</PRE><HR><A href='?src=[UID()];close=1'>Close</A>"
|
||||
|
||||
t += "</TT>"
|
||||
var/datum/browser/popup = new(user, "turbine", name)
|
||||
popup.set_content(t)
|
||||
popup.open()
|
||||
|
||||
return
|
||||
|
||||
/obj/machinery/power/turbine/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=turbine")
|
||||
usr.unset_machine(src)
|
||||
return
|
||||
|
||||
else if( href_list["str"] )
|
||||
if(compressor)
|
||||
compressor.starter = !compressor.starter
|
||||
|
||||
updateDialog()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// COMPUTER NEEDS A SERIOUS REWRITE.
|
||||
|
||||
|
||||
|
||||
/obj/machinery/computer/turbine_computer/Initialize()
|
||||
..()
|
||||
spawn(10)
|
||||
locate_machinery()
|
||||
|
||||
/obj/machinery/computer/turbine_computer/locate_machinery()
|
||||
compressor = locate(/obj/machinery/power/compressor) in range(5, src)
|
||||
|
||||
/obj/machinery/computer/turbine_computer/attack_hand(var/mob/user as mob)
|
||||
if(..())
|
||||
return
|
||||
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/computer/turbine_computer/interact(mob/user)
|
||||
|
||||
var/dat
|
||||
if(compressor && compressor.turbine)
|
||||
dat += "<BR><B>Gas turbine remote control system</B><HR>"
|
||||
if(compressor.stat || compressor.turbine.stat)
|
||||
dat += "[compressor.stat ? "<B>Compressor is inoperable</B><BR>" : "<B>Turbine is inoperable</B>"]"
|
||||
else
|
||||
dat += {"Turbine status: [ src.compressor.starter ? "<A href='?src=[UID()];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=[UID()];str=1'>On</A>"]
|
||||
\n<BR>
|
||||
\nTurbine speed: [src.compressor.rpm]rpm<BR>
|
||||
\nPower currently being generated: [src.compressor.turbine.lastgen]W<BR>
|
||||
\nInternal gas temperature: [src.compressor.gas_contained.temperature]K<BR>
|
||||
\n</PRE><HR><A href='?src=[UID()];close=1'>Close</A>
|
||||
\n<BR>
|
||||
\n"}
|
||||
else
|
||||
dat += "<B>There is [!compressor ? "no compressor" : " compressor[!compressor.turbine ? " but no turbine" : ""]"].</B><BR>"
|
||||
if(!compressor)
|
||||
dat += "<A href='?src=[UID()];search=1'>Search for compressor</A>"
|
||||
|
||||
var/datum/browser/popup = new(user, "turbinecomputer", name)
|
||||
popup.set_content(dat)
|
||||
popup.open()
|
||||
return
|
||||
|
||||
/obj/machinery/computer/turbine_computer/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
else if( href_list["str"] )
|
||||
if(compressor && compressor.turbine)
|
||||
compressor.starter = !compressor.starter
|
||||
else if( href_list["close"] )
|
||||
usr << browse(null, "window=turbinecomputer")
|
||||
usr.unset_machine(src)
|
||||
return
|
||||
else if(href_list["search"])
|
||||
locate_machinery()
|
||||
|
||||
src.updateUsrDialog()
|
||||
return
|
||||
|
||||
/obj/machinery/computer/turbine_computer/process()
|
||||
src.updateDialog()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user