- Standardized the code in code/modules/research

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4243 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
baloh.matevz
2012-07-31 06:01:55 +00:00
parent a3d9123edd
commit e6f7615342
8 changed files with 2959 additions and 2957 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -13,91 +13,91 @@ Note: Must be placed within 3 tiles of the R&D Console
var/obj/item/weapon/loaded_item = null var/obj/item/weapon/loaded_item = null
var/decon_mod = 1 var/decon_mod = 1
New() /obj/machinery/r_n_d/destructive_analyzer/New()
..() ..()
component_parts = list() component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/destructive_analyzer(src) component_parts += new /obj/item/weapon/circuitboard/destructive_analyzer(src)
component_parts += new /obj/item/weapon/stock_parts/scanning_module(src) component_parts += new /obj/item/weapon/stock_parts/scanning_module(src)
component_parts += new /obj/item/weapon/stock_parts/manipulator(src) component_parts += new /obj/item/weapon/stock_parts/manipulator(src)
component_parts += new /obj/item/weapon/stock_parts/micro_laser(src) component_parts += new /obj/item/weapon/stock_parts/micro_laser(src)
RefreshParts()
RefreshParts() RefreshParts()
var/T = 0
for(var/obj/item/weapon/stock_parts/S in src)
T += S.rating * 0.1
T = between (0, T, 1)
decon_mod = T
meteorhit() /obj/machinery/r_n_d/destructive_analyzer/RefreshParts()
del(src) var/T = 0
for(var/obj/item/weapon/stock_parts/S in src)
T += S.rating * 0.1
T = between (0, T, 1)
decon_mod = T
/obj/machinery/r_n_d/destructive_analyzer/meteorhit()
del(src)
return
/obj/machinery/r_n_d/destructive_analyzer/proc/ConvertReqString2List(var/list/source_list)
var/list/temp_list = params2list(source_list)
for(var/O in temp_list)
temp_list[O] = text2num(temp_list[O])
return temp_list
/obj/machinery/r_n_d/destructive_analyzer/attackby(var/obj/O as obj, var/mob/user as mob)
if (shocked)
shock(user,50)
if (istype(O, /obj/item/weapon/screwdriver))
if (!opened)
opened = 1
if(linked_console)
linked_console.linked_destroy = null
linked_console = null
icon_state = "d_analyzer_t"
user << "You open the maintenance hatch of [src]."
else
opened = 0
icon_state = "d_analyzer"
user << "You close the maintenance hatch of [src]."
return return
if (opened)
proc/ConvertReqString2List(var/list/source_list) if(istype(O, /obj/item/weapon/crowbar))
var/list/temp_list = params2list(source_list) playsound(src.loc, 'Crowbar.ogg', 50, 1)
for(var/O in temp_list) var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
temp_list[O] = text2num(temp_list[O]) M.state = 2
return temp_list M.icon_state = "box_1"
for(var/obj/I in component_parts)
I.loc = src.loc
attackby(var/obj/O as obj, var/mob/user as mob) del(src)
if (shocked) return 1
shock(user,50) else
if (istype(O, /obj/item/weapon/screwdriver)) user << "\red You can't load the [src.name] while it's opened."
if (!opened) return 1
opened = 1 if (disabled)
if(linked_console)
linked_console.linked_destroy = null
linked_console = null
icon_state = "d_analyzer_t"
user << "You open the maintenance hatch of [src]."
else
opened = 0
icon_state = "d_analyzer"
user << "You close the maintenance hatch of [src]."
return
if (opened)
if(istype(O, /obj/item/weapon/crowbar))
playsound(src.loc, 'Crowbar.ogg', 50, 1)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 2
M.icon_state = "box_1"
for(var/obj/I in component_parts)
I.loc = src.loc
del(src)
return 1
else
user << "\red You can't load the [src.name] while it's opened."
return 1
if (disabled)
return
if (!linked_console)
user << "\red The protolathe must be linked to an R&D console first!"
return
if (busy)
user << "\red The protolathe is busy right now."
return
if (istype(O, /obj/item) && !loaded_item)
if(!O.origin_tech)
user << "\red This doesn't seem to have a tech origin!"
return
var/list/temp_tech = ConvertReqString2List(O.origin_tech)
if (temp_tech.len == 0)
user << "\red You cannot deconstruct this item!"
return
if(O.reliability < 90 && O.crit_fail == 0)
usr << "\red Item is neither reliable enough or broken enough to learn from."
return
busy = 1
loaded_item = O
user.drop_item()
O.loc = src
user << "\blue You add the [O.name] to the machine!"
flick("d_analyzer_la", src)
spawn(10)
icon_state = "d_analyzer_l"
busy = 0
return return
if (!linked_console)
user << "\red The protolathe must be linked to an R&D console first!"
return
if (busy)
user << "\red The protolathe is busy right now."
return
if (istype(O, /obj/item) && !loaded_item)
if(!O.origin_tech)
user << "\red This doesn't seem to have a tech origin!"
return
var/list/temp_tech = ConvertReqString2List(O.origin_tech)
if (temp_tech.len == 0)
user << "\red You cannot deconstruct this item!"
return
if(O.reliability < 90 && O.crit_fail == 0)
usr << "\red Item is neither reliable enough or broken enough to learn from."
return
busy = 1
loaded_item = O
user.drop_item()
O.loc = src
user << "\blue You add the [O.name] to the machine!"
flick("d_analyzer_la", src)
spawn(10)
icon_state = "d_analyzer_l"
busy = 0
return
//For testing purposes only. //For testing purposes only.
/*/obj/item/weapon/deconstruction_test /*/obj/item/weapon/deconstruction_test

View File

