////////////////////////////////////
///// Rendering stats window ///////
////////////////////////////////////
/obj/mecha/proc/get_stats_html()
. = {"
[src.name] data
[src.get_stats_part()]
[src.get_equipment_list()]
[src.get_commands()]
"}
/obj/mecha/proc/report_internal_damage()
. = ""
var/list/dam_reports = list(
"[MECHA_INT_FIRE]" = "INTERNAL FIRE",
"[MECHA_INT_TEMP_CONTROL]" = "LIFE SUPPORT SYSTEM MALFUNCTION",
"[MECHA_INT_TANK_BREACH]" = "GAS TANK BREACH",
"[MECHA_INT_CONTROL_LOST]" = "COORDINATION SYSTEM CALIBRATION FAILURE - Recalibrate",
"[MECHA_INT_SHORT_CIRCUIT]" = "SHORT CIRCUIT"
)
for(var/tflag in dam_reports)
var/intdamflag = text2num(tflag)
if(internal_damage & intdamflag)
. += dam_reports[tflag]
. += "
"
if(return_pressure() > WARNING_HIGH_PRESSURE)
. += "DANGEROUSLY HIGH CABIN PRESSURE
"
/obj/mecha/proc/get_stats_part()
var/integrity = obj_integrity/max_integrity*100
var/cell_charge = get_charge()
var/datum/gas_mixture/int_tank_air = internal_tank.return_air()
var/tank_pressure = internal_tank ? round(int_tank_air.return_pressure(),0.01) : "None"
var/tank_temperature = internal_tank ? int_tank_air.temperature : "Unknown"
var/cabin_pressure = round(return_pressure(),0.01)
. = {"[report_internal_damage()]
[integrity<30?"DAMAGE LEVEL CRITICAL
":null]
Integrity: [integrity]%
Powercell charge: [isnull(cell_charge)?"No powercell installed":"[cell.percent()]%"]
Air source: [use_internal_tank?"Internal Airtank":"Environment"]
Airtank pressure: [tank_pressure]kPa
Airtank temperature: [tank_temperature]°K|[tank_temperature - T0C]°C
Cabin pressure: [cabin_pressure>WARNING_HIGH_PRESSURE ? "[cabin_pressure]": cabin_pressure]kPa
Cabin temperature: [return_temperature()]°K|[return_temperature() - T0C]°C
[dna_lock?"DNA-locked:
[dna_lock] \[Reset\]
":""]
[thrusters_action.owner ? "Thrusters: [thrusters_active ? "Enabled" : "Disabled"]
" : ""]
[defense_action.owner ? "Defence Mode: [defence_mode ? "Enabled" : "Disabled"]
" : ""]
[overload_action.owner ? "Leg Actuators Overload: [leg_overload_mode ? "Enabled" : "Disabled"]
" : ""]
[smoke_action.owner ? "Smoke: [smoke]
" : ""]
[zoom_action.owner ? "Zoom: [zoom_mode ? "Enabled" : "Disabled"]
" : ""]
[switch_damtype_action.owner ? "Damtype: [damtype]
" : ""]
[phasing_action.owner ? "Phase Modulator: [phasing ? "Enabled" : "Disabled"]
" : ""]
"}
/obj/mecha/proc/get_commands()
. = {"
"}
/obj/mecha/proc/get_equipment_menu() //outputs mecha html equipment menu
. = ""
if(equipment.len)
. += {"
"}
for(var/X in equipment)
var/obj/item/mecha_parts/mecha_equipment/W = X
. += "[W.name]
Detach"
. += "
Available equipment slots: [max_equip-equipment.len]"
. += "
"
/obj/mecha/proc/get_equipment_list() //outputs mecha equipment list in html
if(!equipment.len)
return
. = "Equipment:"
for(var/obj/item/mecha_parts/mecha_equipment/MT in equipment)
. += "
[MT.get_equip_info()]
"
. += "
"
/obj/mecha/proc/get_log_html()
. = "[src.name] Log"
for(var/list/entry in log)
. += {"[entry["time"]] [time2text(entry["date"],"MMM DD")] [entry["year"]]
[entry["message"]]
"}
. += ""
/obj/mecha/proc/output_access_dialog(obj/item/card/id/id_card, mob/user)
if(!id_card || !user)
return
. = {"
Following keycodes are present in this system:
"}
for(var/a in operation_req_access)
. += "[get_access_desc(a)] - Delete
"
. += "
Following keycodes were detected on portable device:
"
for(var/a in id_card.access)
if(a in operation_req_access)
continue
var/a_name = get_access_desc(a)
if(!a_name)
continue //there's some strange access without a name
. += "[a_name] - Add
"
. += "
Finish "
. += "(Warning! The ID upload panel will be locked. It can be unlocked only through Exosuit Interface.)"
. += ""
user << browse(., "window=exosuit_add_access")
onclose(user, "exosuit_add_access")
/obj/mecha/proc/output_maintenance_dialog(obj/item/card/id/id_card,mob/user)
if(!id_card || !user)
return
. = {"
[add_req_access?"Edit operation keycodes":null]
[maint_access?"[(state>0) ? "Terminate" : "Initiate"] maintenance protocol":null]
[(state>0) ?"Set Cabin Air Pressure":null]
"}
user << browse(., "window=exosuit_maint_console")
onclose(user, "exosuit_maint_console")
/////////////////
///// Topic /////
/////////////////
/obj/mecha/Topic(href, href_list)
..()
if(href_list["close"])
return
if(usr.incapacitated())
return
if(in_range(src, usr))
var/obj/item/card/id/id_card
if (href_list["id_card"])
id_card = locate(href_list["id_card"])
if (!istype(id_card))
return
if(href_list["req_access"] && add_req_access)
output_access_dialog(id_card, usr)
if(href_list["maint_access"] && maint_access)
if(state==0)
state = 1
to_chat(usr, "The securing bolts are now exposed.")
else if(state==1)
state = 0
to_chat(usr, "The securing bolts are now hidden.")
output_maintenance_dialog(id_card, usr)
if(href_list["set_internal_tank_valve"] && state >=1)
var/new_pressure = input(usr,"Input new output pressure","Pressure setting",internal_tank_valve) as num
if(new_pressure)
internal_tank_valve = new_pressure
to_chat(usr, "The internal pressure valve has been set to [internal_tank_valve]kPa.")
if(href_list["add_req_access"] && add_req_access)
operation_req_access += text2num(href_list["add_req_access"])
output_access_dialog(id_card, usr)
if(href_list["del_req_access"] && add_req_access)
operation_req_access -= text2num(href_list["add_req_access"])
output_access_dialog(id_card, usr)
if(href_list["finish_req_access"])
add_req_access = 0
usr << browse(null,"window=exosuit_add_access")
if(usr != occupant)
return
if(href_list["update_content"])
send_byjax(usr,"exosuit.browser","content",src.get_stats_part())
if(href_list["select_equip"])
var/obj/item/mecha_parts/mecha_equipment/equip = locate(href_list["select_equip"]) in src
if(equip && equip.selectable)
selected = equip
occupant_message("You switch to [equip]")
visible_message("[src] raises [equip]")
send_byjax(usr, "exosuit.browser","eq_list", get_equipment_list())
if(href_list["rmictoggle"])
radio.broadcasting = !radio.broadcasting
send_byjax(usr,"exosuit.browser","rmicstate",(radio.broadcasting?"Engaged":"Disengaged"))
if(href_list["rspktoggle"])
radio.listening = !radio.listening
send_byjax(usr,"exosuit.browser","rspkstate",(radio.listening?"Engaged":"Disengaged"))
if(href_list["rfreq"])
var/new_frequency = (radio.frequency + text2num(href_list["rfreq"]))
if (!radio.freerange || (radio.frequency < MIN_FREE_FREQ || radio.frequency > MAX_FREE_FREQ))
new_frequency = sanitize_frequency(new_frequency)
radio.set_frequency(new_frequency)
send_byjax(usr,"exosuit.browser","rfreq","[format_frequency(radio.frequency)]")
if (href_list["view_log"])
src.occupant << browse(src.get_log_html(), "window=exosuit_log")
onclose(occupant, "exosuit_log")
if (href_list["change_name"])
var/userinput = stripped_input(occupant,"Choose new exosuit name","Rename exosuit","", MAX_NAME_LEN)
if(!userinput || usr != occupant || usr.incapacitated())
return
name = userinput
return
if (href_list["toggle_id_upload"])
add_req_access = !add_req_access
send_byjax(usr,"exosuit.browser","t_id_upload","[add_req_access?"L":"Unl"]ock ID upload panel")
if(href_list["toggle_maint_access"])
if(state)
occupant_message("Maintenance protocols in effect")
return
maint_access = !maint_access
send_byjax(usr,"exosuit.browser","t_maint_access","[maint_access?"Forbid":"Permit"] maintenance protocols")
if (href_list["toggle_port_connection"])
if(internal_tank.connected_port)
if(internal_tank.disconnect())
occupant_message("Disconnected from the air system port.")
mecha_log_message("Disconnected from gas port.")
else
occupant_message("Unable to disconnect from the air system port!")
return
else
var/obj/machinery/atmospherics/components/unary/portables_connector/possible_port = locate() in loc
if(internal_tank.connect(possible_port))
occupant_message("Connected to the air system port.")
mecha_log_message("Connected to gas port.")
else
occupant_message("Unable to connect with air system port!")
return
send_byjax(occupant,"exosuit.browser","t_port_connection","[internal_tank.connected_port?"Disconnect from":"Connect to"] gas port")
if(href_list["dna_lock"])
if(occupant && !iscarbon(occupant))
to_chat(occupant, " You do not have any DNA!")
return
dna_lock = occupant.dna.unique_enzymes
occupant_message("You feel a prick as the needle takes your DNA sample.")
if(href_list["reset_dna"])
dna_lock = null
if(href_list["repair_int_control_lost"])
occupant_message("Recalibrating coordination system...")
mecha_log_message("Recalibration of coordination system started.")
var/T = loc
spawn(100)
if(T == loc)
clearInternalDamage(MECHA_INT_CONTROL_LOST)
occupant_message("Recalibration successful.")
mecha_log_message("Recalibration of coordination system finished with 0 errors.")
else
occupant_message("Recalibration failed!")
mecha_log_message("Recalibration of coordination system failed with 1 error.", color="red")