@@ -118,56 +118,56 @@ var/global/list/obj/machinery/message_server/message_servers = list()
var/value var/value
var/details var/details
New(var/param_variable,var/param_value = 0) /datum/feedback_variable/New(var/param_variable,var/param_value = 0)
variable = param_variable variable = param_variable
value = param_value value = param_value
proc/inc(var/num = 1) /datum/feedback_variable/proc/inc(var/num = 1)
if(isnum(value))
value += num
else
value = text2num(value)
if(isnum(value)) if(isnum(value))
value += num value += num
else else
value = text2num(value) value = num
if(isnum(value))
value += num
else
value = num
proc/dec(var/num = 1) /datum/feedback_variable/proc/dec(var/num = 1)
if(isnum(value))
value -= num
else
value = text2num(value)
if(isnum(value)) if(isnum(value))
value -= num value -= num
else else
value = text2num(value) value = -num
if(isnum(value))
value -= num
else
value = -num
proc/set_value(var/num) /datum/feedback_variable/proc/set_value(var/num)
if(isnum(num)) if(isnum(num))
value = num value = num
proc/get_value() /datum/feedback_variable/proc/get_value()
return value return value
proc/get_variable() /datum/feedback_variable/proc/get_variable()
return variable return variable
proc/set_details(var/text) /datum/feedback_variable/proc/set_details(var/text)
if(istext(text)) if(istext(text))
details = text
/datum/feedback_variable/proc/add_details(var/text)
if(istext(text))
if(!details)
details = text details = text
else
details += " [text]"
proc/add_details(var/text) /datum/feedback_variable/proc/get_details()
if(istext(text)) return details
if(!details)
details = text
else
details += " [text]"
proc/get_details() /datum/feedback_variable/proc/get_parsed()
return details return list(variable,value,details)
proc/get_parsed()
return list(variable,value,details)
var/obj/machinery/blackbox_recorder/blackbox var/obj/machinery/blackbox_recorder/blackbox
@@ -197,109 +197,109 @@ var/obj/machinery/blackbox_recorder/blackbox
var/list/datum/feedback_variable/feedback = new() var/list/datum/feedback_variable/feedback = new()
//Only one can exsist in the world! //Only one can exsist in the world!
New() /obj/machinery/blackbox_recorder/New()
if(blackbox) if(blackbox)
if(istype(blackbox,/obj/machinery/blackbox_recorder)) if(istype(blackbox,/obj/machinery/blackbox_recorder))
del(src) del(src)
blackbox = src blackbox = src
Del() /obj/machinery/blackbox_recorder/Del()
var/turf/T = locate(1,1,2) var/turf/T = locate(1,1,2)
if(T) if(T)
blackbox = null blackbox = null
var/obj/machinery/blackbox_recorder/BR = new/obj/machinery/blackbox_recorder(T) var/obj/machinery/blackbox_recorder/BR = new/obj/machinery/blackbox_recorder(T)
BR.msg_common = msg_common BR.msg_common = msg_common
BR.msg_science = msg_science BR.msg_science = msg_science
BR.msg_command = msg_command BR.msg_command = msg_command
BR.msg_medical = msg_medical BR.msg_medical = msg_medical
BR.msg_engineering = msg_engineering BR.msg_engineering = msg_engineering
BR.msg_security = msg_security BR.msg_security = msg_security
BR.msg_deathsquad = msg_deathsquad BR.msg_deathsquad = msg_deathsquad
BR.msg_syndicate = msg_syndicate BR.msg_syndicate = msg_syndicate
BR.msg_mining = msg_mining BR.msg_mining = msg_mining
BR.msg_cargo = msg_cargo BR.msg_cargo = msg_cargo
BR.feedback = feedback BR.feedback = feedback
BR.messages = messages BR.messages = messages
BR.messages_admin = messages_admin BR.messages_admin = messages_admin
if(blackbox != BR) if(blackbox != BR)
blackbox = BR blackbox = BR
..() ..()
proc/find_feedback_datum(var/variable) /obj/machinery/blackbox_recorder/proc/find_feedback_datum(var/variable)
for(var/datum/feedback_variable/FV in feedback) for(var/datum/feedback_variable/FV in feedback)
if(FV.get_variable() == variable) if(FV.get_variable() == variable)
return FV return FV
var/datum/feedback_variable/FV = new(variable) var/datum/feedback_variable/FV = new(variable)
feedback += FV feedback += FV
return FV return FV
proc/get_round_feedback() /obj/machinery/blackbox_recorder/proc/get_round_feedback()
return feedback return feedback
proc/round_end_data_gathering() /obj/machinery/blackbox_recorder/proc/round_end_data_gathering()
var/pda_msg_amt = 0 var/pda_msg_amt = 0
var/rc_msg_amt = 0 var/rc_msg_amt = 0
for(var/obj/machinery/message_server/MS in world) for(var/obj/machinery/message_server/MS in world)
if(MS.pda_msgs.len > pda_msg_amt) if(MS.pda_msgs.len > pda_msg_amt)
pda_msg_amt = MS.pda_msgs.len pda_msg_amt = MS.pda_msgs.len
if(MS.rc_msgs.len > rc_msg_amt) if(MS.rc_msgs.len > rc_msg_amt)
rc_msg_amt = MS.rc_msgs.len rc_msg_amt = MS.rc_msgs.len
feedback_set_details("radio_usage","") feedback_set_details("radio_usage","")
feedback_add_details("radio_usage","COM-[msg_common.len]") feedback_add_details("radio_usage","COM-[msg_common.len]")
feedback_add_details("radio_usage","SCI-[msg_science.len]") feedback_add_details("radio_usage","SCI-[msg_science.len]")
feedback_add_details("radio_usage","HEA-[msg_command.len]") feedback_add_details("radio_usage","HEA-[msg_command.len]")
feedback_add_details("radio_usage","MED-[msg_medical.len]") feedback_add_details("radio_usage","MED-[msg_medical.len]")
feedback_add_details("radio_usage","ENG-[msg_engineering.len]") feedback_add_details("radio_usage","ENG-[msg_engineering.len]")
feedback_add_details("radio_usage","SEC-[msg_security.len]") feedback_add_details("radio_usage","SEC-[msg_security.len]")
feedback_add_details("radio_usage","DTH-[msg_deathsquad.len]") feedback_add_details("radio_usage","DTH-[msg_deathsquad.len]")
feedback_add_details("radio_usage","SYN-[msg_syndicate.len]") feedback_add_details("radio_usage","SYN-[msg_syndicate.len]")
feedback_add_details("radio_usage","MIN-[msg_mining.len]") feedback_add_details("radio_usage","MIN-[msg_mining.len]")
feedback_add_details("radio_usage","CAR-[msg_cargo.len]") feedback_add_details("radio_usage","CAR-[msg_cargo.len]")
feedback_add_details("radio_usage","OTH-[messages.len]") feedback_add_details("radio_usage","OTH-[messages.len]")
feedback_add_details("radio_usage","PDA-[pda_msg_amt]") feedback_add_details("radio_usage","PDA-[pda_msg_amt]")
feedback_add_details("radio_usage","RC-[rc_msg_amt]") feedback_add_details("radio_usage","RC-[rc_msg_amt]")
feedback_set_details("round_end","[time2text(world.realtime)]") //This one MUST be the last one that gets set. feedback_set_details("round_end","[time2text(world.realtime)]") //This one MUST be the last one that gets set.
//This proc is only to be called at round end. //This proc is only to be called at round end.
proc/save_all_data_to_sql() /obj/machinery/blackbox_recorder/proc/save_all_data_to_sql()
if(!feedback) return if(!feedback) return
round_end_data_gathering() //round_end time logging and some other data processing round_end_data_gathering() //round_end time logging and some other data processing
var/user = sqlfdbklogin var/user = sqlfdbklogin
var/pass = sqlfdbkpass var/pass = sqlfdbkpass
var/db = sqlfdbkdb var/db = sqlfdbkdb
var/address = sqladdress var/address = sqladdress
var/port = sqlport var/port = sqlport
var/DBConnection/dbcon = new() var/DBConnection/dbcon = new()
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]") dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
if(!dbcon.IsConnected()) return if(!dbcon.IsConnected()) return
var/round_id var/round_id
var/DBQuery/query = dbcon.NewQuery("SELECT MAX(round_id) AS round_id FROM erro_feedback") var/DBQuery/query = dbcon.NewQuery("SELECT MAX(round_id) AS round_id FROM erro_feedback")
query.Execute() query.Execute()
while(query.NextRow()) while(query.NextRow())
round_id = query.item[1] round_id = query.item[1]
if(!isnum(round_id)) if(!isnum(round_id))
round_id = text2num(round_id) round_id = text2num(round_id)
round_id++ round_id++
for(var/datum/feedback_variable/FV in feedback) for(var/datum/feedback_variable/FV in feedback)
var/sql = "INSERT INTO erro_feedback VALUES (null, Now(), [round_id], \"[FV.get_variable()]\", [FV.get_value()], \"[FV.get_details()]\")" var/sql = "INSERT INTO erro_feedback VALUES (null, Now(), [round_id], \"[FV.get_variable()]\", [FV.get_value()], \"[FV.get_details()]\")"
var/DBQuery/query_insert = dbcon.NewQuery(sql) var/DBQuery/query_insert = dbcon.NewQuery(sql)
query_insert.Execute() query_insert.Execute()
dbcon.Disconnect() dbcon.Disconnect()
// Sanitize inputs to avoid SQL injection attacks // Sanitize inputs to avoid SQL injection attacks
proc/sql_sanitize_text(var/text) proc/sql_sanitize_text(var/text)

View File

@@ -24,154 +24,154 @@ Note: Must be placed west/left of and R&D console to function.
var/adamantine_amount = 0.0 var/adamantine_amount = 0.0
New() /obj/machinery/r_n_d/protolathe/New()
..() ..()
component_parts = list() component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/protolathe(src) component_parts += new /obj/item/weapon/circuitboard/protolathe(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/manipulator(src) component_parts += new /obj/item/weapon/stock_parts/manipulator(src)
component_parts += new /obj/item/weapon/stock_parts/manipulator(src) component_parts += new /obj/item/weapon/stock_parts/manipulator(src)
component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(src) component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(src)
component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(src) component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(src)
RefreshParts()
proc/TotalMaterials() //returns the total of all the stored materials. Makes code neater.
return m_amount + g_amount + gold_amount + silver_amount + plasma_amount + uranium_amount + diamond_amount + clown_amount
RefreshParts() RefreshParts()
var/T = 0
for(var/obj/item/weapon/reagent_containers/glass/G in component_parts)
T += G.reagents.maximum_volume
var/datum/reagents/R = new/datum/reagents(T) //Holder for the reagents used as materials.
reagents = R
R.my_atom = src
T = 0
for(var/obj/item/weapon/stock_parts/matter_bin/M in component_parts)
T += M.rating
max_material_storage = T * 75000
attackby(var/obj/item/O as obj, var/mob/user as mob) /obj/machinery/r_n_d/protolathe/proc/TotalMaterials() //returns the total of all the stored materials. Makes code neater.
if (shocked) return m_amount + g_amount + gold_amount + silver_amount + plasma_amount + uranium_amount + diamond_amount + clown_amount
shock(user,50)
if (O.is_open_container())
return 1
if (istype(O, /obj/item/weapon/screwdriver))
if (!opened)
opened = 1
if(linked_console)
linked_console.linked_lathe = null
linked_console = null
icon_state = "protolathe_t"
user << "You open the maintenance hatch of [src]."
else
opened = 0
icon_state = "protolathe"
user << "You close the maintenance hatch of [src]."
return
if (opened)
if(istype(O, /obj/item/weapon/crowbar))
playsound(src.loc, 'Crowbar.ogg', 50, 1)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 2
M.icon_state = "box_1"
for(var/obj/I in component_parts)
if(istype(I, /obj/item/weapon/reagent_containers/glass/beaker))
reagents.trans_to(I, reagents.total_volume)
if(I.reliability != 100 && crit_fail)
I.crit_fail = 1
I.loc = src.loc
if(m_amount >= 3750)
var/obj/item/stack/sheet/metal/G = new /obj/item/stack/sheet/metal(src.loc)
G.amount = round(m_amount / G.perunit)
if(g_amount >= 3750)
var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(src.loc)
G.amount = round(g_amount / G.perunit)
if(plasma_amount >= 2000)
var/obj/item/stack/sheet/plasma/G = new /obj/item/stack/sheet/plasma(src.loc)
G.amount = round(plasma_amount / G.perunit)
if(silver_amount >= 2000)
var/obj/item/stack/sheet/silver/G = new /obj/item/stack/sheet/silver(src.loc)
G.amount = round(silver_amount / G.perunit)
if(gold_amount >= 2000)
var/obj/item/stack/sheet/gold/G = new /obj/item/stack/sheet/gold(src.loc)
G.amount = round(gold_amount / G.perunit)
if(uranium_amount >= 2000)
var/obj/item/stack/sheet/uranium/G = new /obj/item/stack/sheet/uranium(src.loc)
G.amount = round(uranium_amount / G.perunit)
if(diamond_amount >= 2000)
var/obj/item/stack/sheet/diamond/G = new /obj/item/stack/sheet/diamond(src.loc)
G.amount = round(diamond_amount / G.perunit)
if(clown_amount >= 2000)
var/obj/item/stack/sheet/clown/G = new /obj/item/stack/sheet/clown(src.loc)
G.amount = round(clown_amount / G.perunit)
if(adamantine_amount >= 2000)
var/obj/item/stack/sheet/adamantine/G = new /obj/item/stack/sheet/adamantine(src.loc)
G.amount = round(adamantine_amount / G.perunit)
del(src)
return 1
else
user << "\red You can't load the [src.name] while it's opened."
return 1
if (disabled)
return
if (!linked_console)
user << "\The protolathe must be linked to an R&D console first!"
return 1
if (busy)
user << "\red The protolathe is busy. Please wait for completion of previous operation."
return 1
if (!istype(O, /obj/item/stack/sheet))
user << "\red You cannot insert this item into the protolathe!"
return 1
if (stat)
return 1
if(istype(O,/obj/item/stack/sheet))
var/obj/item/stack/sheet/S = O
if (TotalMaterials() + S.perunit > max_material_storage)
user << "\red The protolathe's material bin is full. Please remove material before adding more."
return 1
var/obj/item/stack/sheet/stack = O /obj/machinery/r_n_d/protolathe/RefreshParts()
var/amount = round(input("How many sheets do you want to add?") as num)//No decimals var/T = 0
if(amount < 0)//No negative numbers for(var/obj/item/weapon/reagent_containers/glass/G in component_parts)
amount = 0 T += G.reagents.maximum_volume
if(amount == 0) var/datum/reagents/R = new/datum/reagents(T) //Holder for the reagents used as materials.
return reagents = R
if(amount > stack.amount) R.my_atom = src
amount = stack.amount T = 0
if(max_material_storage - TotalMaterials() < (amount*stack.perunit))//Can't overfill for(var/obj/item/weapon/stock_parts/matter_bin/M in component_parts)
amount = min(stack.amount, round((max_material_storage-TotalMaterials())/stack.perunit)) T += M.rating
max_material_storage = T * 75000
src.overlays += "protolathe_[stack.name]" /obj/machinery/r_n_d/protolathe/attackby(var/obj/item/O as obj, var/mob/user as mob)
sleep(10) if (shocked)
src.overlays -= "protolathe_[stack.name]" shock(user,50)
if (O.is_open_container())
icon_state = "protolathe" return 1
busy = 1 if (istype(O, /obj/item/weapon/screwdriver))
use_power(max(1000, (3750*amount/10))) if (!opened)
spawn(16) opened = 1
user << "\blue You add [amount] sheets to the [src.name]." if(linked_console)
linked_console.linked_lathe = null
linked_console = null
icon_state = "protolathe_t"
user << "You open the maintenance hatch of [src]."
else
opened = 0
icon_state = "protolathe" icon_state = "protolathe"
if(istype(stack, /obj/item/stack/sheet/metal)) user << "You close the maintenance hatch of [src]."
m_amount += amount * 3750 return
else if(istype(stack, /obj/item/stack/sheet/glass)) if (opened)
g_amount += amount * 3750 if(istype(O, /obj/item/weapon/crowbar))
else if(istype(stack, /obj/item/stack/sheet/gold)) playsound(src.loc, 'Crowbar.ogg', 50, 1)
gold_amount += amount * 2000 var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
else if(istype(stack, /obj/item/stack/sheet/silver)) M.state = 2
silver_amount += amount * 2000 M.icon_state = "box_1"
else if(istype(stack, /obj/item/stack/sheet/plasma)) for(var/obj/I in component_parts)
plasma_amount += amount * 2000 if(istype(I, /obj/item/weapon/reagent_containers/glass/beaker))
else if(istype(stack, /obj/item/stack/sheet/uranium)) reagents.trans_to(I, reagents.total_volume)
uranium_amount += amount * 2000 if(I.reliability != 100 && crit_fail)
else if(istype(stack, /obj/item/stack/sheet/diamond)) I.crit_fail = 1
diamond_amount += amount * 2000 I.loc = src.loc
else if(istype(stack, /obj/item/stack/sheet/clown)) if(m_amount >= 3750)
clown_amount += amount * 2000 var/obj/item/stack/sheet/metal/G = new /obj/item/stack/sheet/metal(src.loc)
else if(istype(stack, /obj/item/stack/sheet/adamantine)) G.amount = round(m_amount / G.perunit)
adamantine_amount += amount * 2000 if(g_amount >= 3750)
stack.use(amount) var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(src.loc)
busy = 0 G.amount = round(g_amount / G.perunit)
src.updateUsrDialog() if(plasma_amount >= 2000)
return var/obj/item/stack/sheet/plasma/G = new /obj/item/stack/sheet/plasma(src.loc)
G.amount = round(plasma_amount / G.perunit)
if(silver_amount >= 2000)
var/obj/item/stack/sheet/silver/G = new /obj/item/stack/sheet/silver(src.loc)
G.amount = round(silver_amount / G.perunit)
if(gold_amount >= 2000)
var/obj/item/stack/sheet/gold/G = new /obj/item/stack/sheet/gold(src.loc)
G.amount = round(gold_amount / G.perunit)
if(uranium_amount >= 2000)
var/obj/item/stack/sheet/uranium/G = new /obj/item/stack/sheet/uranium(src.loc)
G.amount = round(uranium_amount / G.perunit)
if(diamond_amount >= 2000)
var/obj/item/stack/sheet/diamond/G = new /obj/item/stack/sheet/diamond(src.loc)
G.amount = round(diamond_amount / G.perunit)
if(clown_amount >= 2000)
var/obj/item/stack/sheet/clown/G = new /obj/item/stack/sheet/clown(src.loc)
G.amount = round(clown_amount / G.perunit)
if(adamantine_amount >= 2000)
var/obj/item/stack/sheet/adamantine/G = new /obj/item/stack/sheet/adamantine(src.loc)
G.amount = round(adamantine_amount / G.perunit)
del(src)
return 1
else
user << "\red You can't load the [src.name] while it's opened."
return 1
if (disabled)
return
if (!linked_console)
user << "\The protolathe must be linked to an R&D console first!"
return 1
if (busy)
user << "\red The protolathe is busy. Please wait for completion of previous operation."
return 1
if (!istype(O, /obj/item/stack/sheet))
user << "\red You cannot insert this item into the protolathe!"
return 1
if (stat)
return 1
if(istype(O,/obj/item/stack/sheet))
var/obj/item/stack/sheet/S = O
if (TotalMaterials() + S.perunit > max_material_storage)
user << "\red The protolathe's material bin is full. Please remove material before adding more."
return 1
var/obj/item/stack/sheet/stack = O
var/amount = round(input("How many sheets do you want to add?") as num)//No decimals
if(amount < 0)//No negative numbers
amount = 0
if(amount == 0)
return
if(amount > stack.amount)
amount = stack.amount
if(max_material_storage - TotalMaterials() < (amount*stack.perunit))//Can't overfill
amount = min(stack.amount, round((max_material_storage-TotalMaterials())/stack.perunit))
src.overlays += "protolathe_[stack.name]"
sleep(10)
src.overlays -= "protolathe_[stack.name]"
icon_state = "protolathe"
busy = 1
use_power(max(1000, (3750*amount/10)))
spawn(16)
user << "\blue You add [amount] sheets to the [src.name]."
icon_state = "protolathe"
if(istype(stack, /obj/item/stack/sheet/metal))
m_amount += amount * 3750
else if(istype(stack, /obj/item/stack/sheet/glass))
g_amount += amount * 3750
else if(istype(stack, /obj/item/stack/sheet/gold))
gold_amount += amount * 2000
else if(istype(stack, /obj/item/stack/sheet/silver))
silver_amount += amount * 2000
else if(istype(stack, /obj/item/stack/sheet/plasma))
plasma_amount += amount * 2000
else if(istype(stack, /obj/item/stack/sheet/uranium))
uranium_amount += amount * 2000
else if(istype(stack, /obj/item/stack/sheet/diamond))
diamond_amount += amount * 2000
else if(istype(stack, /obj/item/stack/sheet/clown))
clown_amount += amount * 2000
else if(istype(stack, /obj/item/stack/sheet/adamantine))
adamantine_amount += amount * 2000
stack.use(amount)
busy = 0
src.updateUsrDialog()
return

File diff suppressed because it is too large Load Diff

View File

@@ -20,88 +20,88 @@
var/opened = 0 var/opened = 0
var/obj/machinery/computer/rdconsole/linked_console var/obj/machinery/computer/rdconsole/linked_console
New() /obj/machinery/r_n_d/New()
..() ..()
wires["Red"] = 0 wires["Red"] = 0
wires["Blue"] = 0 wires["Blue"] = 0
wires["Green"] = 0 wires["Green"] = 0
wires["Yellow"] = 0 wires["Yellow"] = 0
wires["Black"] = 0 wires["Black"] = 0
wires["White"] = 0 wires["White"] = 0
var/list/w = list("Red","Blue","Green","Yellow","Black","White") var/list/w = list("Red","Blue","Green","Yellow","Black","White")
src.hack_wire = pick(w) src.hack_wire = pick(w)
w -= src.hack_wire w -= src.hack_wire
src.shock_wire = pick(w) src.shock_wire = pick(w)
w -= src.shock_wire w -= src.shock_wire
src.disable_wire = pick(w) src.disable_wire = pick(w)
w -= src.disable_wire w -= src.disable_wire
proc /obj/machinery/r_n_d/proc/
shock(mob/user, prb) shock(mob/user, prb)
if(stat & (BROKEN|NOPOWER)) // unpowered, no shock if(stat & (BROKEN|NOPOWER)) // unpowered, no shock
return 0 return 0
if(!prob(prb)) if(!prob(prb))
return 0 return 0
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src) s.set_up(5, 1, src)
s.start() s.start()
if (electrocute_mob(user, get_area(src), src, 0.7)) if (electrocute_mob(user, get_area(src), src, 0.7))
return 1 return 1
else else
return 0 return 0
attack_hand(mob/user as mob) /obj/machinery/r_n_d/attack_hand(mob/user as mob)
if (shocked) if (shocked)
shock(user,50) shock(user,50)
if(opened) if(opened)
var/dat as text var/dat as text
dat += "[src.name] Wires:<BR>" dat += "[src.name] Wires:<BR>"
for(var/wire in src.wires) for(var/wire in src.wires)
dat += text("[wire] Wire: <A href='?src=\ref[src];wire=[wire];cut=1'>[src.wires[wire] ? "Mend" : "Cut"]</A> <A href='?src=\ref[src];wire=[wire];pulse=1'>Pulse</A><BR>") dat += text("[wire] Wire: <A href='?src=\ref[src];wire=[wire];cut=1'>[src.wires[wire] ? "Mend" : "Cut"]</A> <A href='?src=\ref[src];wire=[wire];pulse=1'>Pulse</A><BR>")
dat += text("The red light is [src.disabled ? "off" : "on"].<BR>") dat += text("The red light is [src.disabled ? "off" : "on"].<BR>")
dat += text("The green light is [src.shocked ? "off" : "on"].<BR>") dat += text("The green light is [src.shocked ? "off" : "on"].<BR>")
dat += text("The blue light is [src.hacked ? "off" : "on"].<BR>") dat += text("The blue light is [src.hacked ? "off" : "on"].<BR>")
user << browse("<HTML><HEAD><TITLE>[src.name] Hacking</TITLE></HEAD><BODY>[dat]</BODY></HTML>","window=hack_win") user << browse("<HTML><HEAD><TITLE>[src.name] Hacking</TITLE></HEAD><BODY>[dat]</BODY></HTML>","window=hack_win")
return
/obj/machinery/r_n_d/Topic(href, href_list)
if(..())
return return
usr.machine = src
src.add_fingerprint(usr)
Topic(href, href_list) if(href_list["pulse"])
if(..()) var/temp_wire = href_list["wire"]
return if (!istype(usr.get_active_hand(), /obj/item/device/multitool))
usr.machine = src usr << "You need a multitool!"
src.add_fingerprint(usr) else
if(href_list["pulse"]) if(src.wires[temp_wire])
var/temp_wire = href_list["wire"] usr << "You can't pulse a cut wire."
if (!istype(usr.get_active_hand(), /obj/item/device/multitool))
usr << "You need a multitool!"
else else
if(src.wires[temp_wire]) if(src.hack_wire == href_list["wire"])
usr << "You can't pulse a cut wire."
else
if(src.hack_wire == href_list["wire"])
src.hacked = !src.hacked
spawn(100) src.hacked = !src.hacked
if(src.disable_wire == href_list["wire"])
src.disabled = !src.disabled
src.shock(usr,50)
spawn(100) src.disabled = !src.disabled
if(src.shock_wire == href_list["wire"])
src.shocked = !src.shocked
src.shock(usr,50)
spawn(100) src.shocked = !src.shocked
if(href_list["cut"])
if (!istype(usr.get_active_hand(), /obj/item/weapon/wirecutters))
usr << "You need wirecutters!"
else
var/temp_wire = href_list["wire"]
wires[temp_wire] = !wires[temp_wire]
if(src.hack_wire == temp_wire)
src.hacked = !src.hacked src.hacked = !src.hacked
if(src.disable_wire == temp_wire) spawn(100) src.hacked = !src.hacked
if(src.disable_wire == href_list["wire"])
src.disabled = !src.disabled src.disabled = !src.disabled
src.shock(usr,50) src.shock(usr,50)
if(src.shock_wire == temp_wire) spawn(100) src.disabled = !src.disabled
if(src.shock_wire == href_list["wire"])
src.shocked = !src.shocked src.shocked = !src.shocked
src.shock(usr,50) src.shock(usr,50)
src.updateUsrDialog() spawn(100) src.shocked = !src.shocked
if(href_list["cut"])
if (!istype(usr.get_active_hand(), /obj/item/weapon/wirecutters))
usr << "You need wirecutters!"
else
var/temp_wire = href_list["wire"]
wires[temp_wire] = !wires[temp_wire]
if(src.hack_wire == temp_wire)
src.hacked = !src.hacked
if(src.disable_wire == temp_wire)
src.disabled = !src.disabled
src.shock(usr,50)
if(src.shock_wire == temp_wire)
src.shocked = !src.shocked
src.shock(usr,50)
src.updateUsrDialog()

View File

@@ -45,120 +45,120 @@ research holder datum.
***************************************************************/ ***************************************************************/
/datum/research //Holder for all the existing, archived, and known tech. Individual to console. /datum/research //Holder for all the existing, archived, and known tech. Individual to console.
var
list //Datum/tech go here.
possible_tech = list() //List of all tech in the game that players have access to (barring special events).
known_tech = list() //List of locally known tech.
possible_designs = list() //List of all designs (at base reliability).
known_designs = list() //List of available designs (at base reliability).
New() //Insert techs into possible_tech here. Known_tech automatically updated. //Datum/tech go here.
for(var/T in typesof(/datum/tech) - /datum/tech) var/list/possible_tech = list() //List of all tech in the game that players have access to (barring special events).
possible_tech += new T(src) var/list/known_tech = list() //List of locally known tech.
for(var/D in typesof(/datum/design) - /datum/design) var/list/possible_designs = list() //List of all designs (at base reliability).
possible_designs += new D(src) var/list/known_designs = list() //List of available designs (at base reliability).
RefreshResearch()
proc /datum/research/New() //Insert techs into possible_tech here. Known_tech automatically updated.
for(var/T in typesof(/datum/tech) - /datum/tech)
possible_tech += new T(src)
for(var/D in typesof(/datum/design) - /datum/design)
possible_designs += new D(src)
RefreshResearch()
//Checks to see if tech has all the required pre-reqs.
//Input: datum/tech; Output: 0/1 (false/true)
TechHasReqs(var/datum/tech/T)
if(T.req_tech.len == 0)
return 1
var/matches = 0
for(var/req in T.req_tech)
for(var/datum/tech/known in known_tech)
if((req == known.id) && (known.level >= T.req_tech[req]))
matches++
break
if(matches == T.req_tech.len)
return 1
else
return 0
//Checks to see if design has all the required pre-reqs.
//Input: datum/design; Output: 0/1 (false/true) //Checks to see if tech has all the required pre-reqs.
DesignHasReqs(var/datum/design/D) //Input: datum/tech; Output: 0/1 (false/true)
if(D.req_tech.len == 0) /datum/research/proc/TechHasReqs(var/datum/tech/T)
return 1 if(T.req_tech.len == 0)
var/matches = 0 return 1
var/list/k_tech = list() var/matches = 0
for(var/datum/tech/known in known_tech) for(var/req in T.req_tech)
k_tech[known.id] = known.level for(var/datum/tech/known in known_tech)
for(var/req in D.req_tech) if((req == known.id) && (known.level >= T.req_tech[req]))
if(!isnull(k_tech[req]) && k_tech[req] >= D.req_tech[req]) matches++
matches++ break
if(matches == D.req_tech.len) if(matches == T.req_tech.len)
return 1 return 1
else else
return 0 return 0
//Checks to see if design has all the required pre-reqs.
//Input: datum/design; Output: 0/1 (false/true)
/datum/research/proc/DesignHasReqs(var/datum/design/D)
if(D.req_tech.len == 0)
return 1
var/matches = 0
var/list/k_tech = list()
for(var/datum/tech/known in known_tech)
k_tech[known.id] = known.level
for(var/req in D.req_tech)
if(!isnull(k_tech[req]) && k_tech[req] >= D.req_tech[req])
matches++
if(matches == D.req_tech.len)
return 1
else
return 0
/* /*
//Checks to see if design has all the required pre-reqs. //Checks to see if design has all the required pre-reqs.
//Input: datum/design; Output: 0/1 (false/true) //Input: datum/design; Output: 0/1 (false/true)
DesignHasReqs(var/datum/design/D) /datum/research/proc/DesignHasReqs(var/datum/design/D)
if(D.req_tech.len == 0) if(D.req_tech.len == 0)
return 1 return 1
var/matches = 0 var/matches = 0
for(var/req in D.req_tech) for(var/req in D.req_tech)
for(var/datum/tech/known in known_tech) for(var/datum/tech/known in known_tech)
if((req == known.id) && (known.level >= D.req_tech[req])) if((req == known.id) && (known.level >= D.req_tech[req]))
matches++ matches++
break break
if(matches == D.req_tech.len) if(matches == D.req_tech.len)
return 1 return 1
else else
return 0 return 0
*/ */
//Adds a tech to known_tech list. Checks to make sure there aren't duplicates and updates existing tech's levels if needed. //Adds a tech to known_tech list. Checks to make sure there aren't duplicates and updates existing tech's levels if needed.
//Input: datum/tech; Output: Null //Input: datum/tech; Output: Null
AddTech2Known(var/datum/tech/T) /datum/research/proc/AddTech2Known(var/datum/tech/T)
for(var/datum/tech/known in known_tech) for(var/datum/tech/known in known_tech)
if(T.id == known.id) if(T.id == known.id)
if(T.level > known.level) if(T.level > known.level)
known.level = T.level known.level = T.level
return
known_tech += T
return return
known_tech += T
return
AddDesign2Known(var/datum/design/D) /datum/research/proc/AddDesign2Known(var/datum/design/D)
for(var/datum/design/known in known_designs) for(var/datum/design/known in known_designs)
if(D.id == known.id) if(D.id == known.id)
if(D.reliability_mod > known.reliability_mod) if(D.reliability_mod > known.reliability_mod)
known.reliability_mod = D.reliability_mod known.reliability_mod = D.reliability_mod
return
known_designs += D
return return
known_designs += D
return
//Refreshes known_tech and known_designs list. Then updates the reliability vars of the designs in the known_designs list. //Refreshes known_tech and known_designs list. Then updates the reliability vars of the designs in the known_designs list.
//Input/Output: n/a //Input/Output: n/a
RefreshResearch() /datum/research/proc/RefreshResearch()
for(var/datum/tech/PT in possible_tech) for(var/datum/tech/PT in possible_tech)
if(TechHasReqs(PT)) if(TechHasReqs(PT))
AddTech2Known(PT) AddTech2Known(PT)
for(var/datum/design/PD in possible_designs) for(var/datum/design/PD in possible_designs)
if(DesignHasReqs(PD)) if(DesignHasReqs(PD))
AddDesign2Known(PD) AddDesign2Known(PD)
for(var/datum/tech/T in known_tech) for(var/datum/tech/T in known_tech)
T = between(1,T.level,20) T = between(1,T.level,20)
for(var/datum/design/D in known_designs) for(var/datum/design/D in known_designs)
D.CalcReliability(known_tech) D.CalcReliability(known_tech)
return return
//Refreshes the levels of a given tech. //Refreshes the levels of a given tech.
//Input: Tech's ID and Level; Output: null //Input: Tech's ID and Level; Output: null
UpdateTech(var/ID, var/level) /datum/research/proc/UpdateTech(var/ID, var/level)
for(var/datum/tech/KT in known_tech) for(var/datum/tech/KT in known_tech)
if(KT.id == ID) if(KT.id == ID)
if(KT.level <= level) KT.level = max((KT.level + 1), (level - 1)) if(KT.level <= level) KT.level = max((KT.level + 1), (level - 1))
return return
UpdateDesign(var/path) /datum/research/proc/UpdateDesign(var/path)
for(var/datum/design/KD in known_designs) for(var/datum/design/KD in known_designs)
if(KD.build_path == path) if(KD.build_path == path)
KD.reliability_mod += rand(1,2) KD.reliability_mod += rand(1,2)
break break
return return
@@ -168,92 +168,92 @@ research holder datum.
** Includes all the various technoliges and what they make. ** ** Includes all the various technoliges and what they make. **
***************************************************************/ ***************************************************************/
datum datum/tech //Datum of individual technologies.
tech //Datum of individual technologies. var/name = "name" //Name of the technology.
var var/desc = "description" //General description of what it does and what it makes.
name = "name" //Name of the technology. var/id = "id" //An easily referenced ID. Must be alphanumeric, lower-case, and no symbols.
desc = "description" //General description of what it does and what it makes. var/level = 1 //A simple number scale of the research level. Level 0 = Secret tech.
id = "id" //An easily referenced ID. Must be alphanumeric, lower-case, and no symbols. var/list/req_tech = list() //List of ids associated values of techs required to research this tech. "id" = #
level = 1 //A simple number scale of the research level. Level 0 = Secret tech.
list/req_tech = list() //List of ids associated values of techs required to research this tech. "id" = #
//Trunk Technologies (don't require any other techs and you start knowning them). //Trunk Technologies (don't require any other techs and you start knowning them).
materials datum/tech/materials
name = "Materials Research" name = "Materials Research"
desc = "Development of new and improved materials." desc = "Development of new and improved materials."
id = "materials" id = "materials"
engineering datum/tech/engineering
name = "Engineering Research" name = "Engineering Research"
desc = "Development of new and improved engineering parts and." desc = "Development of new and improved engineering parts and."
id = "engineering" id = "engineering"
plasmatech datum/tech/plasmatech
name = "Plasma Research" name = "Plasma Research"
desc = "Research into the mysterious substance colloqually known as 'plasma'." desc = "Research into the mysterious substance colloqually known as 'plasma'."
id = "plasmatech" id = "plasmatech"
powerstorage datum/tech/powerstorage
name = "Power Manipulation Technology" name = "Power Manipulation Technology"
desc = "The various technologies behind the storage and generation of electicity." desc = "The various technologies behind the storage and generation of electicity."
id = "powerstorage" id = "powerstorage"
bluespace datum/tech/bluespace
name = "'Blue-space' Research" name = "'Blue-space' Research"
desc = "Research into the sub-reality known as 'blue-space'" desc = "Research into the sub-reality known as 'blue-space'"
id = "bluespace" id = "bluespace"
biotech datum/tech/biotech
name = "Biological Technology" name = "Biological Technology"
desc = "Research into the deeper mysteries of life and organic substances." desc = "Research into the deeper mysteries of life and organic substances."
id = "biotech" id = "biotech"
combat datum/tech/combat
name = "Combat Systems Research" name = "Combat Systems Research"
desc = "The development of offensive and defensive systems." desc = "The development of offensive and defensive systems."
id = "combat" id = "combat"
magnets datum/tech/magnets
name = "Electromagnetic Spectrum Research" name = "Electromagnetic Spectrum Research"
desc = "Research into the electromagnetic spectrum. No clue how they actually work, though." desc = "Research into the electromagnetic spectrum. No clue how they actually work, though."
id = "magnets" id = "magnets"
programming datum/tech/programming
name = "Data Theory Research" name = "Data Theory Research"
desc = "The development of new computer and artificial intelligence and data storage systems." desc = "The development of new computer and artificial intelligence and data storage systems."
id = "programming" id = "programming"
syndicate datum/tech/syndicate
name = "Illegal Technologies Research" name = "Illegal Technologies Research"
desc = "The study of technologies that violate Nanotrassen regulations." desc = "The study of technologies that violate Nanotrassen regulations."
id = "syndicate" id = "syndicate"
/* arcane /*
name = "Arcane Research" datum/tech/arcane
desc = "Research into the acult and arcane field for use in practical science" name = "Arcane Research"
id = "arcane" desc = "Research into the acult and arcane field for use in practical science"
level = 0 //It didn't become "secret" as advertised. id = "arcane"
level = 0 //It didn't become "secret" as advertised.
//Branch Techs //Branch Techs
explosives datum/tech/explosives
name = "Explosives Research" name = "Explosives Research"
desc = "The creation and application of explosive materials." desc = "The creation and application of explosive materials."
id = "explosives" id = "explosives"
req_tech = list("materials" = 3) req_tech = list("materials" = 3)
generators datum/tech/generators
name = "Power Generation Technology" name = "Power Generation Technology"
desc = "Research into more powerful and more reliable sources." desc = "Research into more powerful and more reliable sources."
id = "generators" id = "generators"
req_tech = list("powerstorage" = 2) req_tech = list("powerstorage" = 2)
robotics datum/tech/robotics
name = "Robotics Technology" name = "Robotics Technology"
desc = "The development of advanced automated, autonomous machines." desc = "The development of advanced automated, autonomous machines."
id = "robotics" id = "robotics"
req_tech = list("materials" = 3, "programming" = 3)*/ req_tech = list("materials" = 3, "programming" = 3)
*/
/obj/item/weapon/disk/tech_disk /obj/item/weapon/disk/tech_disk
@@ -266,6 +266,7 @@ datum
m_amt = 30 m_amt = 30
g_amt = 10 g_amt = 10
var/datum/tech/stored var/datum/tech/stored
New()
src.pixel_x = rand(-5.0, 5) /obj/item/weapon/disk/tech_disk/New()
src.pixel_y = rand(-5.0, 5) src.pixel_x = rand(-5.0, 5)
src.pixel_y = rand(-5.0, 5)

View File

@@ -2,371 +2,372 @@
name = "R&D Server" name = "R&D Server"
icon = 'icons/obj/machines/research.dmi' icon = 'icons/obj/machines/research.dmi'
icon_state = "server" icon_state = "server"
var var/datum/research/files
datum/research/files var/health = 100
health = 100 var/list/id_with_upload = list() //List of R&D consoles with upload to server access.
list var/list/id_with_download = list() //List of R&D consoles with download from server access.
id_with_upload = list() //List of R&D consoles with upload to server access. var/id_with_upload_string = "" //String versions for easy editing in map editor.
id_with_download = list() //List of R&D consoles with download from server access. var/id_with_download_string = ""
id_with_upload_string = "" //String versions for easy editing in map editor. var/server_id = 0
id_with_download_string = "" var/heat_gen = 100
server_id = 0 var/heating_power = 40000
heat_gen = 100 var/delay = 10
heating_power = 40000
delay = 10
req_access = list(access_rd) //Only the R&D can change server settings. req_access = list(access_rd) //Only the R&D can change server settings.
New() /obj/machinery/r_n_d/server/New()
..() ..()
component_parts = list() component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/rdserver(src) component_parts += new /obj/item/weapon/circuitboard/rdserver(src)
component_parts += new /obj/item/weapon/stock_parts/scanning_module(src) component_parts += new /obj/item/weapon/stock_parts/scanning_module(src)
component_parts += new /obj/item/weapon/cable_coil(src) component_parts += new /obj/item/weapon/cable_coil(src)
component_parts += new /obj/item/weapon/cable_coil(src) component_parts += new /obj/item/weapon/cable_coil(src)
RefreshParts()
src.initialize(); //Agouri
Del()
griefProtection()
..()
RefreshParts() RefreshParts()
var/tot_rating = 0 src.initialize(); //Agouri
for(var/obj/item/weapon/stock_parts/SP in src)
tot_rating += SP.rating
heat_gen /= max(1, tot_rating)
initialize() /obj/machinery/r_n_d/server/Del()
if(!files) files = new /datum/research(src) griefProtection()
var/list/temp_list ..()
if(!id_with_upload.len)
temp_list = list()
temp_list = dd_text2list(id_with_upload_string, ";")
for(var/N in temp_list)
id_with_upload += text2num(N)
if(!id_with_download.len)
temp_list = list()
temp_list = dd_text2list(id_with_download_string, ";")
for(var/N in temp_list)
id_with_download += text2num(N)
process() /obj/machinery/r_n_d/server/RefreshParts()
var/datum/gas_mixture/environment = loc.return_air() var/tot_rating = 0
switch(environment.temperature) for(var/obj/item/weapon/stock_parts/SP in src)
if(0 to T0C) tot_rating += SP.rating
health = min(100, health + 1) heat_gen /= max(1, tot_rating)
if(T0C to (T20C + 20))
health = between(0, health, 100)
if((T20C + 20) to (T0C + 70))
health = max(0, health - 1)
if(health <= 0)
griefProtection() //I dont like putting this in process() but it's the best I can do without re-writing a chunk of rd servers.
files.known_designs = list()
for(var/datum/tech/T in files.known_tech)
if(prob(1))
T.level--
files.RefreshResearch()
if(delay)
delay--
else
produce_heat(heat_gen)
delay = initial(delay)
meteorhit(var/obj/O as obj) /obj/machinery/r_n_d/server/initialize()
griefProtection() if(!files) files = new /datum/research(src)
..() var/list/temp_list
if(!id_with_upload.len)
temp_list = list()
temp_list = dd_text2list(id_with_upload_string, ";")
for(var/N in temp_list)
id_with_upload += text2num(N)
if(!id_with_download.len)
temp_list = list()
temp_list = dd_text2list(id_with_download_string, ";")
for(var/N in temp_list)
id_with_download += text2num(N)
/obj/machinery/r_n_d/server/process()
var/datum/gas_mixture/environment = loc.return_air()
switch(environment.temperature)
if(0 to T0C)
health = min(100, health + 1)
if(T0C to (T20C + 20))
health = between(0, health, 100)
if((T20C + 20) to (T0C + 70))
health = max(0, health - 1)
if(health <= 0)
griefProtection() //I dont like putting this in process() but it's the best I can do without re-writing a chunk of rd servers.
files.known_designs = list()
for(var/datum/tech/T in files.known_tech)
if(prob(1))
T.level--
files.RefreshResearch()
if(delay)
delay--
else
produce_heat(heat_gen)
delay = initial(delay)
/obj/machinery/r_n_d/server/meteorhit(var/obj/O as obj)
griefProtection()
..()
emp_act(severity) /obj/machinery/r_n_d/server/emp_act(severity)
griefProtection() griefProtection()
..() ..()
ex_act(severity) /obj/machinery/r_n_d/server/ex_act(severity)
griefProtection() griefProtection()
..() ..()
blob_act() /obj/machinery/r_n_d/server/blob_act()
griefProtection() griefProtection()
..() ..()
proc /obj/machinery/r_n_d/server/proc/
//Backup files to centcomm to help admins recover data after greifer attacks //Backup files to centcomm to help admins recover data after greifer attacks
griefProtection() /obj/machinery/r_n_d/server/proc/griefProtection()
for(var/obj/machinery/r_n_d/server/centcom/C in world) for(var/obj/machinery/r_n_d/server/centcom/C in world)
for(var/datum/tech/T in files.known_tech) for(var/datum/tech/T in files.known_tech)
C.files.AddTech2Known(T) C.files.AddTech2Known(T)
for(var/datum/design/D in files.known_designs) for(var/datum/design/D in files.known_designs)
C.files.AddDesign2Known(D) C.files.AddDesign2Known(D)
C.files.RefreshResearch() C.files.RefreshResearch()
produce_heat(heat_amt) /obj/machinery/r_n_d/server/proc/produce_heat(heat_amt)
if(!(stat & (NOPOWER|BROKEN))) //Blatently stolen from space heater. if(!(stat & (NOPOWER|BROKEN))) //Blatently stolen from space heater.
var/turf/simulated/L = loc var/turf/simulated/L = loc
if(istype(L)) if(istype(L))
var/datum/gas_mixture/env = L.return_air() var/datum/gas_mixture/env = L.return_air()
if(env.temperature < (heat_amt+T0C)) if(env.temperature < (heat_amt+T0C))
var/transfer_moles = 0.25 * env.total_moles() var/transfer_moles = 0.25 * env.total_moles()
var/datum/gas_mixture/removed = env.remove(transfer_moles) var/datum/gas_mixture/removed = env.remove(transfer_moles)
if(removed) if(removed)
var/heat_capacity = removed.heat_capacity() var/heat_capacity = removed.heat_capacity()
if(heat_capacity == 0 || heat_capacity == null) if(heat_capacity == 0 || heat_capacity == null)
heat_capacity = 1 heat_capacity = 1
removed.temperature = min((removed.temperature*heat_capacity + heating_power)/heat_capacity, 1000) removed.temperature = min((removed.temperature*heat_capacity + heating_power)/heat_capacity, 1000)
env.merge(removed) env.merge(removed)
attackby(var/obj/item/O as obj, var/mob/user as mob) /obj/machinery/r_n_d/server/attackby(var/obj/item/O as obj, var/mob/user as mob)
if (disabled) if (disabled)
return
if (shocked)
shock(user,50)
if (istype(O, /obj/item/weapon/screwdriver))
if (!opened)
opened = 1
icon_state = "server_o"
user << "You open the maintenance hatch of [src]."
else
opened = 0
icon_state = "server"
user << "You close the maintenance hatch of [src]."
return
if (opened)
if(istype(O, /obj/item/weapon/crowbar))
griefProtection()
playsound(src.loc, 'Crowbar.ogg', 50, 1)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 2
M.icon_state = "box_1"
for(var/obj/I in component_parts)
if(I.reliability != 100 && crit_fail)
I.crit_fail = 1
I.loc = src.loc
del(src)
return 1
attack_hand(mob/user as mob)
if (disabled)
return
if (shocked)
shock(user,50)
if(ishuman(user))
if(istype(user:gloves, /obj/item/clothing/gloves/space_ninja)&&user:gloves:candrain&&!user:gloves:draining)
call(/obj/item/clothing/gloves/space_ninja/proc/drain)("RESEARCH",src,user:wear_suit)
return return
if (shocked)
shock(user,50)
if (istype(O, /obj/item/weapon/screwdriver))
if (!opened)
opened = 1
icon_state = "server_o"
user << "You open the maintenance hatch of [src]."
else
opened = 0
icon_state = "server"
user << "You close the maintenance hatch of [src]."
return
if (opened)
if(istype(O, /obj/item/weapon/crowbar))
griefProtection()
playsound(src.loc, 'Crowbar.ogg', 50, 1)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 2
M.icon_state = "box_1"
for(var/obj/I in component_parts)
if(I.reliability != 100 && crit_fail)
I.crit_fail = 1
I.loc = src.loc
del(src)
return 1
/obj/machinery/r_n_d/server/attack_hand(mob/user as mob)
if (disabled)
return
if (shocked)
shock(user,50)
if(ishuman(user))
if(istype(user:gloves, /obj/item/clothing/gloves/space_ninja)&&user:gloves:candrain&&!user:gloves:draining)
call(/obj/item/clothing/gloves/space_ninja/proc/drain)("RESEARCH",src,user:wear_suit)
return
/obj/machinery/r_n_d/server/centcom /obj/machinery/r_n_d/server/centcom
name = "Centcom Central R&D Database" name = "Centcom Central R&D Database"
server_id = -1 server_id = -1
initialize() /obj/machinery/r_n_d/server/centcom/initialize()
..() ..()
var/list/no_id_servers = list() var/list/no_id_servers = list()
var/list/server_ids = list() var/list/server_ids = list()
for(var/obj/machinery/r_n_d/server/S in world) for(var/obj/machinery/r_n_d/server/S in world)
switch(S.server_id) switch(S.server_id)
if(-1) if(-1)
continue continue
if(0) if(0)
no_id_servers += S no_id_servers += S
else else
server_ids += S.server_id server_ids += S.server_id
for(var/obj/machinery/r_n_d/server/S in no_id_servers) for(var/obj/machinery/r_n_d/server/S in no_id_servers)
var/num = 1 var/num = 1
while(!S.server_id) while(!S.server_id)
if(num in server_ids) if(num in server_ids)
num++ num++
else else
S.server_id = num S.server_id = num
server_ids += num server_ids += num
no_id_servers -= S no_id_servers -= S
/obj/machinery/r_n_d/server/centcom/process()
return
process()
return
/obj/machinery/computer/rdservercontrol /obj/machinery/computer/rdservercontrol
name = "R&D Server Controller" name = "R&D Server Controller"
icon_state = "rdcomp" icon_state = "rdcomp"
var var/screen = 0
var/obj/machinery/r_n_d/server/temp_server
var/list/servers = list()
var/list/consoles = list()
var/badmin = 0
/obj/machinery/computer/rdservercontrol/Topic(href, href_list)
if(..())
return
add_fingerprint(usr)
usr.machine = src
if(!src.allowed(usr) && !emagged)
usr << "\red You do not have the required access level"
return
if(href_list["main"])
screen = 0 screen = 0
obj/machinery/r_n_d/server/temp_server
list
servers = list()
consoles = list()
badmin = 0
Topic(href, href_list) else if(href_list["access"] || href_list["data"] || href_list["transfer"])
if(..()) temp_server = null
return consoles = list()
servers = list()
add_fingerprint(usr) for(var/obj/machinery/r_n_d/server/S in world)
usr.machine = src if(S.server_id == text2num(href_list["access"]) || S.server_id == text2num(href_list["data"]) || S.server_id == text2num(href_list["transfer"]))
if(!src.allowed(usr) && !emagged) temp_server = S
usr << "\red You do not have the required access level" break
return if(href_list["access"])
screen = 1
if(href_list["main"]) for(var/obj/machinery/computer/rdconsole/C in world)
screen = 0 if(C.sync)
consoles += C
else if(href_list["access"] || href_list["data"] || href_list["transfer"]) else if(href_list["data"])
temp_server = null screen = 2
consoles = list() else if(href_list["transfer"])
servers = list() screen = 3
for(var/obj/machinery/r_n_d/server/S in world) for(var/obj/machinery/r_n_d/server/S in world)
if(S.server_id == text2num(href_list["access"]) || S.server_id == text2num(href_list["data"]) || S.server_id == text2num(href_list["transfer"])) if(S == src)
temp_server = S continue
servers += S
else if(href_list["upload_toggle"])
var/num = text2num(href_list["upload_toggle"])
if(num in temp_server.id_with_upload)
temp_server.id_with_upload -= num
else
temp_server.id_with_upload += num
else if(href_list["download_toggle"])
var/num = text2num(href_list["download_toggle"])
if(num in temp_server.id_with_download)
temp_server.id_with_download -= num
else
temp_server.id_with_download += num
else if(href_list["reset_tech"])
var/choice = alert("Technology Data Rest", "Are you sure you want to reset this technology to its default data? Data lost cannot be recovered.", "Continue", "Cancel")
if(choice == "Continue")
for(var/datum/tech/T in temp_server.files.known_tech)
if(T.id == href_list["reset_tech"])
T.level = 1
break break
if(href_list["access"]) temp_server.files.RefreshResearch()
screen = 1
for(var/obj/machinery/computer/rdconsole/C in world)
if(C.sync)
consoles += C
else if(href_list["data"])
screen = 2
else if(href_list["transfer"])
screen = 3
for(var/obj/machinery/r_n_d/server/S in world)
if(S == src)
continue
servers += S
else if(href_list["upload_toggle"]) else if(href_list["reset_design"])
var/num = text2num(href_list["upload_toggle"]) var/choice = alert("Design Data Deletion", "Are you sure you want to delete this design? If you still have the prerequisites for the design, it'll reset to its base reliability. Data lost cannot be recovered.", "Continue", "Cancel")
if(num in temp_server.id_with_upload) if(choice == "Continue")
temp_server.id_with_upload -= num for(var/datum/design/D in temp_server.files.known_designs)
else if(D.id == href_list["reset_design"])
temp_server.id_with_upload += num D.reliability_mod = 0
temp_server.files.known_designs -= D
break
temp_server.files.RefreshResearch()
else if(href_list["download_toggle"]) updateUsrDialog()
var/num = text2num(href_list["download_toggle"]) return
if(num in temp_server.id_with_download)
temp_server.id_with_download -= num
else
temp_server.id_with_download += num
else if(href_list["reset_tech"]) /obj/machinery/computer/rdservercontrol/attack_hand(mob/user as mob)
var/choice = alert("Technology Data Rest", "Are you sure you want to reset this technology to its default data? Data lost cannot be recovered.", "Continue", "Cancel") if(stat & (BROKEN|NOPOWER))
if(choice == "Continue")
for(var/datum/tech/T in temp_server.files.known_tech)
if(T.id == href_list["reset_tech"])
T.level = 1
break
temp_server.files.RefreshResearch()
else if(href_list["reset_design"])
var/choice = alert("Design Data Deletion", "Are you sure you want to delete this design? If you still have the prerequisites for the design, it'll reset to its base reliability. Data lost cannot be recovered.", "Continue", "Cancel")
if(choice == "Continue")
for(var/datum/design/D in temp_server.files.known_designs)
if(D.id == href_list["reset_design"])
D.reliability_mod = 0
temp_server.files.known_designs -= D
break
temp_server.files.RefreshResearch()
updateUsrDialog()
return return
user.machine = src
var/dat = ""
attack_hand(mob/user as mob) switch(screen)
if(stat & (BROKEN|NOPOWER)) if(0) //Main Menu
return dat += "Connected Servers:<BR><BR>"
user.machine = src
var/dat = ""
switch(screen) for(var/obj/machinery/r_n_d/server/S in world)
if(0) //Main Menu if(istype(S, /obj/machinery/r_n_d/server/centcom) && !badmin)
dat += "Connected Servers:<BR><BR>" continue
dat += "[S.name] || "
dat += "<A href='?src=\ref[src];access=[S.server_id]'> Access Rights</A> | "
dat += "<A href='?src=\ref[src];data=[S.server_id]'>Data Management</A>"
if(badmin) dat += " | <A href='?src=\ref[src];transfer=[S.server_id]'>Server-to-Server Transfer</A>"
dat += "<BR>"
for(var/obj/machinery/r_n_d/server/S in world) if(1) //Access rights menu
if(istype(S, /obj/machinery/r_n_d/server/centcom) && !badmin) dat += "[temp_server.name] Access Rights<BR><BR>"
continue dat += "Consoles with Upload Access<BR>"
dat += "[S.name] || " for(var/obj/machinery/computer/rdconsole/C in consoles)
dat += "<A href='?src=\ref[src];access=[S.server_id]'> Access Rights</A> | " var/turf/console_turf = get_turf(C)
dat += "<A href='?src=\ref[src];data=[S.server_id]'>Data Management</A>" dat += "* <A href='?src=\ref[src];upload_toggle=[C.id]'>[console_turf.loc]" //FYI, these are all numeric ids, eventually.
if(badmin) dat += " | <A href='?src=\ref[src];transfer=[S.server_id]'>Server-to-Server Transfer</A>" if(C.id in temp_server.id_with_upload)
dat += "<BR>" dat += " (Remove)</A><BR>"
if(1) //Access rights menu
dat += "[temp_server.name] Access Rights<BR><BR>"
dat += "Consoles with Upload Access<BR>"
for(var/obj/machinery/computer/rdconsole/C in consoles)
var/turf/console_turf = get_turf(C)
dat += "* <A href='?src=\ref[src];upload_toggle=[C.id]'>[console_turf.loc]" //FYI, these are all numeric ids, eventually.
if(C.id in temp_server.id_with_upload)
dat += " (Remove)</A><BR>"
else
dat += " (Add)</A><BR>"
dat += "Consoles with Download Access<BR>"
for(var/obj/machinery/computer/rdconsole/C in consoles)
var/turf/console_turf = get_turf(C)
dat += "* <A href='?src=\ref[src];download_toggle=[C.id]'>[console_turf.loc]"
if(C.id in temp_server.id_with_download)
dat += " (Remove)</A><BR>"
else
dat += " (Add)</A><BR>"
dat += "<HR><A href='?src=\ref[src];main=1'>Main Menu</A>"
if(2) //Data Management menu
dat += "[temp_server.name] Data ManagementP<BR><BR>"
dat += "Known Technologies<BR>"
for(var/datum/tech/T in temp_server.files.known_tech)
dat += "* [T.name] "
dat += "<A href='?src=\ref[src];reset_tech=[T.id]'>(Reset)</A><BR>" //FYI, these are all strings.
dat += "Known Designs<BR>"
for(var/datum/design/D in temp_server.files.known_designs)
dat += "* [D.name] "
dat += "<A href='?src=\ref[src];reset_design=[D.id]'>(Delete)</A><BR>"
dat += "<HR><A href='?src=\ref[src];main=1'>Main Menu</A>"
if(3) //Server Data Transfer
dat += "[temp_server.name] Server to Server Transfer<BR><BR>"
dat += "Send Data to what server?<BR>"
for(var/obj/machinery/r_n_d/server/S in servers)
dat += "[S.name] <A href='?src=\ref[src];send_to=[S.server_id]'> (Transfer)</A><BR>"
dat += "<HR><A href='?src=\ref[src];main=1'>Main Menu</A>"
user << browse("<TITLE>R&D Server Control</TITLE><HR>[dat]", "window=server_control;size=575x400")
onclose(user, "server_control")
return
attackby(var/obj/item/weapon/D as obj, var/mob/user as mob)
if(istype(D, /obj/item/weapon/screwdriver))
playsound(src.loc, 'Screwdriver.ogg', 50, 1)
if(do_after(user, 20))
if (src.stat & BROKEN)
user << "\blue The broken glass falls out."
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
new /obj/item/weapon/shard( src.loc )
var/obj/item/weapon/circuitboard/rdservercontrol/M = new /obj/item/weapon/circuitboard/rdservercontrol( A )
for (var/obj/C in src)
C.loc = src.loc
A.circuit = M
A.state = 3
A.icon_state = "3"
A.anchored = 1
del(src)
else else
user << "\blue You disconnect the monitor." dat += " (Add)</A><BR>"
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc ) dat += "Consoles with Download Access<BR>"
var/obj/item/weapon/circuitboard/rdservercontrol/M = new /obj/item/weapon/circuitboard/rdservercontrol( A ) for(var/obj/machinery/computer/rdconsole/C in consoles)
for (var/obj/C in src) var/turf/console_turf = get_turf(C)
C.loc = src.loc dat += "* <A href='?src=\ref[src];download_toggle=[C.id]'>[console_turf.loc]"
A.circuit = M if(C.id in temp_server.id_with_download)
A.state = 4 dat += " (Remove)</A><BR>"
A.icon_state = "4" else
A.anchored = 1 dat += " (Add)</A><BR>"
del(src) dat += "<HR><A href='?src=\ref[src];main=1'>Main Menu</A>"
else if(istype(D, /obj/item/weapon/card/emag) && !emagged)
playsound(src.loc, 'sparks4.ogg', 75, 1) if(2) //Data Management menu
emagged = 1 dat += "[temp_server.name] Data ManagementP<BR><BR>"
user << "\blue You you disable the security protocols" dat += "Known Technologies<BR>"
src.updateUsrDialog() for(var/datum/tech/T in temp_server.files.known_tech)
return dat += "* [T.name] "
dat += "<A href='?src=\ref[src];reset_tech=[T.id]'>(Reset)</A><BR>" //FYI, these are all strings.
dat += "Known Designs<BR>"
for(var/datum/design/D in temp_server.files.known_designs)
dat += "* [D.name] "
dat += "<A href='?src=\ref[src];reset_design=[D.id]'>(Delete)</A><BR>"
dat += "<HR><A href='?src=\ref[src];main=1'>Main Menu</A>"
if(3) //Server Data Transfer
dat += "[temp_server.name] Server to Server Transfer<BR><BR>"
dat += "Send Data to what server?<BR>"
for(var/obj/machinery/r_n_d/server/S in servers)
dat += "[S.name] <A href='?src=\ref[src];send_to=[S.server_id]'> (Transfer)</A><BR>"
dat += "<HR><A href='?src=\ref[src];main=1'>Main Menu</A>"
user << browse("<TITLE>R&D Server Control</TITLE><HR>[dat]", "window=server_control;size=575x400")
onclose(user, "server_control")
return
/obj/machinery/computer/rdservercontrol/attackby(var/obj/item/weapon/D as obj, var/mob/user as mob)
if(istype(D, /obj/item/weapon/screwdriver))
playsound(src.loc, 'Screwdriver.ogg', 50, 1)
if(do_after(user, 20))
if (src.stat & BROKEN)
user << "\blue The broken glass falls out."
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
new /obj/item/weapon/shard( src.loc )
var/obj/item/weapon/circuitboard/rdservercontrol/M = new /obj/item/weapon/circuitboard/rdservercontrol( A )
for (var/obj/C in src)
C.loc = src.loc
A.circuit = M
A.state = 3
A.icon_state = "3"
A.anchored = 1
del(src)
else
user << "\blue You disconnect the monitor."
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
var/obj/item/weapon/circuitboard/rdservercontrol/M = new /obj/item/weapon/circuitboard/rdservercontrol( A )
for (var/obj/C in src)
C.loc = src.loc
A.circuit = M
A.state = 4
A.icon_state = "4"
A.anchored = 1
del(src)
else if(istype(D, /obj/item/weapon/card/emag) && !emagged)
playsound(src.loc, 'sparks4.ogg', 75, 1)
emagged = 1
user << "\blue You you disable the security protocols"
src.updateUsrDialog()
return
/obj/machinery/r_n_d/server/robotics /obj/machinery/r_n_d/server/robotics
name = "Robotics R&D Server" name = "Robotics R&D Server"
@@ -374,6 +375,7 @@
id_with_download_string = "1;2" id_with_download_string = "1;2"
server_id = 2 server_id = 2
/obj/machinery/r_n_d/server/core /obj/machinery/r_n_d/server/core
name = "Core R&D Server" name = "Core R&D Server"
id_with_upload_string = "1" id_with_upload_string = "1"